Behaviour SwRS-MDOKFSTUDIO-PALETTE-150
Figure writes a figure directive for a picked image
When the host answers a path for the Figure button outside a figure, the extension SHALL write a figure directive with that path, the option :alt: set to the file name without extension and the touched lines, or an empty line, as the caption.
Part of StRS-MDOKFSTUDIO-PALETTE-007, outside the paths drawn on its map.
Scenarios 8
The situations the tests check; open one to read it.
nominalPicked image
Giventhe path pics/cat.png picked and the caret after Intro
Whenthe action runs
Thena directive `:::{figure} pics/cat.png` with `:alt: cat` and an empty caption line is inserted after a blank line, with the caret on the caption line
nominalSelection becomes the caption
Giventhe selected line A cat
WhenFigure runs with a picked path
Thenthe touched lines are the caption inside the directive
boundaryFence and path
| Input | Outcome |
|---|---|
| a selection that holds a fence of three colons | the outer fence has four colons (one colon more than the longest colon fence in the touched lines) |
| a selection without a colon fence | the outer fence has three colons (never shorter than three) |
| the path pics/cat.png | written as picked, with no angle brackets |
refusalMissing path
Givenno path
Whenthe action runs
Thenno edit is produced
boundaryWhere Figure opens a dialog or the form
| Input | Outcome |
|---|---|
| the caret in a plain paragraph | the image dialog is requested (see SwRS-MDOKFSTUDIO-PALETTE-192) |
| the caret inside a figure directive, or in a Markdown image alone in its paragraph | the figure form opens and no dialog is requested (see SwRS-MDOKFSTUDIO-PALETTE-153) |
| the caret in nested figures | the deepest directive that holds the caret wins |
nominalForm opens after the pick
Giventhe caret in a plain paragraph and the Figure button pressed
Whenthe host answers a path and the directive is written
Thenthe figure form opens at once on the new directive, with the Source and Alt text filled and the focus on the Caption field; Escape closes the form and keeps the inserted directive with its default values
nominalBrowse in the figure form
Giventhe figure form open
WhenBrowse is pressed and the host answers a path
Thenthe editor stays open, the Source field holds the path and has the focus
refusalBrowse refused
Giventhe host refuses the pick
Whenthe answer arrives
Thenthe Source field is unchanged and the reason is shown in the status line; an answer that arrives after the form closed is ignored