UBERF-4304 UBER-1135 Fix nodeUuid extension exception when clicking below document (#4194)

Signed-off-by: Alexander Onnikov <alexander.onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2023-12-14 12:37:59 +07:00 committed by GitHub
parent 2bf1a03907
commit 48351893b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,8 +115,10 @@ export const NodeUuidExtension = Mark.create<NodeUuidOptions, NodeUuidStorage>({
key: new PluginKey('handle-node-uuid-click-plugin'),
props: {
handleClick (view, pos) {
const from = Math.max(0, pos - 1)
const to = Math.min(view.state.doc.content.size, pos + 1)
const markRanges =
getMarksBetween(Math.max(0, pos - 1), pos + 1, view.state.doc)?.filter(
getMarksBetween(from, to, view.state.doc)?.filter(
(markRange) => markRange.mark.type.name === NAME && markRange.from <= pos && markRange.to >= pos
) ?? []
let nodeUuid: string | null = null