fix: fix fragile schema validity test in splitBlock

This commit is contained in:
Philipp Kühn
2021-05-28 13:55:54 +02:00
parent 9d13db6988
commit e52f41ae78

View File

@@ -110,12 +110,17 @@ export const splitBlock: RawCommands['splitBlock'] = ({ keepMarks = true } = {})
tr.split(tr.mapping.map($from.pos), 1, types)
if (
!atEnd
deflt
&& !atEnd
&& !$from.parentOffset
&& $from.parent.type !== deflt
&& $from.node(-1).canReplace($from.index(-1), $from.indexAfter(-1), Fragment.from(deflt?.create()))
) {
tr.setNodeMarkup(tr.mapping.map($from.before()), deflt || undefined)
const first = tr.mapping.map($from.before())
const $first = tr.doc.resolve(first)
if ($from.parent.canReplaceWith($first.index(), $first.index() + 1, deflt)) {
tr.setNodeMarkup(tr.mapping.map($from.before()), deflt)
}
}
}