diff --git a/crates/ui-egui/src/comments.rs b/crates/ui-egui/src/comments.rs index 7fd9b7a62..d06eafdad 100644 --- a/crates/ui-egui/src/comments.rs +++ b/crates/ui-egui/src/comments.rs @@ -347,6 +347,7 @@ pub fn tool_for(a: &Annotation) -> Option { ("FreeText", _) => CommentTool::TextBox, ("Highlight", _) => CommentTool::Highlight, ("Underline", _) => CommentTool::Underline, + ("StrikeOut", Some("StrikeOutTextEdit")) => CommentTool::ReplaceText, ("StrikeOut", _) => CommentTool::StrikeOut, ("Squiggly", _) => CommentTool::Squiggly, ("Ink", _) => CommentTool::Ink, diff --git a/crates/ui-egui/src/comments_panel.rs b/crates/ui-egui/src/comments_panel.rs index 2ac1853f4..7dca40b85 100644 --- a/crates/ui-egui/src/comments_panel.rs +++ b/crates/ui-egui/src/comments_panel.rs @@ -33,9 +33,10 @@ pub fn subtype_label(s: &str) -> &str { } } -/// The comment type as the panel names it, telling callouts and clouds apart by `/IT`. +/// The comment type as the panel names it, telling callouts, clouds and replaced text apart by `/IT`. pub fn kind_label(a: &Annotation) -> &str { match a.intent.as_deref() { + Some("StrikeOutTextEdit") => "Replace text", Some("FreeTextCallout") => "Callout", Some("PolygonCloud") => "Cloud", Some("FreeTextTypeWriter") => "Typewriter", diff --git a/crates/ui-egui/tests/comments.rs b/crates/ui-egui/tests/comments.rs index 01166a41d..daab3ad64 100644 --- a/crates/ui-egui/tests/comments.rs +++ b/crates/ui-egui/tests/comments.rs @@ -1231,6 +1231,13 @@ fn replacing_text_strikes_it_and_adds_a_caret() { assert_eq!(caret.in_reply_to, strike.name, "grouped with the strikeout"); assert_eq!(h.state().session.get(h.state().views[0].id).unwrap().can_undo(), Some("Replace text")); assert_eq!(h.state().quick_tool, QuickTool::Select); + // The strikeout is the Replace text tool's, not Strikethrough's (#3947): the panel names it + // so, and Make Current Properties Default updates the Replace text tool. + assert_eq!(pdfcraft_ui_egui::comments::tool_for(strike), Some(pdfcraft_ui_egui::comments::CommentTool::ReplaceText)); + h.state_mut().set_option("panel", "comments").unwrap(); + h.run_steps(3); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Label, "Replace text").is_some(), "the panel names the comment Replace text"); + assert!(h.query_by_role_and_label(egui::accesskit::Role::Label, "Strikethrough").is_none(), "not Strikethrough"); } #[test]