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: Support sorting dock entries by position https://github.com/siyuan-note/siyuan/issues/18285
Danield73ab446ac37
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.jsonindex 80c46f508c..aeaae20d48 100644--- a/app/appearance/langs/ar.json+++ b/app/appearance/langs/ar.json@@ -259,7 +259,7 @@"entrySubmenu": "قائمة فرعية","splitMergedCellTip": "يجب تقسيم الخلايا المدمجة أولاً","entryVisibility": "الشريط العلوي والقوائم وشريط الأدوات وشريط الإرساء",- "entryVisibilityTip": "اضبط إظهار وترتيب عناصر الشريط العلوي والعناصر المضمنة في قوائم سطح المكتب وشريط الأدوات، واضبط إظهار أيقونات شريط الإرساء",+ "entryVisibilityTip": "اضبط إظهار وترتيب عناصر الشريط العلوي والعناصر المضمنة في قوائم سطح المكتب وشريط الأدوات، واضبط إظهار وترتيب أيقونات شريط الإرساء","entrySimple": "مبسّط","entryFull": "كامل","entrySimpleTip": "يعرض العناصر شائعة الاستخدام لمساعدة المستخدمين الجدد على البدء بسرعة",diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.jsonindex 4531405f9d..3e4b5d484f 100644--- a/app/appearance/langs/de.json+++ b/app/appearance/langs/de.json@@ -259,7 +259,7 @@"entrySubmenu": "Untermenü","splitMergedCellTip": "Zusammengeführte Zellen müssen zuerst geteilt werden","entryVisibility": "Obere Leiste, Menüs, Symbolleiste und Dock",- "entryVisibilityTip": "Konfigurieren Sie die Sichtbarkeit und Reihenfolge von Einträgen in der oberen Leiste sowie integrierten Einträgen in Desktop-Menüs und der Symbolleiste und die Sichtbarkeit der Dock-Symbole",+ "entryVisibilityTip": "Konfigurieren Sie die Sichtbarkeit und Reihenfolge von Einträgen in der oberen Leiste sowie integrierten Einträgen in Desktop-Menüs und der Symbolleiste und die Sichtbarkeit und Reihenfolge der Dock-Symbole","entrySimple": "Einfach","entryFull": "Vollständig","entrySimpleTip": "Zeigt häufig verwendete Einträge für einen schnellen Einstieg",diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.jsonindex 69d3f4b800..f7e3879236 100644--- a/app/appearance/langs/en.json+++ b/app/appearance/langs/en.json@@ -259,7 +259,7 @@"entrySubmenu": "Submenu","splitMergedCellTip": "Split merged cells first","entryVisibility": "Top bar, menus, toolbar and dock",- "entryVisibilityTip": "Configure the visibility and order of desktop top bar items and built-in menu and toolbar items, and the visibility of dock icons",+ "entryVisibilityTip": "Configure the visibility and order of desktop top bar items and built-in menu and toolbar items, and the visibility and order of dock icons","entrySimple": "Simple","entryFull": "Full","entrySimpleTip": "Shows commonly used entries for getting started quickly",diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.jsonindex 02b90380e6..0bdb8ccd22 100644--- a/app/appearance/langs/es.json+++ b/app/appearance/langs/es.json@@ -259,7 +259,7 @@"entrySubmenu": "Submenú","splitMergedCellTip": "Primero hay que dividir las celdas combinadas","entryVisibility": "Barra superior, menús, barra de herramientas y panel acoplable",- "entryVisibilityTip": "Configura la visibilidad y el orden de los elementos de la barra superior y de los elementos integrados de los menús y la barra de herramientas del escritorio, así como la visibilidad de los iconos del panel acoplable",+ "entryVisibilityTip": "Configura la visibilidad y el orden de los elementos de la barra superior y de los elementos integrados de los menús y la barra de herramientas del escritorio, así como la visibilidad y el orden de los iconos del panel acoplable","entrySimple": "Sencillo","entryFull": "Completo","entrySimpleTip": "Muestra las entradas más utilizadas para empezar rápidamente",diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.jsonindex bede74eeb7..c0d8d0de54 100644--- a/app/appearance/langs/fr.json+++ b/app/appearance/langs/fr.json@@ -259,7 +259,7 @@"entrySubmenu": "Sous-menu","splitMergedCellTip": "Les cellules fusionnées doivent d'abord être fractionnées","entryVisibility": "Barre supérieure, menus, barre d’outils et barre d’ancrage",- "entryVisibilityTip": "Configurez la visibilité et l’ordre des éléments de la barre supérieure et des éléments intégrés des menus et de la barre d’outils du bureau, ainsi que la visibilité des icônes de la barre d’ancrage",+ "entryVisibilityTip": "Configurez la visibilité et l’ordre des éléments de la barre supérieure et des éléments intégrés des menus et de la barre d’outils du bureau, ainsi que la visibilité et l’ordre des icônes de la barre d’ancrage","entrySimple": "Simple","entryFull": "Complet","entrySimpleTip": "Affiche les entrées courantes pour démarrer rapidement",diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.jsonindex e3fc50687e..c27de8eb78 100644--- a/app/appearance/langs/he.json+++ b/app/appearance/langs/he.json@@ -259,7 +259,7 @@"entrySubmenu": "תפריט משנה","splitMergedCellTip": "יש לפצל תחילה תאים ממוזגים","entryVisibility": "סרגל עליון, תפריטים, סרגל כלים וסרגל עגינה",- "entryVisibilityTip": "הגדרת הנראות והסדר של פריטי הסרגל העליון ושל הפריטים המובנים בתפריטי שולחן העבודה ובסרגל הכלים, והנראות של סמלי סרגל העגינה",+ "entryVisibilityTip": "הגדרת הנראות והסדר של פריטי הסרגל העליון ושל הפריטים המובנים בתפריטי שולחן העבודה ובסרגל הכלים, והנראות והסדר של סמלי סרגל העגינה","entrySimple": "פשוט","entryFull": "מלא","entrySimpleTip": "מציג פריטים נפוצים כדי לעזור למשתמשים חדשים להתחיל במהירות",diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.jsonindex e5a166bbdb..75a288e9d0 100644--- a/app/appearance/langs/hi.json+++ b/app/appearance/langs/hi.json@@ -259,7 +259,7 @@"entrySubmenu": "उपमेनू","splitMergedCellTip": "पहले मर्ज किए गए सेल विभाजित करें","entryVisibility": "शीर्ष पट्टी, मेनू, टूलबार और डॉक",- "entryVisibilityTip": "शीर्ष पट्टी के आइटम तथा डेस्कटॉप मेनू और टूलबार के अंतर्निहित आइटम की दृश्यता व क्रम और डॉक आइकन की दृश्यता कॉन्फ़िगर करें",+ "entryVisibilityTip": "शीर्ष पट्टी के आइटम तथा डेस्कटॉप मेनू और टूलबार के अंतर्निहित आइटम की दृश्यता व क्रम और डॉक आइकन की दृश्यता व क्रम कॉन्फ़िगर करें","entrySimple": "सरल","entryFull": "पूर्ण","entrySimpleTip": "नए उपयोगकर्ताओं को जल्दी शुरू करने के लिए आम तौर पर उपयोग की जाने वाली प्रविष्टियाँ दिखाता है",diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.jsonindex e55761aeb3..3f8335fbd6 100644--- a/app/appearance/langs/id.json+++ b/app/appearance/langs/id.json@@ -259,7 +259,7 @@"entrySubmenu": "Submenu","splitMergedCellTip": "Pisahkan sel yang digabungkan terlebih dahulu","entryVisibility": "Bilah atas, menu, bilah alat, dan dok",- "entryVisibilityTip": "Atur visibilitas dan urutan item bilah atas serta item bawaan di menu desktop dan bilah alat, juga visibilitas ikon dok",+ "entryVisibilityTip": "Atur visibilitas dan urutan item bilah atas serta item bawaan di menu desktop dan bilah alat, juga visibilitas dan urutan ikon dok","entrySimple": "Sederhana","entryFull": "Lengkap","entrySimpleTip": "Menampilkan entri yang umum digunakan agar pengguna baru dapat memulai dengan cepat",diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.jsonindex 34e99f4e4c..d1738a3327 100644--- a/app/appearance/langs/it.json+++ b/app/appearance/langs/it.json@@ -259,7 +259,7 @@"entrySubmenu": "Sottomenu","splitMergedCellTip": "Prima dividi le celle unite","entryVisibility": "Barra superiore, menu, barra degli strumenti e barra di ancoraggio",- "entryVisibilityTip": "Configura la visibilità e l'ordine delle voci della barra superiore e delle voci integrate dei menu e della barra degli strumenti desktop, nonché la visibilità delle icone della barra di ancoraggio",+ "entryVisibilityTip": "Configura la visibilità e l'ordine delle voci della barra superiore e delle voci integrate dei menu e della barra degli strumenti desktop, nonché la visibilità e l'ordine delle icone della barra di ancoraggio","entrySimple": "Semplice","entryFull": "Completo","entrySimpleTip": "Mostra le voci usate più spesso per iniziare rapidamente",diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.jsonindex 06e6b4af6f..a0ae87f515 100644--- a/app/appearance/langs/ja.json+++ b/app/appearance/langs/ja.json@@ -259,7 +259,7 @@"entrySubmenu": "サブメニュー","splitMergedCellTip": "先に結合セルを分割する必要があります","entryVisibility": "トップバー、メニュー、ツールバー、ドック",- "entryVisibilityTip": "トップバー項目とデスクトップメニューおよびツールバーの組み込み項目の表示と順序、およびドックアイコンの表示を設定します",+ "entryVisibilityTip": "トップバー項目とデスクトップメニューおよびツールバーの組み込み項目の表示と順序、およびドックアイコンの表示と順序を設定します","entrySimple": "シンプル","entryFull": "完全","entrySimpleTip": "よく使う項目を表示し、すぐに使い始められる構成",diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.jsonindex 5d140a3b75..1be1d65f5f 100644--- a/app/appearance/langs/ko.json+++ b/app/appearance/langs/ko.json@@ -259,7 +259,7 @@"entrySubmenu": "하위 메뉴","splitMergedCellTip": "먼저 병합된 셀을 분할해야 합니다","entryVisibility": "상단 표시줄, 메뉴, 도구 모음 및 도크",- "entryVisibilityTip": "상단 표시줄 항목과 데스크톱 메뉴 및 도구 모음의 기본 항목 표시 여부와 순서, 도크 아이콘의 표시 여부를 설정합니다",+ "entryVisibilityTip": "상단 표시줄 항목과 데스크톱 메뉴 및 도구 모음의 기본 항목 표시 여부와 순서, 도크 아이콘의 표시 여부와 순서를 설정합니다","entrySimple": "간단","entryFull": "전체","entrySimpleTip": "자주 사용하는 항목을 표시해 새 사용자가 빠르게 시작할 수 있도록 함",diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.jsonindex bad01531f6..d3b383a3b4 100644--- a/app/appearance/langs/nl.json+++ b/app/appearance/langs/nl.json@@ -259,7 +259,7 @@"entrySubmenu": "Submenu","splitMergedCellTip": "Splits eerst de samengevoegde cellen","entryVisibility": "Bovenbalk, menu's, werkbalk en dock",- "entryVisibilityTip": "Configureer de zichtbaarheid en volgorde van bovenbalkitems en ingebouwde items in desktopmenu's en de werkbalk, en de zichtbaarheid van dockpictogrammen",+ "entryVisibilityTip": "Configureer de zichtbaarheid en volgorde van bovenbalkitems en ingebouwde items in desktopmenu's en de werkbalk, en de zichtbaarheid en volgorde van dockpictogrammen","entrySimple": "Eenvoudig","entryFull": "Volledig","entrySimpleTip": "Toont veelgebruikte items om snel aan de slag te gaan",diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.jsonindex 7c97681061..17d21d3436 100644--- a/app/appearance/langs/pl.json+++ b/app/appearance/langs/pl.json@@ -259,7 +259,7 @@"entrySubmenu": "Podmenu","splitMergedCellTip": "Najpierw podziel scalone komórki","entryVisibility": "Górny pasek, menu, pasek narzędzi i dok",- "entryVisibilityTip": "Skonfiguruj widoczność i kolejność elementów górnego paska oraz wbudowanych elementów menu i paska narzędzi pulpitu, a także widoczność ikon doku",+ "entryVisibilityTip": "Skonfiguruj widoczność i kolejność elementów górnego paska oraz wbudowanych elementów menu i paska narzędzi pulpitu, a także widoczność i kolejność ikon doku","entrySimple": "Prosty","entryFull": "Pełny","entrySimpleTip": "Wyświetla często używane pozycje, aby ułatwić szybki start",diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.jsonindex 8406589df5..8b41f29f9f 100644--- a/app/appearance/langs/pt-BR.json+++ b/app/appearance/langs/pt-BR.json@@ -259,7 +259,7 @@"entrySubmenu": "Submenu","splitMergedCellTip": "Divida primeiro as células mescladas","entryVisibility": "Barra superior, menus, barra de ferramentas e dock",- "entryVisibilityTip": "Configure a visibilidade e a ordem dos itens da barra superior e dos itens integrados dos menus e da barra de ferramentas da área de trabalho, bem como a visibilidade dos ícones do dock",+ "entryVisibilityTip": "Configure a visibilidade e a ordem dos itens da barra superior e dos itens integrados dos menus e da barra de ferramentas da área de trabalho, bem como a visibilidade e a ordem dos ícones do dock","entrySimple": "Simples","entryFull": "Completo","entrySimpleTip": "Mostra os itens mais usados para começar rapidamente",diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.jsonindex 6c98adb070..d8b4f8d6b0 100644--- a/app/appearance/langs/ru.json+++ b/app/appearance/langs/ru.json@@ -259,7 +259,7 @@"entrySubmenu": "Подменю","splitMergedCellTip": "Сначала разделите объединённые ячейки","entryVisibility": "Верхняя панель, меню, панель инструментов и док-панель",- "entryVisibilityTip": "Настройте видимость и порядок элементов верхней панели и встроенных пунктов меню и панели инструментов рабочего стола, а также видимость значков док-панели",+ "entryVisibilityTip": "Настройте видимость и порядок элементов верхней панели и встроенных пунктов меню и панели инструментов рабочего стола, а также видимость и порядок значков док-панели","entrySimple": "Простой","entryFull": "Полный","entrySimpleTip": "Показывает часто используемые пункты, чтобы быстрее начать работу",diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.jsonindex 28865b391e..08c011bd23 100644--- a/app/appearance/langs/sk.json+++ b/app/appearance/langs/sk.json@@ -259,7 +259,7 @@"entrySubmenu": "Podponuka","splitMergedCellTip": "Najprv rozdeľte zlúčené bunky","entryVisibility": "Horný panel, ponuky, panel s nástrojmi a dok",- "entryVisibilityTip": "Nastavte viditeľnosť a poradie položiek horného panela a vstavaných položiek ponúk a panela s nástrojmi na pracovnej ploche, ako aj viditeľnosť ikon doku",+ "entryVisibilityTip": "Nastavte viditeľnosť a poradie položiek horného panela a vstavaných položiek ponúk a panela s nástrojmi na pracovnej ploche, ako aj viditeľnosť a poradie ikon doku","entrySimple": "Jednoduchý","entryFull": "Úplný","entrySimpleTip": "Zobrazuje často používané položky na rýchle začatie práce",diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.jsonindex f6cfb79c5b..6450a13726 100644--- a/app/appearance/langs/th.json+++ b/app/appearance/langs/th.json@@ -259,7 +259,7 @@"entrySubmenu": "เมนูย่อย","splitMergedCellTip": "ต้องแยกเซลล์ที่ผสานก่อน","entryVisibility": "แถบด้านบน เมนู แถบเครื่องมือ และแถบเชื่อมต่อ",- "entryVisibilityTip": "กำหนดการแสดงผลและลำดับของรายการแถบด้านบน และรายการในตัวของเมนูเดสก์ท็อปและแถบเครื่องมือ ตลอดจนการแสดงผลของไอคอนแถบเชื่อมต่อ",+ "entryVisibilityTip": "กำหนดการแสดงผลและลำดับของรายการแถบด้านบน และรายการในตัวของเมนูเดสก์ท็อปและแถบเครื่องมือ ตลอดจนการแสดงผลและลำดับของไอคอนแถบเชื่อมต่อ","entrySimple": "เรียบง่าย","entryFull": "ครบถ้วน","entrySimpleTip": "แสดงรายการที่ใช้บ่อยเพื่อช่วยให้ผู้ใช้ใหม่เริ่มต้นได้อย่างรวดเร็ว",diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.jsonindex 5acaabeb6f..046ad7864a 100644--- a/app/appearance/langs/tr.json+++ b/app/appearance/langs/tr.json@@ -259,7 +259,7 @@"entrySubmenu": "Alt menü","splitMergedCellTip": "Önce birleştirilmiş hücreleri bölün","entryVisibility": "Üst çubuk, menüler, araç çubuğu ve yuva",- "entryVisibilityTip": "Üst çubuk öğeleri ile masaüstü menüleri ve araç çubuğundaki yerleşik öğelerin görünürlüğünü ve sırasını, ayrıca yuva simgelerinin görünürlüğünü yapılandırın",+ "entryVisibilityTip": "Üst çubuk öğeleri ile masaüstü menüleri ve araç çubuğundaki yerleşik öğelerin görünürlüğünü ve sırasını, ayrıca yuva simgelerinin görünürlüğünü ve sırasını yapılandırın","entrySimple": "Basit","entryFull": "Tam","entrySimpleTip": "Yeni kullanıcıların hızlıca başlayabilmesi için sık kullanılan öğeleri gösterir",diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.jsonindex 079ddfdf7c..d535760ae3 100644--- a/app/appearance/langs/uk.json+++ b/app/appearance/langs/uk.json@@ -259,7 +259,7 @@"entrySubmenu": "Підменю","splitMergedCellTip": "Спочатку розділіть об’єднані комірки","entryVisibility": "Верхня панель, меню, панель інструментів і док-панель",- "entryVisibilityTip": "Налаштуйте видимість і порядок елементів верхньої панелі та вбудованих пунктів меню й панелі інструментів робочого столу, а також видимість піктограм док-панелі",+ "entryVisibilityTip": "Налаштуйте видимість і порядок елементів верхньої панелі та вбудованих пунктів меню й панелі інструментів робочого столу, а також видимість і порядок піктограм док-панелі","entrySimple": "Простий","entryFull": "Повний","entrySimpleTip": "Показує часто використовувані пункти, щоб швидше почати роботу",diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.jsonindex 9354219683..bc2f229582 100644--- a/app/appearance/langs/zh-CN.json+++ b/app/appearance/langs/zh-CN.json@@ -259,7 +259,7 @@"entrySubmenu": "子菜单","splitMergedCellTip": "需要先拆分合并的单元格","entryVisibility": "顶栏、菜单、工具栏与停靠栏",- "entryVisibilityTip": "配置桌面端顶栏项、内置菜单项与工具栏项的显隐与排序,以及停靠栏图标的显隐",+ "entryVisibilityTip": "配置桌面端顶栏项、内置菜单项与工具栏项的显隐与排序,以及停靠栏图标的显隐与排序","entrySimple": "简洁方案","entryFull": "完整方案","entrySimpleTip": "显示常用入口,适合新用户快速上手",diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.jsonindex f6663ed959..34bfbe85ff 100644--- a/app/appearance/langs/zh-TW.json+++ b/app/appearance/langs/zh-TW.json@@ -259,7 +259,7 @@"entrySubmenu": "子菜單","splitMergedCellTip": "需要先拆分合併的單元格","entryVisibility": "頂欄、選單、工具列與停靠欄",- "entryVisibilityTip": "設定桌面端頂欄項目、內建選單項目與工具列項目的顯示與排序,以及停靠欄圖示的顯示",+ "entryVisibilityTip": "設定桌面端頂欄項目、內建選單項目與工具列項目的顯示與排序,以及停靠欄圖示的顯示與排序","entrySimple": "簡潔方案","entryFull": "完整方案","entrySimpleTip": "顯示常用入口,適合新使用者快速上手",diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.tsindex af39b9f915..09da268f41 100644--- a/app/src/config/entryVisibility/catalog.test.ts+++ b/app/src/config/entryVisibility/catalog.test.ts@@ -16,6 +16,8 @@ import {getEntryCatalogNode,getEntryCatalogPathChain,getEntryCatalogSection,+ getDockEntryKey,+ getDockEntryPosition,getEntryParentPath,getEntryOrderParents,getEntryPaths,@@ -343,14 +345,23 @@ test("dock catalog refreshes unique plugin docks and removes unloaded entries",name: "plugin.one",displayName: "Plugin One",docks: {- first: {id: "shared.id", config: {title: "First Dock"}},- duplicate: {id: "shared.id", config: {title: "Duplicate Dock"}},+ first: {+ id: "shared.id",+ config: {title: "First Dock", position: "LeftTop", index: 0},+ },+ duplicate: {+ id: "shared.id",+ config: {title: "Duplicate Dock", position: "RightBottom", index: 1},+ },},}, {name: "plugin.two",displayName: "Plugin Two",docks: {- second: {id: "shared.id", config: {title: "Second Dock"}},+ second: {+ id: "shared.id",+ config: {title: "Second Dock", position: "BottomRight", index: 2},+ },},}]);@@ -360,10 +371,71 @@ test("dock catalog refreshes unique plugin docks and removes unloaded entries",assert.equal(getEntryCatalogNode(`dock.${firstKey}`)?.label(), "Plugin One - First Dock");assert.equal(getEntryCatalogNode(`dock.${secondKey}`)?.label(), "Plugin Two - Second Dock");assert.equal(getEntryParentPath(`dock.${firstKey}`), "dock");+ assert.equal(getDockEntryPosition(firstKey), "LeftTop");+ assert.equal(getDockEntryPosition(secondKey), "BottomRight");} finally {refreshDockCatalog([]);}assert.equal(getEntryCatalogNode(`dock.${firstKey}`), undefined);+ assert.equal(getDockEntryPosition(firstKey), undefined);+});++test("dock catalog exposes the built-in default positions", () => {+ const positions = {+ file: "LeftTop",+ outline: "LeftTop",+ bookmark: "LeftBottom",+ tag: "LeftBottom",+ backlink: "RightBottom",+ agentChat: "RightTop",+ inbox: "LeftTop",+ graph: "RightTop",+ globalGraph: "RightTop",+ };+ Object.entries(positions).forEach(([key, position]) => {+ assert.equal(getDockEntryPosition(key), position, key);+ });+});++test("dock catalog refreshes plugin placement metadata and resolves runtime types", () => {+ const runtimeType = "plugin.runtime-dock";+ const stableKey = getPluginDockEntryKey("plugin.runtime", "stable.id");+ const plugins = (position: TPluginDockPosition, index: number) => [{+ name: "plugin.runtime",+ docks: {+ [runtimeType]: {+ id: "stable.id",+ config: {title: "Runtime Dock", position, index},+ },+ },+ }];+ const element = (attributes: Record<string, string>) => ({+ getAttribute: (name: string) => attributes[name] ?? null,+ }) as unknown as Element;+ try {+ refreshDockCatalog(plugins("LeftTop", 0));+ const initialChildren = getEntryCatalogChildren("dock");+ assert.equal(getDockEntryKey(element({"data-type": runtimeType})), stableKey);+ assert.equal(getDockEntryKey(element({+ "data-entry-id": "explicit-entry",+ "data-type": runtimeType,+ })), "explicit-entry");+ assert.equal(getDockEntryPosition(stableKey), "LeftTop");++ refreshDockCatalog(plugins("LeftTop", 1));+ const indexChangedChildren = getEntryCatalogChildren("dock");+ assert.notEqual(indexChangedChildren, initialChildren);+ refreshDockCatalog(plugins("LeftTop", 1));+ assert.equal(getEntryCatalogChildren("dock"), indexChangedChildren);++ refreshDockCatalog(plugins("RightBottom", 1));+ assert.equal(getDockEntryPosition(stableKey), "RightBottom");+ } finally {+ refreshDockCatalog([]);+ }+ assert.equal(getDockEntryKey(element({"data-type": runtimeType})), runtimeType);+ assert.equal(getDockEntryPosition(stableKey), undefined);+ assert.equal(getDockEntryPosition("file"), "LeftTop");});test("plugin dock keys encode dotted names and IDs without ambiguity", () => {diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.tsindex 1f7ea5149c..bd15ec6533 100644--- a/app/src/config/entryVisibility/catalog.ts+++ b/app/src/config/entryVisibility/catalog.ts@@ -584,6 +584,32 @@ const dockBuiltinChildren = [node("globalGraph", lang("globalGraph"), false),];+const dockBuiltinPositions = new Map<string, TPluginDockPosition>([+ ["file", "LeftTop"],+ ["outline", "LeftTop"],+ ["bookmark", "LeftBottom"],+ ["tag", "LeftBottom"],+ ["backlink", "RightBottom"],+ ["agentChat", "RightTop"],+ ["inbox", "LeftTop"],+ ["graph", "RightTop"],+ ["globalGraph", "RightTop"],+]);++const dockRuntimeTypeKeys = new Map<string, string>();+const dockEntryPositions = new Map(dockBuiltinPositions);++export const getDockEntryKey = (element: Element) => {+ const entryID = element.getAttribute("data-entry-id");+ if (entryID) {+ return entryID;+ }+ const type = element.getAttribute("data-type");+ return type ? dockRuntimeTypeKeys.get(type) || type : undefined;+};++export const getDockEntryPosition = (key: string) => dockEntryPositions.get(key);+const dockCatalogSection: IEntryCatalogSection = {key: "dock",label: lang("entryDock"),@@ -1095,7 +1121,7 @@ interface IDockCatalogPlugin {displayName?: string;docks: Record<string, {id: string;- config: Pick<IPluginDockTab, "title">;+ config: Pick<IPluginDockTab, "title" | "position" | "index">;}>;}@@ -1105,9 +1131,12 @@ export const refreshDockCatalog = (plugins: IDockCatalogPlugin[]) => {const signature = JSON.stringify(plugins.map((plugin) => ({name: plugin.name,displayName: plugin.displayName,- docks: Object.values(plugin.docks).map((dock) => ({+ docks: Object.entries(plugin.docks).map(([type, dock]) => ({+ type,id: dock.id,title: dock.config.title,+ position: dock.config.position,+ index: dock.config.index,})),})));if (signature === dockCatalogSignature) {@@ -1115,18 +1144,26 @@ export const refreshDockCatalog = (plugins: IDockCatalogPlugin[]) => {}const pluginNodes: IEntryCatalogNode[] = [];const pluginKeys = new Set<string>();+ const runtimeTypeKeys = new Map<string, string>();+ const entryPositions = new Map(dockBuiltinPositions);plugins.forEach((plugin) => {- Object.values(plugin.docks).forEach((dock) => {+ Object.entries(plugin.docks).forEach(([type, dock]) => {const key = getPluginDockEntryKey(plugin.name, dock.id);+ runtimeTypeKeys.set(type, key);if (pluginKeys.has(key)) {return;}pluginKeys.add(key);+ entryPositions.set(key, dock.config.position);const pluginName = plugin.displayName?.trim() || plugin.name;pluginNodes.push(node(key, literal(`${pluginName} - ${dock.config.title}`)));});});dockCatalogSection.children = [...dockBuiltinChildren, ...pluginNodes];+ dockRuntimeTypeKeys.clear();+ runtimeTypeKeys.forEach((key, type) => dockRuntimeTypeKeys.set(type, key));+ dockEntryPositions.clear();+ entryPositions.forEach((position, key) => dockEntryPositions.set(key, position));dockCatalogSignature = signature;rebuildCatalogIndexes();};diff --git a/app/src/config/entryVisibility/dockOrder.test.ts b/app/src/config/entryVisibility/dockOrder.test.tsnew file mode 100644index 0000000000..aac767f3e9--- /dev/null+++ b/app/src/config/entryVisibility/dockOrder.test.ts@@ -0,0 +1,200 @@+import * as assert from "node:assert/strict";+import {readFileSync} from "node:fs";+import {resolve} from "node:path";+import test from "node:test";+import {+ applyDockEntryOrderSnapshot,+ createDockEntryOrderSnapshot,+ DOCK_ORDER_SCOPE_BY_POSITION,+ DOCK_ORDER_SCOPES,+ getDockEntryOrderSnapshot,+ getDockOrderContainer,+ isDockOrderScope,+ mergeCurrentDockEntryOrders,+ mergeDockEntryOrderSnapshot,+ type IDockOrderLayout,+ type TDockOrderSnapshot,+} from "./dockOrder";++class FakeDockItem {+ public dataset: {entryId?: string; type?: string};+ public parent?: FakeDockContainer;+ public classList: {contains: (name: string) => boolean};++ constructor(type: string, options: {entryId?: string; hidden?: boolean} = {}) {+ this.dataset = {type, entryId: options.entryId};+ const classes = new Set(["dock__item", ...(options.hidden ? ["fn__none"] : [])]);+ this.classList = {contains: (name) => classes.has(name)};+ }++ public getAttribute(name: string) {+ if (name === "data-entry-id") {+ return this.dataset.entryId || null;+ }+ if (name === "data-type") {+ return this.dataset.type || null;+ }+ return null;+ }+}++class FakeDockContainer {+ public children: FakeDockItem[] = [];++ constructor(items: FakeDockItem[] = []) {+ items.forEach((item) => this.append(item));+ }++ public append(item: FakeDockItem) {+ if (item.parent) {+ const oldIndex = item.parent.children.indexOf(item);+ if (oldIndex > -1) {+ item.parent.children.splice(oldIndex, 1);+ }+ }+ this.children.push(item);+ item.parent = this;+ }+}++const asElement = (item: FakeDockItem) => item as unknown as HTMLElement;+const asContainer = (container: FakeDockContainer) => container as unknown as HTMLElement;++const layoutWith = (containers: FakeDockContainer[]): IDockOrderLayout => ({+ leftDock: {elements: containers.slice(0, 2).map(asContainer)},+ rightDock: {elements: containers.slice(2, 4).map(asContainer)},+ bottomDock: {elements: containers.slice(4, 6).map(asContainer)},+});++const emptySnapshot = () => createDockEntryOrderSnapshot({});++test("dock order scopes map to all six runtime containers", () => {+ const containers = Array.from({length: 6}, () => new FakeDockContainer());+ const layout = layoutWith(containers);+ assert.equal(DOCK_ORDER_SCOPES.length, 6);+ assert.equal(getDockOrderContainer(DOCK_ORDER_SCOPE_BY_POSITION.LeftTop, layout), asContainer(containers[0]));+ assert.equal(getDockOrderContainer(DOCK_ORDER_SCOPE_BY_POSITION.LeftBottom, layout), asContainer(containers[1]));+ assert.equal(getDockOrderContainer(DOCK_ORDER_SCOPE_BY_POSITION.RightTop, layout), asContainer(containers[2]));+ assert.equal(getDockOrderContainer(DOCK_ORDER_SCOPE_BY_POSITION.RightBottom, layout), asContainer(containers[3]));+ assert.equal(getDockOrderContainer(DOCK_ORDER_SCOPE_BY_POSITION.BottomLeft, layout), asContainer(containers[4]));+ assert.equal(getDockOrderContainer(DOCK_ORDER_SCOPE_BY_POSITION.BottomRight, layout), asContainer(containers[5]));+ assert.equal(isDockOrderScope("dock.order.LeftTop"), true);+ assert.equal(isDockOrderScope("dock.order.Unknown"), false);+});++test("dock order snapshot removes duplicates and appends missing catalog entries to their default slots", () => {+ const snapshot = createDockEntryOrderSnapshot({+ LeftTop: ["file", "file", "plugin:one:dock"],+ LeftBottom: ["bookmark"],+ RightTop: ["file", "graph"],+ BottomRight: ["bottom-right"],+ }, [+ {key: "file", position: "LeftTop"},+ {key: "outline", position: "LeftTop"},+ {key: "bookmark", position: "LeftBottom"},+ {key: "tag", position: "LeftBottom"},+ {key: "agentChat", position: "RightTop"},+ {key: "backlink", position: "RightBottom"},+ {key: "bottom-left", position: "BottomLeft"},+ {key: "bottom-right", position: "BottomRight"},+ ]);++ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop], ["file", "plugin:one:dock", "outline"]);+ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.LeftBottom], ["bookmark", "tag"]);+ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.RightTop], ["graph", "agentChat"]);+ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.RightBottom], ["backlink"]);+ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.BottomLeft], ["bottom-left"]);+ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.BottomRight], ["bottom-right"]);+ assert.equal(DOCK_ORDER_SCOPES.flatMap((scope) => snapshot[scope]).filter((key) => key === "file").length, 1);+});++test("runtime dock snapshot reads direct items, keeps hidden items, and uses stable plugin entry IDs", () => {+ const hiddenOutline = new FakeDockItem("outline", {hidden: true});+ const plugin = new FakeDockItem("plugin-runtime-type", {entryId: "plugin:sample:dock"});+ const fileOnRight = new FakeDockItem("file");+ const containers = [+ new FakeDockContainer([hiddenOutline, plugin]),+ new FakeDockContainer(),+ new FakeDockContainer(),+ new FakeDockContainer([fileOnRight]),+ new FakeDockContainer(),+ new FakeDockContainer(),+ ];+ const snapshot = getDockEntryOrderSnapshot(layoutWith(containers));++ assert.deepEqual(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop].slice(0, 2),+ ["outline", "plugin:sample:dock"]);+ assert.equal(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.RightBottom].includes("file"), true);+ assert.equal(snapshot[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop].includes("file"), false);+ assert.equal(hiddenOutline.classList.contains("fn__none"), true);+});++test("merging a dock snapshot preserves an unavailable plugin key at its saved slot", () => {+ const defaults = emptySnapshot();+ defaults[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop] = ["file", "outline"];+ const merged = mergeDockEntryOrderSnapshot(defaults, {+ [DOCK_ORDER_SCOPE_BY_POSITION.LeftTop]: ["outline", "plugin:disabled:dock", "file"],+ });++ assert.deepEqual(merged[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop],+ ["outline", "plugin:disabled:dock", "file"]);+});++test("synchronizing a dock snapshot keeps the current loaded order and preserves unavailable plugins", () => {+ const current = emptySnapshot();+ current[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop] = ["outline", "file"];+ const merged = mergeCurrentDockEntryOrders(current, {+ [DOCK_ORDER_SCOPE_BY_POSITION.LeftTop]: ["file", "plugin:disabled:dock", "outline"],+ });++ assert.deepEqual(merged[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop],+ ["outline", "plugin:disabled:dock", "file"]);+});++test("profiles without dock orders preserve the current six-slot layout", () => {+ const current = emptySnapshot();+ current[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop] = ["outline", "file"];+ current[DOCK_ORDER_SCOPE_BY_POSITION.BottomRight] = ["plugin:sample:dock"];++ assert.deepEqual(mergeDockEntryOrderSnapshot(current), current);+});++test("merging a dock snapshot removes a loaded entry from its stale previous slot", () => {+ const current = emptySnapshot();+ current[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop] = ["outline"];+ current[DOCK_ORDER_SCOPE_BY_POSITION.RightTop] = ["file", "graph"];+ const merged = mergeDockEntryOrderSnapshot(current, {+ [DOCK_ORDER_SCOPE_BY_POSITION.LeftTop]: ["file", "outline", "plugin:disabled:dock"],+ [DOCK_ORDER_SCOPE_BY_POSITION.RightTop]: ["graph", "file"],+ });++ assert.deepEqual(merged[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop], ["outline", "plugin:disabled:dock"]);+ assert.deepEqual(merged[DOCK_ORDER_SCOPE_BY_POSITION.RightTop], ["graph", "file"]);+});++test("applying dock order sorts hidden items and keeps an unknown plugin in its current slot", () => {+ const file = new FakeDockItem("file");+ const unknownPlugin = new FakeDockItem("plugin-runtime", {entryId: "plugin:unknown:dock"});+ const outline = new FakeDockItem("outline", {hidden: true});+ const leftTop = new FakeDockContainer([file, unknownPlugin, outline]);+ const containers = [leftTop, ...Array.from({length: 5}, () => new FakeDockContainer())];+ const snapshot: TDockOrderSnapshot = emptySnapshot();+ snapshot[DOCK_ORDER_SCOPE_BY_POSITION.LeftTop] = ["outline", "file"];++ assert.equal(applyDockEntryOrderSnapshot(snapshot, layoutWith(containers)), true);+ assert.deepEqual(leftTop.children, [outline, unknownPlugin, file]);+ assert.equal(outline.classList.contains("fn__none"), true);+ assert.equal(applyDockEntryOrderSnapshot(snapshot, layoutWith(containers)), false);+ assert.equal(leftTop.children.includes(file), true);+ assert.equal(file.parent, leftTop);+ assert.equal(asElement(file).dataset.type, "file");+});++test("dock ordering is applied at runtime and synchronized after direct dock moves", () => {+ const runtimeSource = readFileSync(resolve(process.cwd(), "src/config/entryVisibility/runtime.ts"), "utf8");+ const dockSource = readFileSync(resolve(process.cwd(), "src/layout/dock/index.ts"), "utf8");++ assert.match(runtimeSource, /applyDockEntryOrderSnapshot\(mergeDockEntryOrderSnapshot\(/);+ assert.match(runtimeSource, /const key = getDockEntryKey\(item\);/);+ assert.match(dockSource, /syncDockEntryOrders\(\);/);+});diff --git a/app/src/config/entryVisibility/dockOrder.ts b/app/src/config/entryVisibility/dockOrder.tsnew file mode 100644index 0000000000..17040051ab--- /dev/null+++ b/app/src/config/entryVisibility/dockOrder.ts@@ -0,0 +1,200 @@+import {+ getDockEntryKey,+ getDockEntryPosition,+ getEntryCatalogChildren,+} from "./catalog";+import {mergeEntryOrderPreservingUnknown, reorderEntrySlots} from "./order";++export const DOCK_ORDER_SCOPE_BY_POSITION = {+ LeftTop: "dock.order.LeftTop",+ LeftBottom: "dock.order.LeftBottom",+ RightTop: "dock.order.RightTop",+ RightBottom: "dock.order.RightBottom",+ BottomLeft: "dock.order.BottomLeft",+ BottomRight: "dock.order.BottomRight",+} as const satisfies Record<TPluginDockPosition, string>;++export type TDockOrderScope = typeof DOCK_ORDER_SCOPE_BY_POSITION[TPluginDockPosition];+export type TDockOrderSnapshot = Record<TDockOrderScope, string[]>;++export const DOCK_ORDER_SCOPES_BY_SIDE: Record<"left" | "right", readonly TDockOrderScope[]> = {+ left: [+ DOCK_ORDER_SCOPE_BY_POSITION.LeftTop,+ DOCK_ORDER_SCOPE_BY_POSITION.LeftBottom,+ DOCK_ORDER_SCOPE_BY_POSITION.BottomLeft,+ ],+ right: [+ DOCK_ORDER_SCOPE_BY_POSITION.RightTop,+ DOCK_ORDER_SCOPE_BY_POSITION.RightBottom,+ DOCK_ORDER_SCOPE_BY_POSITION.BottomRight,+ ],+};++export const DOCK_ORDER_SCOPES: readonly TDockOrderScope[] = [+ ...DOCK_ORDER_SCOPES_BY_SIDE.left,+ ...DOCK_ORDER_SCOPES_BY_SIDE.right,+];++const DOCK_ORDER_SCOPE_SET = new Set<string>(DOCK_ORDER_SCOPES);++const DOCK_ORDER_SCOPE_META: Record<TDockOrderScope, {+ position: TPluginDockPosition;+ labelKey: string;+}> = {+ "dock.order.LeftTop": {position: "LeftTop", labelKey: "moveToLeftTop"},+ "dock.order.LeftBottom": {position: "LeftBottom", labelKey: "moveToLeftBottom"},+ "dock.order.RightTop": {position: "RightTop", labelKey: "moveToRightTop"},+ "dock.order.RightBottom": {position: "RightBottom", labelKey: "moveToRightBottom"},+ "dock.order.BottomLeft": {position: "BottomLeft", labelKey: "moveToBottomLeft"},+ "dock.order.BottomRight": {position: "BottomRight", labelKey: "moveToBottomRight"},+};++export interface IDockOrderLayout {+ leftDock?: {elements: HTMLElement[]};+ rightDock?: {elements: HTMLElement[]};+ bottomDock?: {elements: HTMLElement[]};+}++export interface IDockOrderDefaultEntry {+ key: string;+ position?: TPluginDockPosition;+}++type TDockOrdersByPosition = Partial<Record<TPluginDockPosition, readonly string[]>>;++const createEmptySnapshot = (): TDockOrderSnapshot => Object.fromEntries(+ DOCK_ORDER_SCOPES.map((scope) => [scope, []]),+) as TDockOrderSnapshot;++export const getDockOrderScopePosition = (scope: TDockOrderScope) => DOCK_ORDER_SCOPE_META[scope].position;++export const getDockOrderScopeLabelKey = (scope: TDockOrderScope) => DOCK_ORDER_SCOPE_META[scope].labelKey;++export const isDockOrderScope = (path: string): path is TDockOrderScope => DOCK_ORDER_SCOPE_SET.has(path);++export const getDockOrderContainer = (+ scope: TDockOrderScope,+ layout: IDockOrderLayout = window.siyuan.layout,+) => {+ switch (getDockOrderScopePosition(scope)) {+ case "LeftTop":+ return layout.leftDock?.elements[0];+ case "LeftBottom":+ return layout.leftDock?.elements[1];+ case "RightTop":+ return layout.rightDock?.elements[0];+ case "RightBottom":+ return layout.rightDock?.elements[1];+ case "BottomLeft":+ return layout.bottomDock?.elements[0];+ case "BottomRight":+ return layout.bottomDock?.elements[1];+ }+};++export const createDockEntryOrderSnapshot = (+ current: TDockOrdersByPosition,+ defaults: readonly IDockOrderDefaultEntry[] = [],+) => {+ const snapshot = createEmptySnapshot();+ const seen = new Set<string>();+ DOCK_ORDER_SCOPES.forEach((scope) => {+ const position = getDockOrderScopePosition(scope);+ (current[position] || []).forEach((key) => {+ if (!key || seen.has(key)) {+ return;+ }+ seen.add(key);+ snapshot[scope].push(key);+ });+ });+ defaults.forEach((item) => {+ if (!item.key || !item.position || seen.has(item.key)) {+ return;+ }+ seen.add(item.key);+ snapshot[DOCK_ORDER_SCOPE_BY_POSITION[item.position]].push(item.key);+ });+ return snapshot;+};++const mergeDockEntryOrders = (+ current: TDockOrderSnapshot,+ savedOrders?: Partial<Record<string, readonly string[]>>,+ useCurrentOrder = false,+ loadedKeys: ReadonlySet<string> = new Set(DOCK_ORDER_SCOPES.flatMap((scope) => current[scope])),+) => {+ const snapshot = createEmptySnapshot();+ DOCK_ORDER_SCOPES.forEach((scope) => {+ const currentKeys = new Set(current[scope]);+ const savedOrder = savedOrders?.[scope]?.filter((key) => !loadedKeys.has(key) || currentKeys.has(key));+ snapshot[scope] = mergeEntryOrderPreservingUnknown(+ current[scope],+ savedOrder ? [...savedOrder] : undefined,+ useCurrentOrder ? current[scope] : undefined,+ );+ });+ return snapshot;+};++export const mergeDockEntryOrderSnapshot = (+ current: TDockOrderSnapshot,+ savedOrders?: Partial<Record<string, readonly string[]>>,+) => mergeDockEntryOrders(current, savedOrders);++export const mergeCurrentDockEntryOrders = (+ current: TDockOrderSnapshot,+ savedOrders?: Partial<Record<string, readonly string[]>>,+) => mergeDockEntryOrders(current, savedOrders, true);++const getContainerEntryKeys = (container?: HTMLElement) => {+ if (!container) {+ return [];+ }+ return Array.from(container.children).reduce<string[]>((keys, item) => {+ if (!item.classList.contains("dock__item")) {+ return keys;+ }+ const key = getDockEntryKey(item);+ if (key) {+ keys.push(key);+ }+ return keys;+ }, []);+};++export const getDockEntryOrderSnapshot = (+ layout: IDockOrderLayout = window.siyuan.layout,+) => {+ const current: TDockOrdersByPosition = {};+ DOCK_ORDER_SCOPES.forEach((scope) => {+ current[getDockOrderScopePosition(scope)] = getContainerEntryKeys(getDockOrderContainer(scope, layout));+ });+ const defaults = (getEntryCatalogChildren("dock") || []).map((item) => ({+ key: item.key,+ position: getDockEntryPosition(item.key),+ }));+ return createDockEntryOrderSnapshot(current, defaults);+};++export const applyDockEntryOrderSnapshot = (+ snapshot: TDockOrderSnapshot,+ layout: IDockOrderLayout = window.siyuan.layout,+) => {+ let changed = false;+ DOCK_ORDER_SCOPES.forEach((scope) => {+ const container = getDockOrderContainer(scope, layout);+ if (!container) {+ return;+ }+ const items = Array.from(container.children).filter((item): item is HTMLElement =>+ item.classList.contains("dock__item"));+ const ordered = reorderEntrySlots(items, snapshot[scope], getDockEntryKey);+ if (ordered.every((item, index) => item === items[index])) {+ return;+ }+ ordered.forEach((item) => container.append(item));+ changed = true;+ });+ return changed;+};diff --git a/app/src/config/entryVisibility/runtime.ts b/app/src/config/entryVisibility/runtime.tsindex bcd1dc3df6..eb0df9add4 100644--- a/app/src/config/entryVisibility/runtime.ts+++ b/app/src/config/entryVisibility/runtime.ts@@ -4,10 +4,12 @@ import {getEntryCatalogDefaultVisibility,getEntryCatalogChildren,getEntryCatalogNode,+ getDockEntryKey,getEntryOrderParents,getEntryParentPath,getEntryPaths,isEntryCatalogNodeConfigurable,+ refreshDockCatalog,refreshTopBarCatalog,TOP_BAR_ROOT_PATH,} from "./catalog";@@ -23,6 +25,13 @@ import {TOOLBAR_ENTRY_ROOT_PATH} from "../../protyle/toolbar/defaults";import {resolveToolbarItems} from "../../protyle/toolbar/entryVisibility";import {syncDockBarVisibility} from "../../layout/dock/barVisibility";import {genUUID} from "../../util/genID";+import {+ applyDockEntryOrderSnapshot,+ getDockEntryOrderSnapshot,+ isDockOrderScope,+ mergeCurrentDockEntryOrders,+ mergeDockEntryOrderSnapshot,+} from "./dockOrder";export const ENTRY_VISIBILITY_VERSION = 4;export const ENTRY_PROFILE_SIMPLE = "simple";@@ -76,6 +85,9 @@ export const createEntryProfileSnapshot = (template: TEntryVisibilityTemplate) =};export const getEntryOrder = (parentPath: string, profile = getActiveEntryProfile()) => {+ if (isDockOrderScope(parentPath)) {+ return mergeDockEntryOrderSnapshot(getDockEntryOrderSnapshot(), profile?.orders)[parentPath];+ }const nodes = getEntryCatalogChildren(parentPath) || [];const defaultOrder = nodes.map((item) => item.key);const separatorKeys = new Set(nodes.filter((item) => item.type === "separator").map((item) => item.key));@@ -85,14 +97,17 @@ export const getEntryOrder = (parentPath: string, profile = getActiveEntryProfilreturn resolveEntryOrder(defaultOrder, profile?.orders?.[parentPath], separatorKeys);};-export const createEntryOrderSnapshot = (current = false) => getEntryOrderParents()- .reduce<Record<string, string[]>>((orders, parentPath) => {+export const createEntryOrderSnapshot = (current = false) => {+ refreshDockCatalog(window.siyuan.ws?.app?.plugins || []);+ const orders = getEntryOrderParents().reduce<Record<string, string[]>>((result, parentPath) => {const nodes = getEntryCatalogChildren(parentPath) || [];- orders[parentPath] = current+ result[parentPath] = current? getEntryOrder(parentPath): nodes.map((item) => item.key);- return orders;+ return result;}, {});+ return {...orders, ...getDockEntryOrderSnapshot()};+};const cloneEntryVisibilityConfig = () => JSON.parse(JSON.stringify(window.siyuan.config.appearance.entryVisibility@@ -138,14 +153,15 @@ export const setEntryVisibilityValue = (path: string, visible: boolean) => {};export const setEntryOrderValue = (parentPath: string, order: string[]) => {- const nodes = getEntryCatalogChildren(parentPath);- if (window.siyuan.config.readonly || !nodes) {+ const dockOrder = isDockOrderScope(parentPath) ? getDockEntryOrderSnapshot()[parentPath] : undefined;+ const nodes = dockOrder ? undefined : getEntryCatalogChildren(parentPath);+ if (window.siyuan.config.readonly || (!dockOrder && !nodes)) {return;}const config = cloneEntryVisibilityConfig();const profile = getWritableEntryProfile(config);- const defaultOrder = nodes.map((item) => item.key);- const separatorKeys = new Set(nodes.filter((item) => item.type === "separator").map((item) => item.key));+ const defaultOrder = dockOrder || nodes.map((item) => item.key);+ const separatorKeys = new Set(nodes?.filter((item) => item.type === "separator").map((item) => item.key));profile.orders[parentPath] = mergeEntryOrderPreservingUnknown(defaultOrder,profile.orders[parentPath],@@ -180,6 +196,19 @@ export const saveEntryVisibility = (config: Config.IEntryVisibility) => {flushEntryVisibility();};+export const syncDockEntryOrders = () => {+ if (window.siyuan.config.readonly) {+ return;+ }+ refreshDockCatalog(window.siyuan.ws?.app?.plugins || []);+ const currentOrders = getDockEntryOrderSnapshot();+ const config = cloneEntryVisibilityConfig();+ const profile = getWritableEntryProfile(config);+ profile.orders ||= {};+ Object.assign(profile.orders, mergeCurrentDockEntryOrders(currentOrders, profile.orders));+ saveEntryVisibility(config);+};+const entryScope = (menuElement: HTMLElement): string => {switch (menuElement.dataset.name) {case Constants.MENU_DOC_TREE_PANEL_MORE:@@ -311,9 +340,15 @@ export const applyMenuEntryVisibility = (menuElement: HTMLElement) => {export const applyDockEntryVisibility = () => {/// #if !MOBILE+ refreshDockCatalog(window.siyuan.ws?.app?.plugins || []);+ applyDockEntryOrderSnapshot(mergeDockEntryOrderSnapshot(+ getDockEntryOrderSnapshot(),+ getActiveEntryProfile()?.orders,+ ));document.querySelectorAll<HTMLElement>(".dock__item[data-type]").forEach((item) => {const type = item.dataset.type;- const path = `dock.${item.dataset.entryId || type}`;+ const key = getDockEntryKey(item);+ const path = key ? `dock.${key}` : "";if (!getEntryCatalogNode(path)) {return;}diff --git a/app/src/config/entryVisibility/ui.ts b/app/src/config/entryVisibility/ui.tsindex 0617d4bf54..e505a6a66b 100644--- a/app/src/config/entryVisibility/ui.ts+++ b/app/src/config/entryVisibility/ui.ts@@ -40,6 +40,15 @@ import {TEntryVisibilityImportProfile,} from "./profile";import {getHostCapabilities} from "../../util/hostCapabilities";+import {+ DOCK_ORDER_SCOPES_BY_SIDE,+ getDockEntryOrderSnapshot,+ getDockOrderScopeLabelKey,+ isDockOrderScope,+ mergeDockEntryOrderSnapshot,+ TDockOrderScope,+ TDockOrderSnapshot,+} from "./dockOrder";type TImportFile = {type: "siyuan-entry-profile" | "siyuan-entry-profile-bundle";@@ -193,16 +202,22 @@ const renderProfileCards = (root: HTMLElement) => {container.innerHTML = `<div class="b3-cards b3-cards--nowrap">${cards.join("")}</div>`;};-const getProfileEntryOrder = (profile: Config.IEntryVisibilityProfile, parentPath: string,- nodes = getEntryCatalogChildren(parentPath) || []) => {- const defaultOrder = nodes.map((item) => item.key);- const separatorKeys = new Set(nodes.filter((item) => item.type === "separator").map((item) => item.key));+const resolveProfileEntryOrder = (profile: Config.IEntryVisibilityProfile, parentPath: string,+ defaultOrder: string[], separatorKeys: Set<string>) => {if (parentPath === TOP_BAR_ROOT_PATH) {return resolveEntryOrderWithBoundaryDefaults(defaultOrder, profile.orders?.[parentPath], "drag", separatorKeys);}return resolveEntryOrder(defaultOrder, profile.orders?.[parentPath], separatorKeys);};+const getProfileEntryOrder = (profile: Config.IEntryVisibilityProfile, parentPath: string,+ nodes = getEntryCatalogChildren(parentPath) || []) => resolveProfileEntryOrder(+ profile,+ parentPath,+ nodes.map((item) => item.key),+ new Set(nodes.filter((item) => item.type === "separator").map((item) => item.key)),+);+const orderEntryNodes = (profile: Config.IEntryVisibilityProfile, parentPath: string,nodes: IEntryCatalogNode[]) => {const indexes = new Map(getProfileEntryOrder(profile, parentPath, nodes).map((key, index) => [key, index]));@@ -221,14 +236,15 @@ const renderEntrySwitch = (profile: Config.IEntryVisibilityProfile, path: stringconst renderEntryColumn = (profile: Config.IEntryVisibilityProfile, title: string, prefix: string,nodes: IEntryCatalogNode[], depth: number, selectedPaths: string[],- parentEnabled: boolean, readOnly: boolean, sortable: boolean) => `<section class="config-entry-visibility__column"+ parentEnabled: boolean, readOnly: boolean, sortable: boolean,+ getItemPath = (item: IEntryCatalogNode) => `${prefix}.${item.key}`) => `<section class="config-entry-visibility__column"data-entry-column data-entry-depth="${depth}"><div class="config-entry-visibility__column-title"><span class="fn__ellipsis fn__flex-1" title="${escapeAttr(title)}">${escapeHtml(title)}</span></div><div class="config-entry-visibility__column-list">${nodes.map((item) => {- const path = `${prefix}.${item.key}`;+ const path = getItemPath(item);const configurable = isEntryCatalogNodeConfigurable(item);const draggable = sortable && parentEnabled && configurable;if (item.type === "separator") {@@ -295,9 +311,134 @@ const renderEntryLocation = (profile: Config.IEntryVisibilityProfile, item: IEnt</div>`;};+type TDockSide = keyof typeof DOCK_ORDER_SCOPES_BY_SIDE;++const DOCK_SECTION_KEY = "dock";+const DOCK_SIDES = Object.keys(DOCK_ORDER_SCOPES_BY_SIDE) as TDockSide[];+const getDockSidePath = (side: TDockSide) => `${DOCK_SECTION_KEY}.side.${side}`;+const getDockSideLabel = (side: TDockSide) => `${window.siyuan.languages.entryDock} - ${+ window.siyuan.languages[side === "left" ? "marginLeft" : "marginRight"]}`;++const getEntryOrderContext = (parentPath: string, dockOrderSnapshot: TDockOrderSnapshot) => {+ if (isDockOrderScope(parentPath)) {+ const defaultOrder = [...dockOrderSnapshot[parentPath]];+ const dockNodes = new Map((getEntryCatalogChildren(DOCK_SECTION_KEY) || []).map((item) => [item.key, item]));+ return {+ defaultOrder,+ nodes: defaultOrder.map((key) => dockNodes.get(key))+ .filter((item): item is IEntryCatalogNode => Boolean(item)),+ separatorKeys: new Set<string>(),+ };+ }+ const nodes = getEntryCatalogChildren(parentPath) || [];+ return {+ defaultOrder: nodes.map((item) => item.key),+ nodes,+ separatorKeys: new Set(nodes.filter((item) => item.type === "separator").map((item) => item.key)),+ };+};++const renderEntryNavigationColumn = (+ title: string,+ items: Array<{label: string; path: string}>,+ depth: number,+ selectedPath?: string,+) => `<section class="config-entry-visibility__column" data-entry-column data-entry-depth="${depth}">+ <div class="config-entry-visibility__column-title">+ <span class="fn__ellipsis fn__flex-1" title="${escapeAttr(title)}">${escapeHtml(title)}</span>+ </div>+ <div class="config-entry-visibility__column-list">+ ${items.map((item) => `<div class="config-entry-visibility__row config-entry-visibility__row--navigable${+ selectedPath === item.path ? " config-entry-visibility__row--current" : ""}"+ data-action="navigate-entry" data-entry-path="${escapeAttr(item.path)}" data-entry-depth="${depth}">+ <button class="config-entry-visibility__navigate" data-action="navigate-entry"+ data-entry-path="${escapeAttr(item.path)}" data-entry-depth="${depth}" title="${escapeAttr(item.label)}">+ <span>${escapeHtml(item.label)}</span>+ </button>+ <button class="block__icon block__icon--show config-entry-visibility__arrow" data-action="navigate-entry"+ data-entry-path="${escapeAttr(item.path)}" data-entry-depth="${depth}"+ aria-label="${escapeAttr(window.siyuan.languages.expand)}">+ <svg><use xlink:href="#iconRight"></use></svg>+ </button>+ </div>`).join("")}+ </div>+</section>`;++const getDockScopeLabel = (scope: TDockOrderScope) => {+ const labelKey = getDockOrderScopeLabelKey(scope);+ return window.siyuan.languages[labelKey] || labelKey;+};++const getDockScopeNodes = (+ profile: Config.IEntryVisibilityProfile,+ scope: TDockOrderScope,+ snapshot: TDockOrderSnapshot,+) => {+ const context = getEntryOrderContext(scope, snapshot);+ const nodes = new Map(context.nodes.map((item) => [item.key, item]));+ return resolveProfileEntryOrder(profile, scope, context.defaultOrder, context.separatorKeys)+ .map((key) => nodes.get(key))+ .filter((item): item is IEntryCatalogNode => Boolean(item));+};++const renderDockColumns = (+ columns: string[],+ profile: Config.IEntryVisibilityProfile,+ section: IEntryCatalogSection,+ selectedPaths: string[],+ readOnly: boolean,+ snapshot: TDockOrderSnapshot,+ visiblePaths?: Set<string>,+) => {+ const sideItems = DOCK_SIDES.map((side) => ({+ label: getDockSideLabel(side),+ path: getDockSidePath(side),+ }));+ columns.push(renderEntryNavigationColumn(section.label(), sideItems, 0, selectedPaths[0]));+ const selectedSide = DOCK_SIDES.find((side) => getDockSidePath(side) === selectedPaths[0]);+ if (!selectedSide) {+ return;+ }+ const scopes = DOCK_ORDER_SCOPES_BY_SIDE[selectedSide];+ const scopeItems = scopes.map((scope) => ({+ label: getDockScopeLabel(scope),+ path: scope,+ }));+ columns.push(renderEntryNavigationColumn(getDockSideLabel(selectedSide), scopeItems, 1, selectedPaths[1]));+ const selectedScope = scopes.find((scope) => scope === selectedPaths[1]);+ if (!selectedScope) {+ return;+ }+ const nodes = getDockScopeNodes(profile, selectedScope, snapshot);+ const visibleNodes = visiblePaths+ ? nodes.filter((item) => visiblePaths.has(`${DOCK_SECTION_KEY}.${item.key}`))+ : nodes;+ columns.push(renderEntryColumn(+ profile,+ getDockScopeLabel(selectedScope),+ selectedScope,+ visibleNodes,+ 2,+ selectedPaths,+ true,+ readOnly,+ !visiblePaths && !readOnly,+ (item) => `${DOCK_SECTION_KEY}.${item.key}`,+ ));+};++const getDockEntrySelectedPaths = (snapshot: TDockOrderSnapshot, key: string) => {+ for (const side of DOCK_SIDES) {+ const scope = DOCK_ORDER_SCOPES_BY_SIDE[side].find((item) => snapshot[item].includes(key));+ if (scope) {+ return [getDockSidePath(side), scope, `${DOCK_SECTION_KEY}.${key}`];+ }+ }+};+const renderEntryColumns = (profile: Config.IEntryVisibilityProfile, sectionKey: string,selectedPaths: string[], readOnly: boolean, visiblePaths?: Set<string>,- visibleSectionKeys?: Set<string>) => {+ visibleSectionKeys?: Set<string>, dockOrderSnapshot = getDockEntryOrderSnapshot()) => {const sections = visibleSectionKeys? entryCatalog.filter((item) => visibleSectionKeys.has(item.key)): entryCatalog;@@ -309,6 +450,10 @@ const renderEntryColumns = (profile: Config.IEntryVisibilityProfile, sectionKey:</div></section>`;const columns = [locationColumn];+ if (section.key === DOCK_SECTION_KEY) {+ renderDockColumns(columns, profile, section, selectedPaths, readOnly, dockOrderSnapshot, visiblePaths);+ return `<div class="config-entry-visibility__columns">${columns.join("")}</div>`;+ }const directDisplayRoot = getDirectDisplayRoot(section);const directDisplayRootPath = directDisplayRoot ? `${section.key}.${directDisplayRoot.key}` : "";const columnSelectedPaths = directDisplayRoot && selectedPaths[0] === directDisplayRootPath@@ -391,6 +536,7 @@ const openProfileEditor = (root: HTMLElement, profileID?: string) => {refreshTopBarCatalog(plugins);refreshDockCatalog(plugins);refreshSlashMenuCatalog(plugins);+ const dockOrderSnapshot = getDockEntryOrderSnapshot();const builtin = profileID === ENTRY_PROFILE_SIMPLE || profileID === ENTRY_PROFILE_FULL;let selectedTemplate: TEntryVisibilityTemplate | "current" = ENTRY_PROFILE_SIMPLE;const existing = profileID@@ -472,13 +618,15 @@ const openProfileEditor = (root: HTMLElement, profileID?: string) => {if (filter && queryChanged) {const target = filter.results.find((item) => item.section.key === selectedSectionKey) || filter.results[0];selectedSectionKey = target.section.key;- selectedPaths = getEntryCatalogPathChain(target.section.key, target.path);+ selectedPaths = target.section.key === DOCK_SECTION_KEY+ ? getDockEntrySelectedPaths(dockOrderSnapshot, target.item.key) || []+ : getEntryCatalogPathChain(target.section.key, target.path);scrollToEnd = true;resetEntryColumns = true;revealSelection = true;}browser.innerHTML = renderEntryColumns(draft, selectedSectionKey, selectedPaths, builtin,- filter?.visiblePaths, filter?.visibleSectionKeys);+ filter?.visiblePaths, filter?.visibleSectionKeys, dockOrderSnapshot);previousQuery = query;const columnsContainer = browser.querySelector<HTMLElement>(".config-entry-visibility__columns");const columns = Array.from(browser.querySelectorAll<HTMLElement>("[data-entry-column]"));@@ -535,12 +683,17 @@ const openProfileEditor = (root: HTMLElement, profileID?: string) => {dragging.order = undefined;return;}- const nodes = getEntryCatalogChildren(dragging.parentPath) || [];- dragging.defaultOrder = nodes.map((item) => item.key);- const order = getProfileEntryOrder(draft, dragging.parentPath, nodes);+ const context = getEntryOrderContext(dragging.parentPath, dockOrderSnapshot);+ dragging.defaultOrder = context.defaultOrder;+ const order = resolveProfileEntryOrder(+ draft,+ dragging.parentPath,+ context.defaultOrder,+ context.separatorKeys,+ );const after = event.clientY >= row.getBoundingClientRect().top + row.offsetHeight / 2;const movedOrder = moveEntryOrder(order, dragging.sourceKey, row.dataset.entryKey, after,- new Set(nodes.filter((item) => item.type === "separator").map((item) => item.key)));+ context.separatorKeys);clearDropTarget();dragging.order = movedOrder;if (!movedOrder) {@@ -557,10 +710,9 @@ const openProfileEditor = (root: HTMLElement, profileID?: string) => {event.preventDefault();draft.orders ||= {};const savedOrder = draft.orders[dragging.parentPath];+ const context = getEntryOrderContext(dragging.parentPath, dockOrderSnapshot);const separatorKeys = new Set([- ...(getEntryCatalogChildren(dragging.parentPath) || [])- .filter((item) => item.type === "separator")- .map((item) => item.key),+ ...context.separatorKeys,...(savedOrder || []).filter((key) =>key.startsWith("separator_") || key.startsWith("plugin-separator:")),]);@@ -570,6 +722,9 @@ const openProfileEditor = (root: HTMLElement, profileID?: string) => {dragging.order,separatorKeys,);+ if (isDockOrderScope(dragging.parentPath)) {+ Object.assign(draft.orders, mergeDockEntryOrderSnapshot(dockOrderSnapshot, draft.orders));+ }dragging = undefined;renderBrowser();});diff --git a/app/src/layout/dock/index.ts b/app/src/layout/dock/index.tsindex 694958b344..0b04c15a85 100644--- a/app/src/layout/dock/index.ts+++ b/app/src/layout/dock/index.ts@@ -29,6 +29,7 @@ import {} from "./pluginDockState";import {getDockHotkey} from "./hotkey";import {resolveDockPanelVisibility} from "./panelVisibility";+import {syncDockEntryOrders} from "../../config/entryVisibility/runtime";const TYPES = ["file", "outline", "inbox", "bookmark", "tag", "graph", "globalGraph", "backlink", "agentChat"];const DEFAULT_DOCK_SIZE = 232;@@ -1063,6 +1064,7 @@ export class Dock {adjustDockPadding();this.adjustSplit();sourceDock.adjustSplit();+ syncDockEntryOrders();}public remove(key: TDock | string) {