From 0d0e7299447b68591c83aa3f9c709f4be99e468a Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Tue, 16 Jan 2024 19:51:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=B9=E6=B3=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + src/components/MoveablePanel.vue | 84 ++++++- src/components/TextArea.vue | 8 + src/plugins/icon.ts | 4 + src/store/main.ts | 6 + src/types/slides.ts | 19 ++ src/views/Editor/CanvasTool/index.vue | 25 +- src/views/Editor/NotesPanel.vue | 323 ++++++++++++++++++++++++++ src/views/Editor/index.vue | 4 +- 9 files changed, 461 insertions(+), 13 deletions(-) create mode 100644 src/views/Editor/NotesPanel.vue diff --git a/README.md b/README.md index 1f1361a7..0b0bac8e 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ npm run dev - 元素动画(入场、退场、强调) - 选择面板(隐藏元素、层级排序、元素命名) - 查找/替换 +- 批注 ### 幻灯片元素编辑 - 元素添加、删除 - 元素复制粘贴 diff --git a/src/components/MoveablePanel.vue b/src/components/MoveablePanel.vue index f705ff4a..02aa473e 100644 --- a/src/components/MoveablePanel.vue +++ b/src/components/MoveablePanel.vue @@ -3,8 +3,8 @@ class="moveable-panel" ref="moveablePanelRef" :style="{ - width: width + 'px', - height: height ? height + 'px' : 'auto', + width: w + 'px', + height: h ? h + 'px' : 'auto', left: x + 'px', top: y + 'px', }" @@ -23,6 +23,8 @@
+ +
@@ -32,15 +34,25 @@ import { computed, onMounted, ref } from 'vue' const props = withDefaults(defineProps<{ width: number height: number + minWidth?: number + minHeight?: number + maxWidth?: number + maxHeight?: number left?: number top?: number title?: string moveable?: boolean + resizeable?: boolean }>(), { + minWidth: 20, + minHeight: 20, + maxWidth: 500, + maxHeight: 500, left: 10, top: 10, title: '', moveable: true, + resizeable: false, }) const emit = defineEmits<{ @@ -49,12 +61,14 @@ const emit = defineEmits<{ const x = ref(0) const y = ref(0) +const w = ref(0) +const h = ref(0) const moveablePanelRef = ref() const realHeight = computed(() => { - if (!props.height) { + if (!h.value) { return moveablePanelRef.value?.clientHeight || 0 } - return props.height + return h.value }) onMounted(() => { @@ -63,6 +77,9 @@ onMounted(() => { if (props.top >= 0) y.value = props.top else y.value = document.body.clientHeight + props.top - realHeight.value + + w.value = props.width + h.value = props.height }) const startMove = (e: MouseEvent) => { @@ -90,7 +107,7 @@ const startMove = (e: MouseEvent) => { if (left < 0) left = 0 if (top < 0) top = 0 - if (left + props.width > windowWidth) left = windowWidth - props.width + if (left + w.value > windowWidth) left = windowWidth - w.value if (top + realHeight.value > clientHeight) top = clientHeight - realHeight.value x.value = left @@ -103,6 +120,42 @@ const startMove = (e: MouseEvent) => { document.onmouseup = null } } + +const startResize = (e: MouseEvent) => { + if (!props.resizeable) return + + let isMouseDown = true + + const startPageX = e.pageX + const startPageY = e.pageY + + const originWidth = w.value + const originHeight = h.value + + document.onmousemove = e => { + if (!isMouseDown) return + + const moveX = e.pageX - startPageX + const moveY = e.pageY - startPageY + + let width = originWidth + moveX + let height = originHeight + moveY + + if (width < props.minWidth) width = props.minWidth + if (height < props.minHeight) height = props.minHeight + if (width > props.maxWidth) width = props.maxWidth + if (height > props.maxHeight) height = props.maxHeight + + w.value = width + h.value = height + } + document.onmouseup = () => { + isMouseDown = false + + document.onmousemove = null + document.onmouseup = null + } +} \ No newline at end of file diff --git a/src/views/Editor/index.vue b/src/views/Editor/index.vue index 446b8833..07849b9a 100644 --- a/src/views/Editor/index.vue +++ b/src/views/Editor/index.vue @@ -18,6 +18,7 @@ + mainStore.setDialogForExport('') const remarkHeight = ref(40)