Implement option mode

This commit is contained in:
Jos de Jong 2020-08-16 11:44:28 +02:00
parent f2b2769727
commit 8b99527604
3 changed files with 14 additions and 2 deletions

View File

@ -52,7 +52,7 @@
</p>
<script type="module">
import jsoneditor from './dist/es/jsoneditor.js'
import jsoneditor, { TreeMode } from './dist/es/jsoneditor.js'
const doc = {
'array': [1, 2, 3, {
@ -93,6 +93,7 @@
const testEditor = jsoneditor({
target: document.getElementById('testEditorContainer'),
mode: TreeMode,
doc,
onChangeJson: doc => console.log('onChangeJson', doc),
validate: doc => {

View File

@ -3,8 +3,16 @@
import TreeMode from './treemode/TreeMode.svelte'
export let config = {}
let mode
let restConfig
$: {
let { _mode, ..._restConfig } = config
mode = _mode
restConfig = _restConfig
}
</script>
<Modal>
<TreeMode {...config} />
<svelte:component this={mode || TreeMode} {...restConfig} />
</Modal>

View File

@ -1,4 +1,5 @@
import JSONEditor from './components/JSONEditor.svelte'
import _TreeMode from './components/treemode/TreeMode.svelte'
export default function jsoneditor (config) {
const { target, ...restConfig } = config
@ -11,4 +12,6 @@ export default function jsoneditor (config) {
})
}
export const TreeMode = _TreeMode
export { createAjvValidator } from './plugins/createAjvValidator.mjs'