@veltdev/tiptap-velt-comments
Version:
Tiptap Extension to add Google Docs-style overlay comments to your Tiptap editor. Works with the Velt Collaboration SDK.
81 lines (80 loc) • 2.94 kB
TypeScript
/**
* Core state management module.
*
* Purpose: Single source of truth for annotation state per editor.
* This module manages annotation data and selected annotations for each editor instance.
*
* Key responsibilities:
* - Create and manage per-editor annotation state
* - CRUD operations for annotations
* - Track selected annotations
* - Ensure state isolation between editor instances
*
* Dependencies: types/state.ts, types/common.ts
*/
import type { AnnotationData, AnnotationState } from '@/types/state';
import type { CommentAnnotation } from '@/types/velt';
/**
* Creates a new annotation state for an editor instance.
*
* @param editorId Unique identifier for the editor
* @returns New AnnotationState instance
*/
export declare const createAnnotationState: (editorId: string) => AnnotationState;
/**
* Updates annotations in state from Velt SDK data.
* Converts CommentAnnotation[] to AnnotationData[] and stores them.
*
* @param editorId Unique identifier for the editor
* @param annotations Array of CommentAnnotation from Velt SDK
*/
export declare const updateAnnotations: (editorId: string, annotations: CommentAnnotation[]) => void;
/**
* Retrieves a single annotation by ID.
*
* @param editorId Unique identifier for the editor
* @param annotationId The annotation ID to retrieve
* @returns AnnotationData or null if not found
*/
export declare const getAnnotation: (editorId: string, annotationId: string) => AnnotationData | null;
/**
* Removes an annotation from state.
*
* @param editorId Unique identifier for the editor
* @param annotationId The annotation ID to remove
*/
export declare const removeAnnotation: (editorId: string, annotationId: string) => void;
/**
* Gets the set of selected annotation IDs for an editor.
*
* @param editorId Unique identifier for the editor
* @returns Set of selected annotation IDs
*/
export declare const getSelectedAnnotations: (editorId: string) => Set<string>;
/**
* Updates the set of selected annotation IDs for an editor.
*
* @param editorId Unique identifier for the editor
* @param selectedIds Set of selected annotation IDs
*/
export declare const setSelectedAnnotations: (editorId: string, selectedIds: Set<string>) => void;
/**
* Gets all annotations for an editor.
*
* @param editorId Unique identifier for the editor
* @returns Map of annotation ID to AnnotationData
*/
export declare const getAllAnnotations: (editorId: string) => Map<string, AnnotationData>;
/**
* Gets all comment annotations for an editor (with status field).
*
* @param editorId Unique identifier for the editor
* @returns Array of CommentAnnotation with status field
*/
export declare const getCommentAnnotations: (editorId: string) => CommentAnnotation[];
/**
* Clears all state for an editor (used during cleanup).
*
* @param editorId Unique identifier for the editor
*/
export declare const clearState: (editorId: string) => void;