Markdown OKF-Schema Studio

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
GivenPressing Alert
An empty line and the caret on itThe 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 themThe 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 alertA 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 paragraphThe new alert follows the paragraph directly, without a blank line
nominalChoosing a type
Giventhe caret in an alert of type NOTE
Whenthe writer chooses Warning in the list
Thenthe head reads WARNING, the rest of the alert is unchanged, the caret stays in place and the change is one more edit
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
InputOutcome
Alert pressed with the caret inside an alertThe 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 linesThe 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 paragraphThe 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 itThe caret is in no alert: the line in the code block is never changed
Alert pressed again while the list is open after an insertionThe list closes without another edit
Tip chosen with the caret in an alert of type TIPNo edit is made
Alert action with the argument INFO, or any value other than the five upper-case names NOTE, TIP, IMPORTANT, WARNING, CAUTIONNo edit is produced (the check is case-sensitive)
nominalWhere the list opens
CaretOutcome
MeasurableThe 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 measurableThe 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
InputOutcome
ArrowDown twice, then Enter, none lit at firstThe second type, Tip, is lit and picked, and the head reads TIP; ArrowDown and ArrowUp light a type and wrap
Enter with none litNothing is picked and the key keeps its usual effect
ArrowDown or ArrowUp with Alt, Cmd or Ctrl; Shift+EnterNot taken by the list
EscapeThe 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 EscapeThe editor is cancelled
ArrowLeftThe list closes and the caret moves
Typing a characterThe list closes and the character is typed
ArrowRight, Home, End, PageUp or PageDownThe 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.

Implemented in 2

Tested by 4