Skip to content

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

:sparkles: Separate list and list item search subtype filters https://github.com/siyuan-note/siyuan/issues/19395

Daniel126349a9b593
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 9f5eb715ec..c438d6b73b 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1932,7 +1932,6 @@
"heading5": "عنوان 5",
"heading6": "عنوان 6",
"unorderedList": "قائمة غير مرتبة",
- "searchSubTypeListTip": "الأنواع الفرعية للقائمة (مرتبة/غير مرتبة/مهمة) تنطبق أيضاً على عناصر القائمة",
"outlineExpandLevel": "مستوى التوسيع",
"expandAll": "توسيع الكل",
"outlineKeepCurrentExpand": "الحفاظ على التوسيع الحالي",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index 7d5f5628ee..6416d7d3d3 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1932,7 +1932,6 @@
"heading5": "Überschrift 5",
"heading6": "Überschrift 6",
"unorderedList": "Ungeordnete Liste",
- "searchSubTypeListTip": "Listen-Untertypen (Geordnet/Ungeordnet/Aufgabe) gelten auch für Listenelemente",
"outlineExpandLevel": "Expansionsebene",
"expandAll": "Alle erweitern",
"outlineKeepCurrentExpand": "Aktuelle Erweiterung beibehalten",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 3892975a53..ee69299fe5 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1932,7 +1932,6 @@
"heading5": "Heading 5",
"heading6": "Heading 6",
"unorderedList": "Unordered List",
- "searchSubTypeListTip": "List subtypes (Ordered/Unordered/Task) also apply to list items",
"outlineExpandLevel": "Expand level",
"expandAll": "Expand all",
"outlineKeepCurrentExpand": "Keep current expand",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 441caaa491..37e74e042b 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1932,7 +1932,6 @@
"heading5": "Encabezado 5",
"heading6": "Encabezado 6",
"unorderedList": "Lista no ordenada",
- "searchSubTypeListTip": "Los subtipos de lista (Ordenada/No ordenada/Tarea) también se aplican a los elementos de lista",
"outlineExpandLevel": "Nivel de expansión",
"expandAll": "Expandir todo",
"outlineKeepCurrentExpand": "Mantener la expansión actual",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index 63ed9080f1..7d271f5318 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1932,7 +1932,6 @@
"heading5": "Titre 5",
"heading6": "Titre 6",
"unorderedList": "Liste non ordonnée",
- "searchSubTypeListTip": "Les sous-types de liste (Ordonnée/Non ordonnée/Tâche) s'appliquent aussi aux éléments de liste",
"outlineExpandLevel": "Niveau d'expansion",
"expandAll": "Tout développer",
"outlineKeepCurrentExpand": "Maintenir le titre actuel développé",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index 84a0aaeebc..f9543424bb 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1932,7 +1932,6 @@
"heading5": "כותרת 5",
"heading6": "כותרת 6",
"unorderedList": "רשימה לא מסודרת",
- "searchSubTypeListTip": "סוגי-משנה של רשימה (מסודרת/לא מסודרת/משימה) חלים גם על פריטי רשימה",
"outlineExpandLevel": "רמת הרחבה",
"expandAll": "הרחב הכל",
"outlineKeepCurrentExpand": "שמור כותרת נוכחית מורחבת",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index 9049fb6534..72705b5f1e 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1932,7 +1932,6 @@
"heading5": "शीर्षक 5",
"heading6": "शीर्षक 6",
"unorderedList": "अक्रमित सूची",
- "searchSubTypeListTip": "सूची उपप्रकार (क्रमित/अक्रमित/कार्य) सूची आइटम पर भी लागू होते हैं",
"outlineExpandLevel": "विस्तार स्तर",
"expandAll": "सभी विस्तारित करें",
"outlineKeepCurrentExpand": "वर्तमान विस्तार रखें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index 6dc37ca88d..1d66330135 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1932,7 +1932,6 @@
"heading5": "Judul 5",
"heading6": "Judul 6",
"unorderedList": "Daftar Tidak Berurutan",
- "searchSubTypeListTip": "Subtipe daftar (Berurutan/Tidak Berurutan/Tugas) juga berlaku untuk item daftar",
"outlineExpandLevel": "Tingkat perluasan",
"expandAll": "Perluas semua",
"outlineKeepCurrentExpand": "Pertahankan perluasan saat ini",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 98612a1918..1c6521505a 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1932,7 +1932,6 @@
"heading5": "Titolo 5",
"heading6": "Titolo 6",
"unorderedList": "Elenco non ordinato",
- "searchSubTypeListTip": "I sottotipi di elenco (Ordinato/Non ordinato/Attività) si applicano anche agli elementi dell'elenco",
"outlineExpandLevel": "Livello di espansione",
"expandAll": "Espandi tutto",
"outlineKeepCurrentExpand": "Mantieni espanso l'intestazione corrente",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index afef5140d2..46d096525f 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1932,7 +1932,6 @@
"heading5": "見出し5",
"heading6": "見出し6",
"unorderedList": "番号なしリスト",
- "searchSubTypeListTip": "リストのサブタイプ(番号付き / 番号なし / タスク)はリスト項目にも適用されます",
"outlineExpandLevel": "展開レベル",
"expandAll": "すべて展開",
"outlineKeepCurrentExpand": "現在の見出しを展開し続ける",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index b78ba5233f..2a212560eb 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1932,7 +1932,6 @@
"heading5": "제목 5",
"heading6": "제목 6",
"unorderedList": "순서 없는 목록",
- "searchSubTypeListTip": "목록 하위 유형(순서/순서 없음/작업)은 목록 항목에도 적용됩니다",
"outlineExpandLevel": "펼치기 레벨",
"expandAll": "모두 펼치기",
"outlineKeepCurrentExpand": "현재 펼침 상태 유지",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index b8277e64b0..61d855dfab 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1932,7 +1932,6 @@
"heading5": "Kop 5",
"heading6": "Kop 6",
"unorderedList": "Ongeordende Lijst",
- "searchSubTypeListTip": "Lijstsubtypen (Geordend/Ongeordend/Taak) zijn ook van toepassing op lijstitems",
"outlineExpandLevel": "Uitklapniveau",
"expandAll": "Alles uitklappen",
"outlineKeepCurrentExpand": "Huidig behouden",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index 366a40ed38..7c21746646 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1932,7 +1932,6 @@
"heading5": "Nagłówek 5",
"heading6": "Nagłówek 6",
"unorderedList": "Lista nieuporządkowana",
- "searchSubTypeListTip": "Podtypy list (Uporządkowana/Nieuporządkowana/Zadanie) dotyczą również elementów listy",
"outlineExpandLevel": "Poziom rozwinięcia",
"expandAll": "Rozwiń wszystko",
"outlineKeepCurrentExpand": "Utrzymuj bieżący tytuł rozwinięty",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index 9a0b949a91..a78d450c55 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1932,7 +1932,6 @@
"heading5": "Título 5",
"heading6": "Título 6",
"unorderedList": "Lista não ordenada",
- "searchSubTypeListTip": "Os subtipos de lista (Ordenada/Não ordenada/Tarefa) também se aplicam aos itens da lista",
"outlineExpandLevel": "Nível de expansão",
"expandAll": "Expandir tudo",
"outlineKeepCurrentExpand": "Manter título atual expandido",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index bbb197b4c6..04671d2796 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1932,7 +1932,6 @@
"heading5": "Заголовок 5",
"heading6": "Заголовок 6",
"unorderedList": "Неупорядоченный список",
- "searchSubTypeListTip": "Подтипы списков (Упорядоченный/Неупорядоченный/Задача) также применяются к элементам списка",
"outlineExpandLevel": "Уровень развёртывания",
"expandAll": "Развернуть все",
"outlineKeepCurrentExpand": "Сохранять текущий заголовок развёрнутым",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index c617c14915..e9b72fec89 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1932,7 +1932,6 @@
"heading5": "Nadpis 5",
"heading6": "Nadpis 6",
"unorderedList": "Neusporiadaný zoznam",
- "searchSubTypeListTip": "Podtypy zoznamov (Usporiadaný/Neusporiadaný/Úloha) sa vzťahujú aj na položky zoznamu",
"outlineExpandLevel": "Úroveň rozbalenia",
"expandAll": "Rozbaliť všetko",
"outlineKeepCurrentExpand": "Ponechať aktuálne rozbalenie",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index 79c6a6c456..e1319e8c95 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1932,7 +1932,6 @@
"heading5": "หัวข้อ 5",
"heading6": "หัวข้อ 6",
"unorderedList": "รายการไม่เรียงลำดับ",
- "searchSubTypeListTip": "ชนิดย่อยของรายการ (เรียงลำดับ/ไม่เรียงลำดับ/งาน) ใช้กับรายการย่อยด้วย",
"outlineExpandLevel": "ระดับขยาย",
"expandAll": "ขยายทั้งหมด",
"outlineKeepCurrentExpand": "คงขยาย",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index ecdb8aa647..b2467874c7 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1932,7 +1932,6 @@
"heading5": "Başlık 5",
"heading6": "Başlık 6",
"unorderedList": "Sırasız liste",
- "searchSubTypeListTip": "Liste alt türleri (Sıralı/Sırasız/Görev) liste öğelerine de uygulanır",
"outlineExpandLevel": "Tasarım genişleme seviyesi",
"expandAll": "Tümünü genişlet",
"outlineKeepCurrentExpand": "Mevcut genişlemeyi koru",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 531e25c38d..495c29707f 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1932,7 +1932,6 @@
"heading5": "Заголовок 5",
"heading6": "Заголовок 6",
"unorderedList": "Неупорядкований список",
- "searchSubTypeListTip": "Підтипи списків (Упорядкований/Неупорядкований/Завдання) також застосовуються до елементів списку",
"outlineExpandLevel": "Рівень розгортання",
"expandAll": "Розгорнути все",
"outlineKeepCurrentExpand": "Зберегти поточний стан розгортання",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index bf30324579..a498440a30 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1932,7 +1932,6 @@
"heading5": "五级标题",
"heading6": "六级标题",
"unorderedList": "无序列表",
- "searchSubTypeListTip": "列表子类型(有序/无序/任务)同样适用于列表项",
"outlineExpandLevel": "展开层级",
"expandAll": "全部展开",
"outlineKeepCurrentExpand": "保持当前标题展开",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index c02dcc73c8..554a309472 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1932,7 +1932,6 @@
"heading5": "五級標題",
"heading6": "六級標題",
"unorderedList": "無序列表",
- "searchSubTypeListTip": "列表子類型(有序/無序/任務)同樣適用於列表項",
"outlineExpandLevel": "展開層級",
"expandAll": "全部展開",
"outlineKeepCurrentExpand": "保持當前標題展開",
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-l3qg72k/20201222100222-q47d64s.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-l3qg72k/20201222100222-q47d64s.sy
index 47f3a871ff..9d1b7ef052 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-l3qg72k/20201222100222-q47d64s.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-l3qg72k/20201222100222-q47d64s.sy
@@ -6,9 +6,61 @@
"id": "20201222100222-q47d64s",
"title": "Type filtering",
"type": "doc",
- "updated": "20251219205842"
+ "updated": "20260913020024"
},
"Children": [
+ {
+ "ID": "20260913020024-b527599",
+ "Type": "NodeHeading",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260913020024-b527599",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Search type filters"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020024-jcrzyhk",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020024-jcrzyhk",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "In the search dialog, open "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "Search type"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " and expand Heading, List block, or List item block to select heading levels or ordered, unordered, and task subtypes independently. For example, select only Ordered under List item block to find ordered list items."
+ }
+ ]
+ },
+ {
+ "ID": "20260913020024-t1ymzbn",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020024-t1ymzbn",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "Selecting a parent selects all its subtypes; clearing it clears the group. Selecting any subtype enables its parent, and clearing the last subtype disables the parent. An enabled parent with no subtype restriction appears with all its subtypes selected."
+ }
+ ]
+ },
{
"ID": "20210210104024-efd1ar6",
"Type": "NodeHeading",
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20260612192252-sgw2paw.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20260612192252-sgw2paw.sy
index af3b0b6ba5..a543dcbb98 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20260612192252-sgw2paw.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-xaduj2o/20260612192252-sgw2paw.sy
@@ -6,7 +6,7 @@
"id": "20260612192252-sgw2paw",
"title": "Command Line Interface",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -1579,7 +1579,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20260618124055-5xyayt6",
- "updated": "20260618124055"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4359,7 +4359,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20260618124055-ddm1efp",
- "updated": "20260618124055"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4392,7 +4392,7 @@
"Properties": {
"colgroup": "|",
"id": "20260618124055-jh2j81m",
- "updated": "20260618124055"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4596,7 +4596,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "Filter by subtype (o=ordered list/u=unordered list/t=task list), repeatable"
+ "Data": "Filter by subtype: h1 through h6 for heading levels; list:o/u/t for list blocks and listItem:o/u/t for list item blocks (o=ordered, u=unordered, t=task), repeatable; bare o/u/t are no longer supported"
}
]
}
@@ -4920,7 +4920,7 @@
"IsFencedCodeBlock": true,
"Properties": {
"id": "20260618124055-4eyeyfx",
- "updated": "20260618124055"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4933,7 +4933,7 @@
},
{
"Type": "NodeCodeBlockCode",
- "Data": "siyuan search \"keyword\"\nsiyuan search \"keyword\" --notebook box1 --notebook box2\nsiyuan search \"keyword\" --path \"/folder\"\nsiyuan search \"keyword\" --type document --type heading\nsiyuan search \"keyword\" --subtype o --subtype u\nsiyuan search \"keyword\" --method 2\nsiyuan search \"keyword\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"keyword\" --group-by 1\n"
+ "Data": "siyuan search \"keyword\"\nsiyuan search \"keyword\" --notebook box1 --notebook box2\nsiyuan search \"keyword\" --path \"/folder\"\nsiyuan search \"keyword\" --type document --type heading\nsiyuan search \"keyword\" --type listItem --subtype listItem:o --subtype listItem:u\nsiyuan search \"keyword\" --method 2\nsiyuan search \"keyword\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"keyword\" --group-by 1\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-gyngv2x/20201222095049-hghafhe.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-gyngv2x/20201222095049-hghafhe.sy
index 1a44f724d8..0375753c90 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-gyngv2x/20201222095049-hghafhe.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-gyngv2x/20201222095049-hghafhe.sy
@@ -6,9 +6,61 @@
"id": "20201222095049-hghafhe",
"title": "类型过滤",
"type": "doc",
- "updated": "20251219204304"
+ "updated": "20260913020024"
},
"Children": [
+ {
+ "ID": "20260913020024-v0jx3m5",
+ "Type": "NodeHeading",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260913020024-v0jx3m5",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "搜索类型筛选"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020024-2q2gbom",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020024-2q2gbom",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "在搜索对话框中打开 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "搜索类型"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ",展开标题、列表块或列表项块,可分别选择标题级别或有序、无序、任务子类型。列表块与列表项块的选择互不影响,例如仅勾选列表项块下的有序即可筛选有序列表项块。"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020024-mc5ic30",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020024-mc5ic30",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "勾选父类型会全选该组子类型,取消父类型会清空该组;勾选任一子类型会勾选其父类型,取消最后一个子类型会取消父类型。未限制子类型的已启用父类型在对话框中显示为全选。"
+ }
+ ]
+ },
{
"ID": "20210210103523-ombf290",
"Type": "NodeHeading",
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20260612191136-feqbi1x.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20260612191136-feqbi1x.sy
index 15f0b3884c..0185925a5d 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20260612191136-feqbi1x.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180321-hbvl5c2/20260612191136-feqbi1x.sy
@@ -6,7 +6,7 @@
"id": "20260612191136-feqbi1x",
"title": "命令行接口",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -1579,7 +1579,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20260618123536-56wxe3i",
- "updated": "20260618123536"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4359,7 +4359,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20260618123536-erb905s",
- "updated": "20260618123536"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4392,7 +4392,7 @@
"Properties": {
"colgroup": "|",
"id": "20260618123536-qrjmvmd",
- "updated": "20260618123536"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4596,7 +4596,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "按子类型过滤(o=有序列表/u=无序列表/t=任务列表),可重复"
+ "Data": "按子类型过滤:h1 至 h6 为标题级别;list:o/u/t 为列表块,listItem:o/u/t 为列表项块(o=有序、u=无序、t=任务),可重复指定;不再支持裸 o/u/t"
}
]
}
@@ -4920,7 +4920,7 @@
"IsFencedCodeBlock": true,
"Properties": {
"id": "20260618123536-obikelg",
- "updated": "20260618123536"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4933,7 +4933,7 @@
},
{
"Type": "NodeCodeBlockCode",
- "Data": "siyuan search \"关键词\"\nsiyuan search \"关键词\" --notebook box1 --notebook box2\nsiyuan search \"关键词\" --path \"/目录\"\nsiyuan search \"关键词\" --type document --type heading\nsiyuan search \"关键词\" --subtype o --subtype u\nsiyuan search \"关键词\" --method 2\nsiyuan search \"关键词\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"关键词\" --group-by 1\n"
+ "Data": "siyuan search \"关键词\"\nsiyuan search \"关键词\" --notebook box1 --notebook box2\nsiyuan search \"关键词\" --path \"/目录\"\nsiyuan search \"关键词\" --type document --type heading\nsiyuan search \"关键词\" --type listItem --subtype listItem:o --subtype listItem:u\nsiyuan search \"关键词\" --method 2\nsiyuan search \"关键词\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"关键词\" --group-by 1\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120933-vnjgwwh/20211226121322-9argcys.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120933-vnjgwwh/20211226121322-9argcys.sy
index c485e7d655..d8adb3c8d4 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120933-vnjgwwh/20211226121322-9argcys.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226120933-vnjgwwh/20211226121322-9argcys.sy
@@ -6,9 +6,61 @@
"id": "20211226121322-9argcys",
"title": "類型過濾",
"type": "doc",
- "updated": "20251219205040"
+ "updated": "20260913020024"
},
"Children": [
+ {
+ "ID": "20260913020024-tbxobu2",
+ "Type": "NodeHeading",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260913020024-tbxobu2",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "搜尋類型篩選"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020024-1srsl3h",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020024-1srsl3h",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "在搜尋對話方塊中開啟 "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "搜尋類型"
+ },
+ {
+ "Type": "NodeText",
+ "Data": ",展開標題、列表區塊或列表項區塊,可分別選擇標題層級或有序、無序、任務子類型。列表區塊與列表項區塊的選擇互不影響,例如僅勾選列表項區塊下的有序即可篩選有序列表項區塊。"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020024-bdjjvg6",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020024-bdjjvg6",
+ "updated": "20260913020024"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "勾選父類型會全選該組子類型,取消父類型會清空該組;勾選任一子類型會勾選其父類型,取消最後一個子類型會取消父類型。未限制子類型的已啟用父類型在對話方塊中顯示為全選。"
+ }
+ ]
+ },
{
"ID": "20211226121740-xjez6e9",
"Type": "NodeHeading",
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20260612191214-ymtlxn2.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20260612191214-ymtlxn2.sy
index 911e0c7746..85b5c30542 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20260612191214-ymtlxn2.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226121203-rjjngpz/20260612191214-ymtlxn2.sy
@@ -6,7 +6,7 @@
"id": "20260612191214-ymtlxn2",
"title": "命令列",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -1579,7 +1579,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20260618123823-higd400",
- "updated": "20260618123823"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4359,7 +4359,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20260618123823-5n9vh1d",
- "updated": "20260618123823"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4392,7 +4392,7 @@
"Properties": {
"colgroup": "|",
"id": "20260618123823-i6ptxqr",
- "updated": "20260618123823"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4596,7 +4596,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "按子類型過濾(o=有序列表/u=無序列表/t=任務列表),可重複"
+ "Data": "按子類型過濾:h1 至 h6 為標題層級;list:o/u/t 為列表區塊,listItem:o/u/t 為列表項區塊(o=有序、u=無序、t=任務),可重複指定;不再支援裸 o/u/t"
}
]
}
@@ -4920,7 +4920,7 @@
"IsFencedCodeBlock": true,
"Properties": {
"id": "20260618123823-1depvwg",
- "updated": "20260618123823"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4933,7 +4933,7 @@
},
{
"Type": "NodeCodeBlockCode",
- "Data": "siyuan search \"關鍵字\"\nsiyuan search \"關鍵字\" --notebook box1 --notebook box2\nsiyuan search \"關鍵字\" --path \"/目錄\"\nsiyuan search \"關鍵字\" --type document --type heading\nsiyuan search \"關鍵字\" --subtype o --subtype u\nsiyuan search \"關鍵字\" --method 2\nsiyuan search \"關鍵字\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"關鍵字\" --group-by 1\n"
+ "Data": "siyuan search \"關鍵字\"\nsiyuan search \"關鍵字\" --notebook box1 --notebook box2\nsiyuan search \"關鍵字\" --path \"/目錄\"\nsiyuan search \"關鍵字\" --type document --type heading\nsiyuan search \"關鍵字\" --type listItem --subtype listItem:o --subtype listItem:u\nsiyuan search \"關鍵字\" --method 2\nsiyuan search \"關鍵字\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"關鍵字\" --group-by 1\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-a91lmk2/20240530101000-zj4k048.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-a91lmk2/20240530101000-zj4k048.sy
index 57ffe07e46..83ab0fa122 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-a91lmk2/20240530101000-zj4k048.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-a91lmk2/20240530101000-zj4k048.sy
@@ -7,9 +7,61 @@
"id": "20240530101000-zj4k048",
"title": "種類によるフィルタリング",
"type": "doc",
- "updated": "20251219205712"
+ "updated": "20260913020007"
},
"Children": [
+ {
+ "ID": "20260913020007-7v9i5ab",
+ "Type": "NodeHeading",
+ "HeadingLevel": 2,
+ "Properties": {
+ "id": "20260913020007-7v9i5ab",
+ "updated": "20260913020007"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "検索タイプの絞り込み"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020007-nufhmfu",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020007-nufhmfu",
+ "updated": "20260913020007"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "検索ダイアログで "
+ },
+ {
+ "Type": "NodeTextMark",
+ "TextMarkType": "kbd",
+ "TextMarkTextContent": "検索フィルタ"
+ },
+ {
+ "Type": "NodeText",
+ "Data": " を開き、見出し、リストブロック、リスト項目ブロックを展開すると、見出しレベルや順序付き・順序なし・タスクのサブタイプを個別に選択できます。リストブロックとリスト項目ブロックの選択は互いに影響しません。例えば、リスト項目ブロックの順序付きだけを選ぶと、順序付きリスト項目を検索できます。"
+ }
+ ]
+ },
+ {
+ "ID": "20260913020007-hwomekv",
+ "Type": "NodeParagraph",
+ "Properties": {
+ "id": "20260913020007-hwomekv",
+ "updated": "20260913020007"
+ },
+ "Children": [
+ {
+ "Type": "NodeText",
+ "Data": "親タイプを選ぶとグループ内の全サブタイプが選択され、親タイプを解除するとグループ全体が解除されます。サブタイプを一つ選ぶと親タイプが有効になり、最後のサブタイプを解除すると親タイプも解除されます。サブタイプを制限していない有効な親タイプは、ダイアログでは全選択として表示されます。"
+ }
+ ]
+ },
{
"ID": "20240530101000-jcxgbjo",
"Type": "NodeHeading",
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20260612192417-fb4ueux.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20260612192417-fb4ueux.sy
index de62c28cf2..a7a42fd7e1 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20260612192417-fb4ueux.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-g3ugxml/20260612192417-fb4ueux.sy
@@ -6,7 +6,7 @@
"id": "20260612192417-fb4ueux",
"title": "コマンドラインインターフェース",
"type": "doc",
- "updated": "20260809232000"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -1579,7 +1579,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20260618123956-poyqeb5",
- "updated": "20260618123956"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4359,7 +4359,7 @@
"HeadingLevel": 3,
"Properties": {
"id": "20260618123956-qya0v4w",
- "updated": "20260618123956"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4392,7 +4392,7 @@
"Properties": {
"colgroup": "|",
"id": "20260618123956-ioyvoyu",
- "updated": "20260618123956"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4596,7 +4596,7 @@
"Children": [
{
"Type": "NodeText",
- "Data": "サブタイプで絞り込み(o=順序付きリスト/u=順序なしリスト/t=タスクリスト)、繰り返し指定可能"
+ "Data": "サブタイプで絞り込み:h1~h6 は見出しレベル、list:o/u/t はリストブロック、listItem:o/u/t はリスト項目ブロック(o=順序付き、u=順序なし、t=タスク)。繰り返し指定可能。接頭辞のない o/u/t は非対応"
}
]
}
@@ -4920,7 +4920,7 @@
"IsFencedCodeBlock": true,
"Properties": {
"id": "20260618123956-wsc0r3z",
- "updated": "20260618123956"
+ "updated": "20260913020024"
},
"Children": [
{
@@ -4933,7 +4933,7 @@
},
{
"Type": "NodeCodeBlockCode",
- "Data": "siyuan search \"キーワード\"\nsiyuan search \"キーワード\" --notebook box1 --notebook box2\nsiyuan search \"キーワード\" --path \"/ディレクトリ\"\nsiyuan search \"キーワード\" --type document --type heading\nsiyuan search \"キーワード\" --subtype o --subtype u\nsiyuan search \"キーワード\" --method 2\nsiyuan search \"キーワード\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"キーワード\" --group-by 1\n"
+ "Data": "siyuan search \"キーワード\"\nsiyuan search \"キーワード\" --notebook box1 --notebook box2\nsiyuan search \"キーワード\" --path \"/ディレクトリ\"\nsiyuan search \"キーワード\" --type document --type heading\nsiyuan search \"キーワード\" --type listItem --subtype listItem:o --subtype listItem:u\nsiyuan search \"キーワード\" --method 2\nsiyuan search \"キーワード\" --order-by 4 --page 1 --page-size 20\nsiyuan search \"キーワード\" --group-by 1\n"
},
{
"Type": "NodeCodeBlockFenceCloseMarker",
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 8be0651fe7..cc8ac98f6e 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -834,9 +834,8 @@ export const getLocalStorage = (cb: () => void) => {
Object.keys(window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes).length === 0) {
window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes = Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES);
}
- // Migrate stored search data to include subTypes when absent
- if (!window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes ||
- Object.keys(window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes).length === 0) {
+ // 缺少子类型配置时补充默认值。
+ if (!window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes) {
window.siyuan.storage[Constants.LOCAL_SEARCHDATA].subTypes = getDefaultSubType();
}
const closedTabs = window.siyuan.storage[Constants.LOCAL_CLOSED_TABS];
diff --git a/app/src/search/getDefault.ts b/app/src/search/getDefault.ts
index 3b9b25823d..31c390b2c6 100644
--- a/app/src/search/getDefault.ts
+++ b/app/src/search/getDefault.ts
@@ -26,7 +26,8 @@ export const getDefaultType = () => {
export const getDefaultSubType = (): Config.IUILayoutTabSearchConfigSubTypes => {
return {
- h1: false, h2: false, h3: false, h4: false, h5: false, h6: false,
- o: false, u: false, t: false,
+ heading: {h1: false, h2: false, h3: false, h4: false, h5: false, h6: false},
+ list: {o: false, u: false, t: false},
+ listItem: {o: false, u: false, t: false},
};
};
diff --git a/app/src/search/menu.ts b/app/src/search/menu.ts
index 2891c11daf..abd55b3e47 100644
--- a/app/src/search/menu.ts
+++ b/app/src/search/menu.ts
@@ -9,6 +9,7 @@ import {escapeHtml} from "../util/escape";
import {isSensitiveSearchConfig, setStorageVal} from "../protyle/util/compatibility";
import {confirmDialog} from "../dialog/confirmDialog";
import {goUnRef, updateSearchResult} from "../mobile/menu/search";
+import {bindSearchSubtypeFilters} from "./subTypes";
import {getDefaultSubType} from "./getDefault";
import {hasSearchConfigTemporaryPath, resolvePersistedSearchConfig} from "./config";
@@ -62,7 +63,7 @@ export const filterMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => vo
${window.siyuan.languages["heading" + h.charAt(1)]}
</div>
<span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-subtype="${h}" type="checkbox"${config.subTypes?.[h] ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-group="heading" data-subtype="${h}" type="checkbox"${config.subTypes?.heading?.[h] ? " checked" : ""}>
</label>`).join("")}<div></div>
</div>
<label class="fn__flex b3-label">
@@ -165,45 +166,27 @@ export const filterMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => vo
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type="superBlock" type="checkbox"${config.types.superBlock ? " checked" : ""}>
</label>
+ ${(["list", "listItem"] as const).map((group) => `
<div class="fn__flex b3-label">
- <span style="margin:0 4px 0 -20px" class="b3-list-item__toggle b3-list-item__toggle--hl fn__pointer" data-toggle-subtype="list">
+ <span style="margin:0 4px 0 -20px" class="b3-list-item__toggle b3-list-item__toggle--hl fn__pointer">
<svg class="b3-list-item__arrow"><use xlink:href="#iconRight"></use></svg>
</span>
- <svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconList"></use></svg>
+ <svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#${group === "list" ? "iconList" : "iconListItem"}"></use></svg>
<span class="fn__space"></span>
<div class="fn__flex-1 fn__flex-center">
- ${window.siyuan.languages.list1} <sup>[1] [2]</sup>
+ ${window.siyuan.languages[group === "list" ? "list1" : "listItem"]} <sup>[1]</sup>
</div>
<span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-type="list" type="checkbox"${config.types.list ? " checked" : ""}>
+ <input class="b3-switch fn__flex-center" data-type="${group}" type="checkbox"${config.types[group] ? " checked" : ""}>
</div>
- <div class="fn__none" style="padding-left: 20px;">
- <label class="fn__flex b3-label">
- <div class="fn__flex-1 fn__flex-center">${window.siyuan.languages["ordered-list"]}</div>
- <span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-subtype="o" type="checkbox"${config.subTypes?.o ? " checked" : ""}>
- </label>
- <label class="fn__flex b3-label">
- <div class="fn__flex-1 fn__flex-center">${window.siyuan.languages.unorderedList}</div>
- <span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-subtype="u" type="checkbox"${config.subTypes?.u ? " checked" : ""}>
- </label>
+ <div class="fn__none" style="padding-left: 20px">
+ ${(["o", "u", "t"] as const).map((subtype) => `
<label class="fn__flex b3-label">
- <div class="fn__flex-1 fn__flex-center">${window.siyuan.languages.check}</div>
+ <div class="fn__flex-1 fn__flex-center">${window.siyuan.languages[{o: "ordered-list", u: "unorderedList", t: "check"}[subtype]]}</div>
<span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-subtype="t" type="checkbox"${config.subTypes?.t ? " checked" : ""}>
- </label>
- <div></div>
- </div>
- <label class="fn__flex b3-label">
- <svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconListItem"></use></svg>
- <span class="fn__space"></span>
- <div class="fn__flex-1 fn__flex-center">
- ${window.siyuan.languages.listItem} <sup>[1]</sup>
- </div>
- <span class="fn__space"></span>
- <input class="b3-switch fn__flex-center" data-type="listItem" type="checkbox"${config.types.listItem ? " checked" : ""}>
- </label>
+ <input class="b3-switch fn__flex-center" data-group="${group}" data-subtype="${subtype}" type="checkbox"${config.subTypes?.[group]?.[subtype] ? " checked" : ""}>
+ </label>`).join("")}<div></div>
+ </div>`).join("")}
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconFile"></use></svg>
<span class="fn__space"></span>
@@ -216,7 +199,6 @@ export const filterMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => vo
<span class="fn__space"></span>
<div class="fn__flex-1">
<div class="b3-label__text">[1] ${window.siyuan.languages.containerBlockTip1}</div>
- <div class="b3-label__text">[2] ${window.siyuan.languages.searchSubTypeListTip}</div>
</div>
</div>
<div class="b3-dialog__action">
@@ -235,57 +217,18 @@ export const filterMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => vo
item.firstElementChild.classList.toggle("b3-list-item__arrow--open");
});
});
- // Keep parent and subtype toggles in sync.
- filterDialog.element.querySelectorAll("input[data-subtype]").forEach((item: HTMLInputElement) => {
- item.addEventListener("change", () => {
- if (!item.checked) {
- return;
- }
- ({
- h1: ["heading"], h2: ["heading"], h3: ["heading"],
- h4: ["heading"], h5: ["heading"], h6: ["heading"],
- o: ["list", "listItem"],
- u: ["list", "listItem"],
- t: ["list", "listItem"],
- })[item.getAttribute("data-subtype")].forEach((parentType) => {
- const parentElement = filterDialog.element.querySelector(`input[data-type="${parentType}"]`) as HTMLInputElement;
- if (parentElement && !parentElement.checked) {
- parentElement.checked = true;
- }
- });
- });
- });
- const parentSubtypes: Record<string, string[]> = {
- heading: ["h1", "h2", "h3", "h4", "h5", "h6"],
- list: ["o", "u", "t"],
- listItem: ["o", "u", "t"],
- };
- Object.keys(parentSubtypes).forEach((key) => {
- const parentElement = filterDialog.element.querySelector(`input[data-type="${key}"]`) as HTMLInputElement;
- parentElement.addEventListener("change", () => {
- if (parentElement.checked) {
- return;
- }
- parentSubtypes[key].forEach((subtype) => {
- const subtypeBox = filterDialog.element.querySelector(`input[data-subtype="${subtype}"]`) as HTMLInputElement;
- if (subtypeBox && subtypeBox.checked) {
- subtypeBox.checked = false;
- }
- });
- });
- });
+ bindSearchSubtypeFilters(filterDialog.element);
const btnsElement = filterDialog.element.querySelectorAll(".b3-button");
btnsElement[0].addEventListener("click", () => {
filterDialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
- if (!config.subTypes) {
- config.subTypes = getDefaultSubType();
- }
+ config.subTypes = getDefaultSubType();
filterDialog.element.querySelectorAll(".b3-switch").forEach((item: HTMLInputElement) => {
const subtype = item.getAttribute("data-subtype");
if (subtype) {
- config.subTypes[subtype as keyof Config.IUILayoutTabSearchConfigSubTypes] = item.checked;
+ const group = item.getAttribute("data-group") as keyof Config.IUILayoutTabSearchConfigSubTypes;
+ (config.subTypes[group] as Record<string, boolean>)[subtype] = item.checked;
} else {
config.types[item.getAttribute("data-type") as keyof (typeof config.types)] = item.checked;
}
diff --git a/app/src/search/subTypes.ts b/app/src/search/subTypes.ts
new file mode 100644
index 0000000000..fca7e7ed1b
--- /dev/null
+++ b/app/src/search/subTypes.ts
@@ -0,0 +1,19 @@
+export const bindSearchSubtypeFilters = (element: HTMLElement) => {
+ ["heading", "list", "listItem"].forEach((group) => {
+ const parent = element.querySelector<HTMLInputElement>(`input[data-type="${group}"]`);
+ const children = Array.from(element.querySelectorAll<HTMLInputElement>(`input[data-group="${group}"]`));
+ // 未限制子类型时全选该组,使父类型与子类型的显示保持一致。
+ const unrestricted = !children.some((child) => child.checked);
+ children.forEach((child) => {
+ child.checked = parent.checked && (unrestricted || child.checked);
+ child.addEventListener("change", () => {
+ parent.checked = children.some((input) => input.checked);
+ });
+ });
+ parent.addEventListener("change", () => {
+ children.forEach((child) => {
+ child.checked = parent.checked;
+ });
+ });
+ });
+};
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index a2aa85a5f7..9185823233 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -2627,22 +2627,12 @@ declare namespace Config {
}
/**
- * Search subtype filtering. When all flags within a category (heading or
- * list) are false, that category is not subtype-filtered (parent type
- * filter applies as before). When at least one flag is true, only blocks
- * matching the selected subtypes are returned for that category.
+ * 子类型按父类型独立筛选,组内全否表示不限制子类型。
*/
export interface IUILayoutTabSearchConfigSubTypes {
- h1: boolean;
- h2: boolean;
- h3: boolean;
- h4: boolean;
- h5: boolean;
- h6: boolean;
- // List subtypes — apply to both list and listItem
- o: boolean;
- u: boolean;
- t: boolean;
+ heading: {h1: boolean, h2: boolean, h3: boolean, h4: boolean, h5: boolean, h6: boolean};
+ list: {o: boolean, u: boolean, t: boolean};
+ listItem: {o: boolean, u: boolean, t: boolean};
}
/**
diff --git a/app/tests/searchSubTypes.test.ts b/app/tests/searchSubTypes.test.ts
new file mode 100644
index 0000000000..2cd0c4c194
--- /dev/null
+++ b/app/tests/searchSubTypes.test.ts
@@ -0,0 +1,74 @@
+import assert from "node:assert/strict";
+import {test} from "node:test";
+import {bindSearchSubtypeFilters} from "../src/search/subTypes";
+
+class Input extends EventTarget {
+ constructor(public checked = false) {
+ super();
+ }
+
+ toggle() {
+ this.checked = !this.checked;
+ this.dispatchEvent(new Event("change"));
+ }
+}
+
+const createFilters = (enabled = false, selected = false) => {
+ const groups = ["heading", "list", "listItem"].map((name, index) => ({
+ name,
+ parent: new Input(enabled),
+ children: Array.from({length: index === 0 ? 6 : 3}, (_, i) => new Input(selected && i === 0)),
+ }));
+ const find = (selector: string) => groups.find((group) => selector.includes(`"${group.name}"`));
+ const element = {
+ querySelector: (selector: string) => find(selector).parent,
+ querySelectorAll: (selector: string) => find(selector).children,
+ };
+ bindSearchSubtypeFilters(element as unknown as HTMLElement);
+ return groups;
+};
+
+test("unrestricted enabled groups display all subtypes; disabled groups clear stale selections", () => {
+ for (const enabled of [false, true]) {
+ for (const selected of [false, true]) {
+ for (const group of createFilters(enabled, selected)) {
+ assert.equal(group.parent.checked, enabled);
+ assert.deepEqual(group.children.map((child) => child.checked),
+ group.children.map((_, i) => enabled && (!selected || i === 0)));
+ }
+ }
+ }
+});
+
+test("each reachable selection and each next operation preserve independent symmetric cascading", () => {
+ for (let groupIndex = 0; groupIndex < 3; groupIndex++) {
+ const size = groupIndex === 0 ? 6 : 3;
+ for (let mask = 0; mask < 1 << size; mask++) {
+ for (let operation = -1; operation < size; operation++) {
+ const groups = createFilters();
+ const target = groups[groupIndex];
+ target.children.forEach((child, i) => {
+ if (mask & (1 << i)) {
+ child.toggle();
+ }
+ });
+ const before = groups.map((group) => [group.parent.checked, ...group.children.map((child) => child.checked)]);
+ if (operation === -1) {
+ target.parent.toggle();
+ assert.ok(target.children.every((child) => child.checked === target.parent.checked));
+ } else {
+ target.children[operation].toggle();
+ target.children.forEach((child, i) => {
+ assert.equal(child.checked, i === operation ? !before[groupIndex][i + 1] : before[groupIndex][i + 1]);
+ });
+ }
+ groups.forEach((group, i) => {
+ assert.equal(group.parent.checked, group.children.some((child) => child.checked));
+ if (i !== groupIndex) {
+ assert.deepEqual([group.parent.checked, ...group.children.map((child) => child.checked)], before[i]);
+ }
+ });
+ }
+ }
+ }
+});
diff --git a/docs/API.ja.md b/docs/API.ja.md
index d34f75a39c..6abd939f74 100644
--- a/docs/API.ja.md
+++ b/docs/API.ja.md
@@ -2759,7 +2759,7 @@
* `k`:検索キーワード
* `r`:置換キーワード
* `types`:ブロックタイプのフラグ。`mathBlock`、`table`、`blockquote`、`superBlock`、`paragraph`、`document`、`heading`、`list`、`listItem`、`codeBlock`、`htmlBlock`、`embedBlock`、`databaseBlock`、`audioBlock`、`videoBlock`、`iframeBlock`、`widgetBlock`、`callout` を使用できます
-* `subTypes`:ブロックサブタイプのフラグ。`h1` から `h6` は見出しレベルを、`o`、`u`、`t` はそれぞれ番号付きリスト、箇条書きリスト、タスクリストを示します
+* `subTypes`:独立したサブタイプグループです。`heading` は `h1` から `h6`、`list` と `listItem` はそれぞれ `o`(順序付き)、`u`(順序なし)、`t`(タスク)を指定します。グループが省略、空、または全フラグが `false` の場合、その親タイプのサブタイプは制限されません。親タイプは `types` で有効にする必要があります。旧形式の `h1` から `h6` および `o`、`u`、`t` を含む未知のトップレベルキーはエラーなく無視されるため、旧形式で保存したサブタイプは選択して保存し直してください
* `replaceTypes`:置換タイプのフラグ。`text`、`imgText`、`imgTitle`、`imgSrc`、`aText`、`aTitle`、`aHref`、`code`、`em`、`strong`、`inlineMath`、`inlineMemo`、`blockRef`、`fileAnnotationRef`、`kbd`、`mark`、`s`、`sub`、`sup`、`tag`、`u`、`docTitle`、`codeBlock`、`mathBlock`、`htmlBlock` を使用できます
`types`、`subTypes`、`replaceTypes` で省略された真偽値フラグは `false` として扱われます。
@@ -2793,10 +2793,15 @@
"r": "",
"types": {
"document": true,
- "paragraph": true
+ "paragraph": true,
+ "heading": true,
+ "list": true,
+ "listItem": true
},
"subTypes": {
- "h1": true
+ "heading": {"h1": true},
+ "list": {"o": true},
+ "listItem": {"t": true}
},
"replaceTypes": {
"text": true
diff --git a/docs/API.md b/docs/API.md
index 69153ba2f5..8a8bd4da8c 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -2820,7 +2820,7 @@ Saved search criteria use the following fields:
* `k`: Search keyword
* `r`: Replacement keyword
* `types`: Block type flags. Supported keys are `mathBlock`, `table`, `blockquote`, `superBlock`, `paragraph`, `document`, `heading`, `list`, `listItem`, `codeBlock`, `htmlBlock`, `embedBlock`, `databaseBlock`, `audioBlock`, `videoBlock`, `iframeBlock`, `widgetBlock`, and `callout`
-* `subTypes`: Block subtype flags. `h1` through `h6` select heading levels; `o`, `u`, and `t` select ordered, unordered, and task lists
+* `subTypes`: Independent subtype groups: `heading` accepts `h1` through `h6`; `list` and `listItem` each accept `o` (ordered), `u` (unordered), and `t` (task). A missing or empty group, or a group with all flags `false`, leaves that parent type unrestricted by subtype. The parent must still be enabled in `types`. Unknown top-level keys, including the former flat `h1`–`h6` and `o`/`u`/`t` flags, are ignored without error; saved subtype selections in that format must be selected and saved again
* `replaceTypes`: Replacement type flags. Supported keys are `text`, `imgText`, `imgTitle`, `imgSrc`, `aText`, `aTitle`, `aHref`, `code`, `em`, `strong`, `inlineMath`, `inlineMemo`, `blockRef`, `fileAnnotationRef`, `kbd`, `mark`, `s`, `sub`, `sup`, `tag`, `u`, `docTitle`, `codeBlock`, `mathBlock`, and `htmlBlock`
Boolean flags omitted from `types`, `subTypes`, or `replaceTypes` are treated as `false`.
@@ -2854,10 +2854,15 @@ Creates a criterion or completely replaces the existing criterion with the same
"r": "",
"types": {
"document": true,
- "paragraph": true
+ "paragraph": true,
+ "heading": true,
+ "list": true,
+ "listItem": true
},
"subTypes": {
- "h1": true
+ "heading": {"h1": true},
+ "list": {"o": true},
+ "listItem": {"t": true}
},
"replaceTypes": {
"text": true
diff --git a/docs/API.zh-CN.md b/docs/API.zh-CN.md
index b3074c67be..0fb2e452f4 100644
--- a/docs/API.zh-CN.md
+++ b/docs/API.zh-CN.md
@@ -2775,7 +2775,7 @@ if (response.code === 0 && response.data) {
* `k`:搜索关键字
* `r`:替换关键字
* `types`:块类型开关,支持 `mathBlock`、`table`、`blockquote`、`superBlock`、`paragraph`、`document`、`heading`、`list`、`listItem`、`codeBlock`、`htmlBlock`、`embedBlock`、`databaseBlock`、`audioBlock`、`videoBlock`、`iframeBlock`、`widgetBlock` 和 `callout`
-* `subTypes`:块子类型开关,`h1` 至 `h6` 表示标题级别,`o`、`u` 和 `t` 分别表示有序列表、无序列表和任务列表
+* `subTypes`:独立的子类型分组,`heading` 使用 `h1` 至 `h6`,`list` 和 `listItem` 分别使用 `o`(有序)、`u`(无序)和 `t`(任务)。分组缺省、为空或所有开关为 `false` 时,不限制该父类型的子类型;父类型仍须在 `types` 中启用。未知顶层键(包括旧扁平格式的 `h1` 至 `h6` 和 `o`、`u`、`t`)会被忽略且不报错,旧格式中保存的子类型选择需要重新选择并保存
* `replaceTypes`:替换类型开关,支持 `text`、`imgText`、`imgTitle`、`imgSrc`、`aText`、`aTitle`、`aHref`、`code`、`em`、`strong`、`inlineMath`、`inlineMemo`、`blockRef`、`fileAnnotationRef`、`kbd`、`mark`、`s`、`sub`、`sup`、`tag`、`u`、`docTitle`、`codeBlock`、`mathBlock` 和 `htmlBlock`
`types`、`subTypes` 或 `replaceTypes` 中省略的布尔开关按 `false` 处理。
@@ -2809,10 +2809,15 @@ if (response.code === 0 && response.data) {
"r": "",
"types": {
"document": true,
- "paragraph": true
+ "paragraph": true,
+ "heading": true,
+ "list": true,
+ "listItem": true
},
"subTypes": {
- "h1": true
+ "heading": {"h1": true},
+ "list": {"o": true},
+ "listItem": {"t": true}
},
"replaceTypes": {
"text": true
diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go
index fc1d521833..14bb7815c5 100644
--- a/kernel/api/filetree.go
+++ b/kernel/api/filetree.go
@@ -1512,14 +1512,7 @@ func getDoc(c *gin.Context) {
queryTypes[t] = b.(bool)
}
}
- var querySubTypes map[string]bool
- if querySubTypesArg := arg["querySubTypes"]; nil != querySubTypesArg {
- typesArg := querySubTypesArg.(map[string]any)
- querySubTypes = map[string]bool{}
- for t, b := range typesArg {
- querySubTypes[t] = b.(bool)
- }
- }
+ querySubTypes := parseSearchSubTypes(arg["querySubTypes"])
m := arg["mode"] // 0: 仅当前 ID,1:向上 2:向下,3:上下都加载,4:加载末尾
mode := 0
diff --git a/kernel/api/search.go b/kernel/api/search.go
index a81cad55ec..e2334e2d0f 100644
--- a/kernel/api/search.go
+++ b/kernel/api/search.go
@@ -666,13 +666,7 @@ func parseSearchBlockArgs(arg map[string]any) (page, pageSize int, query string,
}
}
- if nil != arg["subTypes"] {
- subTypesArg := arg["subTypes"].(map[string]any)
- subTypes = map[string]bool{}
- for t, b := range subTypesArg {
- subTypes[t] = b.(bool)
- }
- }
+ subTypes = parseSearchSubTypes(arg["subTypes"])
// method:0:关键字,1:查询语法,2:SQL,3:正则表达式
methodArg := arg["method"]
diff --git a/kernel/api/search_subtypes.go b/kernel/api/search_subtypes.go
new file mode 100644
index 0000000000..3c33ca8e7e
--- /dev/null
+++ b/kernel/api/search_subtypes.go
@@ -0,0 +1,43 @@
+// SiYuan - From thought to insight, with agents
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+package api
+
+// parseSearchSubTypes 仅解析已知分组,忽略未知键及旧的顶层子类型键。
+func parseSearchSubTypes(value any) map[string]bool {
+ groups, ok := value.(map[string]any)
+ if !ok {
+ return nil
+ }
+ ret := map[string]bool{}
+ for _, group := range []struct {
+ name string
+ prefix string
+ keys []string
+ }{
+ {"heading", "", []string{"h1", "h2", "h3", "h4", "h5", "h6"}},
+ {"list", "list:", []string{"o", "u", "t"}},
+ {"listItem", "listItem:", []string{"o", "u", "t"}},
+ } {
+ values, _ := groups[group.name].(map[string]any)
+ for _, key := range group.keys {
+ if selected, _ := values[key].(bool); selected {
+ ret[group.prefix+key] = true
+ }
+ }
+ }
+ return ret
+}
diff --git a/kernel/api/search_subtypes_test.go b/kernel/api/search_subtypes_test.go
new file mode 100644
index 0000000000..84c50d3d8b
--- /dev/null
+++ b/kernel/api/search_subtypes_test.go
@@ -0,0 +1,48 @@
+// SiYuan - From thought to insight, with agents
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+package api
+
+import (
+ "encoding/json"
+ "reflect"
+ "testing"
+)
+
+func TestParseSearchSubTypes(t *testing.T) {
+ for _, tc := range []struct {
+ name string
+ json string
+ want map[string]bool
+ }{
+ {"empty", `{}`, map[string]bool{}},
+ {"null", `null`, nil},
+ {"legacy", `{"h1":true,"h2":true,"h3":true,"h4":true,"h5":true,"h6":true,"o":true,"u":true,"t":true}`, map[string]bool{}},
+ {"independent", `{"heading":{"h2":true},"list":{"o":true,"t":false},"listItem":{"t":true}}`, map[string]bool{"h2": true, "list:o": true, "listItem:t": true}},
+ {"unknown", `{"o":true,"unknown":{"o":true},"heading":{"o":true},"list":{"h1":true,"u":true},"listItem":{"t":"true"}}`, map[string]bool{"list:u": true}},
+ {"invalidGroups", `{"heading":true,"list":null,"listItem":[]}`, map[string]bool{}},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ var value any
+ if err := json.Unmarshal([]byte(tc.json), &value); err != nil {
+ t.Fatal(err)
+ }
+ if got := parseSearchSubTypes(value); !reflect.DeepEqual(got, tc.want) {
+ t.Fatalf("got %v, want %v", got, tc.want)
+ }
+ })
+ }
+}
diff --git a/kernel/api/storage_test.go b/kernel/api/storage_test.go
index ad2eccfc48..a800672959 100644
--- a/kernel/api/storage_test.go
+++ b/kernel/api/storage_test.go
@@ -51,8 +51,8 @@ func TestCriteriaCRUD(t *testing.T) {
return recorder
}
type criterionData struct {
- Name string `json:"name"`
- SubTypes map[string]bool `json:"subTypes"`
+ Name string `json:"name"`
+ SubTypes model.SearchSubTypes `json:"subTypes"`
}
getCriteria := func() []criterionData {
t.Helper()
@@ -70,21 +70,21 @@ func TestCriteriaCRUD(t *testing.T) {
return response.Data
}
- setRecorder := perform("/api/storage/setCriterion", `{"criterion":{"name":"Public notes","subTypes":{"h1":true}}}`)
+ setRecorder := perform("/api/storage/setCriterion", `{"criterion":{"name":"Public notes","subTypes":{"heading":{"h1":true},"list":{"o":true},"listItem":{"t":true}}}}`)
if responseCode(t, setRecorder) != 0 {
t.Fatalf("set criterion failed: %s", setRecorder.Body.String())
}
criteria := getCriteria()
- if len(criteria) != 1 || criteria[0].Name != "Public notes" || !criteria[0].SubTypes["h1"] {
+ if len(criteria) != 1 || criteria[0].Name != "Public notes" || !criteria[0].SubTypes.Heading["h1"] || !criteria[0].SubTypes.List["o"] || !criteria[0].SubTypes.ListItem["t"] {
t.Fatalf("criterion was not persisted: %#v", criteria)
}
- overwriteRecorder := perform("/api/storage/setCriterion", `{"criterion":{"name":"Public notes","subTypes":{"h2":true}}}`)
+ overwriteRecorder := perform("/api/storage/setCriterion", `{"criterion":{"name":"Public notes","subTypes":{"heading":{"h2":true},"list":{"u":true},"listItem":{"o":true}}}}`)
if responseCode(t, overwriteRecorder) != 0 {
t.Fatalf("overwrite criterion failed: %s", overwriteRecorder.Body.String())
}
criteria = getCriteria()
- if len(criteria) != 1 || criteria[0].SubTypes["h1"] || !criteria[0].SubTypes["h2"] {
+ if len(criteria) != 1 || criteria[0].SubTypes.Heading["h1"] || !criteria[0].SubTypes.Heading["h2"] || criteria[0].SubTypes.List["o"] || !criteria[0].SubTypes.List["u"] || criteria[0].SubTypes.ListItem["t"] || !criteria[0].SubTypes.ListItem["o"] {
t.Fatalf("criterion was not overwritten: %#v", criteria)
}
diff --git a/kernel/cli/cmd/search.go b/kernel/cli/cmd/search.go
index 94c4bed70f..ae2c59d7fb 100644
--- a/kernel/cli/cmd/search.go
+++ b/kernel/cli/cmd/search.go
@@ -215,7 +215,7 @@ func init() {
searchCmd.Flags().StringArrayP("notebook", "n", nil, "notebook ID filter (repeatable)")
searchCmd.Flags().StringArray("path", nil, "path prefix filter (repeatable)")
searchCmd.Flags().StringArrayP("type", "t", nil, "block type filter, repeatable (document heading paragraph list listItem codeBlock mathBlock table blockquote superBlock htmlBlock embedBlock databaseBlock audioBlock videoBlock iframeBlock widgetBlock callout)")
- searchCmd.Flags().StringArray("subtype", nil, "block subtype filter, repeatable (o u t)")
+ searchCmd.Flags().StringArray("subtype", nil, "block subtype filter, repeatable (h1-h6, list:o, list:u, list:t, listItem:o, listItem:u, listItem:t)")
searchCmd.Flags().IntP("method", "m", 0, "search method: 0=keyword 1=query-syntax 2=sql 3=regex 4=semantic (asset mode ignores 4=semantic; uses 0-3 with same meanings)")
searchCmd.Flags().IntP("order-by", "o", 0, "order — blocks: 0=type 1=created-asc 2=created-desc 3=updated-asc 4=updated-desc 5=content 6=relevance-asc 7=relevance-desc; asset: 0=relevance-desc 1=relevance-asc 2=updated-asc 3=updated-desc")
searchCmd.Flags().IntP("page", "p", 1, "page number")
diff --git a/kernel/mcp/tools/search.go b/kernel/mcp/tools/search.go
index 9a7955e9e0..a8d1e0bf3b 100644
--- a/kernel/mcp/tools/search.go
+++ b/kernel/mcp/tools/search.go
@@ -36,7 +36,7 @@ var SearchTool = &Tool{
"notebook": {Type: "string", Description: "Comma-separated notebook IDs to filter (optional, fulltext/semantic only)"},
"path": {Type: "string", Description: "Comma-separated path prefixes to filter (optional, fulltext/semantic only); for getasset, a single asset file path like 'assets/foo.pdf'"},
"type": {Type: "string", Description: "Comma-separated block types to filter, e.g. 'document,heading,paragraph' (optional, fulltext/semantic only)"},
- "subtype": {Type: "string", Description: "Comma-separated block subtypes to filter, e.g. 'o,u,t' (optional, fulltext/semantic only)"},
+ "subtype": {Type: "string", Description: "Comma-separated block subtypes to filter, e.g. 'h1,list:o,listItem:t' (heading: h1-h6; list/listItem: o=ordered, u=unordered, t=task) (optional, fulltext/semantic only)"},
"ext": {Type: "string", Description: "Comma-separated asset file extensions to filter, e.g. 'pdf,docx,xlsx' (optional, asset only)"},
"method": {Type: "number", Description: "Search method: fulltext/asset 0=keyword 1=query-syntax 2=sql 3=regex (default 0)"},
"orderBy": {Type: "number", Description: "Sort order — fulltext: 0=type 1=created-asc 2=created-desc 3=updated-asc 4=updated-desc 5=content 6=relevance-asc 7=relevance-desc; asset: 0=relevance-desc 1=relevance-asc 2=updated-asc 3=updated-desc (default 0)"},
diff --git a/kernel/model/search.go b/kernel/model/search.go
index d73b1a5dde..ae9ab35841 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -2057,16 +2057,7 @@ func buildExactAliasSearchOrderCondition(field, query string) string {
return "(',' || " + field + " || ',') LIKE '%," + escapedQuery + ",%' ESCAPE '\\'"
}
-// buildTypeFilter returns a complete SQL predicate (including outer parens)
-// suitable for appending after "AND". When subTypes is empty, the result is
-// equivalent to the previous "type IN (...)" behavior. When subTypes contains
-// at least one heading-level (h1..h6) or list (o/u/t) flag, the predicate is
-// extended so that the corresponding parent type (heading or list/listItem)
-// is restricted to the selected subtypes via "subtype IN (...)".
-//
-// Example output:
-//
-// (type IN ('p','c') OR (type = 'h' AND subtype IN ('h1','h2')))
+// buildTypeFilter 按父类型独立限制子类型,组内为空时仅按父类型筛选。
func buildTypeFilter(types, subTypes map[string]bool, alias ...string) string {
prefix := ""
if 0 < len(alias) && "" != alias[0] {
@@ -2120,18 +2111,6 @@ func buildTypeFilter(types, subTypes map[string]bool, alias ...string) string {
s.TabItem = Conf.Search.TabItem
}
- var headingSubs, listSubs []string
- for _, h := range []string{"h1", "h2", "h3", "h4", "h5", "h6"} {
- if subTypes[h] {
- headingSubs = append(headingSubs, h)
- }
- }
- for _, l := range []string{"o", "u", "t"} {
- if subTypes[l] {
- listSubs = append(listSubs, l)
- }
- }
-
var simpleTypes []string
addSimple := func(enabled bool, abbr string) {
if enabled {
@@ -2158,29 +2137,30 @@ func buildTypeFilter(types, subTypes map[string]bool, alias ...string) string {
var clauses []string
- if s.Heading {
- headingAbbr := treenode.TypeAbbr(ast.NodeHeading.String())
- if 0 == len(headingSubs) {
- simpleTypes = append(simpleTypes, headingAbbr)
- } else {
- clauses = append(clauses, fmt.Sprintf("(%stype = '%s' AND %ssubtype IN (%s))",
- prefix, headingAbbr, prefix, sqlQuoteJoin(headingSubs)))
+ for _, group := range []struct {
+ enabled bool
+ abbr string
+ prefix string
+ keys []string
+ }{
+ {s.Heading, "h", "", []string{"h1", "h2", "h3", "h4", "h5", "h6"}},
+ {s.List, "l", "list:", []string{"o", "u", "t"}},
+ {s.ListItem, "i", "listItem:", []string{"o", "u", "t"}},
+ } {
+ if !group.enabled {
+ continue
}
- }
-
- var listTypes []string
- if s.List {
- listTypes = append(listTypes, treenode.TypeAbbr(ast.NodeList.String()))
- }
- if s.ListItem {
- listTypes = append(listTypes, treenode.TypeAbbr(ast.NodeListItem.String()))
- }
- if 0 < len(listTypes) {
- if 0 == len(listSubs) {
- simpleTypes = append(simpleTypes, listTypes...)
+ var selected []string
+ for _, key := range group.keys {
+ if subTypes[group.prefix+key] {
+ selected = append(selected, key)
+ }
+ }
+ if 0 == len(selected) {
+ simpleTypes = append(simpleTypes, group.abbr)
} else {
- clauses = append(clauses, fmt.Sprintf("(%stype IN (%s) AND %ssubtype IN (%s))",
- prefix, sqlQuoteJoin(listTypes), prefix, sqlQuoteJoin(listSubs)))
+ clauses = append(clauses, fmt.Sprintf("(%stype = '%s' AND %ssubtype IN (%s))",
+ prefix, group.abbr, prefix, sqlQuoteJoin(selected)))
}
}
diff --git a/kernel/model/search_subtypes.go b/kernel/model/search_subtypes.go
new file mode 100644
index 0000000000..1403bb1b4d
--- /dev/null
+++ b/kernel/model/search_subtypes.go
@@ -0,0 +1,24 @@
+// SiYuan - From thought to insight, with agents
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+package model
+
+// SearchSubTypes 保存各父类型的子类型选择,未知顶层字段由 JSON 解析器忽略。
+type SearchSubTypes struct {
+ Heading map[string]bool `json:"heading"`
+ List map[string]bool `json:"list"`
+ ListItem map[string]bool `json:"listItem"`
+}
diff --git a/kernel/model/search_subtypes_test.go b/kernel/model/search_subtypes_test.go
new file mode 100644
index 0000000000..592ff76f0b
--- /dev/null
+++ b/kernel/model/search_subtypes_test.go
@@ -0,0 +1,61 @@
+// SiYuan - From thought to insight, with agents
+// Copyright (c) 2020-present, b3log.org
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+package model
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestBuildTypeFilterSubTypes(t *testing.T) {
+ previous := Conf
+ Conf = NewAppConf()
+ t.Cleanup(func() { Conf = previous })
+ for _, tc := range []struct {
+ name string
+ types map[string]bool
+ subTypes map[string]bool
+ alias string
+ want string
+ }{
+ {"heading", map[string]bool{"heading": true}, map[string]bool{"h2": true}, "", "((type = 'h' AND subtype IN ('h2')))"},
+ {"list", map[string]bool{"list": true, "listItem": true}, map[string]bool{"list:o": true}, "", "(type IN ('i') OR (type = 'l' AND subtype IN ('o')))"},
+ {"listItem", map[string]bool{"list": true, "listItem": true}, map[string]bool{"listItem:t": true}, "", "(type IN ('l') OR (type = 'i' AND subtype IN ('t')))"},
+ {"onlyListItem", map[string]bool{"listItem": true}, map[string]bool{"list:o": true, "listItem:o": true}, "", "((type = 'i' AND subtype IN ('o')))"},
+ {"empty", map[string]bool{"heading": true, "list": true, "listItem": true}, nil, "", "(type IN ('h','l','i'))"},
+ {"false", map[string]bool{"list": true}, map[string]bool{"list:o": false}, "", "(type IN ('l'))"},
+ {"legacyList", map[string]bool{"list": true, "listItem": true}, map[string]bool{"o": true}, "", "(type IN ('l','i'))"},
+ {"mixed", map[string]bool{"paragraph": true, "heading": true, "list": true, "listItem": true}, map[string]bool{"h1": true, "h3": true, "list:u": true, "listItem:t": true}, "b.", "(b.type IN ('p') OR (b.type = 'h' AND b.subtype IN ('h1','h3')) OR (b.type = 'l' AND b.subtype IN ('u')) OR (b.type = 'i' AND b.subtype IN ('t')))"},
+ {"disabled", map[string]bool{}, map[string]bool{"h1": true, "list:o": true, "listItem:t": true}, "", "(1 = 0)"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := buildTypeFilter(tc.types, tc.subTypes, tc.alias); got != tc.want {
+ t.Fatalf("got %s, want %s", got, tc.want)
+ }
+ })
+ }
+}
+
+func TestSearchSubTypesJSON(t *testing.T) {
+ var criterion Criterion
+ if err := json.Unmarshal([]byte(`{"subTypes":{"h1":true,"o":true,"heading":{"h2":true},"list":{"o":true},"listItem":{"t":true}}}`), &criterion); err != nil {
+ t.Fatal(err)
+ }
+ if criterion.SubTypes.Heading["h1"] || !criterion.SubTypes.Heading["h2"] || !criterion.SubTypes.List["o"] || !criterion.SubTypes.ListItem["t"] {
+ t.Fatalf("unexpected subtypes: %+v", criterion.SubTypes)
+ }
+}
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index 194b18a932..4335f3feda 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -135,7 +135,7 @@ type Criterion struct {
K string `json:"k"` // 搜索关键字
R string `json:"r"` // 替换关键字
Types *CriterionTypes `json:"types"` // 类型过滤选项
- SubTypes map[string]bool `json:"subTypes"` // 子类型过滤选项
+ SubTypes SearchSubTypes `json:"subTypes"` // 子类型过滤选项
ReplaceTypes *CriterionReplaceTypes `json:"replaceTypes"` // 替换类型过滤选项
}