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 @@