A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang. (PERSONAL FORK)
1// SiYuan - Refactor your thinking
2// Copyright (c) 2020-present, b3log.org
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Affero General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Affero General Public License for more details.
13//
14// You should have received a copy of the GNU Affero General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
17package conf
18
19import "github.com/siyuan-note/siyuan/kernel/util"
20
21type Editor struct {
22 AllowSVGScript bool `json:"allowSVGScript"` // 允许执行 SVG 内脚本
23 AllowHTMLBLockScript bool `json:"allowHTMLBLockScript"` // 允许执行 HTML 块内脚本
24 FontSize int `json:"fontSize"` // 字体大小
25 FontSizeScrollZoom bool `json:"fontSizeScrollZoom"` // 字体大小是否支持滚轮缩放
26 FontFamily string `json:"fontFamily"` // 字体
27 CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum"` // 代码块是否显示行号
28 CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换
29 CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行
30 CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
31 DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示内容块角标
32 DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标
33 GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟
34 HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数
35 Emoji []string `json:"emoji"` // 常用表情
36 VirtualBlockRef bool `json:"virtualBlockRef"` // 是否启用虚拟引用
37 VirtualBlockRefExclude string `json:"virtualBlockRefExclude"` // 虚拟引用关键字排除列表
38 VirtualBlockRefInclude string `json:"virtualBlockRefInclude"` // 虚拟引用关键字包含列表
39 BlockRefDynamicAnchorTextMaxLen int `json:"blockRefDynamicAnchorTextMaxLen"` // 块引动态锚文本最大长度
40 PlantUMLServePath string `json:"plantUMLServePath"` // PlantUML 伺服地址
41 FullWidth bool `json:"fullWidth"` // 是否使用最大宽度
42 KaTexMacros string `json:"katexMacros"` // KeTex 宏定义
43 ReadOnly bool `json:"readOnly"` // 只读模式
44 EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb"` // 嵌入块是否显示面包屑
45 ListLogicalOutdent bool `json:"listLogicalOutdent"` // 列表逻辑反向缩进
46 ListItemDotNumberClickFocus bool `json:"listItemDotNumberClickFocus"` // 单击列表项标记聚焦
47 FloatWindowMode int `json:"floatWindowMode"` // 浮窗触发模式,0:光标悬停,1:按住 Ctrl 悬停,2:不触发浮窗
48 FloatWindowDelay *int `json:"floatWindowDelay"` // 浮窗悬停触发延迟,单位:毫秒,默认 620,nil 表示未设置
49 DynamicLoadBlocks int `json:"dynamicLoadBlocks"` // 块动态数,可配置区间 [48, 1024]
50 Justify bool `json:"justify"` // 是否两端对齐
51 RTL bool `json:"rtl"` // 是否从右到左显示
52 Spellcheck bool `json:"spellcheck"` // 是否启用拼写检查
53 SpellcheckLanguages []string `json:"spellcheckLanguages"` // 拼写检查语言
54 OnlySearchForDoc bool `json:"onlySearchForDoc"` // 是否启用 [[ 仅搜索文档块
55 BacklinkExpandCount int `json:"backlinkExpandCount"` // 反向链接默认展开数量
56 BackmentionExpandCount int `json:"backmentionExpandCount"` // 反链提及默认展开数量
57 BacklinkContainChildren bool `json:"backlinkContainChildren"` // 反向链接是否包含子块进行计算
58 BacklinkSort *int `json:"backlinkSort"` // 反向链接排序方式
59 BackmentionSort *int `json:"backmentionSort"` // 反链提及排序方式
60 HeadingEmbedMode int `json:"headingEmbedMode"` // 标题嵌入块模式,0:显示标题与下方的块,1:仅显示标题,2:仅显示标题下方的块
61 Markdown *util.Markdown `json:"markdown"` // Markdown 配置
62}
63
64const (
65 MinDynamicLoadBlocks = 48
66)
67
68func NewEditor() *Editor {
69 return &Editor{
70 FontSize: 16,
71 FontSizeScrollZoom: false,
72 CodeSyntaxHighlightLineNum: false,
73 CodeTabSpaces: 0,
74 CodeLineWrap: false,
75 CodeLigatures: false,
76 DisplayBookmarkIcon: true,
77 DisplayNetImgMark: true,
78 GenerateHistoryInterval: 10,
79 HistoryRetentionDays: 30,
80 Emoji: []string{},
81 VirtualBlockRef: false,
82 BlockRefDynamicAnchorTextMaxLen: 96,
83 PlantUMLServePath: "https://www.plantuml.com/plantuml/svg/~1",
84 FullWidth: true,
85 KaTexMacros: "{}",
86 ReadOnly: false,
87 EmbedBlockBreadcrumb: false,
88 ListLogicalOutdent: false,
89 ListItemDotNumberClickFocus: true,
90 FloatWindowMode: 0,
91 FloatWindowDelay: func() *int { v := 620; return &v }(),
92 DynamicLoadBlocks: 192,
93 Justify: false,
94 RTL: false,
95 Spellcheck: false,
96 SpellcheckLanguages: []string{"en-US"},
97 BacklinkExpandCount: 8,
98 BackmentionExpandCount: -1,
99 BacklinkContainChildren: true,
100 BacklinkSort: func() *int { v := util.SortModeUpdatedDESC; return &v }(),
101 BackmentionSort: func() *int { v := util.SortModeUpdatedDESC; return &v }(),
102 HeadingEmbedMode: 0,
103 Markdown: util.MarkdownSettings,
104 }
105}