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))) } })