An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Show database attributes in editors https://github.com/siyuan-note/siyuan/issues/11371
Danielc57bf9adb701
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex ad69f19062..ece58fdac0 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "الحالة الافتراضية لخصائص قاعدة البيانات",+ "databaseAttrViewModeTip": "تحديد ما إذا كانت خصائص قاعدة البيانات موسعة عند فتح مستند",+ "bind": "ربط","targetNotebook": "دفتر الملاحظات الهدف","dataMigration": "ترحيل البيانات","settingsAndSync": "الإعدادات والمزامنة",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex b28292b2d1..4cac57141d 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Standardstatus der Datenbankeigenschaften",+ "databaseAttrViewModeTip": "Legt fest, ob Datenbankeigenschaften beim Öffnen eines Dokuments erweitert sind",+ "bind": "Verknüpfen","targetNotebook": "Zielnotizbuch","dataMigration": "Datenmigration","settingsAndSync": "Einstellungen und Synchronisierung",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 74f83f4781..39f4656db1 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Default state of database attributes",+ "databaseAttrViewModeTip": "Set whether database attributes are expanded when opening a document",+ "bind": "Bind","targetNotebook": "Target notebook","dataMigration": "Data migration","settingsAndSync": "Settings and sync",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex ead3a62dd3..811685c0e3 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Estado predeterminado de las propiedades de la base de datos",+ "databaseAttrViewModeTip": "Define si las propiedades de la base de datos se expanden al abrir un documento",+ "bind": "Vincular","targetNotebook": "Cuaderno de destino","dataMigration": "Migración de datos","settingsAndSync": "Ajustes y sincronización",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex 1fe7065694..fd8d40e5c9 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "État par défaut des propriétés de la base de données",+ "databaseAttrViewModeTip": "Définit si les propriétés de la base de données sont développées à l'ouverture d'un document",+ "bind": "Lier","targetNotebook": "Carnet cible","dataMigration": "Migration des données","settingsAndSync": "Paramètres et synchronisation",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex 0131074643..6ee8784a0d 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "מצב ברירת המחדל של מאפייני מסד הנתונים",+ "databaseAttrViewModeTip": "הגדר אם מאפייני מסד הנתונים יורחבו בעת פתיחת מסמך",+ "bind": "קישור","targetNotebook": "מחברת יעד","dataMigration": "העברת נתונים","settingsAndSync": "הגדרות וסנכרון",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex 815df3580d..0ea9152408 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "डेटाबेस गुणों की डिफ़ॉल्ट स्थिति",+ "databaseAttrViewModeTip": "तय करें कि दस्तावेज़ खोलते समय डेटाबेस गुण विस्तृत हों या नहीं",+ "bind": "बाँधें","targetNotebook": "लक्ष्य नोटबुक","dataMigration": "डेटा माइग्रेशन","settingsAndSync": "सेटिंग्स और सिंक",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex 2d1a03b829..1f002fb9fa 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Status default properti basis data",+ "databaseAttrViewModeTip": "Atur apakah properti basis data diperluas saat membuka dokumen",+ "bind": "Tautkan","targetNotebook": "Buku catatan tujuan","dataMigration": "Migrasi data","settingsAndSync": "Pengaturan dan sinkronisasi",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 9d90ca674b..a2b755f7d9 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Stato predefinito delle proprietà del database",+ "databaseAttrViewModeTip": "Imposta se le proprietà del database vengono espanse all'apertura di un documento",+ "bind": "Collega","targetNotebook": "Taccuino di destinazione","dataMigration": "Migrazione dei dati","settingsAndSync": "Impostazioni e sincronizzazione",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 49a470558b..1c6614ff95 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "データベースプロパティのデフォルト状態",+ "databaseAttrViewModeTip": "文書を開いたときにデータベースプロパティを展開するかどうかを設定します",+ "bind": "紐付け","targetNotebook": "対象ノートブック","dataMigration": "データ移行","settingsAndSync": "設定と同期",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex b70f3f4f65..c9a46420e0 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "데이터베이스 속성 기본 상태",+ "databaseAttrViewModeTip": "문서를 열 때 데이터베이스 속성을 펼칠지 설정합니다",+ "bind": "연결","targetNotebook": "대상 노트북","dataMigration": "데이터 마이그레이션","settingsAndSync": "설정 및 동기화",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex 87fca51b8b..bea2c5b959 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Standaardstatus van database-eigenschappen",+ "databaseAttrViewModeTip": "Stel in of database-eigenschappen worden uitgevouwen bij het openen van een document",+ "bind": "Koppelen","targetNotebook": "Doelnotitieboek","dataMigration": "Gegevensmigratie","settingsAndSync": "Instellingen en synchronisatie",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex f66bcfca82..b390c3a1a1 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Domyślny stan właściwości bazy danych",+ "databaseAttrViewModeTip": "Ustaw, czy właściwości bazy danych mają być rozwinięte podczas otwierania dokumentu",+ "bind": "Powiąż","targetNotebook": "Notatnik docelowy","dataMigration": "Migracja danych","settingsAndSync": "Ustawienia i synchronizacja",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 5ff81cd96d..024abc084f 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Estado padrão das propriedades do banco de dados",+ "databaseAttrViewModeTip": "Define se as propriedades do banco de dados são expandidas ao abrir um documento",+ "bind": "Vincular","targetNotebook": "Caderno de destino","dataMigration": "Migração de dados","settingsAndSync": "Configurações e sincronização",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex 25970452e8..64bc2345aa 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Состояние свойств базы данных по умолчанию",+ "databaseAttrViewModeTip": "Задаёт, разворачивать ли свойства базы данных при открытии документа",+ "bind": "Привязать","targetNotebook": "Целевой блокнот","dataMigration": "Миграция данных","settingsAndSync": "Настройки и синхронизация",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex cb8f68ebce..5d58d8e177 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Predvolený stav vlastností databázy",+ "databaseAttrViewModeTip": "Nastaví, či sa vlastnosti databázy rozbalia pri otvorení dokumentu",+ "bind": "Prepojiť","targetNotebook": "Cieľový zápisník","dataMigration": "Migrácia údajov","settingsAndSync": "Nastavenia a synchronizácia",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex 6aa79622c2..41b5d157c8 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "สถานะเริ่มต้นของคุณสมบัติฐานข้อมูล",+ "databaseAttrViewModeTip": "กำหนดว่าจะขยายคุณสมบัติฐานข้อมูลเมื่อเปิดเอกสารหรือไม่",+ "bind": "ผูก","targetNotebook": "สมุดบันทึกเป้าหมาย","dataMigration": "การย้ายข้อมูล","settingsAndSync": "การตั้งค่าและการซิงค์",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 9494bc3e7a..83634e2512 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Veritabanı özelliklerinin varsayılan durumu",+ "databaseAttrViewModeTip": "Belge açılırken veritabanı özelliklerinin genişletilip genişletilmeyeceğini ayarlayın",+ "bind": "Bağla","targetNotebook": "Hedef not defteri","dataMigration": "Veri taşıma","settingsAndSync": "Ayarlar ve eşitleme",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex 56ca4ec89e..5ace7429d6 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "Типовий стан властивостей бази даних",+ "databaseAttrViewModeTip": "Визначає, чи розгортати властивості бази даних під час відкриття документа",+ "bind": "Прив’язати","targetNotebook": "Цільовий нотатник","dataMigration": "Перенесення даних","settingsAndSync": "Налаштування та синхронізація",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 6b4cb4628b..ac6969bb45 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "数据库属性默认状态",+ "databaseAttrViewModeTip": "设置打开文档时是否展开数据库属性",+ "bind": "绑定","targetNotebook": "目标笔记本","dataMigration": "数据迁移","settingsAndSync": "设置与同步",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex a8dbd552c5..935fe0ffeb 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -1,4 +1,7 @@{+ "databaseAttrViewMode": "資料庫屬性預設狀態",+ "databaseAttrViewModeTip": "設定開啟文件時是否展開資料庫屬性",+ "bind": "綁定","targetNotebook": "目標筆記本","dataMigration": "資料遷移","settingsAndSync": "設定與同步",diff --git a/app/src/assets/scss/business/_custom.scss b/app/src/assets/scss/business/_custom.scssindex 25f98023f5..d3353fc77b 100644--- a/app/src/assets/scss/business/_custom.scss+++ b/app/src/assets/scss/business/_custom.scss@@ -142,3 +142,103 @@top: -1.5px;}}++.protyle-db-attr {+ margin: 8px 16px 8px 24px;+ border-radius: var(--b3-border-radius);++ &__header {+ align-items: center;+ min-height: 34px;+ padding: 0 8px;++ .block__logo {+ min-height: 34px;+ font-weight: 500;+ }+ }++ &--collapsed &__body {+ display: none;+ }++ .custom-attr__avheader {+ padding-left: 40px;+ }+}++.av__row-actions {+ align-items: center;+ display: inline-flex;+ flex-shrink: 0;+ gap: 1px;+ margin: 0;+ padding-left: 6px;+ opacity: 0;+ pointer-events: none;+ position: absolute;+ right: 4px;+ top: 50%;+ transform: translateY(-50%);+ transition: opacity 120ms ease-in-out;+ background-color: inherit;++ .av__row-action {+ align-items: center;+ background-color: transparent;+ border: 0;+ border-radius: var(--b3-border-radius);+ color: var(--b3-theme-on-surface);+ cursor: pointer;+ display: inline-flex;+ height: 22px;+ justify-content: center;+ padding: 0;+ width: 22px;++ &:hover,+ &:focus-visible {+ background-color: var(--b3-list-hover);+ color: var(--b3-theme-on-background);+ outline: none;+ }++ svg {+ height: 14px;+ pointer-events: none;+ width: 14px;+ }+ }+}++.av__cell[data-dtype="block"]:hover .av__row-actions,+.av__cell[data-dtype="block"]:focus-within .av__row-actions,+.av__gallery-item:hover .av__row-actions {+ opacity: 1;+ pointer-events: auto;+}++.protyle-db-row {+ background-color: var(--b3-theme-background);+ max-height: 100%;+ overflow-x: hidden;+ position: relative;++ &__title {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 24px 32px 8px;+ font-size: 24px;+ font-weight: 600;++ svg {+ width: 24px;+ height: 24px;+ }+ }++ &__body {+ margin: 8px 24px;+ }+}diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.tsindex 83e84aa68e..62cc3a56ac 100644--- a/app/src/block/Panel.ts+++ b/app/src/block/Panel.ts@@ -176,6 +176,7 @@ export class BlockPanel {action.push(Constants.CB_GET_BACKLINK);}const editor = new Protyle(this.app, editorElement, {+ databaseAttr: true,blockId: this.refDefs[index].refID,defIds: this.refDefs[index].defIDs || [],originalRefBlockIDs: this.isBacklink ? this.originalRefBlockIDs : undefined,diff --git a/app/src/config/tabs/editorTab.ts b/app/src/config/tabs/editorTab.tsindex 5b2cfe39f9..b7f2b64b3e 100644--- a/app/src/config/tabs/editorTab.ts+++ b/app/src/config/tabs/editorTab.ts@@ -114,6 +114,14 @@ const registerEditorBlockFeaturesGroup = (tab: SettingTabBuilder) => {title: window.siyuan.languages.embedBlockBreadcrumb,desc: window.siyuan.languages.embedBlockBreadcrumbTip,});+ group.select("editor.databaseAttrViewMode", {+ title: window.siyuan.languages.databaseAttrViewMode,+ desc: window.siyuan.languages.databaseAttrViewModeTip,+ options: [+ {value: 0, label: window.siyuan.languages.expand},+ {value: 1, label: window.siyuan.languages.collapse},+ ],+ });group.select("editor.headingEmbedMode", {title: window.siyuan.languages.headingEmbedMode,desc: window.siyuan.languages.headingEmbedModeTip,diff --git a/app/src/editor/databaseRow.ts b/app/src/editor/databaseRow.tsnew file mode 100644index 0000000000..ac2d02f1b3--- /dev/null+++ b/app/src/editor/databaseRow.ts@@ -0,0 +1,57 @@+import {Custom} from "../layout/dock/Custom";+import {Tab} from "../layout/Tab";+import {App} from "../index";+import {renderAVAttribute} from "../protyle/render/av/blockAttr";+import {getAllModels} from "../layout/getAll";++export const newDatabaseRowModel = (options: {+ app: App,+ tab: Tab,+ data: {+ avID: string,+ itemID: string,+ valueID: string,+ title: string,+ },+ protyle?: IProtyle,+}) => {+ const render = (custom: Custom, retry = true) => {+ const previousBodyElement = custom.element.querySelector<HTMLElement>(".protyle-db-row__body");+ if (!previousBodyElement) {+ return;+ }+ const bodyElement = document.createElement("div");+ bodyElement.className = "custom-attr protyle-db-row__body";+ previousBodyElement.replaceWith(bodyElement);+ const sourceProtyle = options.protyle?.ws?.ws?.readyState === WebSocket.OPEN ?+ options.protyle : getAllModels().editor[0]?.editor.protyle;+ if (sourceProtyle) {+ renderAVAttribute(bodyElement, options.data.itemID, sourceProtyle, undefined,+ {avID: options.data.avID, itemID: options.data.itemID, valueID: options.data.valueID});+ } else if (retry) {+ setTimeout(() => render(custom, false), 0);+ }+ };+ const model = new Custom({+ app: options.app,+ tab: options.tab,+ type: "siyuan-database-row",+ data: options.data,+ init(custom) {+ custom.element.innerHTML = `<div class="protyle-db-row fn__flex-1 fn__flex-column">+ <div class="protyle-content">+ <div class="protyle-top">+ <div class="protyle-db-row__title"><svg><use xlink:href="#iconDatabase"></use></svg><span></span></div>+ <div class="custom-attr protyle-db-row__body"></div>+ </div>+ </div>+</div>`;+ custom.element.querySelector(".protyle-db-row__title span").textContent = options.data.title || window.siyuan.languages.untitled;+ render(custom);+ },+ update() {+ render(options.tab.model as Custom);+ },+ });+ return model;+};diff --git a/app/src/editor/index.ts b/app/src/editor/index.tsindex b241df1acf..1322b465f2 100644--- a/app/src/editor/index.ts+++ b/app/src/editor/index.ts@@ -49,6 +49,7 @@ export class Editor extends Model {afterInitProtyle?: (editor: Protyle) => void,}) {this.editor = new Protyle(this.app, this.element, {+ databaseAttr: true,action: options.action || [],blockId: options.blockId,rootId: options.rootId,diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex 34e0e1957e..0b5b44a1f0 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -35,6 +35,17 @@ import {preventScroll} from "../protyle/scroll/preventScroll";import {clearOBG} from "../layout/dock/util";import {Model} from "../layout/Model";import {hideElements} from "../protyle/ui/hideElements";+import {newDatabaseRowModel} from "./databaseRow";++const isSameCustomTab = (type: string, data: any, options: IOpenFileOptions) => {+ if (!options.custom || (options.custom.id && options.custom.id !== type)) {+ return false;+ }+ if (type === "siyuan-database-row") {+ return data?.avID === options.custom.data?.avID && data?.itemID === options.custom.data?.itemID;+ }+ return objEquals(data, options.custom.data);+};export const openFileById = async (options: {app: App,@@ -125,8 +136,8 @@ export const openFile = async (options: IOpenFileOptions) => {}} else if (options.custom) {clearOBG();- const custom = allModels.custom.find((item) => {- if (objEquals(item.data, options.custom.data) && (!options.custom.id || options.custom.id === item.type)) {+ const custom = !options.openNewTab && allModels.custom.find((item) => {+ if (isSameCustomTab(item.type, item.data, options)) {if (!pdfIsLoading(item.parent.parent.element)) {item.parent.parent.switchTab(item.parent.headElement);item.parent.parent.showHeading();@@ -140,7 +151,7 @@ export const openFile = async (options: IOpenFileOptions) => {}return custom.parent;}- const hasModel = getUnInitTab(options);+ const hasModel = !options.openNewTab && getUnInitTab(options);if (hasModel) {if (options.afterOpen) {options.afterOpen(hasModel.model);@@ -263,14 +274,14 @@ export const openFile = async (options: IOpenFileOptions) => {return;}// 在右侧/下侧打开已有页签将进行页签切换 https://github.com/siyuan-note/siyuan/issues/5366- let hasEditor = targetWnd.children.find(item => {+ let hasEditor = !options.openNewTab && targetWnd.children.find(item => {if (item.model && item.model instanceof Editor && item.model.editor.protyle.block.rootID === options.rootID) {switchEditor(item.model, options, allModels);return true;}});if (!hasEditor) {- hasEditor = getUnInitTab(options);+ hasEditor = !options.openNewTab && getUnInitTab(options);createdTab = hasEditor;}if (!hasEditor) {@@ -345,7 +356,7 @@ const getUnInitTab = (options: IOpenFileOptions) => {item.headElement.setAttribute("data-initdata", JSON.stringify(initObj));item.parent.switchTab(item.headElement);return true;- } else if (initObj.instance === "Custom" && options.custom && objEquals(initObj.customModelData, options.custom.data)) {+ } else if (initObj.instance === "Custom" && isSameCustomTab(initObj.customModelType, initObj.customModelData, options)) {item.parent.switchTab(item.headElement);return true;}@@ -486,6 +497,13 @@ const newTab = (options: IOpenFileOptions) => {tab,data: options.custom.data}));+ } else if (options.custom.id === "siyuan-database-row") {+ tab.addModel(newDatabaseRowModel({+ app: options.app,+ tab,+ data: options.custom.data,+ protyle: options.custom.protyle,+ }));} else {options.app.plugins.find(p => {if (p.models[options.custom.id]) {diff --git a/app/src/layout/util.ts b/app/src/layout/util.tsindex 5eba1dcf02..6bcbcf093e 100644--- a/app/src/layout/util.ts+++ b/app/src/layout/util.ts@@ -25,6 +25,7 @@ import {showMessage} from "../dialog/message";import {isEncryptedBox, parseUriInfo} from "../util/pathName";import {Custom} from "./dock/Custom";import {newCardModel} from "../card/newCardTab";+import {newDatabaseRowModel} from "../editor/databaseRow";import {App} from "../index";import {afterLoadPlugin} from "../plugin/loader";import {newCenterEmptyTab, resizeTabs, setTabPosition} from "./tabUtil";@@ -773,6 +774,12 @@ export const newModelByInitData = (app: App, tab: Tab, json: any) => {tab: tab,data: json.customModelData});+ } else if (json.customModelType === "siyuan-database-row") {+ model = newDatabaseRowModel({+ app,+ tab,+ data: json.customModelData,+ });} else {app.plugins.find(item => {if (item.models[json.customModelType]) {diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex e8b8bbdc42..85c7cc6d2d 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -164,6 +164,16 @@ export class Protyle {item.removeAttribute("data-render");avRender(item, this.protyle);});+ if (this.protyle.databaseAttributePanel?.hasDatabase(data.data.id)) {+ this.protyle.databaseAttributePanel.refresh();+ }+ /// #if !MOBILE+ getAllModels().custom.forEach((item) => {+ if (item.type === "siyuan-database-row" && item.data.avID === data.data.id) {+ item.update?.();+ }+ });+ /// #endifbreak;case "addLoading":if (data.data === this.protyle.block.rootID) {diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex dbbfd2a0ad..1afa7e74a8 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -40,6 +40,98 @@ import {editGalleryItem, openGalleryItemMenu} from "./gallery/util";import {clearSelect} from "../../util/clear";import {removeCompressURL} from "../../../util/image";import {callMobileAppShowKeyboard} from "../../../mobile/util/mobileAppUtil";+/// #if !MOBILE+import {openFile, openFileById} from "../../../editor/util";+import {Editor} from "../../../editor";+import {getAllModels} from "../../../layout/getAll";++const isDetachedDatabaseCell = (cellElement: HTMLElement) => {+ return cellElement.dataset.detached === "true" || !cellElement.querySelector(".av__celltext--ref");+};++const openDatabaseRow = (protyle: IProtyle, target: HTMLElement, blockElement: HTMLElement) => {+ const cellElement = hasClosestByClassName(target, "av__cell") as HTMLElement;+ const rowElement = hasClosestByClassName(target, "av__row") || hasClosestByClassName(target, "av__gallery-item");+ if (!cellElement || !rowElement) {+ return;+ }+ const title = cellElement.querySelector(".av__celltext")?.textContent.trim() || window.siyuan.languages.untitled;+ if (isDetachedDatabaseCell(cellElement)) {+ openFile({+ app: protyle.app,+ position: "right",+ removeCurrentTab: false,+ custom: {+ id: "siyuan-database-row",+ icon: "iconDatabase",+ title,+ data: {+ avID: blockElement.dataset.avId,+ itemID: rowElement.getAttribute("data-id"),+ valueID: cellElement.dataset.id,+ title,+ },+ protyle,+ },+ });+ return;+ }+ const blockID = cellElement.querySelector<HTMLElement>(".av__celltext--ref")?.dataset.id;+ if (blockID) {+ const openedEditor = getAllModels().editor.find((item) => {+ return item.editor.protyle.element.dataset.databaseRowId === blockID;+ });+ if (openedEditor) {+ openedEditor.parent.parent.switchTab(openedEditor.parent.headElement);+ openedEditor.parent.parent.showHeading();+ openedEditor.editor.protyle.databaseAttributePanel?.expand();+ openedEditor.editor.protyle.contentElement.scrollTop = 0;+ return;+ }+ openFileById({+ app: protyle.app,+ id: blockID,+ position: "right",+ openNewTab: true,+ removeCurrentTab: false,+ zoomIn: true,+ afterOpen(model: Editor) {+ if (!model?.editor?.protyle) {+ return;+ }+ model.editor.protyle.element.dataset.databaseRowPreview = "true";+ model.editor.protyle.element.dataset.databaseRowId = blockID;+ model.editor.protyle.databaseAttributePanel?.expand();+ model.editor.protyle.contentElement.scrollTop = 0;+ },+ });+ }+};++const openDatabaseRowMore = (protyle: IProtyle, target: HTMLElement) => {+ const cellElement = hasClosestByClassName(target, "av__cell") as HTMLElement;+ if (!cellElement) {+ return;+ }+ const isDetached = isDetachedDatabaseCell(cellElement);+ const menu = new Menu("av-row-more");+ menu.addItem({+ icon: isDetached ? "iconLink" : "iconRefresh",+ label: isDetached ? window.siyuan.languages.bind : window.siyuan.languages.update,+ click() {+ const textElement = cellElement.querySelector<HTMLElement>(".av__celltext");+ protyle.toolbar.range = document.createRange();+ protyle.toolbar.range.selectNodeContents(textElement);+ focusByRange(protyle.toolbar.range);+ cellElement.classList.add("av__cell--select");+ addDragFill(cellElement);+ hintRef(textElement.textContent.trim(), protyle, "av");+ },+ });+ const rect = target.getBoundingClientRect();+ menu.open({x: rect.left, y: rect.bottom, h: rect.height});+};+/// #endiflet foldTimeout: number;export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {@@ -107,19 +199,29 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEleevent.preventDefault();event.stopPropagation();return true;+ /// #if !MOBILE+ } else if (type === "av-row-open") {+ openDatabaseRow(protyle, target, blockElement);+ event.preventDefault();+ event.stopPropagation();+ return true;+ } else if (type === "av-row-more" && !protyle.disabled) {+ openDatabaseRowMore(protyle, target);+ event.preventDefault();+ event.stopPropagation();+ return true;+ /// #endif+ /// #if MOBILE} else if (type === "block-more" && !protyle.disabled) {window.siyuan.menus.menu.remove();protyle.toolbar.range = document.createRange();protyle.toolbar.range.selectNodeContents(target);focusByRange(protyle.toolbar.range);- if (viewType === "table") {- target.parentElement.classList.add("av__cell--select");- addDragFill(target.parentElement);- }hintRef(target.previousElementSibling.textContent.trim(), protyle, "av");event.preventDefault();event.stopPropagation();return true;+ /// #endif} else if (type === "set-page-size" && !protyle.disabled) {setPageSize({target,diff --git a/app/src/protyle/render/av/attributePanel.ts b/app/src/protyle/render/av/attributePanel.tsnew file mode 100644index 0000000000..6db63d69e7--- /dev/null+++ b/app/src/protyle/render/av/attributePanel.ts@@ -0,0 +1,79 @@+import {renderAVAttribute} from "./blockAttr";++export class AVAttributePanel {+ public element: HTMLElement;+ private bodyElement: HTMLElement;+ private protyle: IProtyle;+ private targetID = "";+ private renderToken = 0;+ private collapsed: boolean;++ constructor(protyle: IProtyle) {+ this.protyle = protyle;+ this.collapsed = window.siyuan.config.editor.databaseAttrViewMode === 1;+ this.element = document.createElement("div");+ this.element.className = "protyle-db-attr fn__none";+ this.element.innerHTML = `<div class="protyle-db-attr__header fn__flex">+ <button class="block__icon block__icon--show fn__flex-center" data-type="toggle" aria-label="${window.siyuan.languages.database}"><svg><use xlink:href="#iconRight"></use></svg></button>+ <div class="block__logo fn__flex-1"><svg class="block__logoicon"><use xlink:href="#iconDatabase"></use></svg><span>${window.siyuan.languages.database}</span></div>+</div>`;+ 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="toggle"]')) {+ this.toggle();+ event.preventDefault();+ event.stopPropagation();+ }+ });+ this.updateCollapsedState();+ }++ public render(force = false) {+ const targetID = this.protyle.block.showAll ? this.protyle.block.id : this.protyle.block.rootID;+ if (!targetID || (!force && targetID === this.targetID && this.element.dataset.rendered === "true")) {+ return;+ }+ this.targetID = targetID;+ this.element.dataset.nodeId = targetID;+ this.element.removeAttribute("data-rendered");+ const token = ++this.renderToken;+ const bodyElement = document.createElement("div");+ bodyElement.className = "custom-attr protyle-db-attr__body";+ this.bodyElement.replaceWith(bodyElement);+ this.bodyElement = bodyElement;+ renderAVAttribute(bodyElement, targetID, this.protyle, (renderedElement) => {+ if (token !== this.renderToken) {+ return;+ }+ this.element.dataset.rendered = "true";+ this.element.classList.toggle("fn__none", renderedElement.childElementCount === 0);+ });+ }++ public refresh() {+ this.render(true);+ }++ public hasDatabase(avID: string) {+ return Boolean(this.bodyElement.querySelector(`[data-av-id="${avID}"]`));+ }++ public expand() {+ this.collapsed = false;+ this.updateCollapsedState();+ }++ public toggle() {+ this.collapsed = !this.collapsed;+ this.updateCollapsedState();+ }++ private updateCollapsedState() {+ this.element.classList.toggle("protyle-db-attr--collapsed", this.collapsed);+ const useElement = this.element.querySelector('[data-type="toggle"] use');+ useElement?.setAttribute("xlink:href", this.collapsed ? "#iconRight" : "#iconDown");+ }+}diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.tsindex d35135a42e..087c92b760 100644--- a/app/src/protyle/render/av/blockAttr.ts+++ b/app/src/protyle/render/av/blockAttr.ts@@ -172,10 +172,12 @@ export const genAVValueHTML = (value: IAVCellValue) => {return html;};-export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IProtyle, cb?: (element: HTMLElement) => void) => {- fetchPost("/api/av/getAttributeViewKeys", {id}, (response) => {+export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IProtyle, cb?: (element: HTMLElement) => void,+ row?: { avID: string, itemID: string, valueID: string }) => {+ fetchPost("/api/av/getAttributeViewKeys", row ? {id, avID: row.avID, itemID: row.itemID, valueID: row.valueID} : {id}, (response) => {let html = "";- response.data.forEach((table: {+ const tables = Array.isArray(response.data) ? response.data : [];+ tables.forEach((table: {keyValues: {key: {type: TAVCol,@@ -192,6 +194,7 @@ export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IPrkeyID: string,id: string,blockID: string,+ isDetached?: boolean,type: TAVCol & IAVCellValue} []}[],@@ -214,7 +217,7 @@ export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IPr${item.key.icon ? unicode2Emoji(item.key.icon, "block__logoicon", true) : `<svg class="block__logoicon"><use xlink:href="#${getColIconByType(item.key.type)}"></use></svg>`}<span>${escapeHtml(item.key.name)}</span></div>- <div data-av-id="${table.avID}" data-col-id="${item.values[0].keyID}" data-row-id="${item.values[0].blockID}" data-id="${item.values[0].id}" data-type="${item.values[0].type}"+ <div data-av-id="${table.avID}" data-col-id="${item.values[0].keyID}" data-row-id="${item.values[0].blockID}" data-id="${item.values[0].id}" data-type="${item.values[0].type}"${item.values[0].isDetached ? ' data-detached="true"' : ""}data-options="${item.key?.options ? escapeAttr(JSON.stringify(item.key.options)) : "[]"}"${["text", "number", "date", "url", "phone", "template", "email"].includes(item.values[0].type) ? "" : `placeholder="${window.siyuan.languages.empty}"`}class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"].includes(item.values[0].type) ? "" : " custom-attr__avvalue"}${["created", "updated"].includes(item.values[0].type) ? " custom-attr__avvalue--readonly" : ""}">${genAVValueHTML(item.values[0])}</div>@@ -443,9 +446,9 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]value = {block: {content: item.value,- id: item.dataset.id,+ id: item.parentElement.dataset.detached === "true" ? "" : item.dataset.id,},- isDetached: false+ isDetached: item.parentElement.dataset.detached === "true"};}fetchPost("/api/av/setAttributeViewBlockAttr", {diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex 836c3b926c..fe9a01b4a7 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -966,10 +966,16 @@ export const renderCell = (cellValue: IAVCellValue, rowIndex = 0, showIcon = tru} else if (cellValue.type === "block") {// 不可使用换行 https://github.com/siyuan-note/siyuan/issues/11365if (cellValue?.isDetached) {- text = `<span class="av__celltext">${Lute.EscapeHTMLStr(cellValue.block.content || "")}</span><span class="b3-chip b3-chip--info b3-chip--small" data-type="block-more">${window.siyuan.languages.more}</span>`;+ text = `<span class="av__celltext">${Lute.EscapeHTMLStr(cellValue.block.content || "")}</span>`;} else {- text = `<span class="b3-menu__avemoji${showIcon ? "" : " fn__none"}" data-unicode="${cellValue.block.icon || ""}">${unicode2Emoji(cellValue.block.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file)}</span><span data-type="block-ref" data-id="${cellValue.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${Lute.EscapeHTMLStr(cellValue.block.content)}</span><span class="b3-chip b3-chip--info b3-chip--small" data-type="block-more">${window.siyuan.languages.update}</span>`;+ text = `<span class="b3-menu__avemoji${showIcon ? "" : " fn__none"}" data-unicode="${cellValue.block.icon || ""}">${unicode2Emoji(cellValue.block.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file)}</span><span data-type="block-ref" data-id="${cellValue.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${Lute.EscapeHTMLStr(cellValue.block.content)}</span>`;}+ /// #if !MOBILE+ text += `<span class="av__row-actions"><button class="av__row-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.openBy}" data-type="av-row-open"><svg><use xlink:href="#iconOpen"></use></svg></button><button class="av__row-action ariaLabel" type="button" data-position="4north" aria-label="${window.siyuan.languages.more}" data-type="av-row-more"><svg><use xlink:href="#iconMore"></use></svg></button></span>`;+ /// #endif+ /// #if MOBILE+ text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="block-more">${cellValue?.isDetached ? window.siyuan.languages.more : window.siyuan.languages.update}</span>`;+ /// #endif} else if (cellValue.type === "number") {text = `<span class="av__celltext" data-content="${cellValue?.number.isNotEmpty ? cellValue?.number.content : ""}">${cellValue?.number.formattedContent || cellValue?.number.content || ""}</span>`;} else if (cellValue.type === "mSelect" || cellValue.type === "select") {diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.tsindex 80ddf2890f..f038a0f023 100644--- a/app/src/protyle/render/av/select.ts+++ b/app/src/protyle/render/av/select.ts@@ -648,7 +648,9 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: Htransaction(protyle, cellDoOperations, cellUndoOperations);}if (colData.type === "select") {- blockElement.setAttribute("data-rendering", "true");+ if (blockElement.classList.contains("av")) {+ blockElement.setAttribute("data-rendering", "true");+ }menuElement.parentElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));} else {const oldScroll = menuElement.querySelector(".b3-menu__items").scrollTop;diff --git a/app/src/protyle/scroll/saveScroll.ts b/app/src/protyle/scroll/saveScroll.tsindex 1f80ee09d4..76666bd6b6 100644--- a/app/src/protyle/scroll/saveScroll.ts+++ b/app/src/protyle/scroll/saveScroll.ts@@ -8,7 +8,8 @@ import {isSupportCSSHL} from "../render/searchMarkRender";import {isEncryptedBox} from "../../util/pathName";export const saveScroll = (protyle: IProtyle, getObject = false) => {- if (!protyle.wysiwyg.element.firstElementChild || window.siyuan.config.readonly) {+ if (!protyle.wysiwyg.element.firstElementChild || window.siyuan.config.readonly ||+ (protyle.element.dataset.databaseRowPreview === "true" && !getObject)) {// 报错或者空白页面return undefined;}diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.tsindex 745d5de0f5..4420cffabd 100644--- a/app/src/protyle/ui/initUI.ts+++ b/app/src/protyle/ui/initUI.ts@@ -23,6 +23,9 @@ import {isInEmbedBlock} from "../util/hasClosest";import {hideElements} from "./hideElements";+/// #if !MOBILE+import {AVAttributePanel} from "../render/av/attributePanel";+/// #endifexport const initUI = (protyle: IProtyle) => {protyle.contentElement = document.createElement("div");@@ -38,6 +41,19 @@ export const initUI = (protyle: IProtyle) => {}}+ /// #if !MOBILE+ if (protyle.options.databaseAttr && !protyle.options.action.includes(Constants.CB_GET_HISTORY) && !protyle.options.backlinkData) {+ let topElement = protyle.contentElement.querySelector(".protyle-top");+ if (!topElement) {+ topElement = document.createElement("div");+ topElement.className = "protyle-top";+ protyle.contentElement.appendChild(topElement);+ }+ protyle.databaseAttributePanel = new AVAttributePanel(protyle);+ topElement.appendChild(protyle.databaseAttributePanel.element);+ }+ /// #endif+protyle.contentElement.appendChild(protyle.wysiwyg.element);if (!protyle.options.action.includes(Constants.CB_GET_HISTORY)) {scrollEvent(protyle, protyle.contentElement);@@ -195,6 +211,9 @@ export const initUI = (protyle: IProtyle) => {protyle.element.addEventListener("mouseover", (event: KeyboardEvent & {target: HTMLElement}) => {+ if (hasClosestByClassName(event.target, "protyle-db-attr")) {+ return;+ }// attrconst attrElement = hasClosestByClassName(event.target, "protyle-attr");if (attrElement && !attrElement.parentElement.classList.contains("protyle-title")) {diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex 434bec47ae..ba71af902d 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -244,6 +244,9 @@ const setHTML = (options: {highlightRender(protyle.wysiwyg.element);avRender(protyle.wysiwyg.element, protyle);blockRender(protyle, protyle.wysiwyg.element);+ /// #if !MOBILE+ protyle.databaseAttributePanel?.render();+ /// #endifif (options.action.includes(Constants.CB_GET_HISTORY)) {return;}diff --git a/app/src/protyle/wysiwyg/commonClick.ts b/app/src/protyle/wysiwyg/commonClick.tsindex 5a342283b0..90586b612a 100644--- a/app/src/protyle/wysiwyg/commonClick.ts+++ b/app/src/protyle/wysiwyg/commonClick.ts@@ -5,6 +5,8 @@ import {openGlobalSearch} from "../../search/util";/// #endifimport {isMobile} from "../../util/functions";import {isOnlyMeta} from "../util/compatibility";+import {hasClosestBlock} from "../util/hasClosest";+import {zoomOut} from "../../menus/protyle";export const commonClick = (event: MouseEvent & {target: HTMLElement@@ -47,9 +49,21 @@ export const commonClick = (event: MouseEvent & {const avElement = hasClosestByClassName(event.target, "protyle-attr--av");if (avElement) {if (data) {- openFileAttr(data, "av", protyle);+ if (protyle.databaseAttributePanel) {+ protyle.databaseAttributePanel.toggle();+ } else {+ openFileAttr(data, "av", protyle);+ }} else {- openAttr(avElement.parentElement.parentElement, "av", protyle);+ const blockElement = hasClosestBlock(avElement);+ const blockID = blockElement ? blockElement.getAttribute("data-node-id") : "";+ if (!protyle.databaseAttributePanel) {+ openAttr(avElement.parentElement.parentElement, "av", protyle);+ } else if (blockID && protyle.block.showAll && blockID === protyle.block.id) {+ protyle.databaseAttributePanel?.toggle();+ } else if (blockID) {+ zoomOut({protyle, id: blockID});+ }}event.stopPropagation();return true;diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.tsindex e4f201dc62..91d21ed567 100644--- a/app/src/types/config.d.ts+++ b/app/src/types/config.d.ts@@ -510,6 +510,12 @@ declare namespace Config {* Whether to display the network image mark*/displayNetImgMark: boolean;+ /**+ * Default state of database attributes+ * - `0`: Expanded+ * - `1`: Collapsed+ */+ databaseAttrViewMode: number;/*** The number of blocks loaded each time they are dynamically loaded*/diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex be2f9d0b54..c04361e1cb 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -752,6 +752,7 @@ interface IOpenFileOptions {title: string,icon: string,data?: any+ protyle?: IProtyle,id: string,fn?: (options: {tab: import("../layout/Tab").Tab,diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.tsindex 8a9b5bc95f..f247ff965c 100644--- a/app/src/types/protyle.d.ts+++ b/app/src/types/protyle.d.ts@@ -458,6 +458,7 @@ interface IHint {/** @link https://ld246.com/article/1549638745630#options */interface IProtyleOptions {+ databaseAttr?: boolean,history?: {created?: stringsnapshot?: string@@ -559,6 +560,7 @@ interface IProtyle {breadcrumb?: import("../protyle/breadcrumb").Breadcrumb,title?: import("../protyle/header/Title").Title,background?: import("../protyle/header/background").Background,+ databaseAttributePanel?: import("../protyle/render/av/attributePanel").AVAttributePanel,contentElement?: HTMLElement,options: IProtyleOptions;lute?: Lute;diff --git a/kernel/api/av.go b/kernel/api/av.goindex 4193946cdc..4681375929 100644--- a/kernel/api/av.go+++ b/kernel/api/av.go@@ -1026,8 +1026,16 @@ func getAttributeViewKeys(c *gin.Context) {return}- id := arg["id"].(string)- blockAttributeViewKeys := model.GetBlockAttributeViewKeys(id)+ id, _ := arg["id"].(string)+ avID, _ := arg["avID"].(string)+ itemID, _ := arg["itemID"].(string)+ valueID, _ := arg["valueID"].(string)+ var blockAttributeViewKeys []*model.BlockAttributeViewKeys+ if "" != avID && ("" != itemID || "" != valueID) {+ blockAttributeViewKeys = model.GetAttributeViewItemKeys(avID, itemID, valueID)+ } else {+ blockAttributeViewKeys = model.GetBlockAttributeViewKeys(id)+ }if model.IsReadOnlyRoleContext(c) {publishAccess := model.GetPublishAccess()blockAttributeViewKeys = model.FilterBlockAttributeViewKeysByPublishAccess(c, publishAccess, blockAttributeViewKeys)diff --git a/kernel/conf/editor.go b/kernel/conf/editor.goindex 3f38388c0d..c2e9f64a29 100644--- a/kernel/conf/editor.go+++ b/kernel/conf/editor.go@@ -32,6 +32,7 @@ type Editor struct {CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标+ DatabaseAttrViewMode int `json:"databaseAttrViewMode"` // 数据库属性默认展开状态,0:展开,1:折叠GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数Emoji []string `json:"emoji"` // 常用表情@@ -78,6 +79,7 @@ func NewEditor() *Editor {CodeLigatures: false,DisplayBookmarkIcon: true,DisplayNetImgMark: true,+ DatabaseAttrViewMode: 0,GenerateHistoryInterval: 10,HistoryRetentionDays: 30,Emoji: []string{},diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex b25630e2e7..eb425a8fdd 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -2078,6 +2078,71 @@ type BlockAttributeViewKeys struct {KeyValues []*av.KeyValues `json:"keyValues"`}+func GetAttributeViewItemKeys(avID, itemID, valueID string) (ret []*BlockAttributeViewKeys) {+ waitForSyncingStorages()++ ret = []*BlockAttributeViewKeys{}+ attrView, err := av.ParseAttributeView(avID)+ if nil == attrView {+ logging.LogErrorf("parse attribute view [%s] failed: %s", avID, err)+ return+ }+ if nil == attrView.GetBlockValue(itemID) && "" != valueID {+ blockKeyValues := attrView.GetBlockKeyValues()+ if nil != blockKeyValues {+ for _, value := range blockKeyValues.Values {+ if value.ID == valueID {+ itemID = value.BlockID+ break+ }+ }+ }+ }+ if nil == attrView.GetBlockValue(itemID) {+ return+ }++ view, err := getRenderAttributeViewView(attrView, "", "")+ if nil != err {+ return+ }+ sql.RenderView(attrView, view, "", false)++ var keyValues []*av.KeyValues+ for _, kv := range attrView.KeyValues {+ if av.KeyTypeLineNumber == kv.Key.Type {+ continue+ }++ itemKeyValues := &av.KeyValues{Key: kv.Key}+ for _, value := range kv.Values {+ if value.BlockID == itemID {+ itemKeyValues.Values = append(itemKeyValues.Values, value)+ }+ }+ if 0 < len(itemKeyValues.Values) {+ keyValues = append(keyValues, itemKeyValues)+ }+ }++ refreshAttrViewKeyIDs(attrView, true)+ sorts := map[string]int{}+ for i, keyID := range attrView.KeyIDs {+ sorts[keyID] = i+ }+ sort.Slice(keyValues, func(i, j int) bool {+ return sorts[keyValues[i].Key.ID] < sorts[keyValues[j].Key.ID]+ })++ ret = append(ret, &BlockAttributeViewKeys{+ AvID: avID,+ AvName: getAttrViewName(attrView),+ BlockIDs: treenode.GetMirrorAttrViewBlockIDs(avID),+ KeyValues: keyValues,+ })+ return+}+func GetBlockAttributeViewKeys(nodeID string) (ret []*BlockAttributeViewKeys) {waitForSyncingStorages()