🎨 ⌘/

This commit is contained in:
Vanessa 2022-09-21 11:28:01 +08:00
parent a7a77c4ebb
commit 05de4271cc
2 changed files with 12 additions and 9 deletions

View file

@ -375,7 +375,7 @@ export class Gutter {
};
}
private renderMultipleMenu(protyle: IProtyle, selectsElement: Element[]) {
public renderMultipleMenu(protyle: IProtyle, selectsElement: Element[]) {
let isList = false;
let isContinue = false;
let hasEmbedBlock = false;

View file

@ -514,6 +514,17 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (matchHotKey("⌘/", event)) {
event.stopPropagation();
event.preventDefault();
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
if (selectElements.length > 0) {
if (selectElements.length === 1) {
protyle.gutter.renderMenu(protyle, selectElements[0]);
} else {
protyle.gutter.renderMultipleMenu(protyle, Array.from(selectElements));
}
const rect = nodeElement.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.left, y: rect.top}, true);
return;
}
const inlineElement = hasClosestByAttribute(range.startContainer, "data-type", null);
if (inlineElement) {
const types = inlineElement.getAttribute("data-type").split(" ");
@ -544,14 +555,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
}
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
let actionElement = nodeElement;
if (selectElements.length > 0) {
actionElement = selectElements[0] as HTMLElement;
}
protyle.gutter.renderMenu(protyle, actionElement);
const rect = nodeElement.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.left, y: rect.top}, true);
return;
}