///
import { EditorView } from 'prosemirror-view';
import { type EditorDocDetails } from './markup';
import { type MentionAttrs } from './mention';
import { type MentionPortal } from './mention-node-view';
import { type SuggestionState } from './suggestion-plugin';
export interface UseEditorOptions {
/** Markup for the first document. Read once. */
initialMarkup: string;
/** Placeholder shown while the document is empty. */
placeholder?: string;
disabled?: boolean;
spellCheck?: boolean;
/** Cap on the derived plain text — a chip counts as its label. */
maxLength?: number;
/** Trigger characters currently registered by a `Mentions` part. */
getTriggers?: () => string[];
/** Fires for every document change the user made. */
onChange?: (details: EditorDocDetails) => void;
/** Enter with no active menu. */
onSubmit?: () => void;
onSuggestionChange?: (state: SuggestionState | null) => void;
/** Return true to consume the key while a menu is open. */
onSuggestionKeyDown?: (event: KeyboardEvent, state: SuggestionState) => boolean;
}
export interface EditorActions {
focus: () => void;
/**
* Replaces the document when `markup` differs from what the document already
* serializes to. The compare is what keeps a controlled `value` from
* resetting the caret on every keystroke.
*/
setMarkup: (markup: string) => void;
getDetails: () => EditorDocDetails;
insertMention: (attrs: MentionAttrs, range?: {
from: number;
to: number;
}) => void;
/** Applies fresh labels from `resolveMentions` without touching history. */
refreshMentionLabels: (labels: Map) => void;
dismissSuggestion: () => void;
}
export interface UseEditorResult {
/** Attach to the element that becomes the editing host. */
hostRef: (node: HTMLDivElement | null) => void;
/**
* Server and first-client markup for the host: the derived plain text, so a
* restored draft is readable before ProseMirror takes the subtree over.
*/
initialHtml: {
__html: string;
};
viewRef: React.RefObject;
mentionPortals: MentionPortal[];
actions: EditorActions;
}
export declare function useEditor(options: UseEditorOptions): UseEditorResult;
//# sourceMappingURL=use-editor.d.ts.map