superdocId
console.log(superdoc.superdocId); // "550e8400-e29b-41d4-a716-446655440000"
version
console.log(superdoc.version); // "2.1.0"
activeEditor
if (superdoc.activeEditor) { // Direct ProseMirror access superdoc.activeEditor.commands.toggleBold(); // Access state const { doc, selection } = superdoc.activeEditor.state; // Access view superdoc.activeEditor.view.focus(); }
if (superdoc.isLocked) { console.log(`Locked by ${superdoc.lockedBy.name}`); } if (superdoc.isCollaborative) { showCollaboratorsList(); }
Show User properties
superdoc.users.forEach(user => { console.log(`${user.name} (${user.email})`); });
if (superdoc.toolbar) { superdoc.toolbar.updateToolbarState(); }
if (superdoc.provider) { superdoc.provider.on('synced', () => { console.log('Synced with server'); }); }
const documents = superdoc.superdocStore.documents; documents.forEach(doc => { console.log(doc.id, doc.type); });
const comments = superdoc.commentsStore.comments; console.log(`${comments.length} comments`);
const isHighContrast = superdoc.highContrastModeStore.isEnabled;
// ❌ Don't modify directly superdoc.isLocked = true; superdoc.activeEditor = newEditor; // ✅ Use methods superdoc.lockSuperdoc(true); superdoc.setActiveEditor(newEditor);
// Always check nullable properties if (superdoc.activeEditor) { superdoc.activeEditor.focus(); } if (superdoc.toolbar) { superdoc.toolbar.updateState(); }
superdoc.once('ready', () => { // Now safe to access console.log(superdoc.activeEditor); console.log(superdoc.toolbar); });
// Get ProseMirror state const getSelection = () => { if (!superdoc.activeEditor) return null; const { from, to } = superdoc.activeEditor.state.selection; return { from, to }; }; // Execute commands const makeBold = () => { superdoc.activeEditor?.commands.toggleBold(); };
Was this page helpful?