From 975ea16317b99b8c0e46c3283fa2d2193f9fd9a3 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 15 Aug 2023 15:23:50 +0100 Subject: [PATCH] Avoid handling pasted HTML if there are files on the clipboard (#14321) GitOrigin-RevId: 8bb258545f1763bf511817665c89e6f948dc0f62 --- .../source-editor/extensions/visual/paste-html.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts b/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts index 126189cd83..96da067e5b 100644 --- a/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts +++ b/services/web/frontend/js/features/source-editor/extensions/visual/paste-html.ts @@ -6,7 +6,17 @@ export const pasteHtml = Prec.highest( paste(event, view) { const { clipboardData } = event - if (!clipboardData?.types.includes('text/html')) { + if (!clipboardData) { + return false + } + + // allow pasting an image to create a figure + if (clipboardData.files.length > 0) { + return false + } + + // only handle pasted HTML + if (!clipboardData.types.includes('text/html')) { return false }