Behaviour SwRS-MDOKFSTUDIO-BLOCK-014
A click or Enter on a mapped block opens its editor
When a writer clicks a rendered block in edit mode, or presses Enter or Space on a focused mapped block, the page SHALL open the editor of the mapped block under the click with previewEditOpen for its source lines instead of revealing its source, show in the editor the source text or the error that the host returns in previewEditSource, and give every rendered horizontal rule a box 25 px tall (the 1 px line plus 12 px of transparent padding above and below, with the page spacing unchanged) so that a click within 12 px of the line opens the rule's block editor.
Step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-003: from “Edit mode is on” to “The framed editor is open in place of the block”.
Scenarios 11
The situations the tests check; open one to read it.
nominalParagraph, image or admonition
nominalEnter or Space on a focused block
nominalLine range and placement per kind of block
| Clicked block in edit mode | Editor |
|---|---|
| an item of a list mapped to lines 5 to 8 with items at lines 5, 6 and 7 (also in a 460 px wide pane with long wrapped items), click on the item at line 6 | previewEditOpen carries the lines of that item only: the range the renderer gives the item, from its first line to the line before the next item (a blank line between two items belongs to the first, as it belongs to the list), whatever the item holds (paragraphs, an inline code span or a comment over several lines, an HTML block, a code block); the editor holds the item and its continuation lines, appears after the hidden item, and the wrapped source is not clipped; in an ordered list the next items keep their numbers while the item is edited |
| an item of a list nested in another list, or the rest of the outer item | the editor holds the nested item only (the nearest item wins); a click elsewhere in the outer item opens the outer item, its nested list included |
| the list itself, outside its items | the editor holds the whole list; from the keyboard, the selected list opens the whole list too (SwRS-MDOKFSTUDIO-BLOCK-254) |
| a wrapped item of a tight list (no blank line between items) | the editor holds every wrapped line of the item |
| another block, while an item editor holds changes, then a click on the first item of a list | once the save is rendered, the first item opens, not the list that starts on the same line |
| a paragraph or a list item in the body of a MyST admonition (`{note}` in a backtick or colon fence) | previewEditOpen carries the lines of the directive, opening fence to closing fence, and the editor holds them; the nearest admonition or alert around the click wins over the list around it or inside it |
| a paragraph or a list item in the body of a GitHub alert, also an alert indented in a list item | previewEditOpen carries the lines of the alert, marker line to last quoted line, and the editor holds them with their indentation; the alert wins over the list around it or inside it (SwRS-MDOKFSTUDIO-GFM-009) |
| a fenced code block | the frame is a sibling after the pre, the pre carries data-sphinx-preview-editing true, and the text box holds the fence lines exactly as in the file; after the writer adds a line and presses Done, the final save still starts and ends with the fence lines |
| a block that comes from an {include} | previewEditOpen names the lines of the {include} directive in the edited document and the editor holds the directive text; the included block carries data-sphinx-preview-included true |
| the words Diagram source of the collapsed disclosure of a Mermaid or PlantUML figure | the default toggle is prevented, the disclosure stays closed and the editor of the figure opens on the lines of the diagram block |
boundaryA link inside a mapped block
A link here is any link inside a mapped block: a link inside a paragraph, a paragraph made only of a link (the closing "Next: Related" line of a chapter), the title, header, body or footer of a `:link:` card (SwRS-MDOKFSTUDIO-BLOCK-258), a linked image, a same-page anchor, a footnote reference or an external URL.
| Input, edit mode on | Outcome |
|---|---|
| click on a link, no modifier | the default action is prevented, the link is not followed (no previewLink) and the editor of the block that holds the link opens, as a click on the text around it does |
| Enter or Space on a focused link | the same as a click: the default action is prevented and the block's editor opens |
| click on a mapped block that is itself inside a link | the editor of that block opens and the link is not followed |
| click on a link with Cmd or Ctrl held, or Cmd/Ctrl+Enter on a focused link | the link navigation runs (SwRS-MDOKFSTUDIO-TOOLBAR-077) and no editor opens |
| middle click on a link | the link navigation runs and no editor opens |
| click on a link while the editor of another block is open | as a click on any other block (SwRS-MDOKFSTUDIO-BLOCK-041): the open editor is saved first, no other file opens, so the keys typed next never reach the link target |
| the pointer over a link | the block that holds it gets the edit-hover outline (SwRS-MDOKFSTUDIO-BLOCK-017) and the text cursor, like the text around the link; on a `:link:` card only the part under the pointer is outlined; a link whose click keeps its own behaviour (properties table, comment thread, open editor, outside a mapped block) keeps the pointer cursor and gets no outline |
| Input, edit mode off (reading) | Outcome |
|---|---|
| click, Enter or Space on a link | unchanged: the link is followed and no editor opens |
nominalThe tooltip says how to follow a link in edit mode
| Given | When | Then |
|---|---|---|
| a link inside a mapped block whose tooltip is its target path, its blocked reason or its `link-alt` text | edit mode is turned on | the tooltip keeps that text on its first line and gets the second line "Cmd+click to follow" on macOS, "Ctrl+click to follow" elsewhere; a link without a tooltip shows only that line |
| the same link in edit mode | the host answers a target discovery for it, or the content is rendered again | the new target is the first line and the second line stays |
| the same link | edit mode is turned off | the second line is removed and the tooltip is the text it had without it |
| a link value of the properties table | edit mode is turned on | its tooltip is unchanged |
refusalTargets that open no block editor
| Input in edit mode | Outcome |
|---|---|
| Enter or Space with focus on a text box, a button, a link value of the properties table, a comment chip, an insert point or the Description toggle | no block editor opens |
| click on a comment chip in a paragraph | the chip expands and no editor opens |
| click on the body of an open comment thread | no editor opens |
| click, Enter or Space on a link value of the properties table, in a comment thread or on the anchor icon of a label | the link keeps its own behaviour (field editor, thread, label rename) and no block editor opens |
| click on a cell of the properties table | no block editor opens; the field editor of the cell is specified by SwRS-MDOKFSTUDIO-FMEDIT-001 |
| click on a paragraph below the properties table | its block editor opens as usual |
refusalReading mode
| Input in reading mode | Outcome |
|---|---|
| click on a paragraph | no previewEditOpen is posted and no editor frame appears |
| click on the words Diagram source of a Mermaid figure | the disclosure opens or closes as usual, no editor opens, and the click reveals the source line |
nominalThe host answers with previewEditSource
refusalAn error or a malformed previewEditSource
| Input | Outcome |
|---|---|
| previewEditSource with an error string for the active edit id | the editor stays, its status line shows the error text, pending navigation and selection are cleared and the editor accepts input again |
| previewEditOpen for lines that no longer exist in the document | the host answers with previewEditSource carrying the error "The preview is stale. Refresh it before editing this block." |
| previewEditOpen while another block is being edited | the host answers with previewEditSource carrying the error "Another Markdown block is already being edited." (see SwRS-MDOKFSTUDIO-BLOCK-041) |
| previewEditSource with an edit id other than the active editor's, or with no active editor | ignored |
| previewEditSource with neither an error string nor a string originalText | ignored |
| previewEditSource that arrives when the text box already exists | ignored |
nominalClick above the line
boundarySpacing unchanged
Implemented in 9
- src/core/preview/styles/contentBlockStyles.ts
- src/core/preview/styles/editModeStyles.ts
- src/core/render/mystRenderer.ts
- src/page/features/blockEditor.ts
- src/page/features/editMode.ts
- src/page/features/linkEditing.ts
- src/page/features/mappedBlocks.ts
- src/page/features/pageInput.ts
- src/page/modules/linkNavigation.ts
Tested by 16
- test/core/preview/previewStyles.test.tsunit
- test/core/render/includeMapping.test.tsunit
- test/integration/previewEditing.test.tsintegration
- test/integration/realInput/editorWidgets.tsintegration
- test/page/blockReq.requirements.test.tsunit
- test/page/linkEditModeClick.test.tsunit
- test/page/runtimeBlockEditor.test.tsunit
- test/page/runtimeContentPatch.test.tsunit
- test/page/runtimeStructuralNavigation.test.tsunit
- test/session/alertBlockEditOpen.test.tsunit
- test/session/listItemEditOpen.test.tsunit
- test/visual/alertEditingScenarios.tsvisual
- test/visual/capture_list_numbers.pyvisual
- test/visual/linkEditModeScenarios.tsvisual
- test/visual/scenarioDefinitions1.tsvisual
- test/visual/scenarioDefinitions2.tsvisual