From 48351893b1dcd7ef5cc8b22508604fbe19fccf80 Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Thu, 14 Dec 2023 12:37:59 +0700 Subject: [PATCH] UBERF-4304 UBER-1135 Fix nodeUuid extension exception when clicking below document (#4194) Signed-off-by: Alexander Onnikov --- packages/text-editor/src/components/extension/nodeUuid.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/text-editor/src/components/extension/nodeUuid.ts b/packages/text-editor/src/components/extension/nodeUuid.ts index b51c75d910..1a91130ba4 100644 --- a/packages/text-editor/src/components/extension/nodeUuid.ts +++ b/packages/text-editor/src/components/extension/nodeUuid.ts @@ -115,8 +115,10 @@ export const NodeUuidExtension = Mark.create({ 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