DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into text-frame-options-layout
moppeeer9642aa57c7de
diff --cc crates/engine/src/cmd/object.rsindex 37dacad11,5c0e7e814..78669e00d--- a/crates/engine/src/cmd/object.rs+++ b/crates/engine/src/cmd/object.rs@@@ -598,7 -598,7 +598,7 @@@ pub fn specs() -> Vec<CommandSpec>"Text Frame Options…",["Object"],Some("Cmd+B"),- "{columns?, gutter?, inset?: number|[t,l,b,r] (null keeps that side), verticalJustification?: top|center|bottom|justify, paragraphSpacingLimit? (pt: Justify adds at most this between paragraphs, the rest between lines), columnsKind?: fixedNumber|fixedWidth, columnWidth? (pt, Fixed Width), firstBaseline?: ascent|capHeight|leading|xHeight|emboxHeight|fixed, firstBaselineMin? (pt), autoSize?: off|heightOnly|widthOnly|heightAndWidth|heightAndWidthProportionally, autoSizeReference?: topLeft|topCenter|topRight|leftCenter|center|rightCenter|bottomLeft|bottomCenter|bottomRight (the point that stays put), useMinimumHeight?: bool, minimumHeight? (pt), useMinimumWidth?: bool, minimumWidth? (pt), noLineBreaks?: bool, ignoreWrap?, balanceColumns?, columnRule?: bool, columnRuleWeight? (pt), columnRuleColor? (swatch name), columnRuleTint? (0..1), columnRuleOffset? (pt, horizontal), columnRuleTopInset? (pt), columnRuleBottomInset? (pt), vertical?: bool (sets the story direction of the frames' stories, as Type ▸ Story Direction), ids?}",- "{columns?, gutter?, inset?: number|[t,l,b,r] (null keeps that side), verticalJustification?: top|center|bottom|justify, columnsKind?: fixedNumber|fixedWidth, columnWidth? (pt, Fixed Width), firstBaseline?: ascent|capHeight|leading|xHeight|emboxHeight|fixed, firstBaselineMin? (pt), autoSize?: off|heightOnly|widthOnly|heightAndWidth|heightAndWidthProportionally, autoSizeReference?: topLeft|topCenter|topRight|leftCenter|center|rightCenter|bottomLeft|bottomCenter|bottomRight (the point that stays put), useMinimumHeight?: bool, minimumHeight? (pt), useMinimumWidth?: bool, minimumWidth? (pt), noLineBreaks?: bool, ignoreWrap?, balanceColumns?, columnRule?: bool, columnRuleWeight? (pt), columnRuleColor? (swatch name), columnRuleTint? (0..1), columnRuleOffset? (pt, horizontal), columnRuleTopInset? (pt), columnRuleBottomInset? (pt), baselineGrid?: {start? (pt), increment? (pt), relativeTo?: page|margin|frame|inset} (the frame's custom baseline grid; fields not given keep the frame's, or come from the document grid; null turns it off), vertical?: bool (sets the story direction of the frames' stories, as Type ▸ Story Direction), ids?}",++ "{columns?, gutter?, inset?: number|[t,l,b,r] (null keeps that side), verticalJustification?: top|center|bottom|justify, paragraphSpacingLimit? (pt: Justify adds at most this between paragraphs, the rest between lines), columnsKind?: fixedNumber|fixedWidth, columnWidth? (pt, Fixed Width), firstBaseline?: ascent|capHeight|leading|xHeight|emboxHeight|fixed, firstBaselineMin? (pt), autoSize?: off|heightOnly|widthOnly|heightAndWidth|heightAndWidthProportionally, autoSizeReference?: topLeft|topCenter|topRight|leftCenter|center|rightCenter|bottomLeft|bottomCenter|bottomRight (the point that stays put), useMinimumHeight?: bool, minimumHeight? (pt), useMinimumWidth?: bool, minimumWidth? (pt), noLineBreaks?: bool, ignoreWrap?, balanceColumns?, columnRule?: bool, columnRuleWeight? (pt), columnRuleColor? (swatch name), columnRuleTint? (0..1), columnRuleOffset? (pt, horizontal), columnRuleTopInset? (pt), columnRuleBottomInset? (pt), baselineGrid?: {start? (pt), increment? (pt), relativeTo?: page|margin|frame|inset} (the frame's custom baseline grid; fields not given keep the frame's, or come from the document grid; null turns it off), vertical?: bool (sets the story direction of the frames' stories, as Type ▸ Story Direction), ids?}",has_selection,text_frame_options),diff --cc crates/ui-egui/src/dialogs.rsindex 85dd1f5c2,f6404c8ef..865ffbe21--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@@ -985,11 -948,36 +1076,39 @@@ fn text_frame_params(app: &DesignApp, dp.insert(key.into(), json!(d.m(key).filter(|v| *v >= 0.0).ok_or_else(|| bad(what))?));}}+ // The custom baseline grid: off, or the fields the user changed (all of them when it is+ // turned on, since it shows the document grid's).+ let grid_keys = ["customGrid", "gridStart", "gridIncrement", "gridRelativeTo"];+ if grid_keys.iter().any(|k| edited(d, k)) {+ if d.b("customGrid") {+ let all = edited(d, "customGrid");+ let mut g = Map::new();+ if all || edited(d, "gridStart") {+ g.insert("start".into(), json!(d.m("gridStart").ok_or_else(|| bad("the baseline grid start is not a measure"))?));+ }+ if all || edited(d, "gridIncrement") {+ g.insert(+ "increment".into(),+ json!(+ d.m("gridIncrement")+ .filter(|v| *v > 0.0)+ .ok_or_else(|| bad("the baseline grid increment must be a measure greater than zero"))?+ ),+ );+ }+ if all || edited(d, "gridRelativeTo") {+ g.insert("relativeTo".into(), json!(d.s("gridRelativeTo")));+ }+ p.insert("baselineGrid".into(), Value::Object(g));+ } else {+ p.insert("baselineGrid".into(), Value::Null);+ }+ }- if p.is_empty() {- return Ok(Value::Null);+ if edited(d, "paragraphSpacingLimit") {+ p.insert(+ "paragraphSpacingLimit".into(),+ json!(d.m("paragraphSpacingLimit").filter(|v| *v >= 0.0).ok_or_else(|| bad("the paragraph spacing limit is not a measure"))?),+ );}// Typing in a frame: the options apply to that frame.if let Some(st) = app.session.active()@@@ -8435,65 -8550,53 +8682,112 @@@ mod testsassert_eq!((opts(&app).columns_kind, opts(&app).column_width), (designcraft_doc::ColumnsKind::FixedNumber, 120.0));}+ /// The course's chapter 18: Text Frame Options with Preview on shows the columns and the+ /// inset on the page while the dialog is open; Cancel puts the frame back, OK sets them as one+ /// undo step. The Paragraph Spacing Limit is set from the dialog too.+ #[test]+ fn text_frame_options_preview_shows_the_change_until_ok_or_cancel() {+ let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let r = app.run("frame.create", json!({"rect": [36, 36, 336, 236], "content": "text", "text": "Hello"})).unwrap();+ let id = designcraft_doc::ItemId(r["id"].as_u64().unwrap());+ app.run("selection.set", json!({"ids": [id.0]})).unwrap();+ let opts = |app: &DesignApp| app.session.doc().unwrap().doc.item(id).unwrap().text_frame().unwrap().options.clone();+ let open = |app: &mut DesignApp| {+ let mut d = Dialog::new("textFrameOptions", json!({}));+ seed_text_frame_options(app, &mut d);+ d+ };+ let mut d = open(&mut app);+ d.fields.insert("columns".into(), json!("3"));+ d.fields.insert("preview".into(), json!(true));+ text_frame_preview(&mut app, &mut d);+ assert_eq!(opts(&app).columns, 3, "previewed on the page");+ d.fields.insert("insetTop".into(), json!("1p0"));+ text_frame_preview(&mut app, &mut d);+ assert_eq!((opts(&app).columns, opts(&app).inset[0]), (3, 12.0), "redone when a field changes");+ d.fields.insert("preview".into(), json!(false));+ text_frame_preview(&mut app, &mut d);+ assert_eq!(opts(&app).columns, 1, "Preview off: the page as it was");+ // A value OK would refuse: the page goes back while the status says why.+ d.fields.insert("preview".into(), json!(true));+ text_frame_preview(&mut app, &mut d);+ assert_eq!(opts(&app).columns, 3);+ let gutter = d.fields.get("gutter").cloned().unwrap_or_default();+ d.fields.insert("gutter".into(), json!("wide"));+ text_frame_preview(&mut app, &mut d);+ assert_eq!(opts(&app).columns, 1, "the page as it was");+ assert!(!d.fields.contains_key(PREVIEWED) && !d.s("status").is_empty());+ d.fields.insert("gutter".into(), gutter);+ d.fields.remove("status");+ // Cancel after a preview: back as it was.+ d.fields.insert("preview".into(), json!(true));+ text_frame_preview(&mut app, &mut d);+ app.ui.dialog = Some(d);+ cancel(&mut app);+ assert_eq!(opts(&app).columns, 1);+ // OK after a preview: set once, one undo step.+ let mut d = open(&mut app);+ d.fields.insert("columns".into(), json!("2"));+ d.fields.insert("verticalJustification".into(), json!("justify"));+ d.fields.insert("paragraphSpacingLimit".into(), json!("2p0"));+ d.fields.insert("preview".into(), json!(true));+ text_frame_preview(&mut app, &mut d);+ app.ui.dialog = Some(d);+ confirm(&mut app).unwrap();+ let o = opts(&app);+ assert_eq!((o.columns, o.vj_paragraph_spacing_limit), (2, 24.0));+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(opts(&app).columns, 1, "one undo step");+ }++ #[test]+ fn baseline_grid_increment_error_explains_the_positive_measure_rule() {+ let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let r = app.run("frame.create", json!({"rect": [36, 36, 336, 236], "content": "text", "text": "Hello"})).unwrap();+ let id = designcraft_doc::ItemId(r["id"].as_u64().unwrap());+ for increment in ["0", "-1 pt", "not a measure"] {+ let mut d = Dialog::new("textFrameOptions", json!({}));+ seed_text_frame_options(&app, &mut d);+ d.fields.insert("customGrid".into(), json!(true));+ d.fields.insert("gridIncrement".into(), json!(increment));+ app.ui.dialog = Some(d);+ let error = confirm(&mut app).unwrap_err().to_string();+ assert!(error.contains("the baseline grid increment must be a measure greater than zero"), "{increment}: {error}");+ assert!(app.session.doc().unwrap().doc.item(id).unwrap().text_frame().unwrap().options.baseline_grid.is_none());+ }+ }++ #[test]+ fn text_frame_options_set_a_custom_baseline_grid_relative_to() {+ use designcraft_doc::{FrameBaselineGrid, FrameGridRelative};+ let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let r = app.run("frame.create", json!({"rect": [36, 36, 336, 236], "content": "text", "text": "Hello"})).unwrap();+ let id = designcraft_doc::ItemId(r["id"].as_u64().unwrap());+ let grid = |app: &DesignApp| app.session.doc().unwrap().doc.item(id).unwrap().text_frame().unwrap().options.baseline_grid;+ let open = |app: &mut DesignApp, fields: &[(&str, Value)]| {+ let mut d = Dialog::new("textFrameOptions", json!({}));+ seed_text_frame_options(app, &mut d);+ for (k, v) in fields {+ d.fields.insert((*k).into(), v.clone());+ }+ app.ui.dialog = Some(d);+ confirm(app)+ };+ app.run("selection.set", json!({"ids": [id.0]})).unwrap();+ // Turned on, the grid takes the shown start and increment (the document grid's: 3p0 and 1p0).+ open(&mut app, &[("customGrid", json!(true)), ("gridRelativeTo", json!("frame"))]).unwrap();+ assert_eq!(grid(&app), Some(FrameBaselineGrid { start: 36.0, increment: 12.0, relative_to: FrameGridRelative::TopOfFrame }));+ // The dialog shows the frame's grid; changing Relative To keeps its start and increment.+ open(&mut app, &[("gridStart", json!("0p10"))]).unwrap();+ open(&mut app, &[("gridRelativeTo", json!("inset"))]).unwrap();+ assert_eq!(grid(&app), Some(FrameBaselineGrid { start: 10.0, increment: 12.0, relative_to: FrameGridRelative::TopInset }));+ open(&mut app, &[("customGrid", json!(false))]).unwrap();+ assert_eq!(grid(&app), None);+ }+#[test]fn text_frame_options_change_only_what_was_edited() {let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());diff --cc docs/target-app-parity.mdindex fa51286da,28551d1a8..52d38d279--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -1,6 -1,6 +1,6 @@@# DesignCraft parity with Adobe InDesign- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-24 · **Change:** minor (Text Frame Options layout, Preview and Paragraph Spacing Limit; list buttons with the default hanging indent; custom anchored objects honour Relative to Spine; PDF/X-4 visible unembedded font detection, #909; autoflow fills the following pages first; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; image clipping paths from IDML; anchored objects wrap text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; recovery checkpoint retention; cancelable macOS Dock Quit; Based on Parent; object styles carry effects; colour management on craft-cms, Coated FOGRA39 default CMYK; swatches on placed greyscale and bitmap images) · **Target:** Adobe InDesign 2026 (21.6.0.57, macOS)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-24 · **Change:** minor (Convert Variable to Text; list buttons with the default hanging indent; custom anchored objects honour Relative to Spine; PDF/X-4 visible unembedded font detection, #909; autoflow fills the following pages first; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; image clipping paths from IDML; anchored objects wrap text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; recovery checkpoint retention; cancelable macOS Dock Quit; Based on Parent; object styles carry effects; colour management on craft-cms, Coated FOGRA39 default CMYK; swatches on placed greyscale and bitmap images) · **Target:** Adobe InDesign 2026 (21.6.0.57, macOS)++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-24 · **Change:** minor (Text Frame Options layout, Preview and Paragraph Spacing Limit; Convert Variable to Text; list buttons with the default hanging indent; custom anchored objects honour Relative to Spine; PDF/X-4 visible unembedded font detection, #909; autoflow fills the following pages first; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; image clipping paths from IDML; anchored objects wrap text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; recovery checkpoint retention; cancelable macOS Dock Quit; Based on Parent; object styles carry effects; colour management on craft-cms, Coated FOGRA39 default CMYK; swatches on placed greyscale and bitmap images) · **Target:** Adobe InDesign 2026 (21.6.0.57, macOS)The authoritative assessment of how close DesignCraft is to Adobe InDesign. [ROADMAP.md](../ROADMAP.md)summarizes it; [gaps.md](gaps.md) lists every known shortfall one at a time; the feature-by-feature