Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
copy_and_paste: Refactor `is_safe_url_paste_target`.
Kislay Verma825590dde2ad
diff --git a/web/src/copy_and_paste.ts b/web/src/copy_and_paste.tsindex eb235027ee6..2c2ede30b52 100644--- a/web/src/copy_and_paste.ts+++ b/web/src/copy_and_paste.ts@@ -617,15 +617,19 @@ function is_safe_url_paste_target($textarea: JQuery<HTMLTextAreaElement>): boole// Look at the two characters before the start of the original// range in search of the tell-tale `](` from existing Markdown// link syntax- const possible_markdown_link_markers = $textarea[0]!.value.slice(range.start - 2, range.start);-- if (possible_markdown_link_markers === "](") {+ if (cursor_at_markdown_link_marker($textarea)) {return false;}return true;}+export function cursor_at_markdown_link_marker($textarea: JQuery<HTMLTextAreaElement>): boolean {+ const range = $textarea.range();+ const possible_markdown_link_markers = $textarea[0]!.value.slice(range.start - 2, range.start);+ return possible_markdown_link_markers === "](";+}+export function maybe_transform_html(html: string, text: string): string {if (is_white_space_pre(html)) {// Copied content styled with `white-space: pre` is pasted as is