Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TABLE-001

A click on a pipe table cell opens a cell editor in place

When edit mode is on and the writer clicks a cell of a rendered pipe table, the extension SHALL open a region named "Markdown table cell editor" inside that cell, ask the host for the line range of the table block, and fill the cell text box with the raw Markdown of the cell or, when the block is not an editable pipe table, open the whole block in the raw Markdown editor.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TABLE-001: from “A pipe table is shown in edit mode” to “The cell editor is open”.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TABLE-008: from “A table is shown in edit mode” to “The cell editor is open”.

Scenarios 9

The situations the tests check; open one to read it.

nominalClick on a body cell
Givenedit mode on and a rendered pipe table with a header row and two body rows
Whenthe writer clicks the second cell of the first body row
Thena region named "Markdown table cell editor" is placed inside that cell and the page posts one previewEditOpen request with the line and end line of the table block
refusalEdit mode off
Givenedit mode off and a rendered pipe table
Whenthe reader clicks a cell
Thenno cell editor opens and no previewEditOpen is posted
nominalLoading status until the host sends the table source
Givena cell editor opened by a click and no previewEditSource answer yet
Whenthe cell editor region is read
the page receives the answer with the table text
Thenits only content is a status paragraph reading "Loading Markdown table source…", with no text box yet
the status is replaced by the text box and the table bar, and the status now shows the position of the cell
nominalThe clicked cell is selected and its rendered content keeps its width
Givena cell editor open in a 900 px pane
Whenthe page is inspected
the editor of that cell is closed by Escape
Thenthe cell carries the attribute data-sphinx-preview-table-cell-selected and an outline, and its rendered content is wrapped in an aria-hidden element of height 0 that is invisible but still takes its width, so the column widths do not change
the selected mark is removed and the rendered content is back in the cell
nominalThe text box holds the raw Markdown of the clicked cell
Giventhe table "| a | **y** |" over a delimiter row and a body row "| c | d |"
a cell written "| padded |"
Whenthe writer clicks the header cell "**y**" and, in another session, the body cell "d"
the cell is opened
Thenthe text box holds "**y**" (not the rendered bold text) for the header cell, which is the first model row, and "d" for the body cell, because the delimiter row is skipped when the rendered row is mapped to the model
the text box holds "padded": only the text between the delimiting pipes, trimmed
nominalA click opens the cell with the focus in the text box and the caret at the end
Givena cell containing "alpha"
an empty cell
Whenthe writer clicks the cell
the writer clicks it
Thenthe text box has the focus and the caret sits after the last character
the text box has the focus with the caret at position 0, which is also its end
nominalThe cell editor region shows no status hint
Givena cell editor open
the editor moved to another cell
Whenthe cell editor region and the table bar are read
the regions are read again
Thenthe region holds the text box and the buttons only, and the status paragraph is inside the table bar
the region still holds no status and the bar status shows the new position
boundaryOnly a well-formed pipe table opens a cell editor

A table is editable when it has a header row, a delimiter row whose cells are at least one dash with optional colons (the delimiter rule is /^:?-+:?$/ on each delimiter cell with spaces removed; when a delimiter cell has fewer than three dashes, the delimiter line holds a pipe), the same number of cells in the header and in the delimiter row, and in every body row at least as many cells as the header. The text of a body row after the closing pipe of the header's last column is the row tail (see SwRS-MDOKFSTUDIO-TABLE-094): the preview ignores it and the editor keeps it verbatim.

InputOutcome
"| a | b |\n|---|---|\n| c | d |"parses into rows of two cells and opens a cell editor
the same with colons (":---", "---:", ":---:")parses into rows of two cells and opens a cell editor
a table with no outer pipesparses into rows of two cells and opens a cell editor
a single lineparse returns no table, no cell editor is built
"| a | b |\n| :-- | --: |\n| c | d |"parses into rows of two cells and opens a cell editor, the delimiter row is left as written by a cell edit
"| a | b |\n|-|-|\n| c | d |"parses into rows of two cells and opens a cell editor
a line over a "--" line with no pipe (a setext heading)parse returns no table, no cell editor is built
a header or a delimiter row with an extra cellparse returns no table, no cell editor is built
a body row with fewer cells than the headerparse returns no table, no cell editor is built
a body row with text after the closing pipe of its last column, such as "| a | 1 | ^row-a"parses into rows of the header's cells; the text after the closing pipe is kept as the row tail and a cell editor opens; saving keeps the tail verbatim at the end of its line
refusalA block that is no editable pipe table opens in the raw Markdown editor
InputOutcome
a cell of a rendered MyST list-table that is not plain (see SwRS-MDOKFSTUDIO-TABLE-055), a raw HTML table or a table inside a {table} directive, in edit mode, after the host sends the block sourcethe cell shows its rendered content again, the region is renamed "Raw Markdown editor" and a text box labelled "Raw Markdown block" holds the whole block source and the region leaves the cell and sits after the table, which is hidden while its source is edited, so the editor stays in view
a pipe table whose rendered row has more cells than the parsed header, a cell beyond the parsed width clickedthe same fallback applies

Implemented in 5

Tested by 8