DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
PR-1255: refresh against main and resolve review findings
moppeeerb23422b34dcd
diff --cc ROADMAP.mdindex 3b8d62fd4,0128924c0..dbc4552b0--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -348,8 -348,13 +348,15 @@@ list) · [roadmap.md](docs/roadmap.md)Newest first.+- **2026-10-18** · TOC separators preserve right-indent tabs through the dialog and IDML, including localized `$ID/^y` values. A separator picker exposes Tab Character, Right Indent Tab, Em Space and En Space. Existing paragraph tab leaders now work with the tutorial's TOC workflow. 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.+ - **2026-10-18** · View › Screen Mode: Bleed and Slug do what they say. Both were selectable from the toolbar, the View menu and `view.screenMode` but drew the canvas exactly as Normal did, guides and all; they are preview modes now, and what each page shows reaches the bleed box or the slug box instead of stopping at the trim. The slug guide is drawn as well, in the Slug colour from Preferences › Guides & Pasteboard, which nothing had read. No readiness percentage change.+ - **2026-10-17** · Object strokes reject malformed types and unknown type fields before changing the document; command help lists every stroke kind and its required fields. No readiness percentage change.+ - **2026-10-17** · Docs: documented a persistent source CLI install with Cargo, MCP-client PATH setup and bare-name server registration in `docs/mcp.md`. No readiness percentage change.+- **2026-10-16** · Threading: the loaded text cursor threads into a text frame inside a group (it hit the group and showed it could not thread); a plain click still selects the group (#1075). Gap 27 closed. No readiness percentage change.- **2026-10-16** · Greek text hyphenates. The patterns were never compiled in, so Greek set unhyphenated however narrow the column; `"Greek"`, `"Greek: Greece"`, `el` and `el-GR` all resolve now and ανθρωπος breaks αν-θρω-πος. They are the monotonic patterns (hyph-el-monoton, Dimitrios Filippou, under MIT), which is what polytonic text hyphenates by too. Five of InDesign's ~40 hyphenation languages. No readiness percentage change.- **2026-10-16** · A swatch applied to a placed greyscale or bitmap image colours it, as in InDesign: IDML's `<Image FillColor>` is read and written, greyscale pixels become a tint of the swatch on opaque white and a bitmap's white lets the frame show through, on screen and in PDF (spot swatches print on their plate). Colour images keep their colours. Applying the swatch from the Swatches panel comes next. No readiness percentage change.diff --cc crates/idml/src/tests.rsindex a1551b3e6,035333da4..1c992192a--- a/crates/idml/src/tests.rs+++ b/crates/idml/src/tests.rs@@@ -4190,34 -4194,43 +4194,75 @@@ mod liquid_page_rules}}+ /// Cell Options › Text › First Baseline, set by a cell style that a table style applies to its body+ /// region (cells with `[None]` take it from there) and overridden on one cell.+ const FIRST_BASELINE_STYLES: &str = r#"<idPkg:Styles xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging">+ <RootCellStyleGroup>+ <CellStyle Self="CellStyle/$ID/[None]" Name="$ID/[None]"/>+ <CellStyle Self="cs-cap" Name="Cap" FirstBaselineOffset="CapHeight" MinimumFirstBaselineOffset="2" VerticalJustification="CenterAlign"/>+ <CellStyle Self="cs-cap-child" Name="CapChild" FillTint="50"><Properties><BasedOn type="object">cs-cap</BasedOn></Properties></CellStyle>+ </RootCellStyleGroup>+ <RootParagraphStyleGroup/>+ <RootTableStyleGroup>+ <TableStyle Self="ts" Name="Tbl" BodyRegionCellStyle="cs-cap-child"/>+ </RootTableStyleGroup></idPkg:Styles>"#;++ const FIRST_BASELINE_STORY: &str = r#"<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging">+ <Story Self="s1"><ParagraphStyleRange><CharacterStyleRange><Table AppliedTableStyle="ts" HeaderRowCount="0">+ <Row Name="0" MinimumHeight="20"/>+ <Column Name="0" SingleColumnWidth="60"/><Column Name="1" SingleColumnWidth="60"/>+ <Cell Name="0:0" AppliedCellStyle="CellStyle/$ID/[None]"><ParagraphStyleRange><CharacterStyleRange><Content>Region</Content></CharacterStyleRange></ParagraphStyleRange></Cell>+ <Cell Name="1:0" AppliedCellStyle="CellStyle/$ID/[None]" FirstBaselineOffset="LeadingOffset"><ParagraphStyleRange><CharacterStyleRange><Content>Local</Content></CharacterStyleRange></ParagraphStyleRange></Cell>+ </Table></CharacterStyleRange></ParagraphStyleRange></Story></idPkg:Story>"#;++ #[test]+ fn cell_first_baseline_comes_from_cell_styles_table_regions_and_cells_and_round_trips() {+ use designcraft_doc::FirstBaseline;+ let d = import_idml(&fixture_with_table_styles(FIRST_BASELINE_STYLES, FIRST_BASELINE_STORY)).unwrap();+ d.check().unwrap();+ let style = d.styles.cell.iter().find(|c| c.name == "Cap").unwrap();+ assert_eq!((style.first_baseline, style.first_baseline_min), (Some(FirstBaseline::CapHeight), Some(2.0)));+ let table = d.stories.values().flat_map(|s| s.tables.values()).next().unwrap();+ let region = table.cell(0, 0).unwrap();+ assert_eq!((region.first_baseline, region.first_baseline_min), (FirstBaseline::CapHeight, 2.0), "inherited through BasedOn and the body region");+ assert_eq!(table.cell(0, 1).unwrap().first_baseline, FirstBaseline::Leading, "a cell's own attribute wins");+ let back = import_idml(&export_idml(&d)).unwrap();+ let t2 = back.stories.values().flat_map(|s| s.tables.values()).next().unwrap();+ assert_eq!(t2.cell(0, 0).unwrap().first_baseline, FirstBaseline::CapHeight);+ assert_eq!(t2.cell(0, 0).unwrap().first_baseline_min, 2.0);+ assert_eq!(t2.cell(0, 1).unwrap().first_baseline, FirstBaseline::Leading);+ let s2 = back.styles.cell.iter().find(|c| c.name == "Cap").unwrap();+ assert_eq!(s2.first_baseline, Some(FirstBaseline::CapHeight));+ }+++/// A TOC style as InDesign writes it: `$ID/`-prefixed separator (`^y`, the right indent tab) and entry style.+const TOC_STYLES: &str = r#"<idPkg:Styles xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging">+<RootParagraphStyleGroup>+ <ParagraphStyle Self="ParagraphStyle/Heading 1" Name="Heading 1"/>+ <ParagraphStyleGroup Self="psg-toc" Name="TOC">+ <ParagraphStyle Self="ParagraphStyle/TOC%3aTOC body text" Name="TOC:TOC body text" Capitalization="AllCaps"/>+ <ParagraphStyle Self="ParagraphStyle/TOC%3aTOC Header" Name="TOC:TOC Header"/>+ </ParagraphStyleGroup>+</RootParagraphStyleGroup>+<RootCharacterStyleGroup><CharacterStyle Self="CharacterStyle/TOC Page Number" Name="TOC Page Number"/></RootCharacterStyleGroup>+<TOCStyle Self="TOCStyle/$ID/DefaultTOCStyleName" TitleStyle="ParagraphStyle/TOC%3aTOC Header" Title="Table of Contents" Name="$ID/DefaultTOCStyleName">+ <TOCStyleEntry Self="e1" Name="Heading 1" Level="1" PageNumberPosition="AfterEntry" Separator="$ID/^y">+ <Properties><FormatStyle type="object">ParagraphStyle/$ID/TOC%3aTOC body text</FormatStyle>+ <PageNumberStyle type="object">CharacterStyle/TOC Page Number</PageNumberStyle>+ <SeparatorStyle type="string">$ID/[Same Style]</SeparatorStyle></Properties>+ </TOCStyleEntry>+</TOCStyle></idPkg:Styles>"#;++const TOC_STORY: &str = r#"<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging">+<Story Self="s1" AppliedTOCStyle="TOCStyle/$ID/DefaultTOCStyleName"><ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/TOC%3aTOC body text"><CharacterStyleRange><Content>Welcome</Content></CharacterStyleRange></ParagraphStyleRange></Story></idPkg:Story>"#;++#[test]+fn toc_style_entries_read_id_prefixed_separators_and_styles() {+ let d = import_idml(&fixture_with_table_styles(TOC_STYLES, TOC_STORY)).unwrap();+ let toc = d.toc.as_ref().expect("the story's TOC style is imported");+ let entry = toc.entries.iter().find(|e| e.style == "Heading 1").unwrap();+ assert_eq!(entry.separator.as_deref(), Some("\u{E006}"), "right-indent tabs must not become ordinary tab stops");+ assert_eq!(entry.entry_style.as_deref(), Some("TOC/TOC body text"));+ assert_eq!(entry.page_number_style.as_deref(), Some("TOC Page Number"));+ assert_eq!(toc.title_style.as_deref(), Some("TOC/TOC Header"));+}diff --cc crates/ui-egui/src/dialogs.rsindex c1eff1078,8b4043787..af1e75146--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@@ -7969,31 -7970,6 +7982,34 @@@ mod testsassert_eq!(opts(&app), before);}+ #[test]+ fn toc_right_indent_separator_survives_the_dialog_and_update() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.newSample", json!({})).unwrap();+ open_toc(&mut app);+ app.ui.dialog.as_mut().unwrap().fields.insert(+ "included".into(),+ json!([+ {"style": "Headline", "level": 1, "separator": " ^y "}+ ]),+ );+ confirm(&mut app).unwrap();++ if app.session.tool_id() == "tocPlace" {++ app.run("toc.place", json!({"x":36,"y":36})).unwrap();++ }+ let separator = format!(" {} ", designcraft_doc::story::RIGHT_INDENT_TAB);+ let d = &app.session.doc().unwrap().doc;+ let toc = d.toc.as_ref().unwrap();+ assert_eq!(toc.entries[0].separator.as_deref(), Some(separator.as_str()));+ assert!(d.story(toc.story).unwrap().text.contains(&separator));+ app.run("toc.update", json!({})).unwrap();+ open_toc(&mut app);+ assert_eq!(toc_rows(app.ui.dialog.as_ref().unwrap())[0].separator, " ^y ");+ for text in ["^y", "^t^y", "^m^>", "unknown ^q and trailing ^", "a\t\u{E006}\u{2003}\u{2002}z"] {+ assert_eq!(toc_separator_typed(&toc_separator_shown(text)), text);+ }+ }+#[test]fn toc_dialog_adds_a_style_and_ok_makes_the_table_of_contents() {let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());