{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rich-text-editor-code-block",
  "title": "Code Block",
  "description": "Preformatted code blocks with a toolbar toggle.",
  "dependencies": [
    "@tiptap/extension-code-block@3.32.2",
    "@tiptap/react@3.32.2",
    "cn",
    "lucide-react"
  ],
  "registryDependencies": [
    "litingyes/blocove/rich-text-editor",
    "litingyes/blocove/rich-text-editor-extension"
  ],
  "files": [
    {
      "path": "src/registry/blocove/ui/rich-text-editor/code-block.tsx",
      "content": "import type { CodeBlockOptions } from '@tiptap/extension-code-block'\nimport type { Editor } from '@tiptap/react'\nimport { CodeBlock } from '@tiptap/extension-code-block'\nimport { useCurrentEditor, useEditorState } from '@tiptap/react'\nimport { SquareCodeIcon } from 'lucide-react'\nimport { EditorToolbarButton } from '@/components/blocove/rich-text-editor/editor'\nimport { defineExtensionComponent } from '@/lib/blocove/rich-text-editor-extension'\n\nexport type EditorCodeBlockProps = Partial<CodeBlockOptions>\n\n/**\n * Registers the Tiptap CodeBlock node.\n */\nexport const EditorCodeBlock = defineExtensionComponent<EditorCodeBlockProps>(\n  'codeBlock',\n  props => [\n    CodeBlock.configure(props),\n  ],\n)\n\nexport interface EditorCodeBlockToolbarProps {\n  className?: string\n}\n\n/**\n * Toolbar toggle for the code block node.\n */\nexport function EditorCodeBlockToolbar({\n  className,\n}: EditorCodeBlockToolbarProps) {\n  const { editor } = useCurrentEditor()\n\n  if (!editor) {\n    return null\n  }\n\n  return (\n    <EditorCodeBlockToolbarContent editor={editor} className={className} />\n  )\n}\n\nfunction EditorCodeBlockToolbarContent({\n  editor,\n  className,\n}: {\n  editor: Editor\n  className?: string\n}) {\n  const active = useEditorState({\n    editor,\n    selector: ({ editor: instance }) => instance.isActive('codeBlock'),\n  })\n\n  return (\n    <EditorToolbarButton\n      label=\"Code block\"\n      shortcut=\"Mod Alt C\"\n      pressed={active}\n      onPressedChange={() => editor.chain().focus().toggleCodeBlock().run()}\n      className={className}\n    >\n      <SquareCodeIcon />\n    </EditorToolbarButton>\n  )\n}\n",
      "type": "registry:ui",
      "target": "components/blocove/rich-text-editor/code-block.tsx"
    }
  ],
  "categories": [
    "rich-text-editor",
    "node"
  ],
  "type": "registry:ui"
}