mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-23 06:45:22 -07:00
update the JSON editor to return a normal JSON object
This commit is contained in:
parent
0838315d72
commit
6ce9f66693
1 changed files with 40 additions and 16 deletions
|
@ -1,27 +1,51 @@
|
||||||
<template>
|
<template>
|
||||||
<JsonEditorVue
|
<JsonEditorVue
|
||||||
v-model="modelValue"
|
:modelValue="modelValue"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:style="{ height }"
|
:style="{ height }"
|
||||||
@input="$emit('update:modelValue', $event)"
|
:stringified="false"
|
||||||
|
@change="onChange"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { defineProps, defineEmits } from 'vue'
|
||||||
import JsonEditorVue from 'json-editor-vue'
|
import JsonEditorVue from 'json-editor-vue'
|
||||||
|
|
||||||
export default defineNuxtComponent({
|
const props = defineProps({
|
||||||
components: { JsonEditorVue },
|
modelValue: {
|
||||||
props: {
|
type: Object,
|
||||||
modelValue: {
|
default: () => ({}),
|
||||||
type: Object,
|
|
||||||
default: () => ({}),
|
|
||||||
},
|
|
||||||
height: {
|
|
||||||
type: String,
|
|
||||||
default: "1500px",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
emits: ["update:modelValue"],
|
height: {
|
||||||
});
|
type: String,
|
||||||
|
default: '1500px',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
|
||||||
|
function parseEvent(event: any): object {
|
||||||
|
if (!event) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (event.json) {
|
||||||
|
return event.json;
|
||||||
|
}
|
||||||
|
else if (event.text) {
|
||||||
|
return JSON.parse(event.text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChange(event: any) {
|
||||||
|
emit('update:modelValue', parseEvent(event));
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue