mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 The insertion position is wrong after converting the list to paragraph block in the floating window https://github.com/siyuan-note/siyuan/issues/15396
This commit is contained in:
parent
27f412658b
commit
be684aee76
3 changed files with 62 additions and 0 deletions
|
|
@ -280,6 +280,42 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetBlockIDs(id string) (parentID, previousID, nextID string, err error) {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
if nil == node {
|
||||
err = ErrBlockNotFound
|
||||
return
|
||||
}
|
||||
|
||||
if nil != node.Parent {
|
||||
parentID = node.Parent.ID
|
||||
}
|
||||
if nil != node.Previous {
|
||||
previous := node.Previous
|
||||
if ast.NodeKramdownBlockIAL == previous.Type {
|
||||
previous = previous.Previous
|
||||
}
|
||||
if nil != previous {
|
||||
previousID = previous.ID
|
||||
}
|
||||
}
|
||||
if nil != node.Next {
|
||||
next := node.Next
|
||||
if ast.NodeKramdownBlockIAL == next.Type {
|
||||
next = next.Next
|
||||
}
|
||||
if nil != next {
|
||||
nextID = next.ID
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetUnfoldedParentID(id string) (parentID string) {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue