import { Extension } from '@tiptap/core'; import { Node } from 'prosemirror-model'; import { Transaction } from 'prosemirror-state'; import { DecorationSet, EditorView } from 'prosemirror-view'; interface ITextWithPosition { offset: number; length: number; word: string; } interface IProofreaderInterface { proofreadText(sentence: string): Promise; getSuggestions(word: string): Promise; normalizeTextForLanguage(text: string): string; } declare class Spellchecker { get completeProofreadingDone(): boolean; debouncedProofreadDoc: (doc: Node) => void; debouncedGetMatchAndSetDecorations: (node: Node, text: string, originalFrom: number) => void; debouncedClickEventsListener: (e: Event) => void; debouncedAcceptSuggestionEventsListener: (e: Event) => void; private proofreader; private uiStrings?; private showSuggestionsEvent?; private decorationSet; private editorView?; private isInitialProofreadingDone; private lastOriginalFrom; private readonly suggestionBox; constructor(proofreader: IProofreaderInterface, uiStrings?: IUiStrings, showSuggestionsEvent?: (word: string) => void); setDecorationSet(decorationSet: DecorationSet): void; getDecorationSet(): DecorationSet; setEditorView(editorView: EditorView): void; getEditorView(): EditorView | undefined; getSuggestionBox(): HTMLDivElement; hideSuggestionBox(): void; /** * This function is called on initial load of the editor and when content is pasted into the editor. * For manual modificaitons, only the changed nodes are spellchecked again. * * @param doc */ proofreadDoc(doc: Node): void; getMatchAndSetDecorations(node: Node, text: string, originalFrom: number): Promise; addEventListenersToDecorations(): void; addEventListenersToSuggestionBox(): void; dispatch(tr: Transaction): void; findChangedTextNodes(node: Node, pos: number, from: number, to: number): false | undefined; onNodeChanged(node: Node, text: string, originalFrom: number): void; private clickEventsListener; private acceptSuggestionListener; private addSuggestionsList; } interface IUiStrings { noSuggestions?: string; } interface ISpellcheckerOptions { proofreader?: IProofreaderInterface; uiStrings?: IUiStrings; onShowSuggestionsEvent?: (word: string) => void; } interface ISpellcheckerStorage { didPaste: boolean; spellchecker?: Spellchecker; } declare module '@tiptap/core' { interface Commands { spellchecker: { checkSpelling: () => ReturnType; }; } } declare const SpellcheckerExtension: Extension; export { type IProofreaderInterface, type ITextWithPosition, SpellcheckerExtension as default };