From 131feee53a08d2db3722123650918dfa08d9a714 Mon Sep 17 00:00:00 2001 From: Sherry Date: Tue, 2 Jul 2024 10:31:39 +0800 Subject: [PATCH] [lexical-markdown] Feature Change: Dont trim whitespaces on convertFromMarkdownString (#6360) --- packages/lexical-markdown/src/MarkdownImport.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/lexical-markdown/src/MarkdownImport.ts b/packages/lexical-markdown/src/MarkdownImport.ts index b109b2ca1cc..7dd242a17c5 100644 --- a/packages/lexical-markdown/src/MarkdownImport.ts +++ b/packages/lexical-markdown/src/MarkdownImport.ts @@ -110,8 +110,7 @@ function $importBlocks( textFormatTransformersIndex: TextFormatTransformersIndex, textMatchTransformers: Array, ) { - const lineTextTrimmed = lineText.trim(); - const textNode = $createTextNode(lineTextTrimmed); + const textNode = $createTextNode(lineText); const elementNode = $createParagraphNode(); elementNode.append(textNode); rootNode.append(elementNode); @@ -135,7 +134,7 @@ function $importBlocks( // If no transformer found and we left with original paragraph node // can check if its content can be appended to the previous node // if it's a paragraph, quote or list - if (elementNode.isAttached() && lineTextTrimmed.length > 0) { + if (elementNode.isAttached() && lineText.length > 0) { const previousNode = elementNode.getPreviousSibling(); if ( $isParagraphNode(previousNode) ||