|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { computed } from 'vue'
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
import { ElementTypes, type PPTElement } from '@/types/slides'
|
|
|
import type { ContextmenuItem } from '@/components/Contextmenu/types'
|
|
|
|
|
@@ -28,6 +29,9 @@ import useOrderElement from '@/hooks/useOrderElement'
|
|
|
import useAlignElementToCanvas from '@/hooks/useAlignElementToCanvas'
|
|
|
import useCopyAndPasteElement from '@/hooks/useCopyAndPasteElement'
|
|
|
import useSelectElement from '@/hooks/useSelectElement'
|
|
|
+import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
|
|
+import { useSlidesStore } from '@/store'
|
|
|
+import message from '@/utils/message'
|
|
|
|
|
|
import { ElementOrderCommands, ElementAlignCommands } from '@/types/edit'
|
|
|
|
|
@@ -40,6 +44,7 @@ import TableElement from '@/views/components/element/TableElement/index.vue'
|
|
|
import LatexElement from '@/views/components/element/LatexElement/index.vue'
|
|
|
import VideoElement from '@/views/components/element/VideoElement/index.vue'
|
|
|
import AudioElement from '@/views/components/element/AudioElement/index.vue'
|
|
|
+import FrameElement from '@/views/components/element/FrameElement/index.vue'
|
|
|
|
|
|
const props = defineProps<{
|
|
|
elementInfo: PPTElement
|
|
@@ -47,6 +52,7 @@ const props = defineProps<{
|
|
|
isMultiSelect: boolean
|
|
|
selectElement: (e: MouseEvent | TouchEvent, element: PPTElement, canMove?: boolean) => void
|
|
|
openLinkDialog: () => void
|
|
|
+ openWebpageLinkEditDialog: (elementId: string, currentUrl: string) => void
|
|
|
}>()
|
|
|
|
|
|
const currentElementComponent = computed<unknown>(() => {
|
|
@@ -60,6 +66,7 @@ const currentElementComponent = computed<unknown>(() => {
|
|
|
[ElementTypes.LATEX]: LatexElement,
|
|
|
[ElementTypes.VIDEO]: VideoElement,
|
|
|
[ElementTypes.AUDIO]: AudioElement,
|
|
|
+ [ElementTypes.FRAME]: FrameElement,
|
|
|
}
|
|
|
return elementTypeMap[props.elementInfo.type] || null
|
|
|
})
|
|
@@ -80,7 +87,7 @@ const contextmenus = (): ContextmenuItem[] => {
|
|
|
}]
|
|
|
}
|
|
|
|
|
|
- return [
|
|
|
+ const baseMenu = [
|
|
|
{
|
|
|
text: '剪切',
|
|
|
subText: 'Ctrl + X',
|
|
@@ -163,5 +170,44 @@ const contextmenus = (): ContextmenuItem[] => {
|
|
|
handler: deleteElement,
|
|
|
},
|
|
|
]
|
|
|
+
|
|
|
+ // 为网页元素添加特殊菜单项
|
|
|
+ if (props.elementInfo.type === ElementTypes.FRAME) {
|
|
|
+ const frameMenu = [
|
|
|
+ {
|
|
|
+ text: '修改链接',
|
|
|
+ handler: () => {
|
|
|
+ const frameElement = props.elementInfo as any
|
|
|
+ if (frameElement.url) {
|
|
|
+ props.openWebpageLinkEditDialog(frameElement.id, frameElement.url)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '在新窗口打开',
|
|
|
+ handler: () => {
|
|
|
+ const frameElement = props.elementInfo as any
|
|
|
+ if (frameElement.url) {
|
|
|
+ window.open(frameElement.url, '_blank')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '复制链接',
|
|
|
+ handler: () => {
|
|
|
+ const frameElement = props.elementInfo as any
|
|
|
+ if (frameElement.url) {
|
|
|
+ navigator.clipboard.writeText(frameElement.url)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { divider: true },
|
|
|
+ ]
|
|
|
+ // 为网页元素过滤掉"设置链接"功能
|
|
|
+ const filteredBaseMenu = baseMenu.filter(item => item.text !== '设置链接')
|
|
|
+ return [...frameMenu, ...filteredBaseMenu]
|
|
|
+ }
|
|
|
+
|
|
|
+ return baseMenu
|
|
|
}
|
|
|
</script>
|