From 6136e5e86369e565915fe532c871bcbecf4b7325 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 10 Jun 2023 11:26:56 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/7536 --- app/src/protyle/render/av/action.ts | 42 +++++++++++++++++++++++++++-- app/src/protyle/wysiwyg/index.ts | 6 ++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 09a07a7b8..27f0a5bc1 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -22,7 +22,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle }], [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-type"), + parentID: blockElement.getAttribute("data-av-id"), }]); } }); @@ -103,7 +103,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle transaction(protyle, [{ action: "removeAttrViewCol", id, - parentID: blockElement.getAttribute("data-av-type"), + parentID: blockElement.getAttribute("data-av-id"), }], [{ action: "addAttrViewCol", name: cellElement.textContent.trim(), @@ -135,3 +135,41 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle } return false; }; + + +export const avContextmenu = (protyle: IProtyle, event: MouseEvent & { detail: any }, target: HTMLElement) => { + const rowElement = hasClosestByClassName(target, "av__row"); + if (rowElement) { + const menu = new Menu("av-row"); + menu.addItem({ + icon: "iconCopy", + label: window.siyuan.languages.duplicate, + click() { + + } + }); + menu.addItem({ + icon: "iconTrashcan", + label: window.siyuan.languages.delete, + click() { + + } + }); + menu.addSeparator(); + menu.addItem({ + icon: "iconTrashcan", + label: window.siyuan.languages.open, + click() { + + } + }); + menu.open({ + x: event.clientX, + y: event.clientY, + }); + event.preventDefault(); + event.stopPropagation(); + return true; + } + return false +} diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index c8e52af1c..592ca4d63 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -66,7 +66,7 @@ import {getBacklinkHeadingMore, loadBreadcrumb} from "./renderBacklink"; import {removeSearchMark} from "../toolbar/util"; import {activeBlur, hideKeyboardToolbar} from "../../mobile/util/keyboardToolbar"; import {commonClick} from "./commonClick"; -import {avClick} from "../render/av/action"; +import {avClick, avContextmenu} from "../render/av/action"; export class WYSIWYG { public lastHTMLs: { [key: string]: string } = {}; @@ -1247,6 +1247,10 @@ export class WYSIWYG { return false; } const nodeElement = hasClosestBlock(target); + + if (avContextmenu(protyle, event, target)) { + return; + } if (!nodeElement) { return false; }