mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-14 19:27:07 -04:00
Word import: keep tracked moved text (w:moveTo) (#257)
Text inside a tracked move destination was dropped on .docx import, so moved passages vanished from both places. Treat moveTo like ins (both kept as accepted); moveFrom stays skipped like del. Regression test covers ins, del, moveFrom and moveTo together. Fixes #256. Also adds my contributor credit entry. Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
06322045a5
commit
4aea57fea7
2 files changed
+25
-1
No files matched your search
@@ -21,3 +21,6 @@
|
||||
real_name = "Brandon Thomas"
|
||||
display_name = "Brandon Thomas"
|
||||
sync_github_name = false
|
||||
|
||||
[people.thaynej]
|
||||
real_name = "Jeffrey Thayne"
|
||||
@@ -276,7 +276,9 @@ impl Ctx {
|
||||
for e in p.els() {
|
||||
match e.name.as_str() {
|
||||
"r" => self.run(e, st, allow_notes),
|
||||
"hyperlink" | "smartTag" | "ins" | "fldSimple" | "customXml" => self.inline(e, st, allow_notes),
|
||||
// Tracked changes import as accepted: insertions and move destinations are kept,
|
||||
// deletions (`del`) and move sources (`moveFrom`) are dropped.
|
||||
"hyperlink" | "smartTag" | "ins" | "moveTo" | "fldSimple" | "customXml" => self.inline(e, st, allow_notes),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -469,4 +471,23 @@ mod tests {
|
||||
assert_eq!(i.para_styles[0].para.space_before, Some(12.0));
|
||||
assert_eq!(i.char_styles[0].chars.font_style.as_deref(), Some("Italic"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tracked_changes_import_as_accepted_including_moves() {
|
||||
// Regression (#256): text in a tracked move destination (`w:moveTo`) vanished on import.
|
||||
let document = format!(
|
||||
r#"<w:document {W}><w:body>
|
||||
<w:p><w:r><w:t xml:space="preserve">Kept text. </w:t></w:r>
|
||||
<w:moveTo w:id="1" w:author="A"><w:r><w:t xml:space="preserve">MOVED HERE.</w:t></w:r>
|
||||
<w:del w:id="5" w:author="A"><w:r><w:delText>MOVED THEN DELETED</w:delText></w:r></w:del></w:moveTo>
|
||||
<w:r><w:t xml:space="preserve"> Plain </w:t></w:r>
|
||||
<w:ins w:id="2" w:author="A"><w:r><w:t>INSERTED</w:t></w:r></w:ins>
|
||||
<w:del w:id="3" w:author="A"><w:r><w:delText>DELETED</w:delText></w:r></w:del></w:p>
|
||||
<w:p><w:moveFrom w:id="4" w:author="A"><w:r><w:t>MOVED HERE.</w:t></w:r></w:moveFrom><w:r><w:t>End.</w:t></w:r></w:p>
|
||||
</w:body></w:document>"#
|
||||
);
|
||||
let i = import(&docx(&document, "", "")).unwrap();
|
||||
i.story.check().unwrap();
|
||||
assert_eq!(i.story.text, "Kept text. MOVED HERE. Plain INSERTED\nEnd.");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user