Skip to content

Commit

Permalink
chore: rename to to sliceEndPos
Browse files Browse the repository at this point in the history
  • Loading branch information
hamflx committed Sep 26, 2022
1 parent 417ac55 commit aa0ce7b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/core/src/helpers/getTextContentFromNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { ResolvedPos } from 'prosemirror-model'
export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => {
let textBefore = ''

const to = $from.parentOffset
const sliceEndPos = $from.parentOffset

$from.parent.nodesBetween(
Math.max(0, to - maxMatch),
to,
Math.max(0, sliceEndPos - maxMatch),
sliceEndPos,
(node, pos, parent, index) => {
const chunk = node.type.spec.toText?.({
node, pos, parent, index,
}) || node.textContent || '%leaf%'
textBefore += chunk.slice(0, Math.max(0, to - pos))

textBefore += chunk.slice(0, Math.max(0, sliceEndPos - pos))
},
)

Expand Down

0 comments on commit aa0ce7b

Please sign in to comment.