mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve the behavior of Jump to the next/previous block of the parent block in lists https://github.com/siyuan-note/siyuan/issues/15939
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
d2f8bccc37
commit
467ff96d0e
1 changed files with 10 additions and 67 deletions
|
|
@ -196,78 +196,22 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
node := treenode.GetNodeInTree(tree, id)
|
current := treenode.GetNodeInTree(tree, id)
|
||||||
if nil == node {
|
if nil == current || !current.IsBlock() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
parentBlock := treenode.ParentBlock(current)
|
||||||
|
if nil == parentBlock {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !node.IsBlock() {
|
parent = parentBlock.ID
|
||||||
return
|
if flb := treenode.FirstChildBlock(parentBlock); nil != flb {
|
||||||
}
|
|
||||||
|
|
||||||
parentListCount := 0
|
|
||||||
var parentListItem, current *ast.Node
|
|
||||||
for p := node.Parent; nil != p; p = p.Parent {
|
|
||||||
if ast.NodeListItem == p.Type {
|
|
||||||
parentListCount++
|
|
||||||
if 1 < parentListCount {
|
|
||||||
parentListItem = p
|
|
||||||
break
|
|
||||||
}
|
|
||||||
current = p.Parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if nil != parentListItem {
|
|
||||||
parent = parentListItem.ID
|
|
||||||
|
|
||||||
if parentListItem.Previous != nil {
|
|
||||||
previous = parentListItem.Previous.ID
|
|
||||||
if flb := treenode.FirstChildBlock(parentListItem.Previous); nil != flb {
|
|
||||||
previous = flb.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if parentListItem.Next != nil {
|
|
||||||
next = parentListItem.Next.ID
|
|
||||||
if flb := treenode.FirstChildBlock(parentListItem.Next); nil != flb {
|
|
||||||
next = flb.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if "" == previous && "" == next && nil != current {
|
|
||||||
parent = current.ID
|
|
||||||
if nil != current.Previous {
|
|
||||||
previous = current.Previous.ID
|
|
||||||
if flb := treenode.FirstChildBlock(current.Previous); nil != flb {
|
|
||||||
previous = flb.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if nil != current.Next {
|
|
||||||
next = current.Next.ID
|
|
||||||
if flb := treenode.FirstChildBlock(current.Next); nil != flb {
|
|
||||||
next = flb.ID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if nil == current {
|
|
||||||
current = node
|
|
||||||
}
|
|
||||||
|
|
||||||
if nil == current.Parent || !current.Parent.IsBlock() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
parent = current.Parent.ID
|
|
||||||
if flb := treenode.FirstChildBlock(current.Parent); nil != flb {
|
|
||||||
parent = flb.ID
|
parent = flb.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
if ast.NodeDocument == current.Parent.Type {
|
if ast.NodeDocument == parentBlock.Type {
|
||||||
parent = current.Parent.ID
|
parent = parentBlock.ID
|
||||||
|
|
||||||
if nil != current.Previous && current.Previous.IsBlock() {
|
if nil != current.Previous && current.Previous.IsBlock() {
|
||||||
previous = current.Previous.ID
|
previous = current.Previous.ID
|
||||||
|
|
@ -285,7 +229,6 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
parentBlock := treenode.ParentBlock(current)
|
|
||||||
for ; nil != parentBlock; parentBlock = treenode.ParentBlock(parentBlock) {
|
for ; nil != parentBlock; parentBlock = treenode.ParentBlock(parentBlock) {
|
||||||
if nil != parentBlock.Previous && parentBlock.Previous.IsBlock() {
|
if nil != parentBlock.Previous && parentBlock.Previous.IsBlock() {
|
||||||
previous = parentBlock.Previous.ID
|
previous = parentBlock.Previous.ID
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue