A utility function for creating paired schema fields:
- A code field for editing in YAML or JSON5 format
- A JSON field for storing the parsed data
import { simplerJSON } from '../../lib/fields/simplerJSON'
fields: [
// Other fields...
...simplerJSON({
jsonFieldName: 'data',
codeFieldName: 'yaml',
label: 'Content',
defaultFormat: 'yaml',
}),
// More fields...
]
Option | Type | Default | Description |
---|---|---|---|
jsonFieldName | string | 'shape' | Name of the JSON field |
codeFieldName | string | 'schemaYaml' | Name of the code field |
label | string | 'Schema' | Label for the code field |
defaultFormat | 'yaml' | 'json5' | 'yaml' | Default format for the code field |
adminCondition | function | () => true | Condition for showing fields in admin UI |
editorOptions | object | { lineNumbers: 'off', padding: { top: 20, bottom: 20 } } | Editor options for the code field |
hideJsonField | boolean | true | Whether to hide the JSON field in the admin UI |