mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-12 15:11:10 +08:00
♻️ menu
This commit is contained in:
parent
828eeee4be
commit
82f9b9c60c
@ -628,7 +628,8 @@ export class Wnd {
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: rect.left + rect.width,
|
||||
y: rect.top + rect.height,
|
||||
}, true);
|
||||
isLeft: true
|
||||
});
|
||||
}
|
||||
|
||||
private removeOverCounter(oldFocusIndex?: number) {
|
||||
|
@ -53,7 +53,7 @@ export const initStatus = (isWindow = false) => {
|
||||
}).element);
|
||||
});
|
||||
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();
|
||||
break;
|
||||
} else if (target.id === "statusHelp") {
|
||||
@ -106,7 +106,7 @@ export const initStatus = (isWindow = false) => {
|
||||
}
|
||||
}).element);
|
||||
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();
|
||||
break;
|
||||
} else if (target.classList.contains("b3-menu__item")) {
|
||||
|
@ -100,7 +100,7 @@ export const initBar = (app: App) => {
|
||||
window.siyuan.menus.menu.append(new MenuItem(menuOptions).element);
|
||||
});
|
||||
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();
|
||||
break;
|
||||
} else if (targetId === "barForward") {
|
||||
@ -160,7 +160,7 @@ export const initBar = (app: App) => {
|
||||
if (rect.width === 0) {
|
||||
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();
|
||||
break;
|
||||
} else if (targetId === "toolbarVIP") {
|
||||
@ -216,7 +216,7 @@ export const initBar = (app: App) => {
|
||||
if (rect.width === 0) {
|
||||
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();
|
||||
break;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ export class Menu {
|
||||
this.element.lastElementChild.append(element);
|
||||
}
|
||||
|
||||
public popup(options: IPosition, isLeft = false) {
|
||||
public popup(options: IPosition) {
|
||||
if (this.element.lastElementChild.innerHTML === "") {
|
||||
return;
|
||||
}
|
||||
@ -136,7 +136,7 @@ export class Menu {
|
||||
}
|
||||
this.element.style.zIndex = (++window.siyuan.zIndex).toString();
|
||||
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") {
|
||||
|
@ -635,7 +635,8 @@ export const initKeyboardToolbar = () => {
|
||||
} else if (type === "more") {
|
||||
protyle.breadcrumb.showMenu(protyle, {
|
||||
x: 0,
|
||||
y: 0
|
||||
y: 0,
|
||||
isLeft: true
|
||||
});
|
||||
activeBlur();
|
||||
hideKeyboardToolbar();
|
||||
|
@ -45,7 +45,7 @@ export class Menu {
|
||||
if (this.isOpen) {
|
||||
return;
|
||||
}
|
||||
this.menu.popup(options, options.isLeft);
|
||||
this.menu.popup(options);
|
||||
}
|
||||
|
||||
fullscreen(position: "bottom" | "all" = "all") {
|
||||
|
@ -101,6 +101,7 @@ export class Breadcrumb {
|
||||
this.showMenu(protyle, {
|
||||
x: targetRect.right,
|
||||
y: targetRect.bottom,
|
||||
isLeft: true,
|
||||
});
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
@ -541,7 +542,7 @@ export class Breadcrumb {
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
window.siyuan.menus.menu.popup(position, true);
|
||||
window.siyuan.menus.menu.popup(position);
|
||||
/// #endif
|
||||
});
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ export class Gutter {
|
||||
if (isMobile()) {
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ export class Gutter {
|
||||
}
|
||||
if (!window.siyuan.ctrlIsPressed && !window.siyuan.altIsPressed && !window.siyuan.shiftIsPressed) {
|
||||
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.stopPropagation();
|
||||
|
@ -235,7 +235,7 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))
|
||||
/// #if MOBILE
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
window.siyuan.menus.menu.popup(position, position.isLeft);
|
||||
window.siyuan.menus.menu.popup(position);
|
||||
/// #endif
|
||||
});
|
||||
};
|
||||
|
@ -767,8 +767,9 @@ ${genHintItemHTML(item)}
|
||||
const rect = nodeElement.getBoundingClientRect();
|
||||
window.siyuan.menus.menu.popup({
|
||||
x: rect.left,
|
||||
y: rect.top
|
||||
}, true);
|
||||
y: rect.top,
|
||||
isLeft: true
|
||||
});
|
||||
const itemElement = window.siyuan.menus.menu.element.querySelector('[data-id="assetSubMenu"]');
|
||||
itemElement.classList.add("b3-menu__item--show");
|
||||
window.siyuan.menus.menu.showSubMenu(itemElement.querySelector(".b3-menu__submenu"));
|
||||
|
@ -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");
|
||||
let colHTML = "";
|
||||
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement) => {
|
||||
|
@ -164,6 +164,7 @@ const calcItem = (options: {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const openCalcMenu = (protyle: IProtyle, calcElement: HTMLElement) => {
|
||||
const blockElement = hasClosestBlock(calcElement);
|
||||
if (!blockElement) {
|
||||
|
@ -7,6 +7,7 @@ import {genCellValue} from "./cell";
|
||||
import {openMenuPanel} from "./openMenuPanel";
|
||||
import {getLabelByNumberFormat} from "./number";
|
||||
import {removeAttrViewColAnimation} from "./action";
|
||||
import {openEmojiPanel} from "../../../emoji";
|
||||
|
||||
export const duplicateCol = (options: {
|
||||
protyle: IProtyle,
|
||||
|
@ -601,7 +601,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
||||
protyle.gutter.renderMultipleMenu(protyle, selectElements);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ export const assetMethodMenu = (target: HTMLElement, cb: () => void) => {
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
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
|
||||
};
|
||||
|
||||
@ -559,6 +559,6 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)
|
||||
window.siyuan.menus.menu.fullscreen();
|
||||
/// #else
|
||||
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
|
||||
};
|
||||
|
@ -634,7 +634,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
|
||||
}).element);
|
||||
});
|
||||
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.preventDefault();
|
||||
break;
|
||||
@ -698,7 +698,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
|
||||
inputEvent(element, config, undefined, edit, true);
|
||||
});
|
||||
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.preventDefault();
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user