check for allowed marks in pasteRule, fix #643

This commit is contained in:
Philipp Kühn 2020-04-02 09:22:12 +02:00
parent 15eb791b31
commit 1ee114be5d

View File

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