Skip to content

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

Import warnings: Show selects the frame a story warning is about

texjer4461ebd8866d
diff --git a/ROADMAP.md b/ROADMAP.md
index ad3f52a14..06668b9de 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -384,6 +384,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
Newest first.
+- **2026-10-30** · Import warnings about a story have a Show button: it closes the warnings (the status line keeps them) and selects the story's first frame, fitted in the window. `file.open` returns `warningItems`, the frame each IDML or InDesign warning is about (or null), matching the converter's INDD story numbers (`story 30892`, written to IDML as `u78ac`) and IDML `Self` names to the imported stories. No readiness percentage change.
- **2026-10-29** · Inserting text with many returns no longer takes time that grows with their square (part of #1588): each return copied its paragraph's format with its own insert, moving every format after it. Splitting 20,000 returns into paragraphs took 15.8 s; placing a text file of them now takes 0.2 s, and one of a million returns 5.5 s. No readiness percentage change.
- **2026-10-28** · Discretionary hyphens (U+00AD) break in the single-line composer with automatic hyphenation on or off, matching the paragraph composer. Unbroken soft hyphens remain invisible and zero-width, and words containing them keep only their discretionary break points (#1955). No readiness percentage change.
- **2026-10-28** · Autoflow no longer sizes the rest of a story by a frame that a Start Paragraph option (next column, frame, page, or odd or even page) ends early (#1209). With a title before a chapter that starts on the next odd page, it estimated a page per few characters, added up to 2000 pages (the autoflow limit) and removed them again: placing 2000 words took 36 s in the app, now 0.4 s, with the same pages. It looks past tracked-deleted paragraphs for the option, as composing does, and asks for every frame that start options and breaks force in one round: 200 one-line chapters on their own pages take 9 ms (58 ms before). A break and the start option it meets count once, and breaks that tracked changes delete or a hidden condition hides don't count. No readiness percentage change.
diff --git a/crates/engine/src/cmd/file/registry.rs b/crates/engine/src/cmd/file/registry.rs
index 216f12bdb..c1f522956 100644
--- a/crates/engine/src/cmd/file/registry.rs
+++ b/crates/engine/src/cmd/file/registry.rs
@@ -37,7 +37,7 @@ pub fn specs() -> Vec<CommandSpec> {
ok()
}),
cmd!(noundo "file.open", "Open…", ["File"], Some("Cmd+O"),
- "{path} — a DesignCraft or IDML file (recognised by its content, so the extension may be missing), or an InDesign .indd/.indt (recognised by its signature or extension, converted to IDML; its conversion warnings join `warnings`); the fonts in a `Document Fonts` folder beside it load first → {index, documentFonts: faces loaded, warnings: font files skipped, GREP styles whose pattern can't compile, Based on Parent links cleared and, for IDML and InDesign files, package parts missing}",
+ "{path} — a DesignCraft or IDML file (recognised by its content, so the extension may be missing), or an InDesign .indd/.indt (recognised by its signature or extension, converted to IDML; its conversion warnings join `warnings`); the fonts in a `Document Fonts` folder beside it load first → {index, documentFonts: faces loaded, warnings: font files skipped, GREP styles whose pattern can't compile, Based on Parent links cleared and, for IDML and InDesign files, package parts missing; warningItems (IDML and InDesign files): per warning, the id of the frame it is about, or null}",
always, file_open),
cmd!(noundo "file.openBytes", "Open Bytes", [], None, "{name, base64} — DesignCraft JSON, an IDML package or an InDesign .indd/.indt → {index, warnings}", always, file_open_bytes),
cmd!(noundo "file.openRecent", "Open Recent File", [], None,
diff --git a/crates/engine/src/cmd/interchange.rs b/crates/engine/src/cmd/interchange.rs
index 0ddb6a1aa..4ca22309c 100644
--- a/crates/engine/src/cmd/interchange.rs
+++ b/crates/engine/src/cmd/interchange.rs
@@ -160,7 +160,7 @@ pub fn import(bytes: &[u8], package: Option<&std::path::Path>) -> Result<Documen
/// [`import`], with the problems that did not stop it (parts missing from the package, …).
pub fn import_report(bytes: &[u8], package: Option<&std::path::Path>) -> Result<(Document, Vec<String>)> {
- import_report_with_previews(bytes, package, &std::collections::HashMap::new())
+ import_report_with_previews(bytes, package, &std::collections::HashMap::new()).map(|(document, warnings, _)| (document, warnings))
}
/// [`import_report`], showing `previews` (graphic `Self` → image) for linked files that can't be read.
@@ -168,7 +168,7 @@ fn import_report_with_previews(
bytes: &[u8],
package: Option<&std::path::Path>,
previews: &std::collections::HashMap<String, std::sync::Arc<Vec<u8>>>,
-) -> Result<(Document, Vec<String>)> {
+) -> Result<(Document, Vec<String>, std::collections::HashMap<String, designcraft_doc::StoryId>)> {
#[cfg(not(target_arch = "wasm32"))]
let resolved = std::cell::RefCell::new(std::collections::HashMap::new());
let read = |link: &str| -> Option<Vec<u8>> {
@@ -184,7 +184,7 @@ fn import_report_with_previews(
None
}
};
- let designcraft_idml::Imported { mut document, warnings } =
+ let designcraft_idml::Imported { mut document, warnings, story_ids } =
designcraft_idml::import_idml_report_with_previews(bytes, &read, previews).map_err(|e| EngineError::Other(e.to_string()))?;
resolve_pdf_crops(&mut document);
#[cfg(not(target_arch = "wasm32"))]
@@ -199,7 +199,7 @@ fn import_report_with_previews(
resolve_packaged_links(&mut document, package);
document
};
- Ok((document, warnings))
+ Ok((document, warnings, story_ids))
}
/// Placed PDFs read from IDML name their crop (`PDFCrop`): find where each box sits on its page,
@@ -422,7 +422,7 @@ pub(crate) fn open_idml(s: &mut Session, p: &Value) -> Result<Value> {
} else {
bytes
};
- let (mut d, import_warnings) = import_report_with_previews(&bytes, package.as_deref(), &previews)?;
+ let (mut d, import_warnings, story_ids) = import_report_with_previews(&bytes, package.as_deref(), &previews)?;
warnings.extend(import_warnings);
if !title.is_empty() {
d.title = title;
@@ -433,11 +433,25 @@ pub(crate) fn open_idml(s: &mut Session, p: &Value) -> Result<Value> {
};
warnings.extend(font_warnings);
warnings.extend(super::style::grep_style_warnings(&d));
+ let warning_items: Vec<Value> = warnings.iter().map(|w| warning_item(&d, &story_ids, w).map_or(Value::Null, |i| json!(i.0))).collect();
// Never save over the .idml or .indd with the native format: the document starts unsaved.
let mut st = DocState::new(d, None);
st.fonts = fonts;
let i = s.add_document(st);
- Ok(json!({"index": i, "documentFonts": faces, "warnings": warnings}))
+ Ok(json!({"index": i, "documentFonts": faces, "warnings": warnings, "warningItems": warning_items}))
+}
+
+/// The frame an import warning is about, so it can be shown: the first frame of the story a
+/// "story …: …" warning names, by the converter's INDD id (`story 30892`, which it writes to the
+/// IDML as `u78ac`) or by its IDML `Self` (`story u78ac`).
+fn warning_item(
+ d: &Document,
+ story_ids: &std::collections::HashMap<String, designcraft_doc::StoryId>,
+ warning: &str,
+) -> Option<designcraft_doc::ItemId> {
+ let name = warning.strip_prefix("story ")?.split([':', ' ']).next()?;
+ let self_id = name.parse::<u32>().map_or_else(|_| name.to_string(), |uid| format!("u{uid:x}"));
+ d.stories.get(story_ids.get(&self_id)?)?.frames.first().copied()
}
/// An InDesign document or template (.indd, .indt): known by its signature, or by its name when
@@ -479,6 +493,24 @@ mod tests {
Ok((bytes, png))
}
+ #[test]
+ fn story_warnings_point_at_the_story_frame() {
+ let mut session = Session::new();
+ session.execute("file.new", &json!({})).unwrap();
+ session.execute("frame.create", &json!({"rect": [36, 36, 300, 200], "content": "text"})).unwrap();
+ let idml = designcraft_idml::export_idml_with(&session.doc().unwrap().doc, &designcraft_idml::ExportOptions { embed_images: true });
+ let (d, _, story_ids) = import_report_with_previews(&idml, None, &std::collections::HashMap::new()).unwrap();
+ let (self_id, sid) = story_ids.iter().find(|(_, sid)| d.stories.get(*sid).is_some_and(|s| !s.frames.is_empty())).unwrap();
+ let frame = d.stories[sid].frames[0];
+ assert_eq!(warning_item(&d, &story_ids, &format!("story {self_id}: something")), Some(frame));
+ // The INDD converter names stories by their number, which it writes as `u` + hex.
+ if let Some(uid) = self_id.strip_prefix('u').and_then(|h| u32::from_str_radix(h, 16).ok()) {
+ assert_eq!(warning_item(&d, &story_ids, &format!("story {uid}: text orientation of its frames is not known")), Some(frame));
+ }
+ assert_eq!(warning_item(&d, &story_ids, "story 999999999: unknown"), None);
+ assert_eq!(warning_item(&d, &story_ids, "a table of 2 rows was read as 1"), None);
+ }
+
#[test]
fn opens_nested_packaged_links_from_a_different_computer() {
let dir = std::env::temp_dir().join(format!("dc-idml-nested-links-{}", std::process::id()));
diff --git a/crates/idml/src/import.rs b/crates/idml/src/import.rs
index 2c6185c5c..51cda9c5b 100644
--- a/crates/idml/src/import.rs
+++ b/crates/idml/src/import.rs
@@ -60,6 +60,9 @@ pub struct Imported {
/// One line per problem that did not stop the import (a part listed in `designmap.xml` but
/// absent from the package, …).
pub warnings: Vec<String>,
+ /// Each story's IDML `Self` → its id in `document`, so a warning that names a story can
+ /// point at it.
+ pub story_ids: HashMap<String, StoryId>,
}
/// Import with a custom reader for linked files, reporting the problems that did not stop it.
@@ -119,6 +122,7 @@ pub fn import_idml_report_with_previews(
));
}
warnings.append(&mut im.warnings);
+ let story_ids = im.story_ids.clone();
let mut document = im.finish(&root).map_err(|e| match e {
// Without its spread parts there is nothing to open: say which parts were missing.
IdmlError::Invalid(msg) if !warnings.is_empty() => IdmlError::Invalid(format!("{msg} ({})", warnings.join("; "))),
@@ -126,7 +130,7 @@ pub fn import_idml_report_with_previews(
})?;
warnings.extend(document.fix_parent_bases());
document.check().map_err(|e| IdmlError::Invalid(e.to_string()))?;
- Ok(Imported { document, warnings })
+ Ok(Imported { document, warnings, story_ids })
}
struct ItemCtx {
diff --git a/crates/ui-egui/src/app/files.rs b/crates/ui-egui/src/app/files.rs
index 49d2bd757..b5de53ab1 100644
--- a/crates/ui-egui/src/app/files.rs
+++ b/crates/ui-egui/src/app/files.rs
@@ -258,21 +258,27 @@ impl DesignApp {
}
self.ui.dialog = Some(dialogs::Dialog::new("alert", json!({"title": title, "file": file, "message": e})));
} else if let Ok(result) = &r {
- let warnings: Vec<&str> = result
+ // Each warning with the frame it is about (`warningItems`), if any.
+ let items = result.get("warningItems").and_then(Value::as_array);
+ let (warnings, lines): (Vec<&str>, Vec<Value>) = result
.get("warnings")
.and_then(Value::as_array)
.into_iter()
.flatten()
- .filter_map(Value::as_str)
- .filter(|warning| !warning.is_empty())
- .collect();
+ .enumerate()
+ .filter_map(|(i, w)| Some((i, w.as_str()?)))
+ .filter(|(_, warning)| !warning.is_empty())
+ .map(|(i, w)| (w, json!({"text": w, "item": items.and_then(|a| a.get(i)).cloned().unwrap_or(Value::Null)})))
+ .unzip();
if !warnings.is_empty() {
self.status(format!("{file}: {}", warnings.join("; ")));
// Find Font, offered for the document's missing fonts, stays up: the status line
// keeps the warnings.
if self.ui.dialog.as_ref().is_none_or(|d| d.id != "findFont") {
- self.ui.dialog =
- Some(dialogs::Dialog::new("alert", json!({"title": "Import Warnings", "file": file, "message": warnings.join("\n")})));
+ self.ui.dialog = Some(dialogs::Dialog::new(
+ "alert",
+ json!({"title": "Import Warnings", "file": file, "message": warnings.join("\n"), "lines": lines}),
+ ));
}
}
}
@@ -326,6 +332,7 @@ mod import_warning_tests {
assert_eq!(dialog.id, "alert");
assert_eq!(dialog.fields["title"], "Import Warnings");
assert_eq!(dialog.fields["file"], file);
+ assert!(dialog.fields["lines"].as_array().unwrap().iter().all(|l| l["item"].is_null()), "missing parts name no frame");
for part in ["Spreads/missing.xml", "Stories/missing.xml"] {
assert!(dialog.fields["message"].as_str().unwrap().contains(part), "every missing part is named");
assert!(app.ui.status.contains(part), "the status line retains the warning");
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index bb3077103..0a60ef18f 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -2187,6 +2187,36 @@ fn check(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str) {
}
/// Draw the active localized dialog; open popups own Enter/Escape, and result handling drives confirm or cancel.
+/// An alert's message. Import warnings (`lines`: `{text, item}`) list one per line, scrolling
+/// when there are many, with Show beside each that names a frame (sets `show`).
+fn alert_message(app: &DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {
+ let lines: Vec<(String, Option<u64>)> = d
+ .fields
+ .get("lines")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
+ .map(|l| (l.get("text").and_then(Value::as_str).unwrap_or_default().to_string(), l.get("item").and_then(Value::as_u64)))
+ .collect();
+ if lines.iter().all(|(_, item)| item.is_none()) {
+ crate::rtl::label(ui, d.s("message"));
+ return;
+ }
+ let show = crate::i18n::tr(&app.ui.language, "Show");
+ egui::ScrollArea::vertical().max_height(360.0).auto_shrink([false, true]).show(ui, |ui| {
+ for (text, item) in &lines {
+ ui.horizontal_wrapped(|ui| {
+ if let Some(item) = item
+ && ui.small_button(crate::rtl::widget(ui, show)).clicked()
+ {
+ d.fields.insert("show".into(), json!(item));
+ }
+ crate::rtl::label(ui, text.as_str());
+ });
+ }
+ });
+}
+
pub fn show(app: &mut DesignApp, ctx: &egui::Context) {
let shortcuts = app.ui.dialog.as_ref().is_some_and(|d| d.id == crate::shortcuts_dialog::DIALOG_ID);
if shortcuts {
@@ -2999,7 +3029,7 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {
crate::rtl::label(ui, egui::RichText::new(crate::rtl::isolate(&file)).font(semibold(13.0)));
ui.add_space(4.0);
}
- crate::rtl::label(ui, d.s("message"));
+ alert_message(app, ui, &mut d);
}
_ => {}
}
@@ -3058,6 +3088,15 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {
});
});
});
+ // Show on an import warning: close the warnings (the status line keeps them) and select the
+ // frame the warning is about, in view, so it can be fixed.
+ if let Some(item) = d.fields.remove("show").and_then(|v| v.as_u64()) {
+ app.ui.dialog = None;
+ if app.run("selection.set", json!({"ids": [item]})).is_ok() {
+ let _ = app.run("view.fitSelection", json!({}));
+ }
+ return;
+ }
// Preferences › General › Interface Language takes effect at once, like any other app setting.
if let Some(lang) = d.fields.remove("applyLanguage")
&& let Err(e) = app.run("app.language", json!({"lang": lang}))
diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs
index 84cbf3bea..61aeea6a7 100644
--- a/crates/ui-egui/src/dialogs/tests.rs
+++ b/crates/ui-egui/src/dialogs/tests.rs
@@ -3521,3 +3521,37 @@ fn character_style_options_set_the_digits() {
assert_eq!(ctl(&mut app, "ui.dialog.confirm", json!({}))["ok"], true);
assert_eq!(char_style(&app, "Emphasis").unwrap().chars.digits, Some(designcraft_doc::Digits::Farsi));
}
+
+#[test]
+fn import_warning_show_selects_the_frame_it_is_about() {
+ use egui_kittest::{Harness, kittest::Queryable};
+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({})).unwrap();
+ let f = app.run("frame.create", json!({"rect": [36, 36, 300, 200], "content": "text"})).unwrap();
+ app.run("selection.set", json!({"ids": []})).unwrap();
+ let lines = json!([
+ {"text": "a table of 2 rows was read as 1", "item": null},
+ {"text": "story 30892: text orientation of its frames is not known or differs; written as horizontal", "item": f["id"]},
+ ]);
+ app.ui.dialog = Some(Dialog::new("alert", json!({"title": "Import Warnings", "file": "book.indd", "message": "", "lines": lines})));
+ let mut h = Harness::builder().with_size(egui::vec2(1000.0, 800.0)).build_ui_state(
+ |ui, app: &mut DesignApp| {
+ let key = egui::Id::unique("import_warning_show_fonts");
+ if ui.data(|d| d.get_temp::<bool>(key)).is_none() {
+ crate::theme::install_fonts(ui.ctx(), "");
+ ui.data_mut(|d| d.insert_temp(key, true));
+ return;
+ }
+ show(app, ui.ctx());
+ },
+ app,
+ );
+ h.run_steps(3);
+ // Only the warning that names a frame offers Show.
+ assert_eq!(h.query_all_by_label("Show").count(), 1);
+ h.get_by_label("Show").click();
+ h.run_steps(3);
+ let app = h.state();
+ assert!(app.ui.dialog.is_none(), "Show closes the warnings");
+ assert_eq!(app.session.doc().unwrap().selection.items, vec![designcraft_doc::ItemId(f["id"].as_u64().unwrap())]);
+}