@@ -59,15 +59,7 @@ export default defineComponent({
5959 const currentInstance = getCurrentInstance ( ) ?. proxy
6060 const jsonEditor = ref ( )
6161
62- const preventUpdatingContent = ref ( false )
63- const preventUpdatingModelValue = ref ( false )
64-
6562 const onChange = debounce ( ( updatedContent : Content ) => {
66- if ( preventUpdatingModelValue . value ) {
67- preventUpdatingModelValue . value = false
68- return
69- }
70- preventUpdatingContent . value = true
7163 emit (
7264 updateModelValue ,
7365 ( updatedContent as TextContent ) . text === undefined
@@ -132,21 +124,14 @@ export default defineComponent({
132124 watch (
133125 ( ) => props [ modelValueProp ] ,
134126 ( newModelValue : any ) => {
135- if ( preventUpdatingContent . value ) {
136- preventUpdatingContent . value = false
137- return
138- }
139- if ( jsonEditor . value ) {
140- preventUpdatingModelValue . value = true
141- jsonEditor . value . set (
142- [ undefined , '' ] . includes ( newModelValue )
143- // `undefined` is not accepted by vanilla-jsoneditor
144- // The default value is `{ text: '' }`
145- // Only default value can clear the editor
146- ? { text : '' }
147- : { json : newModelValue } ,
148- )
149- }
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+ )
150135 } ,
151136 {
152137 deep : true ,
0 commit comments