Skip to content

Latest commit

 

History

History

fields

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Field Utilities

simplerJSON

A utility function for creating paired schema fields:

  1. A code field for editing in YAML or JSON5 format
  2. A JSON field for storing the parsed data

Usage

import { simplerJSON } from '../../lib/fields/simplerJSON'

fields: [
  // Other fields...
  ...simplerJSON({
    jsonFieldName: 'data',
    codeFieldName: 'yaml',
    label: 'Content',
    defaultFormat: 'yaml',
  }),
  // More fields...
]

Options

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