From 7068d42df9639f9ac9fce7239d668cf4eae7af0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ska=C5=82ka?= Date: Wed, 28 Aug 2024 11:09:42 +0200 Subject: [PATCH] Fix cursor position setting by correcting tree length --- src/web/utils/parserUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/utils/parserUtils.ts b/src/web/utils/parserUtils.ts index 7b9f7985..05d4163a 100644 --- a/src/web/utils/parserUtils.ts +++ b/src/web/utils/parserUtils.ts @@ -146,7 +146,7 @@ function addParagraph(node: TreeNode, text: string | null = null, length: number /** Builds HTML DOM structure based on passed text and markdown ranges */ function parseRangesToHTMLNodes(text: string, ranges: MarkdownRange[], markdownStyle: PartialMarkdownStyle = {}, disableInlineStyles = false) { const rootElement: HTMLMarkdownElement = document.createElement('span') as HTMLMarkdownElement; - const textLength = text.replace(/\n/g, '\\n').length; + const textLength = text.length; const rootNode: TreeNode = { element: rootElement, start: 0,