An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Refine database attribute panel https://github.com/siyuan-note/siyuan/issues/18321
Danielf904eac943a5
diff --git a/app/src/assets/scss/business/_custom.scss b/app/src/assets/scss/business/_custom.scssindex 9ced2078c7..904491dd77 100644--- a/app/src/assets/scss/business/_custom.scss+++ b/app/src/assets/scss/business/_custom.scss@@ -235,8 +235,10 @@}.protyle-db-attr {- margin: 8px 16px 8px 24px;+ border-bottom: 1px solid var(--b3-border-color);border-radius: var(--b3-border-radius);+ margin: 8px 16px 8px 24px;+ padding-bottom: 8px;&__header {align-items: center;@@ -272,20 +274,31 @@}&__tabs {- align-items: center;- display: flex;- gap: 4px;+ background-color: transparent;margin: 0 8px 4px;max-width: 100%;- overflow-x: auto;- padding: 4px 0;+ padding: 0;- .b3-button {- flex-shrink: 0;+ .item {+ background-color: transparent;+ border: 0;+ font: inherit;+ margin: 2px 4px 2px 0;max-width: 220px;- overflow: hidden;- text-overflow: ellipsis;- white-space: nowrap;+ min-height: 28px;+ padding: 0 8px;++ &--focus {+ background-color: var(--b3-theme-primary-lightest);+ box-shadow: 0 0 0 1px var(--b3-theme-primary-lighter) inset;+ color: var(--b3-theme-on-background);+ }++ &__text {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }}}diff --git a/app/src/protyle/render/av/attributePanel.ts b/app/src/protyle/render/av/attributePanel.tsindex 62a6da7d8d..8c519ff4b2 100644--- a/app/src/protyle/render/av/attributePanel.ts+++ b/app/src/protyle/render/av/attributePanel.ts@@ -1,34 +1,7 @@import {renderAVAttribute} from "./blockAttr";-import {fetchPost} from "../../../util/fetch";const updateEmptyState = (element: HTMLElement, hideEmpty: boolean) => {element.classList.toggle("protyle-db-attr--hide-empty", hideEmpty);- const useElement = element.querySelector('[data-type="hideEmpty"] use');- useElement?.setAttribute("xlink:href", hideEmpty ? "#iconEyeoff" : "#iconEye");- const toggleElement = element.querySelector('[data-type="hideEmpty"]');- toggleElement?.setAttribute("aria-label", hideEmpty ? window.siyuan.languages.displayEmptyFields : window.siyuan.languages.hideEmptyFields);-};--let hideEmptySaving = false;-let hideEmptySavePending = false;-const saveHideEmpty = () => {- if (hideEmptySaving) {- hideEmptySavePending = true;- return;- }- hideEmptySaving = true;- const hideEmpty = window.siyuan.config.editor.databaseAttrHideEmpty;- void fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {- if (!hideEmptySavePending && window.siyuan.config.editor.databaseAttrHideEmpty === hideEmpty) {- window.siyuan.config.editor.databaseAttrHideEmpty = response.data.databaseAttrHideEmpty;- }- }).finally(() => {- hideEmptySaving = false;- if (hideEmptySavePending) {- hideEmptySavePending = false;- saveHideEmpty();- }- });};export class AVAttributePanel {@@ -48,21 +21,13 @@ export class AVAttributePanel {this.element.innerHTML = `<button type="button" class="protyle-db-attr__header fn__flex" data-type="toggle" aria-expanded="${!this.collapsed}" aria-label="${window.siyuan.languages.database}"><span class="block__icon block__icon--show fn__flex-center"><svg><use xlink:href="#iconRight"></use></svg></span><span class="block__logo fn__flex-1"><svg class="block__logoicon"><use xlink:href="#iconDatabase"></use></svg><span>${window.siyuan.languages.database}</span></span>- <span class="block__icon block__icon--show ariaLabel" data-type="hideEmpty" data-position="north" aria-label="${window.siyuan.languages.hideEmptyFields}"><svg><use xlink:href="#iconEye"></use></svg></span></button>`;this.bodyElement = document.createElement("div");this.bodyElement.className = "custom-attr protyle-db-attr__body";this.element.appendChild(this.bodyElement);this.element.addEventListener("click", (event) => {const target = event.target as HTMLElement;- if (target.closest('[data-type="hideEmpty"]')) {- const hideEmpty = !window.siyuan.config.editor.databaseAttrHideEmpty;- window.siyuan.config.editor.databaseAttrHideEmpty = hideEmpty;- document.querySelectorAll<HTMLElement>(".protyle-db-attr").forEach(item => updateEmptyState(item, hideEmpty));- saveHideEmpty();- event.preventDefault();- event.stopPropagation();- } else if (target.closest('[data-type="av-tab"]')) {+ if (target.closest('[data-type="av-tab"]')) {this.activeAvID = (target.closest('[data-type="av-tab"]') as HTMLElement).dataset.id || "";this.updateTabs();event.preventDefault();@@ -152,12 +117,12 @@ export class AVAttributePanel {if (useTabs && databaseElements.length > 1) {if (!tabsElement) {tabsElement = document.createElement("div");- tabsElement.className = "protyle-db-attr__tabs";+ tabsElement.className = "protyle-db-attr__tabs layout-tab-bar fn__flex";this.bodyElement.prepend(tabsElement);}tabsElement.innerHTML = databaseElements.map(item => {const title = item.querySelector(".custom-attr__avheader .block__logo span")?.textContent || window.siyuan.languages.database;- return `<button type="button" class="b3-button${item.dataset.avId === this.activeAvID ? " b3-button--outline" : ""}" data-type="av-tab" data-id="${item.dataset.avId}">${Lute.EscapeHTMLStr(title)}</button>`;+ return `<button type="button" class="item${item.dataset.avId === this.activeAvID ? " item--focus" : ""}" data-type="av-tab" data-id="${item.dataset.avId}"><span class="item__text">${Lute.EscapeHTMLStr(title)}</span></button>`;}).join("");} else {tabsElement?.remove();@@ -170,7 +135,7 @@ export class AVAttributePanel {});if (tabsElement) {tabsElement.querySelectorAll("[data-type=\"av-tab\"]").forEach(item => {- item.classList.toggle("b3-button--outline", item.getAttribute("data-id") === this.activeAvID);+ item.classList.toggle("item--focus", item.getAttribute("data-id") === this.activeAvID);});}}