interface UseMentionAutocompleteResult

Returned by useMentionAutocomplete to TextEditor.

Properties

mentionOpen: boolean

Set only once a search has found someone.

syncMention: (
value: string,
pos: number,
lookup: boolean
) => void

Follows the @query under the caret, searches for it 150 ms after the last keystroke, and closes the list once the caret leaves it. The caller calls it on every change with lookup set, and on every caret move without, since only typing may search.

closeMention: () => void

Handles the arrows, Enter, Tab and Escape while the list is shown, and returns whether it took the key. The caller must then leave the key alone.

handleMentionSelect: (username: string) => void

Inserts @username through replace and closes the list.

Usage

import { type UseMentionAutocompleteResult } from "src/hooks/editor/useMentionAutocomplete.ts";