Behaviour SwRS-MDOKFSTUDIO-PALETTE-115
Alert inserts a GitHub alert and offers its type list
When the writer presses Alert, the extension SHALL quote the touched lines under the head `> [!NOTE]`, or leave the text alone when the caret is already in an alert, and open at the caret a list of Note, Tip, Important, Warning and Caution with none lit, from which a chosen type replaces the type word of the head of the alert at the caret.
Step 1 of path 1 in StRS-MDOKFSTUDIO-PALETTE-020: from “The palette is shown above the text box in the GFM mode” to “An alert is written and its type list is open”.
Scenarios 5
The situations the tests check; open one to read it.
nominalAlert outside an alert
| Given | Pressing Alert |
|---|---|
| An empty line and the caret on it | The text is the head line `> [!NOTE]` and a quoted empty line with the caret on it, and the type list is open with no type lit |
| A selection of two lines and a blank line between them | The head is added, both lines are quoted and the blank line is kept as a bare quote line |
| A quote that is not an alert, or a caret after the alert | A new alert is inserted |
| The caret on a line right under a block quote line, quoted or lazy (`> quote`, then `Second` with the caret) | A new alert is inserted after a blank line, so it does not join the quote above: `> quote`, blank, `> [!NOTE]`, `> Second`, with the caret after `> ` at its column; in a selection, the quoted lines are selected |
| The caret on a line right under a plain paragraph | The new alert follows the paragraph directly, without a blank line |
nominalChoosing a type
the list acts on the live selection, not the one at opening time
Example: the alert action run with the argument CAUTION writes the head with CAUTION
boundaryAlert with the caret already in an alert
| Input | Outcome |
|---|---|
| Alert pressed with the caret inside an alert | The type list opens and the text is unchanged (the action without an argument returns no edit) |
| The caret on a lazy continuation line of an alert (`> [!TIP]`, `> first`, then `Second` with the caret), or on a quoted line after such lazy lines | The caret is in that alert: without an argument no edit; with WARNING the head reads `> [!WARNING]` and the lazy line is unchanged |
| The caret after the end of an alert (after a blank line, on a list item of any number right under it such as `2. x`, or on the line right after a table in it) | The caret is not in the alert: its head is never changed and a new alert is inserted after a blank line |
| The caret on a lazy delimiter row (`> [!TIP]`, `> | a | b |`, then `| - | - |`), or on a lazy line after a closed HTML comment and a paragraph | The caret is in that alert: with WARNING the head reads `> [!WARNING]` |
| The caret in fenced code that holds a `> [!NOTE]` line, on a lazy or quoted line after it | The caret is in no alert: the line in the code block is never changed |
| Alert pressed again while the list is open after an insertion | The list closes without another edit |
| Tip chosen with the caret in an alert of type TIP | No edit is made |
| Alert action with the argument INFO, or any value other than the five upper-case names NOTE, TIP, IMPORTANT, WARNING, CAUTION | No edit is produced (the check is case-sensitive) |
nominalWhere the list opens
| Caret | Outcome |
|---|---|
| Measurable | The list carries data-edit-popover-at caret and sits under the caret line, in the coordinates of the bar, pulled back to stay inside the frame; the vertical offset is the caret bottom minus the bar top plus 2 px |
| Not measurable | The list sits under the Alert button like the other popovers |
The five options carry the values NOTE, TIP, IMPORTANT, WARNING and CAUTION. The placement rule shared by all palette popovers is in SwRS-MDOKFSTUDIO-PALETTE-031.
nominalKeys in the open list
| Input | Outcome |
|---|---|
| ArrowDown twice, then Enter, none lit at first | The second type, Tip, is lit and picked, and the head reads TIP; ArrowDown and ArrowUp light a type and wrap |
| Enter with none lit | Nothing is picked and the key keeps its usual effect |
| ArrowDown or ArrowUp with Alt, Cmd or Ctrl; Shift+Enter | Not taken by the list |
| Escape | The list closes, the head still reads NOTE, the focus is in the text box and the editor is open; the first Escape is consumed by the palette |
| A second Escape | The editor is cancelled |
| ArrowLeft | The list closes and the caret moves |
| Typing a character | The list closes and the character is typed |
| ArrowRight, Home, End, PageUp or PageDown | The list closes and the key takes its normal effect |
A list opened by the insertion itself is not closed by the input event of that insertion.