From 8735290052406dde41174d0a55ea27bb72ed3862 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu <1171051090@qq.com> Date: Wed, 27 Jan 2021 23:44:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E7=BD=AE=E6=96=87=E6=9C=AC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8FUI=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useCreateElement.ts | 17 +++-- src/views/Editor/Canvas/index.vue | 4 +- .../ElementStylePanel/TextStylePanel.vue | 72 +++++++++++++++++++ 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/src/hooks/useCreateElement.ts b/src/hooks/useCreateElement.ts index cd5c8967..43039613 100644 --- a/src/hooks/useCreateElement.ts +++ b/src/hooks/useCreateElement.ts @@ -55,8 +55,8 @@ export default () => { src, width, height, - left: 0, - top: 0, + left: (VIEWPORT_SIZE - width) / 2, + top: (VIEWPORT_SIZE * VIEWPORT_ASPECT_RATIO - height) / 2, fixedRatio: true, }) }) @@ -87,19 +87,22 @@ export default () => { const data: TableCell[][] = new Array(row).fill(rowCells) const DEFAULT_CELL_WIDTH = 100 - const DEFAULT_CELL_HEIGHT = 40 + const DEFAULT_CELL_HEIGHT = 36 const colWidths: number[] = new Array(col).fill(1 / col) + const width = col * DEFAULT_CELL_WIDTH + const height = row * DEFAULT_CELL_HEIGHT + createElement({ type: 'table', id: createRandomCode(), - width: col * DEFAULT_CELL_WIDTH, - height: row * DEFAULT_CELL_HEIGHT, + width, + height, colWidths, data, - left: 0, - top: 0, + left: (VIEWPORT_SIZE - width) / 2, + top: (VIEWPORT_SIZE * VIEWPORT_ASPECT_RATIO - height) / 2, outline: { width: 2, style: 'solid', diff --git a/src/views/Editor/Canvas/index.vue b/src/views/Editor/Canvas/index.vue index 9bb62226..c8b64c91 100644 --- a/src/views/Editor/Canvas/index.vue +++ b/src/views/Editor/Canvas/index.vue @@ -128,7 +128,6 @@ export default defineComponent({ const ctrlOrShiftKeyActive = computed(() => store.getters.ctrlOrShiftKeyActive) const viewportRef = ref() - const isShowGridLines = ref(false) const alignmentLines = ref([]) const activeGroupElementId = ref('') @@ -202,7 +201,7 @@ export default defineComponent({ handler: pasteElement, }, { - text: '网格线', + text: showGridLines.value ? '关闭网格线' : '打开网格线', handler: toggleGridLines, }, { @@ -227,7 +226,6 @@ export default defineComponent({ handleClickBlankArea, removeEditorAreaFocus, currentSlide, - isShowGridLines, creatingElement, insertElementFromCreateSelection, alignmentLines, diff --git a/src/views/Editor/Toolbar/ElementStylePanel/TextStylePanel.vue b/src/views/Editor/Toolbar/ElementStylePanel/TextStylePanel.vue index dff4dcf8..90eb9e6f 100644 --- a/src/views/Editor/Toolbar/ElementStylePanel/TextStylePanel.vue +++ b/src/views/Editor/Toolbar/ElementStylePanel/TextStylePanel.vue @@ -1,5 +1,16 @@