Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
copy_and_paste: Let uppy handle pasted single images.
N-Shar-ma0b728e1b3431
diff --git a/web/src/copy_and_paste.ts b/web/src/copy_and_paste.tsindex bba05764e0a..eb235027ee6 100644--- a/web/src/copy_and_paste.ts+++ b/web/src/copy_and_paste.ts@@ -377,6 +377,18 @@ export function is_white_space_pre(paste_html: string): boolean {);}+function is_single_image(paste_html: string): boolean {+ const html_fragment = new DOMParser()+ .parseFromString(paste_html, "text/html")+ .querySelector("body");+ assert(html_fragment !== null);+ return (+ html_fragment.childNodes.length === 1 &&+ html_fragment.firstElementChild !== null &&+ html_fragment.firstElementChild.nodeName === "IMG"+ );+}+export function paste_handler_converter(paste_html: string): string {const copied_html_fragment = new DOMParser().parseFromString(paste_html, "text/html")@@ -662,6 +674,10 @@ export function paste_handler(this: HTMLTextAreaElement, event: JQuery.Triggeredpaste_html &&!compose_ui.shift_pressed) {+ if (is_single_image(paste_html)) {+ // If the copied content is a single image, we let upload.ts handle it.+ return;+ }event.preventDefault();event.stopPropagation();paste_html = maybe_transform_html(paste_html, paste_text);