Skip to content

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

:art: 位于超级块中的嵌入块不显示面包屑 Fix https://github.com/siyuan-note/siyuan/issues/6258

Liang Ding635227305290
diff --git a/app/src/protyle/markdown/blockRender.ts b/app/src/protyle/markdown/blockRender.ts
index 23fdce070f..e3049e8ceb 100644
--- a/app/src/protyle/markdown/blockRender.ts
+++ b/app/src/protyle/markdown/blockRender.ts
@@ -33,6 +33,7 @@ export const blockRender = (protyle: IProtyle, element: Element) => {
breadcrumb = window.siyuan.config.editor.embedBlockBreadcrumb
}
fetchPost("/api/search/searchEmbedBlock", {
+ embedBlockID: item.getAttribute("data-node-id"),
stmt: content,
headingMode: item.getAttribute("custom-heading-mode") === "1" ? 1 : 0,
excludeIDs: [item.getAttribute("data-node-id"), protyle.block.rootID],
diff --git a/kernel/api/search.go b/kernel/api/search.go
index ee2750d863..cba275d0e5 100644
--- a/kernel/api/search.go
+++ b/kernel/api/search.go
@@ -127,6 +127,7 @@ func searchEmbedBlock(c *gin.Context) {
return
}
+ embedBlockID := arg["embedBlockID"].(string)
stmt := arg["stmt"].(string)
excludeIDsArg := arg["excludeIDs"].([]interface{})
var excludeIDs []string
@@ -144,7 +145,7 @@ func searchEmbedBlock(c *gin.Context) {
breadcrumb = breadcrumbArg.(bool)
}
- blocks := model.SearchEmbedBlock(stmt, excludeIDs, headingMode, breadcrumb)
+ blocks := model.SearchEmbedBlock(embedBlockID, stmt, excludeIDs, headingMode, breadcrumb)
ret.Data = map[string]interface{}{
"blocks": blocks,
}
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 9c97cf902b..79049e4db1 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -381,7 +381,7 @@ func getBlock(id string) (ret *Block, err error) {
return
}
-func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, headingMode int, breadcrumb bool) (block *Block, blockPaths []*BlockPath) {
+func getEmbeddedBlock(embedBlockID string, trees map[string]*parse.Tree, sqlBlock *sql.Block, headingMode int, breadcrumb bool) (block *Block, blockPaths []*BlockPath) {
tree, _ := trees[sqlBlock.RootID]
if nil == tree {
tree, _ = loadTreeByBlockID(sqlBlock.RootID)
@@ -393,6 +393,14 @@ func getEmbeddedBlock(trees map[string]*parse.Tree, sqlBlock *sql.Block, heading
if nil == def {
return
}
+ embedNodeTree, _ := loadTreeByBlockID(embedBlockID)
+ if nil == embedNodeTree {
+ return
+ }
+ embedNode := treenode.GetNodeInTree(embedNodeTree, embedBlockID)
+ if nil == embedNode {
+ return
+ }
var unlinks, nodes []*ast.Node
ast.Walk(def, func(n *ast.Node, entering bool) ast.WalkStatus {
@@ -434,9 +442,12 @@ func getEmbeddedBlock(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}
- if breadcrumb {
- blockPaths = buildBlockBreadcrumb(def)
+ // 位于超级块中的嵌入块不显示面包屑 https://github.com/siyuan-note/siyuan/issues/6258
+ inSuperBlock := embedNode.ParentIs(ast.NodeSuperBlock)
+
+ if breadcrumb && !inSuperBlock {
+ blockPaths = buildBlockBreadcrumb(def)
}
if 1 > len(blockPaths) {
blockPaths = []*BlockPath{}
diff --git a/kernel/model/export.go b/kernel/model/export.go
index f3ba6ad34e..10368b7df0 100644
--- a/kernel/model/export.go
+++ b/kernel/model/export.go
@@ -1041,7 +1041,7 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool) (re
var defMd string
stmt := n.ChildByType(ast.NodeBlockQueryEmbedScript).TokensStr()
stmt = html.UnescapeString(stmt)
- embedBlocks := searchEmbedBlock(stmt, nil, 0, false)
+ embedBlocks := searchEmbedBlock(n.ID, stmt, nil, 0, false)
if 1 > len(embedBlocks) {
return ast.WalkContinue
}
diff --git a/kernel/model/search.go b/kernel/model/search.go
index 58d3e77af0..564cf569d5 100644
--- a/kernel/model/search.go
+++ b/kernel/model/search.go
@@ -43,12 +43,12 @@ type EmbedBlock struct {
BlockPaths []*BlockPath `json:"blockPaths"`
}
-func SearchEmbedBlock(stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
+func SearchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
WaitForWritingFiles()
- return searchEmbedBlock(stmt, excludeIDs, headingMode, breadcrumb)
+ return searchEmbedBlock(embedBlockID, stmt, excludeIDs, headingMode, breadcrumb)
}
-func searchEmbedBlock(stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
+func searchEmbedBlock(embedBlockID, stmt string, excludeIDs []string, headingMode int, breadcrumb bool) (ret []*EmbedBlock) {
sqlBlocks := sql.SelectBlocksRawStmtNoParse(stmt, Conf.Search.Limit)
var tmp []*sql.Block
for _, b := range sqlBlocks {
@@ -76,7 +76,7 @@ func searchEmbedBlock(stmt string, excludeIDs []string, headingMode int, breadcr
}
for _, sb := range sqlBlocks {
- block, blockPaths := getEmbeddedBlock(trees, sb, headingMode, breadcrumb)
+ block, blockPaths := getEmbeddedBlock(embedBlockID, trees, sb, headingMode, breadcrumb)
if nil == block {
continue
}