Behaviour SwRS-MDOKFSTUDIO-PALETTE-039
A palette action edits in one undo step or leaves the text unchanged and says why
When a palette button, a slash command or a shortcut runs an action, the extension SHALL apply the edit that the action returns to the text box as one native editing step that autosaves the editor and leaves the selection that the action returned, and, when the action returns no edit, leave the text unchanged, put the focus back in the text box and show the reason in the status line when the action has one.
Part of StRS-MDOKFSTUDIO-PALETTE-015, outside the paths drawn on its map.
Step 3 of path 1 in StRS-MDOKFSTUDIO-PALETTE-019: from “The selection is wrapped in markers” to “The text is as it was before the button”.
Scenarios 6
The situations the tests check; open one to read it.
nominalBold and undo
Givena text box with a selected word
Whenthe writer presses Bold and then the undo key combination
Thenthe word is wrapped in one step, the editor stays open and one undo restores the text
boundaryNo native editing command
Givena page where the native editing command is not available
Whenthe writer presses Bold
Thenthe text is spliced by hand, the editor reacts as to an input event and the returned selection is set
refusalAn action that makes no edit
Givena text box and an action that refuses the selection (the Colour action on a selection that straddles a span boundary)
Whenthe writer presses the button
Thenthe text is unchanged and the text box has the focus, and the same action on a valid selection applies the edit
refusalA refusal that has a reason
Givenan open editor and a command that makes no edit
Whenthe writer runs it as in the table
Thenthe text is unchanged (apart from the removed query) and the status line is as in the table
| Started from | Case | Outcome |
|---|---|---|
| the button List table in a MyST editor | a table conversion that would lose content | the text is unchanged and the status line gives the reason |
| the slash menu | the same refusal, or a conversion that would lose content chosen from the menu | the typed slash query is removed, the text is otherwise unchanged and the status line gives the reason |
| the slash menu | a command that refuses without a reason | the query is removed and the status line is unchanged |
boundaryInvalid selection
Givena text of 5 characters
Whena line or block action is applied with the selection of the table
Thenthe outcome is the one of the table
| Selection | Outcome |
|---|---|
| ending at 9 (beyond the text) | no edit |
| negative | no edit |
| start after its end | no edit |
| inside the text | the edit is produced |
nominalA matched shortcut is consumed
Giventhe block text box
Whenthe writer presses a palette shortcut that matches, such as Ctrl+B
Thenthe default is prevented and the event is stopped, whether or not the action returns an edit
| Selection | Outcome |
|---|---|
| a selected word | the word is wrapped and the event is stopped |
| a selection the action refuses | the text is unchanged and the event is still stopped, so the side bar does not toggle |