Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge remote-tracking branch 'upstream/main' into xref-edited-text

Claude987c8bbeed13
diff --cc ROADMAP.md
index f8c4bcf32,0128924c0..1ca49ee18
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -348,7 -348,13 +348,14 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+- **2026-10-17** · Cross-references keep text typed over their generated text (IDML import and export), with the page number still live, as InDesign shows them until updated; a cross-reference whose destination is gone shows its saved text and page instead of "??"; and a cross-reference's text breaks at its spaces instead of inside words. 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.rs
index a549991ba,035333da4..a62cfa977
--- a/crates/idml/src/tests.rs
+++ b/crates/idml/src/tests.rs
@@@ -4194,30 -4194,43 +4194,71 @@@ mod liquid_page_rules
}
}
+/// Text typed over a cross-reference's generated text is kept, its page number live (InDesign's
+/// XRefPageNumber variable); text the format still produces is generated again. The edits
+/// survive export and import.
+#[test]
+fn keeps_edited_cross_reference_text() {
+ let story = r#"<?xml version="1.0" encoding="UTF-8"?>
+<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="16.0">
+<Story Self="s1"><ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/NormalParagraphStyle">
+<CrossReferenceSource Self="x1" AppliedFormat="n"><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><Content>Page </Content></CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><TextVariableInstance Self="v1" Name="&lt;?AID 001b?&gt;TV XRefPageNumber" ResultText="7" AssociatedTextVariable="dTextVariablen&lt;?AID 001b?&gt;TV XRefPageNumber"/></CharacterStyleRange><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><Content>: Bove, Vinny. "Advent Horizon." 1996.</Content></CharacterStyleRange></CrossReferenceSource>
+<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><Content> and </Content></CharacterStyleRange>
+<CrossReferenceSource Self="x2" AppliedFormat="n"><CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]"><Content>"Intro" on page </Content><TextVariableInstance Self="v2" Name="&lt;?AID 001b?&gt;TV XRefPageNumber" ResultText="3" AssociatedTextVariable="dTextVariablen&lt;?AID 001b?&gt;TV XRefPageNumber"/></CharacterStyleRange></CrossReferenceSource>
+</ParagraphStyleRange></Story></idPkg:Story>"#;
+ let d = import_idml(&fixture_with_story(story)).unwrap();
+ d.check().unwrap();
+ let s = d.stories.values().find(|s| !s.xrefs.is_empty()).expect("story with cross-references");
+ assert_eq!(s.xrefs.len(), 2);
+ assert_eq!(s.xrefs[0].text.as_deref(), Some("Page <pageNum />: Bove, Vinny. \"Advent Horizon.\" 1996."));
+ assert_eq!(s.xrefs[0].page.as_deref(), Some("7"));
+ assert_eq!(s.xrefs[1].text, None, "unedited text follows its format");
+ // Its destination is gone: the page it last showed.
+ assert_eq!(designcraft_compose::xref::xref_text(&d, &s.xrefs[0], None), "Page 7: Bove, Vinny. \"Advent Horizon.\" 1996.");
+ let back = import_idml(&export_idml(&d)).unwrap();
+ back.check().unwrap();
+ let b = back.stories.values().find(|s| !s.xrefs.is_empty()).unwrap();
+ assert_eq!(b.xrefs[0].text, s.xrefs[0].text);
+ assert_eq!(b.xrefs[0].page, s.xrefs[0].page);
+}
++
+ /// 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));
+ }