Skip to content

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

:art: Unify database item template editor with database panel styles https://github.com/siyuan-note/siyuan/issues/19340

Daniel40af7f86aa8c
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index 672cf33468..76dc3bf4a8 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -272,6 +272,12 @@
}
}
+ &__template-panels {
+ @media (max-width: 750px) {
+ flex-direction: column;
+ }
+ }
+
&__template-list {
--file-toggle-width: 0px;
border-right: 1px solid var(--b3-border-color);
@@ -291,6 +297,14 @@
padding: 0 6px 0 4px;
}
}
+
+ @media (max-width: 750px) {
+ border-bottom: 1px solid var(--b3-border-color);
+ border-right: 0;
+ flex-shrink: 1;
+ max-height: 30vh;
+ width: auto;
+ }
}
&__template-editor .custom-attr__avvalue.av__template-switch {
@@ -304,14 +318,49 @@
}
}
+ &__template-editor .custom-attr .block__icons {
+ @media (max-width: 750px) {
+ flex-wrap: wrap;
+ }
+ }
+
&__template-editor .custom-attr .block__logo:not(.popover__block) {
cursor: default;
+ @media (max-width: 750px) {
+ align-self: auto;
+ flex: 1 1 100%;
+ width: auto;
+ }
+
&:hover {
background-color: transparent;
}
}
+ // 模板编辑器控件与筛选面板统一为描边卡片样式
+ &__template-editor .custom-attr {
+ .b3-text-field,
+ .b3-select {
+ border: 1px solid var(--b3-theme-surface-lighter);
+ border-radius: var(--b3-border-radius);
+ background-color: var(--b3-menu-background);
+ box-shadow: none;
+ outline: none;
+
+ &:hover,
+ &:focus {
+ background-color: var(--b3-menu-background);
+ box-shadow: none;
+ }
+ }
+
+ .b3-text-field {
+ min-height: 0;
+ padding: 4px 8px;
+ }
+ }
+
&__title {
outline: none;
font-weight: bold;
diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scss
index f7c965fd68..1f5a9369b2 100644
--- a/app/src/assets/scss/main/_mobile.scss
+++ b/app/src/assets/scss/main/_mobile.scss
@@ -1729,7 +1729,7 @@ body.mobile-topbar--merged {
transition: transform .15s cubic-bezier(0, 0, .2, 1);
}
- .mobile-bottom-sheet__handle {
+ .mobile-bottom-sheet > .b3-menu__title--root {
height: 16px;
flex-shrink: 0;
position: relative;
diff --git a/app/src/mobile/util/bindBottomSheetDialog.ts b/app/src/mobile/util/bindBottomSheetDialog.ts
index 2e455a9ba1..d26ffe3093 100644
--- a/app/src/mobile/util/bindBottomSheetDialog.ts
+++ b/app/src/mobile/util/bindBottomSheetDialog.ts
@@ -6,7 +6,8 @@ export const bindBottomSheetDialog = (dialog: Dialog, close: () => Promise<void>
const sheet = dialog.element.querySelector<HTMLElement>(".b3-dialog__container");
sheet.classList.add("mobile-bottom-sheet");
const handle = document.createElement("div");
- handle.className = "mobile-bottom-sheet__handle";
+ // 抓手与菜单抽屉保持一致,由 b3-menu__title 的伪元素绘制
+ handle.className = "b3-menu__title b3-menu__title--root";
handle.setAttribute("aria-hidden", "true");
sheet.prepend(handle);
const resize = () => {
diff --git a/app/src/protyle/render/av/newItemTemplate.ts b/app/src/protyle/render/av/newItemTemplate.ts
index 02de8cfea4..2a6f1f59c8 100644
--- a/app/src/protyle/render/av/newItemTemplate.ts
+++ b/app/src/protyle/render/av/newItemTemplate.ts
@@ -16,6 +16,11 @@ import * as dayjs from "dayjs";
import {getAVBlockRefSubtype} from "./cellValue";
import {getAVColorStyle} from "./color";
import {createAVPlainTextEditValue} from "./richTextValue";
+import {isMobile} from "../../../util/functions";
+/// #if MOBILE
+import {activeBlur} from "../../../mobile/util/keyboardToolbar";
+import {bindBottomSheetDialog} from "../../../mobile/util/bindBottomSheetDialog";
+/// #endif
interface ICreatePosition {
previousID?: string;
@@ -609,18 +614,34 @@ export const openNewItemTemplateDialog = (options: {
}
let defaultTemplateID = options.data.defaultTemplateID || "";
const dialog = new Dialog({
- title: window.siyuan.languages.itemTemplate,
- width: "820px",
- height: "70vh",
+ title: isMobile() ? undefined : window.siyuan.languages.itemTemplate,
+ width: isMobile() ? "100vw" : "820px",
+ height: isMobile() ? "60vh" : "70vh",
containerClassName: "b3-dialog__container--theme",
+ hideCloseIcon: isMobile(),
content: `<div class="fn__flex fn__flex-column" style="height:100%">
- <div class="fn__flex fn__flex-1" style="min-height:0">
+ <div class="av__template-panels fn__flex fn__flex-1" style="min-height:0">
<ul class="av__template-list b3-list b3-list--background" data-role="template-list"></ul>
<div data-role="editor-host" class="fn__flex-1 fn__flex"></div>
</div>
<div class="b3-dialog__action"><button class="b3-button b3-button--cancel" data-role="cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div><button class="b3-button b3-button--text" data-role="confirm">${window.siyuan.languages.confirm}</button></div>
</div>`,
+ destroyCallback: () => {
+ /// #if MOBILE
+ disposeSheet();
+ /// #endif
+ },
});
+ /// #if MOBILE
+ const destroyDialog = dialog.destroy.bind(dialog);
+ dialog.destroy = (destroyOptions?: IObject) => {
+ if (dialog.element.contains(document.activeElement)) {
+ activeBlur(true);
+ }
+ destroyDialog(destroyOptions);
+ };
+ const disposeSheet = bindBottomSheetDialog(dialog, async () => dialog.destroy());
+ /// #endif
const root = dialog.element;
const listElement = root.querySelector('[data-role="template-list"]') as HTMLElement;
const hostElement = root.querySelector('[data-role="editor-host"]') as HTMLElement;