Skip to content

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

D: Primary Text Frame toggle

Brandon Thomasb1924618ace0
diff --git a/ROADMAP.md b/ROADMAP.md
index b54321160..512a15e30 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -69,6 +69,7 @@ DesignCraft aims at full Adobe InDesign parity — and to be better: faster, ope
- Variable font axes: Character panel sliders; any axis values (`fontStyle: "Bold {wght:650}"`) make that instance for layout, screen and PDF.
- Image Import Options › Crop to for placed PDFs (`file.place {pdfCrop: crop|trim|bleed|art|media}`, Place PDF dialog): the frame shows that page box.
- Stroke styles: striped (thick-thin… and custom bands), wavy and straight-hash strokes now draw on screen and in PDF; named custom stripe/dash/dot styles (`strokeStyle.new/delete/list`, Stroke panel Type list; IDML Striped/Dashed/DottedStrokeStyle).
+- Object ▸ Primary Text Frame (`object.primaryTextFrame`): any text frame's story can become (or stop being) the primary story Smart Text Reflow follows.
- Drag and drop text editing: drag selected text to move it (Alt copies) with its formatting (`text.release`).
- Image Import Options: place any page of a multi-page PDF (`file.place {pdfPage}`; the app asks which page), shown on screen and embedded as that page in PDF export.
- Define Lists: named numbered lists that continue across stories in page order (`list.define`, paragraph `listName` / `startAt`), round-tripped through IDML; `null` in `type.para` / `type.char` now removes an override.
diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rs
index 6b25ea4e9..f00f9d181 100644
--- a/crates/engine/src/cmd/object.rs
+++ b/crates/engine/src/cmd/object.rs
@@ -437,6 +437,33 @@ pub fn specs() -> Vec<CommandSpec> {
Ok(json!({"sides": s.prefs.polygon_sides, "starInset": (s.prefs.star_inset * 100.0).round()}))
}
),
+ cmd!(
+ "object.primaryTextFrame",
+ "Primary Text Frame",
+ ["Object"],
+ None,
+ "{on?: bool (default: toggle), ids?} — the selected text frame's story becomes the primary story (Smart Text Reflow adds and removes pages for it)",
+ has_selection,
+ |s, p| {
+ let ids = targets(s, p)?;
+ let sid = ids
+ .iter()
+ .find_map(|id| s.doc().ok()?.doc.item(*id)?.text_frame().map(|t| t.story))
+ .ok_or_else(|| bad("object.primaryTextFrame", "select a text frame"))?;
+ let cur = s.doc()?.doc.settings.primary_story;
+ let on = p.get("on").and_then(Value::as_bool).unwrap_or(cur != Some(sid));
+ s.edit(|d, _| {
+ d.settings.primary_story = if on {
+ Some(sid)
+ } else if cur == Some(sid) {
+ None
+ } else {
+ cur
+ };
+ Ok(json!({"primary": on, "story": sid.0}))
+ })
+ }
+ ),
cmd!(
"object.attributes",
"Attributes",
@@ -1821,3 +1848,22 @@ mod fitting_tests {
assert_eq!(g.auto_fit, designcraft_doc::Fitting::FillProportionally);
}
}
+
+#[cfg(test)]
+mod primary_frame_tests {
+ use super::*;
+
+ #[test]
+ fn toggle_primary_text_frame() {
+ let mut s = Session::new();
+ s.execute("file.new", &json!({})).unwrap();
+ let r = s.execute("frame.create", &json!({"rect": [72, 72, 300, 300], "content": "text", "text": "x", "caret": false})).unwrap();
+ let sid = r["story"].as_u64().unwrap();
+ s.execute("object.primaryTextFrame", &json!({})).unwrap();
+ assert_eq!(s.doc().unwrap().doc.settings.primary_story.map(|x| x.0), Some(sid));
+ s.execute("object.primaryTextFrame", &json!({})).unwrap();
+ assert_eq!(s.doc().unwrap().doc.settings.primary_story, None, "toggles off");
+ let g = s.execute("frame.create", &json!({"rect": [0, 0, 10, 10]})).unwrap()["id"].clone();
+ assert!(s.execute("object.primaryTextFrame", &json!({"ids": [g]})).is_err());
+ }
+}
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index b3ce21bf2..fedac3e0f 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -349,6 +349,7 @@ pub const MENUS: &[(&str, &[&str])] = &[
"cmd:object.showAll",
"-",
"cmd:object.textFrameOptions",
+ "cmd:object.primaryTextFrame",
"cmd:object.cornerOptions",
"-",
">Effects",
diff --git a/docs/parity.md b/docs/parity.md
index 932d7f9c6..70d1f12e0 100644
--- a/docs/parity.md
+++ b/docs/parity.md
@@ -10,13 +10,13 @@ Each row of the InDesign feature catalogue is scored **D** (done), **P** (partia
| Priority | Features | Done | Partial | Missing | Parity |
|---|---|---|---|---|---|
| P0 | 102 | 99 | 3 | 0 | 99% |
-| P1 | 97 | 91 | 5 | 1 | 96% |
+| P1 | 97 | 92 | 4 | 1 | 97% |
| P2 | 76 | 23 | 13 | 40 | 39% |
| Area | Parity |
|---|---|
| Application shell & workspace | 82% |
-| Documents, pages, spreads | 85% |
+| Documents, pages, spreads | 87% |
| Layers | 95% |
| Frames, shapes & paths | 95% |
| Transform | 100% |
@@ -71,7 +71,7 @@ Open P0 items: Preferences, Vector/page formats (PDF/AI/SVG/EPS place), Export t
| Documents, pages, spreads | Sections & numbering | P0 | D |
| Documents, pages, spreads | Page numbering display | P1 | D |
| Documents, pages, spreads | Smart Text Reflow | P1 | D |
-| Documents, pages, spreads | Primary text frame | P1 | P |
+| Documents, pages, spreads | Primary text frame | P1 | D |
| Documents, pages, spreads | Parent pages | P0 | D |
| Documents, pages, spreads | Parent item overrides | P0 | D |
| Documents, pages, spreads | Page transitions | P2 | M |