From a08bf85cf041021bb7dfbee94f08fa77c62ba030 Mon Sep 17 00:00:00 2001 From: Nick Perez Date: Mon, 29 Jul 2024 08:54:17 +0200 Subject: [PATCH] fix: do not consider text content as atoms resolve #5405 (#5407) --- .changeset/lemon-files-thank.md | 5 +++++ packages/core/src/helpers/getTextContentFromNodes.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/lemon-files-thank.md diff --git a/.changeset/lemon-files-thank.md b/.changeset/lemon-files-thank.md new file mode 100644 index 000000000..bc95a305a --- /dev/null +++ b/.changeset/lemon-files-thank.md @@ -0,0 +1,5 @@ +--- +"@tiptap/core": patch +--- + +This fixes a bug with inputrules not being able to resolve positions properly diff --git a/packages/core/src/helpers/getTextContentFromNodes.ts b/packages/core/src/helpers/getTextContentFromNodes.ts index c1264d27b..a9a57391f 100644 --- a/packages/core/src/helpers/getTextContentFromNodes.ts +++ b/packages/core/src/helpers/getTextContentFromNodes.ts @@ -24,7 +24,7 @@ export const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => { || node.textContent || '%leaf%' - textBefore += node.isAtom ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos)) + textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos)) }, )