diff --git a/crates/textimport/src/docx.rs b/crates/textimport/src/docx.rs index bc2afc8ad..24843c64c 100644 --- a/crates/textimport/src/docx.rs +++ b/crates/textimport/src/docx.rs @@ -368,6 +368,12 @@ impl Ctx { // 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), + // A content control (date picker, drop-down, plain text) keeps its runs in `sdtContent`. + "sdt" => { + if let Some(c) = e.child("sdtContent") { + self.inline(c, st, allow_notes); + } + } _ => {} } } @@ -640,6 +646,20 @@ mod tests { assert_eq!(i.char_styles[0].chars.font_style.as_deref(), Some("Italic")); } + /// A content control inside a paragraph (`w:sdt`) keeps its text, also around a hyperlink. + #[test] + fn inline_content_control_text_is_kept() { + let document = format!( + r#" + Date: 1 May 2026. + Link + "# + ); + let st = import(&docx(&document, "", "")).unwrap().story; + st.check().unwrap(); + assert_eq!(st.text, "Date: 1 May 2026.\nLink"); + } + #[test] fn tracked_changes_import_as_accepted_including_moves() { // Regression (#256): text in a tracked move destination (`w:moveTo`) vanished on import.