♻️ menu

This commit is contained in:
Vanessa 2023-10-04 20:11:33 +08:00
parent 828eeee4be
commit 82f9b9c60c
16 changed files with 28 additions and 22 deletions

View File

@ -628,7 +628,8 @@ export class Wnd {
window.siyuan.menus.menu.popup({ window.siyuan.menus.menu.popup({
x: rect.left + rect.width, x: rect.left + rect.width,
y: rect.top + rect.height, y: rect.top + rect.height,
}, true); isLeft: true
});
} }
private removeOverCounter(oldFocusIndex?: number) { private removeOverCounter(oldFocusIndex?: number) {

View File

@ -53,7 +53,7 @@ export const initStatus = (isWindow = false) => {
}).element); }).element);
}); });
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.top}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.top, isLeft: true});
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (target.id === "statusHelp") { } else if (target.id === "statusHelp") {
@ -106,7 +106,7 @@ export const initStatus = (isWindow = false) => {
} }
}).element); }).element);
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.top}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.top, isLeft: true});
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (target.classList.contains("b3-menu__item")) { } else if (target.classList.contains("b3-menu__item")) {

View File

@ -100,7 +100,7 @@ export const initBar = (app: App) => {
window.siyuan.menus.menu.append(new MenuItem(menuOptions).element); window.siyuan.menus.menu.append(new MenuItem(menuOptions).element);
}); });
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (targetId === "barForward") { } else if (targetId === "barForward") {
@ -160,7 +160,7 @@ export const initBar = (app: App) => {
if (rect.width === 0) { if (rect.width === 0) {
rect = toolbarElement.querySelector("#barMore").getBoundingClientRect(); rect = toolbarElement.querySelector("#barMore").getBoundingClientRect();
} }
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (targetId === "toolbarVIP") { } else if (targetId === "toolbarVIP") {
@ -216,7 +216,7 @@ export const initBar = (app: App) => {
if (rect.width === 0) { if (rect.width === 0) {
rect = toolbarElement.querySelector("#barMore").getBoundingClientRect(); rect = toolbarElement.querySelector("#barMore").getBoundingClientRect();
} }
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
event.stopPropagation(); event.stopPropagation();
break; break;
} }

View File

@ -125,7 +125,7 @@ export class Menu {
this.element.lastElementChild.append(element); this.element.lastElementChild.append(element);
} }
public popup(options: IPosition, isLeft = false) { public popup(options: IPosition) {
if (this.element.lastElementChild.innerHTML === "") { if (this.element.lastElementChild.innerHTML === "") {
return; return;
} }
@ -136,7 +136,7 @@ export class Menu {
} }
this.element.style.zIndex = (++window.siyuan.zIndex).toString(); this.element.style.zIndex = (++window.siyuan.zIndex).toString();
this.element.classList.remove("fn__none"); this.element.classList.remove("fn__none");
setPosition(this.element, options.x - (isLeft ? window.siyuan.menus.menu.element.clientWidth : 0), options.y, options.h, options.w); setPosition(this.element, options.x - (options.isLeft ? window.siyuan.menus.menu.element.clientWidth : 0), options.y, options.h, options.w);
} }
public fullscreen(position: "bottom" | "all" = "all") { public fullscreen(position: "bottom" | "all" = "all") {

View File

@ -635,7 +635,8 @@ export const initKeyboardToolbar = () => {
} else if (type === "more") { } else if (type === "more") {
protyle.breadcrumb.showMenu(protyle, { protyle.breadcrumb.showMenu(protyle, {
x: 0, x: 0,
y: 0 y: 0,
isLeft: true
}); });
activeBlur(); activeBlur();
hideKeyboardToolbar(); hideKeyboardToolbar();

View File

@ -45,7 +45,7 @@ export class Menu {
if (this.isOpen) { if (this.isOpen) {
return; return;
} }
this.menu.popup(options, options.isLeft); this.menu.popup(options);
} }
fullscreen(position: "bottom" | "all" = "all") { fullscreen(position: "bottom" | "all" = "all") {

View File

@ -101,6 +101,7 @@ export class Breadcrumb {
this.showMenu(protyle, { this.showMenu(protyle, {
x: targetRect.right, x: targetRect.right,
y: targetRect.bottom, y: targetRect.bottom,
isLeft: true,
}); });
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
@ -541,7 +542,7 @@ export class Breadcrumb {
/// #if MOBILE /// #if MOBILE
window.siyuan.menus.menu.fullscreen(); window.siyuan.menus.menu.fullscreen();
/// #else /// #else
window.siyuan.menus.menu.popup(position, true); window.siyuan.menus.menu.popup(position);
/// #endif /// #endif
}); });
} }

View File

@ -221,7 +221,7 @@ export class Gutter {
if (isMobile()) { if (isMobile()) {
window.siyuan.menus.menu.fullscreen(); window.siyuan.menus.menu.fullscreen();
} else { } else {
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true); window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});
focusByRange(protyle.toolbar.range); focusByRange(protyle.toolbar.range);
} }
} }
@ -233,7 +233,7 @@ export class Gutter {
} }
if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) { if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {
this.renderMenu(protyle, buttonElement); this.renderMenu(protyle, buttonElement);
window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true); window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16, isLeft: true});
} }
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();

View File

@ -235,7 +235,7 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))
/// #if MOBILE /// #if MOBILE
window.siyuan.menus.menu.fullscreen(); window.siyuan.menus.menu.fullscreen();
/// #else /// #else
window.siyuan.menus.menu.popup(position, position.isLeft); window.siyuan.menus.menu.popup(position);
/// #endif /// #endif
}); });
}; };

View File

@ -767,8 +767,9 @@ ${genHintItemHTML(item)}
const rect = nodeElement.getBoundingClientRect(); const rect = nodeElement.getBoundingClientRect();
window.siyuan.menus.menu.popup({ window.siyuan.menus.menu.popup({
x: rect.left, x: rect.left,
y: rect.top y: rect.top,
}, true); isLeft: true
});
const itemElement = window.siyuan.menus.menu.element.querySelector('[data-id="assetSubMenu"]'); const itemElement = window.siyuan.menus.menu.element.querySelector('[data-id="assetSubMenu"]');
itemElement.classList.add("b3-menu__item--show"); itemElement.classList.add("b3-menu__item--show");
window.siyuan.menus.menu.showSubMenu(itemElement.querySelector(".b3-menu__submenu")); window.siyuan.menus.menu.showSubMenu(itemElement.querySelector(".b3-menu__submenu"));

View File

@ -339,7 +339,7 @@ export const removeAttrViewColAnimation = (blockElement: Element, id: string) =>
}); });
}; };
export const insertAttrViewBlockAnimation = (blockElement: Element, size: number, previousId: string, avId?:string) => { export const insertAttrViewBlockAnimation = (blockElement: Element, size: number, previousId: string, avId?: string) => {
const previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header"); const previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header");
let colHTML = ""; let colHTML = "";
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement) => { previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement) => {

View File

@ -164,6 +164,7 @@ const calcItem = (options: {
} }
}); });
}; };
export const openCalcMenu = (protyle: IProtyle, calcElement: HTMLElement) => { export const openCalcMenu = (protyle: IProtyle, calcElement: HTMLElement) => {
const blockElement = hasClosestBlock(calcElement); const blockElement = hasClosestBlock(calcElement);
if (!blockElement) { if (!blockElement) {

View File

@ -7,6 +7,7 @@ import {genCellValue} from "./cell";
import {openMenuPanel} from "./openMenuPanel"; import {openMenuPanel} from "./openMenuPanel";
import {getLabelByNumberFormat} from "./number"; import {getLabelByNumberFormat} from "./number";
import {removeAttrViewColAnimation} from "./action"; import {removeAttrViewColAnimation} from "./action";
import {openEmojiPanel} from "../../../emoji";
export const duplicateCol = (options: { export const duplicateCol = (options: {
protyle: IProtyle, protyle: IProtyle,

View File

@ -601,7 +601,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
protyle.gutter.renderMultipleMenu(protyle, selectElements); protyle.gutter.renderMultipleMenu(protyle, selectElements);
} }
const rect = nodeElement.getBoundingClientRect(); const rect = nodeElement.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.left, y: rect.top}, true); window.siyuan.menus.menu.popup({x: rect.left, y: rect.top, isLeft: true});
return; return;
} }

View File

@ -409,7 +409,7 @@ export const assetMethodMenu = (target: HTMLElement, cb: () => void) => {
window.siyuan.menus.menu.fullscreen(); window.siyuan.menus.menu.fullscreen();
/// #else /// #else
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
/// #endif /// #endif
}; };
@ -559,6 +559,6 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
window.siyuan.menus.menu.fullscreen(); window.siyuan.menus.menu.fullscreen();
/// #else /// #else
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
/// #endif /// #endif
}; };

View File

@ -634,7 +634,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
}).element); }).element);
}); });
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;
@ -698,7 +698,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
inputEvent(element, config, undefined, edit, true); inputEvent(element, config, undefined, edit, true);
}); });
const rect = target.getBoundingClientRect(); const rect = target.getBoundingClientRect();
window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom}, true); window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;