From c102ef70039ac1d71b5147bb87d128117d9ca1ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Tue, 7 Jan 2025 14:07:17 +0100 Subject: [PATCH] Improve inserting at the end of the text In some cases inserting at the end of the text skipped the latest character. [MAILPOET-6396] --- .../src/components/personalization-tags/rich-text-utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/js/email-editor/src/components/personalization-tags/rich-text-utils.ts b/packages/js/email-editor/src/components/personalization-tags/rich-text-utils.ts index 2a4f42d95d..883cc6cc32 100644 --- a/packages/js/email-editor/src/components/personalization-tags/rich-text-utils.ts +++ b/packages/js/email-editor/src/components/personalization-tags/rich-text-utils.ts @@ -117,7 +117,7 @@ const getCursorPosition = ( ); if ( formatIndex !== null ) { return { - start: formatIndex + selection.anchorOffset, + start: formatIndex + selection.anchorOffset + 1, // We need to add 1 for the format length end: formatIndex + selection.anchorOffset + range.toString().length, }; } @@ -129,7 +129,7 @@ const getCursorPosition = ( ); if ( replacementIndex !== null ) { return { - start: replacementIndex + selection.anchorOffset, + start: replacementIndex + selection.anchorOffset + 1, // We need to add 1 for the replacement length end: replacementIndex + selection.anchorOffset +