diff --git a/src/components/EditorInput.jsx b/src/components/EditorInput.jsx index 7cc0395..f3f3876 100644 --- a/src/components/EditorInput.jsx +++ b/src/components/EditorInput.jsx @@ -10,7 +10,7 @@ const LexicalEditorInput = (props) => { const [defaultHtml, setDefaultHtml] = useState(''); useEffect(() => { - if (typeof value === 'string' && !isEmpty(value)) { + if (typeof value === 'string') { setDefaultHtml(value) } diff --git a/src/components/LexicalEditor/Index.jsx b/src/components/LexicalEditor/Index.jsx index b0cfa13..5aaa0da 100644 --- a/src/components/LexicalEditor/Index.jsx +++ b/src/components/LexicalEditor/Index.jsx @@ -77,27 +77,31 @@ const editorConfig = { ] }; -function LexicalDefaultValuePlugin({ value = "" }= {}) { +function LexicalDefaultValuePlugin({ value = '' }= {}) { const [editor] = useLexicalComposerContext(); const updateHTML = (editor, value, clear) => { const root = $getRoot(); - const parser = new DOMParser(); - const dom = parser.parseFromString(value, "text/html"); - const nodes = $generateNodesFromDOM(editor, dom); if (clear) { root.clear(); } - nodes.filter(n => n.__size !== 0).forEach((n) => { - const paragraphNode = $createParagraphNode(); - paragraphNode.append(n); - root.append(paragraphNode); - }); + if (isEmpty(value)) { + root.clear(); + } else { + const parser = new DOMParser(); + const dom = parser.parseFromString(value, "text/html"); + const nodes = $generateNodesFromDOM(editor, dom); + nodes.filter(n => n.__size !== 0).forEach((n) => { + const paragraphNode = $createParagraphNode(); + paragraphNode.append(n); + root.append(paragraphNode); + }); + } }; useEffect(() => { - if (editor && !isEmpty(value)) { + if (editor) { editor.update(() => { updateHTML(editor, value, true); }); diff --git a/src/views/Conversations/Online/ConversationsNewItem.jsx b/src/views/Conversations/Online/ConversationsNewItem.jsx index 2b9acde..1406afe 100644 --- a/src/views/Conversations/Online/ConversationsNewItem.jsx +++ b/src/views/Conversations/Online/ConversationsNewItem.jsx @@ -91,7 +91,6 @@ export const ConversationItemFormModal = ({ open, onCreate, onCancel, initialVal const [initialValues, setInitialValues] = useState({}); useEffect(() => { - console.info('_initialValues: %o', _initialValues) setInitialValues({ ..._initialValues, phone_number: _initialValues?.whatsapp_phone_number || _initialValues?.phone_number || '',