@@ -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
@@ -124,14 +126,21 @@ export default defineComponent({
124
126
watch (
125
127
( ) => props [ modelValueProp ] ,
126
128
( 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
+ }
135
144
} ,
136
145
{
137
146
deep : true ,
0 commit comments