@veltdev/tiptap-velt-comments
Version:
Tiptap Extension to add Google Docs-style overlay comments to your Tiptap editor. Works with the Velt Collaboration SDK.
53 lines (52 loc) • 1.86 kB
TypeScript
/**
* Core registry module.
*
* Purpose: Maintains a registry mapping editorId → editor context.
* Replaces the singleton pattern from legacy Plugin class with a proper registry.
*
* Key responsibilities:
* - Register editor instances with their configuration
* - Retrieve editor contexts by ID
* - Unregister editors when they're destroyed
* - Extract editor IDs from editor instances
*
* Dependencies: types/common.ts, core/state.ts, adapters/host/doc.ts
*/
import type { EditorContext, ExtensionConfig } from '@/types/common';
/**
* Registers an editor instance in the registry.
* Creates initial state for the editor.
*
* @param editorId Unique identifier for the editor
* @param editor The editor instance
* @param config Extension configuration options
* @returns EditorContext for the registered editor
*/
export declare const registerEditor: <TEditor = unknown>(editorId: string, editor: TEditor, config?: ExtensionConfig) => EditorContext<TEditor>;
/**
* Retrieves the editor context for a given editor ID.
*
* @param editorId Unique identifier for the editor
* @returns EditorContext or null if not found
*/
export declare const getEditorContext: <TEditor = unknown>(editorId: string) => EditorContext<TEditor> | null;
/**
* Unregisters an editor from the registry and cleans up its state.
*
* @param editorId Unique identifier for the editor
*/
export declare const unregisterEditor: (editorId: string) => void;
/**
* Extracts the editor ID from an editor instance.
* Checks editor storage first, then DOM attributes.
*
* @param editor The editor instance
* @returns Editor ID or null if not found
*/
export declare const getEditorIdFromEditor: (editor: unknown) => string | null;
/**
* Gets all registered editor IDs.
*
* @returns Array of editor IDs
*/
export declare const getAllEditorIds: () => string[];