fix: improve performance for isActive method, see #1930

This commit is contained in:
Philipp Kühn
2021-09-22 19:43:55 +02:00
parent 6fa886273f
commit fcca1e6f4d
5 changed files with 14 additions and 14 deletions

View File

@@ -27,7 +27,7 @@ export default function isMarkActive(
}
let selectionRange = 0
let markRanges: MarkRange[] = []
const markRanges: MarkRange[] = []
state.doc.nodesBetween(from, to, (node, pos) => {
if (node.isText || node.marks.length) {
@@ -37,11 +37,11 @@ export default function isMarkActive(
selectionRange += range
markRanges = [...markRanges, ...node.marks.map(mark => ({
markRanges.push(...node.marks.map(mark => ({
mark,
from: relativeFrom,
to: relativeTo,
}))]
})))
}
})