{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "code-editor-block",
  "title": "Code Editor",
  "description": "A complete code editor block: shiki highlighting, language support, line numbers, the toolbar and the status bar, with a controlled document.",
  "dependencies": [
    "cn"
  ],
  "registryDependencies": [
    "litingyes/blocove/code-editor",
    "litingyes/blocove/code-editor-shiki",
    "litingyes/blocove/code-editor-languages",
    "litingyes/blocove/code-editor-line-numbers"
  ],
  "files": [
    {
      "path": "src/registry/blocove/blocks/code-editor-block.tsx",
      "content": "import { cn } from 'cn'\nimport { useState } from 'react'\nimport {\n  CodeEditor,\n  CodeEditorContent,\n  CodeEditorStatusBar,\n  CodeEditorToolbar,\n} from '@/components/blocove/code-editor/editor'\nimport { CodeEditorLanguages } from '@/components/blocove/code-editor/languages'\nimport { CodeEditorLineNumbers } from '@/components/blocove/code-editor/line-numbers'\nimport { CodeEditorShiki } from '@/components/blocove/code-editor/shiki'\n\n/**\n * A complete code editor: the shiki highlighting, the language item, the line\n * numbers, the toolbar and the status bar, driven by a controlled document.\n */\nconst defaultDocument = [\n  'type CodeSample = {',\n  '  language: string',\n  '  source: string',\n  '}',\n  '',\n  'const samples: CodeSample[] = [',\n  '  { language: \\'tsx\\', source: \\'const answer = 42\\' },',\n  '  { language: \\'json\\', source: \\'{\"answer\": 42}\\' },',\n  ']',\n  '',\n  '/** Pick the sample whose language matches, falling back to the first. */',\n  'export function pickSample(language: string) {',\n  '  return samples.find(sample => sample.language === language) ?? samples[0]',\n  '}',\n  '',\n  'console.log(pickSample(\\'tsx\\')?.source)',\n].join('\\n')\n\nexport interface CodeEditorBlockProps {\n  /** Initial document. Replace it with the code your app edits. */\n  defaultValue?: string\n  /** Language shared by the highlighting, the language item and the status bar. */\n  language?: string\n  /** Read-only mode: the document can be selected and copied, but not edited. */\n  readOnly?: boolean\n  /** Called with the new document whenever it changes. */\n  onChange?: (value: string) => void\n  className?: string\n}\n\n/**\n * A ready-to-use code editor with the full Blocove extension set.\n */\nexport function CodeEditorBlock({\n  defaultValue = defaultDocument,\n  language = 'tsx',\n  readOnly = false,\n  onChange,\n  className,\n}: CodeEditorBlockProps) {\n  const [value, setValue] = useState(defaultValue)\n\n  return (\n    <CodeEditor\n      value={value}\n      onChange={(next) => {\n        setValue(next)\n        onChange?.(next)\n      }}\n      language={language}\n      readOnly={readOnly}\n      className={cn('h-80 w-full max-w-3xl', className)}\n    >\n      <CodeEditorShiki />\n      <CodeEditorLanguages />\n      <CodeEditorLineNumbers />\n      <CodeEditorToolbar />\n      <CodeEditorContent />\n      <CodeEditorStatusBar />\n    </CodeEditor>\n  )\n}\n",
      "type": "registry:block",
      "target": "components/blocove/code-editor-block.tsx"
    }
  ],
  "categories": [
    "code-editor",
    "block"
  ],
  "type": "registry:block"
}