mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-28 12:16:53 -06:00
Merge #257: Word import: keep tracked moved text (w:moveTo)
Conflict: contributors/people.toml: kept both entries
This commit is contained in:
@@ -27,3 +27,6 @@ sync_github_name = true
|
||||
|
||||
[people.emanuelebonaventura]
|
||||
display_name = "insanityxoff"
|
||||
|
||||
[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