DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Paragraph panel: InDesign's layout and panel menu
moppeeercaced4320573
diff --git a/ROADMAP.md b/ROADMAP.mdindex 244d6fc9d..02204bda7 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -349,6 +349,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.mNewest first.- **2026-10-22** · Hyphenation Settings, as in InDesign: the Paragraph panel menu's Hyphenation… (`app.hyphenationDialog`) sets the selected paragraphs' Hyphenate, Words with at Least, After First, Before Last, Hyphen Limit, Hyphenation Zone, the Better Spacing ↔ Fewer Hyphens slider (InDesign's 0–10 steps), Hyphenate Capitalized Words, Last Word and Across Column, with Preview, as one undo step; Paragraph Style Options › Hyphenation has the same form. The panel menu lists its items in InDesign's order. Replicated from a hyphenation tutorial: the same text in Minion Pro breaks into the same lines as InDesign's with hyphenation on, off, and at Fewer Hyphens. Hyphenate Across Column is kept and round-trips through IDML, but composition doesn't apply it yet. No readiness percentage change.+- **2026-10-22** · The Paragraph panel is laid out as InDesign's: the nine alignment buttons in groups; indent, spacing and drop cap fields by their icons in two columns, with Space Between Paragraphs Using Same Style (Ignore or a space); Shading and Border with the Paragraph Borders and Shading button and colour; Hyphenate with Do Not Align / Align to Baseline Grid. Its panel menu follows InDesign's order: Paragraph and Single-line Composer, Only Align First Line to Grid, Balance Ragged Lines, Optical Margin Alignment, Justification…, Keep Options…, Span Columns…, Hyphenation…, Drop Caps and Nested Styles…, GREP Styles… (these three now open for the selected paragraphs), Paragraph Rules…, Paragraph Borders and Shading…, Bullets and Numbering…, Restart/Continue Numbering, Define Lists… and the paragraph direction. Convert Bullets and Numbering to Text is listed but not available yet. No readiness percentage change.- **2026-10-22** · A ruler guide dragged with the Selection tools, out of a ruler, on its own or with other selected guides, snaps along its axis as objects do (#1221): to other ruler guides, margins, columns, bleed, page and object edges and centers (with the smart-guide mark) and the document grid, within the snap zone and following Snap to Guides and Smart Guides. Shift snaps to the ruler's ticks and Cmd suspends snapping. The preview line, the position readout and the drop use the same snapped position. No readiness percentage change.- **2026-10-22** · macOS: the app menu has a Language submenu after Settings… with each interface language in its own name and the current one checked, as in the suite's other apps; Preferences › General › Interface Language stays. No readiness percentage change.- **2026-10-22** · macOS menu bar: the menus keep working after the interface language or Show CJK Features changes (a rebuilt menu bar lost every click, Quit included), and its key equivalents are the shortcuts in effect, so a shortcut moved in the Keyboard Shortcuts editor leaves its old menu item. No readiness percentage change.diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rsindex 62b47cd7a..8517bc63e 100644--- a/crates/ui-egui/src/chrome.rs+++ b/crates/ui-egui/src/chrome.rs@@ -991,7 +991,7 @@ fn control_paragraph(/// A swatch field of the Control panel (Shading and Border colours): the swatch's chip and name,/// and the document's swatches in its menu. Returns the swatch picked.-fn swatch_field(ui: &mut egui::Ui, doc: &designcraft_doc::Document, cur: &str, width: f32, label: &str) -> Option<String> {+pub(crate) fn swatch_field(ui: &mut egui::Ui, doc: &designcraft_doc::Document, cur: &str, width: f32, label: &str) -> Option<String> {let t = Tokens::get(ui.ctx());let (r, resp) = ui.allocate_exact_size(vec2(width, crate::widgets::FIELD_H), Sense::click());let resp = resp.on_hover_text(label);diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rsindex 999aed488..32df58f6c 100644--- a/crates/ui-egui/src/dialogs.rs+++ b/crates/ui-egui/src/dialogs.rs@@ -2057,6 +2057,9 @@ pub fn show(app: &mut DesignApp, ctx: &egui::Context) {match d.s("section").as_str() {"span" => "Span Columns","bullets" => "Bullets and Numbering",+ "keep" => "Keep Options",+ "nested" => "Drop Caps and Nested Styles",+ "grep" => "GREP Styles",_ => "Paragraph Borders and Shading",},),@@ -3897,270 +3900,8 @@ fn paragraph_style_options(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialotext_field(ui, d, "x.class", 160.0);});}- "nested" => {- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Drop Caps")).font(semibold(12.0)));- egui::Grid::new("psdc").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {- for (label, key, max) in [- ("Lines:", "dropCapLines", designcraft_compose::MAX_DROP_CAP_LINES),- ("Characters:", "dropCapChars", designcraft_compose::MAX_DROP_CAP_CHARS),- ] {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, label));- let v = cur(d, &format!("p.{key}"), &pv[key]).as_f64();- if let Some(n) = crate::widgets::number(ui, &format!("ps{key}"), v, "", 60.0, 0) {- d.fields.insert(format!("p.{key}"), json!((n.max(0.0) as u64).min(max as u64)));- }- ui.end_row();- }- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Character Style:"));- let style = cur(d, "p.dropCapStyle", &pv["dropCapStyle"]).as_str().unwrap_or("").to_string();- let style = if style.is_empty() { designcraft_doc::NO_CHAR_STYLE.to_string() } else { style };- egui::ComboBox::from_id_salt("ps_dropcap_style")- .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, &style)))- .width(160.0)- .show_ui(ui, |ui| {- for c in &cnames {- if ui.selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, c))).clicked() {- d.fields.insert("p.dropCapStyle".into(), json!(c));- }- }- });- ui.end_row();- });- for (label, key) in [("Align Left Edge", "dropCapAlignLeft"), ("Scale for Descenders", "dropCapScaleDescenders")] {- let mut on = cur(d, &format!("p.{key}"), &pv[key]).as_bool().unwrap_or(false);- if ui.checkbox(&mut on, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, label))).changed() {- d.fields.insert(format!("p.{key}"), json!(on));- }- }- ui.add_space(8.0);- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Nested Styles")).font(semibold(12.0)));- let mut list: Vec<Value> = cur(d, "p.nestedStyles", &pv["nestedStyles"]).as_array().cloned().unwrap_or_default();- let mut changed = false;- let mut remove = None;- for (i, ns) in list.iter_mut().enumerate() {- ui.horizontal(|ui| {- let style = ns["style"].as_str().unwrap_or("[None]").to_string();- egui::ComboBox::from_id_salt(("ns_style", i))- .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, &style)))- .width(110.0)- .show_ui(ui, |ui| {- for c in &cnames {- if ui- .selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, c)))- .clicked()- {- ns["style"] = json!(c);- changed = true;- }- }- });- let through = ns["through"].as_bool().unwrap_or(true);- egui::ComboBox::from_id_salt(("ns_thr", i))- .selected_text(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, if through { "through" } else { "up to" })))- .width(70.0)- .show_ui(ui, |ui| {- for (v, l) in [(true, "through"), (false, "up to")] {- if ui.selectable_label(v == through, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, l))).clicked() {- ns["through"] = json!(v);- changed = true;- }- }- });- let mut n = ns["count"].as_u64().unwrap_or(1) as u32;- let mut count_value = |ui: &mut egui::Ui, ns: &mut Value, changed: &mut bool| {- if ui.add(egui::DragValue::new(&mut n).range(1..=999)).changed() {- ns["count"] = json!(n);- *changed = true;- }- };- if !crate::i18n::category_first(&app.ui.language) {- count_value(ui, ns, &mut changed);- }- let kind = ns["until"]["kind"].as_str().unwrap_or("words").to_string();- egui::ComboBox::from_id_salt(("ns_until", i))- .selected_text(crate::rtl::widget(- ui,- if crate::i18n::category_first(&app.ui.language) {- format!("{}:", crate::i18n::tr(&app.ui.language, &kind))- } else {- crate::i18n::tr(&app.ui.language, &kind).to_owned()- },- ))- .width(100.0)- .show_ui(ui, |ui| {- for k in [- "sentences",- "words",- "characters",- "letters",- "digits",- "tab",- "forcedLineBreak",- "emSpace",- "enSpace",- "dropcap",- "chars",- ] {- if ui.selectable_label(k == kind, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, k))).clicked() {- ns["until"] = if k == "chars" { json!({"kind": "chars", "chars": ":"}) } else { json!({"kind": k}) };- changed = true;- }- }- });- if crate::i18n::category_first(&app.ui.language) {- count_value(ui, ns, &mut changed);- }- if kind == "chars" {- let mut c = ns["until"]["chars"].as_str().unwrap_or("").to_string();- if ui.add(egui::TextEdit::singleline(&mut c).desired_width(40.0)).changed() {- ns["until"]["chars"] = json!(c);- changed = true;- }- }- if ui- .small_button("×")- .on_hover_ui(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Delete"));- })- .clicked()- {- remove = Some(i);- }- });- }- if let Some(i) = remove {- list.remove(i);- changed = true;- }- if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "New Nested Style"))).clicked() {- list.push(json!({"style": cnames.get(1).cloned().unwrap_or_default(), "through": true, "count": 1, "until": {"kind": "words"}}));- changed = true;- }- if changed {- d.fields.insert("p.nestedStyles".into(), Value::Array(list));- }- ui.add_space(8.0);- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Nested Line Styles")).font(semibold(12.0)));- let mut lines: Vec<Value> = cur(d, "p.nestedLineStyles", &pv["nestedLineStyles"]).as_array().cloned().unwrap_or_default();- let mut changed = false;- let mut remove = None;- for (i, l) in lines.iter_mut().enumerate() {- ui.horizontal(|ui| {- let style = l["style"].as_str().unwrap_or("").to_string();- egui::ComboBox::from_id_salt(("nls_style", i))- .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, &style)))- .width(130.0)- .show_ui(ui, |ui| {- for c in &cnames {- if ui- .selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, c)))- .clicked()- {- l["style"] = json!(c);- changed = true;- }- }- });- crate::rtl::label(- ui,- if crate::i18n::category_first(&app.ui.language) {- format!("{}:", crate::i18n::tr(&app.ui.language, "lines"))- } else {- crate::i18n::tr(&app.ui.language, "for").to_owned()- },- );- let mut n = l["lines"].as_u64().unwrap_or(1) as u32;- if ui.add(egui::DragValue::new(&mut n).range(1..=999)).changed() {- l["lines"] = json!(n);- changed = true;- }- if !crate::i18n::category_first(&app.ui.language) {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, if n == 1 { "line" } else { "lines" }));- }- if ui- .small_button("×")- .on_hover_ui(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Delete"));- })- .clicked()- {- remove = Some(i);- }- });- }- if let Some(i) = remove {- lines.remove(i);- changed = true;- }- if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "New Line Style"))).clicked() {- lines.push(json!({"style": cnames.get(1).cloned().unwrap_or_default(), "lines": 1}));- changed = true;- }- if changed {- d.fields.insert("p.nestedLineStyles".into(), Value::Array(lines));- }- }- "grep" => {- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "GREP Styles")).font(semibold(12.0)));- let mut list: Vec<Value> = cur(d, "p.grepStyles", &pv["grepStyles"]).as_array().cloned().unwrap_or_default();- let mut changed = false;- let mut remove = None;- for (i, g) in list.iter_mut().enumerate() {- ui.horizontal(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Apply Style:"));- let style = g["style"].as_str().unwrap_or("").to_string();- egui::ComboBox::from_id_salt(("gs_style", i))- .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, &style)))- .width(110.0)- .show_ui(ui, |ui| {- for c in &cnames {- if ui- .selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(&app.ui.language, c)))- .clicked()- {- g["style"] = json!(c);- changed = true;- }- }- });- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "To Text:"));- let mut pat = g["pattern"].as_str().unwrap_or("").to_string();- let bad = grep_error(&pat).is_some();- let r = ui.add(- egui::TextEdit::singleline(&mut pat)- .desired_width(150.0)- .text_color_opt(bad.then_some(egui::Color32::from_rgb(240, 90, 90))),- );- if r.changed() {- g["pattern"] = json!(pat);- changed = true;- }- if ui- .small_button("×")- .on_hover_ui(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Delete"));- })- .clicked()- {- remove = Some(i);- }- });- if let Some(e) = grep_error(g["pattern"].as_str().unwrap_or("")) {- crate::rtl::label(ui, egui::RichText::new(e).size(11.0).color(egui::Color32::from_rgb(240, 90, 90)));- }- }- if let Some(i) = remove {- list.remove(i);- changed = true;- }- if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "New GREP Style"))).clicked() {- list.push(json!({"style": cnames.get(1).cloned().unwrap_or_default(), "pattern": "\\d+"}));- changed = true;- }- if changed {- d.fields.insert("p.grepStyles".into(), Value::Array(list));- }- }+ "nested" => drop_caps_and_nested_styles(&app.ui.language, ui, d, &pv, &cnames),+ "grep" => grep_styles(&app.ui.language, ui, d, &pv, &cnames),"chars" => basic_character_formats(app, ui, d, &CharFields { base: &cv, sparse: false }),"indents" => {egui::Grid::new("psi").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {@@ -4693,6 +4434,254 @@ fn border_shading(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, doc/// Paragraph Style Options › Keep Options: lines kept with the next paragraph, the paragraph's/// lines kept together (all of them, or its first and last lines), and where it starts.+/// Drop Caps and Nested Styles: the drop cap, nested styles and nested line styles (`p.` fields).+fn drop_caps_and_nested_styles(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, cnames: &[String]) {+ let cur = |d: &Dialog, k: &str, base: &Value| d.fields.get(k).cloned().unwrap_or_else(|| base.clone());+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(lang, "Drop Caps")).font(semibold(12.0)));+ egui::Grid::new("psdc").num_columns(2).spacing([8.0, 6.0]).show(ui, |ui| {+ for (label, key, max) in [+ ("Lines:", "dropCapLines", designcraft_compose::MAX_DROP_CAP_LINES),+ ("Characters:", "dropCapChars", designcraft_compose::MAX_DROP_CAP_CHARS),+ ] {+ crate::rtl::label(ui, crate::i18n::tr(lang, label));+ let v = cur(d, &format!("p.{key}"), &pv[key]).as_f64();+ if let Some(n) = crate::widgets::number(ui, &format!("ps{key}"), v, "", 60.0, 0) {+ d.fields.insert(format!("p.{key}"), json!((n.max(0.0) as u64).min(max as u64)));+ }+ ui.end_row();+ }+ crate::rtl::label(ui, crate::i18n::tr(lang, "Character Style:"));+ let style = cur(d, "p.dropCapStyle", &pv["dropCapStyle"]).as_str().unwrap_or("").to_string();+ let style = if style.is_empty() { designcraft_doc::NO_CHAR_STYLE.to_string() } else { style };+ egui::ComboBox::from_id_salt("ps_dropcap_style")+ .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(lang, &style)))+ .width(160.0)+ .show_ui(ui, |ui| {+ for c in cnames {+ if ui.selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(lang, c))).clicked() {+ d.fields.insert("p.dropCapStyle".into(), json!(c));+ }+ }+ });+ ui.end_row();+ });+ for (label, key) in [("Align Left Edge", "dropCapAlignLeft"), ("Scale for Descenders", "dropCapScaleDescenders")] {+ let mut on = cur(d, &format!("p.{key}"), &pv[key]).as_bool().unwrap_or(false);+ if ui.checkbox(&mut on, crate::rtl::widget(ui, crate::i18n::tr(lang, label))).changed() {+ d.fields.insert(format!("p.{key}"), json!(on));+ }+ }+ ui.add_space(8.0);+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(lang, "Nested Styles")).font(semibold(12.0)));+ let mut list: Vec<Value> = cur(d, "p.nestedStyles", &pv["nestedStyles"]).as_array().cloned().unwrap_or_default();+ let mut changed = false;+ let mut remove = None;+ for (i, ns) in list.iter_mut().enumerate() {+ ui.horizontal(|ui| {+ let style = ns["style"].as_str().unwrap_or("[None]").to_string();+ egui::ComboBox::from_id_salt(("ns_style", i))+ .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(lang, &style)))+ .width(110.0)+ .show_ui(ui, |ui| {+ for c in cnames {+ if ui.selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(lang, c))).clicked() {+ ns["style"] = json!(c);+ changed = true;+ }+ }+ });+ let through = ns["through"].as_bool().unwrap_or(true);+ egui::ComboBox::from_id_salt(("ns_thr", i))+ .selected_text(crate::rtl::widget(ui, crate::i18n::tr(lang, if through { "through" } else { "up to" })))+ .width(70.0)+ .show_ui(ui, |ui| {+ for (v, l) in [(true, "through"), (false, "up to")] {+ if ui.selectable_label(v == through, crate::rtl::widget(ui, crate::i18n::tr(lang, l))).clicked() {+ ns["through"] = json!(v);+ changed = true;+ }+ }+ });+ let mut n = ns["count"].as_u64().unwrap_or(1) as u32;+ let mut count_value = |ui: &mut egui::Ui, ns: &mut Value, changed: &mut bool| {+ if ui.add(egui::DragValue::new(&mut n).range(1..=999)).changed() {+ ns["count"] = json!(n);+ *changed = true;+ }+ };+ if !crate::i18n::category_first(lang) {+ count_value(ui, ns, &mut changed);+ }+ let kind = ns["until"]["kind"].as_str().unwrap_or("words").to_string();+ egui::ComboBox::from_id_salt(("ns_until", i))+ .selected_text(crate::rtl::widget(+ ui,+ if crate::i18n::category_first(lang) {+ format!("{}:", crate::i18n::tr(lang, &kind))+ } else {+ crate::i18n::tr(lang, &kind).to_owned()+ },+ ))+ .width(100.0)+ .show_ui(ui, |ui| {+ for k in+ ["sentences", "words", "characters", "letters", "digits", "tab", "forcedLineBreak", "emSpace", "enSpace", "dropcap", "chars"]+ {+ if ui.selectable_label(k == kind, crate::rtl::widget(ui, crate::i18n::tr(lang, k))).clicked() {+ ns["until"] = if k == "chars" { json!({"kind": "chars", "chars": ":"}) } else { json!({"kind": k}) };+ changed = true;+ }+ }+ });+ if crate::i18n::category_first(lang) {+ count_value(ui, ns, &mut changed);+ }+ if kind == "chars" {+ let mut c = ns["until"]["chars"].as_str().unwrap_or("").to_string();+ if ui.add(egui::TextEdit::singleline(&mut c).desired_width(40.0)).changed() {+ ns["until"]["chars"] = json!(c);+ changed = true;+ }+ }+ if ui+ .small_button("×")+ .on_hover_ui(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Delete"));+ })+ .clicked()+ {+ remove = Some(i);+ }+ });+ }+ if let Some(i) = remove {+ list.remove(i);+ changed = true;+ }+ if ui.button(crate::rtl::widget(ui, crate::i18n::tr(lang, "New Nested Style"))).clicked() {+ list.push(json!({"style": cnames.get(1).cloned().unwrap_or_default(), "through": true, "count": 1, "until": {"kind": "words"}}));+ changed = true;+ }+ if changed {+ d.fields.insert("p.nestedStyles".into(), Value::Array(list));+ }+ ui.add_space(8.0);+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(lang, "Nested Line Styles")).font(semibold(12.0)));+ let mut lines: Vec<Value> = cur(d, "p.nestedLineStyles", &pv["nestedLineStyles"]).as_array().cloned().unwrap_or_default();+ let mut changed = false;+ let mut remove = None;+ for (i, l) in lines.iter_mut().enumerate() {+ ui.horizontal(|ui| {+ let style = l["style"].as_str().unwrap_or("").to_string();+ egui::ComboBox::from_id_salt(("nls_style", i))+ .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(lang, &style)))+ .width(130.0)+ .show_ui(ui, |ui| {+ for c in cnames {+ if ui.selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(lang, c))).clicked() {+ l["style"] = json!(c);+ changed = true;+ }+ }+ });+ crate::rtl::label(+ ui,+ if crate::i18n::category_first(lang) {+ format!("{}:", crate::i18n::tr(lang, "lines"))+ } else {+ crate::i18n::tr(lang, "for").to_owned()+ },+ );+ let mut n = l["lines"].as_u64().unwrap_or(1) as u32;+ if ui.add(egui::DragValue::new(&mut n).range(1..=999)).changed() {+ l["lines"] = json!(n);+ changed = true;+ }+ if !crate::i18n::category_first(lang) {+ crate::rtl::label(ui, crate::i18n::tr(lang, if n == 1 { "line" } else { "lines" }));+ }+ if ui+ .small_button("×")+ .on_hover_ui(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Delete"));+ })+ .clicked()+ {+ remove = Some(i);+ }+ });+ }+ if let Some(i) = remove {+ lines.remove(i);+ changed = true;+ }+ if ui.button(crate::rtl::widget(ui, crate::i18n::tr(lang, "New Line Style"))).clicked() {+ lines.push(json!({"style": cnames.get(1).cloned().unwrap_or_default(), "lines": 1}));+ changed = true;+ }+ if changed {+ d.fields.insert("p.nestedLineStyles".into(), Value::Array(lines));+ }+}++/// GREP Styles: a character style applied to text matching each pattern (`p.` fields).+fn grep_styles(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value, cnames: &[String]) {+ let cur = |d: &Dialog, k: &str, base: &Value| d.fields.get(k).cloned().unwrap_or_else(|| base.clone());+ crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(lang, "GREP Styles")).font(semibold(12.0)));+ let mut list: Vec<Value> = cur(d, "p.grepStyles", &pv["grepStyles"]).as_array().cloned().unwrap_or_default();+ let mut changed = false;+ let mut remove = None;+ for (i, g) in list.iter_mut().enumerate() {+ ui.horizontal(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Apply Style:"));+ let style = g["style"].as_str().unwrap_or("").to_string();+ egui::ComboBox::from_id_salt(("gs_style", i))+ .selected_text(crate::rtl::widget(ui, crate::i18n::style_name(lang, &style)))+ .width(110.0)+ .show_ui(ui, |ui| {+ for c in cnames {+ if ui.selectable_label(*c == style, crate::rtl::widget(ui, crate::i18n::style_name(lang, c))).clicked() {+ g["style"] = json!(c);+ changed = true;+ }+ }+ });+ crate::rtl::label(ui, crate::i18n::tr(lang, "To Text:"));+ let mut pat = g["pattern"].as_str().unwrap_or("").to_string();+ let bad = grep_error(&pat).is_some();+ let r =+ ui.add(egui::TextEdit::singleline(&mut pat).desired_width(150.0).text_color_opt(bad.then_some(egui::Color32::from_rgb(240, 90, 90))));+ if r.changed() {+ g["pattern"] = json!(pat);+ changed = true;+ }+ if ui+ .small_button("×")+ .on_hover_ui(|ui| {+ crate::rtl::label(ui, crate::i18n::tr(lang, "Delete"));+ })+ .clicked()+ {+ remove = Some(i);+ }+ });+ if let Some(e) = grep_error(g["pattern"].as_str().unwrap_or("")) {+ crate::rtl::label(ui, egui::RichText::new(e).size(11.0).color(egui::Color32::from_rgb(240, 90, 90)));+ }+ }+ if let Some(i) = remove {+ list.remove(i);+ changed = true;+ }+ if ui.button(crate::rtl::widget(ui, crate::i18n::tr(lang, "New GREP Style"))).clicked() {+ list.push(json!({"style": cnames.get(1).cloned().unwrap_or_default(), "pattern": "\\d+"}));+ changed = true;+ }+ if changed {+ d.fields.insert("p.grepStyles".into(), Value::Array(list));+ }+}+fn keep_options(lang: &str, ui: &mut egui::Ui, d: &mut Dialog, pv: &Value) {ui.horizontal(|ui| {crate::rtl::label(ui, crate::i18n::tr(lang, "Keep with Next:"));@@ -5100,6 +5089,15 @@ fn paragraph_local(app: &mut DesignApp, ui: &mut egui::Ui, d: &mut Dialog) {ui.set_min_width(480.0);match d.s("section").as_str() {"span" => span_columns(&lang, ui, d, &pv, &doc),+ "keep" => keep_options(&lang, ui, d, &pv),+ "nested" | "grep" => {+ let cnames: Vec<String> = doc.styles.character.iter().map(|c| c.name.clone()).collect();+ if d.s("section") == "nested" {+ drop_caps_and_nested_styles(&lang, ui, d, &pv, &cnames);+ } else {+ grep_styles(&lang, ui, d, &pv, &cnames);+ }+ }"bullets" => {let (char_styles, families, fonts, scope) = ListUi::new_parts(app);let (family, style) = (d.s("family"), d.s("style"));diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rsindex 0de369f91..508c8e014 100644--- a/crates/ui-egui/src/i18n.rs+++ b/crates/ui-egui/src/i18n.rs@@ -1065,6 +1065,75 @@ const TABLE: &[(&str, [&str; 5])] = &[],),("Load Styles", ["Formate laden", "Charger les styles", "Cargar estilos", "スタイルを読み込み", "加载样式"]),+ ("Restart Numbering", ["Nummerierung neu beginnen", "Recommencer la numérotation", "Reiniciar numeración", "番号の振り直し", "重新开始编号"]),+ ("Continue Numbering", ["Nummerierung fortführen", "Poursuivre la numérotation", "Continuar numeración", "番号の継続", "继续编号"]),+ ("Keep Options…", ["Umbruchoptionen …", "Options d'enchaînement…", "Opciones de separación…", "段落分離禁止オプション…", "保持选项…"]),+ (+ "Space Between Paragraphs Using Same Style",+ [+ "Abstand zwischen Absätzen mit gleichem Format",+ "Espace entre les paragraphes de même style",+ "Espacio entre párrafos con el mismo estilo",+ "同じスタイルの段落間のスペース",+ "使用相同样式的段落间距",+ ],+ ),+ ("Ignore", ["Ignorieren", "Ignorer", "Ignorar", "無視", "忽略"]),+ (+ "Do Not Align to Baseline Grid",+ [+ "Nicht am Grundlinienraster ausrichten",+ "Ne pas aligner sur la grille de ligne de base",+ "No alinear con cuadrícula base",+ "ベースライングリッドに揃えない",+ "不对齐基线网格",+ ],+ ),+ (+ "Only Align First Line to Grid",+ [+ "Nur erste Zeile am Raster ausrichten",+ "Aligner uniquement la première ligne sur la grille",+ "Alinear solo primera línea con cuadrícula",+ "最初の行のみグリッドに揃える",+ "仅首行对齐网格",+ ],+ ),+ (+ "Balance Ragged Lines",+ ["Unausgeglichene Zeilen ausgleichen", "Équilibrer les lignes irrégulières", "Equilibrar líneas desiguales", "行末を調整", "平衡未对齐的行"],+ ),+ (+ "Drop Caps and Nested Styles…",+ [+ "Initialen und verschachtelte Formate …",+ "Lettrines et styles imbriqués…",+ "Capitulares y estilos anidados…",+ "ドロップキャップと先頭文字スタイル…",+ "首字下沉和嵌套样式…",+ ],+ ),+ ("GREP Styles…", ["GREP-Stile …", "Styles GREP…", "Estilos GREP…", "正規表現スタイル…", "GREP 样式…"]),+ (+ "Restart/Continue Numbering",+ [+ "Nummerierung neu beginnen/fortführen",+ "Recommencer/Poursuivre la numérotation",+ "Reiniciar/Continuar numeración",+ "番号の振り直し/継続",+ "重新开始/继续编号",+ ],+ ),+ (+ "Convert Bullets and Numbering to Text",+ [+ "Aufzählungszeichen und Nummerierung in Text konvertieren",+ "Convertir les puces et la numérotation en texte",+ "Convertir viñetas y numeración en texto",+ "箇条書きと段落番号をテキストに変換",+ "将项目符号和编号转换为文本",+ ],+ ),("Hyphenation…", ["Silbentrennung …", "Césure…", "Separación por sílabas…", "ハイフネーション…", "连字…"]),("Hyphenation Settings",diff --git a/crates/ui-egui/src/i18n/ar.rs b/crates/ui-egui/src/i18n/ar.rsindex e702b89c3..49fd3046e 100644--- a/crates/ui-egui/src/i18n/ar.rs+++ b/crates/ui-egui/src/i18n/ar.rs@@ -30,6 +30,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "قص"),("Copy", "نسخ"),("Paste", "لصق"),+ ("Restart Numbering", "إعادة الترقيم"),+ ("Continue Numbering", "متابعة الترقيم"),+ ("Keep Options…", "خيارات الإبقاء…"),+ ("Space Between Paragraphs Using Same Style", "المسافة بين الفقرات ذات النمط نفسه"),+ ("Ignore", "تجاهل"),+ ("Do Not Align to Baseline Grid", "عدم المحاذاة إلى شبكة خط الأساس"),+ ("Only Align First Line to Grid", "محاذاة السطر الأول فقط إلى الشبكة"),+ ("Balance Ragged Lines", "موازنة الأسطر غير المتساوية"),+ ("Drop Caps and Nested Styles…", "الأحرف الاستهلالية والأنماط المتداخلة…"),+ ("GREP Styles…", "أنماط GREP…"),+ ("Restart/Continue Numbering", "إعادة/متابعة الترقيم"),+ ("Convert Bullets and Numbering to Text", "تحويل التعداد النقطي والترقيم إلى نص"),("Hyphenation…", "الواصلة…"),("Hyphenation Settings", "إعدادات الواصلة"),("hyphens", "واصلات"),diff --git a/crates/ui-egui/src/i18n/cs.rs b/crates/ui-egui/src/i18n/cs.rsindex 34d8cc002..4547a4b37 100644--- a/crates/ui-egui/src/i18n/cs.rs+++ b/crates/ui-egui/src/i18n/cs.rs@@ -31,6 +31,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Vyjmout"),("Copy", "Kopírovat"),("Paste", "Vložit"),+ ("Restart Numbering", "Začít číslování znovu"),+ ("Continue Numbering", "Pokračovat v číslování"),+ ("Keep Options…", "Volby zachování…"),+ ("Space Between Paragraphs Using Same Style", "Mezera mezi odstavci se stejným stylem"),+ ("Ignore", "Ignorovat"),+ ("Do Not Align to Baseline Grid", "Nezarovnávat na mřížku účaří"),+ ("Only Align First Line to Grid", "Zarovnat na mřížku jen první řádek"),+ ("Balance Ragged Lines", "Vyrovnat nezarovnané řádky"),+ ("Drop Caps and Nested Styles…", "Iniciály a vnořené styly…"),+ ("GREP Styles…", "Styly GREP…"),+ ("Restart/Continue Numbering", "Začít znovu/pokračovat v číslování"),+ ("Convert Bullets and Numbering to Text", "Převést odrážky a číslování na text"),("Hyphenation…", "Dělení slov…"),("Hyphenation Settings", "Nastavení dělení slov"),("hyphens", "spojovníky"),diff --git a/crates/ui-egui/src/i18n/de.rs b/crates/ui-egui/src/i18n/de.rsindex b2d66cbe7..068c32255 100644--- a/crates/ui-egui/src/i18n/de.rs+++ b/crates/ui-egui/src/i18n/de.rs@@ -31,6 +31,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Ausschneiden"),("Copy", "Kopieren"),("Paste", "Einfügen"),+ ("Restart Numbering", "Nummerierung neu beginnen"),+ ("Continue Numbering", "Nummerierung fortführen"),+ ("Keep Options…", "Umbruchoptionen …"),+ ("Space Between Paragraphs Using Same Style", "Abstand zwischen Absätzen mit gleichem Format"),+ ("Ignore", "Ignorieren"),+ ("Do Not Align to Baseline Grid", "Nicht am Grundlinienraster ausrichten"),+ ("Only Align First Line to Grid", "Nur erste Zeile am Raster ausrichten"),+ ("Balance Ragged Lines", "Unausgeglichene Zeilen ausgleichen"),+ ("Drop Caps and Nested Styles…", "Initialen und verschachtelte Formate …"),+ ("GREP Styles…", "GREP-Stile …"),+ ("Restart/Continue Numbering", "Nummerierung neu beginnen/fortführen"),+ ("Convert Bullets and Numbering to Text", "Aufzählungszeichen und Nummerierung in Text konvertieren"),("Hyphenation…", "Silbentrennung …"),("Hyphenation Settings", "Silbentrennungseinstellungen"),("hyphens", "Trennstriche"),diff --git a/crates/ui-egui/src/i18n/it.rs b/crates/ui-egui/src/i18n/it.rsindex 6adcaa467..48161b64e 100644--- a/crates/ui-egui/src/i18n/it.rs+++ b/crates/ui-egui/src/i18n/it.rs@@ -28,6 +28,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Taglia"),("Copy", "Copia"),("Paste", "Incolla"),+ ("Restart Numbering", "Riavvia numerazione"),+ ("Continue Numbering", "Continua numerazione"),+ ("Keep Options…", "Opzioni di separazione…"),+ ("Space Between Paragraphs Using Same Style", "Spazio tra paragrafi con lo stesso stile"),+ ("Ignore", "Ignora"),+ ("Do Not Align to Baseline Grid", "Non allineare alla griglia linee di base"),+ ("Only Align First Line to Grid", "Allinea solo la prima riga alla griglia"),+ ("Balance Ragged Lines", "Bilancia righe irregolari"),+ ("Drop Caps and Nested Styles…", "Capilettera e stili nidificati…"),+ ("GREP Styles…", "Stili GREP…"),+ ("Restart/Continue Numbering", "Riavvia/continua numerazione"),+ ("Convert Bullets and Numbering to Text", "Converti elenchi puntati e numerati in testo"),("Hyphenation…", "Sillabazione…"),("Hyphenation Settings", "Impostazioni sillabazione"),("hyphens", "trattini"),diff --git a/crates/ui-egui/src/i18n/ja.rs b/crates/ui-egui/src/i18n/ja.rsindex c8515805b..413b2d99e 100644--- a/crates/ui-egui/src/i18n/ja.rs+++ b/crates/ui-egui/src/i18n/ja.rs@@ -30,6 +30,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "カット"),("Copy", "コピー"),("Paste", "ペースト"),+ ("Restart Numbering", "番号の振り直し"),+ ("Continue Numbering", "番号の継続"),+ ("Keep Options…", "段落分離禁止オプション…"),+ ("Space Between Paragraphs Using Same Style", "同じスタイルの段落間のスペース"),+ ("Ignore", "無視"),+ ("Do Not Align to Baseline Grid", "ベースライングリッドに揃えない"),+ ("Only Align First Line to Grid", "最初の行のみグリッドに揃える"),+ ("Balance Ragged Lines", "行末を調整"),+ ("Drop Caps and Nested Styles…", "ドロップキャップと先頭文字スタイル…"),+ ("GREP Styles…", "正規表現スタイル…"),+ ("Restart/Continue Numbering", "番号の振り直し/継続"),+ ("Convert Bullets and Numbering to Text", "箇条書きと段落番号をテキストに変換"),("Hyphenation…", "ハイフネーション…"),("Hyphenation Settings", "ハイフネーション設定"),("hyphens", "ハイフン"),diff --git a/crates/ui-egui/src/i18n/ka.rs b/crates/ui-egui/src/i18n/ka.rsindex c756cc123..4767b6c30 100644--- a/crates/ui-egui/src/i18n/ka.rs+++ b/crates/ui-egui/src/i18n/ka.rs@@ -31,6 +31,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "ამოჭრა"),("Copy", "კოპირება"),("Paste", "ჩასმა"),+ ("Restart Numbering", "ნუმერაციის თავიდან დაწყება"),+ ("Continue Numbering", "ნუმერაციის გაგრძელება"),+ ("Keep Options…", "შენარჩუნების პარამეტრები…"),+ ("Space Between Paragraphs Using Same Style", "დაშორება ერთი სტილის აბზაცებს შორის"),+ ("Ignore", "უგულებელყოფა"),+ ("Do Not Align to Baseline Grid", "საბაზისო ბადეზე არ გასწორდეს"),+ ("Only Align First Line to Grid", "ბადეზე მხოლოდ პირველი ხაზის გასწორება"),+ ("Balance Ragged Lines", "უსწორმასწორო ხაზების დაბალანსება"),+ ("Drop Caps and Nested Styles…", "საწყისი ასოები და ჩადგმული სტილები…"),+ ("GREP Styles…", "GREP სტილები…"),+ ("Restart/Continue Numbering", "ნუმერაციის თავიდან დაწყება/გაგრძელება"),+ ("Convert Bullets and Numbering to Text", "მარკერებისა და ნუმერაციის ტექსტად გარდაქმნა"),("Hyphenation…", "დამარცვლა…"),("Hyphenation Settings", "დამარცვლის პარამეტრები"),("hyphens", "დეფისი"),diff --git a/crates/ui-egui/src/i18n/pl.rs b/crates/ui-egui/src/i18n/pl.rsindex 6f530abe2..bf0c7600b 100644--- a/crates/ui-egui/src/i18n/pl.rs+++ b/crates/ui-egui/src/i18n/pl.rs@@ -29,6 +29,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Wytnij"),("Copy", "Kopiuj"),("Paste", "Wklej"),+ ("Restart Numbering", "Zacznij numerowanie od nowa"),+ ("Continue Numbering", "Kontynuuj numerowanie"),+ ("Keep Options…", "Opcje utrzymywania…"),+ ("Space Between Paragraphs Using Same Style", "Odstęp między akapitami o tym samym stylu"),+ ("Ignore", "Ignoruj"),+ ("Do Not Align to Baseline Grid", "Nie wyrównuj do siatki linii bazowych"),+ ("Only Align First Line to Grid", "Wyrównaj do siatki tylko pierwszy wiersz"),+ ("Balance Ragged Lines", "Wyrównaj nierówne wiersze"),+ ("Drop Caps and Nested Styles…", "Inicjały i style zagnieżdżone…"),+ ("GREP Styles…", "Style GREP…"),+ ("Restart/Continue Numbering", "Zacznij od nowa/kontynuuj numerowanie"),+ ("Convert Bullets and Numbering to Text", "Konwertuj wypunktowanie i numerowanie na tekst"),("Hyphenation…", "Dzielenie wyrazów…"),("Hyphenation Settings", "Ustawienia dzielenia wyrazów"),("hyphens", "dywizy"),diff --git a/crates/ui-egui/src/i18n/pt_br.rs b/crates/ui-egui/src/i18n/pt_br.rsindex b8174f7d8..4faf5cee5 100644--- a/crates/ui-egui/src/i18n/pt_br.rs+++ b/crates/ui-egui/src/i18n/pt_br.rs@@ -31,6 +31,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Recortar"),("Copy", "Copiar"),("Paste", "Colar"),+ ("Restart Numbering", "Reiniciar numeração"),+ ("Continue Numbering", "Continuar numeração"),+ ("Keep Options…", "Opções de manutenção…"),+ ("Space Between Paragraphs Using Same Style", "Espaço entre parágrafos com o mesmo estilo"),+ ("Ignore", "Ignorar"),+ ("Do Not Align to Baseline Grid", "Não alinhar à grade de linha de base"),+ ("Only Align First Line to Grid", "Alinhar somente a primeira linha à grade"),+ ("Balance Ragged Lines", "Equilibrar linhas irregulares"),+ ("Drop Caps and Nested Styles…", "Capitulares e estilos aninhados…"),+ ("GREP Styles…", "Estilos GREP…"),+ ("Restart/Continue Numbering", "Reiniciar/continuar numeração"),+ ("Convert Bullets and Numbering to Text", "Converter marcadores e numeração em texto"),("Hyphenation…", "Hifenização…"),("Hyphenation Settings", "Configurações de hifenização"),("hyphens", "hifens"),diff --git a/crates/ui-egui/src/i18n/ru.rs b/crates/ui-egui/src/i18n/ru.rsindex 854fd20a2..412faea7e 100644--- a/crates/ui-egui/src/i18n/ru.rs+++ b/crates/ui-egui/src/i18n/ru.rs@@ -33,6 +33,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Вырезать"),("Copy", "Копировать"),("Paste", "Вставить"),+ ("Restart Numbering", "Начать нумерацию заново"),+ ("Continue Numbering", "Продолжить нумерацию"),+ ("Keep Options…", "Параметры удержания…"),+ ("Space Between Paragraphs Using Same Style", "Интервал между абзацами одного стиля"),+ ("Ignore", "Игнорировать"),+ ("Do Not Align to Baseline Grid", "Не выравнивать по базовой сетке"),+ ("Only Align First Line to Grid", "Выравнивать по сетке только первую строку"),+ ("Balance Ragged Lines", "Сбалансировать рваные строки"),+ ("Drop Caps and Nested Styles…", "Буквицы и вложенные стили…"),+ ("GREP Styles…", "Стили GREP…"),+ ("Restart/Continue Numbering", "Начать заново/продолжить нумерацию"),+ ("Convert Bullets and Numbering to Text", "Преобразовать маркеры и нумерацию в текст"),("Hyphenation…", "Расстановка переносов…"),("Hyphenation Settings", "Параметры расстановки переносов"),("hyphens", "дефисов"),diff --git a/crates/ui-egui/src/i18n/uk.rs b/crates/ui-egui/src/i18n/uk.rsindex 8cdf821d3..62c594fd1 100644--- a/crates/ui-egui/src/i18n/uk.rs+++ b/crates/ui-egui/src/i18n/uk.rs@@ -29,6 +29,18 @@ pub(super) const TABLE: &[(&str, &str)] = &[("Cut", "Вирізати"),("Copy", "Копіювати"),("Paste", "Вставити"),+ ("Restart Numbering", "Почати нумерацію знову"),+ ("Continue Numbering", "Продовжити нумерацію"),+ ("Keep Options…", "Параметри утримання…"),+ ("Space Between Paragraphs Using Same Style", "Інтервал між абзацами одного стилю"),+ ("Ignore", "Ігнорувати"),+ ("Do Not Align to Baseline Grid", "Не вирівнювати за базовою сіткою"),+ ("Only Align First Line to Grid", "Вирівнювати за сіткою лише перший рядок"),+ ("Balance Ragged Lines", "Збалансувати нерівні рядки"),+ ("Drop Caps and Nested Styles…", "Буквиці та вкладені стилі…"),+ ("GREP Styles…", "Стилі GREP…"),+ ("Restart/Continue Numbering", "Почати знову/продовжити нумерацію"),+ ("Convert Bullets and Numbering to Text", "Перетворити маркери й нумерацію на текст"),("Hyphenation…", "Перенесення…"),("Hyphenation Settings", "Параметри перенесення"),("hyphens", "дефісів"),diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rsindex f33e40184..72c37fc83 100644--- a/crates/ui-egui/src/icons.rs+++ b/crates/ui-egui/src/icons.rs@@ -798,6 +798,12 @@ pub fn paint(p: &Painter, r: Rect, name: &str, c: Color32) {pen.line(&[(3.0, v), (5.0, v)]);}}+ // Do Not Align to Baseline Grid: ragged lines of text, free of any grid.+ "grid-none" => {+ for (y, x1) in [(5.0, 17.0), (8.5, 12.0), (12.0, 17.0), (15.5, 14.0)] {+ pen.line(&[(3.0, y), (x1, y)]);+ }+ }"grid-baseline" => {pen.rect(3.0, 3.0, 17.0, 17.0);for y in [6.5, 10.0, 13.5] {@@ -998,6 +1004,15 @@ pub fn paint(p: &Painter, r: Rect, name: &str, c: Color32) {pen.line(&[(2.5, a + 1.5), (4.0, a), (5.5, a + 1.5)]);pen.line(&[(2.5, z - 1.5), (4.0, z), (5.5, z - 1.5)]);}+ // Space Between Paragraphs Using Same Style: two paragraphs and the space between them.+ "space-same" => {+ for y in [2.0, 5.0, 15.0, 18.0] {+ pen.line(&[(8.0, y), (18.0, y)]);+ }+ pen.line(&[(4.0, 6.5), (4.0, 13.5)]);+ pen.line(&[(2.5, 8.0), (4.0, 6.5), (5.5, 8.0)]);+ pen.line(&[(2.5, 12.0), (4.0, 13.5), (5.5, 12.0)]);+ }"drop-lines" | "drop-chars" => {pen.text(5.5, 8.0, "A", 14.0);if name == "drop-chars" {diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 96233c418..0b2f0c828 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -108,6 +108,14 @@ pub const UI_COMMANDS: &[(&str, &str, Option<&str>, &str)] = &["{tab?: border|shading} — border and shading of the selected paragraphs (type.para)",),("app.spanColumnsDialog", "Span Columns…", None, "{} — span or split columns of the selected paragraphs (type.para)"),+ ("app.keepOptionsDialog", "Keep Options…", None, "{} — Keep with Next and Keep Lines Together of the selected paragraphs (type.para)"),+ (+ "app.nestedStylesDialog",+ "Drop Caps and Nested Styles…",+ None,+ "{} — drop cap, nested styles and nested line styles of the selected paragraphs (type.para)",+ ),+ ("app.grepStylesDialog", "GREP Styles…", None, "{} — GREP styles of the selected paragraphs (type.para)"),("app.bulletsNumberingDialog", "Bullets and Numbering…", None, "{} — bullets or numbers of the selected paragraphs (type.para)"),("app.hyphenationDialog",@@ -1283,11 +1291,19 @@ fn run_ui_inner(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Valueapp.ui.dialog = Some(crate::dialogs::Dialog::new("paragraphRules", json!({"rule": rule, "current": current})));Ok(Value::Null)}- "app.paragraphBordersDialog" | "app.spanColumnsDialog" | "app.bulletsNumberingDialog" => {+ "app.paragraphBordersDialog"+ | "app.spanColumnsDialog"+ | "app.bulletsNumberingDialog"+ | "app.keepOptionsDialog"+ | "app.nestedStylesDialog"+ | "app.grepStylesDialog" => {let Some(a) = crate::panels::text_attrs(app) else { return Some(Err("select text or a text frame".into())) };let section = match id {"app.spanColumnsDialog" => "span","app.bulletsNumberingDialog" => "bullets",+ "app.keepOptionsDialog" => "keep",+ "app.nestedStylesDialog" => "nested",+ "app.grepStylesDialog" => "grep",_ if p.get("tab").and_then(Value::as_str) == Some("shading") => "shading",_ => "border",};diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rsindex 469b23251..2de8d370f 100644--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@ -1356,6 +1356,12 @@ fn character_section(app: &mut DesignApp, ui: &mut Ui) {/// A percentage or other number field in one half of a two-field row, with its icon.#[allow(clippy::too_many_arguments)]fn half_field(ui: &mut Ui, b: Rect, right: bool, y: f32, half: f32, icon: &str, tip: &str, field: NumField) -> Option<f64> {+ half_field_or_clear(ui, b, right, y, half, icon, tip, field).flatten()+}++/// [`half_field`] for a value that may be unset: emptying the field commits `Some(None)`.+#[allow(clippy::too_many_arguments)]+fn half_field_or_clear(ui: &mut Ui, b: Rect, right: bool, y: f32, half: f32, icon: &str, tip: &str, field: NumField) -> Option<Option<f64>> {let t = Tokens::get(ui.ctx());let x = if right { half + 10.0 } else { 0.0 };let ir = sub(b, x, y + 1.0, 19.0, 19.0);@@ -1364,7 +1370,7 @@ fn half_field(ui: &mut Ui, b: Rect, right: bool, y: f32, half: f32, icon: &str,resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Label, true, tip));let label = resp.id;resp.on_hover_text(tip);- place(ui, sub(b, x + 24.0, y, half - 24.0, FIELD_H), |ui| field.width(half - 24.0).labelled_by(label).show(ui))+ place(ui, sub(b, x + 24.0, y, half - 24.0, FIELD_H), |ui| field.width(half - 24.0).labelled_by(label).show_or_clear(ui))}/// Properties › Character after •••: vertical and horizontal scale, baseline shift and skew,@@ -1907,163 +1913,234 @@ pub fn show_typography_panel(app: &mut DesignApp) {let _ = app.run("window.panel", json!({"panel": "typography"}));}+/// The paragraph alignments in InDesign's order, with their icons.+const PARA_ALIGNS: [(Align, &str); 9] = [+ (Align::Left, "palign-left"),+ (Align::Center, "palign-center"),+ (Align::Right, "palign-right"),+ (Align::LeftJustified, "palign-justify-left"),+ (Align::CenterJustified, "palign-justify-center"),+ (Align::RightJustified, "palign-justify-right"),+ (Align::FullyJustified, "palign-justify-all"),+ (Align::TowardsSpine, "palign-spine-towards"),+ (Align::AwayFromSpine, "palign-spine-away"),+];++/// Space Between Paragraphs Using Same Style's presets (pt), after Ignore.+const SAME_STYLE_SPACING: &[f64] = &[0.0, 3.0, 6.0, 9.0, 12.0, 18.0, 24.0];++/// The Paragraph panel, laid out as InDesign's: the alignment buttons in groups of 3, 4 and 2;+/// indents, spacing and drop cap fields by their icons in two columns; Shading and Border with+/// their colours; Hyphenate and the baseline grid buttons. The rest (composer, grid and ragged+/// lines options, the paragraph dialogs) is in the panel menu.pub fn paragraph_panel(app: &mut DesignApp, ui: &mut egui::Ui) {let Some(a) = text_attrs(app) else {crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Select text or a text frame."));return;};+ let lang_ui = app.ui.language.clone();+ let tr = |s: &str| crate::i18n::tr(&lang_ui, s).to_string();let u = units(app);let p = a["para"].clone();- ui.horizontal(|ui| {- crate::rtl::label(ui, egui::RichText::new(crate::i18n::tr(&app.ui.language, "Paragraph")).strong());- ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {- crate::menus::menu_button(ui, "☰", |ui| {- // In the order of InDesign's Paragraph panel menu.- for (label, id) in [- ("Justification…", "app.justificationDialog"),- ("Span Columns…", "app.spanColumnsDialog"),- ("Hyphenation…", "app.hyphenationDialog"),- ("Paragraph Rules…", "app.paragraphRulesDialog"),- ("Paragraph Borders and Shading…", "app.paragraphBordersDialog"),- ("Bullets and Numbering…", "app.bulletsNumberingDialog"),- ] {- if ui.button(crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, label))).clicked() {- let _ = app.run(id, json!({}));- ui.close();- }- }- });- });- });+ let fw = full_width(ui);+ let half = (fw - 10.0) / 2.0;+ // Alignment, and the panel menu at the right.let cur: Align = serde_json::from_value(p["align"].clone()).unwrap_or_default();- ui.horizontal(|ui| {- for (al, icon) in [- (Align::Left, "align-left"),- (Align::Center, "align-center"),- (Align::Right, "align-right"),- (Align::LeftJustified, "align-justify"),- (Align::FullyJustified, "align-justify-all"),- ] {- if icons::button(ui, icon, 24.0, cur == al, al.label()).clicked() {- let _ = app.run("type.para", json!({"attrs": {"align": al}}));- }+ const GAP: f32 = 8.0;+ let pitch = ((fw - 24.0 - 2.0 * GAP) / 9.0).clamp(16.0, 24.0);+ let b = block(ui, 21.0);+ let mut x = 0.0;+ for (i, (al, icon)) in PARA_ALIGNS.into_iter().enumerate() {+ if i == 3 || i == 7 {+ x += GAP;+ }+ if place(ui, sub(b, x, 0.0, pitch, 21.0), |ui| widgets::icon_toggle_sized(ui, icon, cur == al, &tr(al.label()), vec2(pitch, 21.0))).clicked()+ {+ let _ = app.run("type.para", json!({"attrs": {"align": al}}));}- });- // Paragraph Direction (World-Ready): switching also mirrors left/right alignment.- let rtl = p["direction"] == "rightToLeft";- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Direction"));- for (on, label, dir) in [(!rtl, "Left to Right", "leftToRight"), (rtl, "Right to Left", "rightToLeft")] {- if ui.selectable_label(on, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, label))).clicked() && !on {- let align = match cur {- Align::Left => Align::Right,- Align::Right => Align::Left,- a => a,- };- let _ = app.run("type.para", json!({"attrs": {"direction": dir, "align": align}}));+ x += pitch;+ }+ place(ui, sub(b, fw - 20.0, 0.0, 20.0, 21.0), |ui| crate::menus::menu_button(ui, "☰", |ui| paragraph_panel_menu(app, ui, &p)));+ ui.add_space(6.0);+ // Indents, spacing and drop cap, two to a row as in InDesign.+ let row = FIELD_H + 5.0;+ let b = block(ui, 5.0 * row - 5.0);+ let rows = [+ (("indent-left", "Left Indent", "leftIndent"), ("indent-right", "Right Indent", "rightIndent")),+ (("indent-first", "First Line Left Indent", "firstLineIndent"), ("indent-last", "Last Line Right Indent", "lastLineIndent")),+ (("space-before", "Space Before", "spaceBefore"), ("space-after", "Space After", "spaceAfter")),+ ];+ for (i, (l, r)) in rows.into_iter().enumerate() {+ for (right, (icon, tip, key)) in [(false, l), (true, r)] {+ // The first and last line indents may be negative (a hanging line), as InDesign's.+ let min = if matches!(key, "firstLineIndent" | "lastLineIndent") { -10_000.0 } else { 0.0 };+ let field = NumField::measure(key, p[key].as_f64(), u).spinner().range(min, 10_000.0);+ if let Some(v) = half_field(ui, b, right, i as f32 * row, half, icon, &tr(tip), field) {+ let _ = app.run("type.para", json!({"attrs": {key: v}}));}}- });- egui::Grid::new("paragrid").num_columns(4).spacing(vec2(6.0, 4.0)).show(ui, |ui| {- for (row, ((la, ka), (lb, kb))) in [- (("Left", "leftIndent"), ("Right", "rightIndent")),- (("First", "firstLineIndent"), ("Last", "lastLineIndent")),- (("Before", "spaceBefore"), ("After", "spaceAfter")),- ]- .into_iter()- .enumerate()+ }+ // Space Between Paragraphs Using Same Style: Ignore (unset) or a space that replaces the+ // space after and before between paragraphs of the same style.+ let ignore = tr("Ignore");+ let field = NumField::measure("sameParaStyleSpacing", p["sameParaStyleSpacing"].as_f64(), u)+ .spinner()+ .presets(SAME_STYLE_SPACING)+ .empty_text(&ignore)+ .range(0.0, 10_000.0);+ if let Some(v) = half_field_or_clear(ui, b, false, 3.0 * row, half, "space-same", &tr("Space Between Paragraphs Using Same Style"), field) {+ let _ = app.run("type.para", json!({"attrs": {"sameParaStyleSpacing": v}}));+ }+ for (right, icon, tip, key, max) in [+ (false, "drop-lines", "Drop Cap Number of Lines", "dropCapLines", designcraft_compose::MAX_DROP_CAP_LINES),+ (true, "drop-chars", "Drop Cap One or More Characters", "dropCapChars", designcraft_compose::MAX_DROP_CAP_CHARS),+ ] {+ let field = NumField::number(key, p[key].as_f64(), "", 0).spinner().range(0.0, max as f64);+ if let Some(v) = half_field(ui, b, right, 4.0 * row, half, icon, &tr(tip), field) {+ let _ = app.run("type.para", json!({"attrs": {key: (v.max(0.0) as u64).min(max as u64)}}));+ }+ }+ // Shading and Border: on or off at the left; at the right the Paragraph Borders and Shading+ // dialog on its tab and the colour.+ ui.add_space(10.0);+ let doc = app.session.active().map(|d| d.doc.clone());+ let b = block(ui, 2.0 * row - 5.0);+ for (i, (on_key, color_key, label, icon, tab, name)) in [+ ("shadingOn", "shadingColor", "Shading", "para-shading", "shading", "Paragraph Shading"),+ ("borderOn", "borderColor", "Border", "para-border", "border", "Paragraph Border"),+ ]+ .into_iter()+ .enumerate()+ {+ let y = i as f32 * row;+ let mut on = p[on_key].as_bool().unwrap_or(false);+ if place(ui, sub(b, 0.0, y, half, FIELD_H), |ui| widgets::checkbox(ui, &mut on, &tr(label))).changed() {+ let _ = app.run("type.para", json!({"attrs": {on_key: on}}));+ }+ if place(ui, sub(b, half + 10.0, y, 23.0, FIELD_H), |ui| widgets::icon_toggle(ui, icon, false, &tr("Paragraph Borders and Shading…")))+ .clicked(){- caption(ui, crate::i18n::tr(&app.ui.language, la));- if let Some(v) = measure(ui, &format!("pp{row}a"), p[ka].as_f64(), u, 64.0) {- let _ = app.run("type.para", json!({"attrs": {ka: v}}));- }- caption(ui, crate::i18n::tr(&app.ui.language, lb));- if let Some(v) = measure(ui, &format!("pp{row}b"), p[kb].as_f64(), u, 64.0) {- let _ = app.run("type.para", json!({"attrs": {kb: v}}));- }- ui.end_row();+ let _ = app.run("app.paragraphBordersDialog", json!({"tab": tab}));}- // Drop cap: number of lines and characters.- for (label, key, max, id) in [- ("Drop Lines", "dropCapLines", designcraft_compose::MAX_DROP_CAP_LINES, "ppdl"),- ("Drop Chars", "dropCapChars", designcraft_compose::MAX_DROP_CAP_CHARS, "ppdc"),- ] {- caption(ui, crate::i18n::tr(&app.ui.language, label));- if let Some(v) = number(ui, id, p[key].as_f64(), "", 64.0, 0) {- let _ = app.run("type.para", json!({"attrs": {key: (v.max(0.0) as u64).min(max as u64)}}));+ if let Some(doc) = &doc {+ let color = p[color_key].as_str().unwrap_or("[Black]").to_string();+ let w = half - 24.0;+ if let Some(sw) = place(ui, sub(b, half + 34.0, y, w, FIELD_H), |ui| crate::chrome::swatch_field(ui, doc, &color, w, &tr(name))) {+ let _ = app.run("type.para", json!({"attrs": {color_key: sw}}));}}- ui.end_row();- });- ui.horizontal(|ui| {- let mut h = p["hyphenate"].as_bool().unwrap_or(true);- if ui.checkbox(&mut h, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Hyphenate"))).changed() {- let _ = app.run("type.para", json!({"attrs": {"hyphenate": h}}));- }- let mut grid = p["gridAlign"].as_str() == Some("allLines");- if ui.checkbox(&mut grid, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Align to baseline grid"))).changed() {- let _ = app.run("type.para", json!({"attrs": {"gridAlign": if grid { "allLines" } else { "none" }}}));+ }+ // Hyphenate, and Do Not Align / Align to Baseline Grid.+ ui.add_space(10.0);+ let b = block(ui, FIELD_H);+ let mut h = p["hyphenate"].as_bool().unwrap_or(true);+ if place(ui, sub(b, 0.0, 0.0, half, FIELD_H), |ui| widgets::checkbox(ui, &mut h, &tr("Hyphenate"))).changed() {+ let _ = app.run("type.para", json!({"attrs": {"hyphenate": h}}));+ }+ let grid = matches!(p["gridAlign"].as_str(), Some("allLines" | "firstLineOnly"));+ for (i, (icon, tip, on, v)) in+ [("grid-none", "Do Not Align to Baseline Grid", !grid, "none"), ("grid-baseline", "Align to Baseline Grid", grid, "allLines")]+ .into_iter()+ .enumerate()+ {+ if place(ui, sub(b, fw - 48.0 + i as f32 * 25.0, 0.0, 23.0, FIELD_H), |ui| widgets::icon_toggle(ui, icon, on, &tr(tip))).clicked() && !on {+ let _ = app.run("type.para", json!({"attrs": {"gridAlign": v}}));}- });- let mut optical = p["opticalMargin"].as_bool().unwrap_or(false);- if ui.checkbox(&mut optical, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Optical Margin Alignment"))).changed() {- let _ = app.run("type.para", json!({"attrs": {"opticalMargin": optical}}));}- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Composer"));- let (single, [paragraph, single_line]) = composer_choice(p["composer"].as_str());- if ui.selectable_label(!single, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Paragraph"))).clicked() {- let _ = app.run("type.para", json!({"attrs": {"composer": paragraph}}));+ ui.add_space(4.0);+}++/// The Paragraph panel menu, in the order of InDesign's.+fn paragraph_panel_menu(app: &mut DesignApp, ui: &mut Ui, p: &Value) {+ let lang = app.ui.language.clone();+ let item = |ui: &mut Ui, label: &str, check: Option<bool>, enabled: bool| -> bool {+ let label = crate::i18n::tr(&lang, label);+ let text = match check {+ Some(true) => format!("✓ {label}"),+ Some(false) => format!(" {label}"),+ None => label.to_string(),+ };+ let clicked = ui.add_enabled(enabled, egui::Button::new(crate::rtl::widget(ui, text))).clicked();+ if clicked {+ ui.close();}- if ui.selectable_label(single, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, "Single-line"))).clicked() {- let _ = app.run("type.para", json!({"attrs": {"composer": single_line}}));+ clicked+ };+ let mut attrs = None;+ let mut command = None;+ let (single, [paragraph, single_line]) = composer_choice(p["composer"].as_str());+ if item(ui, "Paragraph Composer", Some(!single), true) {+ attrs = Some(json!({"composer": paragraph}));+ }+ if item(ui, "Single-line Composer", Some(single), true) {+ attrs = Some(json!({"composer": single_line}));+ }+ ui.separator();+ let grid = p["gridAlign"].as_str().unwrap_or("none");+ if item(ui, "Only Align First Line to Grid", Some(grid == "firstLineOnly"), grid != "none") {+ attrs = Some(json!({"gridAlign": if grid == "firstLineOnly" { "allLines" } else { "firstLineOnly" }}));+ }+ let balance = p["balanceRagged"].as_bool().unwrap_or(false);+ if item(ui, "Balance Ragged Lines", Some(balance), true) {+ attrs = Some(json!({"balanceRagged": !balance}));+ }+ let optical = p["opticalMargin"].as_bool().unwrap_or(false);+ if item(ui, "Optical Margin Alignment", Some(optical), true) {+ attrs = Some(json!({"opticalMargin": !optical}));+ }+ ui.separator();+ for (label, id) in [+ ("Justification…", "app.justificationDialog"),+ ("Keep Options…", "app.keepOptionsDialog"),+ ("Span Columns…", "app.spanColumnsDialog"),+ ("Hyphenation…", "app.hyphenationDialog"),+ ("Drop Caps and Nested Styles…", "app.nestedStylesDialog"),+ ("GREP Styles…", "app.grepStylesDialog"),+ ("Paragraph Rules…", "app.paragraphRulesDialog"),+ ("Paragraph Borders and Shading…", "app.paragraphBordersDialog"),+ ] {+ if item(ui, label, None, true) {+ command = Some(id);}- });- // Paragraph Border and Shading.- let swatches: Vec<String> =- app.session.active().map(|d| d.doc.swatches.iter().filter(|w| !w.hidden).map(|w| w.name.clone()).collect()).unwrap_or_default();- for (on_key, color_key, label) in [("shadingOn", "shadingColor", "Shading"), ("borderOn", "borderColor", "Border")] {- ui.horizontal(|ui| {- let mut on = p[on_key].as_bool().unwrap_or(false);- if ui.checkbox(&mut on, crate::rtl::widget(ui, crate::i18n::tr(&app.ui.language, label))).changed() {- let _ = app.run("type.para", json!({ on_key: on }));- }- if on {- let cur = p[color_key].as_str().unwrap_or("[Black]").to_string();- egui::ComboBox::from_id_salt(("pbs", label)).selected_text(&cur).width(110.0).show_ui(ui, |ui| {- for w in &swatches {- if ui.selectable_label(*w == cur, w).clicked() {- let _ = app.run("type.para", json!({ color_key: w }));- }- }- });- if label == "Shading" {- if let Some(v) = number(ui, "pshtint", p["shadingTint"].as_f64().map(|t| t * 100.0), "%", 46.0, 0) {- let _ = app.run("type.para", json!({"shadingTint": (v / 100.0).clamp(0.0, 1.0)}));- }- } else if let Some(v) = number(ui, "pbw", p["borderWeights"][0].as_f64(), " pt", 50.0, 2) {- let w = [v.max(0.0); 4];- let _ = app.run("type.para", json!({ "borderWeights": w }));- }- }- });}- if p["shadingOn"].as_bool().unwrap_or(false) || p["borderOn"].as_bool().unwrap_or(false) {- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Offsets"));- let o = p["borderOffsets"][0].as_f64().or(p["shadingOffsets"][0].as_f64());- if let Some(v) = number(ui, "pbo", o, " pt", 50.0, 2) {- let o = [v; 4];- let _ = app.run("type.para", json!({ "borderOffsets": o, "shadingOffsets": o }));- }- });+ ui.separator();+ if item(ui, "Bullets and Numbering…", None, true) {+ command = Some("app.bulletsNumberingDialog");+ }+ // Restart Numbering at 1, or Continue Numbering from the paragraph before, for a numbered list.+ let numbered = p["listType"].as_str() == Some("numbers");+ let restarts = p["startAt"].is_u64();+ let label = match (numbered, restarts) {+ (false, _) => "Restart/Continue Numbering",+ (true, false) => "Restart Numbering",+ (true, true) => "Continue Numbering",+ };+ if item(ui, label, None, numbered) {+ attrs = Some(json!({"startAt": if restarts { Value::Null } else { json!(1) }}));+ }+ item(ui, "Convert Bullets and Numbering to Text", None, false);+ if item(ui, "Define Lists…", None, true) {+ command = Some("list.define");+ }+ // Paragraph Direction (World-Ready): switching also mirrors left and right alignment.+ ui.separator();+ let rtl = p["direction"] == "rightToLeft";+ for (on, label, dir) in [(!rtl, "Left to Right", "leftToRight"), (rtl, "Right to Left", "rightToLeft")] {+ if item(ui, label, Some(on), true) && !on {+ let align = match serde_json::from_value(p["align"].clone()).unwrap_or_default() {+ Align::Left => Align::Right,+ Align::Right => Align::Left,+ a => a,+ };+ attrs = Some(json!({"direction": dir, "align": align}));+ }+ }+ if let Some(attrs) = attrs {+ let _ = app.run("type.para", json!({"attrs": attrs}));+ }+ if let Some(id) = command {+ crate::menus::activate(app, id, &json!({}));}- let ps = a["paragraphStyle"].as_str().unwrap_or("").to_string();- let ov = a["paraOverrides"].as_u64().unwrap_or(0) + a["charOverrides"].as_u64().unwrap_or(0);- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Style"));- super::para_style_picker(app, ui, &ps, ov > 0, 190.0);- });}/// Stroke panel: weight, cap, miter limit, join, alignment, type, arrowheads, gap colour.@@ -3310,6 +3387,84 @@ mod tests {assert!(h.query_by_label("Small Caps").is_none());}+ #[test]+ fn paragraph_panel_is_laid_out_as_indesigns_with_its_panel_menu() {+ let mut h = panel_harness(text_app(), paragraph_panel);+ h.run_steps(3);+ for l in [+ "Left Indent",+ "Right Indent",+ "First Line Left Indent",+ "Last Line Right Indent",+ "Space Before",+ "Space After",+ "Space Between Paragraphs Using Same Style",+ "Drop Cap Number of Lines",+ "Drop Cap One or More Characters",+ "Paragraph Shading",+ "Paragraph Border",+ "Hyphenate",+ "Do Not Align to Baseline Grid",+ ] {+ let _ = h.get_by_label(l);+ }+ let para = |h: &mut Harness<'static, DesignApp>| text_attrs(h.state_mut()).unwrap()["para"].clone();+ // Space Between Paragraphs Using Same Style starts at Ignore; a value is set, and emptying+ // the field ignores it again.+ assert!(para(&mut h)["sameParaStyleSpacing"].is_null());+ let field = h.get_all_by_role(egui::accesskit::Role::TextInput).nth(6).unwrap();+ field.focus();+ field.type_text("6 pt");+ h.run_steps(1);+ h.key_press(egui::Key::Enter);+ h.run_steps(3);+ assert_eq!(para(&mut h)["sameParaStyleSpacing"], 6.0);+ h.get_all_by_role(egui::accesskit::Role::TextInput).nth(6).unwrap().focus();+ h.run_steps(1);+ for _ in 0..8 {+ h.key_press(egui::Key::Backspace);+ }+ h.key_press(egui::Key::Enter);+ h.run_steps(3);+ assert!(para(&mut h)["sameParaStyleSpacing"].is_null(), "Ignore");+ // Shading on, then the grid buttons and Only Align First Line to Grid from the menu.+ h.get_by_label("Shading").click();+ h.run_steps(3);+ assert_eq!(para(&mut h)["shadingOn"], true);+ h.get_by_label("Align to Baseline Grid").click();+ h.run_steps(3);+ assert_eq!(para(&mut h)["gridAlign"], "allLines");+ h.get_by_label("☰").click();+ h.run_steps(3);+ for l in [+ " Balance Ragged Lines",+ "Keep Options…",+ "Drop Caps and Nested Styles…",+ "GREP Styles…",+ "Define Lists…",+ "Restart/Continue Numbering",+ ] {+ let _ = h.get_by_label(l);+ }+ h.get_by_label(" Only Align First Line to Grid").click();+ h.run_steps(3);+ assert_eq!(para(&mut h)["gridAlign"], "firstLineOnly");+ h.get_by_label("Do Not Align to Baseline Grid").click();+ h.run_steps(3);+ assert_eq!(para(&mut h)["gridAlign"], "none");+ // Keep Options… opens the selected paragraphs' Keep Options, and OK applies them.+ h.get_by_label("☰").click();+ h.run_steps(3);+ h.get_by_label("Keep Options…").click();+ h.run_steps(3);+ let app = h.state_mut();+ let d = app.ui.dialog.as_mut().expect("Keep Options");+ assert_eq!((d.id.as_str(), d.s("section").as_str()), ("paragraphLocal", "keep"));+ d.fields.insert("p.keepWithNext".into(), json!(2));+ crate::dialogs::confirm(app).unwrap();+ assert_eq!(para(&mut h)["keepWithNext"], 2);+ }+fn kerning(app: &mut DesignApp) -> Value {text_attrs(app).unwrap()["chars"]["kerning"].clone()}diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rsindex d8eb6c51e..e820e21a8 100644--- a/crates/ui-egui/src/widgets.rs+++ b/crates/ui-egui/src/widgets.rs@@ -82,6 +82,8 @@ pub struct NumField<'a> {parens: bool,/// The widget naming the field (an icon or caption beside it), for accessibility.label: Option<egui::Id>,+ /// What an unset value shows (InDesign's "Ignore"), and the first of the presets.+ empty: Option<&'a str>,}impl<'a> NumField<'a> {@@ -104,6 +106,7 @@ impl<'a> NumField<'a> {enabled: true,parens: false,label: None,+ empty: None,}}/// Total width (spinner and preset segments included).@@ -151,6 +154,13 @@ impl<'a> NumField<'a> {self}+ /// An unset value shows `text` (dimmed), and the preset menu offers it first: picking it, or+ /// emptying the field, commits `Some(None)` from [`NumField::show_or_clear`].+ pub fn empty_text(mut self, text: &'a str) -> Self {+ self.empty = Some(text);+ self+ }+/// Draw the field; returns the new value when the user commits an edit (Enter, focus loss,/// a spinner click, ↑/↓ while focused (Shift = ×10) or a preset).pub fn show(self, ui: &mut Ui) -> Option<f64> {@@ -214,13 +224,16 @@ impl<'a> NumField<'a> {// Value.ui.painter().rect_filled(text_rect, 0.0, bg);let mut buf: String = ui.data(|d| d.get_temp::<String>(key)).unwrap_or_else(|| self.value.map(|v| self.fmt(v)).unwrap_or_default());- let te = egui::TextEdit::singleline(&mut buf)+ let mut te = egui::TextEdit::singleline(&mut buf).id(focused_id).frame(egui::Frame::NONE).font(label_font()).text_color(fg).margin(egui::Margin::ZERO).vertical_align(egui::Align::Center);+ if let Some(empty) = self.empty {+ te = te.hint_text(egui::RichText::new(empty).font(label_font()).color(t.text_dim));+ }// The field already allocated its slot. A scoped allocation here would consume another// grid cell and enlarge toolbar rows; the value editor must stay inside that same slot.let value_rect = Rect::from_min_max(text_rect.min + vec2(5.0, 1.0), text_rect.max - vec2(1.0, 1.0));@@ -283,6 +296,12 @@ impl<'a> NumField<'a> {if let Some(resp) = preset_resp {egui::Popup::menu(&resp).show(|ui| {ui.set_min_width(self.width);+ if let Some(empty) = self.empty+ && ui.selectable_label(self.value.is_none(), empty).clicked()+ {+ cleared = self.value.is_some();+ ui.close();+ }for v in self.presets {if ui.selectable_label(self.value.is_some_and(|c| (c - v).abs() < 1e-9), self.kind.format(*v)).clicked() {out = Some(*v);diff --git a/docs/target-app-parity.md b/docs/target-app-parity.mdindex 904484179..c3a5cbbaf 100644--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@ -375,7 +375,7 @@ It is evidence of breadth: each item exists. It is not a claim of InDesign-level- Split Window / New Window (`window.split`, `window.newWindow`, Window ▸ Arrange): two side-by-side views of the document with their own zoom, scroll and render cache. New Window puts the second view in its own OS window (an egui viewport; a floating window on the web).- Transparency flattener (`file.exportPdf {flatten: high|medium|low|ppi}`, Edit ▸ Transparency Flattener Presets): each object involving transparency becomes an opaque image of its area over what's beneath it, so everything else stays vector (spreads with transparent parent items are rasterised whole).- Video and sound (place .mp4/.mov/.webm/.mp3/.wav…, `media.options/get`, Media panel): media frames show a poster or placeholder on screen, in print and in PDF, and export as HTML5 `<video>`/`<audio>` in EPUB. Interactive PDF export (`file.exportPdf {media: true}`, File ▸ Export PDF (Interactive)) embeds each file and plays it in a Screen annotation through a rendition action (controls, loop, play on page load). No in-app playback.-- Right-to-left text (World-Ready basics): right-to-left runs are shaped right to left, lines are reordered by the Unicode Bidirectional Algorithm (matched against the reference implementation), Paragraph Direction (`type.para {direction}`, Paragraph panel, IDML ParagraphDirection, EPUB `dir`). Digits (`digits`: Default, Arabic, Hindi, Farsi, Native by language; Character panel and Character Style Options; IDML DigitsType) draw 0–9 in another script. Kashidas (`kashidas` paragraph attribute, on by default; IDML Kashidas): justified Arabic lines stretch at one join per word (after seen/sad when possible, never inside lam–alef) with a drawn tatweel before word spaces widen. Carets follow the drawing: the caret before a right-to-left glyph sits at its right edge, arrow keys move as drawn (by words in the line's direction), clicks find the nearest drawn caret position and selections highlight the selected glyphs. Binding: Right to Left (Document Setup, `layout.documentSetup {binding}`, IDML PageBinding) makes page 1 a left page and lays spreads out right to left.+- Right-to-left text (World-Ready basics): right-to-left runs are shaped right to left, lines are reordered by the Unicode Bidirectional Algorithm (matched against the reference implementation), Paragraph Direction (`type.para {direction}`, Paragraph panel menu, IDML ParagraphDirection, EPUB `dir`). Digits (`digits`: Default, Arabic, Hindi, Farsi, Native by language; Character panel and Character Style Options; IDML DigitsType) draw 0–9 in another script. Kashidas (`kashidas` paragraph attribute, on by default; IDML Kashidas): justified Arabic lines stretch at one join per word (after seen/sad when possible, never inside lam–alef) with a drawn tatweel before word spaces widen. Carets follow the drawing: the caret before a right-to-left glyph sits at its right edge, arrow keys move as drawn (by words in the line's direction), clicks find the nearest drawn caret position and selections highlight the selected glyphs. Binding: Right to Left (Document Setup, `layout.documentSetup {binding}`, IDML PageBinding) makes page 1 a left page and lays spreads out right to left.- Interface language (Preferences ▸ General ▸ Interface Language, `app.language`; each language listed by its own name): German, French, Spanish, Italian, Japanese, Simplified Chinese and Arabic menu titles, common menu items and panel names (our own translations). Common dialog, panel and tooltip labels are also localized, with English fallback for untranslated strings. Arabic translations cover every key in the shared interface translation table, including menu commands and utility labels. The Type menu's Story Direction, Horizontal/Vertical, Tate-Chu-Yoko, Ruby… and Kenten are translated too. Arabic labels use Unicode bidi run ordering and contextual shaping; welcome and new-document form layouts follow RTL direction independently of document binding. CJK and Arabic glyphs come from [craft-fonts](https://github.com/storytold/craft-fonts) when built with `CRAFT_FONTS_DIR` (all releases): BIZ UDPGothic and Noto Sans CJK SC for the UI (Chinese forms first in the Chinese interface), Noto Sans Arabic, and Mincho for Japanese documents (the web build embeds BIZ UDPGothic only); otherwise from system fonts. Ukrainian covers all 1,430 existing catalog keys, including publishing dialogs and built-in names, with persisted selection, grammatical count captions, English fallback and bundled Cyrillic UI glyph coverage. Polish covers 1,717 catalog keys with the same category-first count captions and English fallback.- Page transitions (`page.transition/transitions`, Page Transitions panel): twelve transition types with speed and direction per spread, written into exported PDFs as `/Trans` entries through an incremental update.- PDF/X-4 export (`file.exportPdf {standard: "x4"}`): an output intent with the working CMYK space's profile (by default craft-cms's Coated FOGRA39 profile, identifier FOGRA39; Generic CMYK and Device CMYK embed our Generic CMYK profile, lut16 tables generated from the parametric press model), GTS_PDFXVersion in Info and XMP, `pdf:Trapped` in XMP as in Info, `xmp:MetadataDate` and `xmpMM:VersionID` in XMP, RGB images without a profile tagged sRGB, no image interpolation (none in PDF/A either), and built-in PDF/X-4 checks reported as warnings. qpdf finds no errors in the result.