mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-23 23:44:06 +01:00
🎨 位于超级块中的嵌入块不显示面包屑 Fix https://github.com/siyuan-note/siyuan/issues/6258
This commit is contained in:
parent
4b84d6abd1
commit
6352273052
5 changed files with 22 additions and 9 deletions
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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{}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue