From 1ee114be5d2511332987ac15a9d93c10277add7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Thu, 2 Apr 2020 09:22:12 +0200 Subject: [PATCH] check for allowed marks in pasteRule, fix #643 --- packages/tiptap-commands/src/commands/markPasteRule.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tiptap-commands/src/commands/markPasteRule.js b/packages/tiptap-commands/src/commands/markPasteRule.js index 363f4d2c..e555fce0 100644 --- a/packages/tiptap-commands/src/commands/markPasteRule.js +++ b/packages/tiptap-commands/src/commands/markPasteRule.js @@ -3,7 +3,7 @@ import { Slice, Fragment } from 'prosemirror-model' export default function (regexp, type, getAttrs) { - const handler = fragment => { + const handler = (fragment, parent) => { const nodes = [] fragment.forEach(child => { @@ -16,7 +16,7 @@ export default function (regexp, type, getAttrs) { // eslint-disable-next-line while (!isLink && (match = regexp.exec(text)) !== null) { - if (match[1]) { + if (parent.type.allowsMarkType(type) && match[1]) { const start = match.index const end = start + match[0].length const textStart = start + match[0].indexOf(match[1]) @@ -43,7 +43,7 @@ export default function (regexp, type, getAttrs) { nodes.push(child.cut(pos)) } } else { - nodes.push(child.copy(handler(child.content))) + nodes.push(child.copy(handler(child.content, child))) } })