Behaviour SwRS-MDOKFSTUDIO-BLOCK-003
Edit-mode text box follows VS Code undo, redo, select-all and delete-line key bindings
When a writer presses the VS Code key binding of undo, redo, select all or delete line in an open block or table-cell text box of the focused preview, the page SHALL apply that command to the text box through a command the extension contributes, so the key binding the writer set in VS Code applies.
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 2
The situations the tests check; open one to read it.
nominalThe key bindings run the editing commands on the text box
| Input | Outcome |
|---|---|
| A block or table-cell editor open in the focused preview, the writer presses Cmd+Z (Ctrl+Z off macOS) | The page cancels the native action, the key reaches VS Code, its binding runs `markdown-okf-schema-studio.editUndo` and the last change of the text box is undone once; the editor stays open and the autosave follows the text |
| The same, Cmd+Shift+Z (Ctrl+Shift+Z or Ctrl+Y off macOS) | `editRedo` restores the undone change |
| The same, Cmd+A (Ctrl+A off macOS) | `editSelectAll` selects the whole text of the text box and nothing else of the page |
| The same, Cmd+Shift+K (Ctrl+Shift+K off macOS) | `editDeleteLine` removes every line the selection touches with one line break, as one undoable step, keeps the column on the next line (the previous line when the last line goes) and autosaves |
| The writer rebinds or unbinds one of the four commands in VS Code | The new key runs the command; the page does not run it from its own default key |
boundaryWhere the commands apply
| Input | Outcome |
|---|---|
| No editor open in the preview, or the preview does not have the focus | The context `markdownOkfSchemaStudio.previewEditing` is off, the bindings do not apply and VS Code handles the key as before |
| An editor opens, closes or the preview gains or loses the focus | The extension sets the context at once, and only when its value changes |
| An editing command with no text box focused in the page | Nothing changes |
| The text is empty, Cmd+Shift+K | Nothing changes |
| Cmd+K alone (the start of a VS Code chord) | The page does not take it; delete line is Cmd+Shift+K as in VS Code |
| A frontmatter field editor | The keys keep their earlier behaviour: undo, redo and select-all stay in the field |
Implemented in 8
Tested by 8
- test/core/protocol/hostToPage.test.tsunit
- test/integration/editKeys.test.tsintegration
- test/page/modules/editCommandKey.test.tsunit
- test/page/modules/selectAllKey.test.tsunit
- test/page/modules/textEditing.test.tsunit
- test/page/runtimeBlockEditor.test.tsunit
- test/security/package-contract.test.tsunit
- test/session/editCommands.test.tsunit