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
refusalEdit mode off
nominalLoading status until the host sends the table source
the page receives the answer with the table text
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
the editor of that cell is closed by Escape
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
a cell written "| padded |"
the cell is opened
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
an empty cell
the writer clicks it
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
the editor moved to another cell
the regions are read again
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.
| Input | Outcome |
|---|---|
| "| 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 pipes | parses into rows of two cells and opens a cell editor |
| a single line | parse 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 cell | parse returns no table, no cell editor is built |
| a body row with fewer cells than the header | parse 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
| Input | Outcome |
|---|---|
| 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 source | the 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 clicked | the same fallback applies |
Implemented in 5
Tested by 8
- test/core/preview/previewStyles.test.tsunit
- test/integration/realInput/tableRowTokens.tsintegration
- test/integration/realInput/tableShortDelimiter.tsintegration
- test/integration/tableMoves.tsintegration
- test/page/fmtableReqTable.requirements.test.tsunit
- test/page/modules/markdownTable.test.tsunit
- test/page/runtimeTableCellEditor.test.tsunit
- test/page/runtimeTableRowTail.test.tsunit