UNPKG

@sereneinserenade/tiptap-inline-suggestion

Version:

Tiptap Extension for adding inline suggestions. Ex. for AI autocompletion.

33 lines (32 loc) 982 B
import { Extension } from "@tiptap/core"; import { PluginKey } from "@tiptap/pm/state"; declare module "@tiptap/core" { interface Commands<ReturnType> { inlineSuggestion: { /** * fetch inline suggestions */ fetchSuggestion: () => ReturnType; }; } } export declare const inlineSuggestionPluginKey: PluginKey<any>; export interface InlineSuggestionOptions { /** * fetch inline suggestions * * @param existingText - existing text in the node * @returns {string} - the suggestion to be shown */ fetchAutocompletion: (existingText: string) => Promise<string>; } export interface InlineSuggestionStorage { data: { currentSuggestion?: string; nodeDetails?: { from: number; to: number; }; }; } export declare const InlineSuggestion: Extension<InlineSuggestionOptions, InlineSuggestionStorage>;