Vanessa 2023-06-10 11:26:56 +08:00
parent d1b5051ec4
commit 6136e5e863
2 changed files with 45 additions and 3 deletions

View file

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

View file

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