Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
264fb0dff6
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.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}
|
||||
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
|
||||
inSuperBlock := false
|
||||
|
|
|
@ -118,6 +118,25 @@ func renderBlockDOMByNodes(nodes []*ast.Node, luteEngine *lute.Lute) string {
|
|||
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 {
|
||||
var rendered []string
|
||||
nodes := renderBlockMarkdownR0(id, &rendered)
|
||||
|
|
|
@ -70,9 +70,6 @@ func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMod
|
|||
}
|
||||
sqlBlocks = tmp
|
||||
|
||||
// 嵌入块支持搜索 https://github.com/siyuan-note/siyuan/issues/7112
|
||||
task.AppendTask(task.DatabaseIndexEmbedBlock, updateEmbedBlockContent, embedBlockID, sqlBlocks)
|
||||
|
||||
// 缓存最多 128 棵语法树
|
||||
trees := map[string]*parse.Tree{}
|
||||
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
|
||||
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)
|
||||
if nil == embedBlock {
|
||||
return
|
||||
}
|
||||
|
||||
for _, block := range queryResultBlocks {
|
||||
embedBlock.Content += block.Content
|
||||
embedBlock.Content += block.Block.Markdown
|
||||
}
|
||||
if "" == embedBlock.Content {
|
||||
embedBlock.Content = "no query result"
|
||||
|
|
Loading…
Add table
Reference in a new issue