From 9d281e9e998a5cfa9ca1002ad428caf1cee59682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Sun, 10 Oct 2021 19:25:47 +0200 Subject: [PATCH] fix: do not apply paste rules for ProseMirror HTML --- packages/core/src/PasteRule.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/core/src/PasteRule.ts b/packages/core/src/PasteRule.ts index 54b60efa4..981a8ab7d 100644 --- a/packages/core/src/PasteRule.ts +++ b/packages/core/src/PasteRule.ts @@ -127,12 +127,23 @@ function run(config: { * action. */ export function pasteRulesPlugin(rules: PasteRule[]): Plugin { + let isProseMirrorHTML = false + const plugin = new Plugin({ + props: { + handlePaste: (view, event) => { + const html = event.clipboardData?.getData('text/html') + + isProseMirrorHTML = !!html?.includes('data-pm-slice') + + return false + }, + }, appendTransaction: (transactions, oldState, state) => { const transaction = transactions[0] // stop if there is not a paste event - if (!transaction.getMeta('paste')) { + if (!transaction.getMeta('paste') || isProseMirrorHTML) { return }