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.
This commit is contained in:
Jackson Harper
2022-12-27 20:31:31 +08:00
parent 2190acc0e0
commit e16fc81a2f

View File

@ -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)