@@ -62,16 +62,6 @@ export default defineComponent({
62
62
const preventUpdatingContent = ref ( false )
63
63
const preventUpdatingModelValue = ref ( false )
64
64
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
-
75
65
const onChange = debounce ( ( updatedContent : Content ) => {
76
66
if ( preventUpdatingModelValue . value ) {
77
67
preventUpdatingModelValue . value = false
@@ -95,36 +85,45 @@ export default defineComponent({
95
85
currentValue ( ...args )
96
86
}
97
87
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
-
121
88
expose ?.( { jsonEditor } )
122
89
123
90
onUnmounted ( ( ) => {
124
91
jsonEditor . value ?. destroy ( )
125
92
} )
126
93
127
94
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
+
128
127
jsonEditor . value = new JSONEditor ( {
129
128
target : currentInstance ?. $refs . jsonEditorRef as Element ,
130
129
props : initialAttrs ,
0 commit comments