Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-PALETTE-153

The figure form edits the options of a figure and checks them

When the writer opens the figure form, from the Edit figure button over a hovered figure in edit mode or from Figure with the caret in a figure, the extension SHALL show a dialog with the fields Source, Alt text, Caption, Legend, Width, Align and Name, check them when the form is applied, and show each problem under its field while the form stays open and unchanged.

Part of StRS-MDOKFSTUDIO-PALETTE-007, outside the paths drawn on its map.

Scenarios 10

The situations the tests check; open one to read it.

nominalEdit figure button
Givenedit mode on and the pointer over a figure
Whenthe writer presses Edit figure, shown at the top right of the figure
Thenthe block editor of the figure opens and, once its source arrives, the figure form; with the figure already being edited the form opens in the open editor
boundaryEdit figure button hidden
InputOutcome
edit mode offthe button is hidden
a scrollthe button is hidden
the pointer over another elementthe button is hidden
a press on the buttonthe focus never moves

The button is a child of the body placed with the CSSOM, so a content patch never removes it.

boundaryEdit figure button next to the preview controls
Givenedit mode on, a figure whose top right is covered by the fixed preview controls, and no room under them inside the figure (a figure shorter than the controls' bottom edge, in a pane about 420 px wide)
Whenthe pointer is over the figure
Thenthe Edit figure button is placed left of the preview controls, inside the figure, so a press on it reaches the button and not a control

A figure with room below the controls keeps the button at its top right, below them.

nominalFields of the form
Giventhe caret in a figure
Whenthe form opens
Thenthe dialog is named Edit figure, the fields Source with a Browse... button, Alt text, Caption, Legend, Width with the placeholder 60% or 300px, Align with None, Left, Center and Right, and Name are filled from the directive, and the Source field has the focus with its text selected; the fields carry the accessible names Source, Alt text, Caption, Legend, Width, Align and Name
nominalForm after inserting a figure
Giventhe Figure button pressed outside a figure and an image picked
Whenthe directive is written
Thenthe form opens on it without another click, and the Caption field has the focus with its text selected
nominalLone Markdown image
Giventhe caret in an image alone in its paragraph
Whenthe form opens
Thenthe dialog is named Convert image to figure, its submit button reads Convert to figure and has the focus
boundaryDirective found for the form
InputOutcome
a figure that holds another figure and the caret in the inner onethe inner directive is edited (the innermost figure that holds the caret)
the editor opened by Edit figurethe first figure of the text is edited
the caret in ![a](b.png) alone in its paragraphthe form converts that image
an image with other text in its paragraphnot a lone image, no figure
boundaryKeys that apply the form
InputOutcome
Enter in a one-line field (for example Width)the form is applied
Cmd+Enter or Ctrl+Enter anywhere in the formthe form is applied
Enter in Caption or Legenda line break is typed and the form is not applied
Enter on a buttonkeeps its own effect
Enter during an IME compositionignored
refusalProblems under the fields
InputOutcome
Width wide, appliedthe message Use a number with px, %, em or rem, for example 60% or 300px. appears under Width (role alert), the field is aria-invalid and has the focus, the form stays open and the text is unchanged
widths 50, 50%, 12.5px, 3em, 2rem or an empty widthaccepted, no problem reported (a non-negative number with an optional decimal part and the unit px, %, em, rem or none)
widths 50 %, -1px, 50pt, wide, 1.pxeach refused with the width message
an empty SourceChoose or type the image path. under Source
a Source that is not on one lineThe path is one line.
an Alt text that is not on one lineThe alt text is one line.
a Name that is not on one lineThe name is one line.
an Align that is not empty, left, center or rightUse left, center or right.
a Caption of more than one paragraphThe caption is one paragraph; put the others in the legend.
an empty Caption and a LegendA legend needs a caption. under Legend
valid valuesno message is shown and the directive is rewritten (see SwRS-MDOKFSTUDIO-PALETTE-160)

When several fields are invalid the first invalid field gets the focus.

refusalFigure that cannot be edited and stale submit
InputOutcome
the form asked for a figure whose first body line is --- (YAML option block)the status line reads This figure uses a YAML option block: edit it in the text box. and the text is unchanged
the form asked with the caret in a plain paragraphthe status line reads No figure at the caret.
Apply pressed after the text of the text box changed from the text at the opening of the form (for example by a script)the form closes and nothing is written
Apply pressed on the same textthe directive is written

The range recorded at opening is never applied to a different text.

Implemented in 3

Tested by 8