Skip to content

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

Merge upstream main 835edae6

aiongg8f1c60e4fc58
diff --cc ROADMAP.md
index 02bd401da,d33353caa..28b37ec39
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@@ -129,39 -129,11 +129,41 @@@ list) · [roadmap.md](docs/roadmap.md)
Newest first.
+- **2026-10-12** · Properties › Transform shows rotation, shear and X/Y scale, and Rotate 90° and Flip Horizontal/Vertical buttons, as InDesign's does. No readiness percentage change.
+- **2026-10-12** · Underlines and strikethroughs are drawn as one bar per stretch of text on screen, as in PDF export: a bar per letter left faint seams between the letters. No readiness percentage change.
- **2026-10-12** · Words in capitals hyphenate like capitalized words (FERRUM COM-MODI), as in InDesign; Hyphenate Capitalized Words off keeps them whole. No readiness percentage change.
+ - **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.
+ - **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.
- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.
-
+- **2026-10-11** · The View menu follows InDesign's: proofing first, then zoom, Rotate Spread, Screen Mode, Display Performance, rulers, Extras, Grids & Guides and Structure; the view items that sat at the end of the Type menu moved there. No readiness percentage change.
+- **2026-10-11** · Properties › Appearance's Fill and Stroke menus gain InDesign's Tint field and, for a text frame, Apply To: Frame / Text. No readiness percentage change.
+- **2026-10-11** · `story.replaceRange`, `story.setText`, notes, footnotes, endnotes, type on a path and table cells read `\r` and `\r\n` as paragraph returns, as `frame.create` and `text.insert` already did. No readiness percentage change.
+- **2026-10-11** · Corner Options keep curved sides curved and round every corner point, including where an arc meets a line (a Pathfinder quarter circle with rounded corners stayed a triangle). No readiness percentage change.
+- **2026-10-11:** Type › Justification… (Cmd+Alt+Shift+J, also in the Paragraph panel menu) sets word and letter spacing, glyph scaling and the composer on the selected paragraphs, sharing the Paragraph Style Options section (#531). No readiness percentage change.
+- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.
+- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.
+- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.
+- **2026-10-11** · Japanese captions now cover print ranges, imported style handling and table
+ row/column movement, including row-height distribution. Existing translation and RTL helpers
+ handle the display; command IDs, stored option values and user-defined style names are unchanged.
+- **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.
+- **2026-10-11** · Live corners: the yellow widget on a selected rectangle frame shows corner
+ diamonds; dragging one rounds the corners, Alt-click steps the corner shape (#186).
+- **2026-10-11** · Optical kerning (#181): pairs are spaced from their outlines (ink gap per band,
+ pulled towards the font's stem gap, bounded) instead of silently using the font's kern pairs.
+- **2026-10-11** · New Document laid out like InDesign's (#325): Recent, Saved, Print, Web and
+ Mobile preset tabs beside the preset's details; saved document presets live in the engine
+ (`file.savePreset`, `file.deletePreset`, `file.new {preset}`); `file.new` takes intent, units,
+ start page and per-edge bleed and slug.
+- **2026-10-11** · macOS: fonts that font services and managers activate (Adobe Fonts,
+ RightFont) are listed, read from the files CoreText has available (#261, #327).
+- **2026-10-11:** Document pages take their parent page's margins and columns (left or right parent page by side) and follow its changes unless they have their own; parent ruler guides draw and snap on the pages based on it. IDML import marks a page margin preference that differs from its parent as the page's own. No readiness percentage change.
+- **2026-10-11** · Document Setup laid out like InDesign's: Page Size, Margins (new: every
+ page's, `layout.documentSetup {margins}`), Bleed and Slug with links, Adjust Layout.
+- **2026-10-11** · IDML reads and writes a spread's view rotation (Rotate Spread) as the
+ rotation part of the spread transform (#484).
+- **2026-10-11** · The document grid is drawn (View ▸ Grids & Guides ▸ Show/Hide Document Grid,
+ ⌘'), on the lines Snap to Document Grid uses, behind or in front of page items (#530).
- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.
- **2026-10-10** · Version 0.6.0; releases add a Linux riscv64 tar.gz (cross-compiled, CLI
smoke-tested under QEMU).
diff --cc crates/engine/src/cmd/text.rs
index e4c5141ff,71d390d02..54ae8631f
--- a/crates/engine/src/cmd/text.rs
+++ b/crates/engine/src/cmd/text.rs
@@@ -989,314 -819,18 +989,326 @@@ fn warichu_cmd(s: &mut Session, p: &Val
format_chars(s, &Value::Object(body))
}
+// Kenten, shatai, auto tate-chu-yoko and grid settings: validated settings for the CJK commands.
+
+/// Longest font, style or swatch name taken from parameters, in characters.
+const NAME_MAX_CHARS: usize = 256;
+
+/// A number parameter: absent or `null` → `None`; anything but a finite number is an error.
+fn finite_param(p: &Value, key: &str, cmd: &str) -> Result<Option<f64>> {
+ match p.get(key) {
+ None | Some(Value::Null) => Ok(None),
+ Some(v) => v.as_f64().filter(|v| v.is_finite()).map(Some).ok_or_else(|| bad(cmd, format!("`{key}` must be a finite number"))),
+ }
+}
+
+/// A text parameter, cut to `max` characters: absent or `null` → `None`; not text is an error.
+fn text_param(p: &Value, key: &str, cmd: &str, max: usize) -> Result<Option<String>> {
+ match p.get(key) {
+ None | Some(Value::Null) => Ok(None),
+ Some(Value::String(t)) => Ok(Some(t.chars().take(max).collect())),
+ Some(_) => Err(bad(cmd, format!("`{key}` must be text"))),
+ }
+}
+
+/// A boolean parameter: absent or `null` → `None`; not a boolean is an error.
+fn bool_param(p: &Value, key: &str, cmd: &str) -> Result<Option<bool>> {
+ match p.get(key) {
+ None | Some(Value::Null) => Ok(None),
+ Some(v) => v.as_bool().map(Some).ok_or_else(|| bad(cmd, format!("`{key}` must be true or false"))),
+ }
+}
+
+/// An enumeration parameter checked against `T`, as its JSON value.
+fn enum_param<T: serde::de::DeserializeOwned + serde::Serialize>(p: &Value, key: &str, cmd: &str) -> Result<Option<Value>> {
+ match p.get(key) {
+ None | Some(Value::Null) => Ok(None),
+ Some(v) => {
+ let t: T = serde_json::from_value(v.clone()).map_err(|e| bad(cmd, format!("`{key}`: {e}")))?;
+ serde_json::to_value(t).map(Some).map_err(|e| bad(cmd, format!("`{key}`: {e}")))
+ }
+ }
+}
+
+/// A ruby enum parameter, checked against its type.
+fn ruby_enum<T: serde::de::DeserializeOwned>(p: &Value, key: &str) -> Result<Option<Value>> {
+ let Some(v) = p.get(key) else { return Ok(None) };
+ serde_json::from_value::<T>(v.clone()).map_err(|e| bad("type.ruby", format!("{key}: {e}")))?;
+ Ok(Some(v.clone()))
+}
+
+/// A ruby number parameter clamped to `lo..=hi`, then divided by `div` (100 for percentages);
+/// `null` gives `Value::Null` (automatic).
+fn ruby_num(p: &Value, key: &str, lo: f64, hi: f64, div: f64) -> Result<Option<Value>> {
+ match p.get(key) {
+ None => Ok(None),
+ Some(Value::Null) => Ok(Some(Value::Null)),
+ Some(v) => {
+ let x = v.as_f64().filter(|x| x.is_finite()).ok_or_else(|| bad("type.ruby", format!("{key}: expected a finite number")))?;
+ Ok(Some(json!(x.clamp(lo, hi) / div)))
+ }
+ }
+}
+
+/// Is `flag` on in the character format at the start of the first formatting target?
+fn char_flag_on(s: &Session, flag: impl Fn(&CharAttrs) -> Option<bool>) -> bool {
+ format_targets(s).first().is_some_and(|t| {
+ s.doc()
+ .ok()
+ .and_then(|d| d.doc.text_story(t.story, t.cell))
+ .is_some_and(|st| flag(&st.char_format_at(if t.range.is_empty() { t.range.start } else { t.range.start + 1 }).over) == Some(true))
+ })
+}
+
+fn kenten_cmd(s: &mut Session, p: &Value) -> Result<Value> {
+ use designcraft_doc::cjk_settings::{AdornmentOverprint, KENTEN_MARK_MAX_CHARS, KentenAlignment, KentenKind, KentenPosition};
+ const CMD: &str = "type.kenten";
+ let mut body = serde_json::Map::new();
+ let mut set = |k: &str, v: Value| {
+ body.insert(k.to_string(), v);
+ };
+ // Validate every setting first, so a bad one changes nothing.
+ if let Some(v) = enum_param::<KentenKind>(p, "kind", CMD)? {
+ // A preset stores its mark as the character too, as IDML import does, so a custom
+ // character left from before isn't drawn in its place.
+ if let Some(mark) = serde_json::from_value::<KentenKind>(v.clone()).ok().and_then(KentenKind::mark) {
+ set("kentenCharacter", json!(mark));
+ }
+ set("kentenKind", v);
+ }
+ if let Some(c) = text_param(p, "character", CMD, KENTEN_MARK_MAX_CHARS)? {
+ set("kentenCharacter", json!(c.chars().filter(|c| !c.is_control()).collect::<String>()));
+ }
+ for (key, attr) in [("font", "kentenFont"), ("fontStyle", "kentenFontStyle"), ("fill", "kentenFill"), ("stroke", "kentenStroke")] {
+ if let Some(t) = text_param(p, key, CMD, NAME_MAX_CHARS)? {
+ set(attr, json!(t));
+ }
+ }
+ if let Some(v) = finite_param(p, "size", CMD)? {
+ set("kentenSize", json!(v.clamp(0.1, 1296.0)));
+ }
+ if let Some(v) = finite_param(p, "distance", CMD)? {
+ set("kentenDistance", json!(v.clamp(-1296.0, 1296.0)));
+ }
+ for (key, attr) in [("xScale", "kentenXScale"), ("yScale", "kentenYScale")] {
+ if let Some(v) = finite_param(p, key, CMD)? {
+ set(attr, json!(v.clamp(1.0, 1000.0) / 100.0));
+ }
+ }
+ for (key, attr) in [("fillTint", "kentenFillTint"), ("strokeTint", "kentenStrokeTint")] {
+ if let Some(v) = finite_param(p, key, CMD)? {
+ set(attr, json!(v.clamp(0.0, 100.0) / 100.0));
+ }
+ }
+ if let Some(v) = finite_param(p, "strokeWeight", CMD)? {
+ set("kentenStrokeWeight", json!(v.clamp(0.0, 1000.0)));
+ }
+ if let Some(v) = enum_param::<KentenPosition>(p, "position", CMD)? {
+ set("kentenPosition", v);
+ }
+ if let Some(v) = enum_param::<KentenAlignment>(p, "alignment", CMD)? {
+ set("kentenAlignment", v);
+ }
+ for (key, attr) in [("overprintFill", "kentenOverprintFill"), ("overprintStroke", "kentenOverprintStroke")] {
+ if let Some(v) = enum_param::<AdornmentOverprint>(p, key, CMD)? {
+ set(attr, v);
+ }
+ }
+ // `null` returns a setting to the style's (size: half the text size by default).
+ for (key, attr) in
+ [("size", "kentenSize"), ("fillTint", "kentenFillTint"), ("strokeTint", "kentenStrokeTint"), ("strokeWeight", "kentenStrokeWeight")]
+ {
+ if p.get(key).is_some_and(Value::is_null) {
+ set(attr, Value::Null);
+ }
+ }
+ let on = match bool_param(p, "on", CMD)? {
+ Some(v) => v,
+ None if !body.is_empty() => true,
+ None => !char_flag_on(s, |f| f.kenten),
+ };
+ if !on {
+ // Off keeps the settings for the next time kenten are switched on.
+ body = serde_json::Map::new();
+ }
+ body.insert("kenten".into(), json!(on));
+ format_chars(s, &Value::Object(body))
+}
+
+fn shatai_cmd(s: &mut Session, p: &Value) -> Result<Value> {
+ const CMD: &str = "type.shatai";
+ let mut body = serde_json::Map::new();
+ if let Some(v) = finite_param(p, "magnification", CMD)? {
+ body.insert("shataiMagnification".into(), json!(v.clamp(0.0, 90.0)));
+ }
+ if let Some(v) = finite_param(p, "angle", CMD)? {
+ body.insert("shataiAngle".into(), json!(v.rem_euclid(180.0)));
+ }
+ if let Some(v) = bool_param(p, "adjustRotation", CMD)? {
+ body.insert("shataiAdjustRotation".into(), json!(v));
+ }
+ if let Some(v) = bool_param(p, "adjustTsume", CMD)? {
+ body.insert("shataiAdjustTsume".into(), json!(v));
+ }
+ if body.is_empty() {
+ return Err(bad(CMD, "nothing to set: magnification, angle, adjustRotation or adjustTsume"));
+ }
+ format_chars(s, &Value::Object(body))
+}
+
+fn auto_tcy_cmd(s: &mut Session, p: &Value) -> Result<Value> {
+ const CMD: &str = "type.autoTateChuYoko";
+ let mut body = serde_json::Map::new();
+ if let Some(v) = finite_param(p, "digits", CMD)? {
+ let max = f64::from(designcraft_compose::shape::AUTO_TCY_MAX);
+ body.insert("autoTcy".into(), json!(v.round().clamp(0.0, max) as u32));
+ }
+ if let Some(v) = bool_param(p, "includeRoman", CMD)? {
+ body.insert("autoTcyIncludeRoman".into(), json!(v));
+ }
+ if body.is_empty() {
+ return Err(bad(CMD, "nothing to set: digits or includeRoman"));
+ }
+ format_paras(s, &Value::Object(body))
+}
+
+fn grid_settings_cmd(s: &mut Session, p: &Value) -> Result<Value> {
+ use designcraft_doc::cjk::CharacterAlignment as R;
+ const CMD: &str = "type.gridSettings";
+ let mut body = serde_json::Map::new();
+ let first_only = bool_param(p, "firstLineOnly", CMD)?;
+ match text_param(p, "alignment", CMD, 32)?.as_deref() {
+ None => {
+ if let Some(f) = first_only {
+ body.insert("gridAlign".into(), json!(if f { "firstLineOnly" } else { "allLines" }));
+ }
+ }
+ Some("none") => {
+ body.insert("gridAlign".into(), json!("none"));
+ }
+ Some(name) => {
+ let reference = match name {
+ "romanBaseline" | "baseline" => R::Baseline,
+ "emTop" => R::EmTop,
+ "emCenter" => R::EmCenter,
+ "emBottom" => R::EmBottom,
+ "icfTop" => R::IcfTop,
+ "icfBottom" => R::IcfBottom,
+ other => return Err(bad(CMD, format!("unknown alignment `{other}`"))),
+ };
+ body.insert("gridAlign".into(), json!(if first_only == Some(true) { "firstLineOnly" } else { "allLines" }));
+ body.insert("gridReference".into(), json!(reference));
+ }
+ }
+ if let Some(v) = finite_param(p, "gyoudori", CMD)? {
+ let max = 100.0;
+ body.insert("gridGyoudori".into(), json!(v.round().clamp(0.0, max) as u32));
+ }
+ if let Some(v) = bool_param(p, "paragraphGyoudori", CMD)? {
+ body.insert("paragraphGyoudori".into(), json!(v));
+ }
+ if body.is_empty() {
+ return Err(bad(CMD, "nothing to set: alignment, firstLineOnly, gyoudori or paragraphGyoudori"));
+ }
+ format_paras(s, &Value::Object(body))
+}
+
+/// Switch a paragraph attribute of the selected paragraphs: `on`, else the opposite of the
+/// first one's.
+fn para_toggle(s: &mut Session, p: &Value, cmd: &str, attr: &str, get: impl Fn(&designcraft_doc::ParaProps) -> bool) -> Result<Value> {
+ let on = match bool_param(p, "on", cmd)? {
+ Some(v) => v,
+ None => !format_targets(s).first().is_some_and(|t| {
+ s.doc().ok().is_some_and(|d| {
+ d.doc
+ .text_story(t.story, t.cell)
+ .and_then(|st| st.paras.get(st.para_at(t.range.start)))
+ .is_some_and(|pf| get(&d.doc.styles.resolve_para(pf).0))
+ })
+ }),
+ };
+ let mut body = serde_json::Map::new();
+ body.insert(attr.to_string(), json!(on));
+ format_paras(s, &Value::Object(body))
+}
+
+fn ruby_text<'a>(p: &'a Value, key: &str) -> Result<Option<&'a str>> {
+ let Some(v) = p.get(key) else { return Ok(None) };
+ let t = v.as_str().ok_or_else(|| bad("type.ruby", format!("{key}: expected a string")))?;
+ if t.chars().count() > designcraft_doc::ruby::MAX_RUBY_CHARS {
+ return Err(bad("type.ruby", format!("{key}: longer than {} characters", designcraft_doc::ruby::MAX_RUBY_CHARS)));
+ }
+ Ok(Some(t))
+}
+
+fn ruby_cmd(s: &mut Session, p: &Value) -> Result<Value> {
+ use designcraft_doc::cjk_settings::AdornmentOverprint;
+ use designcraft_doc::ruby::{RubyAlignment, RubyOverhang, RubyParentSpacing, RubyPosition, RubyType};
+ let mut body = serde_json::Map::new();
+ let mut put = |attr: &str, v: Option<Value>| {
+ if let Some(v) = v {
+ body.insert(attr.into(), v);
+ }
+ };
+ put("ruby", ruby_text(p, "text")?.map(|t| json!(t)));
+ put("rubyType", ruby_enum::<RubyType>(p, "type")?);
+ put("rubyAlignment", ruby_enum::<RubyAlignment>(p, "alignment")?);
+ put("rubyPosition", ruby_enum::<RubyPosition>(p, "position")?);
+ put("rubyOverhangAmount", ruby_enum::<RubyOverhang>(p, "overhang")?);
+ put("rubyParentSpacing", ruby_enum::<RubyParentSpacing>(p, "parentSpacing")?);
+ put("rubyOverprintFill", ruby_enum::<AdornmentOverprint>(p, "overprintFill")?);
+ put("rubyOverprintStroke", ruby_enum::<AdornmentOverprint>(p, "overprintStroke")?);
+ put("rubyXOffset", ruby_num(p, "xOffset", -1000.0, 1000.0, 1.0)?.filter(|v| !v.is_null()));
+ put("rubyYOffset", ruby_num(p, "yOffset", -1000.0, 1000.0, 1.0)?.filter(|v| !v.is_null()));
+ put("rubyFontSize", ruby_num(p, "size", 0.1, 1296.0, 1.0)?);
+ put("rubyXScale", ruby_num(p, "xScale", 1.0, 1000.0, 100.0)?.filter(|v| !v.is_null()));
+ put("rubyYScale", ruby_num(p, "yScale", 1.0, 1000.0, 100.0)?.filter(|v| !v.is_null()));
+ put("rubyScalingMin", ruby_num(p, "scalingPercent", 10.0, 100.0, 100.0)?.filter(|v| !v.is_null()));
+ put("rubyFillTint", ruby_num(p, "fillTint", 0.0, 100.0, 100.0)?);
+ put("rubyStrokeTint", ruby_num(p, "strokeTint", 0.0, 100.0, 100.0)?);
+ put("rubyStrokeWeight", ruby_num(p, "strokeWeight", 0.0, 800.0, 1.0)?);
+ put(
+ "rubyAutoTcyDigits",
+ ruby_num(p, "autoTcyDigits", 0.0, 9.0, 1.0)?.filter(|v| !v.is_null()).and_then(|v| v.as_f64()).map(|v| json!(v.round() as u32)),
+ );
+ for (key, attr) in [
+ ("openTypePro", "rubyOpenTypePro"),
+ ("autoTcyIncludeRoman", "rubyAutoTcyIncludeRoman"),
+ ("autoTcyAutoScale", "rubyAutoTcyAutoScale"),
+ ("autoAlign", "rubyAutoAlign"),
+ ("autoScaling", "rubyAutoScaling"),
+ ] {
+ if let Some(v) = p.get(key) {
+ let b = v.as_bool().ok_or_else(|| bad("type.ruby", format!("{key}: expected true or false")))?;
+ put(attr, Some(json!(b)));
+ }
+ }
+ put("rubyFont", ruby_text(p, "font")?.map(|t| json!(t)));
+ put("rubyFontStyle", ruby_text(p, "fontStyle")?.map(|t| json!(t)));
+ for (key, attr) in [("fill", "rubyFill"), ("stroke", "rubyStroke")] {
+ if let Some(name) = ruby_text(p, key)? {
+ let known = name.is_empty() || name == designcraft_doc::color::swatch::NONE || s.doc()?.doc.swatch(name).is_some();
+ if !known {
+ return Err(bad("type.ruby", format!("{key}: no swatch `{name}`")));
+ }
+ put(attr, Some(json!(name)));
+ }
+ }
+ format_chars(s, &Value::Object(body))
+}
+
+ pub(crate) fn validate_char_fill(document: &designcraft_doc::Document, attrs: &CharAttrs, command_id: &str) -> Result<()> {
+ if let Some(fill) = &attrs.fill
+ && document.swatch(fill).is_none()
+ {
+ return Err(bad(
+ command_id,
+ format!("unknown character fill `{fill}`; create a swatch with `swatch.create` and use its returned name as `fill`"),
+ ));
+ }
+ Ok(())
+ }
+
pub(crate) fn format_chars(s: &mut Session, attrs: &Value) -> Result<Value> {
let mut a = CharAttrs::default();
if let Some(o) = attrs.as_object() {
@@@ -1304,24 -838,31 +1316,25 @@@
a.set_json(k, v).map_err(|e| bad("type.char", e))?;
}
}
+ validate_char_fill(&s.doc()?.doc, &a, "type.char")?;
let cleared: Vec<String> = attrs.as_object().map(|o| o.iter().filter(|(_, v)| v.is_null()).map(|(k, _)| k.clone()).collect()).unwrap_or_default();
let targets = format_targets(s);
+ // A caret in text: the format is for the next typing.
+ if let [t] = targets.as_slice()
+ && t.range.is_empty()
+ && let Some(at) = s.doc()?.selection.text
+ && s.doc()?.doc.text_story(t.story, t.cell).is_some_and(|st| !st.is_empty())
+ {
+ let doc = s.doc()?.uid;
+ let mut f = typing_format(s).cloned().unwrap_or(TypingFormat { doc, at, attrs: CharAttrs::default(), cleared: vec![] });
+ f.attrs.merge(&a);
+ f.cleared.retain(|k| attrs.get(k).is_none_or(|v| v.is_null()) && !cleared.contains(k));
+ f.cleared.extend(cleared);
+ s.typing_format = Some(f);
+ return ok();
+ }
s.edit(|d, _| {
- for t in &targets {
- let r = &t.range;
- let Some(st) = d.text_story_mut(t.story, t.cell) else { continue };
- if r.is_empty() {
- // Caret: change the typing format (the empty run at the caret).
- let pos = r.start;
- if st.is_empty() {
- st.chars[0].format.over.merge(&a);
- st.rev += 1;
- } else {
- let _ = pos;
- }
- continue;
- }
- st.format_chars(r.clone(), |f| {
- f.over.merge(&a);
- for k in &cleared {
- let _ = f.over.set_json(k, &Value::Null);
- }
- });
- }
+ apply_char_attrs(d, &targets, &a, &cleared);
ok()
})
}