Skip to content

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

:sparkles: Support multiple database automation scopes https://github.com/siyuan-note/siyuan/issues/20997

Danielef233eb7a845
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 85631a85cf..b3c687745b 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "يمكن تحديد ما يصل إلى 32 دفتر ملاحظات أو مستند في نطاق المراقبة",
"pdfAnnotationSaveFailed": "تعذر حفظ تعليقات PDF التوضيحية. أعد فتح ملف PDF لتحميل أحدث التعليقات قبل متابعة التحرير",
"skipExitSync": "تخطي المزامنة والخروج",
"skipExitSyncConfirm": "لم تكتمل المزامنة. هل تريد تخطيها والخروج؟ ستبقى التغييرات غير المتزامنة محفوظة على هذا الجهاز",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 18f5e5e2ba..9ad49d261b 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Der Überwachungsbereich kann höchstens 32 Notizbücher oder Dokumente enthalten",
"pdfAnnotationSaveFailed": "PDF-Anmerkungen konnten nicht gespeichert werden. Öffne die PDF erneut, um vor weiteren Änderungen die aktuellen Anmerkungen zu laden",
"skipExitSync": "Synchronisierung überspringen und beenden",
"skipExitSyncConfirm": "Die Synchronisierung ist noch nicht abgeschlossen. Überspringen und beenden? Nicht synchronisierte Änderungen bleiben auf diesem Gerät gespeichert",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index fe639f1a8b..6e5cc662e4 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "The watch scope can contain up to 32 notebooks or documents",
"pdfAnnotationSaveFailed": "Unable to save PDF annotations. Reopen the PDF to load the latest annotations before editing again",
"skipExitSync": "Skip sync and exit",
"skipExitSyncConfirm": "Synchronization has not finished. Skip it and exit? Unsynced changes will remain saved on this device",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 2975ebfb0f..d39a5a66eb 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "El ámbito de supervisión puede contener hasta 32 cuadernos o documentos",
"pdfAnnotationSaveFailed": "No se pudieron guardar las anotaciones del PDF. Vuelve a abrir el PDF para cargar las anotaciones más recientes antes de seguir editando",
"skipExitSync": "Omitir sincronización y salir",
"skipExitSyncConfirm": "La sincronización no ha terminado. ¿Omitirla y salir? Los cambios sin sincronizar permanecerán guardados en este dispositivo",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 041a1cdd39..765bc62820 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Le périmètre de surveillance peut contenir jusqu’à 32 carnets ou documents",
"pdfAnnotationSaveFailed": "Impossible d’enregistrer les annotations du PDF. Rouvrez le PDF pour charger les dernières annotations avant de poursuivre les modifications",
"skipExitSync": "Ignorer la synchronisation et quitter",
"skipExitSyncConfirm": "La synchronisation n’est pas terminée. L’ignorer et quitter ? Les modifications non synchronisées resteront enregistrées sur cet appareil",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index e4ccf2ce3a..93355bc30e 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "טווח המעקב יכול להכיל עד 32 מחברות או מסמכים",
"pdfAnnotationSaveFailed": "לא ניתן לשמור את הערות ה-PDF. יש לפתוח מחדש את ה-PDF כדי לטעון את ההערות העדכניות לפני המשך העריכה",
"skipExitSync": "דלג על הסנכרון וצא",
"skipExitSyncConfirm": "הסנכרון עדיין לא הושלם. לדלג עליו ולצאת? השינויים שלא סונכרנו יישארו שמורים במכשיר זה",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 9857daf7da..31431690df 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "निगरानी के दायरे में अधिकतम 32 नोटबुक या दस्तावेज़ हो सकते हैं",
"pdfAnnotationSaveFailed": "PDF टिप्पणियाँ सहेजी नहीं जा सकीं। दोबारा संपादन करने से पहले नवीनतम टिप्पणियाँ लोड करने के लिए PDF फिर से खोलें",
"skipExitSync": "सिंक छोड़ें और बाहर निकलें",
"skipExitSyncConfirm": "सिंक अभी पूरा नहीं हुआ है। इसे छोड़कर बाहर निकलें? सिंक न किए गए बदलाव इस डिवाइस पर सहेजे रहेंगे",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index c9beff2a7f..ea70977403 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Cakupan pemantauan dapat memuat hingga 32 buku catatan atau dokumen",
"pdfAnnotationSaveFailed": "Anotasi PDF tidak dapat disimpan. Buka kembali PDF untuk memuat anotasi terbaru sebelum melanjutkan penyuntingan",
"skipExitSync": "Lewati sinkronisasi dan keluar",
"skipExitSyncConfirm": "Sinkronisasi belum selesai. Lewati dan keluar? Perubahan yang belum disinkronkan akan tetap tersimpan di perangkat ini",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index a10e510c28..7e11179d95 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "L’ambito di monitoraggio può contenere fino a 32 taccuini o documenti",
"pdfAnnotationSaveFailed": "Impossibile salvare le annotazioni PDF. Riapri il PDF per caricare le annotazioni più recenti prima di continuare a modificare",
"skipExitSync": "Salta la sincronizzazione ed esci",
"skipExitSyncConfirm": "La sincronizzazione non è terminata. Saltarla e uscire? Le modifiche non sincronizzate rimarranno salvate su questo dispositivo",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 03bcc619b1..821d5664bd 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "監視範囲に含められるノートブックまたはドキュメントは合計32件までです",
"pdfAnnotationSaveFailed": "PDF の注釈を保存できませんでした。編集を続ける前に PDF を開き直して最新の注釈を読み込んでください",
"skipExitSync": "同期をスキップして終了",
"skipExitSyncConfirm": "同期が完了していません。スキップして終了しますか?未同期の変更はこの端末に保存されたままになります",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index fdde26cc31..1293670ba2 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "모니터링 범위에는 노트북 또는 문서를 합계 32개까지 포함할 수 있습니다",
"pdfAnnotationSaveFailed": "PDF 주석을 저장할 수 없습니다. 다시 편집하기 전에 PDF를 다시 열어 최신 주석을 불러오세요",
"skipExitSync": "동기화를 건너뛰고 종료",
"skipExitSyncConfirm": "동기화가 완료되지 않았습니다. 건너뛰고 종료할까요? 동기화되지 않은 변경 사항은 이 기기에 저장된 상태로 유지됩니다",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 9f5076a633..47105bd5ea 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Het bewakingsbereik kan maximaal 32 notitieboeken of documenten bevatten",
"pdfAnnotationSaveFailed": "PDF-annotaties kunnen niet worden opgeslagen. Open de PDF opnieuw om de nieuwste annotaties te laden voordat je verder bewerkt",
"skipExitSync": "Synchronisatie overslaan en afsluiten",
"skipExitSyncConfirm": "De synchronisatie is nog niet voltooid. Overslaan en afsluiten? Niet-gesynchroniseerde wijzigingen blijven op dit apparaat opgeslagen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 3f1978bd07..5ab1e16403 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Zakres monitorowania może zawierać łącznie do 32 notatników lub dokumentów",
"pdfAnnotationSaveFailed": "Nie można zapisać adnotacji PDF. Otwórz ponownie plik PDF, aby wczytać najnowsze adnotacje przed dalszą edycją",
"skipExitSync": "Pomiń synchronizację i wyjdź",
"skipExitSyncConfirm": "Synchronizacja nie została zakończona. Pominąć ją i wyjść? Niezsynchronizowane zmiany pozostaną zapisane na tym urządzeniu",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 9b43c6f42d..e6247debd8 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "O escopo de monitoramento pode conter até 32 cadernos ou documentos",
"pdfAnnotationSaveFailed": "Não foi possível salvar as anotações do PDF. Reabra o PDF para carregar as anotações mais recentes antes de continuar editando",
"skipExitSync": "Ignorar sincronização e sair",
"skipExitSyncConfirm": "A sincronização não terminou. Ignorar e sair? As alterações não sincronizadas permanecerão salvas neste dispositivo",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index a7455c8a31..6eba7ecfd3 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Область отслеживания может содержать не более 32 блокнотов или документов",
"pdfAnnotationSaveFailed": "Не удалось сохранить аннотации PDF. Откройте PDF заново, чтобы загрузить последние аннотации перед дальнейшим редактированием",
"skipExitSync": "Пропустить синхронизацию и выйти",
"skipExitSyncConfirm": "Синхронизация ещё не завершена. Пропустить её и выйти? Несинхронизированные изменения останутся сохранёнными на этом устройстве",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index ac7a399e5f..fbaa91477c 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Rozsah sledovania môže obsahovať najviac 32 zápisníkov alebo dokumentov",
"pdfAnnotationSaveFailed": "Anotácie PDF sa nepodarilo uložiť. Pred ďalšími úpravami znova otvorte PDF a načítajte najnovšie anotácie",
"skipExitSync": "Preskočiť synchronizáciu a skončiť",
"skipExitSyncConfirm": "Synchronizácia sa ešte neskončila. Preskočiť ju a skončiť? Nesynchronizované zmeny zostanú uložené v tomto zariadení",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index f5d0acbda5..4280a334de 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Опсег праћења може да садржи највише 32 бележница или докумената",
"pdfAnnotationSaveFailed": "Није могуће сачувати PDF напомене. Поново отворите PDF да бисте учитали најновије напомене пре даљег уређивања",
"skipExitSync": "Прескочи синхронизацију и изађи",
"skipExitSyncConfirm": "Синхронизација није завршена. Прескочити је и изаћи? Несинхронизоване измене остаће сачуване на овом уређају",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index c9b2eee4d3..77cfb51a00 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "ขอบเขตการติดตามสามารถมีสมุดบันทึกหรือเอกสารรวมกันได้สูงสุด 32 รายการ",
"pdfAnnotationSaveFailed": "ไม่สามารถบันทึกคำอธิบายประกอบ PDF ได้ โปรดเปิด PDF ใหม่เพื่อโหลดคำอธิบายประกอบล่าสุดก่อนแก้ไขต่อ",
"skipExitSync": "ข้ามการซิงค์และออก",
"skipExitSyncConfirm": "การซิงค์ยังไม่เสร็จสิ้น ต้องการข้ามและออกหรือไม่? การเปลี่ยนแปลงที่ยังไม่ได้ซิงค์จะยังคงบันทึกอยู่ในอุปกรณ์นี้",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index 18119f5665..eb4357428c 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "İzleme kapsamı toplamda en fazla 32 not defteri veya belge içerebilir",
"pdfAnnotationSaveFailed": "PDF açıklamaları kaydedilemedi. Düzenlemeye devam etmeden önce en son açıklamaları yüklemek için PDF dosyasını yeniden açın",
"skipExitSync": "Eşitlemeyi atla ve çık",
"skipExitSyncConfirm": "Eşitleme henüz tamamlanmadı. Atlayıp çıkılsın mı? Eşitlenmemiş değişiklikler bu cihazda kayıtlı kalacak",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index ad1b44125a..c951909c03 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "Область відстеження може містити не більше 32 записників або документів",
"pdfAnnotationSaveFailed": "Не вдалося зберегти анотації PDF. Відкрийте PDF знову, щоб завантажити останні анотації перед подальшим редагуванням",
"skipExitSync": "Пропустити синхронізацію та вийти",
"skipExitSyncConfirm": "Синхронізацію ще не завершено. Пропустити її та вийти? Несинхронізовані зміни залишаться збереженими на цьому пристрої",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index d24fe0dc32..97502f6989 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "监听范围最多可包含 32 个笔记本或文档",
"pdfAnnotationSaveFailed": "无法保存 PDF 标注,请重新打开 PDF 加载最新标注后再编辑",
"skipExitSync": "跳过同步并退出",
"skipExitSyncConfirm": "同步尚未完成,是否跳过本次同步并退出?未同步的更改会保留在本机",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index c9da9cc585..3ac5fb5866 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,5 @@
{
+ "automationCollectionScopeLimit": "監聽範圍最多可包含 32 個筆記本或文件",
"pdfAnnotationSaveFailed": "無法儲存 PDF 標註,請重新開啟 PDF 載入最新標註後再編輯",
"skipExitSync": "略過同步並結束",
"skipExitSyncConfirm": "同步尚未完成,是否略過本次同步並結束?未同步的變更會保留在本機",
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy
index d96f341348..4621ae4819 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20240208172514-9dsv6na.sy
@@ -7,7 +7,7 @@
"id": "20240208172514-9dsv6na",
"title": "Database",
"type": "doc",
- "updated": "20261026103001"
+ "updated": "20261027120633"
},
"Children": [
{
@@ -4985,12 +4985,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261015141042-nrq3k5z",
- "updated": "20261024161816"
+ "updated": "20261027120633"
},
"Children": [
{
"Type": "NodeText",
- "Data": "Choose the Block matches conditions trigger, then use the add button under Watch scope to select notebooks or documents. Click a document title to preview it in a floating window while keeping automation settings open; its icon also supports hover preview. Notebook and document scopes are combined."
+ "Data": "Choose the Block matches conditions trigger, then use the add button under Watch scope to select notebooks or documents. In the picker, check multiple notebooks or documents and confirm to add them together. Selections are retained while searching or expanding the tree. Duplicate selections are ignored; each rule can contain up to 32 notebooks or documents in total. Click a document title to preview it in a floating window while keeping automation settings open; its icon also supports hover preview. Notebook and document scopes are combined."
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy
index 0d09fbf7fd..2a63b8e0a3 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20240208113259-nykkvaq.sy
@@ -7,7 +7,7 @@
"id": "20240208113259-nykkvaq",
"title": "数据库",
"type": "doc",
- "updated": "20261026103001"
+ "updated": "20261027120633"
},
"Children": [
{
@@ -4873,12 +4873,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261015141042-ux38r6d",
- "updated": "20261024164212"
+ "updated": "20261027120633"
},
"Children": [
{
"Type": "NodeText",
- "Data": "选择「普通块符合条件」触发器,通过「监听范围」下的添加按钮选择笔记本或文档,范围取并集。点击文档标题可在浮窗中预览,保留自动化设置;也可将鼠标悬停在图标上预览。块类型、标签和自定义属性分别使用 Chip 分组,通过各组的添加按钮配置,点击 Chip 的关闭图标移除。"
+ "Data": "选择「普通块符合条件」触发器,通过「监听范围」下的添加按钮选择笔记本或文档,范围取并集。在选择窗口中勾选多个笔记本或文档后确认,即可一次添加;搜索和展开目录时会保留已勾选项。重复范围会自动去重,每条规则最多可包含 32 个笔记本或文档。点击文档标题可在浮窗中预览,保留自动化设置;也可将鼠标悬停在图标上预览。块类型、标签和自定义属性分别使用 Chip 分组,通过各组的添加按钮配置,点击 Chip 的关闭图标移除。"
}
]
},
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy
index b100b50064..47099eb3dd 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20240208171522-y7dxcno.sy
@@ -7,7 +7,7 @@
"id": "20240208171522-y7dxcno",
"title": "資料庫",
"type": "doc",
- "updated": "20261026103001"
+ "updated": "20261027120633"
},
"Children": [
{
@@ -4873,12 +4873,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261015141042-155k3zl",
- "updated": "20261024164212"
+ "updated": "20261027120633"
},
"Children": [
{
"Type": "NodeText",
- "Data": "選擇「普通區塊符合條件」觸發器,透過「監聽範圍」下的新增按鈕選擇筆記本或文件,範圍取聯集。點擊文件標題可在浮動視窗中預覽,保留自動化設定;也可將滑鼠移到圖示上預覽。區塊類型、標籤和自訂屬性分別使用 Chip 分組,透過各組的新增按鈕設定,點擊 Chip 的關閉圖示移除。"
+ "Data": "選擇「普通區塊符合條件」觸發器,透過「監聽範圍」下的新增按鈕選擇筆記本或文件,範圍取聯集。在選擇視窗中勾選多個筆記本或文件後確認,即可一次新增;搜尋和展開目錄時會保留已勾選項目。重複範圍會自動去重,每條規則最多可包含 32 個筆記本或文件。點擊文件標題可在浮動視窗中預覽,保留自動化設定;也可將滑鼠移到圖示上預覽。區塊類型、標籤和自訂屬性分別使用 Chip 分組,透過各組的新增按鈕設定,點擊 Chip 的關閉圖示移除。"
}
]
},
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy
index 719b8e7ed6..6921f10e86 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20240530101000-3eaevtp.sy
@@ -8,7 +8,7 @@
"id": "20240530101000-3eaevtp",
"title": "データベース",
"type": "doc",
- "updated": "20261026103001"
+ "updated": "20261027120633"
},
"Children": [
{
@@ -4995,12 +4995,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20261015141042-qt2jps9",
- "updated": "20261024161816"
+ "updated": "20261027120633"
},
"Children": [
{
"Type": "NodeText",
- "Data": "「通常ブロックが条件に一致」トリガーを選び、「監視範囲」の下にある追加ボタンでノートブックや文書を指定します。文書名を押すと、自動化設定を開いたままフローティングウィンドウでプレビューできます。アイコンへのマウスオーバーでもプレビューできます。範囲は和集合です。ブロック種類・タグ・カスタム属性はそれぞれ Chip で管理し、各組の追加ボタンで条件を加え、閉じるボタンで削除します。"
+ "Data": "「通常ブロックが条件に一致」トリガーを選び、「監視範囲」の下にある追加ボタンでノートブックや文書を指定します。選択画面で複数のノートブックや文書にチェックを入れて確定すると、まとめて追加できます。検索やツリーの展開中も選択は保持されます。重複する範囲は除外され、各ルールに含められるノートブックや文書は合計32件までです。文書名を押すと、自動化設定を開いたままフローティングウィンドウでプレビューできます。アイコンへのマウスオーバーでもプレビューできます。範囲は和集合です。ブロック種類・タグ・カスタム属性はそれぞれ Chip で管理し、各組の追加ボタンで条件を加え、閉じるボタンで削除します。"
}
]
},
diff --git a/app/src/protyle/render/av/blockCollection.test.ts b/app/src/protyle/render/av/blockCollection.test.ts
index 794dea31ba..f2ec92a333 100644
--- a/app/src/protyle/render/av/blockCollection.test.ts
+++ b/app/src/protyle/render/av/blockCollection.test.ts
@@ -39,13 +39,21 @@ const browserCases = async (sourceCode: string, languages: Record<string, string
const menu = document.createElement("div");
document.body.append(menu);
let addScope: (paths: string[], boxes: string[]) => void;
+ let validateScope: (paths: string[], boxes: string[]) => boolean;
+ const messages: string[] = [];
Object.assign(window, {siyuan: {languages, notebooks: [{id: "box", name: "Notebook"}]}});
new Function("exports", "require", sourceCode)(api, (name: string) => ({
"../../../util/escape": {escapeAttr: String, escapeHtml: String},
"../../../util/fetch": {fetchSyncPost: async () => ({code: 0, data: "/Selected document"})},
"./collectionConditions": {mountCollectionConditions() {}},
"./collectionReference": {mountCollectionReference() {}},
- "../../../util/pathName": {movePathTo: (options: {cb: typeof addScope}) => { addScope = options.cb; }},
+ "../../../util/pathName": {movePathTo: (options: {cb: typeof addScope, validate: typeof validateScope, multiple: boolean, sourceNotebookIds: string[]}) => {
+ check.equal(options.multiple, true);
+ check.deepEqual(options.sourceNotebookIds, ["box"]);
+ addScope = options.cb;
+ validateScope = options.validate;
+ }},
+ "../../../dialog/message": {showMessage: (message: string) => messages.push(message)},
"../../../menus/menuToggle": {toggleMenu: (options: {build: () => void, show: () => void}) => { options.build(); options.show(); }},
"../../../plugin/Menu": {Menu: class {
constructor() { menu.replaceChildren(); }
@@ -129,6 +137,24 @@ const browserCases = async (sourceCode: string, languages: Record<string, string
host.querySelector<HTMLInputElement>("[data-include-selected-documents]").click();
check.equal(source.includeSelectedDocuments, undefined);
check.equal(saves.at(-1).includeSelectedDocuments, undefined);
+ const beforeBatch = saves.length;
+ const paths = ["/", "/", "/doc.sy", "/new.sy", "/new.sy"];
+ const boxes = ["box", "other-box", "box", "box", "box"];
+ check.equal(validateScope(paths, boxes), true);
+ addScope(paths, boxes);
+ await tick();
+ check.equal(saves.length, beforeBatch + 1, "batch selection must save only once");
+ check.deepEqual(source.notebookIDs, ["box", "other-box"]);
+ check.deepEqual(source.documentIDs, ["doc", "new"]);
+ source.documentIDs.push(...Array.from({length: 28}, (_, i) => `doc-${i}`));
+ check.equal(validateScope(["/doc.sy"], ["box"]), true, "existing scope at the limit must remain selectable");
+ const snapshot = JSON.stringify(source);
+ check.equal(validateScope(["/overflow.sy"], ["box"]), false);
+ check.equal(messages.at(-1), languages.automationCollectionScopeLimit);
+ check.equal(JSON.stringify(source), snapshot, "failed validation must preserve the rule");
+ source.documentIDs.push("legacy");
+ check.equal(validateScope(["/doc.sy"], ["box"]), true, "legacy rules must accept an unchanged scope");
+ check.equal(validateScope(["/overflow.sy"], ["box"]), false, "legacy rules must not expand past the limit");
host.remove();
}
menu.remove();
diff --git a/app/src/protyle/render/av/blockCollection.ts b/app/src/protyle/render/av/blockCollection.ts
index 4ea87a7a2c..7ca7b9190d 100644
--- a/app/src/protyle/render/av/blockCollection.ts
+++ b/app/src/protyle/render/av/blockCollection.ts
@@ -7,6 +7,7 @@ import {BlockPanel} from "../../../block/Panel";
import {Menu} from "../../../plugin/Menu";
import {toggleMenu} from "../../../menus/menuToggle";
import {mountCollectionReference} from "./collectionReference";
+import {showMessage} from "../../../dialog/message";
export const collectionSourceIncomplete = (source: AVAutomationBlockSourceInput) => !source ||
!(source.notebookIDs?.length || source.documentIDs?.length) ||
@@ -84,7 +85,19 @@ ${documents.length ? `<div class="av__automation-control"><label class="av__auto
return;
}
if (target.hasAttribute("data-scope")) {
- movePathTo({title: lang.automationCollectionScope, flashcard: false, sourceNotebookIds: [protyle.notebookId],
+ movePathTo({title: lang.automationCollectionScope, flashcard: false, sourceNotebookIds: [protyle.notebookId], multiple: true,
+ validate: (paths, boxes) => {
+ const notebooks = new Set(source.notebookIDs || []);
+ const documents = new Set(source.documentIDs || []);
+ const previousSize = notebooks.size + documents.size;
+ paths.forEach((path, i) => {
+ if (path === "/") { notebooks.add(boxes[i]); }
+ else { documents.add(path.split("/").pop().replace(/\.sy$/, "")); }
+ });
+ if (notebooks.size + documents.size <= 32 || notebooks.size + documents.size === previousSize) { return true; }
+ showMessage(lang.automationCollectionScopeLimit);
+ return false;
+ },
cb: (paths, boxes) => {
paths.forEach((path, i) => {
if (path === "/") {
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index 2227ab94fb..f9a29b11ed 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -8621,6 +8621,7 @@ export interface APIPOSTRoutes {
* 类型和属性始终筛选最终对象;默认首个内容块优先归属合格列表项,每次标签命中只选择一个对象。
* 无标签时收集对象不影响筛选;变更收集对象不转换已有条目,预览与实际收集使用相同规则。
* 自动收集只添加条目,原文失配及规则变更均保留已有条目和字段,再次匹配不会重新初始化。
+ * setAttrViewAutomations 新增范围最多包含 32 个去重后的笔记本或文档;既有超限规则可保留或删减,撤销重做不截断原范围。
* cleanupAttrViewBlocks 按全部启用收集规则复查已确认条目及绑定,仅移出明确失配条目,并支持撤销。
* 规则的 notifyOnSuccess 缺省或 null 为开启,仅实际变更且事务成功提交后通知,同一事务合并;错误提示不受其控制。
* 手动收集及清理、无变化、撤销重放和失败回滚不发送成功通知。
diff --git a/app/src/util/pathName.selection.test.ts b/app/src/util/pathName.selection.test.ts
new file mode 100644
index 0000000000..8c8c70e20f
--- /dev/null
+++ b/app/src/util/pathName.selection.test.ts
@@ -0,0 +1,176 @@
+import * as assert from "node:assert/strict";
+import {execFile} from "node:child_process";
+import {mkdtempSync, readFileSync, rmSync, writeFileSync} from "node:fs";
+import {tmpdir} from "node:os";
+import * as path from "node:path";
+import {test} from "node:test";
+import {promisify} from "node:util";
+import {ModuleKind, ScriptTarget, transpileModule} from "typescript";
+
+const browserCases = async (sourceCode: string) => {
+ const check: typeof assert = require("node:assert/strict");
+ const api = {} as typeof import("./pathName");
+ let mobile = false;
+ let listRequests = 0;
+ const notebooks = [
+ {id: "a", name: "Notebook A"}, {id: "b", name: "Notebook B"},
+ {id: "secret", name: "Encrypted", encrypted: true}, {id: "closed", name: "Closed", closed: true},
+ ];
+ const file = (name: string, notebook = "a") => ({name, path: `/${name}.sy`, box: notebook, hPath: `/${name}`, subFileCount: 0});
+ Object.assign(window, {siyuan: {notebooks, config: {search: {}}, storage: {move: {k: "", keys: []}}, dialogs: [],
+ languages: {confirm: "Confirm", cancel: "Cancel", specifyPath: "Specify path", searchPlaceholder: "Search"},
+ menus: {menu: {element: document.createElement("div")}}}});
+ new Function("exports", "require", sourceCode)(api, (name: string) => ({
+ "../dialog": {Dialog: class {
+ element = document.createElement("div");
+ constructor(options: {title: string, content: string}) {
+ this.element.innerHTML = `<div class="b3-dialog__header">${options.title}</div>${options.content}`;
+ document.body.append(this.element);
+ window.siyuan.dialogs.push(this as any);
+ }
+ destroy() {
+ this.element.remove();
+ window.siyuan.dialogs.splice(window.siyuan.dialogs.indexOf(this as any), 1);
+ }
+ }},
+ "./fetch": {fetchPost: (url: string, data: any, cb: (response: any) => void) => {
+ if (url.endsWith("lsNotebooks")) { cb({data: {notebooks}}); }
+ else if (url.endsWith("listDocsByPath")) {
+ listRequests++;
+ cb({data: {files: [file("parent"), file("other")]}});
+ } else if (url.endsWith("searchDocs")) {
+ queueMicrotask(() => cb({data: data.k === "none" ? [] :
+ data.k === "b" ? [file("beta", "b")] : [file("parent"), file("hidden", "secret")]}));
+ } else { check.fail(url); }
+ }},
+ "./functions": {isMobile: () => mobile},
+ "./escape": {escapeHtml: (text: string) => text, escapeHtmlTextAndAttr: (text: string) => text, escapeAriaLabel: (text: string) => text},
+ "../constants": {Constants: {LOCAL_MOVE_PATH: "move"}},
+ "../emoji/fileTreeIcon": {getFileTreeDefaultIconAttr: () => "", getFileTreeIconHTML: () => ""},
+ "../protyle/util/compatibility": {updateHotkeyTip: (text: string) => text, setStorageVal() {}, isOnlyMeta: (event: MouseEvent) => event.ctrlKey},
+ "../protyle/util/hotKey": {matchHotKey: () => false},
+ "./fileTreeTooltip": {genFileTreeDocAriaLabel: () => "Document"},
+ "./searchHighlight": {highlightSearchText: (text: string) => text},
+ "./addClearButton": {addClearButton() {}},
+ "../layout/dock/fileTreeAnimation": {expandFileTree() {}},
+ })[name] || {});
+ const tick = () => new Promise(resolve => setTimeout(resolve, 0));
+ for (mobile of [false, true]) {
+ let result: {paths: string[], boxes: string[]};
+ let valid = false;
+ api.movePathTo({title: "Watch scope", flashcard: false, multiple: true, sourceNotebookIds: ["a"],
+ validate: () => valid, cb: (paths, boxes) => { result = {paths, boxes}; }});
+ const dialog = document.body.lastElementChild as HTMLElement;
+ const tree = dialog.querySelector<HTMLElement>("#foldTree");
+ const list = dialog.querySelector<HTMLElement>("#foldList");
+ const input = dialog.querySelector<HTMLInputElement>(".b3-text-field");
+ const confirm = dialog.querySelector<HTMLButtonElement>(".b3-button--text");
+ const row = (root: HTMLElement, notebook: string, path = "/") => root.querySelector<HTMLElement>(`[data-box="${notebook}"][data-path="${path}"]`);
+ const checkbox = (element: HTMLElement) => element.querySelector<HTMLInputElement>("[data-path-select]");
+ const search = async (value: string) => {
+ input.value = value;
+ input.dispatchEvent(new Event("input", {bubbles: true}));
+ await tick();
+ };
+ check.equal(tree.querySelectorAll("[data-path-select]").length, 2);
+ check.equal(confirm.disabled, true);
+ check.equal(confirm.textContent, "Confirm (0)");
+ const before = listRequests;
+ row(tree, "a").querySelector<HTMLElement>(".b3-list-item__text").click();
+ check.equal(listRequests, before, "selecting a notebook must not expand it");
+ check.equal(checkbox(row(tree, "a")).checked, true);
+ row(tree, "a").querySelector<HTMLElement>(".b3-list-item__toggle").click();
+ check.equal(listRequests, before + 1);
+ row(tree, "a", "/parent.sy").click();
+ check.equal(confirm.textContent, "Confirm (2)");
+ row(tree, "a").querySelector<HTMLElement>(".b3-list-item__toggle").click();
+ row(tree, "a").querySelector<HTMLElement>(".b3-list-item__toggle").click();
+ check.equal(checkbox(row(tree, "a", "/parent.sy")).checked, true);
+ await search("parent");
+ check.equal(list.querySelectorAll("[data-path-select]").length, 1, "encrypted search results must be excluded");
+ check.equal(checkbox(row(list, "a", "/parent.sy")).checked, true);
+ checkbox(row(list, "a", "/parent.sy")).click();
+ check.equal(confirm.textContent, "Confirm (1)");
+ check.equal(checkbox(row(tree, "a", "/parent.sy")).checked, false);
+ checkbox(row(list, "a", "/parent.sy")).click();
+ await search("b");
+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "ArrowDown", bubbles: true}));
+ check.equal(confirm.textContent, "Confirm (2)", "navigation must preserve checked items");
+ row(list, "b", "/beta.sy").click();
+ check.equal(confirm.textContent, "Confirm (3)");
+ confirm.click();
+ check.equal(result, undefined, "failed validation must retain the dialog and selection");
+ check.equal(dialog.isConnected, true);
+ await search("none");
+ valid = true;
+ input.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter", bubbles: true}));
+ check.deepEqual(result, {paths: ["/", "/parent.sy", "/beta.sy"], boxes: ["a", "a", "b"]});
+ check.equal(dialog.isConnected, false);
+
+ api.movePathTo({title: "Watch scope", flashcard: false, multiple: true, sourceNotebookIds: ["a"],
+ cb: () => check.fail("cancel submitted selected paths")});
+ const cancelled = document.body.lastElementChild as HTMLElement;
+ cancelled.querySelector<HTMLInputElement>("[data-path-select]").click();
+ cancelled.querySelector<HTMLButtonElement>(".b3-button--cancel").click();
+ check.equal(cancelled.isConnected, false);
+
+ let single: string[];
+ api.movePathTo({flashcard: false, sourceNotebookIds: ["a"], cb: paths => { single = paths; }});
+ const normal = document.body.lastElementChild as HTMLElement;
+ check.equal(normal.querySelector("[data-path-select]"), null);
+ normal.querySelector<HTMLElement>('[data-box="b"]').click();
+ normal.querySelector<HTMLButtonElement>(".b3-button--text").click();
+ check.deepEqual(single, ["/"]);
+
+ let legacy: string[];
+ api.movePathTo({title: "Specify path", flashcard: false, sourceNotebookIds: ["a"], cb: (_paths, boxes) => { legacy = boxes; }});
+ const specified = document.body.lastElementChild as HTMLElement;
+ specified.querySelector('[data-box="b"]').dispatchEvent(new MouseEvent("click", {bubbles: true, ctrlKey: true}));
+ specified.querySelector<HTMLButtonElement>(".b3-button--text").click();
+ check.deepEqual(legacy, ["a", "b"]);
+
+ api.movePathTo({flashcard: false, multiple: true, sourceNotebookIds: ["secret"], cb() {}});
+ const encrypted = document.body.lastElementChild as HTMLElement;
+ check.equal(encrypted.querySelectorAll("[data-path-select]").length, 1);
+ check.equal(encrypted.querySelector<HTMLElement>("[data-box]").dataset.box, "secret");
+ encrypted.querySelector<HTMLButtonElement>(".b3-button--cancel").click();
+ window.siyuan.storage.move.k = "";
+ }
+ return "Path selection DOM cases passed";
+};
+
+test("path picker preserves multiple selections across tree and search on desktop and mobile and retains single selection callers", {
+ skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,
+ timeout: 45000,
+}, async () => {
+ const source = transpileModule(readFileSync("src/util/pathName.ts", "utf8"), {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2022},
+ }).outputText;
+ const temporary = mkdtempSync(path.join(tmpdir(), "siyuan-path-selection-"));
+ const script = path.join(temporary, "run.cjs");
+ const cases = transpileModule(`const browserCases = ${browserCases.toString()};`, {
+ compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2022},
+ }).outputText;
+ writeFileSync(script, `const {app, BrowserWindow} = require("electron");
+app.setPath("userData", ${JSON.stringify(path.join(temporary, "profile"))});
+app.commandLine.appendSwitch("disable-gpu");
+app.whenReady().then(async () => {
+ const win = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true, contextIsolation: false}});
+ win.webContents.on("console-message", event => console.error(event.message));
+ try {
+ await win.loadURL("about:blank");
+ console.log(await win.webContents.executeJavaScript(${JSON.stringify(`const __name = value => value; ${cases}\nbrowserCases(${JSON.stringify(source)})`)}));
+ win.destroy(); app.exit(0);
+ } catch (error) { console.error(error); win.destroy(); app.exit(1); }
+});`, "utf8");
+ const env = {...process.env};
+ delete env.ELECTRON_RUN_AS_NODE;
+ try {
+ const {stdout} = await promisify(execFile)(require("electron") as unknown as string, [script], {env, timeout: 40000, windowsHide: true});
+ assert.match(stdout, /Path selection DOM cases passed/);
+ } finally {
+ assert.equal(path.dirname(path.resolve(temporary)), path.resolve(tmpdir()));
+ assert.ok(path.basename(temporary).startsWith("siyuan-path-selection-"));
+ rmSync(temporary, {recursive: true, force: true});
+ }
+});
diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.ts
index 1cb0e1f8f0..ea56f1fed2 100644
--- a/app/src/util/pathName.ts
+++ b/app/src/util/pathName.ts
@@ -268,6 +268,7 @@ export const movePathTo = (options: {
flashcard: boolean
rootIDs?: string[],
sourceNotebookIds?: string[],
+ multiple?: boolean,
}) => {
const exitDialog = window.siyuan.dialogs.find((item) => {
if (item.element.querySelector("#foldList")) {
@@ -316,6 +317,52 @@ export const movePathTo = (options: {
}
const searchListElement = dialog.element.querySelector("#foldList");
const searchTreeElement = dialog.element.querySelector("#foldTree");
+ const confirmElement = dialog.element.querySelector<HTMLButtonElement>(".b3-button--text");
+ const selected = new Map<string, {path: string, notebook: string}>();
+ const selectionKey = (row: HTMLElement) => `${row.dataset.box}:${row.dataset.path}`;
+ const renderSelection = (root: Element) => {
+ if (!options.multiple) { return; }
+ root.querySelectorAll<HTMLElement>(".b3-list-item").forEach(row => {
+ let checkbox = row.querySelector<HTMLInputElement>("[data-path-select]");
+ if (!checkbox) {
+ checkbox = document.createElement("input");
+ checkbox.type = "checkbox";
+ checkbox.className = "b3-switch fn__flex-center";
+ checkbox.setAttribute("data-path-select", "true");
+ checkbox.setAttribute("aria-label", row.querySelector(".b3-list-item__text, .b3-list-item__showall").textContent);
+ row.append(checkbox);
+ checkbox.addEventListener("click", event => event.stopPropagation());
+ checkbox.addEventListener("change", () => {
+ const key = selectionKey(row);
+ if (checkbox.checked) {
+ selected.set(key, {path: row.dataset.path, notebook: row.dataset.box});
+ } else {
+ selected.delete(key);
+ }
+ renderSelection(searchTreeElement);
+ renderSelection(searchListElement);
+ });
+ }
+ checkbox.checked = selected.has(selectionKey(row));
+ });
+ confirmElement.textContent = `${window.siyuan.languages.confirm} (${selected.size})`;
+ confirmElement.disabled = selected.size === 0;
+ };
+ const expand = (row: HTMLElement) => getLeaf(row, options.flashcard, renderSelection);
+ const submit = () => {
+ const currentPanelElement = searchListElement.classList.contains("fn__none") ? searchTreeElement : searchListElement;
+ const items = options.multiple ? Array.from(selected.values()) :
+ Array.from(currentPanelElement.querySelectorAll<HTMLElement>(".b3-list-item--focus"))
+ .map(row => ({path: row.dataset.path, notebook: row.dataset.box}));
+ if (!items.length) { return; }
+ const paths = items.map(item => item.path);
+ const notebooks = items.map(item => item.notebook);
+ if (!options.validate || options.validate(paths, notebooks)) {
+ options.cb(paths, notebooks);
+ dialog.destroy();
+ }
+ };
+ renderSelection(searchTreeElement);
setNoteBook((notebooks) => {
let html = "";
notebooks.forEach((item) => {
@@ -338,6 +385,7 @@ export const movePathTo = (options: {
}
});
searchTreeElement.innerHTML = html;
+ renderSelection(searchTreeElement);
}, options.flashcard);
const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
@@ -404,6 +452,7 @@ export const movePathTo = (options: {
</li>`;
});
searchListElement.innerHTML = fileHTML;
+ renderSelection(searchListElement);
});
};
@@ -525,6 +574,11 @@ export const movePathTo = (options: {
if (window.siyuan.menus.menu.element.getAttribute("data-name") === Constants.MENU_MOVE_PATH_HISTORY) {
return;
}
+ if (event.key === "Enter") {
+ submit();
+ event.preventDefault();
+ return;
+ }
const currentPanelElement = searchListElement.classList.contains("fn__none") ? searchTreeElement : searchListElement;
const currentItemElements = currentPanelElement.querySelectorAll(".b3-list-item--focus");
if (currentItemElements.length === 0) {
@@ -541,7 +595,7 @@ export const movePathTo = (options: {
if (searchListElement.classList.contains("fn__none")) {
if ((event.key === "ArrowRight" && !currentItemElement.querySelector(".b3-list-item__arrow--open") && !currentItemElement.querySelector(".b3-list-item__toggle").classList.contains("fn__hidden")) ||
(event.key === "ArrowLeft" && currentItemElement.querySelector(".b3-list-item__arrow--open"))) {
- getLeaf(currentItemElement, options.flashcard);
+ expand(currentItemElement);
event.preventDefault();
return;
}
@@ -663,29 +717,12 @@ export const movePathTo = (options: {
return;
}
}
- if (event.key === "Enter") {
- const currentItemElements = currentPanelElement.querySelectorAll(".b3-list-item--focus");
- if (currentItemElements.length === 0) {
- return;
- }
- const pathList: string[] = [];
- const notebookIdList: string[] = [];
- currentItemElements.forEach(item => {
- pathList.push(item.getAttribute("data-path"));
- notebookIdList.push(item.getAttribute("data-box"));
- });
- if (!options.validate || options.validate(pathList, notebookIdList)) {
- options.cb(pathList, notebookIdList);
- dialog.destroy();
- }
- event.preventDefault();
- }
});
dialog.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(dialog.element)) {
if (target.classList.contains("b3-list-item__toggle")) {
- getLeaf(target.parentElement, options.flashcard);
+ expand(target.parentElement);
event.preventDefault();
event.stopPropagation();
break;
@@ -695,21 +732,7 @@ export const movePathTo = (options: {
event.stopPropagation();
break;
} else if (target.classList.contains("b3-button--text")) {
- const currentPanelElement = searchListElement.classList.contains("fn__none") ? searchTreeElement : searchListElement;
- const currentItemElements = currentPanelElement.querySelectorAll(".b3-list-item--focus");
- if (currentItemElements.length === 0) {
- return;
- }
- const pathList: string[] = [];
- const notebookIdList: string[] = [];
- currentItemElements.forEach(item => {
- pathList.push(item.getAttribute("data-path"));
- notebookIdList.push(item.getAttribute("data-box"));
- });
- if (!options.validate || options.validate(pathList, notebookIdList)) {
- options.cb(pathList, notebookIdList);
- dialog.destroy();
- }
+ submit();
event.preventDefault();
event.stopPropagation();
break;
@@ -719,6 +742,14 @@ export const movePathTo = (options: {
event.stopPropagation();
break;
} else if (target.classList.contains("b3-list-item")) {
+ if (options.multiple) {
+ dialog.element.querySelectorAll(".b3-list-item--focus").forEach(item => item.classList.remove("b3-list-item--focus"));
+ target.classList.add("b3-list-item--focus");
+ target.querySelector<HTMLInputElement>("[data-path-select]").click();
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ }
const currentPanelElement = searchListElement.classList.contains("fn__none") ? searchTreeElement : searchListElement;
const currentItemElements = currentPanelElement.querySelectorAll(".b3-list-item--focus");
if (currentItemElements.length === 0) {
@@ -735,7 +766,7 @@ export const movePathTo = (options: {
target.classList.add("b3-list-item--focus");
}
if (target.getAttribute("data-path") === "/") {
- getLeaf(target, options.flashcard);
+ expand(target);
}
event.preventDefault();
event.stopPropagation();
@@ -749,7 +780,7 @@ export const movePathTo = (options: {
});
};
-const getLeaf = (liElement: HTMLElement, flashcard: boolean) => {
+const getLeaf = (liElement: HTMLElement, flashcard: boolean, onRender?: (root: Element) => void) => {
const toggleElement = liElement.querySelector(".b3-list-item__arrow");
if (toggleElement.classList.contains("b3-list-item__arrow--open")) {
toggleElement.classList.remove("b3-list-item__arrow--open");
@@ -804,6 +835,7 @@ const getLeaf = (liElement: HTMLElement, flashcard: boolean) => {
}
toggleElement.classList.add("b3-list-item__arrow--open");
liElement.insertAdjacentHTML("afterend", `<ul>${fileHTML}</ul>`);
+ onRender?.(liElement.nextElementSibling);
expandFileTree(liElement.nextElementSibling as HTMLElement);
});
};
diff --git a/docs/API.ja.md b/docs/API.ja.md
index c794c5007a..cadf0f1e68 100644
--- a/docs/API.ja.md
+++ b/docs/API.ja.md
@@ -2240,7 +2240,7 @@ if (response.code === 0 && response.data) {
* `data.av`: 完全な `AttributeView` 定義——フィールド(`keyValues`)、フィールド順序(`keyIDs`、`null` の場合あり)、および全ビューの生のレイアウト設定(`table`/`gallery`/`kanban`)とアイテム順序(`itemIds`)。互換性フィールド `viewID` は最初に利用可能なビューから算出され、永続化されません。レンダリング後の行やページングは含まれないため、計算後の行データが必要な場合は [レンダリング](#レンダリング) を使用してください
- * `data.av.automations` は省略可能で、データベース全体のルール(`spec: 1`~`8`)を保持します。`block` トリガーの `blockSource` はノートブック/文書の範囲、ブロックの種類、タグ、カスタム属性を指定し、`collect` アクションは一致する元のブロックを現在のデータベースにバインドします。主種類はすべてのサブタイプを含みます。形式 3 は `h:h1`~`h:h6`、`l:u/o/t`、`i:u/o/t`、`callout:TYPE`(大文字小文字を区別し、独自種類も指定可能)をサポートします。種類の未選択は制限なし、複数選択は OR です。自動作成された主キー値には、カーネルが管理する `block.collectionRuleID` が含まれる場合があります。自動収集は追加だけを行います。原文やルールの条件・範囲・対象・有効状態が変わっても既存の項目とフィールドを保持し、再び一致しても同じ項目を使います。明示的な整理ではすべての有効な収集ルールを使い、手動・自動でバインドした項目を同じ基準で確認します。一致する項目や判定できない項目は保持し、実行前の再確認で不一致が確定した項目だけを除去します。元に戻す操作で元の項目と全フィールドを復元します。 `blockSource.tagMatch` と `attributeMatch` は既定で `and`、形式 3 では各組を個別に `or` にできます。組の間は AND のままで、空の組は制限しません。 各ルールの省略可能な `notifyOnSuccess` は既定(`null` を含む)で `true` です。実際の変更をトランザクション確定後に一つの通知にまとめます。無効にしてもエラーは通知します。変更なし・明示的な収集・元に戻す・やり直し・ロールバックでは成功通知を送信しません。 形式 4 では省略可能な `blockSource.tagTarget` を追加しています。省略・空文字列は既定の選択で、最初の内容ブロックより条件に合うリスト項目を優先、`block` はタグを含むブロック、`container` は種類と属性の条件に一致する最も近いコンテナを収集し、ブロック ID で重複を除きます。文書には明示的な `d` の選択が必要です。AND のタグは同じ元ブロックに必要で、タグ条件がなければこの設定は影響しません。プレビューと実際の収集対象は一致し、切り替えても既存項目とフィールドは維持されます。 形式 5 では省略可能な `blockSource.documentDepth` を追加しています。省略または `null` は無制限、`0` は選択した各文書自体のみ、`1` は直接の子文書も含み、他の非負整数は相対的な最大階層数を指定します。文書の範囲すべてに共通し、ノートブックの範囲は制限せず、範囲は和集合のままです。深さを変更しても既存の項目とフィールドを保持し、既存の内容を自動で追加収集しません。 形式 6 は各属性条件に省略可能な `nameOperator` を追加します。省略・空文字列・`equals` は完全な名前との一致を維持し、`contains` は `custom-` 接頭辞の入力を必要としない文字列の部分一致、`regex` は接頭辞を含む完全な名前に対する Go の正規表現です。カスタム属性だけを照合し、名前と値は大文字小文字を区別して同じ属性で満たす必要があります。`exists` は名前の一致が一つ以上、`notExists` は一致がないことを要求し、値は無視します。名前パターンは最大 256 バイトで、不正な式は保存を拒否します。既存の形式 1–5 の動作は維持し、古いリーダーはデータベースを書き換えずに形式 6 を拒否します。 形式 7 は省略可能な `blockSource.includeSelectedDocuments` を追加します。省略・`null`・`true` は選択した各文書自体を含み、`false` はその文書と内部のすべてのブロックを除外し、子孫文書には引き続き `documentDepth` を適用します。この設定は文書範囲に共通で、ノートブックの範囲や重なる別の文書範囲には影響せず、範囲は和集合のままです。`false` と深さ `0` の組み合わせでは、対応する文書範囲は空です。変更しても既存の項目とフィールドを保持し、自動で追加収集や除去を行いません。形式 1–6 は引き続き読み取れ、古いリーダーはデータベースを書き換えずに形式 7 を拒否します。 形式 8 は省略可能な `blockSource.referenceID` を追加します。本文中でこのブロックを参照するブロック参照を照合し、文書を指定した場合は内部のコンテンツブロックも含みますが、子文書は含みません。埋め込み、通常のリンク、データベースのリッチテキストフィールド内の参照は対象外です。タグは同じ参照元を判定し、バックリンクの親ブロック規則でまとめた後に種類と属性を判定します。`tagTarget` は使用しません。参照先は同じ暗号化境界内に限られます。参照の削除や参照先の変更でも既存の項目とフィールドを保持し、以前の内容はプレビューして明示的に収集します。形式 1–7 は引き続き読み取れ、古いクライアントはデータベースを書き換えずに形式 8 を拒否します。
+ * `data.av.automations` は省略可能で、データベース全体のルール(`spec: 1`~`8`)を保持します。`block` トリガーの `blockSource` はノートブック/文書の範囲、ブロックの種類、タグ、カスタム属性を指定し、`collect` アクションは一致する元のブロックを現在のデータベースにバインドします。主種類はすべてのサブタイプを含みます。形式 3 は `h:h1`~`h:h6`、`l:u/o/t`、`i:u/o/t`、`callout:TYPE`(大文字小文字を区別し、独自種類も指定可能)をサポートします。種類の未選択は制限なし、複数選択は OR です。自動作成された主キー値には、カーネルが管理する `block.collectionRuleID` が含まれる場合があります。自動収集は追加だけを行います。原文やルールの条件・範囲・対象・有効状態が変わっても既存の項目とフィールドを保持し、再び一致しても同じ項目を使います。明示的な整理ではすべての有効な収集ルールを使い、手動・自動でバインドした項目を同じ基準で確認します。一致する項目や判定できない項目は保持し、実行前の再確認で不一致が確定した項目だけを除去します。元に戻す操作で元の項目と全フィールドを復元します。 `blockSource.tagMatch` と `attributeMatch` は既定で `and`、形式 3 では各組を個別に `or` にできます。組の間は AND のままで、空の組は制限しません。 各ルールの省略可能な `notifyOnSuccess` は既定(`null` を含む)で `true` です。実際の変更をトランザクション確定後に一つの通知にまとめます。無効にしてもエラーは通知します。変更なし・明示的な収集・元に戻す・やり直し・ロールバックでは成功通知を送信しません。 形式 4 では省略可能な `blockSource.tagTarget` を追加しています。省略・空文字列は既定の選択で、最初の内容ブロックより条件に合うリスト項目を優先、`block` はタグを含むブロック、`container` は種類と属性の条件に一致する最も近いコンテナを収集し、ブロック ID で重複を除きます。文書には明示的な `d` の選択が必要です。AND のタグは同じ元ブロックに必要で、タグ条件がなければこの設定は影響しません。プレビューと実際の収集対象は一致し、切り替えても既存項目とフィールドは維持されます。 形式 5 では省略可能な `blockSource.documentDepth` を追加しています。省略または `null` は無制限、`0` は選択した各文書自体のみ、`1` は直接の子文書も含み、他の非負整数は相対的な最大階層数を指定します。文書の範囲すべてに共通し、ノートブックの範囲は制限せず、範囲は和集合のままです。深さを変更しても既存の項目とフィールドを保持し、既存の内容を自動で追加収集しません。 形式 6 は各属性条件に省略可能な `nameOperator` を追加します。省略・空文字列・`equals` は完全な名前との一致を維持し、`contains` は `custom-` 接頭辞の入力を必要としない文字列の部分一致、`regex` は接頭辞を含む完全な名前に対する Go の正規表現です。カスタム属性だけを照合し、名前と値は大文字小文字を区別して同じ属性で満たす必要があります。`exists` は名前の一致が一つ以上、`notExists` は一致がないことを要求し、値は無視します。名前パターンは最大 256 バイトで、不正な式は保存を拒否します。既存の形式 1–5 の動作は維持し、古いリーダーはデータベースを書き換えずに形式 6 を拒否します。 形式 7 は省略可能な `blockSource.includeSelectedDocuments` を追加します。省略・`null`・`true` は選択した各文書自体を含み、`false` はその文書と内部のすべてのブロックを除外し、子孫文書には引き続き `documentDepth` を適用します。この設定は文書範囲に共通で、ノートブックの範囲や重なる別の文書範囲には影響せず、範囲は和集合のままです。`false` と深さ `0` の組み合わせでは、対応する文書範囲は空です。変更しても既存の項目とフィールドを保持し、自動で追加収集や除去を行いません。形式 1–6 は引き続き読み取れ、古いリーダーはデータベースを書き換えずに形式 7 を拒否します。 形式 8 は省略可能な `blockSource.referenceID` を追加します。本文中でこのブロックを参照するブロック参照を照合し、文書を指定した場合は内部のコンテンツブロックも含みますが、子文書は含みません。埋め込み、通常のリンク、データベースのリッチテキストフィールド内の参照は対象外です。タグは同じ参照元を判定し、バックリンクの親ブロック規則でまとめた後に種類と属性を判定します。`tagTarget` は使用しません。参照先は同じ暗号化境界内に限られます。参照の削除や参照先の変更でも既存の項目とフィールドを保持し、以前の内容はプレビューして明示的に収集します。形式 1–7 は引き続き読み取れ、古いクライアントはデータベースを書き換えずに形式 8 を拒否します。 `setAttrViewAutomations` で新しい範囲を保存する場合、重複を除いたノートブックと文書の合計は32件までです。既存の上限を超える範囲は引き続き読み取りと使用ができ、維持または削減できますが、上限を超えた状態で範囲を追加することはできません。元に戻す・やり直しでは元の範囲が保持されます。
### 主キー値を取得
diff --git a/docs/API.md b/docs/API.md
index 39a9ee80c0..dd63305716 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -2250,7 +2250,7 @@ The field types (`keyType`) are:
* `data.av`: The full `AttributeView` definition — fields (`keyValues`), field ordering (`keyIDs`, may be `null`), and all views with their raw layout config (`table`/`list`/`gallery`/`kanban`) and item ordering (`itemIds`). The compatibility `viewID` is computed as the first available view and is not persisted. Returns no rendered rows or pagination; therefore, use [Render](#Render) for computed rows
- * `data.av.automations` optionally contains database-wide rules (`spec: 1` through `8`). A `block` trigger uses `blockSource` to select notebooks/documents, block types, tags, and custom attributes; its `collect` action binds matching source blocks to this database. Main types include every subtype; format 3 supports `h:h1` through `h:h6`, `l:u/o/t`, `i:u/o/t`, and `callout:TYPE` (case-sensitive, including custom types). Empty types impose no restriction, and multiple types use OR. Automatically created primary values may include `block.collectionRuleID`, which is maintained by the kernel. Automatic collection only adds entries. Source changes and changes to rule conditions, scope, target, or activation preserve existing rows and fields; matching again keeps the same row. Explicit cleanup checks all enabled collection rules for manual and automatic bound entries alike, preserves matches and indeterminate entries, and rechecks before removing unmatched entries; undo restores the original row and all fields. `blockSource.tagMatch` and `attributeMatch` default to `and`; format 3 also supports `or` independently within each group. Groups remain ANDed, and empty groups add no restriction. Each rule's optional `notifyOnSuccess` defaults to `true` (including `null`); successful changes are summarized once after the transaction commits. Disabled notifications do not suppress errors. No-op actions, explicit collection, undo, redo, and rolled-back transactions do not generate success messages. Format 4 adds optional `blockSource.tagTarget`: omitted/empty uses default selection, preferring an eligible list item over its first content block, `block` collects the tagged block itself, and `container` collects the nearest container meeting type and attribute conditions, deduplicated by block ID. Documents require an explicit `d` type. AND tags must occur in one source block; without tag conditions this option has no effect. Preview and actual collection share the same targets; changing this option preserves existing rows and fields. Format 5 adds optional `blockSource.documentDepth`: omitted or `null` means unlimited, `0` includes only each selected document itself, and `1` also includes its direct children. Other nonnegative integers set the maximum relative descendant depth. It applies uniformly to document scopes, not notebook scopes; scopes remain combined by union. Changing depth preserves existing rows and fields and does not backfill existing content. Format 6 adds each attribute condition's optional `nameOperator`: omitted/empty or `equals` retains exact full-name matching, `contains` matches a literal substring without requiring the `custom-` prefix, and `regex` uses Go regular expressions against the full name including that prefix. Only custom attributes are considered. Names and values are case-sensitive and must match on the same attribute; `exists` requires at least one name match and `notExists` requires none, ignoring the value. Name patterns are limited to 256 bytes; invalid expressions are rejected on save. Existing formats 1–5 retain their behavior; older readers reject format 6 without rewriting the database. Format 7 adds optional `blockSource.includeSelectedDocuments`: omitted, `null`, or `true` includes each selected document itself; `false` excludes it and all blocks inside it while descendants still follow `documentDepth`. This option is shared by document scopes and does not affect notebook scopes or other overlapping document scopes; scopes remain combined by union. With `false` and depth `0`, the corresponding document scope is empty. Changing it preserves existing rows and fields without automatic backfill or removal. Formats 1–6 remain readable; older readers reject format 7 without rewriting the database. Format 8 adds optional `blockSource.referenceID`: body block references must point to this block; a document target also includes its internal content blocks, excluding child documents. Embeds, ordinary links and references in database rich-text fields are excluded. Tags constrain the same reference source; sources are grouped using backlink parent rules before type and attribute filtering, and `tagTarget` is ignored. The target must be in the same encryption boundary. Existing rows and fields are preserved when references are removed or the target changes; older matches require explicit preview and collection. Formats 1–7 remain readable; older readers reject format 8 without rewriting the database.
+ * `data.av.automations` optionally contains database-wide rules (`spec: 1` through `8`). A `block` trigger uses `blockSource` to select notebooks/documents, block types, tags, and custom attributes; its `collect` action binds matching source blocks to this database. New scopes saved through `setAttrViewAutomations` allow at most 32 distinct notebooks/documents in total. Existing larger scopes remain readable and usable and may be retained or reduced; adding scopes while above the limit is rejected. Undo and redo preserve the original scope. Main types include every subtype; format 3 supports `h:h1` through `h:h6`, `l:u/o/t`, `i:u/o/t`, and `callout:TYPE` (case-sensitive, including custom types). Empty types impose no restriction, and multiple types use OR. Automatically created primary values may include `block.collectionRuleID`, which is maintained by the kernel. Automatic collection only adds entries. Source changes and changes to rule conditions, scope, target, or activation preserve existing rows and fields; matching again keeps the same row. Explicit cleanup checks all enabled collection rules for manual and automatic bound entries alike, preserves matches and indeterminate entries, and rechecks before removing unmatched entries; undo restores the original row and all fields. `blockSource.tagMatch` and `attributeMatch` default to `and`; format 3 also supports `or` independently within each group. Groups remain ANDed, and empty groups add no restriction. Each rule's optional `notifyOnSuccess` defaults to `true` (including `null`); successful changes are summarized once after the transaction commits. Disabled notifications do not suppress errors. No-op actions, explicit collection, undo, redo, and rolled-back transactions do not generate success messages. Format 4 adds optional `blockSource.tagTarget`: omitted/empty uses default selection, preferring an eligible list item over its first content block, `block` collects the tagged block itself, and `container` collects the nearest container meeting type and attribute conditions, deduplicated by block ID. Documents require an explicit `d` type. AND tags must occur in one source block; without tag conditions this option has no effect. Preview and actual collection share the same targets; changing this option preserves existing rows and fields. Format 5 adds optional `blockSource.documentDepth`: omitted or `null` means unlimited, `0` includes only each selected document itself, and `1` also includes its direct children. Other nonnegative integers set the maximum relative descendant depth. It applies uniformly to document scopes, not notebook scopes; scopes remain combined by union. Changing depth preserves existing rows and fields and does not backfill existing content. Format 6 adds each attribute condition's optional `nameOperator`: omitted/empty or `equals` retains exact full-name matching, `contains` matches a literal substring without requiring the `custom-` prefix, and `regex` uses Go regular expressions against the full name including that prefix. Only custom attributes are considered. Names and values are case-sensitive and must match on the same attribute; `exists` requires at least one name match and `notExists` requires none, ignoring the value. Name patterns are limited to 256 bytes; invalid expressions are rejected on save. Existing formats 1–5 retain their behavior; older readers reject format 6 without rewriting the database. Format 7 adds optional `blockSource.includeSelectedDocuments`: omitted, `null`, or `true` includes each selected document itself; `false` excludes it and all blocks inside it while descendants still follow `documentDepth`. This option is shared by document scopes and does not affect notebook scopes or other overlapping document scopes; scopes remain combined by union. With `false` and depth `0`, the corresponding document scope is empty. Changing it preserves existing rows and fields without automatic backfill or removal. Formats 1–6 remain readable; older readers reject format 7 without rewriting the database. Format 8 adds optional `blockSource.referenceID`: body block references must point to this block; a document target also includes its internal content blocks, excluding child documents. Embeds, ordinary links and references in database rich-text fields are excluded. Tags constrain the same reference source; sources are grouped using backlink parent rules before type and attribute filtering, and `tagTarget` is ignored. The target must be in the same encryption boundary. Existing rows and fields are preserved when references are removed or the target changes; older matches require explicit preview and collection. Formats 1–7 remain readable; older readers reject format 8 without rewriting the database.
### Get primary key values
diff --git a/docs/API.zh-CN.md b/docs/API.zh-CN.md
index 7854aa8d0a..dab29e2a21 100644
--- a/docs/API.zh-CN.md
+++ b/docs/API.zh-CN.md
@@ -2246,7 +2246,7 @@ if (response.code === 0 && response.data) {
* `data.av`: 完整的 `AttributeView` 定义——字段(`keyValues`)、字段顺序(`keyIDs`,可能为 `null`),以及所有视图的原始布局配置(`table`/`list`/`gallery`/`kanban`)和条目顺序(`itemIds`)。兼容字段 `viewID` 动态取第一个可用视图,不会持久化。返回值不含渲染后的行或分页;需要计算后的行数据请使用 [渲染](#渲染)
- * `data.av.automations` 可选,保存数据库共享的规则(`spec: 1` 至 `8`)。`block` 触发器通过 `blockSource` 指定笔记本/文档范围、块类型、标签和自定义属性,`collect` 动作将符合条件的原块绑定到当前数据库。主类型包含全部子类型;格式 3 支持 `h:h1` 至 `h:h6`、`l:u/o/t`、`i:u/o/t` 和 `callout:TYPE`(区分大小写,允许自定义提示类型)。类型为空不限制,多个类型取任一匹配。自动创建的主键值可能包含由内核维护的 `block.collectionRuleID`。自动收集只添加条目,原文变化及规则条件、范围、对象或启用状态变化均保留已有条目和字段,再次匹配仍使用原条目。主动清理按全部启用的收集规则统一检查手动和自动绑定条目,保留匹配或无法判断的条目,执行前复查后仅移出确认不匹配的条目;撤销恢复原条目及全部字段。 `blockSource.tagMatch` 和 `attributeMatch` 缺省为 `and`,格式 3 支持各组独立设置 `or`;组间仍取与关系,空组不限制。 每条规则的可选 `notifyOnSuccess` 缺省或 `null` 为 `true`,实际变更在事务提交成功后合并通知;关闭不影响错误提示。无变化、手动收集、撤销重做及回滚事务不发送成功通知。 格式 4 增加可选的 `blockSource.tagTarget`:缺省或空字符串使用默认选择,优先收集合格列表项而非其首个内容块,`block` 收集标签所在块,`container` 选择最近的符合类型和属性条件的容器并按块 ID 去重;文档需显式选择 `d`。全部标签须在同一个来源块中,无标签条件时此选项不影响筛选。预览与实际收集对象一致,切换保留已有条目及字段。 格式 5 增加可选的 `blockSource.documentDepth`:缺省或 `null` 表示不限,`0` 仅包含每个选中文档本身,`1` 还包含一级子文档,其他非负整数指定最大相对后代深度。该设置统一限制文档范围,不影响笔记本范围,各范围仍取并集。修改深度保留已有条目和字段,不自动补收存量内容。 格式 6 为每条属性条件增加可选的 `nameOperator`:缺省、空字符串或 `equals` 保持完整名称精确匹配,`contains` 按字面子串匹配且无需输入 `custom-` 前缀,`regex` 使用 Go 正则语法匹配包含该前缀的完整名称。仅匹配自定义属性,名称和值区分大小写,且必须由同一条属性同时满足;`exists` 要求至少一个名称匹配,`notExists` 要求没有名称匹配,两者忽略属性值。名称模式最多 256 字节,非法正则拒绝保存。既有格式 1–5 的行为保持不变,旧读取器拒绝格式 6 且不改写数据库。 格式 7 增加可选的 `blockSource.includeSelectedDocuments`:缺省、`null` 或 `true` 包含每个所选文档自身;`false` 排除该文档及其内部所有块,子文档仍按 `documentDepth` 匹配。该设置由所有文档范围共用,不影响笔记本范围或其他重叠文档范围,各范围仍取并集。`false` 与深度 `0` 组合时,对应文档范围为空。修改后保留已有条目和字段,不自动补收或移出。格式 1–6 仍可读取,旧读取器拒绝格式 7 且不改写数据库。 格式 8 增加可选的 `blockSource.referenceID`:匹配正文中指向该块的块引用,文档目标还包含内部内容块,不含子文档;不包含嵌入块、普通链接和数据库富文本字段中的引用。标签约束同一引用来源块,来源按反链父块规则归并后再匹配类型和属性,`tagTarget` 不参与选择。目标必须位于同一加密边界。移除引用或更改目标会保留已有条目和字段,历史内容需预览后显式补收。既有格式 1–7 仍可读取,旧客户端会拒绝格式 8 且不改写数据库。
+ * `data.av.automations` 可选,保存数据库共享的规则(`spec: 1` 至 `8`)。`block` 触发器通过 `blockSource` 指定笔记本/文档范围、块类型、标签和自定义属性,`collect` 动作将符合条件的原块绑定到当前数据库。通过 `setAttrViewAutomations` 保存新增范围时,笔记本与文档分别去重后合计最多 32 项。既有超限范围仍可读取和使用,可保留或删减;超限时新增范围会被拒绝。撤销重做保留原范围。主类型包含全部子类型;格式 3 支持 `h:h1` 至 `h:h6`、`l:u/o/t`、`i:u/o/t` 和 `callout:TYPE`(区分大小写,允许自定义提示类型)。类型为空不限制,多个类型取任一匹配。自动创建的主键值可能包含由内核维护的 `block.collectionRuleID`。自动收集只添加条目,原文变化及规则条件、范围、对象或启用状态变化均保留已有条目和字段,再次匹配仍使用原条目。主动清理按全部启用的收集规则统一检查手动和自动绑定条目,保留匹配或无法判断的条目,执行前复查后仅移出确认不匹配的条目;撤销恢复原条目及全部字段。 `blockSource.tagMatch` 和 `attributeMatch` 缺省为 `and`,格式 3 支持各组独立设置 `or`;组间仍取与关系,空组不限制。 每条规则的可选 `notifyOnSuccess` 缺省或 `null` 为 `true`,实际变更在事务提交成功后合并通知;关闭不影响错误提示。无变化、手动收集、撤销重做及回滚事务不发送成功通知。 格式 4 增加可选的 `blockSource.tagTarget`:缺省或空字符串使用默认选择,优先收集合格列表项而非其首个内容块,`block` 收集标签所在块,`container` 选择最近的符合类型和属性条件的容器并按块 ID 去重;文档需显式选择 `d`。全部标签须在同一个来源块中,无标签条件时此选项不影响筛选。预览与实际收集对象一致,切换保留已有条目及字段。 格式 5 增加可选的 `blockSource.documentDepth`:缺省或 `null` 表示不限,`0` 仅包含每个选中文档本身,`1` 还包含一级子文档,其他非负整数指定最大相对后代深度。该设置统一限制文档范围,不影响笔记本范围,各范围仍取并集。修改深度保留已有条目和字段,不自动补收存量内容。 格式 6 为每条属性条件增加可选的 `nameOperator`:缺省、空字符串或 `equals` 保持完整名称精确匹配,`contains` 按字面子串匹配且无需输入 `custom-` 前缀,`regex` 使用 Go 正则语法匹配包含该前缀的完整名称。仅匹配自定义属性,名称和值区分大小写,且必须由同一条属性同时满足;`exists` 要求至少一个名称匹配,`notExists` 要求没有名称匹配,两者忽略属性值。名称模式最多 256 字节,非法正则拒绝保存。既有格式 1–5 的行为保持不变,旧读取器拒绝格式 6 且不改写数据库。 格式 7 增加可选的 `blockSource.includeSelectedDocuments`:缺省、`null` 或 `true` 包含每个所选文档自身;`false` 排除该文档及其内部所有块,子文档仍按 `documentDepth` 匹配。该设置由所有文档范围共用,不影响笔记本范围或其他重叠文档范围,各范围仍取并集。`false` 与深度 `0` 组合时,对应文档范围为空。修改后保留已有条目和字段,不自动补收或移出。格式 1–6 仍可读取,旧读取器拒绝格式 7 且不改写数据库。 格式 8 增加可选的 `blockSource.referenceID`:匹配正文中指向该块的块引用,文档目标还包含内部内容块,不含子文档;不包含嵌入块、普通链接和数据库富文本字段中的引用。标签约束同一引用来源块,来源按反链父块规则归并后再匹配类型和属性,`tagTarget` 不参与选择。目标必须位于同一加密边界。移除引用或更改目标会保留已有条目和字段,历史内容需预览后显式补收。既有格式 1–7 仍可读取,旧客户端会拒绝格式 8 且不改写数据库。
### 获取主键值
diff --git a/kernel/apicontract/av_automation.go b/kernel/apicontract/av_automation.go
index c039e56f4c..e67a3bee30 100644
--- a/kernel/apicontract/av_automation.go
+++ b/kernel/apicontract/av_automation.go
@@ -31,6 +31,8 @@ type AVAutomationRule struct {
}
// AVAutomationBlockSource 监听范围取笔记本与文档的并集,文档包含子文档;范围至少选择一项。
+// 保存新增范围时,笔记本与文档 ID 分别去重后合计最多 32 项;既有超限规则可保留或删减,不能新增范围。
+// 既有规则的读取、匹配、预览及撤销重做保持兼容,不自动截断范围或删除条目。
// documentDepth 缺省或 null 表示不限;非负整数限制每个所选文档的最大子文档深度,0 仅自身,1 包含自身及一级子文档。
// 深度按文档 ID 路径相对计算,不限制文档内部块层级;不影响笔记本范围,重叠范围仍取并集;有限深度要求 spec 5。
// 修改深度保留已有条目及字段,不自动补收存量;预览、显式收集和清理检查使用相同范围判断。
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index 2c5bb59c03..2b11137112 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -1779,6 +1779,7 @@ var SystemAddUIProcess = define[EmptyRequest, Null]("addUIProcess", "/api/system
// 类型和属性始终筛选最终对象;默认首个内容块优先归属合格列表项,每次标签命中只选择一个对象。
// 无标签时收集对象不影响筛选;变更收集对象不转换已有条目,预览与实际收集使用相同规则。
// 自动收集只添加条目,原文失配及规则变更均保留已有条目和字段,再次匹配不会重新初始化。
+// setAttrViewAutomations 新增范围最多包含 32 个去重后的笔记本或文档;既有超限规则可保留或删减,撤销重做不截断原范围。
// cleanupAttrViewBlocks 按全部启用收集规则复查已确认条目及绑定,仅移出明确失配条目,并支持撤销。
// 规则的 notifyOnSuccess 缺省或 null 为开启,仅实际变更且事务成功提交后通知,同一事务合并;错误提示不受其控制。
// 手动收集及清理、无变化、撤销重放和失败回滚不发送成功通知。
diff --git a/kernel/model/attribute_view_automation.go b/kernel/model/attribute_view_automation.go
index b025b83d86..f3f279e0d0 100644
--- a/kernel/model/attribute_view_automation.go
+++ b/kernel/model/attribute_view_automation.go
@@ -806,6 +806,20 @@ func (tx *Transaction) doSetAttrViewAutomations(op *Operation) *TxErr {
return fail(fmt.Errorf("invalid automation rule"))
}
seen[rule.ID] = true
+ if !tx.isReplay && rule.Trigger == "block" {
+ var previous *av.AutomationBlockSource
+ if view.Automations != nil {
+ for _, existing := range view.Automations.Rules {
+ if existing != nil && existing.ID == rule.ID && existing.Trigger == "block" {
+ previous = existing.BlockSource
+ break
+ }
+ }
+ }
+ if !blockCollectionScopeCanSave(rule.BlockSource, previous) {
+ return fail(fmt.Errorf("block collection scope exceeds 32 notebooks or documents"))
+ }
+ }
for _, action := range rule.Actions {
if action == nil {
continue
diff --git a/kernel/model/attribute_view_collection.go b/kernel/model/attribute_view_collection.go
index 4707d23b9d..2cfb24d1f0 100644
--- a/kernel/model/attribute_view_collection.go
+++ b/kernel/model/attribute_view_collection.go
@@ -223,6 +223,33 @@ func validateCollectionAttribute(attr *av.AutomationBlockAttribute) (*regexp.Reg
return nil, nil
}
+// 新增范围最多包含 32 项;既有超限规则可保留或删减,读取和事务重放继续使用原校验。
+func blockCollectionScopeCanSave(source, previous *av.AutomationBlockSource) bool {
+ keys := func(source *av.AutomationBlockSource) map[string]bool {
+ ret := map[string]bool{}
+ if source != nil {
+ for _, id := range source.NotebookIDs {
+ ret["notebook:"+id] = true
+ }
+ for _, id := range source.DocumentIDs {
+ ret["document:"+id] = true
+ }
+ }
+ return ret
+ }
+ current := keys(source)
+ if len(current) <= 32 {
+ return true
+ }
+ old := keys(previous)
+ for key := range current {
+ if !old[key] {
+ return false
+ }
+ }
+ return true
+}
+
func (tx *Transaction) validateBlockCollectionRule(view *av.AttributeView, rule *av.AutomationRule, boxID string) error {
source := rule.BlockSource
if source == nil || len(source.NotebookIDs)+len(source.DocumentIDs) == 0 ||
diff --git a/kernel/model/attribute_view_collection_scope_fts5_test.go b/kernel/model/attribute_view_collection_scope_fts5_test.go
index a28c6af5b2..324b046ee1 100644
--- a/kernel/model/attribute_view_collection_scope_fts5_test.go
+++ b/kernel/model/attribute_view_collection_scope_fts5_test.go
@@ -3,6 +3,7 @@
package model
import (
+ "bytes"
"encoding/json"
"strings"
"testing"
@@ -12,6 +13,83 @@ import (
"github.com/siyuan-note/siyuan/kernel/av"
)
+func TestBlockCollectionScopeLimitContract(t *testing.T) {
+ fixture, view, _ := setupBlockCollectionTest(t)
+ ids := []string{fixture.sourceID}
+ for range 33 {
+ created, err := CreateDocByMdSync(fixture.box.ID, "/"+ast.NewNodeID()+".sy", "Scope", "", nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ ids = append(ids, created.ID)
+ }
+ save := func(source *av.AutomationBlockSource, enabled bool) error {
+ t.Helper()
+ current := readAttributeViewItemsTest(t, view.ID)
+ current.Automations.Rules[0].BlockSource = source
+ current.Automations.Rules[0].Enabled = enabled
+ return PerformAttributeViewOperations([]*Operation{{Action: "setAttrViewAutomations", AvID: view.ID, Data: current.Automations}})
+ }
+ source := func(count int) *av.AutomationBlockSource {
+ return &av.AutomationBlockSource{DocumentIDs: append([]string{}, ids[:count]...), Types: []string{"d"}, Tags: []string{"todo"}}
+ }
+ // 笔记本和文档合计计数,重复 ID 不额外占用名额。
+ boundary := source(31)
+ boundary.NotebookIDs = []string{fixture.box.ID, fixture.box.ID}
+ if err := save(boundary, true); err != nil {
+ t.Fatal("32 distinct scopes rejected", err)
+ }
+ before, _ := json.Marshal(readAttributeViewItemsTest(t, view.ID).Automations)
+ for _, enabled := range []bool{false, true} {
+ if err := save(source(33), enabled); err == nil {
+ t.Fatal("33 new scopes accepted", enabled)
+ }
+ after, _ := json.Marshal(readAttributeViewItemsTest(t, view.ID).Automations)
+ if !bytes.Equal(before, after) {
+ t.Fatal("rejected scope changed saved rules")
+ }
+ }
+ legacy := readAttributeViewItemsTest(t, view.ID)
+ legacy.Automations.Rules[0].BlockSource = source(34)
+ if err := av.SaveAttributeView(legacy); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := PreviewAttributeViewCollection(view.ID, legacy.Automations.Rules[0].ID, 1); err != nil {
+ t.Fatal("legacy scope preview rejected", err)
+ }
+ if err := save(source(34), true); err != nil {
+ t.Fatal("unchanged legacy scope rejected", err)
+ }
+ if err := save(source(33), true); err != nil {
+ t.Fatal("legacy scope could not be reduced while still above the limit", err)
+ }
+ replaced := source(33)
+ replaced.DocumentIDs[32] = ids[33]
+ if err := save(replaced, true); err == nil {
+ t.Fatal("legacy oversized scope accepted a new document")
+ }
+ if err := PerformTxSync(blockCollectionTags(t, ids[0], "todo")); err != nil {
+ t.Fatal("legacy scope stopped collecting", err)
+ }
+ if readAttributeViewItemsTest(t, view.ID).GetBlockValueByBoundID(ids[0]) == nil {
+ t.Fatal("legacy scope lost its live collection behavior")
+ }
+ if err := save(source(32), true); err != nil {
+ t.Fatal("legacy scope could not be reduced", err)
+ }
+ if err := PerformTxSync(&Transaction{isReplay: true, DoOperations: []*Operation{{Action: "setAttrViewAutomations", AvID: view.ID, Data: legacy.Automations}}}); err != nil {
+ t.Fatal("undo could not restore legacy scope", err)
+ }
+ if got := len(readAttributeViewItemsTest(t, view.ID).Automations.Rules[0].BlockSource.DocumentIDs); got != 34 {
+ t.Fatal("undo truncated the legacy scope", got)
+ }
+ if err := PerformTxSync(&Transaction{isReplay: true, DoOperations: []*Operation{{Action: "setAttrViewAutomations", AvID: view.ID,
+ Data: &av.AutomationConfig{Spec: 1, Rules: []*av.AutomationRule{{ID: legacy.Automations.Rules[0].ID, Name: "Collect", Trigger: "block", Enabled: true,
+ BlockSource: source(32), Actions: legacy.Automations.Rules[0].Actions}}}}}}); err != nil {
+ t.Fatal("redo could not reduce legacy scope", err)
+ }
+}
+
func TestBlockCollectionSelectedDocumentScope(t *testing.T) {
ids := map[string]string{"parent": ast.NewNodeID(), "child": ast.NewNodeID(), "grand": ast.NewNodeID()}
paths := strings.NewReplacer("parent", ids["parent"], "child", ids["child"], "grand", ids["grand"])