@@ -62,16 +62,6 @@ export default defineComponent({
6262 const preventUpdatingContent = ref ( false )
6363 const preventUpdatingModelValue = ref ( false )
6464
65- const initialMode = conclude ( [ props . mode , globalProps . mode ] , {
66- type : String as PropType < Mode > ,
67- } )
68- const initialValue = conclude ( [ props [ modelValueProp ] , globalProps [ modelValueProp ] ] )
69- const initialBoolAttrs = Object . fromEntries (
70- Array . from ( boolAttrs , boolAttr => [ boolAttr , conclude ( [ props [ boolAttr ] , globalProps [ boolAttr ] ] ) ] ) . filter (
71- ( [ , v ] ) => v !== undefined ,
72- ) ,
73- )
74-
7565 const onChange = debounce ( ( updatedContent : Content ) => {
7666 if ( preventUpdatingModelValue . value ) {
7767 preventUpdatingModelValue . value = false
@@ -95,36 +85,45 @@ export default defineComponent({
9585 currentValue ( ...args )
9686 }
9787
98- const initialAttrs = conclude (
99- [
100- attrs ,
101- globalAttrs ,
102- {
103- // Both user input & setting value programmatically will trigger onChange
104- onChange,
105- onChangeMode,
106- mode : initialMode ,
107- ...initialBoolAttrs ,
108- ...( initialValue !== undefined && {
109- content : {
110- json : initialValue ,
111- } ,
112- } ) ,
113- } ,
114- ] ,
115- {
116- type : Object ,
117- mergeFunction,
118- } ,
119- )
120-
12188 expose ?.( { jsonEditor } )
12289
12390 onUnmounted ( ( ) => {
12491 jsonEditor . value ?. destroy ( )
12592 } )
12693
12794 onMounted ( ( ) => {
95+ const initialMode = conclude ( [ props . mode , globalProps . mode ] , {
96+ type : String as PropType < Mode > ,
97+ } )
98+ const initialValue = conclude ( [ props [ modelValueProp ] , globalProps [ modelValueProp ] ] )
99+ const initialBoolAttrs = Object . fromEntries (
100+ Array . from ( boolAttrs , boolAttr => [ boolAttr , conclude ( [ props [ boolAttr ] , globalProps [ boolAttr ] ] ) ] ) . filter (
101+ ( [ , v ] ) => v !== undefined ,
102+ ) ,
103+ )
104+ const initialAttrs = conclude (
105+ [
106+ attrs ,
107+ globalAttrs ,
108+ {
109+ // Both user input & setting value programmatically will trigger onChange
110+ onChange,
111+ onChangeMode,
112+ mode : initialMode ,
113+ ...initialBoolAttrs ,
114+ ...( initialValue !== undefined && {
115+ content : {
116+ json : initialValue ,
117+ } ,
118+ } ) ,
119+ } ,
120+ ] ,
121+ {
122+ type : Object ,
123+ mergeFunction,
124+ } ,
125+ )
126+
128127 jsonEditor . value = new JSONEditor ( {
129128 target : currentInstance ?. $refs . jsonEditorRef as Element ,
130129 props : initialAttrs ,
0 commit comments