Skip to content

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

:sparkles: Support excluding selected documents from automation scopes https://github.com/siyuan-note/siyuan/issues/20792

Danielf619eaabdf71
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 4d2cd44ae7..9684b33318 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "تضمين المستندات المحددة نفسها",
+ "automationCollectionIncludeSelfTip": "عند التعطيل، تتم مراقبة المستندات التابعة فقط؛ ومع خيار المستند الحالي فقط، يصبح نطاق المستند فارغًا",
"clearRecentDocs": "مسح سجل المستندات الأخيرة",
"confirmClearRecentDocs": "هل تريد مسح جميع سجلات تصفح المستندات وفتحها وإغلاقها؟ ستبقى المستندات، وسيستمر تسجيل النشاط الجديد.",
"bazaarInstalling": "جارٍ التثبيت...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "بلا حدود",
"automationCollectionDepthCurrent": "المستند الحالي فقط",
"automationCollectionDepthLimited": "العمق الأقصى",
- "automationCollectionDepthTip": "يشمل كل مستند محدد نفسه؛ يقتصر تطبيق العمق على نطاقات المستندات. يتم دمج نطاقات دفاتر الملاحظات والمستندات",
+ "automationCollectionDepthTip": "يقتصر تطبيق العمق على نطاقات المستندات. يتم دمج نطاقات دفاتر الملاحظات والمستندات",
"mindmapPasteChild": "لصق كعقدة فرعية",
"mindmapPasteSibling": "لصق كعقدة شقيقة",
"embedBlockBreadcrumbParentPath": "إظهار المسار الأصل في مسار التنقل",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 7145506b33..bc21b4ccd5 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Ausgewählte Dokumente selbst einschließen",
+ "automationCollectionIncludeSelfTip": "Wenn deaktiviert, werden nur untergeordnete Dokumente überwacht; mit Nur aktuelles Dokument ist der Dokumentbereich leer",
"clearRecentDocs": "Verlauf zuletzt verwendeter Dokumente leeren",
"confirmClearRecentDocs": "Alle Einträge zum Anzeigen, Öffnen und Schließen von Dokumenten löschen? Die Dokumente bleiben erhalten und neue Aktivitäten werden weiterhin aufgezeichnet.",
"bazaarInstalling": "Wird installiert...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Unbegrenzt",
"automationCollectionDepthCurrent": "Nur aktuelles Dokument",
"automationCollectionDepthLimited": "Maximale Tiefe",
- "automationCollectionDepthTip": "Schließt jedes ausgewählte Dokument selbst ein; die Tiefe gilt nur für Dokumentbereiche. Notizbuch- und Dokumentbereiche werden vereinigt",
+ "automationCollectionDepthTip": "Die Tiefe gilt nur für Dokumentbereiche. Notizbuch- und Dokumentbereiche werden vereinigt",
"mindmapPasteChild": "Als untergeordneten Knoten einfügen",
"mindmapPasteSibling": "Als gleichgeordneten Knoten einfügen",
"embedBlockBreadcrumbParentPath": "Übergeordneten Pfad in der Brotkrumennavigation anzeigen",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 014706e792..1e1e315f54 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Include selected documents themselves",
+ "automationCollectionIncludeSelfTip": "When disabled, only descendant documents are watched; combined with Current document only, the document scope is empty",
"clearRecentDocs": "Clear recent document history",
"confirmClearRecentDocs": "Clear all document browsing, opening and closing records? Documents are kept and new activity will still be recorded.",
"bazaarInstalling": "Installing...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Unlimited",
"automationCollectionDepthCurrent": "Current document only",
"automationCollectionDepthLimited": "Limit depth",
- "automationCollectionDepthTip": "Includes each selected document itself; depth applies only to document scopes. Notebook and document scopes are combined",
+ "automationCollectionDepthTip": "Depth applies only to document scopes. Notebook and document scopes are combined",
"mindmapPasteChild": "Paste as child node",
"mindmapPasteSibling": "Paste as sibling node",
"embedBlockBreadcrumbParentPath": "Show parent path in breadcrumbs",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 3fa837731a..129b9cd599 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Incluir los propios documentos seleccionados",
+ "automationCollectionIncludeSelfTip": "Al desactivar, solo se supervisan los documentos descendientes; con Solo el documento actual, el ámbito del documento queda vacío",
"clearRecentDocs": "Borrar el historial de documentos recientes",
"confirmClearRecentDocs": "¿Borrar todos los registros de consulta, apertura y cierre de documentos? Los documentos se conservarán y se seguirá registrando la nueva actividad.",
"bazaarInstalling": "Instalando...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Sin límite",
"automationCollectionDepthCurrent": "Solo el documento actual",
"automationCollectionDepthLimited": "Profundidad máxima",
- "automationCollectionDepthTip": "Incluye cada documento seleccionado; la profundidad solo limita los ámbitos de documentos. Los ámbitos de cuadernos y documentos se unen",
+ "automationCollectionDepthTip": "La profundidad solo limita los ámbitos de documentos. Los ámbitos de cuadernos y documentos se unen",
"mindmapPasteChild": "Pegar como nodo hijo",
"mindmapPasteSibling": "Pegar como nodo hermano",
"embedBlockBreadcrumbParentPath": "Mostrar la ruta superior en la ruta de navegación",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 5d4c5a0fcc..119d2b5129 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Inclure les documents sélectionnés eux-mêmes",
+ "automationCollectionIncludeSelfTip": "Si désactivé, seuls les documents descendants sont surveillés ; avec Document actuel uniquement, le périmètre du document est vide",
"clearRecentDocs": "Effacer l’historique des documents récents",
"confirmClearRecentDocs": "Effacer tous les enregistrements de consultation, d’ouverture et de fermeture de documents ? Les documents seront conservés et les nouvelles activités continueront d’être enregistrées.",
"bazaarInstalling": "Installation en cours...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Illimitée",
"automationCollectionDepthCurrent": "Document actuel uniquement",
"automationCollectionDepthLimited": "Profondeur maximale",
- "automationCollectionDepthTip": "Inclut chaque document sélectionné ; la profondeur limite uniquement les périmètres de documents. Les périmètres des carnets et des documents sont réunis",
+ "automationCollectionDepthTip": "La profondeur limite uniquement les périmètres de documents. Les périmètres des carnets et des documents sont réunis",
"mindmapPasteChild": "Coller comme nœud enfant",
"mindmapPasteSibling": "Coller comme nœud de même niveau",
"embedBlockBreadcrumbParentPath": "Afficher le chemin parent dans le fil d'Ariane",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index a5967f5a18..3c19b6ef8e 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "כלילת המסמכים שנבחרו עצמם",
+ "automationCollectionIncludeSelfTip": "כאשר האפשרות כבויה, מתבצע מעקב רק אחר מסמכים צאצאים; בשילוב עם המסמך הנוכחי בלבד, טווח המסמך ריק",
"clearRecentDocs": "ניקוי היסטוריית המסמכים האחרונים",
"confirmClearRecentDocs": "לנקות את כל רשומות העיון, הפתיחה והסגירה של מסמכים? המסמכים יישמרו ופעילות חדשה תמשיך להירשם.",
"bazaarInstalling": "מתקין...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "ללא הגבלה",
"automationCollectionDepthCurrent": "המסמך הנוכחי בלבד",
"automationCollectionDepthLimited": "עומק מרבי",
- "automationCollectionDepthTip": "כולל כל מסמך שנבחר עצמו; העומק מגביל רק טווחי מסמכים. טווחי מחברות ומסמכים משולבים יחד",
+ "automationCollectionDepthTip": "העומק מגביל רק טווחי מסמכים. טווחי מחברות ומסמכים משולבים יחד",
"mindmapPasteChild": "הדבקה כצומת ילד",
"mindmapPasteSibling": "הדבקה כצומת אח",
"embedBlockBreadcrumbParentPath": "הצגת נתיב האב בנתיב הניווט",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 58df6e86cf..a4c0d5bbeb 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "चयनित दस्तावेज़ों को स्वयं शामिल करें",
+ "automationCollectionIncludeSelfTip": "बंद होने पर केवल वंशज दस्तावेज़ों की निगरानी होती है; केवल वर्तमान दस्तावेज़ के साथ दस्तावेज़ का दायरा खाली होता है",
"clearRecentDocs": "हाल के दस्तावेज़ों का इतिहास साफ़ करें",
"confirmClearRecentDocs": "दस्तावेज़ देखने, खोलने और बंद करने के सभी रिकॉर्ड साफ़ करें? दस्तावेज़ सुरक्षित रहेंगे और नई गतिविधि रिकॉर्ड होती रहेगी।",
"bazaarInstalling": "इंस्टॉल हो रहा है...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "असीमित",
"automationCollectionDepthCurrent": "केवल वर्तमान दस्तावेज़",
"automationCollectionDepthLimited": "अधिकतम गहराई",
- "automationCollectionDepthTip": "प्रत्येक चयनित दस्तावेज़ स्वयं भी शामिल है; गहराई केवल दस्तावेज़ों के दायरे को सीमित करती है। नोटबुक और दस्तावेज़ों के दायरे संयुक्त होते हैं",
+ "automationCollectionDepthTip": "गहराई केवल दस्तावेज़ों के दायरे को सीमित करती है। नोटबुक और दस्तावेज़ों के दायरे संयुक्त होते हैं",
"mindmapPasteChild": "चाइल्ड नोड के रूप में पेस्ट करें",
"mindmapPasteSibling": "समान स्तर के नोड के रूप में पेस्ट करें",
"embedBlockBreadcrumbParentPath": "ब्रेडक्रंब में मूल पथ दिखाएँ",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 4413b66a82..8756bc208a 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Sertakan dokumen yang dipilih itu sendiri",
+ "automationCollectionIncludeSelfTip": "Jika dinonaktifkan, hanya dokumen turunan yang dipantau; dengan Hanya dokumen saat ini, cakupan dokumen menjadi kosong",
"clearRecentDocs": "Hapus riwayat dokumen terbaru",
"confirmClearRecentDocs": "Hapus semua catatan penelusuran, pembukaan, dan penutupan dokumen? Dokumen tetap disimpan dan aktivitas baru akan tetap dicatat.",
"bazaarInstalling": "Sedang memasang...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Tanpa batas",
"automationCollectionDepthCurrent": "Hanya dokumen saat ini",
"automationCollectionDepthLimited": "Kedalaman maksimum",
- "automationCollectionDepthTip": "Mencakup setiap dokumen yang dipilih; kedalaman hanya membatasi cakupan dokumen. Cakupan buku catatan dan dokumen digabungkan",
+ "automationCollectionDepthTip": "Kedalaman hanya membatasi cakupan dokumen. Cakupan buku catatan dan dokumen digabungkan",
"mindmapPasteChild": "Tempel sebagai simpul anak",
"mindmapPasteSibling": "Tempel sebagai simpul sejajar",
"embedBlockBreadcrumbParentPath": "Tampilkan jalur induk di remah roti",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 3a1079f862..b8027886c0 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Includi i documenti selezionati stessi",
+ "automationCollectionIncludeSelfTip": "Se disattivato, vengono monitorati solo i documenti discendenti; con Solo documento corrente, l’ambito del documento è vuoto",
"clearRecentDocs": "Cancella la cronologia dei documenti recenti",
"confirmClearRecentDocs": "Cancellare tutti i dati relativi alla consultazione, apertura e chiusura dei documenti? I documenti saranno conservati e le nuove attività continueranno a essere registrate.",
"bazaarInstalling": "Installazione in corso...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Illimitata",
"automationCollectionDepthCurrent": "Solo il documento corrente",
"automationCollectionDepthLimited": "Profondità massima",
- "automationCollectionDepthTip": "Include ogni documento selezionato; la profondità limita solo gli ambiti dei documenti. Gli ambiti dei taccuini e dei documenti vengono uniti",
+ "automationCollectionDepthTip": "La profondità limita solo gli ambiti dei documenti. Gli ambiti dei taccuini e dei documenti vengono uniti",
"mindmapPasteChild": "Incolla come nodo figlio",
"mindmapPasteSibling": "Incolla come nodo allo stesso livello",
"embedBlockBreadcrumbParentPath": "Mostra il percorso superiore nelle briciole di pane",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index ac65fc2657..d47339da7d 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "選択した文書自体を含める",
+ "automationCollectionIncludeSelfTip": "無効にすると子孫文書のみを監視します。「現在の文書のみ」と組み合わせると、その文書範囲は空になります",
"clearRecentDocs": "最近のドキュメント履歴を消去",
"confirmClearRecentDocs": "ドキュメントの閲覧、開いた履歴、閉じた履歴をすべて消去しますか?ドキュメントは保持され、今後の操作は引き続き記録されます。",
"bazaarInstalling": "インストール中...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "無制限",
"automationCollectionDepthCurrent": "現在の文書のみ",
"automationCollectionDepthLimited": "最大階層数",
- "automationCollectionDepthTip": "選択した各文書自体を含み、深さは文書の範囲にのみ適用されます。ノートブックと文書の範囲は和集合です",
+ "automationCollectionDepthTip": "深さは文書の範囲にのみ適用されます。ノートブックと文書の範囲は和集合です",
"mindmapPasteChild": "子ノードとして貼り付け",
"mindmapPasteSibling": "同階層のノードとして貼り付け",
"embedBlockBreadcrumbParentPath": "パンくずリストに文書の上位パスを表示",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index 19257fd3aa..88fac85c6f 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "선택한 문서 자체 포함",
+ "automationCollectionIncludeSelfTip": "끄면 하위 문서만 감시합니다. 현재 문서만과 함께 사용하면 해당 문서 범위가 비게 됩니다",
"clearRecentDocs": "최근 문서 기록 지우기",
"confirmClearRecentDocs": "문서를 열람하고 열고 닫은 기록을 모두 지우시겠습니까? 문서는 유지되며 새로운 활동은 계속 기록됩니다.",
"bazaarInstalling": "설치 중...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "제한 없음",
"automationCollectionDepthCurrent": "현재 문서만",
"automationCollectionDepthLimited": "최대 깊이",
- "automationCollectionDepthTip": "선택한 각 문서 자체를 포함하며 깊이는 문서 범위에만 적용됩니다. 노트북과 문서 범위는 합집합으로 결합됩니다",
+ "automationCollectionDepthTip": "깊이는 문서 범위에만 적용됩니다. 노트북과 문서 범위는 합집합으로 결합됩니다",
"mindmapPasteChild": "하위 노드로 붙여넣기",
"mindmapPasteSibling": "같은 수준의 노드로 붙여넣기",
"embedBlockBreadcrumbParentPath": "탐색 경로에 문서의 상위 경로 표시",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index 8f6637d24e..4770fa5291 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Geselecteerde documenten zelf opnemen",
+ "automationCollectionIncludeSelfTip": "Bij uitschakeling worden alleen onderliggende documenten gevolgd; met Alleen huidig document is het documentbereik leeg",
"clearRecentDocs": "Geschiedenis van recente documenten wissen",
"confirmClearRecentDocs": "Alle gegevens over het bekijken, openen en sluiten van documenten wissen? Documenten blijven behouden en nieuwe activiteiten worden nog steeds vastgelegd.",
"bazaarInstalling": "Installeren...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Onbeperkt",
"automationCollectionDepthCurrent": "Alleen huidig document",
"automationCollectionDepthLimited": "Maximale diepte",
- "automationCollectionDepthTip": "Omvat elk geselecteerd document zelf; de diepte geldt alleen voor documentbereiken. Notitieboek- en documentbereiken worden samengevoegd",
+ "automationCollectionDepthTip": "De diepte geldt alleen voor documentbereiken. Notitieboek- en documentbereiken worden samengevoegd",
"mindmapPasteChild": "Plakken als onderliggend knooppunt",
"mindmapPasteSibling": "Plakken als knooppunt op hetzelfde niveau",
"embedBlockBreadcrumbParentPath": "Bovenliggend pad in het kruimelpad tonen",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 13a392adbc..50233e8c65 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Uwzględnij same wybrane dokumenty",
+ "automationCollectionIncludeSelfTip": "Po wyłączeniu monitorowane są tylko dokumenty potomne; z opcją Tylko bieżący dokument zakres dokumentu jest pusty",
"clearRecentDocs": "Wyczyść historię ostatnich dokumentów",
"confirmClearRecentDocs": "Wyczyścić wszystkie wpisy dotyczące przeglądania, otwierania i zamykania dokumentów? Dokumenty zostaną zachowane, a nowe działania będą nadal rejestrowane.",
"bazaarInstalling": "Instalowanie...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Bez ograniczeń",
"automationCollectionDepthCurrent": "Tylko bieżący dokument",
"automationCollectionDepthLimited": "Maksymalna głębokość",
- "automationCollectionDepthTip": "Obejmuje każdy wybrany dokument; głębokość ogranicza tylko zakresy dokumentów. Zakresy notatników i dokumentów są łączone",
+ "automationCollectionDepthTip": "Głębokość ogranicza tylko zakresy dokumentów. Zakresy notatników i dokumentów są łączone",
"mindmapPasteChild": "Wklej jako węzeł podrzędny",
"mindmapPasteSibling": "Wklej jako węzeł równorzędny",
"embedBlockBreadcrumbParentPath": "Pokaż ścieżkę nadrzędną w nawigacji okruszkowej",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 957d032ab0..2ea09c7c4c 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Incluir os próprios documentos selecionados",
+ "automationCollectionIncludeSelfTip": "Quando desativado, apenas documentos descendentes são monitorados; com Apenas o documento atual, o escopo do documento fica vazio",
"clearRecentDocs": "Limpar histórico de documentos recentes",
"confirmClearRecentDocs": "Limpar todos os registros de consulta, abertura e fechamento de documentos? Os documentos serão mantidos e novas atividades continuarão sendo registradas.",
"bazaarInstalling": "Instalando...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Sem limite",
"automationCollectionDepthCurrent": "Somente o documento atual",
"automationCollectionDepthLimited": "Profundidade máxima",
- "automationCollectionDepthTip": "Inclui cada documento selecionado; a profundidade limita apenas os escopos de documentos. Os escopos de cadernos e documentos são unidos",
+ "automationCollectionDepthTip": "A profundidade limita apenas os escopos de documentos. Os escopos de cadernos e documentos são unidos",
"mindmapPasteChild": "Colar como nó filho",
"mindmapPasteSibling": "Colar como nó irmão",
"embedBlockBreadcrumbParentPath": "Mostrar o caminho superior na trilha de navegação",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 0a8c79f227..3bf578d967 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Включать сами выбранные документы",
+ "automationCollectionIncludeSelfTip": "При отключении отслеживаются только дочерние документы; вместе с параметром Только текущий документ область документа будет пустой",
"clearRecentDocs": "Очистить историю недавних документов",
"confirmClearRecentDocs": "Очистить все записи о просмотре, открытии и закрытии документов? Документы сохранятся, а новые действия будут по-прежнему записываться.",
"bazaarInstalling": "Установка...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Без ограничений",
"automationCollectionDepthCurrent": "Только текущий документ",
"automationCollectionDepthLimited": "Максимальная глубина",
- "automationCollectionDepthTip": "Включает каждый выбранный документ; глубина ограничивает только области документов. Области блокнотов и документов объединяются",
+ "automationCollectionDepthTip": "Глубина ограничивает только области документов. Области блокнотов и документов объединяются",
"mindmapPasteChild": "Вставить как дочерний узел",
"mindmapPasteSibling": "Вставить как узел того же уровня",
"embedBlockBreadcrumbParentPath": "Показывать родительский путь в навигационной цепочке",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index fb358d5f28..8413af36f4 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Zahrnúť samotné vybrané dokumenty",
+ "automationCollectionIncludeSelfTip": "Po vypnutí sa sledujú iba vnorené dokumenty; s možnosťou Iba aktuálny dokument je rozsah dokumentu prázdny",
"clearRecentDocs": "Vymazať históriu nedávnych dokumentov",
"confirmClearRecentDocs": "Vymazať všetky záznamy o prezeraní, otváraní a zatváraní dokumentov? Dokumenty zostanú zachované a nové činnosti sa budú naďalej zaznamenávať.",
"bazaarInstalling": "Inštaluje sa...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Bez obmedzenia",
"automationCollectionDepthCurrent": "Iba aktuálny dokument",
"automationCollectionDepthLimited": "Maximálna hĺbka",
- "automationCollectionDepthTip": "Zahŕňa každý vybraný dokument; hĺbka obmedzuje iba rozsahy dokumentov. Rozsahy zápisníkov a dokumentov sa zjednocujú",
+ "automationCollectionDepthTip": "Hĺbka obmedzuje iba rozsahy dokumentov. Rozsahy zápisníkov a dokumentov sa zjednocujú",
"mindmapPasteChild": "Prilepiť ako podradený uzol",
"mindmapPasteSibling": "Prilepiť ako uzol rovnakej úrovne",
"embedBlockBreadcrumbParentPath": "Zobraziť nadradenú cestu v navigačnej ceste",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index 8a06e175d4..98253336df 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Укључи саме изабране документе",
+ "automationCollectionIncludeSelfTip": "Када је искључено, прате се само подређени документи; уз Само тренутни документ, опсег документа је празан",
"clearRecentDocs": "Обриши историју недавних докумената",
"confirmClearRecentDocs": "Обрисати све записе о прегледању, отварању и затварању докумената? Документи ће бити сачувани, а нове активности ће се и даље бележити.",
"bazaarInstalling": "Инсталирање...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Неограничено",
"automationCollectionDepthCurrent": "Само тренутни документ",
"automationCollectionDepthLimited": "Највећа дубина",
- "automationCollectionDepthTip": "Укључује сваки изабрани документ; дубина ограничава само опсеге докумената. Опсези бележница и докумената се обједињују",
+ "automationCollectionDepthTip": "Дубина ограничава само опсеге докумената. Опсези бележница и докумената се обједињују",
"mindmapPasteChild": "Налепи као подређени чвор",
"mindmapPasteSibling": "Налепи као чвор истог нивоа",
"embedBlockBreadcrumbParentPath": "Прикажи надређену путању у навигационој путањи",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index c6893ce0e4..2d0727b8a3 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "รวมตัวเอกสารที่เลือกด้วย",
+ "automationCollectionIncludeSelfTip": "เมื่อปิดจะติดตามเฉพาะเอกสารลูกหลาน หากใช้ร่วมกับเฉพาะเอกสารปัจจุบัน ขอบเขตเอกสารนั้นจะว่าง",
"clearRecentDocs": "ล้างประวัติเอกสารล่าสุด",
"confirmClearRecentDocs": "ล้างบันทึกการดู เปิด และปิดเอกสารทั้งหมดหรือไม่? เอกสารจะยังคงอยู่และจะยังคงบันทึกกิจกรรมใหม่ต่อไป",
"bazaarInstalling": "กำลังติดตั้ง...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "ไม่จำกัด",
"automationCollectionDepthCurrent": "เฉพาะเอกสารปัจจุบัน",
"automationCollectionDepthLimited": "ความลึกสูงสุด",
- "automationCollectionDepthTip": "รวมตัวเอกสารแต่ละฉบับที่เลือกด้วย ความลึกจำกัดเฉพาะขอบเขตเอกสาร โดยรวมขอบเขตสมุดบันทึกและเอกสารเข้าด้วยกัน",
+ "automationCollectionDepthTip": "ความลึกจำกัดเฉพาะขอบเขตเอกสาร โดยรวมขอบเขตสมุดบันทึกและเอกสารเข้าด้วยกัน",
"mindmapPasteChild": "วางเป็นโหนดลูก",
"mindmapPasteSibling": "วางเป็นโหนดระดับเดียวกัน",
"embedBlockBreadcrumbParentPath": "แสดงเส้นทางหลักในเส้นทางนำทาง",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index 2e94411ed7..6b27636c29 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Seçilen belgelerin kendilerini dahil et",
+ "automationCollectionIncludeSelfTip": "Kapalıyken yalnızca alt belgeler izlenir; Yalnızca geçerli belge ile birlikte kullanıldığında belge kapsamı boş olur",
"clearRecentDocs": "Son belge geçmişini temizle",
"confirmClearRecentDocs": "Belgeleri görüntüleme, açma ve kapatmayla ilgili tüm kayıtlar temizlensin mi? Belgeler korunur ve yeni etkinlikler kaydedilmeye devam eder.",
"bazaarInstalling": "Yükleniyor...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Sınırsız",
"automationCollectionDepthCurrent": "Yalnızca mevcut belge",
"automationCollectionDepthLimited": "En fazla derinlik",
- "automationCollectionDepthTip": "Seçilen her belgenin kendisini içerir; derinlik yalnızca belge kapsamlarını sınırlar. Not defteri ve belge kapsamları birleştirilir",
+ "automationCollectionDepthTip": "Derinlik yalnızca belge kapsamlarını sınırlar. Not defteri ve belge kapsamları birleştirilir",
"mindmapPasteChild": "Alt düğüm olarak yapıştır",
"mindmapPasteSibling": "Aynı düzeyde düğüm olarak yapıştır",
"embedBlockBreadcrumbParentPath": "Gezinti yolunda üst yolu göster",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index e5f9071808..37457f97c7 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "Включати самі вибрані документи",
+ "automationCollectionIncludeSelfTip": "Після вимкнення відстежуються лише дочірні документи; разом із параметром Лише поточний документ область документа буде порожньою",
"clearRecentDocs": "Очистити історію нещодавніх документів",
"confirmClearRecentDocs": "Очистити всі записи про перегляд, відкриття та закриття документів? Документи залишаться, а нові дії й надалі записуватимуться.",
"bazaarInstalling": "Встановлення...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "Без обмежень",
"automationCollectionDepthCurrent": "Лише поточний документ",
"automationCollectionDepthLimited": "Максимальна глибина",
- "automationCollectionDepthTip": "Включає кожен вибраний документ; глибина обмежує лише області документів. Області записників і документів об’єднуються",
+ "automationCollectionDepthTip": "Глибина обмежує лише області документів. Області записників і документів об’єднуються",
"mindmapPasteChild": "Вставити як дочірній вузол",
"mindmapPasteSibling": "Вставити як вузол того самого рівня",
"embedBlockBreadcrumbParentPath": "Показувати батьківський шлях у навігаційному ланцюжку",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index b27a9148c9..a759dab1bf 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "包含所选文档自身",
+ "automationCollectionIncludeSelfTip": "关闭后仅监听子文档;与“仅当前文档”组合时,该文档范围为空",
"clearRecentDocs": "清空最近文档记录",
"confirmClearRecentDocs": "确定清空所有文档浏览、打开和关闭记录?文档将保留,后续操作仍会产生新记录。",
"bazaarInstalling": "正在安装...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "不限",
"automationCollectionDepthCurrent": "仅当前文档",
"automationCollectionDepthLimited": "最多层数",
- "automationCollectionDepthTip": "包含每个选中文档本身,深度仅限制文档范围;笔记本与文档范围取并集",
+ "automationCollectionDepthTip": "深度仅限制文档范围;笔记本与文档范围取并集",
"mindmapPasteChild": "粘贴为子节点",
"mindmapPasteSibling": "粘贴为同级节点",
"embedBlockBreadcrumbParentPath": "面包屑显示文档上层路径",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 7602113b44..dabdecf228 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,6 @@
{
+ "automationCollectionIncludeSelf": "包含所選文件本身",
+ "automationCollectionIncludeSelfTip": "關閉後僅監聽子文件;與「僅目前文件」組合時,該文件範圍為空",
"clearRecentDocs": "清空最近文件記錄",
"confirmClearRecentDocs": "確定清空所有文件瀏覽、開啟和關閉記錄?文件將保留,後續操作仍會產生新記錄。",
"bazaarInstalling": "正在安裝...",
@@ -12,7 +14,7 @@
"automationCollectionDepthUnlimited": "不限",
"automationCollectionDepthCurrent": "僅目前文件",
"automationCollectionDepthLimited": "最多層數",
- "automationCollectionDepthTip": "包含每個所選文件本身,深度僅限制文件範圍;筆記本與文件範圍取聯集",
+ "automationCollectionDepthTip": "深度僅限制文件範圍;筆記本與文件範圍取聯集",
"mindmapPasteChild": "貼上為子節點",
"mindmapPasteSibling": "貼上為同層級節點",
"embedBlockBreadcrumbParentPath": "麵包屑顯示文件上層路徑",
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 3e55f9b732..04d11bb926 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": "20261021135332"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -3855,7 +3855,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20261002224707-n5wvv5s",
- "updated": "20261016202856"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4526,7 +4526,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20261015141042-fm4qoja",
- "updated": "20261016202856"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4563,6 +4563,20 @@
}
]
},
+ {
+ "ID": "20261022092813-uxiousu",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261022092813-uxiousu",
+ "updated": "20261022092813"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Include selected documents themselves is enabled by default. Disable it to skip each selected document and all blocks inside it while continuing to watch descendant documents up to the configured depth. For example, disable this option and set depth to 1 to watch only direct child documents; combined with Current document only, each document scope is empty. This option is shared by the rule’s document scopes. Notebook scopes and other overlapping document scopes can still include the document because scopes are combined by union. Changing this option preserves existing entries and fields and does not backfill or remove entries automatically; use collection management to preview, collect, or review and remove entries. Excluding selected documents requires automation format 7; existing formats 1–6 remain readable, and older clients reject format 7 without rewriting the database."
+ }
+ ]
+ },
{
"ID": "20261021135332-1brkvpw",
"Type": "NodeParagraph",
@@ -4772,4 +4786,4 @@
}
}
]
-}
+}
\ No newline at end of file
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 eb64dc4e19..b3813faf50 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": "20261021135332"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -3855,7 +3855,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20261002224707-l8jclpi",
- "updated": "20261016202635"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4526,7 +4526,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20261015141042-j06dkl9",
- "updated": "20261016202635"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4563,6 +4563,20 @@
}
]
},
+ {
+ "ID": "20261022092813-5tt0fe5",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261022092813-5tt0fe5",
+ "updated": "20261022092813"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "“包含所选文档自身”默认开启。关闭后跳过每个所选文档及其内部所有块,子文档仍按设定深度监听。例如,关闭此选项并将深度设为 1,就只监听一级子文档;与“仅当前文档”组合时,各文档范围为空。同一规则的所有文档范围共用此设置。各范围仍取并集,笔记本范围或其他重叠文档范围仍可能包含该文档。修改此选项保留已有条目和字段,不自动补收或移出条目;可通过收集管理预览、收集,或检查并移出条目。排除所选文档自身需要自动化格式 7,既有格式 1–6 仍可读取,旧客户端会拒绝格式 7 且不改写数据库。"
+ }
+ ]
+ },
{
"ID": "20261021135332-xudc33f",
"Type": "NodeParagraph",
@@ -4772,4 +4786,4 @@
}
}
]
-}
+}
\ No newline at end of file
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 e03499f9ca..9d877b1b00 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": "20261021135332"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -3855,7 +3855,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20261002224707-f9wjtlr",
- "updated": "20261016202635"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4526,7 +4526,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20261015141042-sk1ubzp",
- "updated": "20261016202635"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4563,6 +4563,20 @@
}
]
},
+ {
+ "ID": "20261022092813-rlh1kqo",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261022092813-rlh1kqo",
+ "updated": "20261022092813"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "「包含所選文件本身」預設開啟。關閉後跳過每個所選文件及其內部所有區塊,子文件仍按設定深度監聽。例如,關閉此選項並將深度設為 1,就只監聽一級子文件;與「僅目前文件」組合時,各文件範圍為空。同一規則的所有文件範圍共用此設定。各範圍仍取聯集,筆記本範圍或其他重疊文件範圍仍可能包含該文件。修改此選項保留既有項目和欄位,不自動補收或移出項目;可透過收集管理預覽、收集,或檢查並移出項目。排除所選文件本身需要自動化格式 7,既有格式 1–6 仍可讀取,舊用戶端會拒絕格式 7 且不改寫資料庫。"
+ }
+ ]
+ },
{
"ID": "20261021135332-36rh1ee",
"Type": "NodeParagraph",
@@ -4764,4 +4778,4 @@
]
}
]
-}
+}
\ No newline at end of file
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 1730bbcc6d..3ee8daf356 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": "20261021135332"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -3865,7 +3865,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20261002224707-2ctdjhm",
- "updated": "20261016202856"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4536,7 +4536,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20261015141042-aj3t5af",
- "updated": "20261016202856"
+ "updated": "20261022092813"
},
"Children": [
{
@@ -4573,6 +4573,20 @@
}
]
},
+ {
+ "ID": "20261022092813-g7jbf4j",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20261022092813-g7jbf4j",
+ "updated": "20261022092813"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "「選択した文書自体を含める」は既定で有効です。無効にすると、選択した各文書とその内部のすべてのブロックを除外し、子孫文書は設定した深さまで監視します。例えば、この設定を無効にして深さを 1 にすると、直接の子文書のみを監視します。「現在の文書のみ」と組み合わせると、各文書範囲は空になります。この設定はルール内の文書範囲すべてに共通です。範囲は和集合のままなので、ノートブックの範囲や重なる別の文書範囲によって、その文書が含まれる場合があります。設定を変更しても既存の項目とフィールドは維持され、自動で追加収集や除去は行いません。収集管理でプレビュー、収集、または確認と除去を行ってください。選択した文書自体の除外には自動化形式 7 が必要です。既存の形式 1–6 は引き続き読み取れますが、古いクライアントはデータベースを書き換えずに形式 7 を拒否します。"
+ }
+ ]
+ },
{
"ID": "20261021135332-1xj7aht",
"Type": "NodeParagraph",
@@ -4770,4 +4784,4 @@
]
}
]
-}
+}
\ No newline at end of file
diff --git a/app/src/protyle/render/av/automation.test.ts b/app/src/protyle/render/av/automation.test.ts
index 875b701a5c..57fa94d42f 100644
--- a/app/src/protyle/render/av/automation.test.ts
+++ b/app/src/protyle/render/av/automation.test.ts
@@ -11,7 +11,7 @@ const compiled = transpileModule(readFileSync("src/protyle/render/av/automation.
compilerOptions: {module: ModuleKind.CommonJS, target: ScriptTarget.ES2022},
}).outputText;
-test("collection autosave versions document depth and attribute name modes with independent undo snapshots", async () => {
+test("collection autosave versions document depth, attribute names and self exclusion with independent undo snapshots", async () => {
const transactions: Array<{perform: IOperation[], undo: IOperation[]}> = [];
let source: AVAutomationBlockSourceInput;
let save: () => void;
@@ -70,6 +70,19 @@ test("collection autosave versions document depth and attribute name modes with
source.attributes = [];
save();
assert.equal(JSON.parse(JSON.stringify(transactions.at(-1).perform[0].data)).spec, 6);
+ source.includeSelectedDocuments = false;
+ save();
+ const excluded = JSON.parse(JSON.stringify(transactions.at(-1)));
+ assert.equal(excluded.perform[0].data.spec, 7);
+ assert.equal(excluded.perform[0].data.rules[0].blockSource.includeSelectedDocuments, false);
+ assert.equal(excluded.undo[0].data.spec, 6);
+ assert.equal(excluded.undo[0].data.rules[0].blockSource.includeSelectedDocuments, undefined);
+ delete source.includeSelectedDocuments;
+ save();
+ const included = JSON.parse(JSON.stringify(transactions.at(-1)));
+ assert.equal(included.perform[0].data.spec, 7);
+ assert.equal(included.perform[0].data.rules[0].blockSource.includeSelectedDocuments, undefined);
+ assert.deepEqual(included.undo, excluded.perform);
});
test("automation settings reject readonly, publishing and historical editors before fetching data", async () => {
diff --git a/app/src/protyle/render/av/automation.ts b/app/src/protyle/render/av/automation.ts
index c1925a1016..e6c76c1034 100644
--- a/app/src/protyle/render/av/automation.ts
+++ b/app/src/protyle/render/av/automation.ts
@@ -213,7 +213,8 @@ export const openAutomationMenu = async (options: {
const usesDocumentDepth = rules.some(rule => rule.blockSource?.documentDepth != null);
const usesAttributeNameMatch = rules.some(rule => rule.blockSource?.attributes?.some(attr =>
attr?.nameOperator && attr.nameOperator !== "equals"));
- const next = {spec: Math.max(previous.spec, usesAttributeNameMatch ? 6 : usesDocumentDepth ? 5 : usesTagTarget ? 4 : usesSourceOptions ? 3 : usesTemplates ? 2 : 1), rules: clone(rules)};
+ const excludesSelectedDocuments = rules.some(rule => rule.blockSource?.includeSelectedDocuments === false);
+ const next = {spec: Math.max(previous.spec, excludesSelectedDocuments ? 7 : usesAttributeNameMatch ? 6 : usesDocumentDepth ? 5 : usesTagTarget ? 4 : usesSourceOptions ? 3 : usesTemplates ? 2 : 1), rules: clone(rules)};
if (JSON.stringify(next) === JSON.stringify(previous)) {
return;
}
diff --git a/app/src/protyle/render/av/blockCollection.test.ts b/app/src/protyle/render/av/blockCollection.test.ts
index beed4b71ab..b3903b9e79 100644
--- a/app/src/protyle/render/av/blockCollection.test.ts
+++ b/app/src/protyle/render/av/blockCollection.test.ts
@@ -72,6 +72,7 @@ const browserCases = async (sourceCode: string, languages: Record<string, string
api.mountBlockCollectionSource(host, source, {notebookId: "box"} as IProtyle, save, () => {});
await tick();
check.equal(host.querySelector("[data-depth-mode]"), null);
+ check.equal(host.querySelector("[data-include-selected-documents]"), null);
host.querySelector<HTMLButtonElement>("[data-scope]").click();
addScope(["/doc.sy"], ["box"]);
await tick();
@@ -84,9 +85,15 @@ const browserCases = async (sourceCode: string, languages: Record<string, string
};
check.match(host.querySelector("[data-depth-mode]").textContent, /Unlimited/);
check.equal(source.documentDepth, undefined);
+ const include = host.querySelector<HTMLInputElement>("[data-include-selected-documents]");
+ check.equal(include.checked, true);
+ include.click();
+ check.equal(source.includeSelectedDocuments, false);
+ check.equal(saves.at(-1).includeSelectedDocuments, false);
await choose(languages.automationCollectionDepthCurrent);
check.equal(source.documentDepth, 0);
check.equal(host.querySelector("[data-document-depth]"), null);
+ check.equal(host.querySelector<HTMLInputElement>("[data-include-selected-documents]").checked, false);
await choose(languages.automationCollectionDepthLimited);
check.equal(source.documentDepth, 1);
const input = host.querySelector<HTMLInputElement>("[data-document-depth]");
@@ -117,13 +124,17 @@ const browserCases = async (sourceCode: string, languages: Record<string, string
check.match(host.querySelector("[data-depth-mode]").textContent, /Current document only/);
check.equal(source.documentDepth, 0);
check.deepEqual(source.notebookIDs, ["box"]);
+ check.equal(host.querySelector<HTMLInputElement>("[data-include-selected-documents]").checked, false);
+ host.querySelector<HTMLInputElement>("[data-include-selected-documents]").click();
+ check.equal(source.includeSelectedDocuments, undefined);
+ check.equal(saves.at(-1).includeSelectedDocuments, undefined);
host.remove();
}
menu.remove();
return "Collection depth DOM cases passed";
};
-test("collection depth controls preserve zero, validate edits and support narrow layouts", {
+test("collection depth and self inclusion controls preserve values, validate edits and support narrow layouts", {
skip: process.platform === "linux" && !process.env.DISPLAY && !process.env.WAYLAND_DISPLAY,
timeout: 45000,
}, async () => {
diff --git a/app/src/protyle/render/av/blockCollection.ts b/app/src/protyle/render/av/blockCollection.ts
index cd55b3239d..d474443caa 100644
--- a/app/src/protyle/render/av/blockCollection.ts
+++ b/app/src/protyle/render/av/blockCollection.ts
@@ -41,7 +41,8 @@ export const mountBlockCollectionSource = (host: HTMLElement, source: AVAutomati
<div class="av__automation-control" data-scope-control><span class="av__automation-control-label">${lang.automationCollectionScope}</span>
${notebooks.length || documents.length ? `<div class="av__automation-source-list">${notebooks.map((id, i) => `<div class="av__automation-row av__automation-source-row"><svg class="block__logoicon ft__on-surface"><use xlink:href="#iconNotebook"></use></svg><span class="fn__flex-1 ft__breakword av__automation-notebook-name">${escapeHtml(window.siyuan.notebooks.find(box => box.id === id)?.name || id)}</span>${removeButton("notebook", i)}</div>`).join("")}${documents.map((id, i) => `<div class="av__automation-row av__automation-source-row"><span class="b3-list-item__icon fn__pointer popover__block" data-id="${escapeAttr(id)}"><svg><use xlink:href="#iconFile"></use></svg></span><button type="button" class="b3-button b3-button--cancel b3-button--wrap fn__flex-1 av__automation-source-action av__automation-document-name" data-preview-document="${escapeAttr(id)}">${escapeHtml(names.get(id) || id)}</button>${removeButton("document", i)}</div>`).join("")}</div>` : ""}
<button type="button" class="b3-button b3-button--cancel b3-button--wrap av__automation-source-action" data-scope><svg><use xlink:href="#iconAdd"></use></svg><span>${escapeHtml(`${lang.addAttr} - ${lang.automationCollectionScope}`)}</span></button></div>
-${documents.length ? `<div class="av__automation-control"><div class="av__automation-row"><span class="av__automation-control-label fn__flex-1">${lang.automationCollectionDepth}</span><button type="button" class="b3-button b3-button--cancel b3-button--wrap av__automation-source-action" data-depth-mode aria-label="${escapeAttr(lang.automationCollectionDepth)}"><span>${depthLabels[depthMode()]}</span><svg><use xlink:href="#iconDown"></use></svg></button></div>${depthMode() === "limited" ? `<input type="number" class="b3-text-field fn__block" min="1" step="1" required data-document-depth value="${source.documentDepth}" aria-label="${escapeAttr(lang.automationCollectionDepth)}">` : ""}<div class="ft__on-surface ft__smaller av__automation-tip">${lang.automationCollectionDepthTip}</div></div>` : ""}
+${documents.length ? `<div class="av__automation-control"><label class="av__automation-row"><span class="fn__flex-1">${lang.automationCollectionIncludeSelf}</span><input type="checkbox" class="b3-switch" data-include-selected-documents${source.includeSelectedDocuments !== false ? " checked" : ""}></label><div class="ft__on-surface ft__smaller av__automation-tip">${lang.automationCollectionIncludeSelfTip}</div></div>
+<div class="av__automation-control"><div class="av__automation-row"><span class="av__automation-control-label fn__flex-1">${lang.automationCollectionDepth}</span><button type="button" class="b3-button b3-button--cancel b3-button--wrap av__automation-source-action" data-depth-mode aria-label="${escapeAttr(lang.automationCollectionDepth)}"><span>${depthLabels[depthMode()]}</span><svg><use xlink:href="#iconDown"></use></svg></button></div>${depthMode() === "limited" ? `<input type="number" class="b3-text-field fn__block" min="1" step="1" required data-document-depth value="${source.documentDepth}" aria-label="${escapeAttr(lang.automationCollectionDepth)}">` : ""}<div class="ft__on-surface ft__smaller av__automation-tip">${lang.automationCollectionDepthTip}</div></div>` : ""}
</div>`;
host.firstElementChild.append(conditions);
onResize();
@@ -102,6 +103,12 @@ ${documents.length ? `<div class="av__automation-control"><div class="av__automa
});
host.addEventListener("change", event => {
const input = event.target as HTMLInputElement;
+ if (input.matches("[data-include-selected-documents]")) {
+ if (input.checked) { delete source.includeSelectedDocuments; }
+ else { source.includeSelectedDocuments = false; }
+ save();
+ return;
+ }
if (!input.matches("[data-document-depth]")) { return; }
const value = Number(input.value);
input.setCustomValidity(input.value.trim() && Number.isSafeInteger(value) && value >= 1 ? "" : lang.invalid);
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index 890c717de3..fe2dcbabeb 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -260,9 +260,9 @@ export type AVAutomationBlockAttribute = { "name": string; "nameOperator"?: "" |
export type AVAutomationBlockAttributeInput = { "name": string; "nameOperator"?: "" | "equals" | "contains" | "regex"; "operator": "equals" | "contains" | "exists" | "notExists"; "value"?: string; };
-export type AVAutomationBlockSource = { "attributeMatch"?: "" | "and" | "or"; "attributes"?: Array<AVAutomationBlockAttribute | null>; "documentDepth"?: number; "documentIDs"?: Array<string>; "notebookIDs"?: Array<string>; "tagMatch"?: "" | "and" | "or"; "tagTarget"?: "" | "block" | "container"; "tags"?: Array<string>; "types"?: Array<string>; };
+export type AVAutomationBlockSource = { "attributeMatch"?: "" | "and" | "or"; "attributes"?: Array<AVAutomationBlockAttribute | null>; "documentDepth"?: number; "documentIDs"?: Array<string>; "includeSelectedDocuments"?: boolean; "notebookIDs"?: Array<string>; "tagMatch"?: "" | "and" | "or"; "tagTarget"?: "" | "block" | "container"; "tags"?: Array<string>; "types"?: Array<string>; };
-export type AVAutomationBlockSourceInput = { "attributeMatch"?: "" | "and" | "or"; "attributes"?: Array<AVAutomationBlockAttributeInput | null>; "documentDepth"?: number | null; "documentIDs"?: Array<string>; "notebookIDs"?: Array<string>; "tagMatch"?: "" | "and" | "or"; "tagTarget"?: "" | "block" | "container"; "tags"?: Array<string>; "types"?: Array<string>; };
+export type AVAutomationBlockSourceInput = { "attributeMatch"?: "" | "and" | "or"; "attributes"?: Array<AVAutomationBlockAttributeInput | null>; "documentDepth"?: number | null; "documentIDs"?: Array<string>; "includeSelectedDocuments"?: boolean | null; "notebookIDs"?: Array<string>; "tagMatch"?: "" | "and" | "or"; "tagTarget"?: "" | "block" | "container"; "tags"?: Array<string>; "types"?: Array<string>; };
export type AVAutomationConfig = { "rules": Array<AVAutomationRule | null> | null; "spec": number; };
@@ -8199,12 +8199,14 @@ export interface APIPOSTRoutes {
/**
* move 操作支持 nextID,将块移到该同级锚点之前,优先于 previousID 和 parentID。
* 移动保留折叠标题下辖块顺序及源块身份,不将整列表自动拆成列表项;moveBlock 接口不接受 nextID。
- * 数据库自动化通过 setAttrViewAutomations 操作整体保存,配置 spec 为 1 至 6,所有视图共享数据库级规则。
+ * 数据库自动化通过 setAttrViewAutomations 操作整体保存,配置 spec 为 1 至 7,所有视图共享数据库级规则。
* blockSource.types 主类型包含全部子类型;spec 3 可指定 h:h1 至 h:h6、l:u/o/t、i:u/o/t、callout:类型名。
* blockSource 的 tagMatch、attributeMatch 缺省为 and;spec 3 支持各组独立设置 or,空组不限制,组间仍为 and。
* spec 4 的 blockSource.tagTarget 支持 block(标签所在块)和 container(最近合格容器),缺省保持原行为。
* spec 5 的 blockSource.documentDepth 限制各文档范围的子文档深度,0 仅自身,1 包含自身及一级子文档。
* spec 6 的属性 nameOperator 支持 contains 和 Go regex;缺省或 equals 保持精确名称匹配,值条件独立。
+ * spec 7 支持 blockSource.includeSelectedDocuments=false,排除所选文档及其内部块,子文档仍按深度匹配;缺省、null 或 true 保持包含自身。
+ * 排除自身不影响其他范围的并集;与 documentDepth=0 组合时对应文档范围为空。配置变更保留条目和字段,不自动补收或清理。
* 深度缺省或 null 不限,不影响笔记本范围,各范围仍取并集;修改不自动清理或补收已有内容。
* 容器按类型及属性条件选择并去重;全部标签须在同一个来源块中,文档容器须显式选择 d。
* 类型和属性始终筛选最终对象;默认首个内容块优先归属合格列表项,每次标签命中只选择一个对象。
diff --git a/docs/API.ja.md b/docs/API.ja.md
index aa30f2c95e..cd974bbe28 100644
--- a/docs/API.ja.md
+++ b/docs/API.ja.md
@@ -2213,7 +2213,7 @@ if (response.code === 0 && response.data) {
* `data.av`: 完全な `AttributeView` 定義——フィールド(`keyValues`)、フィールド順序(`keyIDs`、`null` の場合あり)、および全ビューの生のレイアウト設定(`table`/`gallery`/`kanban`)とアイテム順序(`itemIds`)。互換性フィールド `viewID` は最初に利用可能なビューから算出され、永続化されません。レンダリング後の行やページングは含まれないため、計算後の行データが必要な場合は [レンダリング](#レンダリング) を使用してください
- * `data.av.automations` は省略可能で、データベース全体のルール(`spec: 1`~`6`)を保持します。`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 を拒否します。
+ * `data.av.automations` は省略可能で、データベース全体のルール(`spec: 1`~`7`)を保持します。`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 を拒否します。
### 主キー値を取得
diff --git a/docs/API.md b/docs/API.md
index 2d19281fd2..7cb86a3166 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -2223,7 +2223,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 `6`). 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.
+ * `data.av.automations` optionally contains database-wide rules (`spec: 1` through `7`). 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.
### Get primary key values
diff --git a/docs/API.zh-CN.md b/docs/API.zh-CN.md
index 43bb0c4101..a08d4a3995 100644
--- a/docs/API.zh-CN.md
+++ b/docs/API.zh-CN.md
@@ -2219,7 +2219,7 @@ if (response.code === 0 && response.data) {
* `data.av`: 完整的 `AttributeView` 定义——字段(`keyValues`)、字段顺序(`keyIDs`,可能为 `null`),以及所有视图的原始布局配置(`table`/`list`/`gallery`/`kanban`)和条目顺序(`itemIds`)。兼容字段 `viewID` 动态取第一个可用视图,不会持久化。返回值不含渲染后的行或分页;需要计算后的行数据请使用 [渲染](#渲染)
- * `data.av.automations` 可选,保存数据库共享的规则(`spec: 1` 至 `6`)。`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 且不改写数据库。
+ * `data.av.automations` 可选,保存数据库共享的规则(`spec: 1` 至 `7`)。`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 且不改写数据库。
### 获取主键值
diff --git a/kernel/api/av_contract_automation.go b/kernel/api/av_contract_automation.go
index a2ca20af38..41d529ae33 100644
--- a/kernel/api/av_contract_automation.go
+++ b/kernel/api/av_contract_automation.go
@@ -76,8 +76,9 @@ func toContractAVAutomationBlockSource(source *av.AutomationBlockSource) *apicon
return nil
}
return &apicontract.AVAutomationBlockSource{NotebookIDs: source.NotebookIDs, DocumentIDs: source.DocumentIDs,
- DocumentDepth: source.DocumentDepth,
- TagMatch: source.TagMatch, TagTarget: source.TagTarget, AttributeMatch: source.AttributeMatch,
+ DocumentDepth: source.DocumentDepth,
+ IncludeSelectedDocuments: source.IncludeSelectedDocuments,
+ TagMatch: source.TagMatch, TagTarget: source.TagTarget, AttributeMatch: source.AttributeMatch,
Types: source.Types, Tags: source.Tags, Attributes: avContractSlice(source.Attributes, func(attr *av.AutomationBlockAttribute) *apicontract.AVAutomationBlockAttribute {
if attr == nil {
return nil
diff --git a/kernel/api/contract_av_automation_test.go b/kernel/api/contract_av_automation_test.go
index a3c344de6a..481226553e 100644
--- a/kernel/api/contract_av_automation_test.go
+++ b/kernel/api/contract_av_automation_test.go
@@ -290,6 +290,28 @@ func TestAVContractAutomationWrites(t *testing.T) {
}
}
previousAttributes := collection.BlockSource.Attributes
+ for _, include := range []*bool{nil, new(true), new(false)} {
+ collection.BlockSource.IncludeSelectedDocuments = include
+ if err = model.PerformAttributeViewOperations([]*model.Operation{{Action: "setAttrViewAutomations", AvID: database.ID,
+ Data: &av.AutomationConfig{Spec: 7, Rules: []*av.AutomationRule{collection}}}}); err != nil {
+ t.Fatal(err)
+ }
+ response = callAttributeViewContextFilterAPI(t, "/api/av/getAttributeView", map[string]any{"id": database.ID}, getAttributeView)
+ requireAPIContract(t, http.MethodPost, "/api/av/getAttributeView", response)
+ readBack.Data.AV.Automations = av.AutomationConfig{}
+ if err = json.Unmarshal(response.Body.Bytes(), &readBack); err != nil {
+ t.Fatal(err)
+ }
+ got := readBack.Data.AV.Automations.Rules[0].BlockSource.IncludeSelectedDocuments
+ if readBack.Data.AV.Automations.Spec != 7 || (got == nil) != (include == nil) || got != nil && *got != *include {
+ t.Fatalf("selected document inclusion contract round trip: %s", response.Body.String())
+ }
+ }
+ if err = model.PerformAttributeViewOperations([]*model.Operation{{Action: "setAttrViewAutomations", AvID: database.ID,
+ Data: &av.AutomationConfig{Spec: 6, Rules: []*av.AutomationRule{collection}}}}); err == nil {
+ t.Fatal("scope exclusion saved without its required format")
+ }
+ collection.BlockSource.IncludeSelectedDocuments = nil
for _, mode := range []string{"equals", "contains", "regex"} {
attr := &av.AutomationBlockAttribute{Name: "custom-state", NameOperator: mode, Operator: "exists"}
if mode == "contains" {
diff --git a/kernel/apicontract/av_automation.go b/kernel/apicontract/av_automation.go
index 423fa6b9f1..a09fa7c21f 100644
--- a/kernel/apicontract/av_automation.go
+++ b/kernel/apicontract/av_automation.go
@@ -1,7 +1,7 @@
package apicontract
// AVAutomationConfig 通过 setAttrViewAutomations 事务操作整体保存,所有镜像和视图共享。
-// spec 为 1 至 6;模板赋值至少使用 2,块子类型至少使用 3,标签收集对象至少使用 4,有限文档深度至少使用 5。
+// spec 为 1 至 7;模板赋值至少使用 2,块子类型至少使用 3,标签收集对象至少使用 4,有限文档深度至少使用 5。
// 属性名包含或正则匹配至少使用 6;缺省或 equals 保持既有的精确匹配。
// 旧读取器拒绝新版本,防止配置静默丢失。
// 缺省配置不会触发自动化,既有版本的主类型匹配含义不变。
@@ -34,6 +34,9 @@ type AVAutomationRule struct {
// documentDepth 缺省或 null 表示不限;非负整数限制每个所选文档的最大子文档深度,0 仅自身,1 包含自身及一级子文档。
// 深度按文档 ID 路径相对计算,不限制文档内部块层级;不影响笔记本范围,重叠范围仍取并集;有限深度要求 spec 5。
// 修改深度保留已有条目及字段,不自动补收存量;预览、显式收集和清理检查使用相同范围判断。
+// includeSelectedDocuments 缺省、null 或 true 保持包含每个所选文档自身;false(至少 spec 7)排除其自身及内部块,子文档仍按深度匹配。
+// 此选项不影响笔记本范围或其他重叠文档范围;各范围仍取并集。false 与 documentDepth 0 组合时,对应文档范围为空。
+// 修改此选项保留已有条目和字段,不自动补收或清理;实时收集、预览、显式收集和清理检查使用相同判断。
// 类型组取或关系;标签和属性组各自通过 tagMatch、attributeMatch 选择 and(缺省)或 or(至少 spec 3)。
// 各条件组之间取与关系,空组不限制;标签精确匹配,全部标签必须出现在同一个来源块中。
// types 为空不限制类型;主类型匹配其全部子类型,类型之间取或关系。
@@ -49,15 +52,16 @@ type AVAutomationRule struct {
// 既有条目再次匹配时仍保留其字段;主动移出条目后再次匹配才新建并初始化,撤销重做恢复原事务快照。
// 配置变更、启用规则、导入、同步和历史恢复不补收存量内容,也不串联触发其他自动化。
type AVAutomationBlockSource struct {
- NotebookIDs []string `json:"notebookIDs,omitempty" api:"optional"`
- DocumentIDs []string `json:"documentIDs,omitempty" api:"optional"`
- DocumentDepth *int `json:"documentDepth,omitempty" api:"optional"`
- Types []string `json:"types,omitempty" api:"optional"`
- Tags []string `json:"tags,omitempty" api:"optional"`
- Attributes []*AVAutomationBlockAttribute `json:"attributes,omitempty" api:"optional"`
- TagMatch string `json:"tagMatch,omitempty" api:"optional,enum=|and|or"`
- TagTarget string `json:"tagTarget,omitempty" api:"optional,enum=|block|container"`
- AttributeMatch string `json:"attributeMatch,omitempty" api:"optional,enum=|and|or"`
+ NotebookIDs []string `json:"notebookIDs,omitempty" api:"optional"`
+ DocumentIDs []string `json:"documentIDs,omitempty" api:"optional"`
+ DocumentDepth *int `json:"documentDepth,omitempty" api:"optional"`
+ IncludeSelectedDocuments *bool `json:"includeSelectedDocuments,omitempty" api:"optional"`
+ Types []string `json:"types,omitempty" api:"optional"`
+ Tags []string `json:"tags,omitempty" api:"optional"`
+ Attributes []*AVAutomationBlockAttribute `json:"attributes,omitempty" api:"optional"`
+ TagMatch string `json:"tagMatch,omitempty" api:"optional,enum=|and|or"`
+ TagTarget string `json:"tagTarget,omitempty" api:"optional,enum=|block|container"`
+ AttributeMatch string `json:"attributeMatch,omitempty" api:"optional,enum=|and|or"`
}
// AVAutomationBlockAttribute 仅匹配 custom- 前缀的自定义属性,名称与值必须在同一条属性上满足条件。
diff --git a/kernel/apicontract/av_test.go b/kernel/apicontract/av_test.go
index afbae55fa2..bcdf80b7b0 100644
--- a/kernel/apicontract/av_test.go
+++ b/kernel/apicontract/av_test.go
@@ -40,6 +40,34 @@ func TestAVAutomationDocumentDepthContract(t *testing.T) {
}
}
+func TestAVAutomationSelectedDocumentsContract(t *testing.T) {
+ endpoint := Endpoint[AVAutomationBlockSource, Null]{definition: Definition{Path: "/test", Body: JSONBody}}
+ for _, test := range []struct {
+ body string
+ include *bool
+ }{
+ {`{}`, nil}, {`{"includeSelectedDocuments":null}`, nil},
+ {`{"includeSelectedDocuments":true}`, new(true)}, {`{"includeSelectedDocuments":false}`, new(false)},
+ } {
+ value, err := endpoint.Decode(strings.NewReader(test.body))
+ if err != nil || (value.IncludeSelectedDocuments == nil) != (test.include == nil) ||
+ value.IncludeSelectedDocuments != nil && *value.IncludeSelectedDocuments != *test.include {
+ t.Fatalf("include selected documents %s: %+v %v", test.body, value, err)
+ }
+ raw, _ := json.Marshal(value)
+ var output map[string]json.RawMessage
+ if err = json.Unmarshal(raw, &output); err != nil ||
+ (output["includeSelectedDocuments"] != nil) != (test.include != nil) {
+ t.Fatalf("include selected documents presence lost: %s %v", raw, err)
+ }
+ }
+ for _, body := range []string{`{"includeSelectedDocuments":0}`, `{"includeSelectedDocuments":"false"}`, `{"includeSelectedDocuments":[]}`} {
+ if _, err := endpoint.Decode(strings.NewReader(body)); err == nil {
+ t.Fatalf("invalid inclusion type accepted: %s", body)
+ }
+ }
+}
+
func TestAVAutomationAttributeNameContract(t *testing.T) {
endpoint := Endpoint[AVAutomationBlockAttribute, Null]{definition: Definition{Path: "/test", Body: JSONBody}}
for _, mode := range []string{"", "equals", "contains", "regex"} {
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index 9370b898c0..4d14aced80 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -1585,12 +1585,14 @@ var SystemAddUIProcess = define[EmptyRequest, Null]("addUIProcess", "/api/system
// move 操作支持 nextID,将块移到该同级锚点之前,优先于 previousID 和 parentID。
// 移动保留折叠标题下辖块顺序及源块身份,不将整列表自动拆成列表项;moveBlock 接口不接受 nextID。
-// 数据库自动化通过 setAttrViewAutomations 操作整体保存,配置 spec 为 1 至 6,所有视图共享数据库级规则。
+// 数据库自动化通过 setAttrViewAutomations 操作整体保存,配置 spec 为 1 至 7,所有视图共享数据库级规则。
// blockSource.types 主类型包含全部子类型;spec 3 可指定 h:h1 至 h:h6、l:u/o/t、i:u/o/t、callout:类型名。
// blockSource 的 tagMatch、attributeMatch 缺省为 and;spec 3 支持各组独立设置 or,空组不限制,组间仍为 and。
// spec 4 的 blockSource.tagTarget 支持 block(标签所在块)和 container(最近合格容器),缺省保持原行为。
// spec 5 的 blockSource.documentDepth 限制各文档范围的子文档深度,0 仅自身,1 包含自身及一级子文档。
// spec 6 的属性 nameOperator 支持 contains 和 Go regex;缺省或 equals 保持精确名称匹配,值条件独立。
+// spec 7 支持 blockSource.includeSelectedDocuments=false,排除所选文档及其内部块,子文档仍按深度匹配;缺省、null 或 true 保持包含自身。
+// 排除自身不影响其他范围的并集;与 documentDepth=0 组合时对应文档范围为空。配置变更保留条目和字段,不自动补收或清理。
// 深度缺省或 null 不限,不影响笔记本范围,各范围仍取并集;修改不自动清理或补收已有内容。
// 容器按类型及属性条件选择并去重;全部标签须在同一个来源块中,文档容器须显式选择 d。
// 类型和属性始终筛选最终对象;默认首个内容块优先归属合格列表项,每次标签命中只选择一个对象。
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 736a5f020f..c09015cf56 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -6767,6 +6767,9 @@
"type": "string"
}
},
+ "includeSelectedDocuments": {
+ "type": "boolean"
+ },
"notebookIDs": {
"type": "array",
"items": {
@@ -6844,6 +6847,16 @@
"type": "string"
}
},
+ "includeSelectedDocuments": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"notebookIDs": {
"type": "array",
"items": {
diff --git a/kernel/av/automation.go b/kernel/av/automation.go
index ef34d71650..9b0b6d41c1 100644
--- a/kernel/av/automation.go
+++ b/kernel/av/automation.go
@@ -27,17 +27,19 @@ type AutomationRule struct {
NotifyOnSuccess *bool `json:"notifyOnSuccess,omitempty"`
}
-// AutomationBlockSource 的范围取并集,各类条件取交集;文档深度缺省不限,0 仅包含文档本身。
+// AutomationBlockSource 的范围取并集,各类条件取交集;文档深度缺省不限,0 仅自身。
+// 所选文档自身缺省包含;显式关闭时跳过该文档及内部块,子文档仍按深度匹配。
type AutomationBlockSource struct {
- NotebookIDs []string `json:"notebookIDs,omitempty"`
- DocumentIDs []string `json:"documentIDs,omitempty"`
- DocumentDepth *int `json:"documentDepth,omitempty"`
- Types []string `json:"types,omitempty"`
- Tags []string `json:"tags,omitempty"`
- Attributes []*AutomationBlockAttribute `json:"attributes,omitempty"`
- TagMatch string `json:"tagMatch,omitempty"`
- TagTarget string `json:"tagTarget,omitempty"`
- AttributeMatch string `json:"attributeMatch,omitempty"`
+ NotebookIDs []string `json:"notebookIDs,omitempty"`
+ DocumentIDs []string `json:"documentIDs,omitempty"`
+ DocumentDepth *int `json:"documentDepth,omitempty"`
+ IncludeSelectedDocuments *bool `json:"includeSelectedDocuments,omitempty"`
+ Types []string `json:"types,omitempty"`
+ Tags []string `json:"tags,omitempty"`
+ Attributes []*AutomationBlockAttribute `json:"attributes,omitempty"`
+ TagMatch string `json:"tagMatch,omitempty"`
+ TagTarget string `json:"tagTarget,omitempty"`
+ AttributeMatch string `json:"attributeMatch,omitempty"`
}
type AutomationBlockAttribute struct {
@@ -56,7 +58,10 @@ func (source *AutomationBlockSource) MatchesDocument(notebookID, documentID, doc
}
for _, id := range source.DocumentIDs {
if documentID == id {
- return true
+ if source.IncludeSelectedDocuments == nil || *source.IncludeSelectedDocuments {
+ return true
+ }
+ continue
}
if _, suffix, found := strings.Cut(documentPath, "/"+id+"/"); found &&
(source.DocumentDepth == nil || strings.Count(suffix, "/")+1 <= *source.DocumentDepth) {
@@ -89,6 +94,9 @@ func IsAutomationBlockType(value string) bool {
func (rule *AutomationRule) RequiredSpec() int {
ret := 1
if rule.BlockSource != nil {
+ if rule.BlockSource.IncludeSelectedDocuments != nil && !*rule.BlockSource.IncludeSelectedDocuments {
+ return 7
+ }
for _, attr := range rule.BlockSource.Attributes {
if attr != nil && attr.NameOperator != "" && attr.NameOperator != "equals" {
return 6
@@ -126,7 +134,7 @@ func (config *AutomationConfig) ValidateSpec() error {
if config == nil {
return nil
}
- if config.Spec < 1 || config.Spec > 6 {
+ if config.Spec < 1 || config.Spec > 7 {
return fmt.Errorf("unsupported database automation specification [%d]", config.Spec)
}
for _, rule := range config.Rules {
diff --git a/kernel/av/automation_test.go b/kernel/av/automation_test.go
index f570fcc75f..63138d0ffc 100644
--- a/kernel/av/automation_test.go
+++ b/kernel/av/automation_test.go
@@ -112,7 +112,7 @@ func TestAutomationClonePreservesPausedRules(t *testing.T) {
if copiedRule.Actions[1].RelationKeyID == relationID || !rule.Enabled || rule.KeyID != primaryID {
t.Fatal("copy changed the original rule or retained its source field")
}
- source.Automations.Spec = 7
+ source.Automations.Spec = 8
future, _ := json.Marshal(source)
if _, err := ParseAttributeViewData(source.ID, future); err == nil {
t.Fatal("unknown automation format was accepted")
@@ -134,7 +134,7 @@ func TestAutomationBlockTypeAndSpecCompatibility(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- for _, spec := range []int{1, 2, 3, 4, 5, 6} {
+ for _, spec := range []int{1, 2, 3, 4, 5, 6, 7} {
view, err := ParseAttributeViewData("20260921000000-layouts", data)
if err != nil {
t.Fatal(err)
@@ -185,7 +185,7 @@ func TestAutomationAttributeNameSpecCompatibility(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- for spec := 1; spec <= 6; spec++ {
+ for spec := 1; spec <= 7; spec++ {
for _, mode := range []string{"", "equals", "contains", "regex"} {
view, err := ParseAttributeViewData("20260921000000-layouts", data)
if err != nil {
@@ -216,6 +216,43 @@ func TestAutomationAttributeNameSpecCompatibility(t *testing.T) {
}
}
+func TestAutomationSelectedDocumentsSpecCompatibility(t *testing.T) {
+ data, err := os.ReadFile("testdata/spec9-layouts.json")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for spec := 1; spec <= 7; spec++ {
+ for _, include := range []*bool{nil, new(true), new(false)} {
+ view, err := ParseAttributeViewData("20260921000000-layouts", data)
+ if err != nil {
+ t.Fatal(err)
+ }
+ source := &AutomationBlockSource{DocumentIDs: []string{"parent"}, IncludeSelectedDocuments: include}
+ view.Automations = &AutomationConfig{Spec: spec, Rules: []*AutomationRule{{BlockSource: source}}}
+ raw, _ := json.Marshal(view)
+ read, err := ParseAttributeViewData(view.ID, raw)
+ want := include == nil || *include || spec >= 7
+ if (err == nil) != want {
+ t.Fatalf("include %v spec %d: %v", include, spec, err)
+ }
+ if want {
+ got := read.Automations.Rules[0].BlockSource.IncludeSelectedDocuments
+ if (got == nil) != (include == nil) || got != nil && *got != *include {
+ t.Fatal("selected document inclusion lost during storage round trip")
+ }
+ }
+ if include != nil && !*include {
+ source.DocumentDepth = new(1)
+ source.TagTarget = "container"
+ source.Attributes = []*AutomationBlockAttribute{{Name: "state", NameOperator: "contains", Operator: "exists"}}
+ if got := view.Automations.Rules[0].RequiredSpec(); got != 7 {
+ t.Fatalf("combined required spec = %d", got)
+ }
+ }
+ }
+ }
+}
+
func TestAutomationPreservesPersistedColors(t *testing.T) {
view := &AttributeView{Automations: &AutomationConfig{Spec: 1, Rules: []*AutomationRule{{
Actions: []*AutomationAction{{Fields: map[string]*AutomationValue{"select": {
diff --git a/kernel/av/collection_index.go b/kernel/av/collection_index.go
index d7b04af592..7b335272f8 100644
--- a/kernel/av/collection_index.go
+++ b/kernel/av/collection_index.go
@@ -120,6 +120,10 @@ func collectionScopes(config *AutomationConfig) (ret []*AutomationBlockSource) {
depth := *source.DocumentDepth
scope.DocumentDepth = &depth
}
+ if source.IncludeSelectedDocuments != nil {
+ include := *source.IncludeSelectedDocuments
+ scope.IncludeSelectedDocuments = &include
+ }
ret = append(ret, scope)
}
return
@@ -131,6 +135,7 @@ func equalCollectionScopes(left, right []*AutomationBlockSource) bool {
return a == b
}
return slices.Equal(a.NotebookIDs, b.NotebookIDs) && slices.Equal(a.DocumentIDs, b.DocumentIDs) &&
+ (a.IncludeSelectedDocuments == nil || *a.IncludeSelectedDocuments) == (b.IncludeSelectedDocuments == nil || *b.IncludeSelectedDocuments) &&
(a.DocumentDepth == nil && b.DocumentDepth == nil || a.DocumentDepth != nil && b.DocumentDepth != nil && *a.DocumentDepth == *b.DocumentDepth)
})
}
diff --git a/kernel/av/collection_index_test.go b/kernel/av/collection_index_test.go
index da4031f2e7..59a23e3a63 100644
--- a/kernel/av/collection_index_test.go
+++ b/kernel/av/collection_index_test.go
@@ -146,7 +146,7 @@ func TestBlockCollectionIndexScopesAndSnapshots(t *testing.T) {
t.Fatal("disabling last rule did not update empty fast path")
}
view.Automations.Rules[0].Enabled = true
- view.Automations.Spec = 7
+ view.Automations.Spec = 8
rememberCollectionView(view, "")
unknown, err := BlockCollectionIndexInBox("")
if err != nil || !unknown.MatchesDocument("unrelated", child, "/child.sy") {
@@ -158,6 +158,52 @@ func TestBlockCollectionIndexScopesAndSnapshots(t *testing.T) {
}
}
+func TestBlockCollectionIndexSelectedDocuments(t *testing.T) {
+ setupCollectionIndexTest(t)
+ view := collectionIndexTestView()
+ source := view.Automations.Rules[0].BlockSource
+ parent, child := source.DocumentIDs[0], ast.NewNodeID()
+ writeCollectionIndexView(t, view)
+ before, err := BlockCollectionIndexInBox("")
+ if err != nil {
+ t.Fatal(err)
+ }
+ source.IncludeSelectedDocuments = new(true)
+ rememberCollectionView(view, "")
+ if !before.Current() {
+ t.Fatal("explicit default invalidated identical scope")
+ }
+ view.Automations.Spec = 7
+ source.IncludeSelectedDocuments = new(false)
+ rememberCollectionView(view, "")
+ index, err := BlockCollectionIndexInBox("")
+ if err != nil || before.Current() || index.MatchesDocument("", parent, "/"+parent+".sy") ||
+ !index.MatchesDocument("", child, "/"+parent+"/"+child+".sy") {
+ t.Fatal("scope exclusion did not update snapshot", err)
+ }
+ if !before.MatchesDocument("", parent, "/"+parent+".sy") {
+ t.Fatal("exclusion mutated previous snapshot")
+ }
+ *source.IncludeSelectedDocuments = true
+ if index.MatchesDocument("", parent, "/"+parent+".sy") {
+ t.Fatal("caller mutated immutable exclusion snapshot")
+ }
+ // Persist and reload to cover cold discovery, not just the hot save path.
+ *source.IncludeSelectedDocuments = false
+ writeCollectionIndexView(t, view)
+ cache.ClearAVCache()
+ index, err = BlockCollectionIndexInBox("")
+ if err != nil || index.MatchesDocument("", parent, "/"+parent+".sy") {
+ t.Fatal("cold discovery lost scope exclusion", err)
+ }
+ source.IncludeSelectedDocuments = nil
+ rememberCollectionView(view, "")
+ restored, err := BlockCollectionIndexInBox("")
+ if err != nil || index.Current() || !restored.MatchesDocument("", parent, "/"+parent+".sy") {
+ t.Fatal("restoring default did not invalidate exclusion snapshot", err)
+ }
+}
+
func TestBlockCollectionIndexCorruptionFailsClosed(t *testing.T) {
setupCollectionIndexTest(t)
view := collectionIndexTestView()
diff --git a/kernel/model/attribute_view_collection_scope_fts5_test.go b/kernel/model/attribute_view_collection_scope_fts5_test.go
new file mode 100644
index 0000000000..a28c6af5b2
--- /dev/null
+++ b/kernel/model/attribute_view_collection_scope_fts5_test.go
@@ -0,0 +1,220 @@
+//go:build fts5
+
+package model
+
+import (
+ "encoding/json"
+ "strings"
+ "testing"
+
+ "github.com/88250/lute/ast"
+ "github.com/88250/lute/parse"
+ "github.com/siyuan-note/siyuan/kernel/av"
+)
+
+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"])
+ for _, test := range []struct {
+ name string
+ include *bool
+ depth *int
+ ids []string
+ box string
+ id, path string
+ want bool
+ }{
+ {"legacy self", nil, nil, []string{"parent"}, "", "parent", "/parent.sy", true},
+ {"explicit self", new(true), new(0), []string{"parent"}, "", "parent", "/parent.sy", true},
+ {"excluded self", new(false), nil, []string{"parent"}, "", "parent", "/parent.sy", false},
+ {"zero depth empty", new(false), new(0), []string{"parent"}, "", "child", "/parent/child.sy", false},
+ {"child", new(false), new(1), []string{"parent"}, "", "child", "/parent/child.sy", true},
+ {"grandchild depth", new(false), new(1), []string{"parent"}, "", "grand", "/parent/child/grand.sy", false},
+ {"unlimited", new(false), nil, []string{"parent"}, "", "grand", "/parent/child/grand.sy", true},
+ {"overlap excluded scope first", new(false), new(1), []string{"child", "parent"}, "", "child", "/parent/child.sy", true},
+ {"overlap ancestor first", new(false), new(1), []string{"parent", "child"}, "", "child", "/parent/child.sy", true},
+ {"nested selected scope", new(false), new(1), []string{"parent", "child"}, "", "grand", "/parent/child/grand.sy", true},
+ {"notebook union", new(false), new(0), []string{"parent"}, "box", "parent", "/parent.sy", true},
+ } {
+ t.Run(test.name, func(t *testing.T) {
+ source := &av.AutomationBlockSource{DocumentIDs: test.ids, DocumentDepth: test.depth, IncludeSelectedDocuments: test.include}
+ source.DocumentIDs = make([]string, len(test.ids))
+ for i, id := range test.ids {
+ source.DocumentIDs[i] = ids[id]
+ }
+ if test.box != "" {
+ source.NotebookIDs = []string{test.box}
+ }
+ root := &ast.Node{ID: ids[test.id], Type: ast.NodeDocument}
+ paragraph := &ast.Node{ID: ast.NewNodeID(), Type: ast.NodeParagraph}
+ root.AppendChild(paragraph)
+ tree := &parse.Tree{ID: root.ID, Path: paths.Replace(test.path), Box: test.box, Root: root}
+ matches := collectionMatches(source, tree)
+ if collectionScopeMatches(source, tree) != test.want || matches[root.ID] != test.want || matches[paragraph.ID] != test.want {
+ t.Fatalf("document and internal block inclusion = %v, want %v", matches, test.want)
+ }
+ })
+ }
+}
+
+func TestBlockCollectionSelectedDocumentTransitionsAndReview(t *testing.T) {
+ fixture, view, keyID := setupBlockCollectionTest(t)
+ parent, err := LoadTreeByBlockID(fixture.sourceID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ child, err := CreateDocByMdSync(fixture.box.ID, strings.TrimSuffix(parent.Path, ".sy")+"/"+ast.NewNodeID()+".sy", "Child", "Child content", nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ ruleID := view.Automations.Rules[0].ID
+ setInclude := func(include *bool) *Transaction {
+ t.Helper()
+ view = readAttributeViewItemsTest(t, view.ID)
+ raw, err := json.Marshal(view.Automations)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var previous av.AutomationConfig
+ if err = json.Unmarshal(raw, &previous); err != nil {
+ t.Fatal(err)
+ }
+ view.Automations.Spec = 7
+ view.Automations.Rules[0].BlockSource.IncludeSelectedDocuments = include
+ view.Automations.Rules[0].BlockSource.DocumentDepth = new(1)
+ op := &Operation{Action: "setAttrViewAutomations", AvID: view.ID, Data: view.Automations}
+ tx := &Transaction{fromAPI: true, DoOperations: []*Operation{op}, UndoOperations: []*Operation{{Action: "setAttrViewAutomations", AvID: view.ID, Data: &previous}}}
+ if err := PerformTxSync(tx); err != nil {
+ t.Fatal(err)
+ }
+ return tx
+ }
+ setInclude(new(false))
+ for _, id := range []string{parent.ID, child.ID} {
+ if err = PerformTxSync(blockCollectionTags(t, id, "todo")); err != nil {
+ t.Fatal(err)
+ }
+ }
+ view = readAttributeViewItemsTest(t, view.ID)
+ if view.GetBlockValueByBoundID(parent.ID) != nil || view.GetBlockValueByBoundID(child.ID) == nil {
+ t.Fatal("live collection did not exclude self and retain child")
+ }
+ preview, err := PreviewAttributeViewCollection(view.ID, ruleID, 1)
+ if err != nil || len(preview.Blocks) != 1 || preview.Blocks[0].ID != child.ID {
+ t.Fatalf("excluding self preview: %+v %v", preview, err)
+ }
+ if err = PerformAttributeViewOperations([]*Operation{{Action: "collectAttrViewBlocks", AvID: view.ID,
+ Data: map[string]any{"ruleID": ruleID, "blockIDs": []string{parent.ID}}}}); err != nil {
+ t.Fatal(err)
+ }
+ if readAttributeViewItemsTest(t, view.ID).GetBlockValueByBoundID(parent.ID) != nil {
+ t.Fatal("explicit collection collected excluded parent")
+ }
+ change := setInclude(nil)
+ view = readAttributeViewItemsTest(t, view.ID)
+ if view.GetBlockValueByBoundID(parent.ID) != nil {
+ t.Fatal("including self backfilled existing parent")
+ }
+ if err = PerformTxSync(&Transaction{isReplay: true, DoOperations: cloneOperations(change.UndoOperations)}); err != nil {
+ t.Fatal(err)
+ }
+ view = readAttributeViewItemsTest(t, view.ID)
+ if include := view.Automations.Rules[0].BlockSource.IncludeSelectedDocuments; include == nil || *include {
+ t.Fatal("undo lost scope exclusion")
+ }
+ if err = PerformTxSync(&Transaction{isReplay: true, DoOperations: cloneOperations(change.DoOperations)}); err != nil {
+ t.Fatal(err)
+ }
+ if err = PerformAttributeViewOperations([]*Operation{{Action: "collectAttrViewBlocks", AvID: view.ID,
+ Data: map[string]any{"ruleID": ruleID, "blockIDs": []string{parent.ID}}}}); err != nil {
+ t.Fatal(err)
+ }
+ view = readAttributeViewItemsTest(t, view.ID)
+ parentItem := view.GetBlockValueByBoundID(parent.ID).BlockID
+ view.GetValue(keyID, parentItem).Text.Content = "Edited parent"
+ if err = av.SaveAttributeView(view); err != nil {
+ t.Fatal(err)
+ }
+ setInclude(new(false))
+ view = readAttributeViewItemsTest(t, view.ID)
+ if view.GetValue(keyID, parentItem).Text.Content != "Edited parent" {
+ t.Fatal("scope exclusion changed existing fields")
+ }
+ review, err := ReviewAttributeViewCollection(view.ID, 1, "")
+ if err != nil || review.Matched != 1 || review.Unmatched != 1 {
+ t.Fatalf("exclusion review: %+v %v", review, err)
+ }
+ stale := collectionCleanupOperation(view.ID, review)
+ setInclude(nil)
+ if err = PerformAttributeViewOperations([]*Operation{stale}); err == nil {
+ t.Fatal("inclusion change accepted stale cleanup")
+ }
+ setInclude(new(false))
+ review, err = ReviewAttributeViewCollection(view.ID, 1, "")
+ if err != nil {
+ t.Fatal(err)
+ }
+ op := collectionCleanupOperation(view.ID, review)
+ cleanup := &Transaction{fromAPI: true, DoOperations: []*Operation{op}, UndoOperations: []*Operation{op}}
+ if err = PerformTxSync(cleanup); err != nil {
+ t.Fatal(err)
+ }
+ view = readAttributeViewItemsTest(t, view.ID)
+ if view.GetBlockValue(parentItem) != nil || view.GetBlockValueByBoundID(child.ID) == nil {
+ t.Fatal("cleanup removed the wrong entries")
+ }
+ if err = PerformTxSync(&Transaction{isReplay: true, DoOperations: cloneOperations(cleanup.UndoOperations)}); err != nil {
+ t.Fatal(err)
+ }
+ view = readAttributeViewItemsTest(t, view.ID)
+ if view.GetValue(keyID, parentItem).Text.Content != "Edited parent" {
+ t.Fatal("cleanup undo lost original fields")
+ }
+ if err = PerformTxSync(&Transaction{isReplay: true, DoOperations: cloneOperations(cleanup.DoOperations)}); err != nil {
+ t.Fatal(err)
+ }
+ if readAttributeViewItemsTest(t, view.ID).GetBlockValue(parentItem) != nil {
+ t.Fatal("cleanup redo did not remove excluded parent")
+ }
+ created, err := CreateDocByMdSync(fixture.box.ID, strings.TrimSuffix(parent.Path, ".sy")+"/"+ast.NewNodeID()+".sy", "New child", "", nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = PerformTxSync(blockCollectionTags(t, created.ID, "todo")); err != nil {
+ t.Fatal(err)
+ }
+ if readAttributeViewItemsTest(t, view.ID).GetBlockValueByBoundID(created.ID) == nil {
+ t.Fatal("new child was excluded with its parent")
+ }
+}
+
+func TestBlockCollectionSelectedDocumentBlockMoves(t *testing.T) {
+ fixture, view, _ := setupBlockCollectionTest(t)
+ parent, err := LoadTreeByBlockID(fixture.sourceID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ child, err := CreateDocByMdSync(fixture.box.ID, strings.TrimSuffix(parent.Path, ".sy")+"/"+ast.NewNodeID()+".sy", "Child", "Child content", nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ view.Automations.Spec = 7
+ source := view.Automations.Rules[0].BlockSource
+ source.IncludeSelectedDocuments, source.Tags, source.Types = new(false), nil, []string{"p"}
+ if err = av.SaveAttributeView(view); err != nil {
+ t.Fatal(err)
+ }
+ blockID := parent.Root.FirstChild.ID
+ if err = PerformTxSync(&Transaction{fromAPI: true, DoOperations: []*Operation{{Action: "move", ID: blockID, ParentID: child.ID}}}); err != nil {
+ t.Fatal(err)
+ }
+ if readAttributeViewItemsTest(t, view.ID).GetBlockValueByBoundID(blockID) == nil {
+ t.Fatal("move from excluded parent into child did not collect")
+ }
+ if err = PerformTxSync(&Transaction{fromAPI: true, DoOperations: []*Operation{{Action: "move", ID: blockID, ParentID: parent.ID}}}); err != nil {
+ t.Fatal(err)
+ }
+ if readAttributeViewItemsTest(t, view.ID).GetBlockValueByBoundID(blockID) == nil {
+ t.Fatal("move back into excluded parent removed existing entry")
+ }
+}
diff --git a/kernel/model/attribute_view_collection_sqlcipher_test.go b/kernel/model/attribute_view_collection_sqlcipher_test.go
index bf4ee798c1..bb558e2d24 100644
--- a/kernel/model/attribute_view_collection_sqlcipher_test.go
+++ b/kernel/model/attribute_view_collection_sqlcipher_test.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"os"
"path/filepath"
+ "strings"
"testing"
"github.com/88250/lute/ast"
@@ -25,22 +26,30 @@ func TestBlockCollectionEncryptedSourceAndRecovery(t *testing.T) {
name = "default"
}
t.Run(name, func(t *testing.T) {
- t.Run("unlimited", func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, target, nil, "") })
- t.Run("current", func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, target, new(0), "") })
+ t.Run("unlimited", func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, target, nil, "", false) })
+ t.Run("current", func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, target, new(0), "", false) })
})
}
for _, mode := range []string{"contains", "regex"} {
- t.Run(mode, func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, "", nil, mode) })
+ t.Run(mode, func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, "", nil, mode, false) })
}
+ t.Run("exclude selected document", func(t *testing.T) { testBlockCollectionEncryptedSourceAndRecovery(t, "", new(1), "", true) })
}
-func testBlockCollectionEncryptedSourceAndRecovery(t *testing.T, target string, depth *int, nameOperator string) {
+func testBlockCollectionEncryptedSourceAndRecovery(t *testing.T, target string, depth *int, nameOperator string, excludeSelf bool) {
fixture, view, keyID := setupBlockCollectionTest(t)
boxID := fixture.box.ID
tree, err := LoadTreeByBlockID(fixture.sourceID)
if err != nil {
t.Fatal(err)
}
+ parent := tree
+ if excludeSelf {
+ tree, err = CreateDocByMdSync(boxID, strings.TrimSuffix(parent.Path, ".sy")+"/"+ast.NewNodeID()+".sy", "Child", "Child content", nil, nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ }
markRuntimeEncryptedBox(boxID)
key := bytes.Repeat([]byte{0x58}, 32)
prepareUnlockedEncryptedBoxTest(t, boxID, key)
@@ -95,6 +104,12 @@ func testBlockCollectionEncryptedSourceAndRecovery(t *testing.T, target string,
t.Fatal(err)
}
treenode.UpsertBlockTree(tree)
+ if excludeSelf {
+ if _, err = filesys.WriteTree(parent); err != nil {
+ t.Fatal(err)
+ }
+ treenode.UpsertBlockTree(parent)
+ }
if target == "" {
view.Automations.Rules[0].BlockSource.Tags = nil
}
@@ -112,6 +127,10 @@ func testBlockCollectionEncryptedSourceAndRecovery(t *testing.T, target string,
attr.Name = "^custom-st(?:ate|atus)$"
}
}
+ if excludeSelf {
+ view.Automations.Spec = 7
+ view.Automations.Rules[0].BlockSource.IncludeSelectedDocuments = new(false)
+ }
if err = av.SaveAttributeView(view); err != nil {
t.Fatal(err)
}
@@ -120,6 +139,15 @@ func testBlockCollectionEncryptedSourceAndRecovery(t *testing.T, target string,
t.Fatal(err)
}
cache.ClearAVCache()
+ if excludeSelf {
+ if err = PerformTxSync(&Transaction{fromAPI: true, DoOperations: []*Operation{{Action: "setAttrs", ID: parent.ID, Data: `{"custom-state":"active"}`}}}); err != nil {
+ t.Fatal(err)
+ }
+ stored, readErr := av.ParseAttributeViewForIndexInBox(view.ID, boxID)
+ if readErr != nil || stored.GetBlockValueByBoundID(parent.ID) != nil {
+ t.Fatal("encrypted selected parent was collected", readErr)
+ }
+ }
op := &Operation{Action: "setAttrs", ID: sourceID, Data: `{"custom-state":"active"}`}
tx := &Transaction{fromAPI: true, DoOperations: []*Operation{op}, UndoOperations: []*Operation{{Action: "setAttrs", ID: sourceID, Data: `{"custom-state":""}`}}}
if err = PerformTxSync(tx); err != nil {