import { EventEmitter } from 'eventemitter3'; import { Whiteboard } from './whiteboard/Whiteboard'; import { SuperToolbar } from '../../../super-editor/src/index.js'; import { SuperComments } from '../components/CommentsLayer/commentsList/super-comments-list.js'; /** @typedef {import('./types').User} User */ /** @typedef {import('./types').Document} Document */ /** @typedef {import('./types').Modules} Modules */ /** @typedef {import('./types').Editor} Editor */ /** @typedef {import('./types').DocumentMode} DocumentMode */ /** @typedef {import('./types').Config} Config */ /** @typedef {import('./types').ExportParams} ExportParams */ /** @typedef {import('./types').UpgradeToCollaborationOptions} UpgradeToCollaborationOptions */ /** @typedef {import('./types').SurfaceRequest} SurfaceRequest */ /** @typedef {import('./types').SurfaceHandle} SurfaceHandle */ /** * SuperDoc class * Expects a config object * * @class * @extends EventEmitter */ export class SuperDoc extends EventEmitter { /** @type {Array} */ static allowedTypes: Array; /** * @param {Config} config */ constructor(config: Config); /** @type {string} */ version: string; /** @type {User[]} */ users: User[]; /** @type {import('yjs').Doc | undefined} */ ydoc: import('yjs').Doc | undefined; /** @type {import('@hocuspocus/provider').HocuspocusProvider | undefined} */ provider: import('@hocuspocus/provider').HocuspocusProvider | undefined; /** @type {Whiteboard | null} */ whiteboard: Whiteboard | null; /** @type {Config} */ config: Config; userColorMap: Map | undefined; colorIndex: number | undefined; superdocId: any; colors: string[] | undefined; user: import('./types').User | undefined; socket: any; isDev: boolean | undefined; /** @type {Editor | null | undefined} */ activeEditor: Editor | null | undefined; comments: any[] | undefined; isLocked: boolean | undefined; lockedBy: import('./types').User | null | undefined; readyEditors: number | undefined; /** * Get the number of editors that are required for this superdoc * @returns {number} The number of required editors */ get requiredNumberOfEditors(): number; get state(): { documents: any; users: import('./types').User[]; }; /** * Get the SuperDoc container element * @returns {HTMLElement | null} */ get element(): HTMLElement | null; app: any; pinia: any; superdocStore: any; commentsStore: any; highContrastModeStore: any; isCollaborative: boolean | undefined; _commentsCollabInitialized: boolean | undefined; _cleanupAwareness: (() => void) | null | undefined; /** * Upgrade a local SuperDoc instance into collaboration by overwriting * the supplied room with the current local document and comment state, * then attaching collaboration to the live editor instance in place. * * This is a **destructive promotion**: the target room is authoritatively * overwritten with the caller's current local state. It is NOT the API * for joining an existing room without changing its content. * * Currently limited to: * - A single DOCX document * - External `{ ydoc, provider }` collaboration * - Overwrite-and-upgrade only (no merge semantics) * * @param {UpgradeToCollaborationOptions} options * @returns {Promise} Resolves once the collaborative runtime is ready */ upgradeToCollaboration({ ydoc, provider }: UpgradeToCollaborationOptions): Promise; /** * Add a user to the shared users list * @param {Object} user The user to add * @returns {void} */ addSharedUser(user: Object): void; /** * Remove a user from the shared users list * @param {String} email The email of the user to remove * @returns {void} */ removeSharedUser(email: string): void; /** * Triggered when there is an error in the content * @param {Object} param0 * @param {Error} param0.error The error that occurred * @param {Editor} param0.editor The editor that caused the error */ onContentError({ error, editor }: { error: Error; editor: Editor; }): void; /** * Triggered when the PDF document is ready * @returns {void} */ broadcastPdfDocumentReady(): void; /** * Triggered when the superdoc is ready * @returns {void} */ broadcastReady(): void; /** * Triggered before an editor is created * @param {Editor} editor The editor that is about to be created * @returns {void} */ broadcastEditorBeforeCreate(editor: Editor): void; /** * Triggered when an editor is created * @param {Editor} editor The editor that was created * @returns {void} */ broadcastEditorCreate(editor: Editor): void; /** * Triggered when an editor is destroyed * @returns {void} */ broadcastEditorDestroy(): void; /** * Triggered when the comments sidebar is toggled * @param {boolean} isOpened */ broadcastSidebarToggle(isOpened: boolean): void; /** * Set the active editor * @param {Editor} editor The editor to set as active * @returns {void} */ setActiveEditor(editor: Editor): void; /** * Toggle the ruler visibility for SuperEditors * * @returns {void} */ toggleRuler(): void; /** * Determine whether the current configuration allows a given permission. * Used by downstream consumers (toolbar, context menu, commands) to keep * tracked-change affordances consistent with customer overrides. * * @param {Object} params * @param {string} params.permission Permission key to evaluate * @param {string} [params.role=this.config.role] Role to evaluate against * @param {boolean} [params.isInternal=this.config.isInternal] Internal/external flag * @param {Object|null} [params.comment] Comment object (if already resolved) * @param {Object|null} [params.trackedChange] Tracked change metadata (id, attrs, etc.) * @returns {boolean} */ canPerformPermission({ permission, role, isInternal, comment, trackedChange, }?: { permission: string; role?: string | undefined; isInternal?: boolean | undefined; comment?: Object | null | undefined; trackedChange?: Object | null | undefined; }): boolean; toolbarElement: any; toolbar: SuperToolbar | null | undefined; /** * Add a comments list to the superdoc * Requires the comments module to be enabled * @param {Element} element The DOM element to render the comments list in * @returns {void} */ addCommentsList(element: Element): void; commentsList: SuperComments | null | undefined; /** * Remove the comments list from the superdoc * @returns {void} */ removeCommentsList(): void; /** * Scroll the document to a given comment by id. * * @param {string} commentId The comment id * @param {{ behavior?: ScrollBehavior, block?: ScrollLogicalPosition }} [options] * @returns {boolean} Whether a matching element was found */ scrollToComment(commentId: string, options?: { behavior?: ScrollBehavior; block?: ScrollLogicalPosition; }): boolean; /** * Scroll to any document element by its ID. * * Pass any element ID — paragraph nodeId, comment entityId, or tracked * change entityId. The method resolves the element type automatically * and scrolls to it. * * @param {string} elementId - The element's stable ID. * @returns {Promise} Whether the element was found and scrolled to. * * @example * // Navigate to a paragraph by its nodeId * await superdoc.scrollToElement('5AF80E61'); * * // Navigate to a comment by its entityId * await superdoc.scrollToElement('imported-25def254'); */ scrollToElement(elementId: string): Promise; /** * Toggle the custom context menu globally. * Updates both flow editors and PresentationEditor instances so downstream listeners can short-circuit early. * @param {boolean} disabled */ setDisableContextMenu(disabled?: boolean): void; /** * Triggered when a toolbar command is executed * @param {Object} param0 * @param {Object} param0.item The toolbar item that was clicked * @param {string} param0.argument The argument passed to the command */ onToolbarCommand({ item, argument }: { item: Object; argument: string; }): void; /** * Set the document mode. * @param {DocumentMode} type * @returns {void} */ setDocumentMode(type: DocumentMode): void; /** * Force PresentationEditor instances to render a specific tracked-changes mode * or disable tracked-change metadata entirely. * * @param {{ mode?: 'review' | 'original' | 'final' | 'off', enabled?: boolean }} [preferences] */ setTrackedChangesPreferences(preferences?: { mode?: "review" | "original" | "final" | "off"; enabled?: boolean; }): void; /** * Search for text or regex in the active editor * @param {string | RegExp} text The text or regex to search for * @returns {Object[]} The search results */ search(text: string | RegExp): Object[]; /** * Go to the next search result * @param {Object} match The match object * @returns {void} */ goToSearchResult(match: Object): void; /** * Get the current zoom level as a percentage (e.g., 100 for 100%) * @returns {number} The current zoom level as a percentage * @example * const zoom = superdoc.getZoom(); // Returns 100, 150, 200, etc. */ getZoom(): number; /** * Set the zoom level for all documents. * Updates the centralized activeZoom state, which propagates to all * presentation editors, PDF viewers, and whiteboard layers via the Vue watcher. * @param {number} percent - The zoom level as a percentage (e.g., 100, 150, 200) * @example * superdoc.setZoom(150); // Set zoom to 150% * superdoc.setZoom(50); // Set zoom to 50% */ setZoom(percent: number): void; /** * Set the document to locked or unlocked * @param {boolean} lock */ setLocked(lock?: boolean): void; /** * Get the HTML content of all editors * @returns {Array} The HTML content of all editors */ getHTML(options?: {}): Array; /** * Lock the current superdoc * @param {Boolean} isLocked * @param {User} lockedBy The user who locked the superdoc */ lockSuperdoc(isLocked: boolean, lockedBy: User): void; /** * Export the superdoc to a file * @param {ExportParams} params - Export configuration * @returns {Promise} */ export({ exportType, commentsType, exportedName, additionalFiles, additionalFileNames, isFinalDoc, triggerDownload, fieldsHighlightColor, }?: ExportParams): Promise; /** * Export editors to DOCX format. * @param {{ commentsType?: string, isFinalDoc?: boolean, fieldsHighlightColor?: string }} [options] * @returns {Promise>} */ exportEditorsToDOCX({ commentsType, isFinalDoc, fieldsHighlightColor }?: { commentsType?: string; isFinalDoc?: boolean; fieldsHighlightColor?: string; }): Promise>; pendingCollaborationSaves: number | undefined; /** * Save the superdoc if in collaboration mode * @returns {Promise} Resolves when all documents have saved */ save(): Promise; /** * Open a surface (dialog or floating) above the document content. * * @template [TResult=unknown] * @param {SurfaceRequest} request * @returns {SurfaceHandle} */ openSurface(request: SurfaceRequest): SurfaceHandle; /** * Close a surface by id, or the topmost surface if no id is given. * @param {string} [id] */ closeSurface(id?: string): void; /** * Destroy the superdoc instance * @returns {void} */ destroy(): void; /** * Focus the active editor or the first editor in the superdoc * @returns {void} */ focus(): void; /** * Set the high contrast mode * @param {boolean} isHighContrast * @returns {void} */ setHighContrastMode(isHighContrast: boolean): void; #private; } export type User = import('./types').User; export type Document = import('./types').Document; export type Modules = import('./types').Modules; export type Editor = import('./types').Editor; export type DocumentMode = import('./types').DocumentMode; export type Config = import('./types').Config; export type ExportParams = import('./types').ExportParams; export type UpgradeToCollaborationOptions = import('./types').UpgradeToCollaborationOptions; export type SurfaceRequest = import('./types').SurfaceRequest; export type SurfaceHandle = import('./types').SurfaceHandle; //# sourceMappingURL=SuperDoc.d.ts.map