Behaviour SwRS-MDOKFSTUDIO-LAYOUT-023
Auto width lets wide blocks break out of the column
When the width mode is Auto, the extension SHALL widen a table, figure, image, code block or Mermaid diagram that is wider than the text column to the width it needs, up to the available area, centred on that area, measuring it again whenever the layout may have changed.
Step 2 of path 1 in StRS-MDOKFSTUDIO-LAYOUT-003: from “The width mode has changed” to “Wide content is drawn at the width it needs”.
Scenarios 7
The situations the tests check; open one to read it.
nominalWide table and oversized block
GivenAuto mode, a column of 700 px, a pane of 1000 px, a table needing 900 px and a code block needing 1600 px
Whenthe elements are measured
Thenthe table gets a breakout of 200 px; the code block is capped at the available area, a breakout of 268 px (1000 minus 32 gutters minus 700); an element not wider than the column is not marked
nominalColumn off the pane centre
Giventhe column starts 120 px from the pane edge so that it is 30 px off the pane centre
Whenthe elements are measured
Thenthe breakout shift is 30 px, so the wide element is centred on the available area, and a narrow element keeps an empty shift
nominalTable-of-contents column
GivenAuto mode, TOC reserve 256 px, a pane of 1000 px, a column of 400 px starting at 100 px and a table needing 1600 px
Whenthe elements are measured
Thenthe available area is 712 px, the breakout is 312 px and the shift is 72 px, because the open table-of-contents column of 256 px is excluded from the available area, from the centre of the breakout and from the cap
when the TOC reserve is 0 (closed, or pane under 760 px) the available area is the pane minus the 32 px gutters
when the TOC reserve is 0 (closed, or pane under 760 px) the available area is the pane minus the 32 px gutters
refusalElements kept in the column
| Input | Outcome |
|---|---|
| A wide table marked data-sphinx-preview-editing in Auto mode (its source editor is open) | Not marked wide; keeps the column width while its source editor is open |
| A wide table holding an editor field other than a cell editor | Not marked wide; keeps the column width |
| An image whose data-okf-width is 50% | Not marked wide |
| An image whose data-okf-width is 20em | Not marked wide |
| An image whose data-okf-width is 3rem | Not marked wide |
boundaryAuthor pixel width and a gain of 1 px
| Input | Outcome |
|---|---|
| Image with data-okf-width 800 and intrinsic width 3000 px, in a 700 px column | Breakout based on 800 px, so 100 px |
| Element 701 px wide in a 700 px column | Not marked wide |
| Element as wide as the column, or 1 px wider, measured after a resize | Not marked wide |
nominalMeasured again when the layout changes
| Input | Outcome |
|---|---|
| Auto mode with a wide table and the window is resized | The table is measured again and is marked wide with its breakout |
| A content patch, an image load, a toolbar collapse, a table-of-contents toggle or a change of the edited element | The wide elements are measured again |
| An editor opens or closes on a top-level block that cannot break out (a paragraph, a heading, a list) | Nothing is measured again: no verdict can change |
nominalRe-measure keeps the sideways scroll
GivenAuto mode and a wide table that the reader scrolled sideways
Whena layout pass measures it again (a cell editor closes, the pane is resized, an image loads)
Thenits scrollLeft is kept, clamped to the new maximum scroll (scroll width minus box width)
when the breakout width changes the table keeps the same pixel offset, clamped, not a proportional one
when the breakout width changes the table keeps the same pixel offset, clamped, not a proportional one
Implemented in 2
Tested by 9
- test/core/preview/previewStyles.test.tsunit
- test/page/diagReq.layout.requirements.test.tsunit
- test/page/runtimePageControls.test.tsunit
- test/page/runtimeScroll.test.tsunit
- test/page/tableBreakout.test.tsunit
- test/page/widthModeScenarios.test.tsunit
- test/visual/capture_layout_checks.pyvisual
- test/visual/capture_width_scroll.pyvisual
- test/visual/widthScrollScenarios.tsvisual
Known limits (3)
- Only top-level blocks, or the paragraph holding only an image, break out.
- No visual scenario combines the open table-of-contents column with Auto; the TOC case is a unit test only, and the TOC column itself belongs to the toolbar requirements.
- The re-measure after a content patch, an image load and a table-of-contents toggle has no unit test (the content patch test builds the runtime but asserts nothing about width).
Replaces
SwRS-MDOKFSTUDIO-LAYOUT-024Auto width excludes the open table-of-contents column superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-023 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-025Auto measures a wide table uncapped and rounds up superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-023 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-026Auto leaves edited and relatively sized elements in the column superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-023 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-027Auto uses the author's pixel width for an image breakout superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-023 Markdown file
SwRS-MDOKFSTUDIO-LAYOUT-031Auto measures wide elements again when the layout changes superseded superseded by SwRS-MDOKFSTUDIO-LAYOUT-023 Markdown file