Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/16235

Vanessa965352043ecd
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 0a7df113e8..ca46e7f9cf 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1237,7 +1237,6 @@
"syncProvider": "موفر خدمات التخزين السحابي",
"syncProviderTip": "إذا تم اختياره، سيتم استخدام خدمة التخزين السحابية لهذا الموفر لتحقيق مزامنة السحابة ووظائف النسخ الاحتياطي",
"confirmReset": "هل أنت متأكد من أنك تريد إعادة تعيين كافة اختصارات لوحة المفاتيح إلى الإعدادات الافتراضية؟",
- "notBatchRemove": "حذف دفعة دفتر الملاحظات غير مدعوم",
"confirmRemoveAll": "‫هل أنت متأكد من أنك تريد حذف الـ${count} مستند/مسنتدات والمستندات الفرعية الخاصة بها؟‬",
"microphoneDenied": "‫من الضروري السماح لـSiYuan بالوصول إلى الميكروفون في تفضيلات النظام‬",
"microphoneNotAccess": "تم رفض الوصول إلى الميكروفون، انتقل إلى تفضيلات النظام لإعادة التعيين",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 1aa86aa592..da135dbdb7 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Cloud-Speicherdienstanbieter",
"syncProviderTip": "Wenn ausgewählt, wird der Cloud-Speicherdienst dieses Anbieters verwendet, um Cloud-Synchronisations- und Backup-Funktionen zu erreichen.",
"confirmReset": "Sind Sie sicher, dass Sie alle Tastenkombinationen auf die Standardwerte zurücksetzen möchten?",
- "notBatchRemove": "Die Batch-Löschung von Notizen wird nicht unterstützt",
"confirmRemoveAll": "Sind Sie sicher, dass Sie die ausgewählten ${count} Dokumente und ihre Unterdokumente löschen möchten?",
"microphoneDenied": "Es muss SiYuan der Zugriff auf das Mikrofon in den Systemeinstellungen erlaubt werden.",
"microphoneNotAccess": "Der Zugriff auf das Mikrofon wurde verweigert, gehen Sie zu den Systemeinstellungen, um zurückzusetzen.",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 9d76d21f98..d54cf8cdc2 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Cloud storage service provider",
"syncProviderTip": "If selected, the cloud storage service of this provider will be used to achieve cloud synchronization and backup functions",
"confirmReset": "Are you sure want to reset all keyboard shortcuts to default settings?",
- "notBatchRemove": "Notebook batch deletion is not supported",
"confirmRemoveAll": "Are you sure you want to delete the selected ${count} documents and their subdocuments?",
"microphoneDenied": "Need to allow Siyuan to access the microphone in System Preferences",
"microphoneNotAccess": "Access to the microphone is denied, go to System Preferences to reset",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index d309d04879..f1fa6a038d 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Proveedor de servicios de almacenamiento en la nube",
"syncProviderTip": "Si se selecciona, el servicio de almacenamiento en la nube de este proveedor se usará para lograr funciones de sincronización y copia de seguridad en la nube",
"confirmReset": "¿Está seguro de que desea restablecer todos los atajos de teclado a la configuración predeterminada?",
- "notBatchRemove": "No se admite la eliminación por lotes de blocs de notas",
"confirmRemoveAll": "¿Está seguro de que desea eliminar los documentos ${count} seleccionados y sus subdocumentos?",
"microphoneDenied": "Necesito permitir que Siyuan acceda al micrófono en Preferencias del Sistema",
"microphoneNotAccess": "Acceso al micrófono denegado, ve a Preferencias del Sistema para reiniciar",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 75d2e65d2c..627ff106ca 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Fournisseur de services de stockage en nuage",
"syncProviderTip": "Si sélectionné, le service de stockage cloud de ce fournisseur sera utilisé pour réaliser les fonctions de synchronisation et de sauvegarde cloud",
"confirmReset": "Voulez-vous vraiment réinitialiser tous les raccourcis clavier aux paramètres par défaut ?",
- "notBatchRemove": "La suppression par lots de bloc-notes n'est pas prise en charge",
"confirmRemoveAll": "Voulez-vous vraiment supprimer les documents ${count} sélectionnés et leurs sous-documents ?",
"microphoneDenied": "Vous devez autoriser Siyuan à accéder au microphone dans les Préférences Système",
"microphoneNotAccess": "L'accès au microphone est refusé, allez dans les Préférences Système pour réinitialiser",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 5946c52475..ffe96555e5 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1237,7 +1237,6 @@
"syncProvider": "ספק שירות אחסון בענן",
"syncProviderTip": "אם נבחר, שירות האחסון בענן של ספק זה ישמש כדי להשיג פונקציות סנכרון וגיבוי בענן",
"confirmReset": "האם אתה בטוח רוצה לאפס את כל קיצורי המקלדת להגדרות ברירת מחדל?",
- "notBatchRemove": "מחיקת מחברות באצווה אינה נתמכת",
"confirmRemoveAll": "האם אתה בטוח שברצונך למחוק את ${count} המסמכים שנבחרו ואת תתי-מסמכיהם?",
"microphoneDenied": "יש לאפשר לסייוון לגשת למיקרופון בהעדפות המערכת",
"microphoneNotAccess": "הגישה למיקרופון נדחתה, יש לאפס את הגישה בהעדפות המערכת",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 33624105c2..b70859be74 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1237,7 +1237,6 @@
"syncProvider": "क्लाउड स्टोरेज सेवा प्रदाता",
"syncProviderTip": "यदि चयनित है, तो क्लाउड सिंक्रोनाइज़ेशन और बैकअप कार्यों को प्राप्त करने के लिए इस प्रदाता की क्लाउड स्टोरेज सेवा का उपयोग किया जाएगा",
"confirmReset": "क्या आप वाकई सभी कीबोर्ड शॉर्टकट को डिफ़ॉल्ट सेटिंग्स पर रीसेट करना चाहते हैं?",
- "notBatchRemove": "नोटबुक बैच हटाना समर्थित नहीं है",
"confirmRemoveAll": "क्या आप वाकई चयनित ${count} दस्तावेज़ और उनके उप-दस्तावेज़ हटाना चाहते हैं?",
"microphoneDenied": "सिस्टम प्राथमिकताओं में SiYuan को माइक्रोफ़ोन तक पहुंचने की अनुमति देनी होगी",
"microphoneNotAccess": "माइक्रोफ़ोन तक पहुंच अस्वीकृत, रीसेट करने के लिए सिस्टम प्राथमिकताओं पर जाएं",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index eebe60c359..0be56b2a7a 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Penyedia layanan penyimpanan cloud",
"syncProviderTip": "Jika dipilih, layanan penyimpanan cloud dari penyedia ini akan digunakan untuk mencapai fungsi sinkronisasi dan pencadangan cloud",
"confirmReset": "Apakah Anda yakin ingin mereset semua pintasan keyboard ke pengaturan default?",
- "notBatchRemove": "Penghapusan batch buku catatan tidak didukung",
"confirmRemoveAll": "Apakah Anda yakin ingin menghapus ${count} dokumen yang dipilih dan sub-dokumennya?",
"microphoneDenied": "Perlu mengizinkan Siyuan untuk mengakses mikrofon di Preferensi Sistem",
"microphoneNotAccess": "Akses ke mikrofon ditolak, buka Preferensi Sistem untuk mengatur ulang",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 44725a686b..ed9910cd91 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Provider di servizio di archiviazione cloud",
"syncProviderTip": "Se selezionato, verrà utilizzato il servizio di archiviazione cloud di questo provider per sincronizzare e fare il backup dei dati",
"confirmReset": "Sei sicuro di voler ripristinare tutte le scorciatoie da tastiera alle impostazioni predefinite?",
- "notBatchRemove": "La cancellazione in batch dei taccuini non è supportata",
"confirmRemoveAll": "Sei sicuro di voler eliminare i ${count} documenti selezionati e i loro sotto-documenti?",
"microphoneDenied": "SiYuan deve avere l'autorizzazione per accedere al microfono nelle Preferenze di Sistema",
"microphoneNotAccess": "L'accesso al microfono è negato, vai nelle Preferenze di Sistema per reimpostare",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 3ac3aba53f..342d99b106 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1237,7 +1237,6 @@
"syncProvider": "クラウドストレージサービスプロバイダー",
"syncProviderTip": "選択したプロバイダーのクラウドストレージサービスがクラウド同期とバックアップ機能を実現するために使用されます",
"confirmReset": "すべてのキーボードショートカットをデフォルト設定にリセットしてもよろしいですか?",
- "notBatchRemove": "ノートブックの一括削除はサポートされていません",
"confirmRemoveAll": "選択した ${count} 件のドキュメントとそのサブドキュメントを削除してもよろしいですか?",
"microphoneDenied": "システム環境設定で SiYuan にマイクへのアクセスを許可する必要があります",
"microphoneNotAccess": "マイクへのアクセスが拒否されました。システムの環境設定で許可してください",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index 0bcb2e3470..1c92740249 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1237,7 +1237,6 @@
"syncProvider": "클라우드 저장소 서비스 제공자",
"syncProviderTip": "선택하면 해당 제공자의 클라우드 저장소 서비스를 사용하여 클라우드 동기화 및 백업 기능을 수행합니다",
"confirmReset": "모든 키보드 단축키를 기본 설정으로 초기화하시겠습니까?",
- "notBatchRemove": "노트북 일괄 삭제는 지원되지 않습니다",
"confirmRemoveAll": "선택한 ${count}개의 문서와 하위 문서를 삭제하시겠습니까?",
"microphoneDenied": "시스템 환경설정에서 Siyuan이 마이크에 액세스하도록 허용해야 합니다",
"microphoneNotAccess": "마이크 액세스가 거부되었습니다. 재설정하려면 시스템 환경설정으로 이동하세요",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 243db3a8cc..8410a4d7f5 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Cloudopslagprovider",
"syncProviderTip": "Indien geselecteerd wordt de cloudopslagdienst van deze provider gebruikt voor cloudsynchronisatie en back-up",
"confirmReset": "Weet u zeker dat u alle sneltoetsen wilt herstellen naar de standaardinstellingen?",
- "notBatchRemove": "Batchverwijdering niet ondersteund",
"confirmRemoveAll": "${count} documenten en subdocumenten verwijderen?",
"microphoneDenied": "Geef SiYuan microfoontoegang in Systeemvoorkeuren",
"microphoneNotAccess": "Microfoontoegang geweigerd; ga naar Systeemvoorkeuren om opnieuw in te stellen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 978a941a98..2b9908084f 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Dostawca usługi pamięci w chmurze",
"syncProviderTip": "Jeśli zostanie wybrany, usługa pamięci w chmurze tego dostawcy zostanie wykorzystana do realizacji funkcji synchronizacji i kopii zapasowej w chmurze",
"confirmReset": "Czy na pewno chcesz przywrócić wszystkie skróty klawiszowe do ustawień domyślnych?",
- "notBatchRemove": "Partycjonowanie notesów nie jest wspierane",
"confirmRemoveAll": "Czy na pewno chcesz usunąć wybrane ${count} dokumenty i ich poddokumenty?",
"microphoneDenied": "Należy zezwolić SiYuanowi na dostęp do mikrofonu w Ustawieniach systemowych",
"microphoneNotAccess": "Dostęp do mikrofonu jest zabroniony, przejdź do Ustawień systemowych, aby zresetować",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 7cbf0d0eee..6c20ff1e0d 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Provedor de serviço de armazenamento em nuvem",
"syncProviderTip": "Se selecionado, o serviço de armazenamento em nuvem deste provedor será usado para alcançar funções de sincronização e backup em nuvem",
"confirmReset": "Tem certeza que deseja redefinir todos os atalhos de teclado para as configurações padrão?",
- "notBatchRemove": "Exclusão em lote de bloco de notas não suportada",
"confirmRemoveAll": "Tem certeza que deseja excluir os ${count} documentos selecionados e seus subdocumentos?",
"microphoneDenied": "É necessário permitir que o SiYuan acesse o microfone nas Preferências do Sistema",
"microphoneNotAccess": "O acesso ao microfone foi negado, vá para as Preferências do Sistema para redefinir",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 62aa100939..4330ba4eb8 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Поставщик услуги облачного хранения",
"syncProviderTip": "Если выбрано, будет использоваться облачное хранилище этого провайдера для реализации функций синхронизации и резервного копирования в облаке",
"confirmReset": "Вы уверены, что хотите сбросить все комбинации клавиш до значений по умолчанию?",
- "notBatchRemove": "Пакетное удаление блокнотов не поддерживается",
"confirmRemoveAll": "Вы уверены, что хотите удалить выбранные ${count} документа и их поддокументы?",
"microphoneDenied": "Необходимо разрешить SiYuan доступ к микрофону в Системных настройках",
"microphoneNotAccess": "Доступ к микрофону запрещён, перейдите в Системные настройки для сброса",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index bd6b143f45..e9925a9c1d 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Poskytovateľ cloudu",
"syncProviderTip": "Vyberte poskytovateľa pre synchronizáciu a zálohovanie",
"confirmReset": "Naozaj resetovať všetky klávesové skratky?",
- "notBatchRemove": "Hromadné mazanie zápisníkov nie je podporované",
"confirmRemoveAll": "Naozaj chcete odstrániť vybraných ${count} dokumentov vrátane poddokumentov?",
"microphoneDenied": "Povoľte prístup k mikrofónu v systémových nastaveniach",
"microphoneNotAccess": "Prístup k mikrofónu zamietnutý",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 2fd98becb1..4f458a054b 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1237,7 +1237,6 @@
"syncProvider": "ผู้ให้บริการคลาวด์",
"syncProviderTip": "เมื่อเลือกจะใช้บริการพื้นที่เก็บข้อมูลคลาวด์ของผู้ให้บริการนี้เพื่อการซิงค์และสำรองข้อมูลบนคลาวด์",
"confirmReset": "แน่ใจหรือไม่ที่จะรีเซ็ตปุ่มลัดทั้งหมดเป็นค่าเริ่มต้น?",
- "notBatchRemove": "ไม่รองรับลบสมุดกลุ่ม",
"confirmRemoveAll": "แน่ใจหรือไม่ที่จะลบ ${count} เอกสารที่เลือกและเอกสารย่อยของมัน?",
"microphoneDenied": "ต้องอนุญาตให้ SiYuan เข้าถึงไมโครโฟนในการตั้งค่าระบบ",
"microphoneNotAccess": "การเข้าถึงไมโครโฟนถูกปฏิเสธ ไปที่การตั้งค่าระบบเพื่อตั้งค่าใหม่",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index a9f9a999a3..369e97ece6 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Bulut depolama sağlayıcısı",
"syncProviderTip": "Seçildiğinde, bulut senkronizasyonu ve yedekleme işlevleri bu sağlayıcının servisiyle gerçekleştirilir",
"confirmReset": "Tüm klavye kısayollarını varsayılanlara sıfırlamak istediğine emin misin?",
- "notBatchRemove": "Not defteri toplu silme desteklenmiyor",
"confirmRemoveAll": "Seçilen ${count} belge ve alt belgelerini silmek istediğine emin misin?",
"microphoneDenied": "Siyuan’ın mikrofona erişmesine Sistem Ayarları’ndan izin verilmesi gerekiyor",
"microphoneNotAccess": "Mikrofon erişimi reddedildi, Sistem Ayarları’ndan sıfırla",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 06c895017e..7afc03a4d9 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1237,7 +1237,6 @@
"syncProvider": "Провайдер хмарного сховища",
"syncProviderTip": "Якщо вибрано, хмарний сервіс цього провайдера використовуватиметься для синхронізації та резервного копіювання",
"confirmReset": "Справді скинути всі клавіатурні скорочення до типових налаштувань?",
- "notBatchRemove": "Пакетне видалення блокнотів не підтримується",
"confirmRemoveAll": "Справді видалити вибрані ${count} документів і їхні піддокументи?",
"microphoneDenied": "Потрібно дозволити SiYuan доступ до мікрофона в System Preferences",
"microphoneNotAccess": "Доступ до мікрофона заборонено, перейдіть у System Preferences, щоб скинути налаштування",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index e8fb270276..9034402aa7 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1237,7 +1237,6 @@
"syncProvider": "云端存储服务提供商",
"syncProviderTip": "选择后将使用该提供商的云端存储服务实现云端同步和备份功能",
"confirmReset": "确定将所有快捷键都恢复为默认设置?",
- "notBatchRemove": "不支持笔记本批量删除",
"confirmRemoveAll": "确定删除选中的 ${count} 个文档及其子文档?",
"microphoneDenied": "需在系统偏好设置中允许思源访问麦克风",
"microphoneNotAccess": "麦克风被拒绝访问,可前往系统偏好设置中重新设置",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 991708feb5..dd2babde6a 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1237,7 +1237,6 @@
"syncProvider": "雲端存儲服務提供商",
"syncProviderTip": "選擇後將使用該提供商的雲端存儲服務實現雲端同步和備份功能",
"confirmReset": "確定將所有快捷鍵都恢復為預設設置?",
- "notBatchRemove": "不支持筆記本批量刪除",
"confirmRemoveAll": "確定刪除選中的 ${count} 個文件及其子文件?",
"microphoneDenied": "需在系統偏好設置中允許思源訪問麥克風",
"microphoneNotAccess": "麥克風被拒絕訪問,可前往系統偏好設置中重新設置",
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
index 53f3fff233..2f56a09cdb 100644
--- a/app/src/config/entryVisibility/catalog.test.ts
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -134,6 +134,41 @@ test("document loading actions follow the document menu order", () => {
assert.equal(children[loadAllIndex + 2]?.key, "separator_1");
});
+test("multiple document and notebook entries follow their document tree menus", () => {
+ assert.deepEqual(getEntryCatalogChildren("docTree.notebooks").map((item) => item.key), ["close", "delete"]);
+ assert.ok(getEntryCatalogChildren("docTree.multi").some((item) => item.key === "delete"));
+});
+
+test("multiple document and notebook settings have distinct labels", () => {
+ const windowDescriptor = Object.getOwnPropertyDescriptor(globalThis, "window");
+ Object.defineProperty(globalThis, "window", {
+ configurable: true,
+ value: {
+ siyuan: {
+ languages: {
+ agentCatDoc: "Document",
+ agentCatNotebook: "Notebook",
+ entryDocPanel: "Document panel",
+ more: "More",
+ multiSelect: "Multi-select",
+ },
+ },
+ },
+ });
+ try {
+ assert.equal(entryCatalog.find((item) => item.key === "docTree.multi")?.label(),
+ "Document panel - Document - Multi-select - More");
+ assert.equal(entryCatalog.find((item) => item.key === "docTree.notebooks")?.label(),
+ "Document panel - Notebook - Multi-select - More");
+ } finally {
+ if (windowDescriptor) {
+ Object.defineProperty(globalThis, "window", windowDescriptor);
+ } else {
+ Reflect.deleteProperty(globalThis, "window");
+ }
+ }
+});
+
test("HTML file insertion follows general asset insertion", () => {
const children = getEntryCatalogChildren("document.more");
const insertAssetIndex = children.findIndex((item) => item.key === "insertAsset");
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
index f0284de330..44524fbbd7 100644
--- a/app/src/config/entryVisibility/catalog.ts
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -450,9 +450,14 @@ export const entryCatalog: IEntryCatalogSection[] = [
},
{
key: "docTree.multi",
- label: location(lang("entryDocPanel"), lang("multiSelect"), lang("more")),
+ label: location(lang("entryDocPanel"), lang("agentCatDoc"), lang("multiSelect"), lang("more")),
children: docTreeMultiple(),
},
+ {
+ key: "docTree.notebooks",
+ label: location(lang("entryDocPanel"), lang("agentCatNotebook"), lang("multiSelect"), lang("more")),
+ children: [node("close", lang("close")), node("delete", lang("delete"))],
+ },
{
key: "document.title",
label: location(lang("editor"), lang("entryDocumentMenu")),
diff --git a/app/src/config/entryVisibility/docTreeScope.test.ts b/app/src/config/entryVisibility/docTreeScope.test.ts
new file mode 100644
index 0000000000..334ed357e5
--- /dev/null
+++ b/app/src/config/entryVisibility/docTreeScope.test.ts
@@ -0,0 +1,17 @@
+import * as assert from "node:assert/strict";
+import test from "node:test";
+import {getDocTreeEntryScope} from "./docTreeScope";
+
+const menuFrom = {
+ notebook: "tree-notebook",
+ notebooks: "tree-notebooks",
+ doc: "tree-doc",
+ docs: "tree-docs",
+ items: "tree-items",
+};
+
+test("document tree multiple selections use their respective entry scopes", () => {
+ assert.equal(getDocTreeEntryScope(menuFrom.docs, menuFrom), "docTree.multi");
+ assert.equal(getDocTreeEntryScope(menuFrom.items, menuFrom), "docTree.multi");
+ assert.equal(getDocTreeEntryScope(menuFrom.notebooks, menuFrom), "docTree.notebooks");
+});
diff --git a/app/src/config/entryVisibility/docTreeScope.ts b/app/src/config/entryVisibility/docTreeScope.ts
new file mode 100644
index 0000000000..29a1e5082e
--- /dev/null
+++ b/app/src/config/entryVisibility/docTreeScope.ts
@@ -0,0 +1,23 @@
+interface IDocTreeMenuFrom {
+ notebook: string;
+ notebooks: string;
+ doc: string;
+ docs: string;
+ items: string;
+}
+
+export const getDocTreeEntryScope = (from: string | undefined, menuFrom: IDocTreeMenuFrom) => {
+ if (from === menuFrom.notebook) {
+ return "docTree.notebook";
+ }
+ if (from === menuFrom.doc) {
+ return "docTree.document";
+ }
+ if (from === menuFrom.docs || from === menuFrom.items) {
+ return "docTree.multi";
+ }
+ if (from === menuFrom.notebooks) {
+ return "docTree.notebooks";
+ }
+ return "";
+};
diff --git a/app/src/config/entryVisibility/runtime.ts b/app/src/config/entryVisibility/runtime.ts
index 1ab9cbfa6d..9101c1b040 100644
--- a/app/src/config/entryVisibility/runtime.ts
+++ b/app/src/config/entryVisibility/runtime.ts
@@ -8,6 +8,7 @@ import {
getEntryPaths,
} from "./catalog";
import {reorderEntrySlots, resolveEntryOrder} from "./order";
+import {getDocTreeEntryScope} from "./docTreeScope";
export const ENTRY_VISIBILITY_VERSION = 2;
export const ENTRY_PROFILE_SIMPLE = "simple";
@@ -103,16 +104,13 @@ const entryScope = (menuElement: HTMLElement): string => {
case Constants.MENU_DOC_TREE_PANEL_MORE:
return "docTree.panel";
case Constants.MENU_DOC_TREE_MORE:
- if (menuElement.dataset.from === Constants.MENU_FROM_DOC_TREE_MORE_NOTEBOOK) {
- return "docTree.notebook";
- }
- if (menuElement.dataset.from === Constants.MENU_FROM_DOC_TREE_MORE_DOC) {
- return "docTree.document";
- }
- if (menuElement.dataset.from === Constants.MENU_FROM_DOC_TREE_MORE_ITEMS) {
- return "docTree.multi";
- }
- return "";
+ return getDocTreeEntryScope(menuElement.dataset.from, {
+ notebook: Constants.MENU_FROM_DOC_TREE_MORE_NOTEBOOK,
+ notebooks: Constants.MENU_FROM_DOC_TREE_MORE_NOTEBOOKS,
+ doc: Constants.MENU_FROM_DOC_TREE_MORE_DOC,
+ docs: Constants.MENU_FROM_DOC_TREE_MORE_DOCS,
+ items: Constants.MENU_FROM_DOC_TREE_MORE_ITEMS,
+ });
case Constants.MENU_TITLE:
return "document.title";
case Constants.MENU_BREADCRUMB_MORE:
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 66947f61bf..c923f1194f 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -270,8 +270,10 @@ export abstract class Constants {
public static readonly MENU_DOC_TREE_MORE = "docTreeMore"; // 侧栏文档树右键菜单
public static readonly MENU_DOC_TREE_PANEL_MORE = "docTreePanelMore"; // 文档树面板更多菜单
public static readonly MENU_FROM_DOC_TREE_MORE_NOTEBOOK = "tree-notebook"; // 侧栏文档树右键菜单,单个笔记本
+ public static readonly MENU_FROM_DOC_TREE_MORE_NOTEBOOKS = "tree-notebooks"; // 侧栏文档树右键菜单,多个笔记本
public static readonly MENU_FROM_DOC_TREE_MORE_DOC = "tree-doc"; // 侧栏文档树右键菜单,单个文档
- public static readonly MENU_FROM_DOC_TREE_MORE_ITEMS = "tree-items"; // 侧栏文档树右键菜单,多个文档或笔记本
+ public static readonly MENU_FROM_DOC_TREE_MORE_DOCS = "tree-docs"; // 侧栏文档树右键菜单,多个文档
+ public static readonly MENU_FROM_DOC_TREE_MORE_ITEMS = "tree-items"; // 侧栏文档树右键菜单,文档和笔记本混选
public static readonly MENU_TAG = "tagMenu"; // 侧栏标签菜单
public static readonly MENU_BOOKMARK = "bookmarkMenu"; // 侧栏书签菜单
public static readonly MENU_OUTLINE_CONTEXT = "outline-context"; // 大纲标题右键菜单
diff --git a/app/src/editor/deleteFile.ts b/app/src/editor/deleteFile.ts
index f9ae0e8267..1f3016880b 100644
--- a/app/src/editor/deleteFile.ts
+++ b/app/src/editor/deleteFile.ts
@@ -2,10 +2,10 @@ import {fetchPost, fetchSyncPost} from "../util/fetch";
import {getDisplayName, getNotebookName, isEncryptedBox} from "../util/pathName";
import {confirmDialog} from "../dialog/confirmDialog";
import {hasTopClosestByTag} from "../protyle/util/hasClosest";
-import {showMessage} from "../dialog/message";
import {escapeHtml} from "../util/escape";
import {Constants} from "../constants";
import {checkBlockRef, getBlockRefWarningHTML} from "../util/checkBlockRef";
+import {getDocTreeDeleteTargets} from "../menus/navigationSelection";
export const deleteFile = async (notebookId: string, pathString: string) => {
const hasRef = await checkBlockRef({
@@ -52,6 +52,29 @@ export const deleteFile = async (notebookId: string, pathString: string) => {
}, undefined, true);
};
+export const deleteNotebooks = async (notebookIds: string[]) => {
+ const uniqueNotebookIds = Array.from(new Set(notebookIds));
+ const refResults = await Promise.all(uniqueNotebookIds.map((notebook) => checkBlockRef({
+ scope: "notebook",
+ notebook,
+ })));
+ if (refResults.some((result) => result === undefined)) {
+ return;
+ }
+ const notebookNames = uniqueNotebookIds.map((notebook) => escapeHtml(getNotebookName(notebook))).join("<br>");
+ let tip = `${window.siyuan.languages.confirmDeleteTip.replace("${x}", notebookNames)}
+<div class="fn__hr"></div>
+<div class="ft__smaller ft__on-surface">${window.siyuan.languages.rollbackTip.replace("${x}", window.siyuan.config.editor.historyRetentionDays)}</div>`;
+ if (refResults.some((result) => result)) {
+ tip += getBlockRefWarningHTML();
+ }
+ confirmDialog(window.siyuan.languages.deleteOpConfirm, tip, async () => {
+ for (const notebook of uniqueNotebookIds) {
+ await fetchPost("/api/notebook/removeNotebook", {notebook});
+ }
+ }, undefined, true);
+};
+
export const deleteFiles = async (liElements: Element[]) => {
if (liElements.length === 1) {
const itemTopULElement = hasTopClosestByTag(liElements[0], "UL");
@@ -89,15 +112,51 @@ export const deleteFiles = async (liElements: Element[]) => {
}
}
} else {
- const paths: string[] = [];
- liElements.forEach(item => {
- const dataPath = item.getAttribute("data-path");
- if (dataPath !== "/") {
- paths.push(item.getAttribute("data-path"));
- }
- });
+ const {notebookIds, paths} = getDocTreeDeleteTargets(liElements);
+ if (notebookIds.length > 0 && paths.length === 0) {
+ deleteNotebooks(notebookIds);
+ return;
+ }
if (paths.length === 0) {
- showMessage(window.siyuan.languages.notBatchRemove);
+ return;
+ }
+ if (notebookIds.length > 0) {
+ const refResults = await Promise.all([
+ checkBlockRef({
+ scope: "documents",
+ paths,
+ }),
+ ...notebookIds.map((notebook) => checkBlockRef({
+ scope: "notebook",
+ notebook,
+ })),
+ ]);
+ if (refResults.some((result) => result === undefined)) {
+ return;
+ }
+ const itemNames = liElements.map((item) => {
+ const name = item.querySelector(".b3-list-item__text")?.textContent?.trim();
+ if (name) {
+ return escapeHtml(name);
+ }
+ if (item.getAttribute("data-type") === "navigation-root") {
+ const notebook = item.closest("ul[data-url]")?.getAttribute("data-url");
+ return notebook ? escapeHtml(getNotebookName(notebook)) : "";
+ }
+ return escapeHtml(getDisplayName(item.getAttribute("data-path"), true, true));
+ }).filter(Boolean).join("<br>");
+ let tip = `${window.siyuan.languages.confirmDeleteTip.replace("${x}", itemNames)}
+<div class="fn__hr"></div>
+<div class="ft__smaller ft__on-surface">${window.siyuan.languages.rollbackTip.replace("${x}", window.siyuan.config.editor.historyRetentionDays)}</div>`;
+ if (refResults.some((result) => result)) {
+ tip += getBlockRefWarningHTML();
+ }
+ confirmDialog(window.siyuan.languages.deleteOpConfirm, tip, async () => {
+ await fetchPost("/api/filetree/removeDocs", {paths});
+ for (const notebook of notebookIds) {
+ await fetchPost("/api/notebook/removeNotebook", {notebook});
+ }
+ }, undefined, true);
return;
}
const hasRef = await checkBlockRef({
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index 153a5b5a8c..b6924c7441 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -18,7 +18,7 @@ import {popSearch} from "../mobile/menu/search";
import {Constants} from "../constants";
import {newFileInTree} from "../util/newFile";
import {hasClosestByTag, hasTopClosestByTag} from "../protyle/util/hasClosest";
-import {deleteFiles} from "../editor/deleteFile";
+import {deleteFiles, deleteNotebooks} from "../editor/deleteFile";
/// #if !MOBILE
import {openFileById} from "../editor/util";
/// #endif
@@ -35,6 +35,7 @@ import {emitOpenMenu} from "../plugin/EventBus";
import {saveExportFile} from "../protyle/util/compatibility";
import {exportMarkdownZip} from "../protyle/export/exportMd";
import {addFilesToDatabase} from "../protyle/render/av/addToDatabase";
+import {getDocTreeMenuItems, getDocTreeMenuType} from "./navigationSelection";
/// #if MOBILE
import {openEmojiPanel} from "../emoji";
import {openMobileFileByIdInNewTab} from "../mobile/editor";
@@ -48,16 +49,70 @@ const confirmEncryptedExport = (notebookId: string, callback: () => void) => {
confirmDialog(window.siyuan.languages.export, window.siyuan.languages.encryptedExportRiskTip, callback);
};
-const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
- window.siyuan.menus.menu.element.setAttribute("data-from", Constants.MENU_FROM_DOC_TREE_MORE_ITEMS);
- const fileItemElement = Array.from(selectItemElements).find(item => {
- if (item.getAttribute("data-type") === "navigation-file") {
- return true;
+const initMultiMenu = (selectItemElements: NodeListOf<HTMLElement>, app: App) => {
+ const selectedItems = Array.from(selectItemElements);
+ const fileItemElements = selectedItems.filter((item) => item.getAttribute("data-type") === "navigation-file");
+ const type = getDocTreeMenuType(selectedItems);
+ const items = getDocTreeMenuItems(selectedItems);
+ if (type === "notebooks") {
+ window.siyuan.menus.menu.element.setAttribute("data-from", Constants.MENU_FROM_DOC_TREE_MORE_NOTEBOOKS);
+ if (!window.siyuan.config.readonly) {
+ const notebookIds = items.map((item) => item.id);
+ if (notebookIds.every((notebookId) => !Object.values(Constants.HELP_PATH).includes(notebookId))) {
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "close",
+ label: window.siyuan.languages.close,
+ icon: "iconClose",
+ click: async () => {
+ for (const notebook of notebookIds) {
+ await fetchPost("/api/notebook/closeNotebook", {notebook});
+ }
+ }
+ }).element);
+ }
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "delete",
+ icon: "iconTrashcan",
+ label: window.siyuan.languages.delete,
+ accelerator: "⌦",
+ click: () => {
+ deleteNotebooks(notebookIds);
+ }
+ }).element);
+ }
+ if (app.plugins) {
+ emitOpenMenu({
+ plugins: app.plugins,
+ type: "open-menu-doctree",
+ detail: {elements: selectItemElements, type: "notebooks", items},
+ separatorPosition: !window.siyuan.config.readonly ? "top" : undefined,
+ });
}
- });
- if (!fileItemElement) {
return window.siyuan.menus.menu;
}
+ if (type === "items") {
+ window.siyuan.menus.menu.element.setAttribute("data-from", Constants.MENU_FROM_DOC_TREE_MORE_ITEMS);
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "delete",
+ icon: "iconTrashcan",
+ label: window.siyuan.languages.delete,
+ accelerator: "⌦",
+ click: () => {
+ deleteFiles(selectedItems);
+ }
+ }).element);
+ if (app.plugins) {
+ emitOpenMenu({
+ plugins: app.plugins,
+ type: "open-menu-doctree",
+ detail: {elements: selectItemElements, type: "items", items},
+ separatorPosition: "top",
+ });
+ }
+ return window.siyuan.menus.menu;
+ }
+ window.siyuan.menus.menu.element.setAttribute("data-from", Constants.MENU_FROM_DOC_TREE_MORE_DOCS);
+ const fileItemElement = fileItemElements[0];
const blockIDs: string[] = [];
const notebookId = fileItemElement.parentElement?.getAttribute("data-url") || "";
selectItemElements.forEach(item => {
@@ -89,7 +144,6 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
}).element);
}
- const selectedItems = Array.from(selectItemElements);
window.siyuan.menus.menu.append(movePathToMenu(getTopPaths(selectedItems), selectedItems.map((item) =>
item.closest("ul[data-url]")?.getAttribute("data-url") || "")));
@@ -196,7 +250,8 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>, app: App) => {
type: "open-menu-doctree",
detail: {
elements: selectItemElements,
- type: "docs"
+ type,
+ items,
},
separatorPosition: "top",
});
@@ -219,7 +274,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
});
liElement.classList.add("b3-list-item--focus");
}
- const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
+ const selectItemElements = fileElement.querySelectorAll<HTMLElement>(".b3-list-item--focus");
if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements, app);
}
@@ -463,7 +518,8 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
type: "open-menu-doctree",
detail: {
elements: selectItemElements,
- type: "notebook"
+ type: "notebook",
+ items: [{id: notebookId, path: "/"}],
},
separatorPosition: "top",
});
@@ -486,7 +542,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
});
liElement.classList.add("b3-list-item--focus");
}
- const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
+ const selectItemElements = fileElement.querySelectorAll<HTMLElement>(".b3-list-item--focus");
if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements, app);
}
@@ -774,7 +830,8 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, l
type: "open-menu-doctree",
detail: {
elements: selectItemElements,
- type: "doc"
+ type: "doc",
+ items: [{id, path: pathString}],
},
separatorPosition: "top",
});
diff --git a/app/src/menus/navigationSelection.test.ts b/app/src/menus/navigationSelection.test.ts
new file mode 100644
index 0000000000..0425764956
--- /dev/null
+++ b/app/src/menus/navigationSelection.test.ts
@@ -0,0 +1,65 @@
+import * as assert from "node:assert/strict";
+import test from "node:test";
+import {getDocTreeDeleteTargets, getDocTreeMenuItems, getDocTreeMenuType} from "./navigationSelection";
+
+const createItem = (type: "navigation-file" | "navigation-root", options: {
+ id?: string,
+ notebookId: string,
+ path: string,
+}) => ({
+ getAttribute(name: string) {
+ if (name === "data-type") {
+ return type;
+ }
+ if (name === "data-node-id") {
+ return options.id || null;
+ }
+ if (name === "data-path") {
+ return options.path;
+ }
+ return null;
+ },
+ closest(selector: string) {
+ if (selector !== "ul[data-url]") {
+ return null;
+ }
+ return {
+ getAttribute(name: string) {
+ return name === "data-url" ? options.notebookId : null;
+ }
+ };
+ },
+}) as unknown as HTMLElement;
+
+const doc1 = createItem("navigation-file", {id: "doc-1", notebookId: "notebook-1", path: "/doc-1.sy"});
+const doc2 = createItem("navigation-file", {id: "doc-2", notebookId: "notebook-1", path: "/doc-2.sy"});
+const notebook1 = createItem("navigation-root", {id: "box-doc-1", notebookId: "notebook-1", path: "/"});
+const notebook2 = createItem("navigation-root", {notebookId: "notebook-2", path: "/"});
+
+test("document tree menu type distinguishes all selection kinds", () => {
+ assert.equal(getDocTreeMenuType([doc1]), "doc");
+ assert.equal(getDocTreeMenuType([doc1, doc2]), "docs");
+ assert.equal(getDocTreeMenuType([notebook1]), "notebook");
+ assert.equal(getDocTreeMenuType([notebook1, notebook2]), "notebooks");
+ assert.equal(getDocTreeMenuType([notebook1, doc1]), "items");
+});
+
+test("document tree menu items contain document and notebook identifiers", () => {
+ assert.deepEqual(getDocTreeMenuItems([doc1, notebook1, notebook2]), [
+ {id: "doc-1", path: "/doc-1.sy"},
+ {id: "notebook-1", path: "/"},
+ {id: "notebook-2", path: "/"},
+ ]);
+});
+
+test("document tree menu items omit incomplete elements", () => {
+ const missingID = createItem("navigation-file", {notebookId: "notebook-1", path: "/missing.sy"});
+ assert.deepEqual(getDocTreeMenuItems([doc1, missingID]), [{id: "doc-1", path: "/doc-1.sy"}]);
+});
+
+test("mixed document tree deletion includes documents and notebooks", () => {
+ assert.deepEqual(getDocTreeDeleteTargets([doc1, notebook1, doc2, notebook2]), {
+ notebookIds: ["notebook-1", "notebook-2"],
+ paths: ["/doc-1.sy", "/doc-2.sy"],
+ });
+});
diff --git a/app/src/menus/navigationSelection.ts b/app/src/menus/navigationSelection.ts
new file mode 100644
index 0000000000..07faf589d4
--- /dev/null
+++ b/app/src/menus/navigationSelection.ts
@@ -0,0 +1,27 @@
+export type TDocTreeMenuType = "doc" | "docs" | "notebook" | "notebooks" | "items";
+
+export const getDocTreeMenuType = (elements: Element[]): TDocTreeMenuType => {
+ const docCount = elements.filter((item) => item.getAttribute("data-type") === "navigation-file").length;
+ const notebookCount = elements.filter((item) => item.getAttribute("data-type") === "navigation-root").length;
+ if (docCount === elements.length) {
+ return docCount === 1 ? "doc" : "docs";
+ }
+ if (notebookCount === elements.length) {
+ return notebookCount === 1 ? "notebook" : "notebooks";
+ }
+ return "items";
+};
+
+export const getDocTreeMenuItems = (elements: Element[]) => elements.map((item) => ({
+ id: item.getAttribute("data-type") === "navigation-root" ?
+ item.closest("ul[data-url]")?.getAttribute("data-url") : item.getAttribute("data-node-id"),
+ path: item.getAttribute("data-path"),
+})).filter((item): item is { id: string, path: string } => Boolean(item.id && item.path));
+
+export const getDocTreeDeleteTargets = (elements: Element[]) => {
+ const items = getDocTreeMenuItems(elements);
+ return {
+ notebookIds: items.filter((item) => item.path === "/").map((item) => item.id),
+ paths: items.filter((item) => item.path !== "/").map((item) => item.path),
+ };
+};