mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 08:00:13 +01:00
🎨 Add two shortcuts for block navigation https://github.com/siyuan-note/siyuan/issues/11193
This commit is contained in:
parent
c1bde4f917
commit
4ad53bbeab
1 changed files with 53 additions and 13 deletions
|
|
@ -129,36 +129,76 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parentListCount := 0
|
||||||
var parentList *ast.Node
|
var parentList *ast.Node
|
||||||
for p := node.Parent; nil != p; p = p.Parent {
|
for p := node.Parent; nil != p; p = p.Parent {
|
||||||
if ast.NodeList == p.Type {
|
if ast.NodeList == p.Type {
|
||||||
|
parentListCount++
|
||||||
|
if 1 < parentListCount {
|
||||||
parentList = p
|
parentList = p
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if nil != parentList {
|
if nil != parentList {
|
||||||
parent = parentList.ID
|
parent = parentList.ID
|
||||||
if node.Previous != nil {
|
if flb := treenode.FirstLeafBlock(parentList); nil != flb {
|
||||||
previous = node.Previous.ID
|
parent = flb.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
if parentList.Previous != nil {
|
||||||
|
previous = parentList.Previous.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(parentList.Previous); nil != flb {
|
||||||
|
previous = flb.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if parentList.Next != nil {
|
||||||
|
next = parentList.Next.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(parentList.Next); nil != flb {
|
||||||
|
next = flb.ID
|
||||||
}
|
}
|
||||||
if node.Next != nil {
|
|
||||||
next = node.Next.ID
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != node.Parent && node.Parent.IsBlock() {
|
if nil != node.Parent && node.Parent.IsBlock() {
|
||||||
parent = node.Parent.ID
|
parent = node.Parent.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(node.Parent); nil != flb {
|
||||||
|
parent = flb.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ast.NodeDocument == node.Parent.Type {
|
||||||
if nil != node.Previous && node.Previous.IsBlock() {
|
if nil != node.Previous && node.Previous.IsBlock() {
|
||||||
previous = node.Previous.ID
|
previous = node.Previous.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(node.Previous); nil != flb {
|
||||||
|
previous = flb.ID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != node.Next && node.Next.IsBlock() {
|
if nil != node.Next && node.Next.IsBlock() {
|
||||||
next = node.Next.ID
|
next = node.Next.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(node.Next); nil != flb {
|
||||||
|
next = flb.ID
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if nil != node.Parent.Previous && node.Parent.Previous.IsBlock() {
|
||||||
|
previous = node.Parent.Previous.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(node.Parent.Previous); nil != flb {
|
||||||
|
previous = flb.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if nil != node.Parent.Next && node.Parent.Next.IsBlock() {
|
||||||
|
next = node.Parent.Next.ID
|
||||||
|
if flb := treenode.FirstLeafBlock(node.Parent.Next); nil != flb {
|
||||||
|
next = flb.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue