mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
30a5cdc9f5
commit
1e2a707e02
4 changed files with 26 additions and 6 deletions
|
|
@ -457,7 +457,8 @@ func getEmbeddedBlock(embedBlockID string, trees map[string]*parse.Tree, sqlBloc
|
||||||
luteEngine := NewLute()
|
luteEngine := NewLute()
|
||||||
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
|
luteEngine.RenderOptions.ProtyleContenteditable = false // 不可编辑
|
||||||
dom := renderBlockDOMByNodes(nodes, luteEngine)
|
dom := renderBlockDOMByNodes(nodes, luteEngine)
|
||||||
block = &Block{Box: def.Box, Path: def.Path, HPath: b.HPath, ID: def.ID, Type: def.Type.String(), Content: dom}
|
content := renderBlockContentByNodes(nodes)
|
||||||
|
block = &Block{Box: def.Box, Path: def.Path, HPath: b.HPath, ID: def.ID, Type: def.Type.String(), Content: dom, Markdown: content /* 这里使用 Markdown 字段来临时存储 content */}
|
||||||
|
|
||||||
// 位于超级块中的嵌入块不显示面包屑 https://github.com/siyuan-note/siyuan/issues/6258
|
// 位于超级块中的嵌入块不显示面包屑 https://github.com/siyuan-note/siyuan/issues/6258
|
||||||
inSuperBlock := false
|
inSuperBlock := false
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,25 @@ func renderBlockDOMByNodes(nodes []*ast.Node, luteEngine *lute.Lute) string {
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func renderBlockContentByNodes(nodes []*ast.Node) string {
|
||||||
|
var subNodes []*ast.Node
|
||||||
|
for _, n := range nodes {
|
||||||
|
if ast.NodeDocument == n.Type {
|
||||||
|
for c := n.FirstChild; nil != c; c = c.Next {
|
||||||
|
subNodes = append(subNodes, c)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
subNodes = append(subNodes, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf := bytes.Buffer{}
|
||||||
|
for _, n := range subNodes {
|
||||||
|
buf.WriteString(treenode.NodeStaticContent(n, nil))
|
||||||
|
}
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
func renderBlockMarkdownR(id string) string {
|
func renderBlockMarkdownR(id string) string {
|
||||||
var rendered []string
|
var rendered []string
|
||||||
nodes := renderBlockMarkdownR0(id, &rendered)
|
nodes := renderBlockMarkdownR0(id, &rendered)
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,6 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
||||||
}
|
}
|
||||||
sqlBlocks = tmp
|
sqlBlocks = tmp
|
||||||
|
|
||||||
// 嵌入块支持搜索 https://github.com/siyuan-note/siyuan/issues/7112
|
|
||||||
task.AppendTask(task.DatabaseIndexEmbedBlock, updateEmbedBlockContent, embedBlockID, sqlBlocks)
|
|
||||||
|
|
||||||
// 缓存最多 128 棵语法树
|
// 缓存最多 128 棵语法树
|
||||||
trees := map[string]*parse.Tree{}
|
trees := map[string]*parse.Tree{}
|
||||||
count := 0
|
count := 0
|
||||||
|
|
@ -101,6 +98,9 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 嵌入块支持搜索 https://github.com/siyuan-note/siyuan/issues/7112
|
||||||
|
task.AppendTask(task.DatabaseIndexEmbedBlock, updateEmbedBlockContent, embedBlockID, ret)
|
||||||
|
|
||||||
// 添加笔记本名称
|
// 添加笔记本名称
|
||||||
var boxIDs []string
|
var boxIDs []string
|
||||||
for _, embedBlock := range ret {
|
for _, embedBlock := range ret {
|
||||||
|
|
|
||||||
|
|
@ -1244,14 +1244,14 @@ func autoIndexEmbedBlock(embedBlocks []*sql.Block) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateEmbedBlockContent(embedBlockID string, queryResultBlocks []*sql.Block) {
|
func updateEmbedBlockContent(embedBlockID string, queryResultBlocks []*EmbedBlock) {
|
||||||
embedBlock := sql.GetBlock(embedBlockID)
|
embedBlock := sql.GetBlock(embedBlockID)
|
||||||
if nil == embedBlock {
|
if nil == embedBlock {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, block := range queryResultBlocks {
|
for _, block := range queryResultBlocks {
|
||||||
embedBlock.Content += block.Content
|
embedBlock.Content += block.Block.Markdown
|
||||||
}
|
}
|
||||||
if "" == embedBlock.Content {
|
if "" == embedBlock.Content {
|
||||||
embedBlock.Content = "no query result"
|
embedBlock.Content = "no query result"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue