DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge PR #1060: Styles: show paragraph overrides and clear them from the row menu
aiongg75875b2e96d7
diff --cc ROADMAP.mdindex 5abe60ac0,9c1ab281e..388fd5409--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -345,10 -343,8 +345,12 @@@ list) · [roadmap.md](docs/roadmap.md)## Progress log+- **2026-10-15** · Applying text styles removes matching local formatting so capture sources+ inherit later edits; real overrides and named character styles remain.+- **2026-10-15** · Redefine paragraph and character styles from local formatting, including the+ Styles panel context menu, global updates and one-step undo.+ - **2026-10-15** · Paragraph Styles marks local character overrides and offers Clear Overrides+ in the style row menu; named character styles and equal local values are not false overrides.- **2026-10-13** · Switching between document and parent pages refreshes the canvas immediately, preventing black parent pages and stale document objects when the zoom stays the same. Ordinary edits retain partial repainting. No readiness percentage change.diff --cc crates/engine/src/cmd/text.rsindex 3205530a9,8d7abaa6e..685ece7ab--- a/crates/engine/src/cmd/text.rs+++ b/crates/engine/src/cmd/text.rs@@@ -1722,33 -1279,18 +1722,42 @@@ fn selection_attrs(s: &mut Session, p:let (pp, base) = st.doc.styles.resolve_para(pf);let cf = effective_char_format(s, &Target { story: sid, cell, range: r.clone() })?;let cp = st.doc.styles.resolve_char(&base, &cf);+ let (style_para, style_chars) = st.doc.styles.resolve_para_style(&pf.style);+ let mut character_base = base.clone();+ let character_style = st.doc.styles.char_style_attrs(&cf.style);+ character_base.apply(&character_style);+ let char_delta = character_base.delta(&cp);+ let style_keys = character_style.keys();+ let character_style_overrides = char_delta.keys().iter().filter(|key| style_keys.contains(key)).count();+ // The selected text (its start, on one line), for previews such as the font menu's.let selected = selected_text_preview(story.text.get(r.start..r.end).unwrap_or_default().chars());- Ok(json!({"story": sid.0, "paragraphStyle": pf.style, "characterStyle": cf.style, "para": pp, "chars": cp,+ let mut out = json!({"story": sid.0, "paragraphStyle": pf.style, "characterStyle": cf.style, "para": pp, "chars": cp,- "paraOverrides": pf.para.count(), "charOverrides": cf.over.count(), "selectedText": selected.trim()});+ "paraOverrides": style_para.delta(&pp).count() + style_chars.delta(&base).count(),+ "charOverrides": char_delta.count(), "characterStyleOverrides": character_style_overrides,- "selectedText": selected.trim()}))++ "selectedText": selected.trim()});+ if bool_or(p, "mixed", false) {+ out["paraMixed"] = json!(mixed_para_attrs(&st.doc, &targets));+ }+ Ok(out)+}++/// The paragraph attributes whose resolved values differ across the paragraphs of `targets`.+fn mixed_para_attrs(doc: &designcraft_doc::Document, targets: &[Target]) -> Vec<String> {+ let mut first: Option<serde_json::Map<String, Value>> = None;+ let mut mixed = std::collections::BTreeSet::new();+ for t in targets {+ let Some(story) = doc.text_story(t.story, t.cell) else { continue };+ let a = story.para_at(t.range.start);+ let b = story.para_at(t.range.end.max(t.range.start));+ for pf in story.paras.get(a..=b).unwrap_or(&[]) {+ let Ok(Value::Object(v)) = serde_json::to_value(doc.styles.resolve_para(pf).0) else { continue };+ match &first {+ None => first = Some(v),+ Some(f) => mixed.extend(v.into_iter().filter(|(k, x)| f.get(k) != Some(x)).map(|(k, _)| k)),+ }+ }+ }+ mixed.into_iter().collect()}/// The first target character, with any pending caret overrides. Keep character-stylediff --cc crates/ui-egui/src/panels/styles.rsindex 0ecf9dbbc,dd793ef5a..f7e6fa803--- a/crates/ui-egui/src/panels/styles.rs+++ b/crates/ui-egui/src/panels/styles.rs@@@ -129,11 -126,14 +139,19 @@@ fn style_row(app: &mut DesignApp, ui: &let _ = app.run(cmd, json!({"name": n}));ui.close();}+ if editable && current == Some(n) && ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Redefine Style"))).clicked() {+ let command = if para { "style.paragraph.redefine" } else { "style.character.redefine" };+ let _ = app.run(command, json!({"name":n}));+ ui.close();+ }+ if para+ && ui+ .button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Apply \"{name}\", Clear Overrides").replace("{name}", label)))+ .clicked()+ {+ let _ = app.run("style.paragraph.apply", json!({"name": n, "clearOverrides": true}));+ ui.close();+ }if current == Some(n) && ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Break Link to Style"))).clicked() {let _ = app.run("style.breakLink", json!({"kind": kind}));ui.close();@@@ -189,34 -189,58 +207,86 @@@ mod testsuse super::*;+ #[test]+ fn selected_style_context_menu_redefines_its_format() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({})).unwrap();+ let frame = app.run("frame.create", json!({"rect":[36,36,300,200],"content":"text","text":"Headline"})).unwrap();+ app.run("text.select", json!({"story":frame["story"],"anchor":0,"focus":8})).unwrap();+ app.run("style.paragraph.create", json!({"name":"Header","chars":{"size":18}})).unwrap();+ app.run("style.paragraph.apply", json!({"name":"Header"})).unwrap();+ app.run("type.char", json!({"size":24})).unwrap();+ let mut h = Harness::builder().with_size(vec2(360.0, 240.0)).build_ui_state(+ |ui, app: &mut DesignApp| {+ let tokens = Tokens::get(ui.ctx());- style_row(app, ui, true, "Header", Some("Header"), &[], &tokens);++ style_row(app, ui, true, "Header", Some("Header"), true, &[], &tokens);+ },+ app,+ );+ h.run_steps(3);+ let at = egui::pos2(30.0, 15.0);+ h.event(egui::Event::PointerMoved(at));+ for pressed in [true, false] {+ h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed, modifiers: Default::default() });+ h.run_steps(2);+ }+ h.get_by_label("Redefine Style").click();+ h.run_steps(3);+ assert_eq!(h.state().session.doc().unwrap().doc.styles.para("Header").unwrap().chars.size, Some(24.0));+ }++ #[test]+ fn paragraph_color_override_is_marked_and_cleared_from_the_row_menu() {+ 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", "text": "Header"})).unwrap();+ app.run("text.select", json!({"story": f["story"], "anchor": 0, "focus": 6})).unwrap();+ app.run("style.paragraph.create", json!({"name": "Header", "chars": {"fill": "[Black]"}})).unwrap();+ app.run("style.paragraph.apply", json!({"name": "Header"})).unwrap();+ app.run("style.character.create", json!({"name": "Emphasis", "chars": {"underline": true}})).unwrap();+ app.run("style.character.apply", json!({"name": "Emphasis"})).unwrap();+ app.run("type.char", json!({"fill": "[Paper]"})).unwrap();+ let mut h = Harness::builder().with_size(vec2(460.0, 300.0)).build_ui_state(|ui, app: &mut DesignApp| paragraph(app, ui), app);+ h.run_steps(3);+ let at = h.get_all_by_label("Header+").next_back().unwrap().rect().center();+ h.event(egui::Event::PointerMoved(at));+ for pressed in [true, false] {+ h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Secondary, pressed, modifiers: Default::default() });+ h.run_steps(2);+ }+ h.get_by_label("Apply \"Header\", Clear Overrides").click();+ h.run_steps(3);+ let app = h.state_mut();+ let a = app.run("type.selectionAttrs", json!({})).unwrap();+ assert_eq!(a["chars"]["fill"], "[Black]");+ assert_eq!(a["chars"]["underline"], true);+ assert_eq!(a["characterStyle"], "Emphasis");+ assert_eq!(a["charOverrides"], 0);+ assert_eq!(a["paraOverrides"], 0);+ app.run("edit.undo", json!({})).unwrap();+ assert_eq!(app.run("type.selectionAttrs", json!({})).unwrap()["chars"]["fill"], "[Paper]");+ }++ #[test]+ fn named_character_styles_and_redundant_local_values_are_not_paragraph_overrides() {+ 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", "text": "Body text"})).unwrap();+ app.run("text.select", json!({"story": f["story"], "anchor": 0, "focus": 4})).unwrap();+ app.run("style.paragraph.create", json!({"name": "Body", "para": {"spaceAfter": 6}, "chars": {"size": 10}})).unwrap();+ app.run("style.paragraph.apply", json!({"name": "Body"})).unwrap();+ app.run("style.character.create", json!({"name": "Italic", "chars": {"fontStyle": "Italic"}})).unwrap();+ app.run("style.character.apply", json!({"name": "Italic"})).unwrap();+ app.run("type.char", json!({"size": 10, "fontStyle": "Italic"})).unwrap();+ app.run("type.para", json!({"spaceAfter": 6})).unwrap();+ let a = app.run("type.selectionAttrs", json!({})).unwrap();+ assert_eq!((a["paraOverrides"].as_u64(), a["charOverrides"].as_u64()), (Some(0), Some(0)));+ let mut h = Harness::builder().with_size(vec2(360.0, 240.0)).build_ui_state(|ui, app: &mut DesignApp| paragraph(app, ui), app);+ h.run_steps(3);+ assert!(h.query_by_label("Body+").is_none());+ assert!(h.query_all_by_label("Body").next().is_some());+ }+#[test]fn character_style_plus_captures_selection_for_reuse() {let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());diff --cc docs/ui-parity.mdindex fe8023eed,b50d6a65d..619acc1f2--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@@ -1,6 -1,6 +1,6 @@@# UI and interaction parity- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (live corners work; document views row: scrollbars, Alt pans while editing text; Tabs panel listed as present (#343); spring-loaded Zoom navigation) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (paragraph style override feedback and clearing) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (live corners work; document views row: scrollbars, Alt pans while editing text; Tabs panel listed as present (#343); spring-loaded Zoom navigation; paragraph style override feedback and clearing) · **Target:** Adobe InDesign 2026 (21.6, Medium Dark, macOS)Tools, handles, snapping, nudging, modifiers, shortcuts, panels, menus, context menus and feel,against InDesign 2026. The look was measured from the running app@@@ -59,33 -59,16 +59,41 @@@ Counted 2026-10-11: 28 rows, 12 ✓, 1for real work is lower, ~45%, because threading is missing and three of the ~ rows (copy/paste,context menus, typing at a caret) are things a layout artist does every minute, and their failures stop work.+Navigation also supports held Space as Hand and held Cmd+Space as Zoom (Ctrl+Space on+Windows/Linux), with Alt-click zooming out. Releasing restores the previous tool and its state.+The temporary Zoom uses the selected Zoom tool's click and horizontal scrubby drag behavior;+marquee zoom is not implemented. It is suppressed while typing in a document text frame or a+focused text field, and does not interrupt an existing tool drag. Synthetic canvas input tests+cover the cursors, click anchors, scrub/release ownership, restoration, typing guards and undo+history (DC-1).+## Remaining effort+Applying a paragraph or character style now removes local values equal to the applied style,+so text used to capture a style follows later edits to that style. Different local formatting+and named character styles stay intact. Paragraph-style application treats selection endpoints+as exclusive; Clear Overrides removes character formatting only inside a nonempty selection.+Regressions cover the capture/edit workflow at 2:16 and 6:02 in+[Jessica Garrity's styles tutorial](https://www.youtube.com/watch?v=pG9JkAPLgs8).++Redefining a character style at a caret also normalizes the sampled source run, so subsequent+style edits reach that text while different local overrides in adjacent runs remain intact.++The selected style's context menu now offers Redefine Style for paragraph and character styles.+It incorporates the source text's local changes, updates every use, and removes matching source+overrides in one undo step. Named character styles remain separate when redefining a paragraph+style. Commands: `style.paragraph.redefine` and `style.character.redefine` (optional `name`,+which must match the source). This implements the global color, size and spacing updates at+about 5:10–6:00 in [Jessica Garrity's styles tutorial](https://www.youtube.com/watch?v=pG9JkAPLgs8).++ The Paragraph Styles panel now includes character formatting in its `+` indicator, on both+ the current-style summary and the selected row. The row menu offers Apply "name", Clear+ Overrides through the existing command, retaining named character styles. Selection attribute+ counts compare effective values with their style definitions, so equal local values and named+ character styles alone do not report overrides. This covers the color-override/clear workflow+ at 4:25–5:20 in [Jessica Garrity's styles tutorial](https://www.youtube.com/watch?v=pG9JkAPLgs8).-Redefine Style and style-dialog Preview remain separate gaps.++Style-dialog Preview remains a separate gap.+| Work | Opus 5.5 h ||---|---|| Copy/paste, context menus, threading clicks, caret formatting on every platform, with control-channel regression tests | 30–50 |