diff --git a/contributors/people.toml b/contributors/people.toml index af385063f..9a482c653 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -27,3 +27,6 @@ sync_github_name = true [people.emanuelebonaventura] display_name = "insanityxoff" + +[people.thaynej] +real_name = "Jeffrey Thayne" diff --git a/crates/textimport/src/docx.rs b/crates/textimport/src/docx.rs index 563eb7289..670f8a0fa 100644 --- a/crates/textimport/src/docx.rs +++ b/crates/textimport/src/docx.rs @@ -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#" + Kept text. + MOVED HERE. + MOVED THEN DELETED + Plain + INSERTED + DELETED + MOVED HERE.End. + "# + ); + let i = import(&docx(&document, "", "")).unwrap(); + i.story.check().unwrap(); + assert_eq!(i.story.text, "Kept text. MOVED HERE. Plain INSERTED\nEnd."); + } }