fix json editor lint

This commit is contained in:
Michael Genson 2025-06-18 19:45:55 +00:00
commit a7d330d062

View file

@ -1,6 +1,6 @@
<template> <template>
<JsonEditorVue <JsonEditorVue
:modelValue="modelValue" :model-value="modelValue"
v-bind="$attrs" v-bind="$attrs"
:style="{ height }" :style="{ height }"
:stringified="false" :stringified="false"
@ -8,28 +8,29 @@
/> />
</template> </template>
<script setup lang="ts"> <script lang="ts">
import { defineProps, defineEmits } from 'vue' import { defineComponent } from "vue";
import JsonEditorVue from 'json-editor-vue' import JsonEditorVue from "json-editor-vue";
const props = defineProps({ export default defineComponent({
name: "RecipeJsonEditor",
components: { JsonEditorVue },
props: {
modelValue: { modelValue: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
height: { height: {
type: String, type: String,
default: '1500px', default: "1500px",
}, },
}) },
emits: ["update:modelValue"],
const emit = defineEmits(['update:modelValue']) setup(_, { emit }) {
function parseEvent(event: any): object {
function parseEvent(event: any): object {
if (!event) { if (!event) {
return {}; return {};
} }
try { try {
if (event.json) { if (event.json) {
return event.json; return event.json;
@ -40,12 +41,17 @@ function parseEvent(event: any): object {
else { else {
return event; return event;
} }
} catch { }
catch {
return {}; return {};
} }
} }
function onChange(event: any) {
function onChange(event: any) { emit("update:modelValue", parseEvent(event));
emit('update:modelValue', parseEvent(event)); }
} return {
onChange,
};
},
});
</script> </script>