Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Unify mobile menus as bottom sheets https://github.com/siyuan-note/siyuan/issues/19207

Daniel513c854799de
diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scss
index f1cb7a9eb3..1932f9a098 100644
--- a/app/src/assets/scss/main/_mobile.scss
+++ b/app/src/assets/scss/main/_mobile.scss
@@ -1403,6 +1403,17 @@ body.mobile-topbar--merged {
}
.b3-menu {
+ &--sheet {
+ // 菜单入口可能指定宽度,移动端底部菜单始终铺满视口
+ top: auto !important;
+ bottom: 0 !important;
+ left: 0 !important;
+ right: 0 !important;
+ width: auto !important;
+ min-width: 0 !important;
+ max-width: none !important;
+ }
+
&__accelerator--hotkey {
display: none;
}
@@ -1416,6 +1427,38 @@ body.mobile-topbar--merged {
}
}
+.av__panel {
+ > .b3-dialog__scrim {
+ background-color: rgba(0, 0, 0, .2);
+ }
+
+ > .b3-menu {
+ // 数据库面板切换内容时会重新写入锚点坐标,底部布局不随锚点变化
+ top: auto !important;
+ bottom: 0 !important;
+ left: 0 !important;
+ right: 0 !important;
+ width: auto !important;
+ min-width: 0 !important;
+ max-width: none !important;
+ height: 56vh;
+ max-height: 90vh !important;
+ max-height: 90dvh !important;
+ box-sizing: border-box;
+ border: 0;
+ border-radius: var(--b3-border-radius-b) var(--b3-border-radius-b) 0 0;
+ padding: 16px 8px max(16px, env(safe-area-inset-bottom));
+ overflow: auto;
+ overscroll-behavior: contain;
+ animation: bottom2Top .15s cubic-bezier(0, 0, .2, 1);
+
+ > .b3-menu__items {
+ max-height: none;
+ min-height: 0;
+ }
+ }
+}
+
#historyContainer,
#docHistoryContainer {
& > div {
diff --git a/app/src/menus/Menu.ts b/app/src/menus/Menu.ts
index 45222e73cf..c1bfd748da 100644
--- a/app/src/menus/Menu.ts
+++ b/app/src/menus/Menu.ts
@@ -532,6 +532,10 @@ export class Menu {
}
public popup(options: IPosition) {
+ if (isMobile()) {
+ this.fullscreen("bottom");
+ return;
+ }
applyMenuConfig(this.element);
if (this.element.lastElementChild.innerHTML === "") {
return;
@@ -551,7 +555,14 @@ export class Menu {
}
public resetPosition() {
- if (this.element.classList.contains("fn__none") || !this.position) {
+ if (this.element.classList.contains("fn__none")) {
+ return;
+ }
+ if (this.element.classList.contains("b3-menu--sheet")) {
+ this.setSheetHeight();
+ return;
+ }
+ if (!this.position) {
return;
}
if (this.position.target?.isConnected) {
@@ -594,6 +605,8 @@ export class Menu {
if (this.element.lastElementChild.innerHTML === "") {
return;
}
+ this.stopTrackingTargetPosition();
+ this.position = undefined;
this.emitCommonMenu("common-menu-open", {
name: this.element.getAttribute("data-name"),
from: this.element.getAttribute("data-from"),
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 529d76c182..149e47d74c 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -1474,16 +1474,12 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
}
});
}
- if (isMobile()) {
- menu.fullscreen("bottom");
- } else {
- const cellRect = cellElement.getBoundingClientRect();
- menu.open({
- x: cellRect.left,
- y: cellRect.bottom,
- h: cellRect.height
- });
- }
+ const cellRect = cellElement.getBoundingClientRect();
+ menu.open({
+ x: cellRect.left,
+ y: cellRect.bottom,
+ h: cellRect.height
+ });
/// #if !MOBILE
const inputElement = window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement;
if (inputElement) {