@veltdev/tiptap-velt-comments
Version:
Tiptap Extension to add Google Docs-style overlay comments to your Tiptap editor. Works with the Velt Collaboration SDK.
58 lines (57 loc) • 2.14 kB
TypeScript
/**
* Velt SDK adapter.
*
* Purpose: High-level Velt SDK wrapper with comprehensive error handling.
* This is the ONLY place where @veltdev/types and window.Velt may be accessed.
*
* Key responsibilities:
* - Wrap all Velt SDK calls with error handling
* - Provide clean interface for features layer
* - Handle SDK unavailability gracefully
* - Manage subscriptions to Velt events
*
* Dependencies:
* - @veltdev/types (ONLY place allowed to import Velt types)
* - types/common.ts (for CommentAnnotationContext)
* - types/velt.ts (for re-exported Velt types)
* - utils/console.ts (for logging)
*/
import type { CommentAnnotation, CommentElement, Location } from '@veltdev/types';
import type { CommentAnnotationContext } from '@/types/common';
export declare const isVeltAvailable: () => boolean;
/**
* Gets the Velt comment element from the SDK.
* Returns null if SDK is unavailable or comment element cannot be accessed.
*
* @returns CommentElement or null if unavailable
*/
export declare const getCommentElement: () => CommentElement | null;
/**
* Adds a comment via the Velt SDK.
*
* @param params Object containing context and optional location
* @returns Promise resolving to CommentAnnotation or null if failed
*/
export declare const addVeltComment: (params: {
context: CommentAnnotationContext;
location?: Location;
}) => Promise<{
annotation: CommentAnnotation | null;
result: unknown;
}>;
/**
* Updates the context of an existing annotation in the Velt SDK.
*
* @param annotationId The annotation ID to update
* @param context The new context to set
*/
export declare const updateAnnotationContext: (annotationId: string, context: CommentAnnotationContext) => void;
/**
* Subscribes to changes in selected annotations from the Velt SDK.
* Returns an unsubscribe function.
*
* @param callback Function called when selected annotations change
* @param subscriberId Optional unique ID for this subscriber
* @returns Unsubscribe function
*/
export declare const subscribeToSelectedAnnotations: (callback: (selectedIds: Set<string>) => void, subscriberId?: string) => () => void;