🎨 查询嵌入块支持设置是否显示面包屑 https://github.com/siyuan-note/siyuan/issues/6184

This commit is contained in:
Liang Ding 2022-10-17 10:37:01 +08:00
parent 82ffe82c81
commit 3bc24f89c5
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
10 changed files with 62 additions and 35 deletions

View file

@ -17,14 +17,14 @@
package conf
type Editor struct {
FontSize int `json:"fontSize"`
FontFamily string `json:"fontFamily"`
CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum"`
CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换
CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行
CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
DisplayBookmarkIcon bool `json:"displayBookmarkIcon"`
DisplayNetImgMark bool `json:"displayNetImgMark"`
FontSize int `json:"fontSize"` // 字体大小
FontFamily string `json:"fontFamily"` // 字体
CodeSyntaxHighlightLineNum bool `json:"codeSyntaxHighlightLineNum"` // 代码块是否显示行号
CodeTabSpaces int `json:"codeTabSpaces"` // 代码块中 Tab 转换空格数,配置为 0 则表示不转换
CodeLineWrap bool `json:"codeLineWrap"` // 代码块是否自动折行
CodeLigatures bool `json:"codeLigatures"` // 代码块是否连字
DisplayBookmarkIcon bool `json:"displayBookmarkIcon"` // 是否显示书签图标
DisplayNetImgMark bool `json:"displayNetImgMark"` // 是否显示网络图片角标
GenerateHistoryInterval int `json:"generateHistoryInterval"` // 生成历史时间间隔,单位:分钟
HistoryRetentionDays int `json:"historyRetentionDays"` // 历史保留天数
Emoji []string `json:"emoji"` // 常用表情
@ -35,6 +35,7 @@ type Editor struct {
FullWidth bool `json:"fullWidth"` // 是否使用最大宽度
KaTexMacros string `json:"katexMacros"` // KeTex 宏定义
ReadOnly bool `json:"readOnly"` // 只读模式
EmbedBlockBreadcrumb bool `json:"embedBlockBreadcrumb"` // 嵌入块是否显示面包屑
}
func NewEditor() *Editor {
@ -55,5 +56,6 @@ func NewEditor() *Editor {
FullWidth: true,
KaTexMacros: "{}",
ReadOnly: false,
EmbedBlockBreadcrumb: false,
}
}

View file

@ -381,7 +381,7 @@ func getBlock(id string) (ret *Block, err error) {
return
}
func getBlockRendered(trees map[string]*parse.Tree, sqlBlock *sql.Block, headingMode int) (block *Block, blockPaths []*BlockPath) {
func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, headingMode int) (block *Block, blockPaths []*BlockPath) {
tree, _ := trees[sqlBlock.RootID]
if nil == tree {
tree, _ = loadTreeByBlockID(sqlBlock.RootID)
@ -434,6 +434,11 @@ func getBlockRendered(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
dom := renderBlockDOMByNodes(nodes, luteEngine)
block = &Block{Box: def.Box, Path: def.Path, HPath: b.HPath, ID: def.ID, Type: def.Type.String(), Content: dom}
blockPaths = buildBlockBreadcrumb(def)
if Conf.Editor.EmbedBlockBreadcrumb {
blockPaths = buildBlockBreadcrumb(def)
}
if 1 > len(blockPaths) {
blockPaths = []*BlockPath{}
}
return
}

View file

@ -76,7 +76,7 @@ func searchEmbedBlock(stmt string, excludeIDs []string, headingMode int) (ret []
}
for _, sb := range sqlBlocks {
block, blockPaths := getBlockRendered(trees, sb, headingMode)
block, blockPaths := getEmbeddedBlock(trees, sb, headingMode)
if nil == block {
continue
}