Browse Source

feat(gui-v2): expose format function

pull/2795/head
Wing-Kam Wong 2 years ago
parent
commit
41b2002003
  1. 8
      packages/nc-gui-v2/components/monaco/Editor.vue

8
packages/nc-gui-v2/components/monaco/Editor.vue

@ -9,6 +9,14 @@ const emit = defineEmits(['update:modelValue'])
const root = ref<HTMLDivElement>() const root = ref<HTMLDivElement>()
let editor: monaco.editor.IStandaloneCodeEditor let editor: monaco.editor.IStandaloneCodeEditor
const format = () => {
editor.setValue(JSON.stringify(JSON.parse(editor?.getValue() as string), null, 2))
}
defineExpose({
format,
})
onMounted(() => { onMounted(() => {
if (root.value) { if (root.value) {
const model = monaco.editor.createModel(JSON.stringify(modelValue, null, 2), 'json') const model = monaco.editor.createModel(JSON.stringify(modelValue, null, 2), 'json')

Loading…
Cancel
Save