Skip to content

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

:recycle: Remove integer compatibility from block indicator settings https://github.com/siyuan-note/siyuan/issues/20647

Daniel84f54d04245e
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index 02107324fd..d8ad16bfca 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -1888,7 +1888,7 @@ export type SetCriterionRequestInput = { "criterion": CriterionInput | null; };
export type SetDatabaseBlockViewRequestInput = { "avID": string; "id": string; "viewID": string; };
-export type SetEditorRequestInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoCloseRefBrackets"?: boolean | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockGutterMode"?: boolean | number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pageScrollButtons"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
+export type SetEditorRequestInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoCloseRefBrackets"?: boolean | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockGutterMode"?: boolean | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pageScrollButtons"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
export type SetEntryVisibilityRequestInput = { "active"?: string | null; "profiles"?: Array<SettingEntryVisibilityProfileInput | null> | null; "version"?: number | null; };
@@ -2030,7 +2030,7 @@ export type SettingEditorFont = { "displayName": string; "family": string; "weig
export type SettingEditorFontInput = { "displayName"?: string | null; "family"?: string | null; "weight"?: number | null; };
-export type SettingEditorInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoCloseRefBrackets"?: boolean | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockGutterMode"?: boolean | number | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pageScrollButtons"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
+export type SettingEditorInput = { "allowHTMLBLockScript"?: boolean | null; "allowSVGScript"?: boolean | null; "assetOpen"?: SettingAssetOpenInput | null; "autoCloseRefBrackets"?: boolean | null; "autoDirection"?: boolean | null; "backlinkBlockSort"?: number | null; "backlinkContainChildren"?: boolean | null; "backlinkExpandCount"?: number | null; "backlinkGlobalSort"?: number | null; "backlinkHideReference"?: boolean | null; "backlinkMentionExclude"?: string | null; "backlinkShowBottom"?: boolean | null; "backlinkSort"?: number | null; "backmentionExpandCount"?: number | null; "backmentionSort"?: number | null; "blockGutterMode"?: boolean | null; "blockRefDynamicAnchorTextMaxLen"?: number | null; "checkBlockRef"?: boolean | null; "codeFontFamilies"?: Array<SettingEditorFontInput | null> | null; "codeLigatures"?: boolean | null; "codeLineWrap"?: boolean | null; "codeSyntaxHighlightLineNum"?: boolean | null; "codeTabSpaces"?: number | null; "cursorSurroundingLines"?: number | null; "databaseAttrClickMode"?: number | null; "databaseAttrHideEmpty"?: boolean | null; "databaseAttrShow"?: boolean | null; "databaseAttrUseTabs"?: boolean | null; "databaseAttrViewMode"?: number | null; "displayBookmarkIcon"?: boolean | null; "displayImgAlt"?: boolean | null; "displayImgName"?: boolean | null; "displayNetImgMark"?: boolean | null; "dragHTMLFileToIframe"?: boolean | null; "dynamicLoadBlocks"?: number | null; "embedBlockBreadcrumb"?: boolean | null; "emoji"?: Array<string> | null; "floatWindowDelay"?: number | null; "floatWindowMode"?: number | null; "fontFamilies"?: Array<SettingEditorFontInput | null> | null; "fontFamily"?: string | null; "fontFamilyDisplay"?: string | null; "fontSize"?: number | null; "fontSizeScrollZoom"?: boolean | null; "fontWeight"?: number | null; "fullWidth"?: boolean | null; "generateHistoryInterval"?: number | null; "hashTagSearch"?: boolean | null; "headingEmbedMode"?: number | null; "headingNumber"?: boolean | null; "headingNumberFormat"?: string | null; "historyRetentionDays"?: number | null; "justify"?: boolean | null; "katexMacros"?: string | null; "keepLoadedContent"?: boolean | null; "listItemDotNumberClickFocus"?: boolean | null; "listLogicalOutdent"?: boolean | null; "markdown"?: SettingMarkdownInput | null; "onlySearchForDoc"?: boolean | null; "pageScrollButtons"?: boolean | null; "pasteURLAutoConvert"?: boolean | null; "plantUMLServePath"?: string | null; "readOnly"?: boolean | null; "rtl"?: boolean | null; "spellcheck"?: boolean | null; "spellcheckLanguages"?: Array<string> | null; "virtualBlockRef"?: boolean | null; "virtualBlockRefExclude"?: string | null; "virtualBlockRefInclude"?: string | null; };
export type SettingEmbedding = { "apiKey": string; "baseURL": string; "batchSize": number; "concurrency": number; "dimensions": number; "enabled": boolean; "id": string; "name": string; "timeout": number; };
diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts
index 661d4d6e7f..1b3f88329a 100644
--- a/app/src/types/config.d.ts
+++ b/app/src/types/config.d.ts
@@ -646,7 +646,7 @@ declare namespace Config {
* Whether to display the bookmark icon
*/
displayBookmarkIcon: boolean;
- /** 是否显示完整块标,默认 false;输入兼容旧整数,1 为启用,其他整数为关闭 */
+ /** 是否显示完整块标,默认 false */
blockGutterMode: boolean;
/**
* Whether to display the network image mark
diff --git a/app/tests/api-contract.types.ts b/app/tests/api-contract.types.ts
index bb81382270..b375bf9a50 100644
--- a/app/tests/api-contract.types.ts
+++ b/app/tests/api-contract.types.ts
@@ -49,12 +49,14 @@ fetchPost("/api/setting/setEditor", {blockGutterMode: true}, response => {
if (response.code === 0 && response.data) {
const enabled: boolean = response.data.blockGutterMode;
// @ts-expect-error 块标开关响应统一为布尔值。
- const legacyMode: number = response.data.blockGutterMode;
- void [enabled, legacyMode];
+ const numericMode: number = response.data.blockGutterMode;
+ void [enabled, numericMode];
}
});
+// @ts-expect-error 块标开关不接受整数。
fetchPost("/api/setting/setEditor", {blockGutterMode: 1});
fetchPost("/api/setting/patch", {editor: {blockGutterMode: false}});
+// @ts-expect-error 局部更新也不接受整数块标配置。
fetchPost("/api/setting/patch", {editor: {blockGutterMode: 0}});
// @ts-expect-error 块标开关不接受字符串。
fetchPost("/api/setting/setEditor", {blockGutterMode: "true"});
diff --git a/kernel/api/contract_setting_gutter_test.go b/kernel/api/contract_setting_gutter_test.go
index d8577e4a96..2ec4224699 100644
--- a/kernel/api/contract_setting_gutter_test.go
+++ b/kernel/api/contract_setting_gutter_test.go
@@ -38,16 +38,14 @@ func TestAPIContractSettingBlockGutterMode(t *testing.T) {
want bool
}{
{`{"blockGutterMode":true}`, true}, {`{}`, true}, {`{"blockGutterMode":false}`, false},
- {`{"blockGutterMode":1}`, true}, {`{}`, true}, {`{"blockGutterMode":0}`, false},
- {`{"BlockGutterMode":1}`, true}, {`{"blockGutterMode":null}`, false},
- {`{"blockGutterMode":-1}`, false}, {`{"blockGutterMode":2}`, false},
+ {`{"BlockGutterMode":true}`, true}, {`{"blockGutterMode":null}`, false},
} {
code, message, data := settingContractRequest(t, "setEditor", setEditor, entry.body)
var response apicontract.SettingEditor
if err := json.Unmarshal(data, &response); err != nil {
t.Fatal(err)
}
- if code != 0 || bool(model.Conf.Editor.Load().BlockGutterMode) != entry.want || bool(response.BlockGutterMode) != entry.want {
+ if code != 0 || model.Conf.Editor.Load().BlockGutterMode != entry.want || response.BlockGutterMode != entry.want {
t.Fatalf("block gutter mode update %s: code=%d message=%s data=%s", entry.body, code, message, data)
}
var output struct {
@@ -62,23 +60,22 @@ func TestAPIContractSettingBlockGutterMode(t *testing.T) {
want bool
}{
{`{"editor":{"blockGutterMode":true}}`, true}, {`{"editor":{"fontSize":18}}`, true},
- {`{"editor":{"blockGutterMode":false}}`, false}, {`{"editor":{"blockGutterMode":1}}`, true},
- {`{"editor":{"blockGutterMode":0}}`, false}, {`{"editor":{"blockGutterMode":99}}`, false},
+ {`{"editor":{"blockGutterMode":false}}`, false},
{`{"editor":{"blockGutterMode":true}}`, true}, {`{"editor":{"blockGutterMode":null}}`, false},
} {
code, message, data := settingContractRequest(t, "patch", patchSetting, entry.body)
- if code != 0 || bool(model.Conf.Editor.Load().BlockGutterMode) != entry.want {
+ if code != 0 || model.Conf.Editor.Load().BlockGutterMode != entry.want {
t.Fatalf("block gutter mode patch %s: code=%d message=%s data=%s", entry.body, code, message, data)
}
}
- code, message, _ := settingContractRequest(t, "setEditor", setEditor, `{"blockGutterMode":1}`)
+ code, message, _ := settingContractRequest(t, "setEditor", setEditor, `{"blockGutterMode":true}`)
if code != 0 {
t.Fatalf("full mode could not be saved: %d %s", code, message)
}
- for _, raw := range []string{`"true"`, `1.5`, `[]`, `{}`} {
+ for _, raw := range []string{`0`, `1`, `-1`, `2`, `99`, `"true"`, `1.5`, `[]`, `{}`} {
code, _, _ = settingContractRequest(t, "setEditor", setEditor, `{"blockGutterMode":`+raw+`}`)
if code == 0 || !model.Conf.Editor.Load().BlockGutterMode {
- t.Fatalf("invalid legacy write changed the enabled preference: %s", raw)
+ t.Fatalf("invalid setting write changed the enabled preference: %s", raw)
}
code, _, _ = settingContractRequest(t, "patch", patchSetting, `{"editor":{"blockGutterMode":`+raw+`}}`)
if code == 0 || !model.Conf.Editor.Load().BlockGutterMode {
diff --git a/kernel/apicontract/schema.go b/kernel/apicontract/schema.go
index 17f309d45f..7b75bc3cdc 100644
--- a/kernel/apicontract/schema.go
+++ b/kernel/apicontract/schema.go
@@ -8,8 +8,6 @@ import (
"reflect"
"sort"
"strings"
-
- "github.com/siyuan-note/siyuan/kernel/internal/configcompat"
)
// Schema 是生成器和响应验证共用的 JSON Schema 子集;不支持的 Go 类型直接报错。
@@ -95,12 +93,6 @@ func nonnullable(schema *Schema) *Schema {
}
func (b *schemaBuilder) schema(t reflect.Type, input bool) (*Schema, error) {
- if t == reflect.TypeFor[configcompat.BlockGutterMode]() {
- if input {
- return &Schema{AnyOf: []*Schema{{Type: "boolean"}, {Type: "integer"}}}, nil
- }
- return &Schema{Type: "boolean"}, nil
- }
if schema, err := transactionPayloadSchema(b, t, input); schema != nil || err != nil {
return schema, err
}
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 1486db56d7..c978c6f31c 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -40499,14 +40499,7 @@
"blockGutterMode": {
"anyOf": [
{
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "type": "integer"
- }
- ]
+ "type": "boolean"
},
{
"type": "null"
@@ -45152,14 +45145,7 @@
"blockGutterMode": {
"anyOf": [
{
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "type": "integer"
- }
- ]
+ "type": "boolean"
},
{
"type": "null"
diff --git a/kernel/apicontract/setting.go b/kernel/apicontract/setting.go
index 47821fc7fc..e794735f7f 100644
--- a/kernel/apicontract/setting.go
+++ b/kernel/apicontract/setting.go
@@ -1,7 +1,5 @@
package apicontract
-import "github.com/siyuan-note/siyuan/kernel/internal/configcompat"
-
type SettingSnpt struct {
EnabledCSS bool `json:"enabledCSS" api:"optional,nullable"`
EnabledJS bool `json:"enabledJS" api:"optional,nullable"`
@@ -197,52 +195,52 @@ type SettingFlashcard struct {
}
// SettingEditor 描述编辑器配置。displayImgName 和 displayImgAlt 默认关闭,更新设置时省略这些字段保留当前值。
-// blockGutterMode 为布尔开关,默认 false,输出及持久化均为布尔值;旧接口省略时保留当前值。
-// 输入兼容旧整数:1 表示启用,其他整数归为关闭;null 表示关闭,非法类型和小数拒绝更新。
+// blockGutterMode 控制是否显示完整块标,默认 false,输出及持久化均为布尔值。
+// 整段设置接口省略时保留当前值;null 表示关闭,其他非布尔类型拒绝更新。
type SettingEditor struct {
- AllowSVGScript bool `json:"allowSVGScript" api:"optional,nullable"`
- AllowHTMLBLockScript bool `json:"allowHTMLBLockScript" api:"optional,nullable"`
- CursorSurroundingLines int `json:"cursorSurroundingLines" api:"optional,nullable"`
- FontSize int `json:"fontSize" api:"optional,nullable"`
- FontSizeScrollZoom bool `json:"fontSizeScrollZoom" api:"optional,nullable"`
- FontFamily string `json:"fontFamily" api:"optional,nullable"`
- FontWeight int `json:"fontWeight" api:"optional,nullable"`
- FontFamilyDisplay string `json:"fontFamilyDisplay" api:"optional,nullable"`
- FontFamilies []*SettingEditorFont `json:"fontFamilies" api:"optional,nullable"`
- CodeFontFamilies []*SettingEditorFont `json:"codeFontFamilies" api:"optional,nullable"`
- CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum" api:"optional,nullable"`
- CodeTabSpaces int `json:"codeTabSpaces" api:"optional,nullable"`
- CodeLineWrap bool `json:"codeLineWrap" api:"optional,nullable"`
- CodeLigatures bool `json:"codeLigatures" api:"optional,nullable"`
- DisplayBookmarkIcon bool `json:"displayBookmarkIcon" api:"optional,nullable"`
- BlockGutterMode configcompat.BlockGutterMode `json:"blockGutterMode" api:"optional,nullable"`
- DisplayNetImgMark bool `json:"displayNetImgMark" api:"optional,nullable"`
- DisplayImgName bool `json:"displayImgName" api:"optional,nullable"`
- DisplayImgAlt bool `json:"displayImgAlt" api:"optional,nullable"`
- DatabaseAttrShow *bool `json:"databaseAttrShow" api:"optional,nullable"`
- DatabaseAttrClickMode int `json:"databaseAttrClickMode" api:"optional,nullable"`
- DatabaseAttrViewMode int `json:"databaseAttrViewMode" api:"optional,nullable"`
- DatabaseAttrHideEmpty bool `json:"databaseAttrHideEmpty" api:"optional,nullable"`
- DatabaseAttrUseTabs *bool `json:"databaseAttrUseTabs" api:"optional,nullable"`
- GenerateHistoryInterval int `json:"generateHistoryInterval" api:"optional,nullable"`
- HistoryRetentionDays int `json:"historyRetentionDays" api:"optional,nullable"`
- Emoji []string `json:"emoji" api:"optional,nullable"`
- VirtualBlockRef bool `json:"virtualBlockRef" api:"optional,nullable"`
- VirtualBlockRefExclude string `json:"virtualBlockRefExclude" api:"optional,nullable"`
- VirtualBlockRefInclude string `json:"virtualBlockRefInclude" api:"optional,nullable"`
- CheckBlockRef *bool `json:"checkBlockRef" api:"optional,nullable"`
- BlockRefDynamicAnchorTextMaxLen int `json:"blockRefDynamicAnchorTextMaxLen" api:"optional,nullable"`
- AssetOpen *SettingAssetOpen `json:"assetOpen" api:"optional,nullable"`
- PlantUMLServePath string `json:"plantUMLServePath" api:"optional,nullable"`
- FullWidth bool `json:"fullWidth" api:"optional,nullable"`
- KaTexMacros string `json:"katexMacros" api:"optional,nullable"`
- ReadOnly bool `json:"readOnly" api:"optional,nullable"`
- EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb" api:"optional,nullable"`
- ListLogicalOutdent bool `json:"listLogicalOutdent" api:"optional,nullable"`
- ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus" api:"optional,nullable"`
- FloatWindowMode int `json:"floatWindowMode" api:"optional,nullable"`
- FloatWindowDelay *int `json:"floatWindowDelay" api:"optional,nullable"`
- KeepLoadedContent bool `json:"keepLoadedContent" api:"optional,nullable"`
+ AllowSVGScript bool `json:"allowSVGScript" api:"optional,nullable"`
+ AllowHTMLBLockScript bool `json:"allowHTMLBLockScript" api:"optional,nullable"`
+ CursorSurroundingLines int `json:"cursorSurroundingLines" api:"optional,nullable"`
+ FontSize int `json:"fontSize" api:"optional,nullable"`
+ FontSizeScrollZoom bool `json:"fontSizeScrollZoom" api:"optional,nullable"`
+ FontFamily string `json:"fontFamily" api:"optional,nullable"`
+ FontWeight int `json:"fontWeight" api:"optional,nullable"`
+ FontFamilyDisplay string `json:"fontFamilyDisplay" api:"optional,nullable"`
+ FontFamilies []*SettingEditorFont `json:"fontFamilies" api:"optional,nullable"`
+ CodeFontFamilies []*SettingEditorFont `json:"codeFontFamilies" api:"optional,nullable"`
+ CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum" api:"optional,nullable"`
+ CodeTabSpaces int `json:"codeTabSpaces" api:"optional,nullable"`
+ CodeLineWrap bool `json:"codeLineWrap" api:"optional,nullable"`
+ CodeLigatures bool `json:"codeLigatures" api:"optional,nullable"`
+ DisplayBookmarkIcon bool `json:"displayBookmarkIcon" api:"optional,nullable"`
+ BlockGutterMode bool `json:"blockGutterMode" api:"optional,nullable"`
+ DisplayNetImgMark bool `json:"displayNetImgMark" api:"optional,nullable"`
+ DisplayImgName bool `json:"displayImgName" api:"optional,nullable"`
+ DisplayImgAlt bool `json:"displayImgAlt" api:"optional,nullable"`
+ DatabaseAttrShow *bool `json:"databaseAttrShow" api:"optional,nullable"`
+ DatabaseAttrClickMode int `json:"databaseAttrClickMode" api:"optional,nullable"`
+ DatabaseAttrViewMode int `json:"databaseAttrViewMode" api:"optional,nullable"`
+ DatabaseAttrHideEmpty bool `json:"databaseAttrHideEmpty" api:"optional,nullable"`
+ DatabaseAttrUseTabs *bool `json:"databaseAttrUseTabs" api:"optional,nullable"`
+ GenerateHistoryInterval int `json:"generateHistoryInterval" api:"optional,nullable"`
+ HistoryRetentionDays int `json:"historyRetentionDays" api:"optional,nullable"`
+ Emoji []string `json:"emoji" api:"optional,nullable"`
+ VirtualBlockRef bool `json:"virtualBlockRef" api:"optional,nullable"`
+ VirtualBlockRefExclude string `json:"virtualBlockRefExclude" api:"optional,nullable"`
+ VirtualBlockRefInclude string `json:"virtualBlockRefInclude" api:"optional,nullable"`
+ CheckBlockRef *bool `json:"checkBlockRef" api:"optional,nullable"`
+ BlockRefDynamicAnchorTextMaxLen int `json:"blockRefDynamicAnchorTextMaxLen" api:"optional,nullable"`
+ AssetOpen *SettingAssetOpen `json:"assetOpen" api:"optional,nullable"`
+ PlantUMLServePath string `json:"plantUMLServePath" api:"optional,nullable"`
+ FullWidth bool `json:"fullWidth" api:"optional,nullable"`
+ KaTexMacros string `json:"katexMacros" api:"optional,nullable"`
+ ReadOnly bool `json:"readOnly" api:"optional,nullable"`
+ EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb" api:"optional,nullable"`
+ ListLogicalOutdent bool `json:"listLogicalOutdent" api:"optional,nullable"`
+ ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus" api:"optional,nullable"`
+ FloatWindowMode int `json:"floatWindowMode" api:"optional,nullable"`
+ FloatWindowDelay *int `json:"floatWindowDelay" api:"optional,nullable"`
+ KeepLoadedContent bool `json:"keepLoadedContent" api:"optional,nullable"`
// PageScrollButtons 控制翻屏按钮,默认关闭,不迁移旧的本地偏好。
PageScrollButtons bool `json:"pageScrollButtons" api:"optional,nullable"`
DynamicLoadBlocks int `json:"dynamicLoadBlocks" api:"optional,nullable"`
diff --git a/kernel/conf/editor.go b/kernel/conf/editor.go
index 775810b384..9845f68597 100644
--- a/kernel/conf/editor.go
+++ b/kernel/conf/editor.go
@@ -16,10 +16,7 @@
package conf
-import (
- "github.com/siyuan-note/siyuan/kernel/internal/configcompat"
- "github.com/siyuan-note/siyuan/kernel/util"
-)
+import "github.com/siyuan-note/siyuan/kernel/util"
const (
AssetOpenActionFollowTab = "follow-tab"
@@ -47,75 +44,75 @@ type EditorFont struct {
}
type Editor struct {
- AllowSVGScript bool `json:"allowSVGScript"` // 允许执行 SVG 内脚本
- AllowHTMLBLockScript bool `json:"allowHTMLBLockScript"` // 允许执行 HTML 内容中的脚本
- CursorSurroundingLines int `json:"cursorSurroundingLines"` // 光标上下文行数
- FontSize int `json:"fontSize"` // 字体大小
- FontSizeScrollZoom bool `json:"fontSizeScrollZoom"` // 保留用于配置兼容,前端不再使用
- FontFamily string `json:"fontFamily"` // 首选字体(兼容旧版本)
- FontWeight int `json:"fontWeight"` // 首选字体字重(兼容旧版本)
- FontFamilyDisplay string `json:"fontFamilyDisplay"` // 设置面板中展示的字体名称(与 FontFamily/FontWeight 对应,可选)
- FontFamilies []*EditorFont `json:"fontFamilies"` // 按优先级排列的字体
- CodeFontFamilies []*EditorFont `json:"codeFontFamilies"` // 按优先级排列的等宽字体
- CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum"` // 代码块是否显示行号
- CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换
- CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行
- CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
- DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标
- BlockGutterMode configcompat.BlockGutterMode `json:"blockGutterMode"` // 是否显示完整块标,兼容整数配置
- DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标
- DisplayImgName bool `json:"displayImgName"` // 是否显示图片文件名
- DisplayImgAlt bool `json:"displayImgAlt"` // 是否显示图片提示文本
- DatabaseAttrShow *bool `json:"databaseAttrShow"` // 是否在文档顶部显示数据库属性
- DatabaseAttrClickMode int `json:"databaseAttrClickMode"` // 数据库角标点击模式,0:聚焦块并展开数据库面板,1:打开块属性面板
- DatabaseAttrViewMode int `json:"databaseAttrViewMode"` // 数据库属性默认展开状态,0:展开,1:折叠
- DatabaseAttrHideEmpty bool `json:"databaseAttrHideEmpty"` // 是否隐藏数据库空属性
- DatabaseAttrUseTabs *bool `json:"databaseAttrUseTabs"` // 数据库属性是否使用页签
- GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟
- HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数
- Emoji []string `json:"emoji"` // 常用表情
- VirtualBlockRef bool `json:"virtualBlockRef"` // 是否启用虚拟引用
- VirtualBlockRefExclude string `json:"virtualBlockRefExclude"` // 虚拟引用关键字排除列表
- VirtualBlockRefInclude string `json:"virtualBlockRefInclude"` // 虚拟引用关键字包含列表
- CheckBlockRef *bool `json:"checkBlockRef"` // 删除或剪切前是否检查块引用和数据库绑定
- BlockRefDynamicAnchorTextMaxLen int `json:"blockRefDynamicAnchorTextMaxLen"` // 块引动态锚文本最大长度
- AssetOpen *AssetOpen `json:"assetOpen"` // 资源打开方式
- PlantUMLServePath string `json:"plantUMLServePath"` // PlantUML 伺服地址
- FullWidth bool `json:"fullWidth"` // 是否使用最大宽度
- KaTexMacros string `json:"katexMacros"` // KeTex 宏定义
- ReadOnly bool `json:"readOnly"` // 只读模式
- EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb"` // 嵌入块是否显示面包屑
- ListLogicalOutdent bool `json:"listLogicalOutdent"` // 列表逻辑反向缩进
- ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus"` // 单击列表项标记聚焦
- FloatWindowMode int `json:"floatWindowMode"` // 浮窗触发模式,0:光标悬停,1:按住 Ctrl 悬停,2:不触发浮窗
- FloatWindowDelay *int `json:"floatWindowDelay"` // 浮窗悬停触发延迟,单位:毫秒,默认 620,nil 表示未设置
- KeepLoadedContent bool `json:"keepLoadedContent"` // 是否保持动态加载的内容
- PageScrollButtons bool `json:"pageScrollButtons"` // 是否显示翻屏按钮,默认关闭
- DynamicLoadBlocks int `json:"dynamicLoadBlocks"` // 块动态数,下限 48
- Justify bool `json:"justify"` // 是否两端对齐
- RTL bool `json:"rtl"` // 是否从右到左显示
- AutoDirection bool `json:"autoDirection"` // 是否自动判定段落和标题的文本方向
- Spellcheck bool `json:"spellcheck"` // 是否启用拼写检查
- SpellcheckLanguages []string `json:"spellcheckLanguages"` // 拼写检查语言
- HashTagSearch *bool `json:"hashTagSearch"` // 输入 # 时是否进行标签搜索
- OnlySearchForDoc bool `json:"onlySearchForDoc"` // 是否启用 [[ 仅搜索文档块
- AutoCloseRefBrackets bool `json:"autoCloseRefBrackets"` // 输入 [[ 时自动补全 ]],输入 ]] 时完成引用
- BacklinkExpandCount int `json:"backlinkExpandCount"` // 反向链接默认展开数量
- BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
- BacklinkMentionExclude string `json:"backlinkMentionExclude"` // 反链提及关键字排除列表
- BacklinkContainChildren bool `json:"backlinkContainChildren"` // 反向链接是否包含子块进行计算
- BacklinkHideReference bool `json:"backlinkHideReference"` // 反链面板是否隐藏传递型纯引用块
- BacklinkShowBottom bool `json:"backlinkShowBottom"` // 是否在文档底部显示反向链接
- BacklinkSort *int `json:"backlinkSort"` // 反向链接排序方式
- BacklinkGlobalSort int `json:"backlinkGlobalSort"` // 0 文档分组,1 全局锚文本升序,2 全局锚文本降序
- BacklinkBlockSort int `json:"backlinkBlockSort"` // 文档内引用排序:0 正文顺序,1 锚文本升序,2 锚文本降序
- BackmentionSort *int `json:"backmentionSort"` // 反链提及排序方式
- HeadingNumber bool `json:"headingNumber"` // 是否显示标题编号
- HeadingNumberFormat string `json:"headingNumberFormat"` // 标题编号格式
- HeadingEmbedMode int `json:"headingEmbedMode"` // 标题嵌入块模式,0:显示标题与下方的块,1:仅显示标题,2:仅显示标题下方的块
- PasteURLAutoConvert bool `json:"pasteURLAutoConvert"` // 粘贴网址时自动转为链接
- DragHTMLFileToIframe bool `json:"dragHTMLFileToIframe"` // 是否将拖拽的 HTML 文件嵌入为 IFrame 块
- Markdown *util.Markdown `json:"markdown"` // Markdown 配置
+ AllowSVGScript bool `json:"allowSVGScript"` // 允许执行 SVG 内脚本
+ AllowHTMLBLockScript bool `json:"allowHTMLBLockScript"` // 允许执行 HTML 内容中的脚本
+ CursorSurroundingLines int `json:"cursorSurroundingLines"` // 光标上下文行数
+ FontSize int `json:"fontSize"` // 字体大小
+ FontSizeScrollZoom bool `json:"fontSizeScrollZoom"` // 保留用于配置兼容,前端不再使用
+ FontFamily string `json:"fontFamily"` // 首选字体(兼容旧版本)
+ FontWeight int `json:"fontWeight"` // 首选字体字重(兼容旧版本)
+ FontFamilyDisplay string `json:"fontFamilyDisplay"` // 设置面板中展示的字体名称(与 FontFamily/FontWeight 对应,可选)
+ FontFamilies []*EditorFont `json:"fontFamilies"` // 按优先级排列的字体
+ CodeFontFamilies []*EditorFont `json:"codeFontFamilies"` // 按优先级排列的等宽字体
+ CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum"` // 代码块是否显示行号
+ CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换
+ CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行
+ CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
+ DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标
+ BlockGutterMode bool `json:"blockGutterMode"` // 是否显示完整块标
+ DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标
+ DisplayImgName bool `json:"displayImgName"` // 是否显示图片文件名
+ DisplayImgAlt bool `json:"displayImgAlt"` // 是否显示图片提示文本
+ DatabaseAttrShow *bool `json:"databaseAttrShow"` // 是否在文档顶部显示数据库属性
+ DatabaseAttrClickMode int `json:"databaseAttrClickMode"` // 数据库角标点击模式,0:聚焦块并展开数据库面板,1:打开块属性面板
+ DatabaseAttrViewMode int `json:"databaseAttrViewMode"` // 数据库属性默认展开状态,0:展开,1:折叠
+ DatabaseAttrHideEmpty bool `json:"databaseAttrHideEmpty"` // 是否隐藏数据库空属性
+ DatabaseAttrUseTabs *bool `json:"databaseAttrUseTabs"` // 数据库属性是否使用页签
+ GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟
+ HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数
+ Emoji []string `json:"emoji"` // 常用表情
+ VirtualBlockRef bool `json:"virtualBlockRef"` // 是否启用虚拟引用
+ VirtualBlockRefExclude string `json:"virtualBlockRefExclude"` // 虚拟引用关键字排除列表
+ VirtualBlockRefInclude string `json:"virtualBlockRefInclude"` // 虚拟引用关键字包含列表
+ CheckBlockRef *bool `json:"checkBlockRef"` // 删除或剪切前是否检查块引用和数据库绑定
+ BlockRefDynamicAnchorTextMaxLen int `json:"blockRefDynamicAnchorTextMaxLen"` // 块引动态锚文本最大长度
+ AssetOpen *AssetOpen `json:"assetOpen"` // 资源打开方式
+ PlantUMLServePath string `json:"plantUMLServePath"` // PlantUML 伺服地址
+ FullWidth bool `json:"fullWidth"` // 是否使用最大宽度
+ KaTexMacros string `json:"katexMacros"` // KeTex 宏定义
+ ReadOnly bool `json:"readOnly"` // 只读模式
+ EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb"` // 嵌入块是否显示面包屑
+ ListLogicalOutdent bool `json:"listLogicalOutdent"` // 列表逻辑反向缩进
+ ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus"` // 单击列表项标记聚焦
+ FloatWindowMode int `json:"floatWindowMode"` // 浮窗触发模式,0:光标悬停,1:按住 Ctrl 悬停,2:不触发浮窗
+ FloatWindowDelay *int `json:"floatWindowDelay"` // 浮窗悬停触发延迟,单位:毫秒,默认 620,nil 表示未设置
+ KeepLoadedContent bool `json:"keepLoadedContent"` // 是否保持动态加载的内容
+ PageScrollButtons bool `json:"pageScrollButtons"` // 是否显示翻屏按钮,默认关闭
+ DynamicLoadBlocks int `json:"dynamicLoadBlocks"` // 块动态数,下限 48
+ Justify bool `json:"justify"` // 是否两端对齐
+ RTL bool `json:"rtl"` // 是否从右到左显示
+ AutoDirection bool `json:"autoDirection"` // 是否自动判定段落和标题的文本方向
+ Spellcheck bool `json:"spellcheck"` // 是否启用拼写检查
+ SpellcheckLanguages []string `json:"spellcheckLanguages"` // 拼写检查语言
+ HashTagSearch *bool `json:"hashTagSearch"` // 输入 # 时是否进行标签搜索
+ OnlySearchForDoc bool `json:"onlySearchForDoc"` // 是否启用 [[ 仅搜索文档块
+ AutoCloseRefBrackets bool `json:"autoCloseRefBrackets"` // 输入 [[ 时自动补全 ]],输入 ]] 时完成引用
+ BacklinkExpandCount int `json:"backlinkExpandCount"` // 反向链接默认展开数量
+ BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
+ BacklinkMentionExclude string `json:"backlinkMentionExclude"` // 反链提及关键字排除列表
+ BacklinkContainChildren bool `json:"backlinkContainChildren"` // 反向链接是否包含子块进行计算
+ BacklinkHideReference bool `json:"backlinkHideReference"` // 反链面板是否隐藏传递型纯引用块
+ BacklinkShowBottom bool `json:"backlinkShowBottom"` // 是否在文档底部显示反向链接
+ BacklinkSort *int `json:"backlinkSort"` // 反向链接排序方式
+ BacklinkGlobalSort int `json:"backlinkGlobalSort"` // 0 文档分组,1 全局锚文本升序,2 全局锚文本降序
+ BacklinkBlockSort int `json:"backlinkBlockSort"` // 文档内引用排序:0 正文顺序,1 锚文本升序,2 锚文本降序
+ BackmentionSort *int `json:"backmentionSort"` // 反链提及排序方式
+ HeadingNumber bool `json:"headingNumber"` // 是否显示标题编号
+ HeadingNumberFormat string `json:"headingNumberFormat"` // 标题编号格式
+ HeadingEmbedMode int `json:"headingEmbedMode"` // 标题嵌入块模式,0:显示标题与下方的块,1:仅显示标题,2:仅显示标题下方的块
+ PasteURLAutoConvert bool `json:"pasteURLAutoConvert"` // 粘贴网址时自动转为链接
+ DragHTMLFileToIframe bool `json:"dragHTMLFileToIframe"` // 是否将拖拽的 HTML 文件嵌入为 IFrame 块
+ Markdown *util.Markdown `json:"markdown"` // Markdown 配置
}
// NormalizeFontFamilies 清理字体列表并同步兼容旧版本的首选字体字段。
diff --git a/kernel/conf/editor_gutter_test.go b/kernel/conf/editor_gutter_test.go
deleted file mode 100644
index 6d619cd766..0000000000
--- a/kernel/conf/editor_gutter_test.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package conf
-
-import (
- "encoding/json"
- "testing"
-
- "github.com/88250/gulu"
-)
-
-func TestEditorBlockGutterModeMigration(t *testing.T) {
- if NewEditor().BlockGutterMode {
- t.Fatal("full block indicators must default to disabled")
- }
- for _, decoder := range []struct {
- name string
- decode func([]byte, any) error
- }{{"json", json.Unmarshal}, {"gulu", gulu.JSON.UnmarshalJSON}} {
- for _, raw := range []string{`true`, `false`, `1`, `0`, `null`, `99`} {
- t.Run(decoder.name+"/"+raw, func(t *testing.T) {
- editor := NewEditor()
- if err := decoder.decode([]byte(`{"blockGutterMode":`+raw+`,"fontSize":24}`), editor); err != nil {
- t.Fatal(err)
- }
- editor = NormalizeEditor(editor)
- want := raw == "true" || raw == "1"
- if bool(editor.BlockGutterMode) != want || editor.FontSize != 24 {
- t.Fatalf("migration changed preferences: %+v", editor)
- }
- data, err := json.Marshal(editor)
- if err != nil {
- t.Fatal(err)
- }
- var saved struct {
- BlockGutterMode bool `json:"blockGutterMode"`
- }
- if err = json.Unmarshal(data, &saved); err != nil || saved.BlockGutterMode != want {
- t.Fatalf("saved preference is not boolean: %s, %v", data, err)
- }
- })
- }
- }
-}
diff --git a/kernel/internal/configcompat/block_gutter.go b/kernel/internal/configcompat/block_gutter.go
deleted file mode 100644
index bbed265c75..0000000000
--- a/kernel/internal/configcompat/block_gutter.go
+++ /dev/null
@@ -1,20 +0,0 @@
-package configcompat
-
-import "encoding/json"
-
-// BlockGutterMode 保存完整块标开关,并兼容整数配置;仅 1 表示启用,其他整数表示关闭。
-type BlockGutterMode bool
-
-func (mode *BlockGutterMode) UnmarshalJSON(data []byte) error {
- var enabled bool
- if err := json.Unmarshal(data, &enabled); err == nil {
- *mode = BlockGutterMode(enabled)
- return nil
- }
- var legacy int
- if err := json.Unmarshal(data, &legacy); err != nil {
- return err
- }
- *mode = legacy == 1
- return nil
-}
diff --git a/kernel/internal/configcompat/block_gutter_test.go b/kernel/internal/configcompat/block_gutter_test.go
deleted file mode 100644
index 62d7cc3ccb..0000000000
--- a/kernel/internal/configcompat/block_gutter_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package configcompat
-
-import (
- "encoding/json"
- "testing"
-)
-
-func TestBlockGutterModeJSON(t *testing.T) {
- for _, entry := range []struct {
- raw string
- want bool
- }{
- {`true`, true}, {`false`, false}, {`null`, false},
- {`1`, true}, {`0`, false}, {`-1`, false}, {`2`, false}, {`99`, false},
- } {
- t.Run(entry.raw, func(t *testing.T) {
- mode := BlockGutterMode(true)
- if err := json.Unmarshal([]byte(entry.raw), &mode); err != nil || bool(mode) != entry.want {
- t.Fatalf("input %s: %v, %v", entry.raw, mode, err)
- }
- encoded, err := json.Marshal(mode)
- var enabled bool
- if err != nil || json.Unmarshal(encoded, &enabled) != nil || enabled != entry.want {
- t.Fatalf("non-boolean output %s: %v", encoded, err)
- }
- })
- }
- for _, raw := range []string{`1.5`, `1.0`, `1e0`, `"true"`, `"1"`, `[]`, `{}`, `9223372036854775808`} {
- t.Run(raw, func(t *testing.T) {
- mode := BlockGutterMode(true)
- if err := json.Unmarshal([]byte(raw), &mode); err == nil || !mode {
- t.Fatalf("invalid input changed the existing value: %s, %v", raw, err)
- }
- })
- }
-}