Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

copy_and_paste: Paste text first unformatted and then formatted.

Kislay Verma3620139700b1
diff --git a/web/src/copy_and_paste.ts b/web/src/copy_and_paste.ts
index 59c2d9fdee6..c88f56eb87e 100644
--- a/web/src/copy_and_paste.ts
+++ b/web/src/copy_and_paste.ts
@@ -745,6 +745,11 @@ export function paste_handler(this: HTMLTextAreaElement, event: JQuery.Triggered
event.stopPropagation();
paste_html = maybe_transform_html(paste_html, paste_text);
const text = paste_handler_converter(paste_html);
+ // Pasting formatted text is a two-step process:
+ // First we paste unformatted text,
+ // then overwrite it with formatted text.
+ // This way, undo restores the pre-formatting syntax.
+ add_text_and_select(trimmed_paste_text, $textarea);
compose_ui.insert_and_scroll_into_view(text, $textarea);
}
}