mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-27 03:36:51 -06:00
#84's Add to Swatches renamed the colour in footnotes and endnotes through its own helpers; next's Document::rename_swatch_refs (#416), which add_to_swatches calls after the merge, covered footnotes but not endnotes. rename_swatch_refs now walks each story's endnotes too, and #84's test checks an endnote.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user