Skip to content

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

:sparkles: Support searching custom block content https://github.com/siyuan-note/siyuan/issues/19508

Daniel74836981ac4f
diff --git a/app/appearance/langs/ar.json b/app/appearance/langs/ar.json
index 8317f2ec0d..a9e6b4dabe 100644
--- a/app/appearance/langs/ar.json
+++ b/app/appearance/langs/ar.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "كتلة مخصصة",
"embedHeadingLevel": "مستوى عناوين الكتلة المضمنة",
"embedHeadingLevelPreserve": "الاحتفاظ بالمستوى الأصلي",
"originalToRef": "تحويل الكتلة الأصلية إلى مرجع كتلة",
diff --git a/app/appearance/langs/de.json b/app/appearance/langs/de.json
index dedaf6e371..65221d6a1d 100644
--- a/app/appearance/langs/de.json
+++ b/app/appearance/langs/de.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Benutzerdefinierter Block",
"embedHeadingLevel": "Überschriftenebene des eingebetteten Blocks",
"embedHeadingLevelPreserve": "Ursprüngliche Ebene beibehalten",
"originalToRef": "Original in Blockreferenz umwandeln",
diff --git a/app/appearance/langs/en.json b/app/appearance/langs/en.json
index 7b01240fee..a9207a1205 100644
--- a/app/appearance/langs/en.json
+++ b/app/appearance/langs/en.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Custom block",
"embedHeadingLevel": "Embedded heading level",
"embedHeadingLevelPreserve": "Keep original levels",
"originalToRef": "Convert original to block reference",
diff --git a/app/appearance/langs/es.json b/app/appearance/langs/es.json
index 77639192e3..997594b85d 100644
--- a/app/appearance/langs/es.json
+++ b/app/appearance/langs/es.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Bloque personalizado",
"embedHeadingLevel": "Nivel de los encabezados incrustados",
"embedHeadingLevelPreserve": "Mantener los niveles originales",
"originalToRef": "Convertir el original en referencia a bloque",
diff --git a/app/appearance/langs/fr.json b/app/appearance/langs/fr.json
index b772960094..8cc9a3cc94 100644
--- a/app/appearance/langs/fr.json
+++ b/app/appearance/langs/fr.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Bloc personnalisé",
"embedHeadingLevel": "Niveau des titres intégrés",
"embedHeadingLevelPreserve": "Conserver les niveaux d’origine",
"originalToRef": "Convertir le bloc original en référence de bloc",
diff --git a/app/appearance/langs/he.json b/app/appearance/langs/he.json
index c4002536d8..ab37b22875 100644
--- a/app/appearance/langs/he.json
+++ b/app/appearance/langs/he.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "בלוק מותאם אישית",
"embedHeadingLevel": "רמת הכותרות המוטמעות",
"embedHeadingLevelPreserve": "שמירה על הרמות המקוריות",
"originalToRef": "המרת הבלוק המקורי להפניה לבלוק",
diff --git a/app/appearance/langs/hi.json b/app/appearance/langs/hi.json
index a0eba093d6..3b24551877 100644
--- a/app/appearance/langs/hi.json
+++ b/app/appearance/langs/hi.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "कस्टम ब्लॉक",
"embedHeadingLevel": "एम्बेड किए गए शीर्षकों का स्तर",
"embedHeadingLevelPreserve": "मूल स्तर बनाए रखें",
"originalToRef": "मूल ब्लॉक को ब्लॉक संदर्भ में बदलें",
diff --git a/app/appearance/langs/id.json b/app/appearance/langs/id.json
index b31d1a710a..ffb3d98d67 100644
--- a/app/appearance/langs/id.json
+++ b/app/appearance/langs/id.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Blok kustom",
"embedHeadingLevel": "Tingkat judul tersemat",
"embedHeadingLevelPreserve": "Pertahankan tingkat asli",
"originalToRef": "Ubah blok asli menjadi referensi blok",
diff --git a/app/appearance/langs/it.json b/app/appearance/langs/it.json
index 661c16fea6..8339ce6265 100644
--- a/app/appearance/langs/it.json
+++ b/app/appearance/langs/it.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Blocco personalizzato",
"embedHeadingLevel": "Livello dei titoli incorporati",
"embedHeadingLevelPreserve": "Mantieni i livelli originali",
"originalToRef": "Converti il blocco originale in riferimento a blocco",
diff --git a/app/appearance/langs/ja.json b/app/appearance/langs/ja.json
index 7320632fda..dcb958929a 100644
--- a/app/appearance/langs/ja.json
+++ b/app/appearance/langs/ja.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "カスタムブロック",
"embedHeadingLevel": "埋め込み見出しのレベル",
"embedHeadingLevelPreserve": "元の見出しレベルを維持",
"originalToRef": "元の定義ブロックをブロック参照に変換",
diff --git a/app/appearance/langs/ko.json b/app/appearance/langs/ko.json
index 91c4d451e6..ce9d460b3e 100644
--- a/app/appearance/langs/ko.json
+++ b/app/appearance/langs/ko.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "사용자 정의 블록",
"embedHeadingLevel": "임베드된 제목 수준",
"embedHeadingLevelPreserve": "원래 제목 수준 유지",
"originalToRef": "원본 정의 블록을 블록 참조로 변환",
diff --git a/app/appearance/langs/nl.json b/app/appearance/langs/nl.json
index cb07dbe051..0d26b3acdf 100644
--- a/app/appearance/langs/nl.json
+++ b/app/appearance/langs/nl.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Aangepast blok",
"embedHeadingLevel": "Niveau van ingesloten koppen",
"embedHeadingLevelPreserve": "Oorspronkelijke niveaus behouden",
"originalToRef": "Origineel omzetten naar blokverwijzing",
diff --git a/app/appearance/langs/pl.json b/app/appearance/langs/pl.json
index c7c3a5ee60..6e7610dc66 100644
--- a/app/appearance/langs/pl.json
+++ b/app/appearance/langs/pl.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Blok niestandardowy",
"embedHeadingLevel": "Poziom osadzonych nagłówków",
"embedHeadingLevelPreserve": "Zachowaj oryginalne poziomy",
"originalToRef": "Zamień oryginalny blok na odwołanie do bloku",
diff --git a/app/appearance/langs/pt-BR.json b/app/appearance/langs/pt-BR.json
index e32cc7ace1..8e5cd1bf48 100644
--- a/app/appearance/langs/pt-BR.json
+++ b/app/appearance/langs/pt-BR.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Bloco personalizado",
"embedHeadingLevel": "Nível dos títulos incorporados",
"embedHeadingLevelPreserve": "Manter os níveis originais",
"originalToRef": "Converter o original em referência de bloco",
diff --git a/app/appearance/langs/ru.json b/app/appearance/langs/ru.json
index 9b981d2912..58b8854d16 100644
--- a/app/appearance/langs/ru.json
+++ b/app/appearance/langs/ru.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Пользовательский блок",
"embedHeadingLevel": "Уровень встроенных заголовков",
"embedHeadingLevelPreserve": "Сохранять исходные уровни",
"originalToRef": "Преобразовать исходный блок в ссылку на блок",
diff --git a/app/appearance/langs/sk.json b/app/appearance/langs/sk.json
index 106f1936f1..0309d17d62 100644
--- a/app/appearance/langs/sk.json
+++ b/app/appearance/langs/sk.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Vlastný blok",
"embedHeadingLevel": "Úroveň vložených nadpisov",
"embedHeadingLevelPreserve": "Zachovať pôvodné úrovne",
"originalToRef": "Previesť pôvodný blok na odkaz na blok",
diff --git a/app/appearance/langs/sr.json b/app/appearance/langs/sr.json
index f575cd1e84..439204b2a3 100644
--- a/app/appearance/langs/sr.json
+++ b/app/appearance/langs/sr.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Прилагођени блок",
"embedHeadingLevel": "Ниво уграђених наслова",
"embedHeadingLevelPreserve": "Задржи изворне нивое",
"originalToRef": "Претвори изворни блок у референцу на блок",
diff --git a/app/appearance/langs/th.json b/app/appearance/langs/th.json
index b160b8cdbe..b35eae6e8c 100644
--- a/app/appearance/langs/th.json
+++ b/app/appearance/langs/th.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "บล็อกที่กำหนดเอง",
"embedHeadingLevel": "ระดับหัวเรื่องที่ฝัง",
"embedHeadingLevelPreserve": "คงระดับเดิม",
"originalToRef": "แปลงบล็อกต้นฉบับเป็นการอ้างอิงบล็อก",
diff --git a/app/appearance/langs/tr.json b/app/appearance/langs/tr.json
index cee4c56c27..2be855c8bf 100644
--- a/app/appearance/langs/tr.json
+++ b/app/appearance/langs/tr.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Özel blok",
"embedHeadingLevel": "Gömülü başlık düzeyi",
"embedHeadingLevelPreserve": "Özgün düzeyleri koru",
"originalToRef": "Özgün bloğu blok referansına dönüştür",
diff --git a/app/appearance/langs/uk.json b/app/appearance/langs/uk.json
index 22b03734d9..20f5b0798c 100644
--- a/app/appearance/langs/uk.json
+++ b/app/appearance/langs/uk.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "Користувацький блок",
"embedHeadingLevel": "Рівень вбудованих заголовків",
"embedHeadingLevelPreserve": "Зберігати початкові рівні",
"originalToRef": "Перетворити початковий блок на посилання на блок",
diff --git a/app/appearance/langs/zh-CN.json b/app/appearance/langs/zh-CN.json
index 0851d83249..a691329870 100644
--- a/app/appearance/langs/zh-CN.json
+++ b/app/appearance/langs/zh-CN.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "自定义块",
"embedHeadingLevel": "嵌入标题层级",
"embedHeadingLevelPreserve": "保持原层级",
"originalToRef": "定义块转为引用",
diff --git a/app/appearance/langs/zh-TW.json b/app/appearance/langs/zh-TW.json
index 9e96174a85..3f9a826ed6 100644
--- a/app/appearance/langs/zh-TW.json
+++ b/app/appearance/langs/zh-TW.json
@@ -1,4 +1,5 @@
{
+ "customBlock": "自訂區塊",
"embedHeadingLevel": "嵌入標題層級",
"embedHeadingLevelPreserve": "保持原層級",
"originalToRef": "原定義區塊轉為區塊引用",
diff --git a/app/src/config/tabs/searchTab.ts b/app/src/config/tabs/searchTab.ts
index 70c4376a8d..998cede815 100644
--- a/app/src/config/tabs/searchTab.ts
+++ b/app/src/config/tabs/searchTab.ts
@@ -8,6 +8,7 @@ const registerSearchQueryGroup = (tab: SettingTabBuilder) => {
title: window.siyuan.languages.searchBlockType,
footer: `[1] ${window.siyuan.languages.containerBlockTip1}`,
items: [
+ {kind: "switch", id: "search.customBlock", label: window.siyuan.languages.customBlock, icon: "iconPlugin"},
{kind: "switch", id: "search.mathBlock", label: window.siyuan.languages.math, icon: "iconMath"},
{kind: "switch", id: "search.table", label: window.siyuan.languages.tableBlock, icon: "iconTable"},
{kind: "switch", id: "search.paragraph", label: window.siyuan.languages.paragraph, icon: "iconParagraph"},
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 3596cbb08a..38adb75994 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -4,7 +4,7 @@ import {Constants} from "../../constants";
/// #if !BROWSER
import {ipcRenderer} from "electron";
/// #endif
-import {getDefaultSubType, getDefaultType} from "../../search/getDefault";
+import {getDefaultSubType, getDefaultType, normalizeSearchTypes} from "../../search/getDefault";
import {hideMessage, showMessage} from "../../dialog/message";
import {isEncryptedBox, isSiYuanUriProtocol} from "../../util/pathName";
import {isBrowser} from "../../util/functions";
@@ -834,6 +834,7 @@ export const getLocalStorage = (cb: () => void) => {
window.siyuan.storage[key] = defaultStorage[key];
}
});
+ window.siyuan.storage[Constants.LOCAL_SEARCHDATA].types = normalizeSearchTypes(window.siyuan.storage[Constants.LOCAL_SEARCHDATA].types);
// 搜索数据添加 replaceTypes 兼容
if (!window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes ||
Object.keys(window.siyuan.storage[Constants.LOCAL_SEARCHDATA].replaceTypes).length === 0) {
diff --git a/app/src/search/config.test.ts b/app/src/search/config.test.ts
index e33515bda6..a9ecc3a832 100644
--- a/app/src/search/config.test.ts
+++ b/app/src/search/config.test.ts
@@ -1,5 +1,13 @@
-import {describe, it} from "node:test";
+import {after, before, describe, it} from "node:test";
import * as assert from "node:assert/strict";
+import {getDefaultType} from "./getDefault";
+const previousWindow = globalThis.window;
+before(() => {
+ Object.defineProperty(globalThis, "window", {configurable: true, writable: true, value: {siyuan: {config: {search: {customBlock: true}}}}});
+});
+after(() => {
+ globalThis.window = previousWindow;
+});
import {
buildSearchRequest,
cloneSearchConfig,
@@ -27,6 +35,19 @@ import {
} from "./config";
describe("search request configuration", () => {
+ it("defaults legacy custom block filters and preserves explicit choices", () => {
+ const types: Config.IUILayoutTabSearchConfigTypes = {...getDefaultType()};
+ delete types.customBlock;
+ assert.equal(buildSearchRequest({types}).types.customBlock, true);
+ assert.equal(buildSearchRequest({types: {...types, customBlock: false}}).types.customBlock, false);
+ window.siyuan.config.search.customBlock = false;
+ try {
+ assert.equal(buildSearchRequest({types}).types.customBlock, false);
+ assert.equal(buildSearchRequest({types: {...types, customBlock: true}}).types.customBlock, true);
+ } finally {
+ window.siyuan.config.search.customBlock = true;
+ }
+ });
it("disables hierarchical path matches only while replacing", () => {
const config: Config.IUILayoutTabSearchConfig = {query: "ancestor", method: 0};
@@ -72,7 +93,7 @@ describe("search request configuration", () => {
assert.deepEqual(buildSearchRequest({...config, hasReplace: true}), {...search, searchHPath: false});
assert.equal(search.query, "ancestor");
assert.deepEqual(search.paths, config.idPath);
- assert.deepEqual(search.types, config.types);
+ assert.deepEqual(search.types, {...config.types, customBlock: true});
assert.equal(search.groupBy, 1);
assert.equal(search.orderBy, 2);
assert.equal(search.page, 3);
diff --git a/app/src/search/config.ts b/app/src/search/config.ts
index fb07cb0971..b7f98d4c62 100644
--- a/app/src/search/config.ts
+++ b/app/src/search/config.ts
@@ -1,10 +1,11 @@
+import {normalizeSearchTypes} from "./getDefault";
import type {FullTextSearchBlockRequestInput} from "../types/api";
export const buildSearchRequest = (config: Config.IUILayoutTabSearchConfig): FullTextSearchBlockRequestInput => {
return {
query: config.query,
method: config.method,
- types: {...config.types},
+ types: normalizeSearchTypes(config.types),
subTypes: config.subTypes,
paths: config.idPath || [],
groupBy: config.group,
diff --git a/app/src/search/getDefault.ts b/app/src/search/getDefault.ts
index 31c390b2c6..f0e23b6976 100644
--- a/app/src/search/getDefault.ts
+++ b/app/src/search/getDefault.ts
@@ -17,6 +17,7 @@ export const getDefaultType = () => {
callout: window.siyuan.config.search.callout,
tabs: window.siyuan.config.search.tabs,
tabItem: window.siyuan.config.search.tabItem,
+ customBlock: window.siyuan.config.search.customBlock ?? true,
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
@@ -24,6 +25,11 @@ export const getDefaultType = () => {
};
};
+export const normalizeSearchTypes = (types: Config.IUILayoutTabSearchConfig["types"]) => ({
+ ...types,
+ customBlock: types?.customBlock ?? window.siyuan.config.search.customBlock ?? true,
+});
+
export const getDefaultSubType = (): Config.IUILayoutTabSearchConfigSubTypes => {
return {
heading: {h1: false, h2: false, h3: false, h4: false, h5: false, h6: false},
diff --git a/app/src/search/menu.ts b/app/src/search/menu.ts
index ba11a3ba4e..91c562c938 100644
--- a/app/src/search/menu.ts
+++ b/app/src/search/menu.ts
@@ -10,13 +10,20 @@ import {isSensitiveSearchConfig, setStorageVal} from "../protyle/util/compatibil
import {confirmDialog} from "../dialog/confirmDialog";
import {goUnRef, updateSearchResult} from "../mobile/menu/search";
import {bindSearchSubtypeFilters} from "./subTypes";
-import {getDefaultSubType} from "./getDefault";
+import {getDefaultSubType, normalizeSearchTypes} from "./getDefault";
import {hasSearchConfigTemporaryPath, resolvePersistedSearchConfig} from "./config";
export const filterMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => void) => {
+ config.types = normalizeSearchTypes(config.types);
const filterDialog = new Dialog({
title: window.siyuan.languages.searchType,
content: `<div class="b3-dialog__content">
+ <label class="fn__flex b3-label">
+ <svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconPlugin"></use></svg>
+ <span class="fn__space"></span>
+ <div class="fn__flex-1 fn__flex-center">${window.siyuan.languages.customBlock}</div>
+ <input class="b3-switch fn__flex-center" data-type="customBlock" type="checkbox"${config.types.customBlock ? " checked" : ""}>
+ </label>
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconMath"></use></svg>
<span class="fn__space"></span>
@@ -707,6 +714,7 @@ export const initCriteriaMenu = (element: HTMLElement, data: Config.IUILayoutTab
const defaults = getDefaultSubType();
const item: Config.IUILayoutTabSearchConfig = {
...criterion,
+ types: normalizeSearchTypes(criterion.types),
subTypes: {
heading: {...defaults.heading, ...criterion.subTypes?.heading},
list: {...defaults.list, ...criterion.subTypes?.list},
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index 489a8c73f8..8e9eab4c95 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -790,9 +790,9 @@ export type CriterionReplaceTypes = { "aHref": boolean; "aText": boolean; "aTitl
export type CriterionReplaceTypesInput = { "aHref"?: boolean | null; "aText"?: boolean | null; "aTitle"?: boolean | null; "blockRef"?: boolean | null; "code"?: boolean | null; "codeBlock"?: boolean | null; "docTitle"?: boolean | null; "em"?: boolean | null; "fileAnnotationRef"?: boolean | null; "htmlBlock"?: boolean | null; "imgSrc"?: boolean | null; "imgText"?: boolean | null; "imgTitle"?: boolean | null; "inlineMath"?: boolean | null; "inlineMemo"?: boolean | null; "kbd"?: boolean | null; "mark"?: boolean | null; "mathBlock"?: boolean | null; "s"?: boolean | null; "strong"?: boolean | null; "sub"?: boolean | null; "sup"?: boolean | null; "tag"?: boolean | null; "text"?: boolean | null; "u"?: boolean | null; };
-export type CriterionTypes = { "audioBlock": boolean; "blockquote": boolean; "callout": boolean; "codeBlock": boolean; "databaseBlock": boolean; "document": boolean; "embedBlock": boolean; "heading": boolean; "htmlBlock": boolean; "iframeBlock": boolean; "list": boolean; "listItem": boolean; "mathBlock": boolean; "paragraph": boolean; "superBlock": boolean; "tabItem": boolean; "table": boolean; "tabs": boolean; "videoBlock": boolean; "widgetBlock": boolean; };
+export type CriterionTypes = { "audioBlock": boolean; "blockquote": boolean; "callout": boolean; "codeBlock": boolean; "customBlock"?: boolean; "databaseBlock": boolean; "document": boolean; "embedBlock": boolean; "heading": boolean; "htmlBlock": boolean; "iframeBlock": boolean; "list": boolean; "listItem": boolean; "mathBlock": boolean; "paragraph": boolean; "superBlock": boolean; "tabItem": boolean; "table": boolean; "tabs": boolean; "videoBlock": boolean; "widgetBlock": boolean; };
-export type CriterionTypesInput = { "audioBlock"?: boolean | null; "blockquote"?: boolean | null; "callout"?: boolean | null; "codeBlock"?: boolean | null; "databaseBlock"?: boolean | null; "document"?: boolean | null; "embedBlock"?: boolean | null; "heading"?: boolean | null; "htmlBlock"?: boolean | null; "iframeBlock"?: boolean | null; "list"?: boolean | null; "listItem"?: boolean | null; "mathBlock"?: boolean | null; "paragraph"?: boolean | null; "superBlock"?: boolean | null; "tabItem"?: boolean | null; "table"?: boolean | null; "tabs"?: boolean | null; "videoBlock"?: boolean | null; "widgetBlock"?: boolean | null; };
+export type CriterionTypesInput = { "audioBlock"?: boolean | null; "blockquote"?: boolean | null; "callout"?: boolean | null; "codeBlock"?: boolean | null; "customBlock"?: boolean | null; "databaseBlock"?: boolean | null; "document"?: boolean | null; "embedBlock"?: boolean | null; "heading"?: boolean | null; "htmlBlock"?: boolean | null; "iframeBlock"?: boolean | null; "list"?: boolean | null; "listItem"?: boolean | null; "mathBlock"?: boolean | null; "paragraph"?: boolean | null; "superBlock"?: boolean | null; "tabItem"?: boolean | null; "table"?: boolean | null; "tabs"?: boolean | null; "videoBlock"?: boolean | null; "widgetBlock"?: boolean | null; };
export type DOMData = { "dom": string; };
@@ -1700,7 +1700,7 @@ export type SetRetentionIndexesDailyRequestInput = { "indexes": number; };
export type SetRiffCardsDueRequestInput = { "cardDues": Array<RiffCardDueInput>; };
-export type SetSearchRequestInput = { "alias"?: boolean | null; "audioBlock"?: boolean | null; "backlinkMentionAlias"?: boolean | null; "backlinkMentionAnchor"?: boolean | null; "backlinkMentionDoc"?: boolean | null; "backlinkMentionKeywordsLimit"?: number | null; "backlinkMentionName"?: boolean | null; "blockquote"?: boolean | null; "callout"?: boolean | null; "caseSensitive"?: boolean | null; "codeBlock"?: boolean | null; "databaseBlock"?: boolean | null; "document"?: boolean | null; "embedBlock"?: boolean | null; "hanSensitive"?: boolean | null; "heading"?: boolean | null; "htmlBlock"?: boolean | null; "ial"?: boolean | null; "iframeBlock"?: boolean | null; "indexAssetPath"?: boolean | null; "limit"?: number | null; "list"?: boolean | null; "listItem"?: boolean | null; "mathBlock"?: boolean | null; "memo"?: boolean | null; "name"?: boolean | null; "paragraph"?: boolean | null; "superBlock"?: boolean | null; "tabItem"?: boolean | null; "table"?: boolean | null; "tabs"?: boolean | null; "videoBlock"?: boolean | null; "virtualRefAlias"?: boolean | null; "virtualRefAnchor"?: boolean | null; "virtualRefDoc"?: boolean | null; "virtualRefName"?: boolean | null; "widgetBlock"?: boolean | null; };
+export type SetSearchRequestInput = { "alias"?: boolean | null; "audioBlock"?: boolean | null; "backlinkMentionAlias"?: boolean | null; "backlinkMentionAnchor"?: boolean | null; "backlinkMentionDoc"?: boolean | null; "backlinkMentionKeywordsLimit"?: number | null; "backlinkMentionName"?: boolean | null; "blockquote"?: boolean | null; "callout"?: boolean | null; "caseSensitive"?: boolean | null; "codeBlock"?: boolean | null; "customBlock"?: boolean | null; "databaseBlock"?: boolean | null; "document"?: boolean | null; "embedBlock"?: boolean | null; "hanSensitive"?: boolean | null; "heading"?: boolean | null; "htmlBlock"?: boolean | null; "ial"?: boolean | null; "iframeBlock"?: boolean | null; "indexAssetPath"?: boolean | null; "limit"?: number | null; "list"?: boolean | null; "listItem"?: boolean | null; "mathBlock"?: boolean | null; "memo"?: boolean | null; "name"?: boolean | null; "paragraph"?: boolean | null; "superBlock"?: boolean | null; "tabItem"?: boolean | null; "table"?: boolean | null; "tabs"?: boolean | null; "videoBlock"?: boolean | null; "virtualRefAlias"?: boolean | null; "virtualRefAnchor"?: boolean | null; "virtualRefDoc"?: boolean | null; "virtualRefName"?: boolean | null; "widgetBlock"?: boolean | null; };
export type SetSecretsRequestInput = { "items"?: Array<SettingSecretInput | null> | null; };
@@ -1862,7 +1862,7 @@ export type SettingRerank = { "apiKey": string; "candidateCount": number; "enabl
export type SettingRerankInput = { "apiKey"?: string | null; "candidateCount"?: number | null; "enabled"?: boolean | null; "endpoint"?: string | null; "id"?: string | null; "name"?: string | null; "requestFormat"?: string | null; "timeout"?: number | null; };
-export type SettingSearch = { "alias": boolean; "audioBlock": boolean; "backlinkMentionAlias": boolean; "backlinkMentionAnchor": boolean; "backlinkMentionDoc": boolean; "backlinkMentionKeywordsLimit": number; "backlinkMentionName": boolean; "blockquote": boolean; "callout": boolean; "caseSensitive": boolean; "codeBlock": boolean; "databaseBlock": boolean; "document": boolean; "embedBlock": boolean; "hanSensitive": boolean | null; "heading": boolean; "htmlBlock": boolean; "ial": boolean; "iframeBlock": boolean; "indexAssetPath": boolean; "limit": number; "list": boolean; "listItem": boolean; "mathBlock": boolean; "memo": boolean; "name": boolean; "paragraph": boolean; "superBlock": boolean; "tabItem": boolean; "table": boolean; "tabs": boolean; "videoBlock": boolean; "virtualRefAlias": boolean; "virtualRefAnchor": boolean; "virtualRefDoc": boolean; "virtualRefName": boolean; "widgetBlock": boolean; };
+export type SettingSearch = { "alias": boolean; "audioBlock": boolean; "backlinkMentionAlias": boolean; "backlinkMentionAnchor": boolean; "backlinkMentionDoc": boolean; "backlinkMentionKeywordsLimit": number; "backlinkMentionName": boolean; "blockquote": boolean; "callout": boolean; "caseSensitive": boolean; "codeBlock": boolean; "customBlock": boolean | null; "databaseBlock": boolean; "document": boolean; "embedBlock": boolean; "hanSensitive": boolean | null; "heading": boolean; "htmlBlock": boolean; "ial": boolean; "iframeBlock": boolean; "indexAssetPath": boolean; "limit": number; "list": boolean; "listItem": boolean; "mathBlock": boolean; "memo": boolean; "name": boolean; "paragraph": boolean; "superBlock": boolean; "tabItem": boolean; "table": boolean; "tabs": boolean; "videoBlock": boolean; "virtualRefAlias": boolean; "virtualRefAnchor": boolean; "virtualRefDoc": boolean; "virtualRefName": boolean; "widgetBlock": boolean; };
export type SettingSecret = { "allowedHosts": Array<string> | null; "name": string; "value": string; };
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index cca6708ebe..c00a75849c 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -1581,6 +1581,7 @@ declare namespace Config {
callout: boolean;
tabs?: boolean;
tabItem?: boolean;
+ customBlock?: boolean;
/**
* Whether to distinguish between uppercase and lowercase letters when searching
*/
@@ -2801,6 +2802,7 @@ declare namespace Config {
callout: boolean;
tabs?: boolean;
tabItem?: boolean;
+ customBlock?: boolean;
/**
* Search results contain code blocks
* @default false
diff --git a/docs/API-CONTRACTS.md b/docs/API-CONTRACTS.md
index 0c48a83c3b..3e0eaa54ac 100644
--- a/docs/API-CONTRACTS.md
+++ b/docs/API-CONTRACTS.md
@@ -140,6 +140,8 @@ Dynamic multipart endpoints use `MultipartFields` to retain every text value and
## Generation and verification
+Custom block search uses the optional `customBlock` type filter. Explicit API type maps select only their enabled types; omitted type maps use search settings, which enable custom blocks by default. Saved criteria preserve omission separately from `false` so older frontend search configurations can inherit the setting. `TestCustomBlockSearch` regressions cover configuration compatibility, saved criteria, filtering, and FTS updates; `TestAPIContractSettingConfigCompatibility` and `TestAPIContractSettingCompletePayloads` cover the setting contract. All are included in the full kernel command below.
+
`TestAPIContractFileTreeMissingDocuments` exercises actual HTTP responses for missing documents during path lookup, removal, renaming, duplication, and moving. It checks business errors and preserved `closeTimeout` values against the response contracts and runs in the full kernel command below. Run it separately with `go test -tags "fts5 sqlcipher" ./api -run TestAPIContractFileTreeMissingDocuments -count=1` from `kernel/`.
`swapBlockRef` accepts the optional boolean `originalToEmbed`. Omission or `false` keeps the reference at the original definition position; `true` replaces it with an embed querying the moved definition ID. `includeChildren` retains its heading and list behavior. `TestSwapBlockRefContractCompatibility` and `TestSwapBlockRefNodes` cover request defaults, invalid options, and both replacement modes across document, heading, and list cases; they run in the full kernel command below.
diff --git a/docs/API-CONTRACTS.zh-CN.md b/docs/API-CONTRACTS.zh-CN.md
index 7c0289d51b..46e773b4a0 100644
--- a/docs/API-CONTRACTS.zh-CN.md
+++ b/docs/API-CONTRACTS.zh-CN.md
@@ -140,6 +140,8 @@ JSON SSE 接口通过 `SSEOptions` 和 `SSEEvent` 声明各事件名称及载荷
## 生成与验证
+自定义块搜索使用可选的 `customBlock` 类型筛选字段。API 显式传入类型映射时仅搜索其中启用的类型;省略类型映射时使用搜索设置,默认启用自定义块。保存的搜索条件区分字段缺失与 `false`,使旧版前端搜索配置能够继承设置。`TestCustomBlockSearch` 回归覆盖配置兼容、搜索条件保存、类型筛选和全文索引更新;`TestAPIContractSettingConfigCompatibility` 与 `TestAPIContractSettingCompletePayloads` 覆盖设置契约,均包含在下方完整内核测试命令中。
+
编辑器通过独立的 `swapBlockRef` 事务转换块引用:`id` 指定引用块,`blockID` 指定定义块,`data` 包含布尔选项 `includeChildren` 和 `originalToEmbed`。内核在 `retData` 中返回受影响的文档 ID,并以受影响顶层块的私有内存快照生成逆向操作。快照不传给客户端,也不接受客户端提交。重放保留块 ID 和数据库绑定;内容或位置已改变时拒绝覆盖;提交失败时补偿已写入的文档。`TestBlockSwapTransaction` 覆盖落盘后的撤销和重做、跨文档历史、冲突拒绝及写入失败恢复,包含在下方完整内核测试命令中,也可在 `kernel/` 下运行 `go test -tags "fts5 sqlcipher" ./model -run 'Test(SwapBlockRefNodes|BlockSwapTransaction)' -count=1` 单独验证
块交换的撤销和重做为所有受影响文档持有笔记本租约,直到响应序列化完成。`TestContractBlockSwapReplayNotebookResponseLease` 验证锁定操作会等待响应结束,包含在完整内核测试命令中。
diff --git a/kernel/api/contract_setting_test.go b/kernel/api/contract_setting_test.go
index bfc23e6427..70b2162824 100644
--- a/kernel/api/contract_setting_test.go
+++ b/kernel/api/contract_setting_test.go
@@ -80,7 +80,7 @@ func TestAPIContractSettingConfigCompatibility(t *testing.T) {
compareSettingConfig(t, apicontract.SetEditor, conf.NewEditor, append(common, `{"markdown":{"inlineMath":null}}`, `{"markdown":null,"fontFamilies":null}`, `{"FontFamilies":[],"fontSize":16.0}`, `{"fontSize":1.5}`, `{"markdown":false}`, `{"emoji":[null,"x"]}`))
compareSettingConfig(t, apicontract.SetExport, func() *conf.Export { return &conf.Export{} }, append(common, `{"blockRefMode":1.0}`, `{"blockRefMode":1.5}`))
compareSettingConfig(t, apicontract.SetFiletree, conf.NewFileTree, append(common, `{"maxOpenTabCount":1e0,"boxDocEnabled":null}`, `{"useSVGDefaultIcon":null,"tabStartupMode":null}`, `{"maxOpenTabCount":"x"}`))
- compareSettingConfig(t, apicontract.SetSearch, func() *conf.Search { return &conf.Search{} }, append(common, `{"hanSensitive":null,"limit":3.0}`, `{"limit":3.2}`))
+ compareSettingConfig(t, apicontract.SetSearch, func() *conf.Search { return &conf.Search{} }, append(common, `{"hanSensitive":null,"limit":3.0}`, `{"limit":3.2}`, `{"customBlock":true}`, `{"customBlock":false}`, `{"customBlock":null}`, `{"customBlock":"bad"}`))
compareSettingConfig(t, apicontract.SetAppearance, func() *conf.Appearance { return &conf.Appearance{} }, append(common, `{"bodyGradient":null}`, `{"BodyGradient":null,"globalFontFamilies":[]}`, `{"statusBar":false}`, `{"notifications":{"selectAllTip":null}}`))
compareSettingConfig(t, apicontract.SetEntryVisibility, func() *conf.EntryVisibility { return &conf.EntryVisibility{} }, append(common, `{"profiles":[null,{"orders":{"menu":[null,"id"]}}]}`))
compareSettingConfig(t, apicontract.SetPublish, func() *conf.Publish { return &conf.Publish{} }, append(common, `{"auth":null,"port":65535.0}`, `{"port":65536}`, `{"auth":{"accounts":[null]}}`))
diff --git a/kernel/api/setting.go b/kernel/api/setting.go
index 2a7bbe8405..c6fe820dc2 100644
--- a/kernel/api/setting.go
+++ b/kernel/api/setting.go
@@ -579,6 +579,9 @@ var setSearch = contractHandler(apicontract.SetSearch, func(c *gin.Context, requ
// 兼容未携带该字段的旧版前端/第三方调用:保持当前值,避免被零值意外关闭并触发重建索引
s.HanSensitive = model.Conf.Search.HanSensitive
}
+ if s.CustomBlock == nil {
+ s.CustomBlock = new(model.Conf.Search.CustomBlockEnabled())
+ }
if 32 > s.Limit {
s.Limit = 32
diff --git a/kernel/api/setting_contract.go b/kernel/api/setting_contract.go
index ecbf31a612..f954547a6e 100644
--- a/kernel/api/setting_contract.go
+++ b/kernel/api/setting_contract.go
@@ -517,6 +517,7 @@ func settingSearchPayload(value *conf.Search) *apicontract.SettingSearch {
result.Callout = value.Callout
result.Tabs = value.Tabs
result.TabItem = value.TabItem
+ result.CustomBlock = value.CustomBlock
result.Limit = value.Limit
result.CaseSensitive = value.CaseSensitive
result.HanSensitive = value.HanSensitive
diff --git a/kernel/apicontract/criterion.go b/kernel/apicontract/criterion.go
index 500d3e1fcc..edb3f9f3e9 100644
--- a/kernel/apicontract/criterion.go
+++ b/kernel/apicontract/criterion.go
@@ -18,6 +18,8 @@ type Criterion struct {
}
type CriterionTypes struct {
+ CustomBlock *bool `json:"customBlock,omitempty" api:"optional,nullable"`
+
MathBlock bool `json:"mathBlock" api:"optional,nullable"`
Table bool `json:"table" api:"optional,nullable"`
Blockquote bool `json:"blockquote" api:"optional,nullable"`
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 506f5b515b..3fd0b8b3e0 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -19991,6 +19991,9 @@
"codeBlock": {
"type": "boolean"
},
+ "customBlock": {
+ "type": "boolean"
+ },
"databaseBlock": {
"type": "boolean"
},
@@ -20107,6 +20110,16 @@
}
]
},
+ "customBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"databaseBlock": {
"anyOf": [
{
@@ -38007,6 +38020,16 @@
}
]
},
+ "customBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"databaseBlock": {
"anyOf": [
{
@@ -42116,6 +42139,16 @@
"codeBlock": {
"type": "boolean"
},
+ "customBlock": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
"databaseBlock": {
"type": "boolean"
},
@@ -42214,6 +42247,7 @@
"callout",
"caseSensitive",
"codeBlock",
+ "customBlock",
"databaseBlock",
"document",
"embedBlock",
diff --git a/kernel/apicontract/setting.go b/kernel/apicontract/setting.go
index 1b8a8da981..25c0792020 100644
--- a/kernel/apicontract/setting.go
+++ b/kernel/apicontract/setting.go
@@ -311,6 +311,7 @@ type SettingFileTree struct {
}
type SettingSearch struct {
+ CustomBlock *bool `json:"customBlock" api:"optional,nullable"`
Document bool `json:"document" api:"optional,nullable"`
Heading bool `json:"heading" api:"optional,nullable"`
List bool `json:"list" api:"optional,nullable"`
diff --git a/kernel/conf/search.go b/kernel/conf/search.go
index 188c50158d..78d05b1f66 100644
--- a/kernel/conf/search.go
+++ b/kernel/conf/search.go
@@ -25,6 +25,8 @@ import (
)
type Search struct {
+ CustomBlock *bool `json:"customBlock"`
+
Document bool `json:"document"`
Heading bool `json:"heading"`
List bool `json:"list"`
@@ -71,6 +73,7 @@ type Search struct {
func NewSearch() *Search {
return &Search{
+ CustomBlock: new(true),
Document: true,
Heading: true,
List: false,
@@ -155,6 +158,11 @@ func (s *Search) NAMFilter(keyword string) string {
return buf.String()
}
+// CustomBlockEnabled 为缺少新字段的配置启用自定义块搜索。
+func (s *Search) CustomBlockEnabled() bool {
+ return s.CustomBlock == nil || *s.CustomBlock
+}
+
func (s *Search) TypeFilter() string {
buf := bytes.Buffer{}
if s.Document {
@@ -272,6 +280,9 @@ func (s *Search) TypeFilter() string {
if s.TabItem {
buf.WriteString("'tab',")
}
+ if s.CustomBlockEnabled() {
+ buf.WriteString("'custom',")
+ }
ret := buf.String()
if "" == ret {
return ret
diff --git a/kernel/conf/search_custom_test.go b/kernel/conf/search_custom_test.go
new file mode 100644
index 0000000000..9079ac2bfe
--- /dev/null
+++ b/kernel/conf/search_custom_test.go
@@ -0,0 +1,25 @@
+package conf
+
+import (
+ "encoding/json"
+ "strings"
+ "testing"
+)
+
+func TestCustomBlockSearchCompatibility(t *testing.T) {
+ for _, tc := range []struct {
+ body string
+ want bool
+ }{{`{}`, true}, {`{"customBlock":null}`, true}, {`{"customBlock":true}`, true}, {`{"customBlock":false}`, false}} {
+ var search Search
+ if err := json.Unmarshal([]byte(tc.body), &search); err != nil {
+ t.Fatal(err)
+ }
+ if search.CustomBlockEnabled() != tc.want || strings.Contains(search.TypeFilter(), "'custom'") != tc.want {
+ t.Fatalf("unexpected filter for %s: %s", tc.body, search.TypeFilter())
+ }
+ }
+ if !NewSearch().CustomBlockEnabled() {
+ t.Fatal("custom blocks must be enabled by default")
+ }
+}
diff --git a/kernel/model/conf.go b/kernel/model/conf.go
index e17eeabd01..edfe14b61e 100644
--- a/kernel/model/conf.go
+++ b/kernel/model/conf.go
@@ -703,6 +703,9 @@ func InitConf() {
if nil == Conf.Search {
Conf.Search = conf.NewSearch()
}
+ if nil == Conf.Search.CustomBlock {
+ Conf.Search.CustomBlock = new(true)
+ }
if 1 > Conf.Search.Limit {
Conf.Search.Limit = 64
}
diff --git a/kernel/model/search.go b/kernel/model/search.go
index ae9ab35841..e3835eee67 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -2088,6 +2088,7 @@ func buildTypeFilter(types, subTypes map[string]bool, alias ...string) string {
s.Callout = types["callout"]
s.Tabs = types["tabs"]
s.TabItem = types["tabItem"]
+ s.CustomBlock = new(types["customBlock"])
} else {
s.Document = Conf.Search.Document
s.Heading = Conf.Search.Heading
@@ -2134,6 +2135,7 @@ func buildTypeFilter(types, subTypes map[string]bool, alias ...string) string {
addSimple(s.Callout, treenode.TypeAbbr(ast.NodeCallout.String()))
addSimple(s.Tabs, "tabs")
addSimple(s.TabItem, "tab")
+ addSimple(s.CustomBlockEnabled(), "custom")
var clauses []string
diff --git a/kernel/model/search_custom_fts5_test.go b/kernel/model/search_custom_fts5_test.go
new file mode 100644
index 0000000000..af9a6ebe24
--- /dev/null
+++ b/kernel/model/search_custom_fts5_test.go
@@ -0,0 +1,63 @@
+//go:build fts5
+
+package model
+
+import (
+ gosql "database/sql"
+ "testing"
+
+ "github.com/88250/lute/ast"
+ "github.com/88250/lute/parse"
+ "github.com/siyuan-note/siyuan/kernel/sql"
+)
+
+func TestCustomBlockSearchFTS(t *testing.T) {
+ setSearchCaseSensitive(t, true)
+ db, err := gosql.Open("sqlite3_extended", ":memory:")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer db.Close()
+ db.SetMaxOpenConns(1)
+ for _, stmt := range []string{
+ "CREATE TABLE blocks (id, parent_id, root_id, hash, box, path, hpath, name, alias, memo, tag, content, fcontent, markdown, length, type, subtype, ial, sort, created, updated)",
+ "CREATE VIRTUAL TABLE blocks_fts USING fts5(id UNINDEXED, parent_id UNINDEXED, root_id UNINDEXED, hash UNINDEXED, box UNINDEXED, path UNINDEXED, hpath UNINDEXED, name, alias, memo, tag, content, fcontent, markdown UNINDEXED, length UNINDEXED, type UNINDEXED, subtype UNINDEXED, ial, sort UNINDEXED, created UNINDEXED, updated UNINDEXED, content='blocks', content_rowid='rowid')",
+ } {
+ if _, err = db.Exec(stmt); err != nil {
+ t.Fatal(err)
+ }
+ }
+ root := &ast.Node{Type: ast.NodeDocument, ID: "20260914000000-root001"}
+ node := &ast.Node{Type: ast.NodeCustomBlock, ID: "20260914000000-custom1", CustomBlockInfo: "example/task", Tokens: []byte(`{"content":"采购清单 shopping"}`)}
+ root.AppendChild(node)
+ block := sql.BuildBlockFromNode(node, &parse.Tree{Root: root, ID: root.ID, Box: "20260729120000-box000", Path: "/" + root.ID + ".sy", HPath: "/Tasks"})
+ insertSearchHPathTestBlock(t, db, block.ID, root.ID, "/Tasks", block.Content, block.Type)
+ if _, err = db.Exec("INSERT INTO blocks_fts(blocks_fts) VALUES('rebuild')"); err != nil {
+ t.Fatal(err)
+ }
+ check := func(query string, types map[string]bool, want int) {
+ t.Helper()
+ cte, args := buildFTSAndHPathMatchesCTE("", query, "", "", nil, nil, buildTypeFilter(types, nil), "")
+ var count int
+ if err := db.QueryRow(cte+" SELECT COUNT(*) FROM matches", args...).Scan(&count); err != nil {
+ t.Fatal(err)
+ }
+ if count != want {
+ t.Fatalf("query %q types %v: got %d, want %d", query, types, count, want)
+ }
+ }
+ for _, query := range []string{"shopping", "采购清单"} {
+ check(query, nil, 1)
+ check(query, map[string]bool{"customBlock": true}, 1)
+ check(query, map[string]bool{"paragraph": true}, 0)
+ check(query, map[string]bool{"customBlock": false}, 0)
+ }
+ if _, err = db.Exec("UPDATE blocks_fts SET content = 'completed' WHERE rowid = 1"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err = db.Exec("UPDATE blocks SET content = 'completed' WHERE rowid = 1"); err != nil {
+ t.Fatal(err)
+ }
+ check("shopping", nil, 0)
+ check("completed", nil, 1)
+}
diff --git a/kernel/model/search_custom_test.go b/kernel/model/search_custom_test.go
new file mode 100644
index 0000000000..555d71dcd0
--- /dev/null
+++ b/kernel/model/search_custom_test.go
@@ -0,0 +1,47 @@
+package model
+
+import (
+ "encoding/json"
+ "strings"
+ "testing"
+
+ "github.com/siyuan-note/siyuan/kernel/conf"
+)
+
+func TestCustomBlockSearchTypeFilter(t *testing.T) {
+ previous := Conf
+ Conf = NewAppConf()
+ Conf.Search = conf.NewSearch()
+ t.Cleanup(func() { Conf = previous })
+ for _, tc := range []struct {
+ types map[string]bool
+ want bool
+ }{{nil, true}, {map[string]bool{"customBlock": true}, true}, {map[string]bool{"customBlock": false}, false}, {map[string]bool{"paragraph": true}, false}, {map[string]bool{}, false}} {
+ if got := buildTypeFilter(tc.types, nil, "b."); strings.Contains(got, "'custom'") != tc.want {
+ t.Fatalf("unexpected filter for %v: %s", tc.types, got)
+ }
+ }
+ Conf.Search.CustomBlock = new(false)
+ if strings.Contains(buildTypeFilter(nil, nil), "'custom'") {
+ t.Fatal("disabled custom blocks included")
+ }
+}
+
+func TestCustomBlockSearchCriterionCompatibility(t *testing.T) {
+ for _, body := range []string{`{"paragraph":true}`, `{"customBlock":false}`, `{"customBlock":true}`} {
+ var types CriterionTypes
+ if err := json.Unmarshal([]byte(body), &types); err != nil {
+ t.Fatal(err)
+ }
+ encoded, err := json.Marshal(types)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if strings.Contains(body, "customBlock") != strings.Contains(string(encoded), "customBlock") {
+ t.Fatalf("field presence changed: %s", encoded)
+ }
+ if types.CustomBlock != nil && *types.CustomBlock != strings.Contains(body, "true") {
+ t.Fatalf("option changed: %s", encoded)
+ }
+ }
+}
diff --git a/kernel/model/storage.go b/kernel/model/storage.go
index 0ab6f2660c..2621049250 100644
--- a/kernel/model/storage.go
+++ b/kernel/model/storage.go
@@ -140,6 +140,8 @@ type Criterion struct {
}
type CriterionTypes struct {
+ CustomBlock *bool `json:"customBlock,omitempty"`
+
MathBlock bool `json:"mathBlock"`
Table bool `json:"table"`
Blockquote bool `json:"blockquote"`