Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-BLOCK-069

Marker keys wrap a selection; Home, End, select-all and undo stay in the text box

When a writer presses a key in the text box of an open editor, the page SHALL give it the text-box behaviour of its row in the scenarios (wrap a selection, caret to the start or the end, select-all, undo, repeated spaces and Enter typed as they are, except in the alt text of an image, where it validates it), apply every text change as a native undoable edit and keep a key the editor handled from reaching VS Code.

Another outcome at step 1 of path 1 in StRS-MDOKFSTUDIO-BLOCK-008, in the state “A block editor is open on a list”.

Part of StRS-MDOKFSTUDIO-TABLE-006, outside the paths drawn on its map.

Scenarios 10

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

nominalTyping * _ backtick or ~ over a selection wraps it
Giventhe word `foo` selected in `a foo b`
Whenthe writer types * and then * again
Thenthe text becomes `a *foo* b` and then `a **foo** b`, with `foo` still selected each time (the selection start and the selection end each move by one after every wrap), and the same holds for _, a backtick and ~
refusalMarker keys stay native
InputOutcome
The caret in the text box with nothing selected, the writer types *A single * is typed
A wrap marker typed with Cmd, Ctrl or Alt heldThe key stays native in the text box
A wrap marker typed during an IME compositionThe key stays native in the text box
A keyboard layout whose AltGr reports ctrlKey and altKey, ~ or a backtick typed with AltGr over a selectionThe selection is wrapped
Plain Ctrl+Alt with a marker over a selectionThe selection is not wrapped
nominalEditor key edits keep the browser undo stack
Givena list item continued with Enter, or an indentation by Tab, a marker wrap or a palette shortcut
Whenthe writer undoes in the text box
Thenthe new line or the change disappears and the editor stays open, because the page applied the change through the native insertText or delete command first
boundaryNo native editing command
InputOutcome
A browser where the editing command is unavailable, the writer types * over a selectionThe page splices the text directly, keeps the selection and autosaves
A browser without the editing command, an editor key changes the textThe page splices the value and still posts the autosave
boundaryHome, End and their Shift forms
InputOutcome
End in a text box whose text ends with a line breakThe caret sits after the last visible character, before the line break, and the preview does not scroll
HomeThe caret moves to the start of the text and the preview does not scroll
Shift+End with the caret in the middle of the textThe text from the caret to the end, without trailing line breaks, is selected forward
Shift+Home with a backward selectionThe selection keeps its anchor and extends backward to the start
Home with Cmd, Ctrl or Alt held, or during a compositionThe key stays native
nominalUndo and redo stay in the text box
InputOutcome
An editor with typed text, the writer presses Cmd+Z or Ctrl+ZThe typing is undone in the text box only and the editor stays open and focused; in a block or table-cell text box the undo runs through VS Code's key binding (SwRS-MDOKFSTUDIO-BLOCK-003), in a frontmatter field the key stops at the page and the text box undoes natively
The same keys with Shift+Z or YThe same for redo: through the key binding in a block or table-cell text box, natively in a frontmatter field
The preview opened through Open With, and then side by side, the same keysThe result is the same in both
boundaryRepeated spaces and Enter are typed as they are
InputOutcome
A nested list editor in the dark theme at 460 px, the writer types six spaces, Enter and a wordThe text holds exactly those characters, the focus and the caret stay at the end and the autosave carries the exact text with its newline
The same editor in the light theme at 900 px, the same keysThe same exact text is saved
nominalHandled keys stop at the document
InputOutcome
A keydown of Enter in an editor whose listener prevented the default (Tab, Escape and the arrow keys likewise)It stops at the document and the default stays prevented, so VS Code runs no shortcut for it
Cmd+A on macOS or Ctrl+A elsewhere in a frontmatter fieldThe propagation stops, the default is not prevented and the control selects its own text
Cmd+A on macOS or Ctrl+A elsewhere in a block or table-cell text boxThe page cancels the native action, the document does not stop the key and VS Code's key binding selects the text of the text box (SwRS-MDOKFSTUDIO-BLOCK-003)
nominalEnter in the alt text of an image validates it
InputOutcome
An image pasted or picked, so that its alt text is selected, as in `![image.png](image.png)`, the writer presses EnterThe text is unchanged and the caret sits just after the closing parenthesis of the image; no line break is typed
The caret inside the alt text after the writer typed there, EnterThe same: the alt text is kept and the caret moves just after the image
Shift+Enter, Cmd+Enter or Ctrl+Enter in the alt textNot this rule: Shift+Enter stays native, Cmd/Ctrl+Enter is Done
Enter with the caret outside the alt text of an image (in the path, before the image or in other text)Enter keeps its other behaviour in the row above
refusalKeys that go on to VS Code
InputOutcome
A keydown of Ctrl+TabThe page does not stop it, so Ctrl+Tab still switches tabs in VS Code
An arrow key whose default was not preventedThe page does not stop it
Enter during an IME compositionThe page does not stop it
Ctrl+Shift+A, Alt+A, or Ctrl+A on macOSThe page does not stop it
Ctrl+A (Cmd+A on macOS) outside a text controlThe page does not stop it

Implemented in 6

Tested by 8