Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-PALETTE-021

The palette is a toolbar above the editor that sticks over a tall editor

When a block editor opens, the extension SHALL place the edition palette as a toolbar named Edition palette on top of the editor frame, outside the frame, inside one host element that holds both, from the arrival of the source of the block until the editor closes, and keep it in reach, sticking or wrapping, while a tall editor scrolls or the pane is narrow, without covering the first lines of an editor that fits in the viewport when it opens or the panels in it.

Step 1 of path 1 in StRS-MDOKFSTUDIO-PALETTE-005: from “A block text box is open in edit mode” to “The palette is in view above the text box”.

Scenarios 8

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

nominalPalette above the frame
Givenan open paragraph editor whose source has arrived
Whenthe editor is inspected
Thenthe palette (role toolbar, aria-label Edition palette) and the frame are the two children of one host element marked data-sphinx-preview-block-editor-host, the palette first, and the frame does not contain the palette
boundaryWhen a palette exists
Givenan editor of the kind of the table
Whenthe page is inspected at the moment of the table
Thenthe palette is as in the table
Editor and momentOutcome
edit mode on and a block clicked, the host has not answered yetno palette exists
the source arrivedthe palette is shown above the frame
the editor closes (the writer presses Escape)the host, the frame and the palette are removed together
an insertion editor opened from an insert point or from Start writingan edition palette above it, like above a paragraph editor
a table cell editor or a frontmatter field editorno block palette is added (the cell editor gets the cell formatting group inside its table bar, see SwRS-MDOKFSTUDIO-TABLE-085; the field editors, see SwRS-MDOKFSTUDIO-FMEDIT-001)
nominalA small palette sticks over a tall editor
Givenan editor taller than one and a half viewports
Whenits top has scrolled out of view, and again when it is scrolled to its end
Thenthe palette is as in the table
Scroll positionPalette
the top of the frame is out of viewat the top of the viewport, 4 px below the larger of the reading offset and the toolbar bottom, below the sticky band and the floating toolbar, uncovered, inside its host; the box has not moved, and Bold keeps the editor open and the focus in the box
the top of the frame is out of view, the frame is taller than the viewport and none of the palette's buttons shares columns with the floating toolbar (it overlaps only the bar's empty end)4 px below the visible bottom of the sticky band (4 px from the top of the viewport when the band is hidden, also for the first block of the document): the host carries data-sphinx-palette-top and the custom property --sphinx-preview-palette-top, measured again when the pane, the bar, the band or the tall state change; a button under the floating toolbar keeps the line below the toolbar
the wheel scrolls a frame taller than the viewport down, one notch at a timethe page only goes down and the palette stays on its sticking line until the end of the frame
the end of the editorit has left with the end of the frame and is not below it
boundaryA tall palette or a short pane stays in the flow
Givenan edition palette
Whenthe window is resized or scrolled
Thenthe palette is as in the table, and the check is repeated on every scroll and resize
CaseOutcome
a palette of 60 px in a viewport of 100 px (taller than 40 percent of the viewport)the host carries data-sphinx-palette-static and the palette is positioned relative, in the flow above the frame, with no scroll padding set
the palette shrinks to 30 pxthe attribute is removed again
a viewport at most 520 px highthe palette stays in the flow instead of sticking
nominalThe caret is kept in view
Givena block editor with a stuck palette
Whenthe caret moves or text is typed
Thenthe page scrolls as in the table
CaretOutcome
the top of the caret line is above the palette bottomthe page scrolls up by the difference so that the top of the caret line is level with the palette bottom
the caret line ends less than 8 px above the bottom of the viewport, or below it, the palette stuck or not (the end of a large paste)the page scrolls down so that the caret line ends 8 px above the bottom of the viewport
the caret is below the palette, or more than 8 px above the viewport bottomthe page does not scroll
the palette is still above the frame (not stuck) and the caret line is above its bottomthe page does not scroll

The page does not follow the scroll that an applied edit causes in the text editor: see SwRS-MDOKFSTUDIO-PALETTE-279.

nominalNative scrolling keeps clear of the stuck palette
Givena palette, synchronised on every scroll and resize
Whenit is stuck over the box or not
Thenthe root element is as in the table
Palettescroll-padding-top of the root element
a small palette stuck over the boxthe larger of the reading offset and the toolbar bottom, plus the palette height, plus 12 px, so that it covers the palette (for a tall frame's line under the sticky band, that line plus the palette height plus 8 px)
a palette above the frame, or a tall palettethe property is removed
boundaryA narrow pane
Givenan editor in a pane narrower than the buttons of the palette
Whenthe palette is inspected
Thenit is as in the table
PaneOutcome
360 px, dark themethe buttons wrap onto several rows, the palette does not exceed the frame and its popups stay inside the pane
460 px, a very tall editor, scrolledthe palette stays inside the pane and the page has no sideways scroll
boundaryA block near the top of the pane keeps its first lines uncovered
Givena 900 or 1100 px pane on the cream theme in which the palette wraps onto two rows, and a block (a paragraph, or a figure whose Edit figure form opens in its frame) whose top is 20, 60 or 140 px under the top of the pane, so that its host is above the line where the palette sticks (4 px below the toolbar bottom)
Whenthe block editor opens
Thenthe palette is as in the table
Part of the open editorOutcome
the palette's bottom edgenot below the top of the frame, nor below the top of the text box or of the figure form
the frametakes the distance between the sticking line and its host's top, plus 3 px, as its top margin (custom property --sphinx-preview-palette-reserve on the host), so the editor and its panels move down with the bar; 0 when the host is not above that line
the pagekeeps the text where the user clicked: the scroll anchor follows the frame down
a frame whose top is more than one palette height above the linenothing is reserved, unless the page is not scrolled (scroll offset 0): then the whole distance is reserved, since nothing is scrolled under the bar
a frame taller than the viewport whose host is above the line where the palette may sit (a block taller than the pane, opened in its middle)nothing is reserved; the page scrolls down by the palette's height in flow, so the clicked text stays where it was and the stuck bar covers the lines under it (a close scrolls back); the page never scrolls up to bring the first lines below the bar
the room the page may scroll to keep the text in place when a panel opensends where the host's top meets the usable top, not the frame's top, so the palette is never left riding over the panel

The distance is measured when the editor opens and when the layout changes (resize, the palette changing height, the frame becoming taller or shorter than the viewport), never while the user scrolls. A frame taller than the viewport reserves nothing: a reserve taken for a short frame is given back when the frame grows past the viewport, so the bar stays attached to the frame.

Implemented in 8

Tested by 10