{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "code-docs",
  "title": "Code",
  "description": "Add inline code formatting.",
  "files": [
    {
      "path": "../../content/docs/(plugins)/(marks)/code.mdx",
      "content": "---\ntitle: Code\ndescription: Add inline code formatting.\ndocs:\n  - route: /docs/basic-marks\n    title: Basic Marks\n  - route: /docs/components/code-node\n    title: Code Leaf\n  - route: /docs/components/mark-toolbar-button\n    title: Mark Toolbar Button\n  - route: /docs/code-block\n    title: Code Block\n---\n\nCode applies the `code` leaf mark to inline text. Use [Code Block](/docs/code-block) for fenced or multiline code; this page is only for inline code spans.\n\n<ComponentPreview name=\"basic-marks-demo\" />\n\n<PackageInfo>\n\n## Features\n\n- `KEYS.code` leaf mark.\n- Hard selection affinity.\n- HTML deserialization from `code` tags and Consolas font styles.\n- `<code>` rendering by default.\n- Registry `CodeLeaf` for styled inline code.\n- Optional Markdown-style input rule through `CodeRules`.\n\n</PackageInfo>\n\n## Kit Usage\n\n<Steps>\n\n### Add Basic Marks\n\n`BasicMarksKit` includes `CodePlugin`, `CodeLeaf`, the backtick input rule, and a `mod+e` shortcut.\n\n<ComponentSource name=\"basic-marks-kit\" />\n\n```tsx\nimport { createPlateEditor } from 'platejs/react';\n\nimport { BasicMarksKit } from '@/components/editor/plugins/basic-marks-kit';\n\nexport const editor = createPlateEditor({\n  plugins: [...BasicMarksKit],\n});\n```\n\n### Add A Toolbar Button\n\nUse `MarkToolbarButton` with `KEYS.code`.\n\n```tsx\nimport { Code2Icon } from 'lucide-react';\nimport { KEYS } from 'platejs';\n\nimport { MarkToolbarButton } from '@/components/ui/mark-toolbar-button';\n\nexport function CodeToolbarButton() {\n  return (\n    <MarkToolbarButton nodeType={KEYS.code} tooltip=\"Code (⌘+E)\">\n      <Code2Icon />\n    </MarkToolbarButton>\n  );\n}\n```\n\n</Steps>\n\n## Manual Usage\n\nInstall the mark package.\n\n```bash\nnpm install @platejs/basic-nodes\n```\n\nAdd `CodePlugin` directly when you want the default `<code>` render.\n\n```tsx\nimport { CodePlugin } from '@platejs/basic-nodes/react';\nimport { createPlateEditor } from 'platejs/react';\n\nexport const editor = createPlateEditor({\n  plugins: [CodePlugin],\n});\n```\n\nConfigure the registry leaf, input rule, and shortcut when you want the same behavior as the kit.\n\n```tsx\nimport { CodeRules } from '@platejs/basic-nodes';\nimport { CodePlugin } from '@platejs/basic-nodes/react';\n\nimport { CodeLeaf } from '@/components/ui/code-node';\n\nexport const codePlugin = CodePlugin.configure({\n  inputRules: [CodeRules.markdown()],\n  node: { component: CodeLeaf },\n  shortcuts: { toggle: { keys: 'mod+e' } },\n});\n```\n\n## Ownership\n\n| Surface | Owner | What It Does |\n|---------|-------|--------------|\n| `BaseCodePlugin` | `@platejs/basic-nodes` | Headless inline code mark, HTML parser, render tag, selection rule, and `toggle` transform. |\n| `CodePlugin` | `@platejs/basic-nodes/react` | React wrapper for the headless code mark. |\n| `CodeRules.markdown` | `@platejs/basic-nodes` | Optional backtick input rule. |\n| `CodeLeaf` | Registry UI | Styled inline code leaf using `PlateLeaf`. |\n| `CodeLeafStatic` | Registry UI | Static rendering version using `SlateLeaf`. |\n| `BasicMarksKit` | Registry | Adds `CodePlugin`, `CodeLeaf`, `CodeRules.markdown()`, and `mod+e`. |\n| `MarkToolbarButton` | Registry UI | Reads active mark state and calls the mark toggle hook. |\n\nThe package owns inline code semantics. The registry owns visual styling and toolbar placement.\n\n## Behavior\n\n| Behavior | Source |\n|----------|--------|\n| Mark key | `KEYS.code` |\n| Leaf behavior | `node.isLeaf: true` |\n| Toggle transform | `editor.tf.code.toggle()` calls `editor.tf.toggleMark(type)`. |\n| Selection affinity | `hard` |\n| HTML tags | `code` |\n| HTML styles | `font-family: Consolas` |\n| HTML guard | Skips code inside `pre` and paragraph-level Consolas blocks. |\n| Render output | `code` |\n| Kit shortcut | `mod+e` |\n\n## API Reference\n\n| API | Package | Use |\n|-----|---------|-----|\n| `BaseCodePlugin` | `@platejs/basic-nodes` | Headless inline code plugin. |\n| `CodePlugin` | `@platejs/basic-nodes/react` | React inline code plugin. |\n| `CodeRules.markdown()` | `@platejs/basic-nodes` | Creates the backtick mark input rule. |\n| `tf.code.toggle()` | `@platejs/basic-nodes` | Toggles the inline code mark at the selection. |\n| `CodeLeaf` | Registry UI | Styled client inline code leaf. |\n| `CodeLeafStatic` | Registry UI | Styled static inline code leaf. |\n\n",
      "type": "registry:file",
      "target": "content/docs/plate/(plugins)/(marks)/code.mdx"
    }
  ],
  "type": "registry:file"
}