@wisersolutions/aor-codemirror
v0.3.0
Published
CodeMirror wrapper for react-admin
Downloads
17
Readme
Admin on Rest - CodeMirror
Wrapper around CodeMirror for react-admin.
Supported formats:
- html
- json
- sql
- javascript
Install
Install using npm: npm install @wisersolutions/aor-codemirror
Usage
The prop name
will be mapped to source
for react-admin.
JSON editor
We should to turn on validation for JSON.
import { CodeMirror, validJson } from 'aor-codemirror'
<CodeMirror label="My Label" name="fieldName" type="json" defaultValue="{}" required validate={validJson} />
Output from the CodeMirrror will be JSON object (not string);
SQL editor
import { CodeMirror } from 'aor-codemirror'
<CodeMirror label="My Label" name="fieldName" type="sql" required />
HTML editor
import { required } from 'react-admin'
import { CodeMirror } from 'aor-codemirror'
<CodeMirror label="My Label" name="fieldName" type="html" required validate={required} />
Javascript editor
import { required } from 'react-admin'
import { CodeMirror } from 'aor-codemirror'
<CodeMirror label="My Label" name="fieldName" type="javascript" required validate={required} />