From 4058f34dc2e2c99d26e16b717d752d55569bcdd4 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Wed, 13 Mar 2024 21:16:15 +0000 Subject: [PATCH] fix(nc-gui): use withDefaults insted of directly assigning default props value in defineProps call --- packages/nc-gui/components/monaco/Editor.vue | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/nc-gui/components/monaco/Editor.vue b/packages/nc-gui/components/monaco/Editor.vue index 49831adebf..63203a7149 100644 --- a/packages/nc-gui/components/monaco/Editor.vue +++ b/packages/nc-gui/components/monaco/Editor.vue @@ -15,28 +15,30 @@ interface Props { autoFocus?: boolean } -const { - hideMinimap, - lang = 'json', - validate = true, - disableDeepCompare = false, - readOnly, - autoFocus = true, - modelValue = '', -} = defineProps() +const props = withDefaults(defineProps(), { + modelValue: '', + lang: 'json', + validate: true, + disableDeepCompare: false, + autoFocus: true, +}) + +const { modelValue } = toRefs(props) + +const { hideMinimap, lang, validate, disableDeepCompare, readOnly, autoFocus } = props const emits = defineEmits(['update:modelValue']) const vModel = computed({ get: () => { - if (typeof modelValue === 'object') { - return JSON.stringify(modelValue, null, 2) + if (typeof modelValue.value === 'object') { + return JSON.stringify(modelValue.value, null, 2) } else { - return modelValue + return modelValue.value ?? '' } }, set: (newVal: string | Record) => { - if (typeof modelValue === 'object') { + if (typeof modelValue.value === 'object') { try { emits('update:modelValue', typeof newVal === 'object' ? newVal : JSON.parse(newVal)) } catch (e) {