@@ -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
@@ -124,14 +126,21 @@ export default defineComponent({
124126 watch (
125127 ( ) => props [ modelValueProp ] ,
126128 ( 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- )
129+ if ( preventUpdatingContent . value ) {
130+ preventUpdatingContent . value = false
131+ return
132+ }
133+ if ( jsonEditor . value ) {
134+ // jsonEditor.value.update cannot render new props in json
135+ jsonEditor . value . set (
136+ [ undefined , '' ] . includes ( newModelValue )
137+ // `undefined` is not accepted by vanilla-jsoneditor
138+ // The default value is `{ text: '' }`
139+ // Only default value can clear the editor
140+ ? { text : '' }
141+ : { json : newModelValue } ,
142+ )
143+ }
135144 } ,
136145 {
137146 deep : true ,
0 commit comments