DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Integration: renaming a swatch reaches endnote text (#84 × #416)
aionggd30cefe1665e
diff --git a/crates/doc/src/swatch_refs.rs b/crates/doc/src/swatch_refs.rsindex 08ea2ea2a..d15519fcf 100644--- a/crates/doc/src/swatch_refs.rs+++ b/crates/doc/src/swatch_refs.rs@@ -144,8 +144,8 @@ impl Names<'_> {impl Document {/// Point every reference to swatch `from` at `to`: tints based on it, colour groups, inks,/// styles, page items (fills, strokes, gaps, effects, column rules), text, kenten and ruby- /// colours, rules, shading, borders and border gaps, tables (with stroke gaps) and the- /// footnote rule. The swatch itself is renamed by the+ /// colours, rules, shading, borders and border gaps, tables (with stroke gaps), footnotes,+ /// endnotes and the footnote rule. The swatch itself is renamed by the/// caller.pub fn rename_swatch_refs(&mut self, from: &str, to: &str) {if from == to {@@ -221,6 +221,9 @@ impl Document {for sid in self.stories.keys().copied().collect::<Vec<_>>() {if let Some(story) = self.story_mut(sid) {story.for_each_text_mut(&mut |st| n.story(st));+ for e in &mut story.endnotes {+ Arc::make_mut(e).text.for_each_text_mut(&mut |st| n.story(st));+ }}}}diff --git a/crates/engine/src/cmd/style.rs b/crates/engine/src/cmd/style.rsindex 46375773d..3e60cf626 100644--- a/crates/engine/src/cmd/style.rs+++ b/crates/engine/src/cmd/style.rs@@ -1586,6 +1586,8 @@ mod color_tests {let r = s.execute("frame.create", &json!({"rect": [72, 72, 400, 300], "content": "text", "text": "Hello world"})).unwrap();let sid = designcraft_doc::StoryId(r["story"].as_u64().unwrap());s.execute("text.select", &json!({"story": sid.0, "anchor": 11})).unwrap();+ s.execute("endnote.insert", &json!({"text": "end"})).unwrap();+ s.execute("text.select", &json!({"story": sid.0, "anchor": 11})).unwrap();s.execute("footnote.insert", &json!({"text": "note"})).unwrap();s.execute("text.select", &json!({"story": sid.0, "anchor": 0})).unwrap();s.execute("table.insert", &json!({"rows": 1, "cols": 1})).unwrap();@@ -1598,6 +1600,7 @@ mod color_tests {t.cells[0].fill = old.clone();t.cells[0].text.chars[0].format.over.fill = Some(old.clone());Arc::make_mut(&mut st.notes[0]).text.chars[0].format.over.stroke = Some(old.clone());+ Arc::make_mut(&mut st.endnotes[0]).text.chars[0].format.over.underline_color = Some(old.clone());Ok(())}).unwrap();@@ -1609,6 +1612,7 @@ mod color_tests {assert_eq!(cell.fill, "Sand");assert_eq!(cell.text.chars[0].format.over.fill.as_deref(), Some("Sand"));assert_eq!(st.notes[0].text.chars[0].format.over.stroke.as_deref(), Some("Sand"));+ assert_eq!(st.endnotes[0].text.chars[0].format.over.underline_color.as_deref(), Some("Sand"));d.check().unwrap();}}