UNPKG

@veltdev/tiptap-velt-comments

Version:

Tiptap Extension to add Google Docs-style overlay comments to your Tiptap editor. Works with the Velt Collaboration SDK.

48 lines (47 loc) 1.99 kB
/** * Comment renderer module. * * Purpose: Handle filtering, comparison, and mark updates for comment annotations. * This module manages the rendering state and applies marks based on resolved/selected status. * * Key responsibilities: * - Filter annotations based on status (terminal/resolved) and selected state * - Compare previous vs current filtered annotations to detect removals * - Remove marks for annotations that should no longer be shown * - Re-apply marks for all filtered annotations * * Dependencies: * - core/state.ts (for reading annotations and selected state) * - adapters/host/doc.ts (for finding text occurrences) * - adapters/host/marks.ts (for applying/removing marks) * - types/velt.ts (for CommentAnnotation) * - utils/console.ts (for logging) * * IMPORTANT: This module MUST NOT import editor or Velt types directly. * All SDK access goes through adapters. */ import type { CommentAnnotation } from '@/types/velt'; /** * Updates comments for an editor by filtering, comparing, removing, and re-applying marks. * This is the core rendering logic that handles resolved comment filtering. * * @param editorId Unique identifier for the editor * @param editor The editor instance * @param annotations All CommentAnnotation from Velt SDK (with status) */ export declare const updateComments: (editorId: string, editor: unknown, annotations: CommentAnnotation[]) => void; /** * Updates comments when selected annotations change. * Re-reads annotations from state and triggers re-rendering. * * @param editorId Unique identifier for the editor * @param selectedIds Set of selected annotation IDs (already updated in state) */ export declare const updateSelection: (editorId: string, selectedIds: Set<string>) => void; /** * Cleans up renderer store for an editor. * Should be called when editor is destroyed. * * @param editorId Unique identifier for the editor */ export declare const cleanupRenderer: (editorId: string) => void;