@@ -58,8 +58,10 @@ export default defineComponent({
58
58
setup ( props , { attrs, emit, expose } ) {
59
59
const currentInstance = getCurrentInstance ( ) ?. proxy
60
60
const jsonEditor = ref ( )
61
+ const preventUpdatingContent = ref ( false )
61
62
62
63
const onChange = debounce ( ( updatedContent : Content ) => {
64
+ preventUpdatingContent . value = true
63
65
emit (
64
66
updateModelValue ,
65
67
( updatedContent as TextContent ) . text === undefined
@@ -111,8 +113,9 @@ export default defineComponent({
111
113
} ,
112
114
] ,
113
115
{
114
- type : Object ,
116
+ camelizeObjectKeys : true ,
115
117
mergeFunction,
118
+ type : Object ,
116
119
} ,
117
120
)
118
121
@@ -124,14 +127,21 @@ export default defineComponent({
124
127
watch (
125
128
( ) => props [ modelValueProp ] ,
126
129
( newModelValue : any ) => {
127
- jsonEditor . value ?. set (
128
- [ undefined , '' ] . includes ( newModelValue )
129
- // `undefined` is not accepted by vanilla-jsoneditor
130
- // The default value is `{ text: '' }`
131
- // Only default value can clear the editor
132
- ? { text : '' }
133
- : { json : newModelValue } ,
134
- )
130
+ if ( preventUpdatingContent . value ) {
131
+ preventUpdatingContent . value = false
132
+ return
133
+ }
134
+ if ( jsonEditor . value ) {
135
+ // jsonEditor.value.update cannot render new props in json
136
+ jsonEditor . value . set (
137
+ [ undefined , '' ] . includes ( newModelValue )
138
+ // `undefined` is not accepted by vanilla-jsoneditor
139
+ // The default value is `{ text: '' }`
140
+ // Only default value can clear the editor
141
+ ? { text : '' }
142
+ : { json : newModelValue } ,
143
+ )
144
+ }
135
145
} ,
136
146
{
137
147
deep : true ,
@@ -165,17 +175,18 @@ export default defineComponent({
165
175
onChange ?: ( ...args : any ) => unknown
166
176
onChangeMode ?: ( ...args : any ) => unknown
167
177
} = { }
168
- if ( newAttrs . onChange ) {
178
+ if ( newAttrs . onChange || newAttrs [ 'on-change' ] ) {
169
179
defaultFunctionAttrs . onChange = onChange
170
180
}
171
- if ( newAttrs . onChangeMode ) {
181
+ if ( newAttrs . onChangeMode || newAttrs [ 'on-change-mode' ] ) {
172
182
defaultFunctionAttrs . onChangeMode = onChangeMode
173
183
}
174
184
jsonEditor . value ?. updateProps (
175
185
Object . getOwnPropertyNames ( defaultFunctionAttrs ) . length > 0
176
186
? conclude ( [ newAttrs , defaultFunctionAttrs ] , {
177
- type : Object ,
187
+ camelizeObjectKeys : true ,
178
188
mergeFunction,
189
+ type : Object ,
179
190
} )
180
191
: newAttrs ,
181
192
)
0 commit comments