@@ -9,16 +9,13 @@ import {
99 unref ,
1010 watch ,
1111} from 'vue-demi'
12- import type {
13- PropType ,
14- } from 'vue-demi'
12+ import type { PropType } from 'vue-demi'
1513import { JSONEditor } from 'vanilla-jsoneditor'
1614import { conclude } from 'vue-global-config'
1715import { debounce } from 'lodash-es'
1816import { globalAttrs , globalProps } from './index'
1917
2018export type Mode = 'tree' | 'text'
21- type ValueKey = 'json' | 'text'
2219
2320const modelValueProp = isVue3 ? 'modelValue' : 'value'
2421const updateModelValue = isVue3 ? 'update:modelValue' : 'input'
@@ -46,8 +43,6 @@ export default defineComponent({
4643 } ,
4744 emits : [ updateModelValue , 'update:mode' ] ,
4845 setup ( props , { attrs, emit, expose } ) {
49- const valueToContentKey = ( value : any ) : ValueKey => typeof value === 'string' ? 'text' : 'json'
50-
5146 const currentInstance = getCurrentInstance ( ) ?. proxy
5247 const jsonEditor = ref ( )
5348
@@ -78,7 +73,7 @@ export default defineComponent({
7873 ...initialBoolAttrs ,
7974 ...initialValue !== undefined && {
8075 content : {
81- [ valueToContentKey ( initialValue ) ] : initialValue ,
76+ json : initialValue ,
8277 } ,
8378 } ,
8479 } ] , {
@@ -100,7 +95,7 @@ export default defineComponent({
10095 preventOnChange . value = true
10196 jsonEditor . value . update ( [ undefined , '' ] . includes ( n )
10297 ? { text : '' }
103- : { [ valueToContentKey ( n ) ] : n } )
98+ : { json : n } )
10499 } , {
105100 deep : true ,
106101 } )
0 commit comments