Skip to content

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

Merge pr/610: Links: placed text files can stay linked (Word, RTF, text) (#610)

aionggd7d71380ad7b
diff --cc ROADMAP.md
index 226be138f,13975d746..f386e7d79
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -128,44 -129,9 +128,45 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+ - **2026-10-12** · Linked text files (#597): placed Word, RTF and text files can stay linked; the Links panel shows them OK / Modified / Missing, and Update imports the file again into the same frames with the saved style map (the Links panel asks before replacing edits made in the layout). No readiness percentage change.
+- **2026-10-12** · Text in oval, polygon and other non-rectangular text frames follows the frame's outline: each line is set in the part of its band inside the shape, one inset away from the outline, in every column and in vertical frames; text wrap still applies on top (#646). No readiness percentage change.
+- **2026-10-12** · Colour entry: the Color Picker's hex, R/G/B and C/M/Y/K fields and the Color panel's number fields keep typed text until it is complete; panel and picker values are applied on a fixed scale (`{model, …}` colours in 0..1), so M 1 is 1 %. Picking keeps a CMYK colour CMYK; dialogs leave the page behind them undimmed; colours that round to the same swatch name share one swatch (#323). No readiness percentage change.
+- **2026-10-12** · Placed photos show in their own colours: embedded ICC profiles (Adobe RGB, ProPhoto, P3, grey) are converted to sRGB on screen, and CMYK JPEGs (including YCCK), CMYK TIFFs and CMYK PSDs go through their embedded CMYK profile or the working CMYK space with the colour settings' intent and black-point compensation, instead of the profile-free formula. Unreadable profiles are ignored. No readiness percentage change.
+- **2026-10-12** · Placed Word documents keep their bullets and numbering (#626): `numbering.xml` levels become bullet or numbered paragraphs with Word's number formats, label text, start numbers, restarts and list indents, also when a paragraph style carries the list. No readiness percentage change.
+- **2026-10-12** · Text strokes can sit behind the fill: the stroke lies wholly outside the letters at its full weight on screen, in PNG and in PDF, set from the Properties panel or Character Style Options. IDML `StrokeAlignment` on text imports and exports as this setting, so imported text with outside-aligned strokes keeps its letter shapes (#619). No readiness percentage change.
+- **2026-10-12** · Type tool: Option/Alt+Left/Right kerns the pair at the caret (manual kerning) or tracks a selection by the Kerning/Tracking increment (Preferences › Units & Increments, 20/1000 em), five times with Cmd/Ctrl; moving by words is Cmd+Left/Right on macOS and Ctrl+Left/Right elsewhere, and Option/Alt+Shift+Left/Right still selects by words (#621). No readiness percentage change.
+- **2026-10-12** · Autoflow on Place threads one frame per page column (right to left in a right-to-left story), so text no longer runs across the gutter; pages Smart Text Reflow adds get a primary frame with the page's columns (#625). No readiness percentage change.
+- **2026-10-12** · Vector art copied in Illustrator, VectorCraft, Figma or Inkscape pastes as editable paths, as InDesign pastes Illustrator art: the SVG those apps put on the clipboard becomes paths with their fills, strokes (weight, caps, joins, dashes) and opacity, groups stay groups and text comes in as outlines, centred in the view (`edit.pasteSvg`, `ui.paste`). Edit › Paste reads the system clipboard when nothing was copied in DesignCraft. No readiness percentage change.
+- **2026-10-12** · Pages panel: double-clicking a parent shows that parent and selects only its row; parent rows show rendered thumbnails. Commands name parents by id, full name, or a prefix only one parent has; an unknown or ambiguous name is an error instead of clearing the page's parent (#624). No readiness percentage change.
+- **2026-10-12** · With the Type tool, dragging a table's column or row border resizes it (the double-arrow cursor shows over a border): later columns and rows move along, Shift keeps the table size, and Shift on the right or bottom edge scales every column or row. A dragged row becomes At Least; one undo step per drag, Esc cancels; works in rotated frames and turned spreads. Scripts use `table.resizeBorder`. No readiness percentage change.
+- **2026-10-12** · The Tools panel's Fill/Stroke keys work: D (default fill and stroke), X (fill or stroke in front), Shift+X (swap per object, tints included) and / (Apply None), as `color.*` commands; swap and default are one undo step (`object.swapFillStroke`, `object.defaultFillStroke`); the Color panel follows the proxy's fill/stroke choice. No readiness percentage change.
+- **2026-10-12** · With a placed graphic selected (Direct Selection), the Transform values act on the graphic inside its frame, as in InDesign: a tilted frame's image can be straightened to 0°. No readiness percentage change.
+- **2026-10-11** · Font menu laid out like InDesign's: filters (classification, favourites,
+ recently added), families opening to their styles, the selected text as the sample in three
+ sizes, Recently Used fonts, Show Similar Fonts and each font's format.
+- **2026-10-12** · The Effects panel shows the level its settings apply to ("Group: Color Dodge 100%") and, as in InDesign, Isolate Blending and Knockout Group for a selected group. No readiness percentage change.
+- **2026-10-12** · Edit › Step and Repeat has its InDesign dialog: Repeat (Count, or Rows and Columns with Create as a grid), Offset (Vertical, Horizontal, in ruler units) and Preview, which shows the copies while the dialog is open; Cancel takes them away and OK makes them as one undo step. No readiness percentage change.
+- **2026-10-12** · Load Styles: the Paragraph Styles and Character Styles panels load styles from another DesignCraft document or an IDML file, with the styles, swatches and lists they name; a dialog picks the styles and what happens to one the document defines differently (`style.load`). No readiness percentage change.
+- **2026-10-12** · On screen, blend modes blend with the objects below and not with the paper, as in InDesign and in PDF export: a Color Dodge or Screen object over blank paper shows as it is. No readiness percentage change.
+- **2026-10-12** · Text threads by hand: click a selected text frame's in or out port to load
+ the text cursor, then click a frame to thread it, click empty space for a column-wide frame or
+ drag one (it snaps like frame drawing); Shift-click autoflows, Alt-click stays loaded on the
+ frame just added; click the linked frame or double-click a port to break the thread.
+ `text.thread`, `text.unthread`, `text.removeFromThread` with undo; locked frames and layers
+ refuse threads. The alpha gate now waits only on the Primary Text Frame page fixes (#165). No
+ readiness percentage change.
+- **2026-10-12** · Properties › Transform shows rotation, shear and X/Y scale, and Rotate 90° and Flip Horizontal/Vertical buttons, as InDesign's does. No readiness percentage change.
+- **2026-10-12** · Underlines and strikethroughs are drawn as one bar per stretch of text on screen, as in PDF export: a bar per letter left faint seams between the letters. No readiness percentage change.
+- **2026-10-12** · The section marker character shows its section's marker text on document pages (nothing when the section has none) instead of the word "Section", which stays on parent pages; editing the marker recomposes (#556). No readiness percentage change.
+- **2026-10-12** · IDML import keeps a font family name exactly as written, trailing spaces included, and font lookup falls back to the name without surrounding spaces; `FontStyle="Nothing"` leaves the style to the paragraph (#558). No readiness percentage change.
+- **2026-10-12** · Clipping paths saved with images in IDML (Detect Edges, Alpha Channel, Photoshop Path, User-Modified Path, inverted or not) clip the image on screen and in PDF and survive IDML export; `object.clippingPathOptions` reports, inverts or removes one (#450). No readiness percentage change.
+- **2026-10-12** · Anchored objects with text wrap push text aside: other stories' text under them and the lines of their own story after the anchor's line (#557). No readiness percentage change.
+- **2026-10-12** · Hyphenation Zone applies to the Single-line Composer only, as in InDesign. With the default Paragraph Composer, ragged text hyphenates where InDesign does (aper-natem), giving the same line breaks. No readiness percentage change.
+- **2026-10-12** · Text frame auto-size: Height Only, Width Only, Height and Width (also keeping proportions) frames grow and shrink to fit their text after edits and IDML import, around their reference point, with minimum sizes and No Line Breaks, in the same undo step (#180). No readiness percentage change.
+- **2026-10-12** · Text Frame Options › Balance Columns (`object.textFrameOptions {balanceColumns}`, IDML `VerticalBalanceColumns`) evens out the columns of the frame a story ends in, from its last column break on; frames the text runs on from fill normally (#609). No readiness percentage change.
- **2026-10-12** · macOS Dock Quit uses the same unsaved-document prompts as window and menu Quit. Repeated requests keep the current answers; Cancel retains every tab and unsaved recovery checkpoint, and completed Save/Don't Save answers exit through the ordinary event loop. No readiness percentage change.
- **2026-10-12** · Orderly native exit writes the latest recovery state after finalizing current quit approvals; incomplete or stale plans keep their documents, and Undo to the saved state clears stale recovery. Unavailable or failed recovery is reported. Cancelable macOS Dock Quit remains open (#544). No readiness percentage change.
+- **2026-10-12** · Windows: dragging the window across monitors with different display scales keeps its size instead of growing until it crashes (winit pinned to its 0.30.x backport of the fix). The GPU surface may be as large as the adapter's largest texture (16384 px on DirectX 12, Vulkan and Metal hardware) instead of 8192, and a wgpu error is logged instead of closing the app. No readiness percentage change.
- **2026-10-12** · Recovered documents keep a checkpoint until saved, closed or reverted, including a second crash before autosave. Restarted document IDs and explicit recovery folders preserve other snapshots; failed republishing retains the original. No readiness percentage change.
- **2026-10-12** · Book numbering and style updates prepare every chapter before saving. Only closed native chapters are changed; imported IDML remains a read-only style/PDF source. If a later disk write fails, the error names the completed chapters; the batch is not a whole-book transaction. No readiness percentage change.
- **2026-10-12** · Desktop write callbacks and CLI raster exports use the atomic writer too; open readers retain the original bytes, while private Unix modes and symlink targets survive replacement. Permanent tests cover both actual callers. No readiness percentage change.
diff --cc crates/engine/src/cmd/file.rs
index d401a22bc,59d197f42..7f1936dc1
--- a/crates/engine/src/cmd/file.rs
+++ b/crates/engine/src/cmd/file.rs
@@@ -124,7 -102,7 +124,7 @@@ pub fn specs() -> Vec<CommandSpec>
"Place…",
["File"],
Some("Cmd+D"),
- "{path?|base64?, name?, frame?: id (place into), spread?, x?, y?, width?: finite number > 0 (null: absent), pdfPage?: n (1-based, Image Import Options), pdfCrop?: crop|art|trim|bleed|media|contentVisible|contentAll (the box the graphic shows; `width` is the whole page's), loadCursor?: with no frame to fill and no x/y, an image loads into the place cursor (File › Place), layoutPage?: n (IDML / .designcraft: that page's objects as a group)} — places an image into `frame` when given; otherwise any explicit x/y/spread/width creates a new frame; otherwise uses the selected empty or graphic frame, or creates a new frame; text files (.txt, .docx, .rtf, .md) and Excel workbooks (.xlsx, as a table) go into the insertion point, the selected frame or a new frame on `page`/`rect` — {autoflow?: threads one frame per page column (from the first frame on), adding pages until the text fits, removeStyles?, styleMap?: {imported name: document style}, styleConflicts?: useExisting|redefine|autoRename}",
- "{path?|base64?, name?, frame?: id (place into), spread?, x?, y?, width?, pdfPage?: n (1-based, Image Import Options), pdfCrop?: crop|trim|bleed|art|media, layoutPage?: n (IDML / .designcraft: that page's objects as a group)} — places an image (into the selected empty frame if any); text files (.txt, .docx, .rtf, .md) and Excel workbooks (.xlsx, as a table) go into the insertion point, the selected frame or a new frame on `page`/`rect` — {autoflow?: adds pages with threaded frames until the text fits, removeStyles?, styleMap?: {imported name: document style}, styleConflicts?: useExisting|redefine|autoRename, link?: keep the file linked (Links panel; default: the linkTextFiles preference)}",
++ "{path?|base64?, name?, frame?: id (place into), spread?, x?, y?, width?: finite number > 0 (null: absent), pdfPage?: n (1-based, Image Import Options), pdfCrop?: crop|art|trim|bleed|media|contentVisible|contentAll (the box the graphic shows; `width` is the whole page's), loadCursor?: with no frame to fill and no x/y, an image loads into the place cursor (File › Place), layoutPage?: n (IDML / .designcraft: that page's objects as a group)} — places an image into `frame` when given; otherwise any explicit x/y/spread/width creates a new frame; otherwise uses the selected empty or graphic frame, or creates a new frame; text files (.txt, .docx, .rtf, .md) and Excel workbooks (.xlsx, as a table) go into the insertion point, the selected frame or a new frame on `page`/`rect` — {autoflow?: threads one frame per page column (from the first frame on), adding pages until the text fits, removeStyles?, styleMap?: {imported name: document style}, styleConflicts?: useExisting|redefine|autoRename, link?: keep the file linked (Links panel; default: the linkTextFiles preference)}",
has_doc,
file_place
),
@@@ -405,18 -295,8 +405,18 @@@ fn file_place(s: &mut Session, p: &Valu
}
// Text files (plain, Word, RTF) flow into frames.
if designcraft_textimport::is_text_file(&name) {
- return super::place_text::place_text(s, p, &name, &bytes);
+ return super::place_text::place_text(s, p, &name, &bytes, link);
}
+ let want_w = p
+ .get("width")
+ .filter(|value| !value.is_null())
+ .map(|value| {
+ value
+ .as_f64()
+ .filter(|width| width.is_finite() && *width > 0.0)
+ .ok_or_else(|| bad("file.place", "`width` must be a finite number greater than zero"))
+ })
+ .transpose()?;
// Image Import Options: which page of a PDF (1-based).
let pdf_page = match p.get("pdfPage").and_then(Value::as_u64) {
Some(n) if designcraft_render::is_pdf(&bytes) => {
diff --cc crates/engine/src/cmd/linked.rs
index ab53837b0,96939afb9..0b80e3aab
--- a/crates/engine/src/cmd/linked.rs
+++ b/crates/engine/src/cmd/linked.rs
@@@ -11,8 -11,8 +11,8 @@@ use crate::Result
fn copy_into(d: &mut Document, parent: StoryId, child: StoryId) -> Result<()> {
let src = d.story(parent).ok_or_else(|| bad("story.link", format!("no story {}", parent.0)))?.clone();
let st = d.story_mut(child).ok_or_else(|| bad("story.link", format!("no story {}", child.0)))?;
- let (frames, rev) = (std::mem::take(&mut st.frames), st.rev);
- *st = Story { id: child, frames, rev: rev.wrapping_add(1), link: Some((parent, src.rev)), ..src };
+ let (frames, rev, file_link) = (std::mem::take(&mut st.frames), st.rev, st.file_link.take());
- *st = Story { id: child, frames, rev: rev + 1, link: Some((parent, src.rev)), file_link, ..src };
++ *st = Story { id: child, frames, rev: rev.wrapping_add(1), link: Some((parent, src.rev)), file_link, ..src };
Ok(())
}
diff --cc crates/engine/src/cmd/links.rs
index d867a3d29,e1c482a07..b37dae68e
--- a/crates/engine/src/cmd/links.rs
+++ b/crates/engine/src/cmd/links.rs
@@@ -15,7 -18,7 +18,7 @@@ use crate::{EngineError, Result, Sessio
pub fn specs() -> Vec<CommandSpec> {
vec![
- cmd!(query "links.list", "Links", [], None, "{} → [{asset, name, path, status: ok|modified|missing|embedded, pixels, pdfCrop (placed PDFs: the box shown), uses: [{id, page, ppi}]}]", has_doc, |s, _| {
- cmd!(query "links.list", "Links", [], None, "{} → [{asset, name, path, status: ok|modified|missing|embedded, pixels, uses: [{id, page, ppi}]}], then linked text files: [{story, name, path, status (also tooLarge: unchanged size, too big to check), edited (the story was changed in the layout), uses: [{id, page}]}]", has_doc, |s, _| {
++ cmd!(query "links.list", "Links", [], None, "{} → [{asset, name, path, status: ok|modified|missing|embedded, pixels, pdfCrop (placed PDFs: the box shown), uses: [{id, page, ppi}]}], then linked text files: [{story, name, path, status (also tooLarge: unchanged size, too big to check), edited (the story was changed in the layout), uses: [{id, page}]}]", has_doc, |s, _| {
Ok(Value::Array(list(&s.doc()?.doc)))
}),
cmd!(
@@@ -138,9 -214,9 +214,10 @@@ fn list(d: &Document) -> Vec<Value>
json!({"id": id.0, "page": page, "ppi": ppi})
})
.collect();
- json!({"asset": a.id.0, "name": a.name, "path": a.link, "status": status(a), "pixels": a.pixels, "uses": uses})
+ let pdf_crop = (a.mime == "application/pdf").then(|| a.pdf_crop.name());
+ json!({"asset": a.id.0, "name": a.name, "path": a.link, "status": status(a), "pixels": a.pixels, "pdfCrop": pdf_crop, "uses": uses})
})
+ .chain(texts)
.collect()
}
@@@ -234,10 -365,13 +368,14 @@@ fn update(s: &mut Session, p: &Value) -
let a = Arc::make_mut(a);
a.data = Arc::new(bytes.clone());
a.pixels = Some(*px);
+ super::file::crop_pdf(a);
}
}
- Ok(json!({"updated": n}))
+ let mut warnings = Vec::new();
+ for (sid, path, bytes) in &fresh_texts {
+ warnings.extend(reimport(d, *sid, path, bytes)?);
+ }
+ Ok(json!({"updated": n, "warnings": warnings}))
})
}
diff --cc crates/engine/src/cmd/place_text.rs
index 6f5276eda,4d4577a5f..73f9e5495
--- a/crates/engine/src/cmd/place_text.rs
+++ b/crates/engine/src/cmd/place_text.rs
@@@ -2,7 -2,7 +2,7 @@@
//! selected frame, or a new frame on the page; with autoflow, pages and threaded frames are added
//! until the whole story fits (InDesign's Shift-click with a loaded text cursor).
- use designcraft_doc::{CharacterStyle, Content, Document, ParaFormat, ParagraphStyle, SpreadRef, Story, StoryId, TextDirection, TextSel};
-use designcraft_doc::{CharacterStyle, Content, Document, ParaFormat, ParagraphStyle, SpreadRef, Story, StoryId, TextFileLink, TextSel};
++use designcraft_doc::{CharacterStyle, Content, Document, ParaFormat, ParagraphStyle, SpreadRef, Story, StoryId, TextDirection, TextFileLink, TextSel};
use designcraft_geom::Rect;
use serde_json::{Value, json};
@@@ -122,111 -203,38 +202,111 @@@ fn fit(d: &Document, sid: StoryId) -> (
(cs.overset_at, held, full)
}
-/// Thread new frames on new pages (margin rectangles) until the story fits. Returns pages added.
-pub(crate) fn autoflow(d: &mut Document, sid: StoryId, max_pages: usize) -> Result<usize> {
+/// The frames autoflow sets on a page: one per column inside the margins, in the order a story
+/// of direction `dir` runs through them. A vertical story gets one frame on the live area.
+fn flow_rects(d: &Document, dir: TextDirection, vertical: bool, page: usize) -> Vec<Rect> {
+ let Some(p) = d.page(page) else { return Vec::new() };
+ if vertical {
+ return vec![p.margin_rect()];
+ }
+ let mut cols = p.column_rects();
+ if dir == TextDirection::RightToLeft {
+ cols.reverse();
+ }
+ cols
+}
+
+fn same_rect(a: Rect, b: Rect) -> bool {
+ [a.x0 - b.x0, a.y0 - b.y0, a.x1 - b.x1, a.y1 - b.y1].iter().all(|v| v.abs() < 0.01)
+}
+
+/// Thread new frames until the story fits: first into the columns after the last frame's column
+/// on its page (when it sits in one), then one frame per column on each page it adds. With
+/// `primary` (Smart Text Reflow of the primary text frame), each added page gets one frame on the
+/// live area with the page's columns instead. Empty frames it made at the end of the thread are
+/// removed again, except the first on a page. Returns pages added.
+/// A story on a parent spread doesn't autoflow: its frames thread only on that parent. Errors
+/// name `cmd`, the command that autoflows.
+pub(crate) fn autoflow(d: &mut Document, sid: StoryId, max_pages: usize, cmd: &str, primary: bool) -> Result<usize> {
+ let last = d.story(sid).and_then(|s| s.frames.last().copied()).ok_or_else(|| bad(cmd, "the story has no frame"))?;
+ if !matches!(d.find(last).map(|l| l.spread), Some(SpreadRef::Doc(_))) {
+ return Err(bad(cmd, "autoflow works only from a frame on a document page"));
+ }
+ let (dir, story_vertical) = d.story(sid).map(|s| (s.direction, s.vertical)).ok_or_else(|| bad(cmd, "no such story"))?;
+ // One frame per page: on the live area, its columns those of the page.
+ let vertical = story_vertical || primary;
let mut added = 0;
+ let mut made = Vec::new();
+ let mut first = true;
loop {
let (overset, held, full) = fit(d, sid);
- let Some(at) = overset else { return Ok(added) };
- if added >= max_pages {
- return Err(bad("file.place", format!("autoflow stopped after {max_pages} pages")));
- }
+ let Some(at) = overset else { break };
let len = d.story(sid).map_or(0, |s| s.len());
// Frames still needed at the rate the full ones are filled (at least one); with no full
- // frame to go by yet, one more page.
- let want = held.checked_div(full).map_or(1, |per_frame| len.saturating_sub(at).div_ceil(per_frame.max(1))).clamp(1, max_pages - added);
- let last = *d.story(sid).and_then(|s| s.frames.last()).ok_or_else(|| bad("file.place", "the story has no frame"))?;
- let mut page = d.page_of_item(last).unwrap_or(d.page_count().saturating_sub(1));
- let parent = d.page_loc(page).and_then(|(si, pi)| d.spreads[si].pages[pi].parent);
- d.insert_pages(Some(page), want, parent)?;
+ // frame to go by yet, one more.
+ let want = held.checked_div(full).map_or(1, |per_frame| len.saturating_sub(at).div_ceil(per_frame.max(1))).max(1);
+ let last = *d.story(sid).and_then(|s| s.frames.last()).ok_or_else(|| bad(cmd, "the story has no frame"))?;
+ let page = d.page_of_item(last).unwrap_or(d.page_count().saturating_sub(1));
let layer = d.default_layer();
let mut prev = last;
- for _ in 0..want {
- page += 1;
- let (si, pi) = d.page_loc(page).ok_or_else(|| bad("file.place", "page insert failed"))?;
- let r = d.spreads[si].pages[pi].margin_rect();
- let (fid, _) = d.add_text_frame(SpreadRef::Doc(si), r, layer, "", ParaFormat::default())?;
- d.thread(prev, fid)?;
- prev = fid;
+ if std::mem::take(&mut first) {
+ let rects = flow_rects(d, dir, vertical, page);
+ let next = d.item(last).and_then(|it| rects.iter().position(|r| same_rect(*r, it.bounds()))).map_or(rects.len(), |k| k + 1);
+ if let (Some(rest), Some((si, _))) = (rects.get(next..).filter(|r| !r.is_empty()), d.page_loc(page)) {
+ for r in rest.iter().take(want) {
+ prev = add_flow_frame(d, si, *r, layer, prev)?;
+ made.push(prev);
+ }
+ continue;
+ }
}
- added += want;
+ if added >= max_pages {
+ return Err(bad(cmd, format!("autoflow stopped after {max_pages} pages")));
+ }
+ let per_page = if vertical { 1 } else { d.page(page).map_or(1, |p| p.columns.count.max(1) as usize) };
+ let pages = want.div_ceil(per_page).clamp(1, max_pages - added);
+ let parent = d.page_loc(page).and_then(|(si, pi)| d.spreads[si].pages[pi].parent);
+ d.insert_pages(Some(page), pages, parent)?;
+ for pg in page + 1..=page + pages {
+ let (si, pi) = d.page_loc(pg).ok_or_else(|| bad(cmd, "page insert failed"))?;
+ let columns = d.spreads[si].pages[pi].columns.clone();
+ for r in flow_rects(d, dir, vertical, pg) {
+ prev = add_flow_frame(d, si, r, layer, prev)?;
+ made.push(prev);
+ if primary && let Some(tf) = d.item_mut(prev).and_then(|it| it.text_frame_mut()) {
+ tf.options.columns = columns.count.max(1);
+ tf.options.gutter = columns.gutter;
+ }
+ }
+ }
+ added += pages;
}
+ let cs = designcraft_compose::compose_story(d, sid, &Default::default());
+ while let Some(&f) = made.last() {
+ let frames = d.story(sid).map_or(&[][..], |s| s.frames.as_slice());
+ let [.., before, tail] = frames else { break };
+ if *tail != f || cs.frame(f).is_some_and(|ft| !ft.range.is_empty()) || d.page_of_item(*before) != d.page_of_item(f) {
+ break;
+ }
+ d.remove_item(f)?;
+ made.pop();
+ }
+ Ok(added)
+}
+
+fn add_flow_frame(
+ d: &mut Document,
+ si: usize,
+ r: Rect,
+ layer: designcraft_doc::LayerId,
+ prev: designcraft_doc::ItemId,
+) -> Result<designcraft_doc::ItemId> {
+ let (fid, _) = d.add_text_frame(SpreadRef::Doc(si), r, layer, "", ParaFormat::default())?;
+ d.thread(prev, fid)?;
+ Ok(fid)
}
- pub(super) fn place_text(s: &mut Session, p: &Value, name: &str, bytes: &[u8]) -> Result<Value> {
+ pub(super) fn place_text(s: &mut Session, p: &Value, name: &str, bytes: &[u8], path: Option<String>) -> Result<Value> {
let mut imp = designcraft_textimport::import(name, bytes).map_err(|e| bad("file.place", e.to_string()))?;
let remove = p.get("removeStyles").and_then(Value::as_bool).unwrap_or(false);
if remove {
diff --cc crates/engine/src/cmd/prefs.rs
index b8b1f3ef6,6c4908ffd..cbd0e1ece
--- a/crates/engine/src/cmd/prefs.rs
+++ b/crates/engine/src/cmd/prefs.rs
@@@ -50,7 -48,7 +50,7 @@@ pub fn specs() -> Vec<CommandSpec>
"Preferences",
[],
None,
- "{showHiddenCharacters?, typographersQuotes?, polygonSides?, starInset?, scaleStrokes?, dimensionsIncludeStroke?, transformationsAreTotals?, absolutePageNumbers?, highlightHj?, highlightKeeps?, highlightCustomTracking?, highlightSubstitutedFonts?, richBlackOutput?, favoriteFonts?: [family], showFontNamesInEnglish?, cjkFeatures?: bool|null (CJK-only menu items and dialogs shown; null follows the interface language)} → all application preferences",
- "{showHiddenCharacters?, typographersQuotes?, polygonSides?, starInset?, scaleStrokes?, dimensionsIncludeStroke?, transformationsAreTotals?, absolutePageNumbers?, highlightHj?, highlightKeeps?, highlightCustomTracking?, highlightSubstitutedFonts?, richBlackOutput?, favoriteFonts?: [family], showFontNamesInEnglish?, linkTextFiles? (Create Links When Placing Text Files)} → all application preferences",
++ "{showHiddenCharacters?, typographersQuotes?, polygonSides?, starInset?, scaleStrokes?, dimensionsIncludeStroke?, transformationsAreTotals?, absolutePageNumbers?, highlightHj?, highlightKeeps?, highlightCustomTracking?, highlightSubstitutedFonts?, richBlackOutput?, favoriteFonts?: [family], showFontNamesInEnglish?, cjkFeatures?: bool|null (CJK-only menu items and dialogs shown; null follows the interface language), linkTextFiles? (Create Links When Placing Text Files)} → all application preferences",
super::always,
|s, p| {
let cur = serde_json::to_value(&s.prefs).map_err(|e| bad("prefs.set", e.to_string()))?;
diff --cc crates/engine/src/lib.rs
index 5f647e34e,38c570d7c..534204475
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@@ -231,8 -199,9 +231,11 @@@ pub struct Prefs
pub show_note_anchors: bool,
/// Preferences › File Handling: minutes between document recovery saves.
pub recovery_minutes: f64,
+ /// File › New › Document › Save Document Preset: saved document presets, by name (`title`).
+ pub document_presets: Vec<designcraft_doc::build::NewDocument>,
+ /// Preferences › File Handling › Create Links When Placing Text Files: placed text files are
+ /// linked (Links panel) unless `file.place` says otherwise.
+ pub link_text_files: bool,
}
/// A starter autocorrect list (common English typing slips).
diff --cc crates/ui-egui/src/dialogs.rs
index 4b1b0bcd3,7b2f56623..fb67508d5
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@@ -1503,9 -1141,9 +1506,10 @@@ pub fn show(app: &mut DesignApp, ctx: &
"userDictionary" => crate::i18n::tr(&app.ui.language, "User Dictionary"),
"newWorkspace" => crate::i18n::tr(&app.ui.language, "New Workspace"),
"closeDocument" => crate::i18n::tr(&app.ui.language, "Unsaved Changes"),
+ "updateLink" => crate::i18n::tr(&app.ui.language, "Update Link"),
"menus" => crate::i18n::tr(&app.ui.language, "Menu Customization"),
"importOptions" => crate::i18n::tr(&app.ui.language, "Import Options"),
+ "loadStyles" => crate::i18n::tr(&app.ui.language, "Load Styles"),
"fittingOptions" => crate::i18n::tr(&app.ui.language, "Frame Fitting Options"),
"qrCode" => crate::i18n::tr(&app.ui.language, "Generate QR Code"),
"preferences" => crate::i18n::tr(&app.ui.language, "Preferences"),
@@@ -1530,9 -1164,8 +1534,9 @@@
let available = (ctx.content_rect().size() - frame_margin - egui::vec2(16.0, 16.0)).max(egui::Vec2::splat(1.0));
let preferred_width: f32 = match d.id.as_str() {
"alert" => 440.0,
- "closeDocument" => 380.0,
+ "closeDocument" | "updateLink" => 380.0,
- "newDocument" if crate::i18n::is_rtl(&app.ui.language) => 380.0,
+ "newDocument" => 960.0,
+ "numberingSection" => 560.0,
_ => 640.0,
};
let width = preferred_width.min(available.x);
@@@ -2051,20 -1711,11 +2060,21 @@@
_ => {}
}
});
+ if side_actions {
+ return;
+ }
ui.add_space(12.0);
let ok_label = match d.id.as_str() {
- "closeDocument" => " Save ",
- "updateLink" => " Update ",
- _ => " OK ",
+ "closeDocument" => crate::i18n::tr(&app.ui.language, " Save ").to_string(),
++ "updateLink" => crate::i18n::tr(&app.ui.language, " Update ").to_string(),
+ "findFont" => crate::i18n::tr(&app.ui.language, "Replace All").to_string(),
+ "newDocument" => format!(" {} ", crate::i18n::tr(&app.ui.language, "Create")),
+ _ => crate::i18n::tr(&app.ui.language, " OK ").to_string(),
+ };
+ let cancel_label = match d.id.as_str() {
+ "newDocument" => "Close",
+ "findFont" => "Done",
+ _ => "Cancel",
};
ui.horizontal(|ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
@@@ -2517,9 -1999,11 +2527,9 @@@ pub fn confirm(app: &mut DesignApp) ->
}
}
"preferences" => {
- app.run(
- "prefs.set",
- json!({"scaleStrokes": d.b("scaleStrokes"), "dimensionsIncludeStroke": d.b("dimensionsIncludeStroke"), "transformationsAreTotals": d.b("transformationsAreTotals"), "absolutePageNumbers": d.b("absolutePageNumbers"), "highlightHj": d.b("highlightHj"), "highlightKeeps": d.b("highlightKeeps"), "highlightCustomTracking": d.b("highlightCustomTracking"), "highlightSubstitutedFonts": d.b("highlightSubstitutedFonts"), "richBlackOutput": d.b("richBlackOutput"), "typographersQuotes": d.b("typographersQuotes"), "showFontNamesInEnglish": d.b("showFontNamesInEnglish"), "smartTextReflow": d.b("smartTextReflow"),
+ let mut prefs = json!({"scaleStrokes": d.b("scaleStrokes"), "dimensionsIncludeStroke": d.b("dimensionsIncludeStroke"), "transformationsAreTotals": d.b("transformationsAreTotals"), "absolutePageNumbers": d.b("absolutePageNumbers"), "highlightHj": d.b("highlightHj"), "highlightKeeps": d.b("highlightKeeps"), "highlightCustomTracking": d.b("highlightCustomTracking"), "highlightSubstitutedFonts": d.b("highlightSubstitutedFonts"), "richBlackOutput": d.b("richBlackOutput"), "typographersQuotes": d.b("typographersQuotes"), "showFontNamesInEnglish": d.b("showFontNamesInEnglish"), "smartTextReflow": d.b("smartTextReflow"),
"autocorrect": d.b("autocorrect"), "showAddedText": d.b("showAddedText"), "showNoteAnchors": d.b("showNoteAnchors"),
- "recoveryMinutes": d.n("recoveryMinutes").unwrap_or(0.5),
+ "recoveryMinutes": d.n("recoveryMinutes").unwrap_or(0.5), "linkTextFiles": d.b("linkTextFiles"),
"autocorrectList": d.s("autocorrectText").lines().filter_map(|l| {
let (a, b) = l.split_once('→').or_else(|| l.split_once("->"))?;
let (a, b) = (a.trim().to_lowercase(), b.trim().to_string());