From e577628852a59607da39be580465c2f4ca758da4 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Wed, 19 Jul 2023 14:57:26 +0800 Subject: [PATCH] =?UTF-8?q?style(editor):=20=E4=BB=A3=E7=A0=81=E5=9D=97?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=B8=AD=E4=BB=A3=E7=A0=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E9=AB=98=E5=BA=A6=E8=87=AA=E5=8A=A8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E8=A1=A8=E5=8D=95=E4=B8=8D=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/src/components/CodeBlockEditor.vue | 16 +++++++++- packages/editor/src/fields/Code.vue | 9 ++---- packages/editor/src/index.ts | 1 + packages/editor/src/layouts/CodeEditor.vue | 2 +- packages/editor/src/layouts/Framework.vue | 10 +++++-- packages/form/src/FormDrawer.vue | 30 ++++++++++++++----- packages/form/src/theme/form-drawer.scss | 6 ++++ 7 files changed, 54 insertions(+), 20 deletions(-) diff --git a/packages/editor/src/components/CodeBlockEditor.vue b/packages/editor/src/components/CodeBlockEditor.vue index 25a4a1df..d61c6b3d 100644 --- a/packages/editor/src/components/CodeBlockEditor.vue +++ b/packages/editor/src/components/CodeBlockEditor.vue @@ -9,6 +9,7 @@ :disabled="disabled" @submit="submitForm" @error="errorHandler" + @open="openHandler" > @@ -37,7 +38,10 @@ const emit = defineEmits<{ const services = inject('services'); -const size = computed(() => globalThis.document.body.clientWidth - (services?.uiService.get('columnWidth').left || 0)); +const columnWidth = computed(() => services?.uiService.get('columnWidth')); +const size = computed(() => (columnWidth.value ? columnWidth.value.center + columnWidth.value.right : 600)); + +const codeEditorHeight = ref('600px'); const defaultParamColConfig: ColumnConfig = { type: 'row', @@ -104,6 +108,7 @@ const functionConfig = computed(() => [ name: 'content', type: 'vs-code', options: inject('codeOptions', {}), + height: codeEditorHeight.value, onChange: (formState: FormState | undefined, code: string) => { try { // 检测js代码是否存在语法错误 @@ -129,6 +134,15 @@ const errorHandler = (error: any) => { const fomDrawer = ref>(); +const openHandler = () => { + setTimeout(() => { + if (fomDrawer.value) { + const height = fomDrawer.value?.bodyHeight - 468; + codeEditorHeight.value = `${height > 100 ? height : 600}px`; + } + }); +}; + defineExpose({ show() { fomDrawer.value?.show(); diff --git a/packages/editor/src/fields/Code.vue b/packages/editor/src/fields/Code.vue index aa5369fb..2760c1f7 100644 --- a/packages/editor/src/fields/Code.vue +++ b/packages/editor/src/fields/Code.vue @@ -1,8 +1,8 @@