@assistant-ui/react
Version:
Open-source TypeScript/React library for building production-grade AI chat experiences
18 lines • 854 B
TypeScript
export type TriggerMatch = {
readonly query: string;
readonly offset: number;
readonly endOffset: number;
};
/**
* Locates a trigger query in `text` relative to `cursorPosition`.
*
* `offset` is the index of `triggerChar`. `endOffset` is the exclusive end of
* the span both the textarea and Lexical replace on select. `query` is the
* search string and may differ from that span.
*
* Return null when the caret is at or before the trigger. Escape moves the
* caret to `offset` so a match there would reopen the popover.
*/
export type TriggerMatcher = (text: string, triggerChar: string, cursorPosition: number) => TriggerMatch | null;
export declare function resolveTriggerMatch(text: string, triggerChar: string, cursorPosition: number, match: TriggerMatch | null): TriggerMatch | null;
//# sourceMappingURL=detectTrigger.d.ts.map