Skip to content

Commit db71502

Browse files
committed
feat!: adapt to [email protected]
1 parent 72e9bc4 commit db71502

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

src/Component.ts

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)