{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "field-static", "dependencies": [ "platejs", "diff-match-patch-ts@^0.6.0" ], "files": [ { "path": "src/registry/components/editor/field-static.tsx", "content": "import { IconPlaceholder } from '@/components/icon-placeholder';\nimport { BaseFieldPlugin, fillsField } from 'platejs/field';\nimport { type EditorElementProps, EditorElement } from 'platejs/static';\nimport * as React from 'react';\n\nconst optionLabel = (\n options:\n | ReadonlyArray>\n | undefined,\n entry: unknown\n) => {\n if (!options) return undefined;\n\n const index = options.findIndex((option) => option.value === entry);\n\n if (index === -1) return undefined;\n\n const { label } = options[index];\n\n return label.trim().length > 0 ? label : `Option ${index + 1}`;\n};\n\nexport function FieldElementStatic(\n props: EditorElementProps\n) {\n const { element } = props;\n const { kind, options, value } = element;\n let shown: React.ReactNode = (\n \n );\n\n if (kind === 'checkbox') {\n shown = (\n \n {value === true && }\n \n );\n } else if (fillsField(element, value)) {\n shown = Array.isArray(value)\n ? value.map((entry) => optionLabel(options, entry) ?? entry).join(', ')\n : kind === 'choice'\n ? optionLabel(options, value)\n : String(value);\n }\n\n return (\n \n {shown}\n {props.children}\n \n );\n}\n\nexport const BaseFieldKit = [\n BaseFieldPlugin.configure({ component: FieldElementStatic }),\n];\n", "type": "registry:component", "target": "@components/editor/field-static.tsx" } ], "meta": { "docs": [ { "route": "/docs/field", "title": "Field" } ] }, "type": "registry:component" }