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

@@ -2,14 +2,14 @@ import { EditorState } from 'prosemirror-state'
import { MarkRange } from '../types'
export default function getMarksBetween(from: number, to: number, state: EditorState): MarkRange[] {
let marks: MarkRange[] = []
const marks: MarkRange[] = []
state.doc.nodesBetween(from, to, (node, pos) => {
marks = [...marks, ...node.marks.map(mark => ({
marks.push(...node.marks.map(mark => ({
from: pos,
to: pos + node.nodeSize,
mark,
}))]
})))
})
return marks