mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
🎨 ⌘/
This commit is contained in:
parent
a7a77c4ebb
commit
05de4271cc
2 changed files with 12 additions and 9 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue