{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mention-docs",
  "title": "Mention",
  "description": "Inline markable void mentions backed by trigger combobox input.",
  "files": [
    {
      "path": "../../content/docs/(plugins)/(elements)/mention.mdx",
      "content": "---\ntitle: Mention\ndescription: Inline markable void mentions backed by trigger combobox input.\ndocs:\n  - route: /docs/combobox\n    title: Combobox\n  - route: /docs/components/mention-node\n    title: Mention Nodes\n  - route: /docs/components/inline-combobox\n    title: Inline Combobox\n---\n\nMention turns trigger text such as `@` into an inline combobox input and inserts a markable void `mention` node when the user selects an item. The package owns trigger detection, input node creation, mention insertion, selection movement, and Markdown mention serialization. The registry owns the demo item list and the inline combobox UI.\n\n<ComponentPreview name=\"mention-demo\" />\n\n<PackageInfo>\n\n## Features\n\n- Inline void `mention` nodes with `value` and optional `key`.\n- Inline void `mention_input` nodes created by trigger text.\n- Trigger combobox support from `@platejs/combobox`.\n- Configurable trigger strings, regexes, and trigger queries.\n- Markable void rendering so bold, italic, and underline can style a mention.\n- Optional trailing space after selected mention items.\n- Markdown format through `[display text](mention:id)` plus bare `@name` deserialization.\n\n</PackageInfo>\n\n## Fast Path\n\n<Steps>\n\n### Add The Kit\n\n`MentionKit` installs `MentionPlugin`, `MentionInputPlugin`, the registry mention nodes, and a trigger rule that allows `@` at the start of a line, after whitespace, or after quotes.\n\n<ComponentSource name=\"mention-kit\" />\n\n```tsx\nimport { createPlateEditor } from 'platejs/react';\n\nimport { MentionKit } from '@/components/editor/plugins/mention-kit';\n\nexport const editor = createPlateEditor({\n  plugins: MentionKit,\n});\n```\n\n### Render Mentions\n\n`mention-node` renders both the selected mention and the temporary combobox input. The demo data lives in that registry UI file, so replace it with your app users, pages, or records.\n\n<ComponentSource name=\"mention-node\" />\n\n### Add Static Rendering\n\n`mention-base-kit` uses `BaseMentionPlugin` with the static mention node for read-only output.\n\n<ComponentSource name=\"mention-base-kit\" />\n\n</Steps>\n\n## Ownership\n\n| Layer | Owner | What It Does |\n|-------|-------|--------------|\n| `@platejs/mention` | Package | Exports `BaseMentionPlugin`, `BaseMentionInputPlugin`, and `getMentionOnSelectItem`. |\n| `@platejs/mention/react` | Package | Exports `MentionPlugin` and `MentionInputPlugin`. |\n| `@platejs/combobox` | Package | Provides `withTriggerCombobox`, trigger options, and combobox input hooks. |\n| `mention-kit` | Registry | Adds mention plugins with editable mention and input components. |\n| `mention-base-kit` | Registry | Adds `BaseMentionPlugin.withComponent(MentionElementStatic)`. |\n| `mention-node` | Registry UI | Renders mention atoms, the inline combobox input, and demo items. |\n| `inline-combobox` | Registry UI | Renders the Ariakit-backed popover, input, groups, items, and empty state. |\n| `@platejs/markdown` | Package | Serializes mentions as `mention:` links and deserializes mention links or bare mentions. |\n\n## Manual Setup\n\n<Steps>\n\n### Install Package\n\n```bash\nnpm install @platejs/mention\n```\n\n### Add Plugins\n\nConfigure the mention plugin with the trigger behavior and render both node types.\n\n```tsx\nimport { MentionInputPlugin, MentionPlugin } from '@platejs/mention/react';\nimport { createPlateEditor } from 'platejs/react';\n\nimport {\n  MentionElement,\n  MentionInputElement,\n} from '@/components/ui/mention-node';\n\nexport const editor = createPlateEditor({\n  plugins: [\n    MentionPlugin.configure({\n      options: {\n        triggerPreviousCharPattern: /^$|^[\\s\"']$/,\n      },\n    }).withComponent(MentionElement),\n    MentionInputPlugin.withComponent(MentionInputElement),\n  ],\n});\n```\n\n### Select An Item\n\nUse `getMentionOnSelectItem` from your combobox item renderer. It inserts the mention, moves the cursor after it, and inserts a trailing space only when `insertSpaceAfterMention` is enabled and the mention lands at the end of the block.\n\n```tsx\nimport { getMentionOnSelectItem } from '@platejs/mention';\n\nconst onSelectItem = getMentionOnSelectItem();\n\n<InlineComboboxItem\n  value={item.text}\n  onClick={() => onSelectItem(editor, item, search)}\n>\n  {item.text}\n</InlineComboboxItem>;\n```\n\n</Steps>\n\n## Value Shape\n\n`BaseMentionPlugin` uses `KEYS.mention`, which resolves to the `mention` node type. The input plugin uses `KEYS.mentionInput`, which resolves to `mention_input`.\n\n```tsx\nconst value = [\n  {\n    children: [\n      { text: 'Assigned to ' },\n      {\n        children: [{ text: '' }],\n        key: 'user_123',\n        type: 'mention',\n        value: 'Jane Smith',\n      },\n      { text: '.' },\n    ],\n    type: 'p',\n  },\n];\n```\n\n| Field | Type | Notes |\n|-------|------|-------|\n| `type` | `'mention'` | Inline void mention node. |\n| `value` | `string` | Display text rendered by the registry node. |\n| `key` | `unknown` | Optional stable id used by selection handlers and Markdown serialization. |\n| `children` | `[{ text: '' }]` | Empty child required for Slate inline void nodes. |\n\nThe mention node is `isMarkableVoid`, so marks on its empty child can style the rendered mention.\n\n## Trigger Flow\n\n`withTriggerCombobox` overrides `insertText`. It creates a combobox input only when every gate passes.\n\n| Gate | Source |\n|------|--------|\n| Inserted text matches `trigger` | `string`, `string[]`, or `RegExp`. |\n| Insert is not using `options.at` | Programmatic text insertion bypasses the trigger. |\n| Editor has a selection | No selection means no inline input target. |\n| `triggerQuery(editor)` returns true | Optional app veto for custom contexts. |\n| Previous character matches `triggerPreviousCharPattern` | Defaults to `/^\\s?$/`; registry kit uses `/^$\\|^[\\s\"']$/`. |\n\nThe default `createComboboxInput` creates:\n\n```tsx\n{\n  children: [{ text: '' }],\n  trigger: '@',\n  type: KEYS.mentionInput,\n}\n```\n\nIf `editor.meta.userId` exists, the combobox input stores that `userId` so only the creator sees the transient input in collaborative editors.\n\n## Markdown\n\n`@platejs/markdown` serializes mentions as link-style `mention:` URLs. It uses `key` for the URL when present and `value` for the visible text.\n\n```md\nHello [Jane Smith](mention:user_123).\n```\n\nDeserialization supports link-style mentions and bare `@alice` text. Normal links such as `[@docs](/docs/mention)` stay links.\n\n## API Reference\n\n| API | Package | Use |\n|-----|---------|-----|\n| `BaseMentionPlugin` | `@platejs/mention` | Headless inline markable void mention plugin with trigger-combobox behavior. |\n| `BaseMentionInputPlugin` | `@platejs/mention` | Inline void input node inserted while the combobox is active. |\n| `MentionPlugin` | `@platejs/mention/react` | React mention plugin. |\n| `MentionInputPlugin` | `@platejs/mention/react` | React mention input plugin. |\n| `editor.tf.insert.mention({ key, value })` | `BaseMentionPlugin` transform | Inserts the mention node at the current selection. |\n| `getMentionOnSelectItem({ key? })` | `@platejs/mention` | Returns an item handler for mention combobox selection. |\n| `withTriggerCombobox` | `@platejs/combobox` | Creates temporary combobox input nodes from trigger text. |\n| `useComboboxInput` | `@platejs/combobox/react` | Handles focus, cancellation, arrow/backspace/escape behavior, and undo/redo forwarding for custom input UI. |\n",
      "type": "registry:file",
      "target": "content/docs/plate/(plugins)/(elements)/mention.mdx"
    }
  ],
  "type": "registry:file"
}