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
| Input | Outcome |
|---|---|
| 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 held | The key stays native in the text box |
| A wrap marker typed during an IME composition | The key stays native in the text box |
| A keyboard layout whose AltGr reports ctrlKey and altKey, ~ or a backtick typed with AltGr over a selection | The selection is wrapped |
| Plain Ctrl+Alt with a marker over a selection | The 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
| Input | Outcome |
|---|---|
| A browser where the editing command is unavailable, the writer types * over a selection | The page splices the text directly, keeps the selection and autosaves |
| A browser without the editing command, an editor key changes the text | The page splices the value and still posts the autosave |
boundaryHome, End and their Shift forms
| Input | Outcome |
|---|---|
| End in a text box whose text ends with a line break | The caret sits after the last visible character, before the line break, and the preview does not scroll |
| Home | The caret moves to the start of the text and the preview does not scroll |
| Shift+End with the caret in the middle of the text | The text from the caret to the end, without trailing line breaks, is selected forward |
| Shift+Home with a backward selection | The selection keeps its anchor and extends backward to the start |
| Home with Cmd, Ctrl or Alt held, or during a composition | The key stays native |
nominalUndo and redo stay in the text box
| Input | Outcome |
|---|---|
| An editor with typed text, the writer presses Cmd+Z or Ctrl+Z | The 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 Y | The 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 keys | The result is the same in both |
boundaryRepeated spaces and Enter are typed as they are
| Input | Outcome |
|---|---|
| A nested list editor in the dark theme at 460 px, the writer types six spaces, Enter and a word | The 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 keys | The same exact text is saved |
nominalHandled keys stop at the document
| Input | Outcome |
|---|---|
| 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 field | The 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 box | The 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
| Input | Outcome |
|---|---|
| An image pasted or picked, so that its alt text is selected, as in ``, the writer presses Enter | The 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, Enter | The same: the alt text is kept and the caret moves just after the image |
| Shift+Enter, Cmd+Enter or Ctrl+Enter in the alt text | Not 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
| Input | Outcome |
|---|---|
| A keydown of Ctrl+Tab | The page does not stop it, so Ctrl+Tab still switches tabs in VS Code |
| An arrow key whose default was not prevented | The page does not stop it |
| Enter during an IME composition | The page does not stop it |
| Ctrl+Shift+A, Alt+A, or Ctrl+A on macOS | The page does not stop it |
| Ctrl+A (Cmd+A on macOS) outside a text control | The page does not stop it |
Implemented in 6
Tested by 8
- test/integration/realInput/textEditing.tsintegration
- test/page/blockReq.requirements.test.tsunit
- test/page/modules/editActions.test.tsunit
- test/page/modules/editorKeys.test.tsunit
- test/page/modules/selectAllKey.test.tsunit
- test/page/modules/textEditing.test.tsunit
- test/page/runtimeBlockEditor.test.tsunit
- test/visual/scenarioDefinitions1.tsvisual