fix: multi-line formatted correctly for sms (#21779)

* fix: multi-line formatted correctly for sms

* fix: tests iteration2
This commit is contained in:
Chai authored and GitHub committed 2025-06-12 14:26:34 +00:00
1 parent cf83038a7a
commit 5e2f06cdea
2 files changed
+6 -3

No files matched your search

@@ -220,6 +220,7 @@ 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");
@@ -364,11 +365,13 @@ export default function ToolbarPlugin(props: TextEditorProps) {
}, [props.updateTemplate]);
useEffect(() => {
if (props.setFirstRender) {
if (props.setFirstRender && !isInitialized.current) {
isInitialized.current = true;
props.setFirstRender(false);
editor.update(() => {
const parser = new DOMParser();
const dom = parser.parseFromString(props.getText(), "text/html");
const content = props.getText()?.replace(/\n/g, "<br>");
const dom = parser.parseFromString(content, "text/html");
const nodes = $generateNodesFromDOM(editor, dom);