This commit is contained in:
Timothy J. Baek 2025-07-15 20:59:28 +04:00
parent 0aabbdd23a
commit fa91795b77

View file

@ -218,12 +218,13 @@
// Empty state, check if we have content to initialize // Empty state, check if we have content to initialize
// check if editor empty as well // check if editor empty as well
const isEmptyEditor = !editor || editor.getText().trim() === ''; const isEmptyEditor = !editor || editor.getText().trim() === '';
if (content && (data?.sessions ?? ['']).length === 1) {
if (isEmptyEditor) { if (isEmptyEditor) {
if (content && (data?.sessions ?? ['']).length === 1) {
const editorYdoc = prosemirrorJSONToYDoc(editor.schema, content); const editorYdoc = prosemirrorJSONToYDoc(editor.schema, content);
if (editorYdoc) { if (editorYdoc) {
Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(editorYdoc)); Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(editorYdoc));
} }
}
} else { } else {
// If the editor already has content, we don't need to send an empty state // If the editor already has content, we don't need to send an empty state
if (this.doc.getXmlFragment('prosemirror').length > 0) { if (this.doc.getXmlFragment('prosemirror').length > 0) {
@ -237,7 +238,6 @@
console.warn('Yjs document is empty, not sending state.'); console.warn('Yjs document is empty, not sending state.');
} }
} }
}
} else { } else {
Y.applyUpdate(this.doc, state, 'server'); Y.applyUpdate(this.doc, state, 'server');
} }