diff --git a/packages/tiptap-utils/src/utils/getMarkRange.js b/packages/tiptap-utils/src/utils/getMarkRange.js index 115f8b6b..b3b02977 100644 --- a/packages/tiptap-utils/src/utils/getMarkRange.js +++ b/packages/tiptap-utils/src/utils/getMarkRange.js @@ -17,13 +17,14 @@ export default function ($pos = null, type = null) { let startIndex = $pos.index() let startPos = $pos.start() + start.offset + let endIndex = startIndex + 1 + let endPos = startPos + start.node.nodeSize + while (startIndex > 0 && link.isInSet($pos.parent.child(startIndex - 1).marks)) { startIndex -= 1 startPos -= $pos.parent.child(startIndex).nodeSize } - let endIndex = $pos.indexAfter() - let endPos = startPos + start.node.nodeSize while (endIndex < $pos.parent.childCount && link.isInSet($pos.parent.child(endIndex).marks)) { endPos += $pos.parent.child(endIndex).nodeSize endIndex += 1