diff --git a/src/components/Mindmap/listener/listener.ts b/src/components/Mindmap/listener/listener.ts index a22d1fe..4f43bbe 100644 --- a/src/components/Mindmap/listener/listener.ts +++ b/src/components/Mindmap/listener/listener.ts @@ -91,6 +91,7 @@ export const onContextmenu = (e: MouseEvent): void => { if (!classList.contains(style.selected)) { selectGNode(gNode as SVGGElement) } ctm.addItem.value.disabled = collapseFlag ctm.deleteItem.value.disabled = isRoot + ctm.cutItem.value.disabled = isRoot ctm.addSiblingItem.value.disabled = isRoot ctm.addSiblingBeforeItem.value.disabled = isRoot ctm.addParentItem.value.disabled = isRoot @@ -127,6 +128,15 @@ export const onClickMenu = (name: MenuEvent): void => { const d = addParent(seleData.id, '') if (d) { edit(d) } } break + case 'cut': { + const { id } = getSelectedGData() + const rawdata = mmdata.find(id)?.rawData + if (rawdata) { + // navigator.clipboard.write + navigator.clipboard.writeText(JSON.stringify(rawdata)) + } + del(id) + } break case 'copy': { const seleData = getSelectedGData() const rawdata = mmdata.find(seleData.id)?.rawData diff --git a/src/components/Mindmap/variable/contextmenu.ts b/src/components/Mindmap/variable/contextmenu.ts index c757e88..c9e86b9 100644 --- a/src/components/Mindmap/variable/contextmenu.ts +++ b/src/components/Mindmap/variable/contextmenu.ts @@ -3,7 +3,7 @@ import { scaleExtent, zoomTransform } from '.' export type MenuEvent = 'zoomin' | 'zoomout' | 'zoomfit' | 'add' | 'delete' | 'selectall' | 'collapse' | 'expand' | 'add-sibling' | 'add-sibling-before' | - 'add-parent' | 'copy' | 'paste' + 'add-parent' | 'copy' | 'paste' | 'cut' export interface MenuItem { title: string name: string @@ -18,13 +18,14 @@ export const addItem: Ref = ref({ title: '新建子节点', name: 'add export const addParentItem: Ref = ref({ title: '新建父节点', name: 'add-parent', disabled: false }) export const addSiblingItem: Ref = ref({ title: '新建兄弟节点', name: 'add-sibling', disabled: false }) export const addSiblingBeforeItem: Ref = ref({ title: '在此之前新建兄弟节点', name: 'add-sibling-before', disabled: true }) +export const cutItem: Ref = ref({ title: '剪切', name: 'cut', disabled: false }) export const copyItem: Ref = ref({ title: '拷贝', name: 'copy', disabled: false }) export const pasteItem: Ref = ref({ title: '粘贴', name: 'paste', disabled: false }) const nodeMenu = computed(() => [ [ addItem.value, addParentItem.value, addSiblingItem.value, addSiblingBeforeItem.value ], - [ copyItem.value, pasteItem.value, deleteItem.value ], + [ cutItem.value, copyItem.value, pasteItem.value, deleteItem.value ], [ { title: '全选', name: 'selectall', disabled: true } ], [ collapseItem.value, expandItem.value ] ])