API reference: @salmonui/dropdowns/mention
MentionEditorTargetinterface
import type { MentionEditorTarget } from '@salmonui/dropdowns/mention';interface MentionEditorTarget {
readonly element: HTMLElement;
getTextBeforeCaret(): string | null;
getCaretRect(offset: number): {
readonly left: number;
readonly top: number;
readonly bottom: number;
} | null;
insertMention(insertion: MentionEditorInsertion): void;
subscribe(listener: () => void): () => void;
}
A rich text surface Mention attaches to instead of a <textarea> or
<input>: a plain contenteditable element through
createContentEditableMentionTarget, or the @salmonui/rich-text engine.
Offsets count the characters of the current text block, an inline atom
(an inserted mention) as one U+FFFC character.
| Name | Signature | Description |
|---|---|---|
element | readonly element: HTMLElement; | The editable element (the host gives it |
getTextBeforeCaret | getTextBeforeCaret(): string | null; | Text of the current text block from its start to the caret; |
getCaretRect | getCaretRect(offset: number): {
readonly left: number;
readonly top: number;
readonly bottom: number;
} | null; | Viewport rectangle of the character at |
insertMention | insertMention(insertion: MentionEditorInsertion): void; | Replaces |
subscribe | subscribe(listener: () => void): () => void; | Calls |