Skip to content

Scheduling infrastructure for absolutely everyone.

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

Chai5e2f06cdea80
diff --git a/packages/ui/components/editor/Editor.test.tsx b/packages/ui/components/editor/Editor.test.tsx
index f3ca4629d0d..f7b0f776eac 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 ca62a447bf4..01fec94b28d 100644
--- a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx
+++ b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx
@@ -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);