@veltdev/tiptap-velt-comments
Version:
Tiptap Extension to add Google Docs-style overlay comments to your Tiptap editor. Works with the Velt Collaboration SDK.
51 lines (50 loc) • 2.12 kB
TypeScript
/**
* Host adapter for marks operations.
*
* Purpose: Tiptap/ProseMirror view operations (applying/removing marks and decorations).
* This is ONE OF ONLY TWO places where Tiptap/ProseMirror types may be imported.
*
* Key responsibilities:
* - Apply annotation marks to editor document
* - Remove annotation marks from editor document
* - Update marks based on annotation changes
*
* Dependencies:
* - @tiptap/core (ONLY place allowed to import Editor types)
* - types/host.ts (for AnnotationChange)
* - utils/console.ts (for logging)
*/
import type { Editor } from '@tiptap/core';
import type { AnnotationChange } from '@/types/host';
/**
* Applies an annotation mark to the editor document at the specified position.
* This is a unified adapter function that matches Lexical's signature.
*
* @param editor The editor instance (typed as unknown to avoid importing editor types in feature modules)
* @param annotationId The annotation ID to mark
* @param multiThreadAnnotationId Optional multi-thread annotation ID
* @param from Start position of the mark
* @param to End position of the mark
* @returns True if mark was successfully applied, false otherwise
*/
export declare const applyAnnotationMark: (editor: unknown, annotationId: string, multiThreadAnnotationId: string | undefined, from: number, to: number) => boolean;
/**
* Removes an annotation mark from the editor document.
*
* @param editor The editor instance
* @param annotationId The annotation ID to remove
* @param position Optional position range { from, to } to scope removal
* @returns True if mark was successfully removed, false otherwise
*/
export declare const removeAnnotationMark: (editor: Editor, annotationId: string, position?: {
from: number;
to: number;
}) => boolean;
/**
* Updates marks based on annotation changes.
* This efficiently diffs the changes and updates only what's necessary.
*
* @param editor The editor instance
* @param changes Map of annotation ID to AnnotationChange
*/
export declare const updateMarks: (editor: Editor, changes: Map<string, AnnotationChange>) => void;