DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge storytold/main (v0.14.0) into running-header-order
Claude94e0e752492b
diff --cc ROADMAP.mdindex 6bd0158e3,c02176bab..069f3839d--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -348,7 -380,74 +380,75 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+ - **2026-10-27** · An iconic panel's flyout stays open while you work in the canvas or a text field: Auto-Collapse Iconic Panels is off by default, and preferences saved with it on start with it off. Preferences › Interface › Panels holds the setting next to the column bar's menu item. No readiness percentage change.+ - **2026-10-24** · Column rules run from the top line's ascent to the bottom line's descent, as InDesign draws them, instead of from the top to the bottom of the columns, on screen, in PDF and in PowerPoint export. The top and bottom insets shorten the rule from those lines. Existing documents draw their column rules at the new length. No readiness percentage change.+ - **2026-10-20** · Edit › Keyboard Shortcuts is craft-keymap's shared dialog: commands grouped by menu with Show and Filter, recording that asks before taking a key from another command, undo and redo, named shortcut sets (edits of Default become Custom; an imported set becomes a set of its own), an on-screen US keyboard, InDesign Show Set files reviewed before they apply, JSON export and an HTML summary. ui.json keeps the `shortcuts` map earlier versions read, for the active set. No readiness percentage change.+ - **2026-10-19** · Import InDesign Set… runs on craft-keymap's importer: a set's Window menu panel items (Layers F7, Pages F12, Swatches F5) and Tools items set the panel and tool shortcuts, all of an item's Default keys apply, and the report adds numeric keypad keys read as main keys and likely commands for unmatched items (`window.importShortcuts`). On InDesign's Windows defaults it matches 366 of 1,629 items (was 233) and changes 23 commands. No readiness percentage change.+ - **2026-10-19** · Keyboard shortcuts run on the shared craft-keymap crate. Panels take shortcuts, with InDesign's defaults where the key is free (Swatches F5, Color F6, Layers F7, Info F8, Stroke F10, Paragraph Styles F11, Character Styles Shift+F11, Pages F12, Align Shift+F7); tool keys are editable in Edit › Keyboard Shortcuts and `window.setShortcut`, and tools sharing a key take turns (B). Saved shortcuts load unchanged. No readiness percentage change.+ - **2026-10-16** · Edit › Keyboard Shortcuts imports a set saved by InDesign's Show Set (.txt, Windows or Mac key names, UTF-8 or UTF-16): matched commands take its Default shortcuts or lose theirs, other commands give up keys it takes, and a report lists what it changed and the items it could not match (`window.importShortcuts`, #1180). Tool keys stay fixed. No readiness percentage change.+ - **2026-10-20** · PDF/X-1a:2003 export (craft-libs#194): `file.exportPdf {standard: "x1a"}`, the Export PDF dialog's PDF/X-1a:2003 preset and standard. The PDF/X-4 print file is flattened in its inks by craft-prepress (no transparency; spot, process, overprint and live text kept; complex regions as DeviceN images at the Transparency Flattener preset's resolution), then written as PDF 1.4 with the X-1a identification and checked; `validate-pdf --standard x1a`. Soft drop shadows reach the flattener in their swatch's inks; other soft effects are still RGB images. No readiness percentage change.+ - **2026-10-20** · Print color (craft-libs#190): CMYK print PDFs blend in DeviceCMYK through craft-pdf's print settings instead of byte rewrites, with the CMYK working space as the output intent in PDF/X-4 only; overprint (Overprint Fill, Stroke and Gap, overprinting text, 100% [Black]) is written as `/op` `/OP` `/OPM 1`; Knockout Group writes `/K true` instead of becoming an image; File › Print prints the PDF Export PDF writes. No readiness percentage change.+ - **2026-10-20** · Separations Preview shows the plates the exported PDF prints, spot plates included: each visible spread is exported in memory with the Export PDF settings and separated by craft-prepress off the UI thread, then shown as all inks, one plate or an ink limit. The Ink Manager builds craft-prepress's `InkSet` from the document for export and preview. On the sample magazine the first preview of a spread takes about 0.6–1.1 s, most of it the PDF export. No readiness percentage change.+ - **2026-10-20** · Spot gradients print on their plates. A gradient stop keeps the swatch it was given (Gradient panel drop, `swatch.create {gradient}`, `object.gradient`, IDML `StopColor`), following its renames and edits. PDF export shades one spot with its tints or [Paper] as a Separation, and a spot with process inks or a second spot as DeviceN; a process gradient to [Paper] prints in DeviceCMYK. Documents with plain-color stops export as before. No readiness percentage change.+ - **2026-10-24** · Panels dock through the suite's shared docking (craft-libs), and on desktop a floating panel opens in its own window that can leave the main window: keys pressed there run the main window's shortcuts, clipboard and tool keys, and the canvas paints no tool cursor while another of the app's windows has the pointer. The web build keeps floating panels in the page. No readiness percentage change.+ - **2026-10-24** · Story Options rejects malformed or nonexistent explicit story/frame IDs without changing the selected story, including an invalid frame alongside a valid story. Null targets remain absent; omitted targets still use the selection. No readiness percentage change.+ - **2026-10-24** · Text Frame Options explains that a custom baseline-grid increment must be a measure greater than zero when zero, a negative value or a non-measure is entered. Validation is unchanged. No readiness percentage change.+ - **2026-10-24** · Renaming a paragraph or character style, or moving it into a style group, keeps its Export Tagging under the new name, and undo puts it back under the old one. Deleting a tagged style drops its tagging and leaves the replacement style's own tagging as it was. No readiness percentage change.+ - **2026-10-24** · Quick Apply and the application bar's search leave out the interface commands that failed or reset a setting when chosen there: those that need a workspace, a command and shortcut, a menu item, a panel, a window edge, an app page, a recent file or a swatch they can't give them, a Contextual Task Bar place, and Interface Color Theme, UI Scaling, Reset Shortcuts, the flattener preset, Screen Mode and Zoom To, which without a value switched to the dark theme, set 100%, cleared every custom shortcut or the preset, or went to Normal mode or 100% zoom. Each stays in the menu, panel or dialog that gives it the value. No readiness percentage change.+ - **2026-10-24** · EPUB Export Options › Split Document, a dialog before File › Export EPUB… saves (`document.epubSplit`, stored with the document): off, a single paragraph style, or based on paragraph style export tags, with Paragraph Style Options › Export Tagging's Split Document flag marking those styles. A reflowable EPUB is one content file unless Split Document is on; the split before each top-level h1 from #791 is gone. A split before a list item or preformatted line no longer leaves an unclosed list or block in a content file. IDML import and export keep the setting and the flag, and Load Styles the flag. No readiness percentage change.+ - **2026-10-18** · Repeated placed-PDF layer variants are prepared once per asset and hidden-name set, with recovery warnings retained. All-visible named layers keep their original source bytes, including PDFs whose cross-reference tables the reader repairs, in plain, PDF/X-4, booklet and book-merge output. Layer changes that require writing still reject an unusable cross-reference table with a file-named damage error; the first placement error is retained (#906). No readiness percentage change.+ - **2026-10-18** · Placed PDF optional-content defaults and per-frame overrides survive plain and PDF/X-4 vector export, including repeated placements, booklet output and book merging (#906). Source usage-application arrays are accepted; groups without a catalog configuration stay visible. Missing or unreadable default configurations and unsupported base states use all-ON defaults with a file-named export warning, retaining explicit frame overrides. Readable groups omitted from the catalog list are added with a distinct file-named warning, preserving their default ON/OFF states. Concurrent recovery warnings are combined. Malformed ON data is recoverable when a known ON base and empty OFF list prove it cannot hide artwork; missing display names are generated without changing known visibility when no override needs name matching. Contradictory states, unresolved references and ambiguous name overrides still fail export. Print-usage adjustments and IDML layer overrides remain follow-ups. No readiness percentage change.++ - **2026-10-24** · Optical Margin Alignment and hanging punctuation apply to lines with a tab or a right indent tab, as both composers already measured them: the edge glyphs hang, and tab stops stay where they are. Such a line was set without the hang: a justified line that fit only because its period or closing quote hangs had its word spaces squeezed to make up for it, and text after a right indent tab stopped at the measure instead of hanging. No readiness percentage change.+ - **2026-10-23** · `designcraft-cli mcp` takes `--automation-read-root` and `--automation-write-root` more than once, as the suite's other apps do (#1552): a path inside any root of its kind passes, and the roots' common parent, `..` or a link out of them and the other kind's roots stay refused. No readiness percentage change.+ - **2026-10-23** · Layout › Go Back and Go Forward (Cmd+Page Up / Cmd+Page Down, Ctrl on Windows and Linux) retrace the jumps between pages (Go to Page, the page and spread commands, the Pages panel) as InDesign's do, returning to where the view was on each page at the current zoom; a new jump after going back drops the pages ahead, scrolling adds no entry, and pages deleted since are skipped. No readiness percentage change.+ - **2026-10-24** · The Story Editor has InDesign's vertical depth ruler between the style column and the text, and View › Story Editor › Show/Hide Depth Ruler (`view.storyEditorDepthRuler`) shows or hides it in the Story Editor, remembered with the preferences. The ruler is marked in the document's vertical ruler units with how deep the story's text fills its frames, counted through its columns and threaded frames (lines set side by side, in the sub-columns of a split paragraph or on both sides of a wrap object, count once), and is shaded down to the overset point, where a red line now crosses the editor. No readiness percentage change.+ - **2026-10-24** · Split Note (`note.split {story, id, at}`, the Notes panel's Split Note button): as in InDesign, a note splits in two at the insertion point in its text. DesignCraft moves the text after it into a new note by the same author, anchored right after the first. No readiness percentage change.+ - **2026-10-24** · Type › Notes › Previous Note and Next Note (`note.previous`, `note.next`): as in InDesign, they move the insertion point from note to note in the story, putting the caret after the note's anchor. Each item is unavailable when no note lies in its direction in the story, or when the insertion point is in a table cell or a footnote. No readiness percentage change.+ - **2026-10-24** · Type › Notes › Convert to Note (`note.convertFromText {author?}`): as in InDesign, the selected text leaves the story and becomes the text of a new note, whose anchor takes its place; Convert Note to Text puts it back. DesignCraft refuses a selection in a table cell, or one that holds a note, footnote, endnote, anchored object, index marker, text anchor, cross-reference or table. No readiness percentage change.+ - **2026-10-23** · Effects dialog: with Use Global Light on, the Angle field (and the Bevel and Emboss one) stays editable and shows the document's global light angle; a change there sets the global light for every effect that uses it, applied with the effects in one undo step (`object.effects` takes `globalLight`). Before, the field was greyed out and the angle couldn't be changed in the dialog. No readiness percentage change.+ - **2026-10-24** · Story panel (Window › Type & Tables › Story): Optical Margin Alignment and its size for the stories of the text selection or the selected text frames, disabled without either; `type.selectionAttrs` reports them as `storyOptions`, null where the stories differ. The Paragraph panel menu has Ignore Optical Margin in place of the per-paragraph Optical Margin Alignment switch, which stays in `type.para`, and Paragraph Style Options › Indents and Spacing has Ignore Optical Margin (#947). No readiness percentage change.+ - **2026-10-24** · Optical Margin Alignment per story with a size (`story.options {opticalMargin, opticalMarginSize}`, off by default): when it is on, the story's paragraphs hang punctuation and letter edges by amounts set for that type size, except paragraphs with Ignore Optical Margin (`ignoreOpticalMargin` in `type.para` and paragraph styles). Table cells and footnotes don't take the story setting yet. When it is off, the per-paragraph switch still hangs at the text's own size. IDML imports and exports both (`StoryPreference/@OpticalMarginAlignment`, `@OpticalMarginSize`, `IgnoreEdgeAlignment`) (#947). No readiness percentage change.+ - **2026-10-24** · Text frames: a custom baseline grid's Relative To (Text Frame Options › Baseline Options, `object.textFrameOptions {baselineGrid: {relativeTo}}`, IDML `BaselineFrameGridRelativeOption`) measures the grid's start from the top of the page, the top margin, the top of the frame or its top inset. Text Frame Options had no custom baseline grid controls, imports dropped the setting and every frame grid started from the page top, so grid-aligned text in a frame measured from its own top sat on the wrong lines. No readiness percentage change.+ - **2026-10-24** · Paragraph Style Options › Indents and Spacing has an Align to Grid menu: None, All Lines or First Line Only. It shows the style's current setting. A First Line Only style could be set only in the CJK Grid Settings section, which shows only with CJK features on, or through commands. No readiness percentage change.+ - **2026-10-24** · Anchored text frames, such as marginal notes, compose where their host story places them: they align to the baseline grid at that position, and page-number markers and spine-relative alignment inside them read the host's page. They composed against a grid measured from their stored position and on no page, so a note set to Only Align First Line to Grid could sit a fraction of a line off the body text's grid line. No readiness percentage change.+ - **2026-10-24** · Tables: a gradient swatch in a cell fill draws as a gradient on the canvas and in PDF, in one gradient space for the whole table, so it runs across cells without restarting. Cells showed the gradient's first stop as a solid colour. No readiness percentage change.+ - **2026-10-24** · New documents start with Hyphenate Capitalized Words, Hyphenate Last Word and Hyphenate Across Column off in [Basic Paragraph], as in InDesign. Opened and imported files keep the values they carry. No readiness percentage change.+ - **2026-10-24** · The baseline grid's Relative To setting applies: with Top Margin, the grid starts at each page's own top margin in text composition, on the canvas and for snapping. It started at the page top, so grid-aligned text sat on the wrong lines and a page could fit one line fewer. No readiness percentage change.+ - **2026-10-24** · Custom-positioned anchored objects honour Relative to Spine (`anchored.options {spineRelative}`, IDML `SpineRelative`): the settings describe a left-hand page and mirror on a right-hand page, so marginal notes stay in the outside margin on both pages of a spread. On right-hand pages they took the left-hand placement and landed in the inside margin, across the spine or over the body text. No readiness percentage change.+ - **2026-10-24** · Text frames: a custom baseline grid (Text Frame Options › Baseline Options) from an IDML file sets lines from its start by its increment. The composer read the two values in the other order, so lines landed on the wrong grid. No readiness percentage change.+ - **2026-10-23** · File › File Info… edits the document's Document Title, Author, Description, Keywords, Copyright Notice and Copyright Info URL (`file.info`), and the document saves them. PDF export (PDF/X-4 and Print Booklet included) writes the title, author, description and keywords into the PDF's document information and XMP. EPUB export takes the title and author from File Info, and HTML export takes the title. A title or author given to the export replaces File Info's, and an empty Document Title leaves the document's name as the title. No readiness percentage change.+ - **2026-10-23** · Save and export dialogs (Save As, Save a Copy, Export PDF and the other exports, Package, libraries and books) start in the active document's folder once it has been saved, and for a document never saved in the folder of the last file saved or exported, remembered across sessions (#1653). A folder deleted since falls back to the system's choice. No readiness percentage change.+ - **2026-10-22** · Autoflow (Shift-click with the loaded text cursor, autoflow on Place, `text.thread {autoflow}`) fills the pages that follow before it adds any, as InDesign does: one frame per column on each following page, whatever else the page holds, then new pages at the end of the document. It inserted pages right after the story's last frame, in front of the document's own pages. Frames it set past the end of the text go again; a page the document had stays, and a page autoflow added only for such a frame goes with it. Smart Text Reflow of the primary text frame is unchanged. No readiness percentage change.+ - **2026-10-16** · Edit › Keyboard Shortcuts imports a set saved by InDesign's Show Set (.txt, Windows or Mac key names, UTF-8 or UTF-16): matched commands take its Default shortcuts or lose theirs, other commands give up keys it takes, and a report lists what it changed and the items it could not match (`window.importShortcuts`, #1180). Tool keys stay fixed. No readiness percentage change.+ - **2026-10-23** · Translations: a missing string shows in English and fails no test; `cargo xtask i18n-report`, run by `cargo xtask ci`, prints the missing strings per language. Tests keep duplicate-key and placeholder checks and the language mechanics (lookup, context captions, plural captions, right-to-left). No readiness percentage change.+ - **2026-10-22** · Hyphenation Settings, as in InDesign: the Paragraph panel menu's Hyphenation… (`app.hyphenationDialog`) sets the selected paragraphs' Hyphenate, Words with at Least, After First, Before Last, Hyphen Limit, Hyphenation Zone, the Better Spacing ↔ Fewer Hyphens slider (InDesign's 0–10 steps), Hyphenate Capitalized Words, Last Word and Across Column, with Preview, as one undo step; Paragraph Style Options › Hyphenation has the same form. The panel menu lists its items in InDesign's order. Replicated from a hyphenation tutorial: the same text in Minion Pro breaks into the same lines as InDesign's with hyphenation on, off, and at Fewer Hyphens. No readiness percentage change.+ - **2026-10-22** · Hyphenate Across Column (Hyphenation Settings; IDML HyphenateAcrossColumns) is applied: with it off, a paragraph whose line ending in an automatic hyphen would end a column or frame is re-composed without that hyphenation point, so the word moves on whole, as in InDesign. Opened and imported files keep their own setting, so their layouts don't change. No readiness percentage change.+ - **2026-10-22** · The Paragraph panel is laid out as InDesign's: the nine alignment buttons in groups; indent, spacing and drop cap fields by their icons in two columns, with Space Between Paragraphs Using Same Style (Ignore or a space); Shading and Border with the Paragraph Borders and Shading button and colour; Hyphenate with Do Not Align / Align to Baseline Grid. Its panel menu follows InDesign's order: Paragraph and Single-line Composer, Only Align First Line to Grid, Balance Ragged Lines, Optical Margin Alignment, Justification…, Keep Options…, Span Columns…, Hyphenation…, Drop Caps and Nested Styles…, GREP Styles… (these three now open for the selected paragraphs), Paragraph Rules…, Paragraph Borders and Shading…, Bullets and Numbering…, Restart/Continue Numbering, Define Lists… and the paragraph direction. Convert Bullets and Numbering to Text is listed but not available yet. No readiness percentage change.+ - **2026-10-22** · A ruler guide dragged with the Selection tools, out of a ruler, on its own or with other selected guides, snaps along its axis as objects do (#1221): to other ruler guides, margins, columns, bleed, page and object edges and centers (with the smart-guide mark) and the document grid, within the snap zone and following Snap to Guides and Smart Guides. Shift snaps to the ruler's ticks and Cmd suspends snapping. The preview line, the position readout and the drop use the same snapped position. No readiness percentage change.+ - **2026-10-22** · macOS: the app menu has a Language submenu after Settings… with each interface language in its own name and the current one checked, as in the suite's other apps; Preferences › General › Interface Language stays. No readiness percentage change.+ - **2026-10-23** · Type › Text Variables › Convert Variable to Text (`variables.convertToText`): the variable instances in the selected text, in a story, a table cell or a footnote, become plain text of the value each shows on its own page (a running header on page 3 becomes page 3's heading). `variables.convertAllToText {name}` does the same for every instance of one variable in the document, as the Text Variables dialog's Convert to Text button. The variable stays defined; one undo step. No readiness percentage change.+ - **2026-10-22** · macOS menu bar: the menus keep working after the interface language or Show CJK Features changes (a rebuilt menu bar lost every click, Quit included), and its key equivalents are the shortcuts in effect, so a shortcut moved in the Keyboard Shortcuts editor leaves its old menu item. No readiness percentage change.+ - **2026-10-22** · Paragraph rules: Rule Above's offset is measured from the first line's baseline to the rule's bottom edge, as in InDesign. Rules sat one ascent too high and crossed the previous paragraph's text (reported from an imported INDD document). No readiness percentage change.+ - **2026-10-21** · Ruler guides are selected like objects (#1282): a click with the Selection tools selects a guide (also where it crosses an object), Shift-click adds or removes one, a new guide from the rulers is selected, a marquee that touches no object selects the guides it crosses, and Edit › Select All Guides (⌥⌘G, `guide.selectAll`) selects every unlocked guide on the spread. Selected guides draw thicker in their layer's color, drag together (all of them shown moving), nudge with the arrow keys and go with Delete, each as one undo step (`guide.select`, `guide.deselect`, `guide.moveBy`, `guide.delete {}`). With one guide selected the Control bar's X (vertical guide) or Y (horizontal guide) field and Properties › Transform show where it is, as the rulers measure, and typing a value moves it there. No readiness percentage change.+ - **2026-10-17** · PDF/X-4 export warns about fonts drawing visible text without an embedded+ font program, including placed PDF forms; `validate-pdf` reports the font and page (#909).+ Invisible OCR text is exempt. Detection only: fonts are not embedded or outlined automatically.+ Repeated forms reuse context-aware font findings; a document-wide operation limit and a form-nesting depth limit+ report incomplete checks instead of allowing excessive nested-form traversal.+ No readiness percentage change.+ - **2026-10-16** · Selection: drag a column guide to move its gutter, as in InDesign (#1096). Both guides of the gutter move together and keep its width, stop at the neighbouring guides and the margins, and snap to the document grid, guides and objects, or with Shift to the ruler's tick marks; Escape cancels and the drag is one undo step. Locked column guides (the default) are not picked. A document page takes the result as its own columns; on a parent page it passes to the pages that follow it. `layout.moveColumnGuide` does the same over the control channel and MCP. No readiness percentage change.+ - **2026-10-16** · Layout: autoflow, inserted pages and new parents follow dragged column guides (#1096). Autoflow sets one frame per dragged column and counts the pages it adds from them; Insert Pages and New Parent keep the custom positions with the column count and gutter; a page that moves to the other side of the spine (inserted, deleted or moved pages, Duplicate Spread, a new parent's other page) has them mirrored across its margin box, as InDesign does; `document.inspect` reports each page's gutter, column rects and whether its columns are custom. No readiness percentage change.+ - **2026-10-16** · Layout: Margins and Columns keeps dragged column guides unless the column count or gutter changes (#1096). The dialog sends every field on OK, so a margin-only change re-divided the columns evenly. Margin changes keep the positions; the columns follow them only while they fit the margin box. No readiness percentage change.+ - **2026-10-16** · Lock Guides and Lock Column Guides are commands in View ▸ Grids & Guides (`view.lockGuides`, ⌥⌘;, and `view.lockColumnGuides`), so the control channel and MCP reach them. Lock Column Guides is an undo step, is saved with the document, on in new ones, and read from and written to IDML's `ColumnGuideLocked`, which export always wrote as locked (#1096). No readiness percentage change.+ - **2026-10-16** · IDML: a page keeps column guides that were dragged off centre (InDesign's Custom columns). They were divided evenly on import, so the gutter sprang back to the middle; the imported positions now place the columns, with the canvas guides, snapping and text placement following them, and they are written back on export. Layout › Margins and Columns re-divides them evenly when the count or gutter changes, as InDesign's does. No readiness percentage change.+ - **2026-10-16** · IDML: custom column positions are checked before they are used (#1096). A set must give two edges per column, ascending from the left margin to the right one; any other (a wrong count, unsorted or non-numeric values, a list longer than 216 columns allow, or positions left behind by a margin or page-size change) is the even split, in the canvas, on import and on export, instead of columns drawn outside the margins. No readiness percentage change.+ - **2026-10-21** · Properties › Character and Paragraph: ••• (More Options) expands the section in place, as InDesign's: Character adds vertical and horizontal scale, baseline shift, skew, language and OpenType, and All Caps, Small Caps, Superscript, Subscript, Underline and Strikethrough; Paragraph adds the left, right, first line and last line indents, space before and after, the drop cap's lines and characters, Align to Baseline Grid and Hyphenate. It used to open the Character or Paragraph panel; the language field moved under ••• as in InDesign. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.+ - **2026-10-21** · The text Control panel has InDesign's two modes: A (Character Formatting Controls: font and style, size and leading, All Caps/Superscript/Underline and Small Caps/Subscript/Strikethrough, kerning and tracking, vertical and horizontal scale, baseline shift and skew, character style and language) and ¶ (Paragraph Formatting Controls: the nine alignments, left/first line and right/last line indents, space before and after, the drop cap's lines and characters, paragraph style, Hyphenate and Align to Baseline Grid). It used to show a fixed mix of both. Found in the Learn Skills Daily course, chapter 16. No readiness percentage change.+ - **2026-10-20** · With the Type tool, the Control panel's font size, leading and tracking fields have a spinner and a list of common values, as in InDesign (auto leading in parentheses). No readiness percentage change.+ - **2026-10-21** · The ¶ (Paragraph Formatting Controls) mode of the text Control panel has InDesign's Bulleted List and Numbered List buttons (with the default hanging indent) and Shading and Border: a checkbox, a button opening Paragraph Borders and Shading on that tab, and the colour. Found in the Learn Skills Daily course, chapter 21. No readiness percentage change.+ - **2026-10-21** · The Bulleted and Numbered List buttons (Properties, and Type › Bulleted & Numbered Lists › Apply Bullets / Apply Numbers) work as InDesign's: a paragraph with no indents gets the default hanging indent (0.25 in, −0.25 in), so the text lines up after the bullet instead of at the next default tab stop, and pressing the button again removes the list and that indent (`list.bullets`, `list.numbers`). Found in the Learn Skills Daily course, chapter 21. No readiness percentage change.+- **2026-10-17** · Running headers: *first/last on page* read a page in text order (story order, then column by column), not by height — a multi-column page's right header showed the lowest entry of column 1 instead of the page's last entry. No readiness percentage change.- **2026-10-16** · Type › Reload Fonts (`font.reload`): fonts installed, edited or removed while DesignCraft runs are read again without a restart, and the open documents recompose with them (#328, #547). An edited font file is noticed by its length and modification time; bundled, added and document fonts stay as they are. InDesign does this by itself, so noticing changes automatically is still open (gap 6). No readiness percentage change.- **2026-10-16** · Parents can be deleted from their Pages-panel context menu or `layout.parents.delete {id}`. Applied-page and based-on references are cleared, local override copies survive, and Undo restores the parent. Addresses the deletion portion of #956; no readiness percentage change.- **2026-10-17** · File › Package writes the document's and the IDML's links relative to the package (`Links/logo.png`, `file:Links/logo.png`), so a package holds no path from the machine that made it; opening a document resolves them to the files beside it. Links › Copy Link(s) To still links by full path. (#340). No readiness percentage change.diff --cc crates/engine/src/cmd/variables/tests.rsindex 000000000,4a4832c84..75c4bcaedmode 000000,100644..100644--- a/crates/engine/src/cmd/variables/tests.rs+++ b/crates/engine/src/cmd/variables/tests.rs@@@ -1,0 -1,356 +1,423 @@@+ use super::*;++ /// A parent-page page-number marker follows Numbering & Section Options: changing a section's+ /// start number renames its pages without changing their index or the number of sections, and+ /// the marker composed for a page shows the new name.+ #[test]+ fn parent_page_number_follows_section_renumbering() {+ let mut s = Session::new();+ s.execute("file.new", &json!({"pages": 3, "facingPages": false})).unwrap();+ let marker = designcraft_doc::story::PAGE_NUMBER.to_string();+ let r = s+ .execute("frame.create", &json!({"spread": {"kind": "parent", "index": 0}, "rect": [72, 30, 500, 60], "content": "text", "text": marker}))+ .unwrap();+ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ assert_eq!(s.doc().unwrap().doc.story(sid).unwrap().text, marker);+ let shown = |s: &Session, page: usize| -> usize {+ let d = s.doc().unwrap().doc.clone();+ let cs = s.cache.get(&d, sid, Some(page));+ cs.frames.iter().flat_map(|f| f.lines.iter()).map(|l| l.glyphs.iter().filter(|g| g.visible && g.adv > 0.0).count()).sum()+ };+ assert_eq!(shown(&s, 2), 1, "page 3");+ s.execute("layout.section", &json!({"page": 1, "startNumber": 100})).unwrap();+ assert_eq!(s.doc().unwrap().doc.page_name(2), "102");+ assert_eq!(shown(&s, 2), 3, "page 102 after renumbering");+ }++ /// A section marker character shows the marker text of the section of the page it is composed+ /// for: on each document page a parent-page frame is shown on, and in a frame on a document+ /// page. A section without marker text shows nothing; the parent page itself shows "Section".+ #[test]+ fn section_marker_shows_the_pages_section_marker() {+ let mut s = Session::new();+ s.execute("file.new", &json!({"pages": 4, "facingPages": false})).unwrap();+ s.execute("layout.section", &json!({"page": 3, "startNumber": 1, "marker": "Intro"})).unwrap();+ let marker = designcraft_doc::story::SECTION_MARKER.to_string();+ let r = s+ .execute("frame.create", &json!({"spread": {"kind": "parent", "index": 0}, "rect": [72, 30, 500, 60], "content": "text", "text": marker}))+ .unwrap();+ let parent = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ let sp = s.doc().unwrap().doc.page_loc(3).unwrap().0;+ let r = s.execute("frame.create", &json!({"spread": sp, "rect": [72, 200, 400, 260], "content": "text", "text": marker})).unwrap();+ let own = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ let shown = |s: &Session, sid, page: Option<usize>| -> usize {+ let d = s.doc().unwrap().doc.clone();+ let cs = s.cache.get(&d, sid, page);+ cs.frames.iter().flat_map(|f| f.lines.iter()).map(|l| l.glyphs.iter().filter(|g| g.visible && g.adv > 0.0).count()).sum()+ };+ assert_eq!(shown(&s, parent, Some(0)), 0, "the first section has no marker");+ assert_eq!(shown(&s, parent, Some(2)), "Intro".len());+ assert_eq!(shown(&s, parent, Some(3)), "Intro".len());+ assert_eq!(shown(&s, own, None), "Intro".len(), "a frame on a document page");+ assert_eq!(shown(&s, parent, None), "Section".len(), "the parent page itself");+ // Editing the marker recomposes.+ s.execute("layout.section", &json!({"page": 3, "marker": "Appendix"})).unwrap();+ assert_eq!(shown(&s, parent, Some(2)), "Appendix".len());+ assert_eq!(shown(&s, own, None), "Appendix".len());+ }++ /// Two sections that both number from 1 repeat page names ("1, 2, 1, 2"). A parent-page running+ /// header is composed for the page it is shown on, not the first page with that name.+ #[test]+ fn running_header_on_parent_page_with_repeated_page_numbers() {+ let mut s = Session::new();+ s.execute("file.new", &json!({"pages": 4, "facingPages": false})).unwrap();+ s.execute("layout.section", &json!({"page": 3, "startNumber": 1})).unwrap();+ let names: Vec<String> = (0..4).map(|i| s.doc().unwrap().doc.page_name(i)).collect();+ assert_eq!(names, ["1", "2", "1", "2"]);+ s.execute("style.paragraph.create", &json!({"name": "Heading"})).ok();+ // The only heading is on the third page (the second section's page 1).+ let sp = s.doc().unwrap().doc.page_loc(2).unwrap().0;+ let r = s.execute("frame.create", &json!({"spread": sp, "rect": [72, 200, 400, 260], "content": "text", "text": "Epsilon"})).unwrap();+ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 1})).unwrap();+ s.execute("style.paragraph.apply", &json!({"name": "Heading"})).unwrap();+ s.execute("variables.define", &json!({"name": "Chapter Head", "type": "runningHeader", "style": "Heading"})).unwrap();+ let r = s+ .execute("frame.create", &json!({"spread": {"kind": "parent", "index": 0}, "rect": [72, 30, 500, 60], "content": "text", "text": ""}))+ .unwrap();+ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 0})).unwrap();+ s.execute("variables.insert", &json!({"name": "Chapter Head"})).unwrap();+ let d = s.doc().unwrap().doc.clone();+ let shown = |page: usize| -> usize {+ let cs = s.cache.get(&d, sid, Some(page));+ cs.frames.iter().flat_map(|f| f.lines.iter()).map(|l| l.glyphs.iter().filter(|g| g.visible && g.adv > 0.0).count()).sum()+ };+ assert_eq!(shown(0), 0, "no heading on or before the first page");+ assert_eq!(shown(2), "Epsilon".len(), "the third page (named 1) shows its own heading");+ assert_eq!(shown(3), "Epsilon".len(), "the fourth page (named 2) carries it");+ }++ /// Three pages with "Alpha" in the Heading style on page 1 and "Epsilon" on page 3, a+ /// `Chapter Head` running header on Heading, and a text frame on pages 1 and 3 that each hold+ /// "<head>|<head>" (two instances). Returns the two frames' stories.+ fn running_heads() -> (Session, designcraft_doc::StoryId, designcraft_doc::StoryId) {+ let mut s = Session::new();+ s.execute("file.new", &json!({"pages": 3, "facingPages": false})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Heading"})).ok();+ let frame = |s: &mut Session, page: usize, y: f64, text: &str| {+ let sp = s.doc().unwrap().doc.page_loc(page).unwrap().0;+ let r = s.execute("frame.create", &json!({"spread": sp, "rect": [72, y, 400, y + 60.0], "content": "text", "text": text})).unwrap();+ s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story+ };+ for (page, text) in [(0, "Alpha"), (2, "Epsilon")] {+ let sid = frame(&mut s, page, 200.0, text);+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 1})).unwrap();+ s.execute("style.paragraph.apply", &json!({"name": "Heading"})).unwrap();+ }+ s.execute("variables.define", &json!({"name": "Chapter Head", "type": "runningHeader", "style": "Heading"})).unwrap();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let both = format!("{c}|{c}");+ let (p1, p3) = (frame(&mut s, 0, 400.0, &both), frame(&mut s, 2, 400.0, &both));+ (s, p1, p3)+ }++ /// Convert Variable to Text turns the selected instance into the value it shows on its own+ /// page (Epsilon on page 3, not page 1's Alpha); the other instance and the variable stay.+ #[test]+ fn convert_variable_to_text_uses_the_instances_page() {+ let (mut s, p1, p3) = running_heads();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let second = c.len_utf8() + 1;+ s.execute("text.select", &json!({"story": p3.0, "anchor": second, "focus": second + c.len_utf8()})).unwrap();+ s.execute("variables.convertToText", &json!({})).unwrap();+ let d = &s.doc().unwrap().doc;+ assert_eq!(d.story(p3).unwrap().text, format!("{c}|Epsilon"), "only the selected instance");+ assert_eq!(d.story(p1).unwrap().text, format!("{c}|{c}"));+ assert!(d.variable("Chapter Head").is_some(), "the variable stays defined");+ let t = s.doc().unwrap().selection.text.unwrap();+ assert_eq!((t.anchor, t.focus), (second, second + "Epsilon".len()), "the converted text stays selected");+ s.execute("edit.undo", &json!({})).unwrap();+ assert_eq!(s.doc().unwrap().doc.story(p3).unwrap().text, format!("{c}|{c}"), "one undo step");+ }++ /// The menu item is enabled only for a selection that holds an instance: not a caret, not+ /// text without one.+ #[test]+ fn convert_variable_to_text_needs_a_selected_instance() {+ let (mut s, p1, _) = running_heads();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let bar = c.len_utf8();+ let enabled = |s: &Session| (crate::find_command("variables.convertToText").unwrap().enabled)(s).is_ok();+ for (anchor, focus) in [(0, 0), (bar, bar + 1)] {+ s.execute("text.select", &json!({"story": p1.0, "anchor": anchor, "focus": focus})).unwrap();+ assert!(!enabled(&s), "{anchor}..{focus}");+ }+ s.execute("text.select", &json!({"story": p1.0, "anchor": 0, "focus": bar})).unwrap();+ assert!(enabled(&s));+ }++ /// A story threaded from a frame on page 1, which holds only "Lead", to a frame on page 3,+ /// where the caret is left at the end of "Body". A cell's or a note's own byte 0 read in this+ /// story is on page 1, its anchor on page 3.+ fn threaded(s: &mut Session) -> designcraft_doc::StoryId {+ let sp1 = s.doc().unwrap().doc.page_loc(0).unwrap().0;+ let sp3 = s.doc().unwrap().doc.page_loc(2).unwrap().0;+ let r = s.execute("frame.create", &json!({"spread": sp1, "rect": [72, 500, 400, 520], "content": "text", "text": "Lead\nBody"})).unwrap();+ let from = r["id"].as_u64().unwrap();+ s.execute("text.thread", &json!({"from": from, "rect": [72, 500, 400, 700], "spread": sp3})).unwrap();+ let d = s.doc().unwrap().doc.clone();+ let sid = d.item(designcraft_doc::ItemId(from)).unwrap().text_frame().unwrap().story;+ let cs = s.cache.get(&d, sid, None);+ let page = |pos| designcraft_compose::vars::page_of(&d, &cs, pos);+ assert_eq!((page(0), page("Lead\nB".len())), (Some(0), Some(2)), "Lead on page 1, Body on page 3");+ s.execute("text.select", &json!({"story": sid.0, "anchor": "Lead\nBody".len(), "focus": "Lead\nBody".len()})).unwrap();+ sid+ }++ /// An instance selected in a table cell becomes the value on the page of the table's anchor.+ #[test]+ fn convert_variable_to_text_in_a_table_cell() {+ let (mut s, ..) = running_heads();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let sid = threaded(&mut s);+ s.execute("table.insert", &json!({"rows": 1, "cols": 1})).unwrap();+ s.execute("table.setCell", &json!({"row": 0, "col": 0, "text": c.to_string()})).unwrap();+ let table = *s.doc().unwrap().doc.story(sid).unwrap().tables.keys().next().unwrap();+ let cell = designcraft_doc::CellAddr { table, row: 0, col: 0 };+ s.doc_mut().unwrap().selection =+ designcraft_doc::Selection::text(designcraft_doc::TextSel { story: sid, anchor: 0, focus: c.len_utf8(), frame: None, cell: Some(cell) });+ s.execute("variables.convertToText", &json!({})).unwrap();+ let d = &s.doc().unwrap().doc;+ assert_eq!(d.text_story(sid, Some(cell)).unwrap().text, "Epsilon");+ }++ /// An instance selected in a footnote becomes the value on the page of the note's reference.+ #[test]+ fn convert_variable_to_text_in_a_footnote() {+ let (mut s, ..) = running_heads();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let sid = threaded(&mut s);+ s.execute("footnote.insert", &json!({"text": c.to_string()})).unwrap();+ let id = s.doc().unwrap().doc.story(sid).unwrap().notes[0].id;+ let note = designcraft_doc::CellAddr::footnote(id);+ let at = s.doc().unwrap().doc.text_story(sid, Some(note)).unwrap().text.find(c).unwrap();+ s.doc_mut().unwrap().selection = designcraft_doc::Selection::text(designcraft_doc::TextSel {+ story: sid,+ anchor: at,+ focus: at + c.len_utf8(),+ frame: None,+ cell: Some(note),+ });+ s.execute("variables.convertToText", &json!({})).unwrap();+ let d = &s.doc().unwrap().doc;+ let text = &d.text_story(sid, Some(note)).unwrap().text;+ assert!(!text.contains(c) && text.ends_with("Epsilon"), "{text:?}");+ }++ /// Text Variables › Convert to Text turns every instance of the variable into the value on+ /// its page, in table cells, footnotes and endnotes on the page of their anchor, and keeps the+ /// variable.+ #[test]+ fn convert_all_instances_to_text() {+ let (mut s, p1, p3) = running_heads();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let sid = threaded(&mut s);+ let at_end = |s: &mut Session| {+ let n = s.doc().unwrap().doc.story(sid).unwrap().len();+ s.execute("text.select", &json!({"story": sid.0, "anchor": n, "focus": n})).unwrap();+ };+ s.execute("footnote.insert", &json!({"text": c.to_string()})).unwrap();+ at_end(&mut s);+ s.execute("endnote.insert", &json!({"text": c.to_string()})).unwrap();+ at_end(&mut s);+ s.execute("table.insert", &json!({"rows": 1, "cols": 1})).unwrap();+ s.execute("table.setCell", &json!({"row": 0, "col": 0, "text": c.to_string()})).unwrap();+ s.execute("variables.convertAllToText", &json!({"name": "Chapter Head"})).unwrap();+ let d = &s.doc().unwrap().doc;+ assert_eq!(d.story(p1).unwrap().text, "Alpha|Alpha");+ assert_eq!(d.story(p3).unwrap().text, "Epsilon|Epsilon");+ let st = d.story(sid).unwrap();+ assert_eq!(st.tables.values().next().unwrap().cells[0].text.text, "Epsilon", "table cell");+ assert!(st.notes[0].text.text.ends_with("Epsilon"), "footnote: {:?}", st.notes[0].text.text);+ assert!(st.endnotes[0].text.text.ends_with("Epsilon"), "endnote: {:?}", st.endnotes[0].text.text);+ assert!(d.variable("Chapter Head").is_some(), "the variable stays defined");+ }++ /// A caret in a table cell or a footnote after an instance stays after the value Convert to+ /// Text writes there, so typing lands after it.+ #[test]+ fn convert_all_keeps_the_caret_in_a_cell_or_a_footnote() {+ for footnote in [false, true] {+ let (mut s, ..) = running_heads();+ let c = var_char(s.doc().unwrap().doc.variable("Chapter Head").unwrap()).unwrap();+ let sid = threaded(&mut s);+ let text = format!("{c}|");+ let at = if footnote {+ s.execute("footnote.insert", &json!({"text": text})).unwrap();+ designcraft_doc::CellAddr::footnote(s.doc().unwrap().doc.story(sid).unwrap().notes[0].id)+ } else {+ s.execute("table.insert", &json!({"rows": 1, "cols": 1})).unwrap();+ s.execute("table.setCell", &json!({"row": 0, "col": 0, "text": text})).unwrap();+ let table = *s.doc().unwrap().doc.story(sid).unwrap().tables.keys().next().unwrap();+ designcraft_doc::CellAddr { table, row: 0, col: 0 }+ };+ let n = s.doc().unwrap().doc.text_story(sid, Some(at)).unwrap().text.len();+ s.doc_mut().unwrap().selection =+ designcraft_doc::Selection::text(designcraft_doc::TextSel { story: sid, anchor: n, focus: n, frame: None, cell: Some(at) });+ s.execute("variables.convertAllToText", &json!({"name": "Chapter Head"})).unwrap();+ s.execute("text.insert", &json!({"text": "x"})).unwrap();+ let text = &s.doc().unwrap().doc.text_story(sid, Some(at)).unwrap().text;+ assert!(text.ends_with("Epsilon|x"), "footnote {footnote}: {text:?}");+ }+ }++ /// Deleting a variable flattens its instances in table cells too and moves the instances of+ /// later variables down, so cells keep showing the same text.+ #[test]+ fn delete_variable_reaches_table_cells() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ s.execute("variables.define", &json!({"name": "A", "type": "custom", "text": "Alpha"})).unwrap();+ let b = s.execute("variables.define", &json!({"name": "B", "type": "custom", "text": "Beta"})).unwrap()["index"].as_u64().unwrap() as usize;+ let a = s.doc().unwrap().doc.variable("A").unwrap();+ let r = s.execute("frame.create", &json!({"rect": [72, 72, 400, 300], "content": "text", "text": ""})).unwrap();+ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 0})).unwrap();+ s.execute("table.insert", &json!({"rows": 1, "cols": 2})).unwrap();+ let text = format!("{}|{}", var_char(a).unwrap(), var_char(b).unwrap());+ s.execute("table.setCell", &json!({"row": 0, "col": 0, "text": text})).unwrap();+ s.execute("variables.delete", &json!({"name": "A"})).unwrap();+ let d = &s.doc().unwrap().doc;+ let t = d.story(sid).unwrap().tables.values().next().unwrap();+ let nb = d.variable("B").unwrap();+ assert_eq!(t.cells[0].text.text, format!("Alpha|{}", var_char(nb).unwrap()));+ }++ /// Deleting a variable flattens its instances in footnotes and endnotes too and moves the+ /// instances of later variables down.+ #[test]+ fn delete_variable_reaches_notes() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ s.execute("variables.define", &json!({"name": "A", "type": "custom", "text": "Alpha"})).unwrap();+ let b = s.execute("variables.define", &json!({"name": "B", "type": "custom", "text": "Beta"})).unwrap()["index"].as_u64().unwrap() as usize;+ let a = s.doc().unwrap().doc.variable("A").unwrap();+ let r = s.execute("frame.create", &json!({"rect": [72, 72, 400, 300], "content": "text", "text": "x"})).unwrap();+ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ let text = format!("{}|{}", var_char(a).unwrap(), var_char(b).unwrap());+ s.execute("text.select", &json!({"story": sid.0, "anchor": 1, "focus": 1})).unwrap();+ s.execute("footnote.insert", &json!({"text": text})).unwrap();+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 0})).unwrap();+ s.execute("endnote.insert", &json!({"text": text})).unwrap();+ s.execute("variables.delete", &json!({"name": "A"})).unwrap();+ let d = &s.doc().unwrap().doc;+ let st = d.story(sid).unwrap();+ let want = format!("Alpha|{}", var_char(d.variable("B").unwrap()).unwrap());+ assert_eq!(st.notes[0].text.text, want);+ assert_eq!(st.endnotes[0].text.text, want);+ }++ #[test]+ fn running_header_on_parent_page_follows_headings() {+ let mut s = Session::new();+ s.execute("file.new", &json!({"pages": 3, "facingPages": false})).unwrap();+ s.execute("style.paragraph.create", &json!({"name": "Heading"})).ok();+ // Headings on pages 1 and 3 (page 2 carries page 1's).+ for (page, text) in [(0, "Alpha"), (2, "Epsilon")] {+ let sp = s.doc().unwrap().doc.page_loc(page).unwrap().0;+ let r = s.execute("frame.create", &json!({"spread": sp, "rect": [72, 200, 400, 260], "content": "text", "text": text})).unwrap();+ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 1})).unwrap();+ s.execute("style.paragraph.apply", &json!({"name": "Heading"})).unwrap();+ }+ s.execute("variables.define", &json!({"name": "Chapter Head", "type": "runningHeader", "style": "Heading"})).unwrap();+ s.execute("variables.define", &json!({"name": "Total", "type": "custom", "text": "of "})).unwrap();+ // A header frame on the parent with "<running header> · <page> / <last page>".+ let r = s+ .execute("frame.create", &json!({"spread": {"kind": "parent", "index": 0}, "rect": [72, 30, 500, 60], "content": "text", "text": ""}))+ .unwrap();+ let fid = designcraft_doc::ItemId(r["id"].as_u64().unwrap());+ let sid = s.doc().unwrap().doc.item(fid).unwrap().text_frame().unwrap().story;+ s.execute("text.select", &json!({"story": sid.0, "anchor": 0, "focus": 0})).unwrap();+ s.execute("variables.insert", &json!({"name": "Chapter Head"})).unwrap();+ s.execute("text.insert", &json!({"text": " · "})).unwrap();+ s.execute("variables.insert", &json!({"name": "Last Page Number"})).unwrap();+ let d = s.doc().unwrap().doc.clone();+ assert!(matches!(d.find(fid).unwrap().spread, designcraft_doc::SpreadRef::Parent(0)));+ // Visible glyphs of the header composed for each page: "Alpha · 3" vs "Epsilon · 3".+ let shown = |page: usize| -> usize {+ let cs = s.cache.get(&d, sid, Some(page));+ cs.frames.iter().flat_map(|f| f.lines.iter()).map(|l| l.glyphs.iter().filter(|g| g.visible && g.adv > 0.0).count()).sum()+ };+ let (p1, p2, p3) = (shown(0), shown(1), shown(2));+ assert_eq!(p1, p2, "page 2 carries page 1's header");+ assert_eq!(p3, p1 + 2, "Epsilon is two letters longer than Alpha");+ let idx = s.cache.running_index(&d);+ assert_eq!(idx.value("Heading", false, Default::default(), 0), "Alpha");+ assert_eq!(idx.value("Heading", false, Default::default(), 1), "Alpha");+ assert_eq!(idx.value("Heading", false, Default::default(), 2), "Epsilon");+ let list = s.execute("variables.list", &json!({})).unwrap();+ assert!(list.as_array().unwrap().iter().any(|v| v["name"] == "Last Page Number" && v["value"] == "3"));+ // Deleting a variable flattens its instances to text.+ s.execute("variables.delete", &json!({"name": "Last Page Number"})).unwrap();+ assert!(s.doc().unwrap().doc.story(sid).unwrap().text.ends_with(" · 3"));+ }++++/// A running header reads a page in text order: in a two-column frame the right column's++/// headings come after the left column's, even when they sit higher on the page. (The first++/// and last were picked by height, so a dictionary page's header named its left column's last++/// entry, which sits lowest, instead of the right column's.)++#[test]++fn running_header_reads_columns_in_text_order() {++ use designcraft_doc::story::COLUMN_BREAK;++ let mut s = Session::new();++ s.execute("file.new", &json!({"pages": 1, "facingPages": false})).unwrap();++ s.execute("style.paragraph.create", &json!({"name": "Heading"})).ok();++ // Left column: a line, Alpha, a line, Beta (low). Right column: Gamma (at the top), a line.++ let text = format!("x\nAlpha\nx\nBeta{COLUMN_BREAK}\nGamma\ny");++ let r = s.execute("frame.create", &json!({"rect": [72, 72, 472, 400], "content": "text", "text": text})).unwrap();++ s.execute("object.textFrameOptions", &json!({"ids": [r["id"]], "columns": 2, "gutter": 20})).unwrap();++ let sid = s.doc().unwrap().doc.item(designcraft_doc::ItemId(r["id"].as_u64().unwrap())).unwrap().text_frame().unwrap().story;++ for word in ["Alpha", "Beta", "Gamma"] {++ let at = text.find(word).unwrap();++ s.execute("text.select", &json!({"story": sid.0, "anchor": at, "focus": at + word.len()})).unwrap();++ s.execute("style.paragraph.apply", &json!({"name": "Heading"})).unwrap();++ }++ s.execute("variables.define", &json!({"name": "Entry", "type": "runningHeader", "style": "Heading"})).unwrap();++ let d = s.doc().unwrap().doc.clone();++ let cs = s.cache.get(&d, sid, None);++ let y = |word: &str| crate::compose::caret(&cs, text.find(word).unwrap()).unwrap().2;++ assert!(y("Gamma") < y("Beta") && y("Gamma") < y("Alpha"), "Gamma heads the right column, above the left column's headings");++ let idx = s.cache.running_index(&d);++ assert_eq!(idx.value("Heading", false, designcraft_doc::vars::Use::FirstOnPage, 0), "Alpha");++ assert_eq!(idx.value("Heading", false, designcraft_doc::vars::Use::LastOnPage, 0), "Gamma");++}++/// Stories on one page are ordered by where each one's text starts there: a story whose first++/// heading sits low in its first column comes after another story's heading above it, even++/// though its later column starts higher still.++#[test]++fn running_header_orders_stories_by_their_first_heading() {++ use designcraft_doc::story::COLUMN_BREAK;++ let mut s = Session::new();++ s.execute("file.new", &json!({"pages": 1, "facingPages": false})).unwrap();++ s.execute("style.paragraph.create", &json!({"name": "Heading"})).ok();++ // Story A, two columns: filler, then Alpha low in column 1; Gamma at the top of column 2.++ let a_text = format!("{}Alpha{COLUMN_BREAK}\nGamma\ny", "x\n".repeat(8));++ let a = s.execute("frame.create", &json!({"rect": [72, 72, 300, 400], "content": "text", "text": a_text})).unwrap();++ s.execute("object.textFrameOptions", &json!({"ids": [a["id"]], "columns": 2, "gutter": 12})).unwrap();++ // Story B beside it: Beta between Gamma's height and Alpha's.++ let b_text = "Beta".to_string();++ let b = s.execute("frame.create", &json!({"rect": [320, 120, 560, 160], "content": "text", "text": b_text})).unwrap();++ let story =++ |s: &Session, id: &Value| s.doc().unwrap().doc.item(designcraft_doc::ItemId(id.as_u64().unwrap())).unwrap().text_frame().unwrap().story;++ let (sa, sb) = (story(&s, &a["id"]), story(&s, &b["id"]));++ for (sid, text, word) in [(sa, &a_text, "Alpha"), (sa, &a_text, "Gamma"), (sb, &b_text, "Beta")] {++ let at = text.find(word).unwrap();++ s.execute("text.select", &json!({"story": sid.0, "anchor": at, "focus": at + word.len()})).unwrap();++ s.execute("style.paragraph.apply", &json!({"name": "Heading"})).unwrap();++ }++ s.execute("variables.define", &json!({"name": "Entry", "type": "runningHeader", "style": "Heading"})).unwrap();++ let d = s.doc().unwrap().doc.clone();++ let y = |sid, text: &str, word: &str| {++ let cs = s.cache.get(&d, sid, None);++ let (fi, _, b, ..) = crate::compose::caret(&cs, text.find(word).unwrap()).unwrap();++ d.item(cs.frames[fi].frame).unwrap().bounds().y0 + b++ };++ let (ya, yg, yb) = (y(sa, &a_text, "Alpha"), y(sa, &a_text, "Gamma"), y(sb, &b_text, "Beta"));++ assert!(yg < yb && yb < ya, "Gamma {yg} above Beta {yb} above Alpha {ya}");++ let idx = s.cache.running_index(&d);++ assert_eq!(idx.value("Heading", false, designcraft_doc::vars::Use::FirstOnPage, 0), "Beta");++ assert_eq!(idx.value("Heading", false, designcraft_doc::vars::Use::LastOnPage, 0), "Gamma");++}