Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-120

The Anchor button switches whether the preview follows the editor

When the reader presses the enabled Anchor button, or the page learns whether a text editor shows its document, the extension SHALL show the anchor mode and the pairing on the button (data-anchor-mode, aria-pressed, label, title and tooltip, disabled while no text editor shows the file) and, when the mode is turned on, post to the preview the first visible line of each visible text editor that shows its document; a pairing message for another document, document version or request than the page's leaves the button unchanged, and the host accepts a mode change only when anchorToEditor is a boolean.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-013: from “The Anchor button is enabled” to “The preview and the text editor scroll together”.

Scenarios 11

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

nominalThe button switches the mode
InputOutcome
the enabled Anchor button in the off mode, presseddata-anchor-mode is on, aria-pressed is true, the title and tooltip say Preview and text editor scroll together
the button in the on mode, presseddata-anchor-mode is off, aria-pressed is false, the title and tooltip say Preview and text editor scroll independently
boundaryInitial state
Giventhe toolbar markup before the page script runs
Whenthe Anchor button is read
Thendata-anchor-mode is off and aria-pressed is false
refusalNo text editor shows the file
Givena preview whose file is shown in no text editor and an anchor mode of on
WhenpreviewPairing arrives with pairedTextEditor false
Thenthe button is disabled, its label, title and tooltip say No text editor shows this file and aria-pressed is false
nominalA text editor shows the file
InputOutcome
a disabled Anchor button, previewPairing with pairedTextEditor truethe button is enabled, its label is restored to Anchor preview to text editor and its title and tooltip show the mode of the moment
an enabled Anchor button, previewPairing with pairedTextEditor truethe button stays enabled and keeps its mode
boundaryPairing message without the field
Givena previewPairing message without the field pairedTextEditor
Whenthe page applies it
Thenthe button is enabled, because only the value false means unpaired
nominalTurning the mode on aligns the preview
Givena panel in the off mode and a visible text editor of the same file
Whenthe mode is switched on
Thenthe preview receives a sourceScroll with the editor's first visible line and scrolls there, because the page follows the editor now
boundaryTurning the mode off
Giventhe mode switched off
Whenthe host handles it
Thenno sourceScroll is posted
refusalForeign document
InputOutcome
a message for another document identitythe button does not change
a message for another document version or another requestthe button does not change
nominalOwn document
Givena message for the page's document
Whenthe page receives it
Thenthe button follows it
nominalBoolean
GivenanchorToEditor true and false
Whenthe validator runs
Thenboth are accepted
refusalNot a boolean
Giventhe string true, the number 1 and a missing field
Whenthe validator runs
Thenall are refused

Implemented in 4

Tested by 7

Replaces

SwRS-MDOKFSTUDIO-TOOLBAR-122A pairing message for another document is ignored superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-120 Markdown file
SwRS-MDOKFSTUDIO-TOOLBAR-126The host accepts only a boolean anchor mode superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-120 Markdown file