From fad488623f4f050565516ad77108651d7636cad9 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Mon, 23 Jun 2025 21:30:43 +0530 Subject: [PATCH] Revert "fix: multi-line formatted correctly for sms (#21779)" (#21979) This reverts commit 5e2f06cdea806c48502e526e759d7b0d7367fd06. --- packages/ui/components/editor/Editor.test.tsx | 2 +- packages/ui/components/editor/plugins/ToolbarPlugin.tsx | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/ui/components/editor/Editor.test.tsx b/packages/ui/components/editor/Editor.test.tsx index f7b0f776ea..f3ca4629d0 100644 --- a/packages/ui/components/editor/Editor.test.tsx +++ b/packages/ui/components/editor/Editor.test.tsx @@ -7,7 +7,7 @@ import type { TextEditorProps } from "./types"; describe("Editor", () => { const defaultProps: TextEditorProps = { - getText: vi.fn(() => ""), + getText: vi.fn(), setText: vi.fn(), variables: ["name", "email"], height: "200px", diff --git a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx index 01fec94b28..ca62a447bf 100644 --- a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx +++ b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx @@ -220,7 +220,6 @@ function getSelectedNode(selection: RangeSelection) { } export default function ToolbarPlugin(props: TextEditorProps) { - const isInitialized = useRef(false); const [editor] = useLexicalComposerContext(); const toolbarRef = useRef(null); const [blockType, setBlockType] = useState("paragraph"); @@ -365,13 +364,11 @@ export default function ToolbarPlugin(props: TextEditorProps) { }, [props.updateTemplate]); useEffect(() => { - if (props.setFirstRender && !isInitialized.current) { - isInitialized.current = true; + if (props.setFirstRender) { props.setFirstRender(false); editor.update(() => { const parser = new DOMParser(); - const content = props.getText()?.replace(/\n/g, "
"); - const dom = parser.parseFromString(content, "text/html"); + const dom = parser.parseFromString(props.getText(), "text/html"); const nodes = $generateNodesFromDOM(editor, dom);