Implement option mode
This commit is contained in:
parent
f2b2769727
commit
8b99527604
|
@ -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 => {
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue