@@ -58,8 +58,10 @@ export default defineComponent({
5858 setup ( props , { attrs, emit, expose } ) {
5959 const currentInstance = getCurrentInstance ( ) ?. proxy
6060 const jsonEditor = ref ( )
61+ const preventUpdatingContent = ref ( false )
6162
6263 const onChange = debounce ( ( updatedContent : Content ) => {
64+ preventUpdatingContent . value = true
6365 emit (
6466 updateModelValue ,
6567 ( updatedContent as TextContent ) . text === undefined
@@ -111,8 +113,9 @@ export default defineComponent({
111113 } ,
112114 ] ,
113115 {
114- type : Object ,
116+ camelizeObjectKeys : true ,
115117 mergeFunction,
118+ type : Object ,
116119 } ,
117120 )
118121
@@ -124,14 +127,21 @@ export default defineComponent({
124127 watch (
125128 ( ) => props [ modelValueProp ] ,
126129 ( 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+ }
135145 } ,
136146 {
137147 deep : true ,
@@ -165,17 +175,18 @@ export default defineComponent({
165175 onChange ?: ( ...args : any ) => unknown
166176 onChangeMode ?: ( ...args : any ) => unknown
167177 } = { }
168- if ( newAttrs . onChange ) {
178+ if ( newAttrs . onChange || newAttrs [ 'on-change' ] ) {
169179 defaultFunctionAttrs . onChange = onChange
170180 }
171- if ( newAttrs . onChangeMode ) {
181+ if ( newAttrs . onChangeMode || newAttrs [ 'on-change-mode' ] ) {
172182 defaultFunctionAttrs . onChangeMode = onChangeMode
173183 }
174184 jsonEditor . value ?. updateProps (
175185 Object . getOwnPropertyNames ( defaultFunctionAttrs ) . length > 0
176186 ? conclude ( [ newAttrs , defaultFunctionAttrs ] , {
177- type : Object ,
187+ camelizeObjectKeys : true ,
178188 mergeFunction,
189+ type : Object ,
179190 } )
180191 : newAttrs ,
181192 )
0 commit comments