Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-003

A chevron folds the section under a heading, and Fold all folds every section

When the reader presses the chevron of a heading of the content, or the section shortcut with that heading current, the extension SHALL hide every block after the heading up to the next heading of the same or a higher level, keep the heading shown with its chevron marked folded, and show the blocks again when the chevron is pressed again; and when the reader presses the Fold button of the toolbar, or runs the command Fold All Sections in Preview or Unfold All Sections in Preview, fold every section that has content, or unfold every section, in the preview that has the focus.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-002: from “The document is shown with its sections open” to “A section is folded”.

Scenarios 7

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

nominalFold a section
Givencontent with an h2 B followed by two paragraphs, an h3 C with a paragraph, and then an h2 D
Whenthe reader presses the chevron of B
Thenthe two paragraphs, C and its paragraph are hidden (data-okf-folded, hidden="until-found"), B and D stay shown, the chevron of B has aria-expanded false and the heading has data-okf-fold="closed"; pressing it again shows the blocks and sets data-okf-fold="open"
boundaryWhich headings fold and where a section ends
InputOutcome
A heading directly followed by a heading of the same or a higher level, or by nothingIt has no chevron, because its section is empty
An h3 inside a folded h2 that is itself foldedIt stays hidden until the h2 opens; its own fold state is kept
A folded h3 followed by an h2The section ends at the h2, which stays shown
A heading inside an admonition or the properties tableIt is not a top-level block of the content and has no chevron
The chevron is pressed in edit modeThe click is taken by the chevron: no block editor opens and the editor does not reveal the source
The chevron is pressed while a block editor or the frontmatter editor is openNothing folds
The section shortcut (Ctrl+Alt+[, Cmd+Alt+[ on macOS) with focus outside a text boxThe section of the focused heading, or of the last heading at the reading line, folds or unfolds; a heading without a section stands for the heading above it; the key typed in a text box does nothing
nominalThe chevron is shown when it is useful
Givena heading with a section
Whenthe pointer is over the heading, the chevron has the focus, or the section is folded
Thenthe chevron is visible; otherwise it is transparent but still reachable by keyboard
boundaryFolded blocks take no room
Givena folded section
Whenthe page is laid out
Thenthe hidden blocks have no margin, padding or border, so the folded heading is followed by the next heading at the spacing of two headings
nominalFold all and unfold all from the toolbar
Givena document with several sections and none folded
Whenthe reader presses the Fold button in row 3 of the toolbar
Thenevery heading that has a section is folded, the button reads Unfold all sections with aria-pressed true; pressing it again unfolds every section and the button reads Fold all sections again
nominalFold all and unfold all from the command palette
Givena preview or the custom editor has the focus
Whenthe reader runs Markdown OKF-Schema Studio: Fold All Sections in Preview or Unfold All Sections in Preview
Thenthe host posts previewFoldCommand with foldAll or unfoldAll to that preview and the page folds or unfolds every section
refusalNo preview, wrong command, open editor
InputOutcome
No preview has the focusThe command does nothing and returns false
A previewFoldCommand with a command other than foldAll or unfoldAllThe page refuses it
A block editor or the frontmatter editor is openThe page does not fold or unfold
The command palette while a text editor has the focusThe two entries are not offered (when: activeWebviewPanelId or activeCustomEditorId is the Studio's)

Implemented in 8

Tested by 6

Replaces

SwRS-MDOKFSTUDIO-TOOLBAR-005Fold all and unfold all fold every section from the toolbar and the command palette superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-003 Markdown file