Skip to content

Commit

Permalink
Add text normalization to fix problems with \r\n
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Aug 20, 2024
1 parent ea8c204 commit b5e9b86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/web/utils/parserUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ function updateInputStructure(
targetElement.innerHTML = '';
targetElement.innerText = '';
}

const normalizedText = text.replaceAll('\r\n', '\n');
// We don't want to parse text with single '\n', because contentEditable represents it as invisible <br />
if (text) {
const {dom, tree} = parseRangesToHTMLNodes(text, markdownRanges, markdownStyle);
if (normalizedText) {
const {dom, tree} = parseRangesToHTMLNodes(normalizedText, markdownRanges, markdownStyle);

if (shouldForceDOMUpdate || targetElement.innerHTML !== dom.innerHTML) {
targetElement.innerHTML = '';
Expand Down

0 comments on commit b5e9b86

Please sign in to comment.