@veltdev/tiptap-velt-comments
Version:
Tiptap Extension to add Google Docs-style overlay comments to your Tiptap editor. Works with the Velt Collaboration SDK.
56 lines (55 loc) • 2.24 kB
TypeScript
/**
* Storage adapter for editor-specific storage access.
*
* Purpose: Abstracts away editor-specific storage patterns.
* This allows the codebase to be more generic and reusable across different editor implementations.
*
* Key responsibilities:
* - Get extension storage from editor instance
* - Get persistVeltMarks setting from storage
* - Get editorId from storage
*
* Dependencies:
* - @tiptap/core (ONLY place allowed to import Editor types for storage access)
* - utils/console.ts (for logging)
*/
import type { Editor } from '@tiptap/core';
import type { ExtensionStorage } from '@/types/host';
/**
* Gets extension storage from editor instance.
*
* @param editor The editor instance
* @param storageKey The storage key (e.g., 'tiptapVeltComments')
* @returns ExtensionStorage or null if not found
*/
export declare const getExtensionStorage: (editor: Editor, storageKey?: string) => ExtensionStorage | null;
/**
* Gets persistVeltMarks setting from storage.
*
* @param editor The editor instance
* @param storageKey The storage key (default: 'tiptapVeltComments')
* @returns persistVeltMarks boolean value (defaults to true)
*/
export declare const getPersistVeltMarks: (editor: Editor, storageKey?: string) => boolean;
/**
* Gets editorId from storage.
*
* @param editor The editor instance
* @param storageKey The storage key (default: 'tiptapVeltComments')
* @returns Editor ID string or undefined if not found
*/
export declare const getEditorIdFromStorage: (editor: Editor, storageKey?: string) => string | undefined;
/**
* Determines if marks should be applied based on persistVeltMarks setting.
* This is a unified adapter function that abstracts the mark application logic.
*
* @param editor The editor instance (typed as unknown to avoid importing editor types in feature modules)
* @param storageKey The storage key (default: 'tiptapVeltComments')
* @returns boolean indicating if marks should be applied
*
* @remarks
* - For TipTap: checks persistVeltMarks setting (apply if FALSE)
* - For Lexical: always returns true (always apply marks)
* - Defaults to true if storage is unavailable
*/
export declare const shouldApplyMark: (editor: unknown, storageKey?: string) => boolean;