From e16fc81a2fdf8a76fd56fbbd0ba6127ecc322d10 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Tue, 27 Dec 2022 20:31:31 +0800 Subject: [PATCH] Fix issue with spaces dissapearing when highlights are created Use the raw text when creating a highlight node instead of the escaped text. This means \n spaces will be preserved in the node and prevent spaces from being removed. --- packages/web/lib/highlights/highlightGenerator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/lib/highlights/highlightGenerator.ts b/packages/web/lib/highlights/highlightGenerator.ts index 40f6d7046..0175d717b 100644 --- a/packages/web/lib/highlights/highlightGenerator.ts +++ b/packages/web/lib/highlights/highlightGenerator.ts @@ -126,7 +126,7 @@ export function makeHighlightNodeAttributes( // If we are not in preformatted text, prevent hardcoded \n, // we'll create new-lines based on the startsParagraph data const text = isPre ? rawText : rawText.replace(/\n/g, '') - const newTextNode = document.createTextNode(text) + const newTextNode = document.createTextNode(rawText) if (!highlight) { return parentNode?.insertBefore(newTextNode, nextSibling)