Skip to content

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

Merge remote-tracking branch 'origin/main' into paragraph-style-general

moppeeer0ca8633987c3
diff --cc ROADMAP.md
index b0ea61ac9,458b706cc..56caed228
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -19,7 -35,11 +35,12 @@@ DesignCraft aims at full Adobe InDesig
regression tests cover metadata, output-intent references, nonzero generations and
forward Prev links; repeated cross-reference offsets are rejected explicitly. No readiness percentage change.
+ - **2026-10-23** · PDF layer commands reject overrides on layerless files atomically;
+ default layer queries find a placed PDF anywhere in mixed selections. Regression tests cover
+ IDML export after rejection and both selection orders.
+
+ ## Status (2026-10-01)
+## Status (2026-10-21)
**Working today**
- Document model: facing/non-facing spreads, parent pages with page-number markers, sections, layers, frames (text / graphic / unassigned), threaded stories, paragraph/character/object styles with based-on, swatches (process/spot/tints/gradients), corner options, text wrap, drop shadow, opacity/blend.
diff --cc crates/engine/src/cmd/style.rs
index 699b01ea8,5d440a5d4..c128e68b1
--- a/crates/engine/src/cmd/style.rs
+++ b/crates/engine/src/cmd/style.rs
@@@ -311,7 -318,7 +318,7 @@@ pub fn specs() -> Vec<CommandSpec>
"Paragraph Style Options…",
[],
None,
- "{name, rename?, basedOn?, nextStyle?: style | null ([Same style]), resetToBase?: bool (Reset To Base: the style sets nothing of its own; `para`/`chars` then apply over its Based On), para?: {paragraph attributes, as type.para names them: align, leftIndent, spaceBefore, …; ruleAbove?/ruleBelow?: only the named rule fields change; startAt?: null = continue numbering; kinsoku?: set | null (default rules); a grepStyles pattern that can't compile is an error}, chars?: {character attributes, as type.char names them: fontFamily, fontStyle, size, leading, tracking, fill, …}}",
- "{name, rename?, basedOn?, nextStyle?, para?: {paragraph attributes, as type.para names them: align, leftIndent, spaceBefore, ignoreOpticalMargin, …; ruleAbove?/ruleBelow?: only the named rule fields change; startAt?: null = continue numbering; kinsoku?: set | null (default rules); a grepStyles pattern that can't compile is an error}, chars?: {character attributes, as type.char names them: fontFamily, fontStyle, size, leading, tracking, fill, …}}",
++ "{name, rename?, basedOn?, nextStyle?: style | null ([Same style]), resetToBase?: bool (Reset To Base: the style sets nothing of its own; `para`/`chars` then apply over its Based On), para?: {paragraph attributes, as type.para names them: align, leftIndent, spaceBefore, ignoreOpticalMargin, …; ruleAbove?/ruleBelow?: only the named rule fields change; startAt?: null = continue numbering; kinsoku?: set | null (default rules); a grepStyles pattern that can't compile is an error}, chars?: {character attributes, as type.char names them: fontFamily, fontStyle, size, leading, tracking, fill, …}}",
has_doc,
edit_para
),
@@@ -941,44 -941,22 +948,52 @@@ fn edit_para(s: &mut Session, p: &Value
let name = str_param(p, "name").ok_or_else(|| bad("style.paragraph.edit", "missing name"))?.to_string();
let chars: CharAttrs = attrs("style.paragraph.edit", "chars", p, |a: &mut CharAttrs, k, v| a.set_json(k, v))?;
super::text::validate_char_fill(&s.doc()?.doc, &chars, "style.paragraph.edit")?;
- let rename = str_param(p, "rename").map(str::to_string);
+ let rename = str_param(p, "rename").map(str::trim).filter(|n| *n != name).map(str::to_string);
let based = p.get("basedOn").cloned();
+ let next = p.get("nextStyle").cloned();
+ let reset = p.get("resetToBase").and_then(Value::as_bool).unwrap_or(false);
+ for (key, v) in [("basedOn", &based), ("nextStyle", &next)] {
+ if v.as_ref().is_some_and(|v| !v.is_string() && !v.is_null()) {
+ return Err(bad("style.paragraph.edit", format!("`{key}` must be a style name or null")));
+ }
+ }
s.edit(|d, _| {
- if let Some(Value::String(b)) = &based
- && d.styles.para_based_on_cycles(&name, b)
+ if let Some(Value::String(b)) = &based {
+ if d.styles.para(b).is_none() {
+ return Err(bad("style.paragraph.edit", format!("no style `{b}`")));
+ }
+ if d.styles.para_based_on_cycles(&name, b) {
+ return Err(bad("style.paragraph.edit", "based-on would create a cycle"));
+ }
+ }
+ if let Some(Value::String(n)) = &next
+ && d.styles.para(n).is_none()
{
- return Err(bad("style.paragraph.edit", "based-on would create a cycle"));
+ return Err(bad("style.paragraph.edit", format!("no style `{n}`")));
+ }
+ // Reset To Base: what the style set of its own goes before the edits apply.
+ if reset {
+ let st = d.styles_mut().para_mut(&name).ok_or_else(|| bad("style.paragraph.edit", format!("no style `{name}`")))?;
+ st.para = ParaAttrs::default();
+ st.chars = CharAttrs::default();
+ }
+ // A new Based On first, so the fields below resolve over the new parent.
+ if based.is_some() {
+ let st = d.styles_mut().para_mut(&name).ok_or_else(|| bad("style.paragraph.edit", format!("no style `{name}`")))?;
+ match &based {
+ Some(Value::String(b)) => st.based_on = Some(b.clone()),
+ Some(Value::Null) => st.based_on = None,
+ _ => {}
+ }
}
+ if let Some(n) = &rename {
+ if n.is_empty() || n.starts_with('[') {
+ return Err(bad("style.paragraph.edit", format!("can't rename to `{n}`")));
+ }
+ if d.styles.para(n).is_some() {
+ return Err(bad("style.paragraph.edit", format!("a paragraph style named `{n}` already exists")));
+ }
+ }
// A rule object changes only the rule fields it names, over the style's resolved rule.
let (current, _) = d.styles.resolve_para_style(&name);
let mut para: ParaAttrs = attrs("style.paragraph.edit", "para", p, |a: &mut ParaAttrs, k, v| a.set_json_over(k, v, &current))?;
diff --cc crates/ui-egui/src/dialogs.rs
index fe711b183,f6404c8ef..148cc10ba
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@@ -3785,10 -3892,9 +3927,10 @@@ fn confirm_paragraph_style_options(app
}
let (para, chars) = style_option_maps(d);
let based = d.s("basedOn");
- let rename = d.s("rename");
+ let rename = d.s("rename").trim().to_string();
+ let next = d.fields.get("nextStyle").cloned();
let (r, style) = if d.b("new") {
- let mut params = json!({"name": if rename.trim().is_empty() { "Paragraph Style 1" } else { rename.trim() }, "para": para, "chars": chars});
+ let mut params = json!({"name": if rename.is_empty() { "Paragraph Style 1" } else { rename.as_str() }, "para": para, "chars": chars});
if !based.is_empty() && based != designcraft_doc::NO_PARA_STYLE {
params["basedOn"] = json!(based);
}