/react-jsonschema-form-codemirror-widget

codemirror widget for react-jsonschema-form

Primary LanguageJavaScript

travis npm semantic-release

Example

import React from 'react'
import { CodeMirrorWidgetJavascript, CodeMirrorWidgetJSON } from 'react-jsonschema-form-codemirror-widget'
import Form from "react-jsonschema-form"

class MyForm extends React.Component {
  render() {
    const schema = {
      title: "Blog",
      type: "object",
      properties: {
        codeMirrorJavascript: {type: "string"},
        codeMirrorJSON: {type: "string"}
      }
    }

    const uiSchema = {
      codeMirrorJavascript: {
        "ui:widget": "codeMirrorJavascript"
      },
      codeMirrorJSON: {
        "ui:widget": "codeMirrorJSON"
      }
    }

    return <Form
      widgets={{codeMirrorJavascript: CodeMirrorWidgetJavascript, codeMirrorJSON: CodeMirrorWidgetJSON}}
      schema={schema}
      uiSchema={uiSchema}
    />
  }
}