# Mention Menu ## Example ```svelte {#if $editor} {#snippet item({ item: mentionItem, isActive, select })} {/snippet} {/if} ``` ## Documentation ## Usage Add `MentionNode` via `extraExtensions`, then render `MentionMenu` as a child — similar to how `BubbleMenu` and `FloatingMenu` work in svelte-tiptap. ```svelte {#if $editor} {#snippet item({ item: mentionItem, isActive, select })} {/snippet} {/if} ``` ## Custom rendering The `item` snippet receives `{ item, isActive, select }`. Use this to fully customize how each suggestion looks — add avatars, secondary text, keyboard highlight styling, etc. If no `item` snippet is provided, a minimal default rendering is used. ## How it works `MentionNode` is a tiptap Node extension that defines an inline, non-editable mention node with `id`, `label`, and optional `data` attributes. `MentionMenu` follows the same pattern as svelte-tiptap's `BubbleMenu` — it takes an `editor` prop and registers a suggestion plugin on mount. The popup is positioned using `@floating-ui/dom` and supports keyboard navigation (Arrow keys + Enter + Escape). ## Works with any editor Both `CoreRichTextEditor` and `RichTextEditor` support `extraExtensions` to add extensions without replacing defaults. You can also use `MentionNode` + `MentionMenu` with any tiptap editor setup. ## API Reference ### MentionMenu A suggestion popup component for @mentions. Registers a tiptap suggestion plugin on mount, like BubbleMenu/FloatingMenu. | Prop | Type | Default | Description | |------|------|---------|-------------| | editor | `Editor` | `-` | The tiptap editor instance. (required) | | items | `(query: string) => MentionItem[] | Promise` | `-` | Function that returns mention suggestions for a search query. (required) | | char | `string` | `'@'` | Trigger character for the mention popup. | | minQueryLength | `number` | `2` | Minimum characters after trigger before searching. | | pluginKey | `string` | `'mentionMenu'` | Unique key for the suggestion plugin. | | item | `Snippet<[{ item: MentionItem; isActive: boolean; select: () => void }]>` | `-` | Snippet for custom rendering of each suggestion item. | | class | `string` | `-` | CSS classes for the popup container. | ### MentionNode A tiptap Node extension for inline mention nodes. Add to editor extensions to enable mentions. | Prop | Type | Default | Description | |------|------|---------|-------------| | HTMLAttributes | `Record` | `{}` | HTML attributes applied to mention nodes. | | renderLabel | `({ node }) => string` | `'({ node }) => `@${node.attrs.label}`'` | Custom function to render the mention label text. | ### MentionItem The data shape for mention suggestions. | Prop | Type | Default | Description | |------|------|---------|-------------| | id | `string` | `-` | Unique identifier for the mention (e.g., user ID, DID). (required) | | label | `string` | `-` | Display label for the mention (e.g., username, handle). (required) | | avatar | `string` | `-` | Optional avatar URL. | | data | `Record` | `-` | Optional extra data stored on the mention node. |