An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Keep button menus anchored and scroll within available space https://github.com/siyuan-note/siyuan/issues/19269
Daniel3f152a8e73a1
diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.tsindex a4775b57f7..7a950453bd 100644--- a/app/src/card/openCard.ts+++ b/app/src/card/openCard.ts@@ -518,7 +518,8 @@ export const bindCardEvent = async (options: {const rect = moreElement.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});/// #endifreturn;@@ -607,7 +608,8 @@ export const bindCardEvent = async (options: {const rect = sticktabElement.getBoundingClientRect();stickMenu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});event.stopPropagation();event.preventDefault();@@ -682,7 +684,7 @@ export const bindCardEvent = async (options: {}).element);});const filterRect = filterTempElement.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: filterRect.left, y: filterRect.bottom});+ window.siyuan.menus.menu.popup({x: filterRect.left, y: filterRect.bottom, h: filterRect.height});});event.stopPropagation();event.preventDefault();diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.tsindex 17f5c9f65c..809e5fd928 100644--- a/app/src/layout/Wnd.ts+++ b/app/src/layout/Wnd.ts@@ -895,6 +895,7 @@ export class Wnd {window.siyuan.menus.menu.popup({x: rect.left + rect.width,y: rect.top + rect.height,+ h: rect.height,isLeft: true});}diff --git a/app/src/layout/dock/BacklinkContent.ts b/app/src/layout/dock/BacklinkContent.tsindex e6df7f464e..fa9a9f03ef 100644--- a/app/src/layout/dock/BacklinkContent.ts+++ b/app/src/layout/dock/BacklinkContent.ts@@ -489,13 +489,15 @@ export class BacklinkContent extends Model {event.stopPropagation();break;case "sort":- case "mSort":+ case "mSort": {this.showSortMenu(type, target.getAttribute("data-sort"));- window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});+ const rect = target.getBoundingClientRect();+ window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom, h: rect.height});event.stopPropagation();break;+ }case "sourceFilter":- this.showSourceFilterMenu(event);+ this.showSourceFilterMenu(target);event.stopPropagation();break;case "layout":@@ -865,7 +867,7 @@ export class BacklinkContent extends Model {);}- private showSourceFilterMenu(event: MouseEvent) {+ private showSourceFilterMenu(target: HTMLElement) {let foldedTypes = normalizeBacklinkFoldTypes(this.viewState?.get("foldedBlockTypes"));const foldItems = new Map<string, HTMLElement>();let foldResetElement: HTMLElement;@@ -1022,7 +1024,8 @@ export class BacklinkContent extends Model {applyFoldTypes([]);}}).element);- window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});+ const rect = target.getBoundingClientRect();+ window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom, h: rect.height});}private toggleItem(liElement: HTMLElement, isMention: boolean, persist = true) {diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.tsindex 1e1f612f13..fac415241f 100644--- a/app/src/layout/dock/Files.ts+++ b/app/src/layout/dock/Files.ts@@ -207,7 +207,8 @@ export class Files extends Model {event.preventDefault();break;} else if (type === "more") {- this.initMoreMenu().popup({x: event.clientX, y: event.clientY});+ const rect = target.getBoundingClientRect();+ this.initMoreMenu().popup({x: rect.left, y: rect.bottom, h: rect.height});event.preventDefault();event.stopPropagation();break;@@ -333,16 +334,20 @@ export class Files extends Model {if (type === "new") {newFileInTree(options.app, notebookId, pathString);} else if (type === "more-root") {+ const rect = target.getBoundingClientRect();initNavigationMenu(options.app, target.parentElement).popup({- x: event.clientX,- y: event.clientY+ x: rect.left,+ y: rect.bottom,+ h: rect.height,});}}if (type === "more-file") {+ const rect = target.getBoundingClientRect();initFileMenu(options.app, notebookId, pathString, target.parentElement).popup({- x: event.clientX,- y: event.clientY+ x: rect.left,+ y: rect.bottom,+ h: rect.height,});}event.preventDefault();diff --git a/app/src/layout/dock/Inbox.ts b/app/src/layout/dock/Inbox.tsindex 4cead52edf..8393e5b1d6 100644--- a/app/src/layout/dock/Inbox.ts+++ b/app/src/layout/dock/Inbox.ts@@ -300,7 +300,13 @@ ${data.shorthandContent}},separatorPosition: "top",});- window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16});+ const button = (event.target as Element).closest("[data-type='more']");+ const rect = !itemElement ? button?.getBoundingClientRect() : undefined;+ window.siyuan.menus.menu.popup({+ x: rect ? rect.left : event.clientX,+ y: rect ? rect.bottom : event.clientY + 16,+ h: rect ? rect.height : 0,+ });}private remove(removeIds?: string[]) {diff --git a/app/src/layout/dock/Tag.ts b/app/src/layout/dock/Tag.tsindex c349791606..82ef167107 100644--- a/app/src/layout/dock/Tag.ts+++ b/app/src/layout/dock/Tag.ts@@ -118,7 +118,7 @@ export class Tag extends Model {case "min":getDockByType("tag").toggleModel("tag", false, true);break;- case "sort":+ case "sort": {window.siyuan.menus.menu.remove();window.siyuan.menus.menu.append(new MenuItem({icon: window.siyuan.config.tag.sort === 0 ? "iconSelect" : undefined,@@ -168,10 +168,12 @@ export class Tag extends Model {this.update();},}).element);- window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});+ const rect = target.getBoundingClientRect();+ window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom, h: rect.height});event.preventDefault();event.stopPropagation();break;+ }case "refresh":this.update();break;diff --git a/app/src/layout/status.ts b/app/src/layout/status.tsindex f4823c576c..711c7a8d4f 100644--- a/app/src/layout/status.ts+++ b/app/src/layout/status.ts@@ -56,7 +56,7 @@ export const initStatus = (isWindow = false) => {}).element);});const rect = target.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: rect.right, y: rect.top, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();break;} else if (target.id === "statusHelp") {@@ -110,7 +110,7 @@ export const initStatus = (isWindow = false) => {}}).element);const rect = target.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: rect.right, y: rect.top, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();break;} else if (target.classList.contains("b3-menu__item")) {diff --git a/app/src/layout/topBar.ts b/app/src/layout/topBar.tsindex e86546ed16..316974c6a9 100644--- a/app/src/layout/topBar.ts+++ b/app/src/layout/topBar.ts@@ -168,7 +168,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, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();break;} else if (targetId === "barForward") {@@ -229,7 +229,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, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();break;} else if (targetId === "toolbarVIP" || targetId === "toolbarTitle") {@@ -288,7 +288,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, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();break;}diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.tsindex c1bfd748da..c6991d02ee 100644--- a/app/src/menus/Menu.ts+++ b/app/src/menus/Menu.ts@@ -1,5 +1,6 @@import {getEventName, updateHotkeyTip} from "../protyle/util/compatibility";import {setPosition} from "../util/setPosition";+import {getAnchoredMenuPosition} from "./menuPosition";import {hasClosestByClassName} from "../protyle/util/hasClosest";import {isMobile} from "../util/functions";import {Constants} from "../constants";@@ -549,11 +550,29 @@ export class Menu {this.element.style.zIndex = (++window.siyuan.zIndex).toString();this.element.classList.remove("fn__none");this.position = options;- setPosition(this.element, options.x - (options.isLeft ? this.element.clientWidth : 0), options.y, options.h, options.w);- this.updateMaxHeight(this.element, this.element.lastElementChild as HTMLElement);+ this.setPopupPosition();this.startTrackingTargetPosition();}+ private setPopupPosition() {+ const options = this.position;+ const itemsElement = this.element.lastElementChild as HTMLElement;+ if (options.h > 0) {+ // 先按锚点一侧的可用空间限制内容高度,避免长菜单跨过按钮。+ itemsElement.style.maxHeight = "";+ const menuHeight = this.element.getBoundingClientRect().height;+ const position = getAnchoredMenuPosition(options.y, options.h, menuHeight,+ window.innerHeight, getTopBarHeight());+ const chromeHeight = menuHeight - itemsElement.getBoundingClientRect().height;+ itemsElement.style.maxHeight = Math.max(0, position.height - chromeHeight) + "px";+ setPosition(this.element, options.x - (options.isLeft ? this.element.clientWidth : 0),+ position.top, 0, options.w);+ return;+ }+ setPosition(this.element, options.x - (options.isLeft ? this.element.clientWidth : 0), options.y, options.h, options.w);+ this.updateMaxHeight(this.element, itemsElement);+ }+public resetPosition() {if (this.element.classList.contains("fn__none")) {return;@@ -572,8 +591,7 @@ export class Menu {this.position.h = rect.height;this.position.w = rect.width;}- setPosition(this.element, this.position.x - (this.position.isLeft ? this.element.clientWidth : 0), this.position.y, this.position.h, this.position.w);- this.updateMaxHeight(this.element, this.element.lastElementChild as HTMLElement);+ this.setPopupPosition();this.element.querySelectorAll(".b3-menu__item--show .b3-menu__submenu").forEach((item: HTMLElement) => {// 可能有多层子菜单,都要重新定位this.showSubMenu(item);diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex 1437203735..778fb2cd1e 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -367,7 +367,8 @@ export const openFileAttr = (attrs: Record<string, string>, focusName = "bookmar});}window.siyuan.menus.menu.element.classList.add("b3-menu--list");- window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY + 16, w: 16});+ const rect = target.getBoundingClientRect();+ window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom, h: rect.height, w: rect.width});});event.stopPropagation();event.preventDefault();diff --git a/app/src/menus/index.ts b/app/src/menus/index.tsindex f62896a13e..99768b6881 100644--- a/app/src/menus/index.ts+++ b/app/src/menus/index.ts@@ -74,16 +74,25 @@ export class Menus {}this.unselect();// navigation 根上:新建文档/文件夹/取消挂在/打开文件位置- initNavigationMenu(app, target).popup({x: event.clientX, y: event.clientY});+ const menuButton = (event.target as Element).closest("[data-type='more-root']");+ const rect = menuButton?.getBoundingClientRect();+ initNavigationMenu(app, target).popup({+ x: rect ? rect.left : event.clientX,+ y: rect ? rect.bottom : event.clientY,+ h: rect ? rect.height : 0,+ });setPanelFocus(hasClosestByClassName(target, "sy__file") as HTMLElement);event.stopPropagation();break;} else if (dataType === "navigation-file") {this.unselect();+ const menuButton = (event.target as Element).closest("[data-type='more-file']");+ const rect = menuButton?.getBoundingClientRect();// navigation 文件上:删除/重命名/打开文件位置/导出initFileMenu(app, this.getDir(target), target.getAttribute("data-path"), target).popup({- x: event.clientX,- y: event.clientY+ x: rect ? rect.left : event.clientX,+ y: rect ? rect.bottom : event.clientY,+ h: rect ? rect.height : 0,});setPanelFocus(hasClosestByClassName(target, "sy__file") as HTMLElement);event.stopPropagation();diff --git a/app/src/menus/menuPosition.test.ts b/app/src/menus/menuPosition.test.tsnew file mode 100644index 0000000000..b77f5bb73b--- /dev/null+++ b/app/src/menus/menuPosition.test.ts@@ -0,0 +1,25 @@+import {describe, it} from "node:test";+import * as assert from "node:assert/strict";+import {getAnchoredMenuPosition} from "./menuPosition";++describe("getAnchoredMenuPosition", () => {+ it("keeps a short menu below the button", () => {+ assert.deepEqual(getAnchoredMenuPosition(300, 24, 200, 800, 32), {top: 300, height: 200});+ });++ it("opens above when the complete menu fits there", () => {+ assert.deepEqual(getAnchoredMenuPosition(700, 24, 300, 800, 32), {top: 376, height: 300});+ });++ it("limits a long menu to the larger space below", () => {+ assert.deepEqual(getAnchoredMenuPosition(300, 24, 700, 800, 32), {top: 300, height: 500});+ });++ it("limits a long menu above without overlapping the button or top bar", () => {+ assert.deepEqual(getAnchoredMenuPosition(500, 24, 700, 800, 32), {top: 32, height: 444});+ });++ it("recalculates the available height after the window shrinks", () => {+ assert.deepEqual(getAnchoredMenuPosition(300, 24, 700, 400, 32), {top: 32, height: 244});+ });+});diff --git a/app/src/menus/menuPosition.ts b/app/src/menus/menuPosition.tsnew file mode 100644index 0000000000..c602bb71b0--- /dev/null+++ b/app/src/menus/menuPosition.ts@@ -0,0 +1,11 @@+export const getAnchoredMenuPosition = (bottom: number, targetHeight: number, menuHeight: number,+ viewportHeight: number, topBarHeight: number) => {+ const below = Math.max(0, viewportHeight - bottom);+ const above = Math.max(0, bottom - targetHeight - topBarHeight);+ const openAbove = menuHeight > below && (menuHeight <= above || above > below);+ const height = Math.min(menuHeight, openAbove ? above : below);+ return {+ top: openAbove ? bottom - targetHeight - height : bottom,+ height,+ };+};diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.tsindex b462810e8e..db81f3f917 100644--- a/app/src/menus/workspace.ts+++ b/app/src/menus/workspace.ts@@ -742,7 +742,7 @@ export const workspaceMenu = async (app: App, rect: DOMRect) => {}}).element);}- window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom});+ window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom, h: rect.height});};if (getHostCapabilities().workspaces) {fetchPost("/api/system/getWorkspaces", {}, (response) => renderMenu(response.data));diff --git a/app/src/plugin/openTopBarMenu.ts b/app/src/plugin/openTopBarMenu.tsindex 4ed0e43ada..37e5965dc0 100644--- a/app/src/plugin/openTopBarMenu.ts+++ b/app/src/plugin/openTopBarMenu.ts@@ -137,7 +137,7 @@ export const openTopBarMenu = (app: App, target?: Element) => {if (rect.width === 0) {rect = document.querySelector("#barMore").getBoundingClientRect();}- menu.open({x: rect.right, y: rect.bottom, isLeft: true});+ menu.open({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});} else {menu.fullscreen();}diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.tsindex e22b25b975..3112bc9a90 100644--- a/app/src/protyle/breadcrumb/index.ts+++ b/app/src/protyle/breadcrumb/index.ts@@ -102,6 +102,7 @@ ${padHTML}this.openChildrenMenu(protyle, itemElement.getAttribute("data-node-id"), {x: targetRect.left,y: targetRect.bottom,+ h: targetRect.height,isLeft: false,});event.preventDefault();@@ -145,7 +146,7 @@ ${padHTML}});} else {const targetRect = target.getBoundingClientRect();- openTitleMenu(protyle, {x: targetRect.right, y: targetRect.bottom, isLeft: true}, Constants.MENU_FROM_TITLE_BREADCRUMB);+ openTitleMenu(protyle, {x: targetRect.right, y: targetRect.bottom, h: targetRect.height, isLeft: true}, Constants.MENU_FROM_TITLE_BREADCRUMB);}event.stopPropagation();event.preventDefault();@@ -155,6 +156,7 @@ ${padHTML}this.showMenu(protyle, {x: targetRect.right,y: targetRect.bottom,+ h: targetRect.height,isLeft: true,});event.stopPropagation();@@ -240,6 +242,15 @@ ${padHTML}}});/// #if !MOBILE+ element.querySelector("[data-type='doc']").addEventListener("contextmenu", (event: MouseEvent) => {+ if (event.shiftKey) {+ return;+ }+ event.preventDefault();+ event.stopPropagation();+ const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();+ openTitleMenu(protyle, {x: rect.right, y: rect.bottom, h: rect.height, isLeft: true}, Constants.MENU_FROM_TITLE_BREADCRUMB);+ });this.element.addEventListener("contextmenu", (event) => {const itemElement = (event.target as HTMLElement).closest(".protyle-breadcrumb__item");if (!itemElement || !this.element.contains(itemElement)) {@@ -276,6 +287,7 @@ ${padHTML}this.openChildrenMenu(protyle, itemElement.getAttribute("data-node-id"), {x: itemRect.left,y: itemRect.bottom,+ h: itemRect.height,isLeft: false,}, true);event.preventDefault();diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 5162bee958..8d64342d02 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -389,7 +389,7 @@ export class Gutter {this.getNodeElement(protyle, activeBlockButton) || protyle.wysiwyg.element.firstElementChild);}/// #if !MOBILE- window.siyuan.menus.menu.popup({x: br.left, y: br.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: br.left, y: br.bottom, h: br.height, isLeft: true});restoreGutterRange(protyle.toolbar.range);/// #endif}@@ -671,7 +671,7 @@ export class Gutter {/// #if MOBILEwindow.siyuan.menus.menu.fullscreen();/// #else- window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, h: gutterRect.height, isLeft: true});const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");restoreGutterRange(protyle.toolbar.range);@@ -714,7 +714,7 @@ export class Gutter {/// #if MOBILEwindow.siyuan.menus.menu.fullscreen();/// #else- window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: gutterRect.left, y: gutterRect.bottom, h: gutterRect.height, isLeft: true});const popoverElement = hasTopClosestByClassName(protyle.element, "block__popover", true);window.siyuan.menus.menu.element.setAttribute("data-from", popoverElement ? popoverElement.dataset.level + "popover" : "app");restoreGutterRange(protyle.toolbar.range);diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.tsindex 903095e64a..7e8768ab0d 100644--- a/app/src/protyle/header/Background.ts+++ b/app/src/protyle/header/Background.ts@@ -914,7 +914,7 @@ export class Background {itemsElement.firstElementChild.setAttribute("style", "padding: 0 8px;height: 100%;");/// #elseconst rect = target.getBoundingClientRect();- menu.open({x: rect.left, y: rect.top + rect.height});+ menu.open({x: rect.left, y: rect.top + rect.height, h: rect.height});menu.element.querySelector("input").focus();/// #endif}diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 0f6ff9da36..3505c24e1c 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -197,14 +197,21 @@ export class Title {});} else {const iconRect = iconElement.getBoundingClientRect();- openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom}, Constants.MENU_FROM_TITLE_PROTYLE);+ openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom, h: iconRect.height}, Constants.MENU_FROM_TITLE_PROTYLE);}});this.element.addEventListener("contextmenu", async (event) => {if (event.shiftKey) {return;}- if (getSelection().rangeCount === 0 || iconElement.contains((event.target as HTMLElement))) {+ if (iconElement.contains(event.target as Node)) {+ event.preventDefault();+ event.stopPropagation();+ const iconRect = iconElement.getBoundingClientRect();+ openTitleMenu(protyle, {x: iconRect.left, y: iconRect.bottom, h: iconRect.height}, Constants.MENU_FROM_TITLE_PROTYLE);+ return;+ }+ if (getSelection().rangeCount === 0) {openTitleMenu(protyle, {x: event.clientX, y: event.clientY}, Constants.MENU_FROM_TITLE_PROTYLE);return;}diff --git a/app/src/protyle/render/av/asset.ts b/app/src/protyle/render/av/asset.tsindex d7e84fe268..8a0482946b 100644--- a/app/src/protyle/render/av/asset.ts+++ b/app/src/protyle/render/av/asset.ts@@ -443,7 +443,7 @@ export const editAssetItem = (options: {/// #elsemenu.open({x: rect.right,- y: rect.top,+ y: rect.bottom,w: rect.width,h: rect.height,});diff --git a/app/src/protyle/render/av/gallery/util.ts b/app/src/protyle/render/av/gallery/util.tsindex 012730bb4e..ed5c4f9506 100644--- a/app/src/protyle/render/av/gallery/util.ts+++ b/app/src/protyle/render/av/gallery/util.ts@@ -143,7 +143,7 @@ export const setGalleryCover = (options: {}});const rect = options.target.getBoundingClientRect();- menu.open({x: rect.left, y: rect.bottom});+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});};export const setGallerySize = (options: {@@ -220,7 +220,7 @@ export const setGallerySize = (options: {}});const rect = options.target.getBoundingClientRect();- menu.open({x: rect.left, y: rect.bottom});+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});};export const setGalleryRatio = (options: {@@ -298,7 +298,7 @@ export const setGalleryRatio = (options: {}});const rect = options.target.getBoundingClientRect();- menu.open({x: rect.left, y: rect.bottom});+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});};export const openGalleryItemMenu = (options: {diff --git a/app/src/protyle/render/av/groups.ts b/app/src/protyle/render/av/groups.tsindex bcdc99101f..a2d712cbec 100644--- a/app/src/protyle/render/av/groups.ts+++ b/app/src/protyle/render/av/groups.ts@@ -387,7 +387,8 @@ export const goGroupsDate = (options: {menu.open({isLeft: true,x: rect.right,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};@@ -438,6 +439,7 @@ export const goGroupsSort = (options: {menu.open({isLeft: true,x: rect.right,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};diff --git a/app/src/protyle/render/av/layout.ts b/app/src/protyle/render/av/layout.tsindex b919b55ddd..88e203a9f0 100644--- a/app/src/protyle/render/av/layout.ts+++ b/app/src/protyle/render/av/layout.ts@@ -307,7 +307,7 @@ export const bindLayoutEvent = (options: {});});const rect = cardLayoutElement.getBoundingClientRect();- menu.open({x: rect.left, y: rect.bottom});+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});event.preventDefault();event.stopPropagation();});diff --git a/app/src/protyle/render/av/newItemTemplate.ts b/app/src/protyle/render/av/newItemTemplate.tsindex b45e19e4e1..80499e2fc4 100644--- a/app/src/protyle/render/av/newItemTemplate.ts+++ b/app/src/protyle/render/av/newItemTemplate.ts@@ -766,7 +766,7 @@ export const openNewItemTemplateDialog = (options: {},});const rect = target.getBoundingClientRect();- menu.open({x: rect.right, y: rect.top, h: rect.height});+ menu.open({x: rect.right, y: rect.bottom, h: rect.height});};let draggingIndex = -1;diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex be95540739..47c2fe614e 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -1049,7 +1049,8 @@ export const openMenuPanel = (options: {}});}- menu.open({x: event.clientX, y: event.clientY, h: 28});+ const rect = target.getBoundingClientRect();+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});event.preventDefault();event.stopPropagation();break;@@ -1106,7 +1107,8 @@ export const openMenuPanel = (options: {setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height, 0, true);}});- menu.open({x: event.clientX, y: event.clientY, h: 28});+ const rect = target.getBoundingClientRect();+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});event.preventDefault();event.stopPropagation();break;diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.tsindex f1388be02e..71de50983d 100644--- a/app/src/protyle/render/av/row.ts+++ b/app/src/protyle/render/av/row.ts@@ -858,7 +858,8 @@ export const setPageSize = (options: {const rect = options.target.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};diff --git a/app/src/protyle/render/av/view.ts b/app/src/protyle/render/av/view.tsindex 8bafcbcd49..20488d904e 100644--- a/app/src/protyle/render/av/view.ts+++ b/app/src/protyle/render/av/view.ts@@ -176,7 +176,8 @@ export const openViewMenu = (options: { protyle: IProtyle, blockElement: HTMLEleconst rect = options.element.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};@@ -526,7 +527,8 @@ export const addView = (protyle: IProtyle, blockElement: Element) => {const addRect = viewElement.querySelector('.block__icon[data-type="av-add"]')?.getBoundingClientRect();addMenu.open({x: addRect.left,- y: addRect.bottom + 8+ y: addRect.bottom + 8,+ h: addRect.height + 8});};diff --git a/app/src/protyle/wysiwyg/tabs.ts b/app/src/protyle/wysiwyg/tabs.tsindex 1da2caedb0..310f15484e 100644--- a/app/src/protyle/wysiwyg/tabs.ts+++ b/app/src/protyle/wysiwyg/tabs.ts@@ -214,7 +214,7 @@ export const openTabsMenu = (protyle: IProtyle, tabs: HTMLElement, item: HTMLEle}});}const rect = anchor.getBoundingClientRect();- menu.open({x: rect.left, y: rect.bottom});+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});};export const initEditorTabs = (protyle: IProtyle) => {diff --git a/app/src/search/assets.ts b/app/src/search/assets.tsindex 424b4302b9..61562575f1 100644--- a/app/src/search/assets.ts+++ b/app/src/search/assets.ts@@ -305,7 +305,7 @@ export const assetMethodMenu = (target: HTMLElement, cb: () => void) => {window.siyuan.menus.menu.fullscreen();/// #elseconst rect = target.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});/// #endif};@@ -458,6 +458,6 @@ export const assetMoreMenu = (target: Element, element: Element, cb: () => void)window.siyuan.menus.menu.fullscreen();/// #elseconst rect = target.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});/// #endif};diff --git a/app/src/search/toggleHistory.ts b/app/src/search/toggleHistory.tsindex 133499e992..70f9eaa3c1 100644--- a/app/src/search/toggleHistory.ts+++ b/app/src/search/toggleHistory.ts@@ -74,7 +74,8 @@ export const toggleReplaceHistory = (replaceInputElement: HTMLInputElement) => {const rect = replaceInputElement.previousElementSibling.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};@@ -149,7 +150,8 @@ export const toggleSearchHistory = (searchElement: Element, config: Config.IUILaconst rect = searchInputElement.previousElementSibling.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};@@ -218,7 +220,8 @@ export const toggleAssetHistory = (assetElement: Element) => {const rect = assetInputElement.previousElementSibling.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};diff --git a/app/src/search/unRef.ts b/app/src/search/unRef.tsindex 9877b5cabe..ea95127de7 100644--- a/app/src/search/unRef.ts+++ b/app/src/search/unRef.ts@@ -196,6 +196,6 @@ export const unRefMoreMenu = (target: Element, element: Element, edit: Protyle)menu.fullscreen();/// #elseconst rect = target.getBoundingClientRect();- menu.open({x: rect.right, y: rect.bottom, isLeft: true});+ menu.open({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});/// #endif};diff --git a/app/src/search/util.ts b/app/src/search/util.tsindex d6c67a5b97..f1fabb517c 100644--- a/app/src/search/util.ts+++ b/app/src/search/util.ts@@ -732,7 +732,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, ele}).element);});const rect = target.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();event.preventDefault();break;@@ -803,7 +803,7 @@ export const genSearch = (app: App, config: Config.IUILayoutTabSearchConfig, elepersistSearchConfig(config);});const rect = target.getBoundingClientRect();- window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, isLeft: true});+ window.siyuan.menus.menu.popup({x: rect.right, y: rect.bottom, h: rect.height, isLeft: true});event.stopPropagation();event.preventDefault();break;diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex aeb77d05f0..74cad0def7 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -437,7 +437,8 @@ export const movePathTo = (options: {const rect = inputElement.getBoundingClientRect();menu.open({x: rect.left,- y: rect.bottom+ y: rect.bottom,+ h: rect.height});};inputEvent();