This commit is contained in:
Timothy Jaeryang Baek
2026-01-05 17:44:44 +04:00
parent 3f577c0c3f
commit e27fb3e291
2 changed files with 16 additions and 5 deletions
@@ -131,9 +131,17 @@ export class SocketIOCollaborationProvider {
const isEmptyEditor = !this.editor?.getText().trim();
if (isEmptyEditor && this.editor) {
if (this.initialContent && (data?.sessions ?? ['']).length === 1) {
const editorYdoc = prosemirrorJSONToYDoc(this.editor.schema, this.initialContent);
if (editorYdoc) {
Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(editorYdoc));
// Check if initialContent is HTML (string) or JSON (object)
if (typeof this.initialContent === 'string') {
// HTML content - let the editor parse it, then sync to Yjs
this.editor.commands.setContent(this.initialContent);
// The Yjs plugin will automatically sync the content
} else {
// JSON content - use the existing approach
const editorYdoc = prosemirrorJSONToYDoc(this.editor.schema, this.initialContent);
if (editorYdoc) {
Y.applyUpdate(this.doc, Y.encodeStateAsUpdate(editorYdoc));
}
}
}
} else {