Skip to content

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

:art: Improve the behavior of `Jump to parent block` in lists https://github.com/siyuan-note/siyuan/issues/16516

Danield3001ab12072
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 3f632e7323..1eae22dcd6 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -212,7 +212,7 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
parent = parentBlock.ID
if ast.NodeDocument == parentBlock.Type {
- parent = parentBlock.ID
+ parent = treenode.FirstLeafBlock(parentBlock).ID
if nil != current.Previous && current.Previous.IsBlock() {
previous = current.Previous.ID
@@ -230,6 +230,16 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
return
}
+ if ast.NodeListItem != parentBlock.Type {
+ if parentBlock = treenode.ParentBlock(parentBlock); nil != parentBlock {
+ parent = parentBlock.ID
+ if ast.NodeDocument == parentBlock.Type {
+ parent = treenode.FirstLeafBlock(parentBlock).ID
+ }
+ }
+ }
+
+ parentBlock = treenode.ParentBlock(current)
for ; nil != parentBlock; parentBlock = treenode.ParentBlock(parentBlock) {
if nil != parentBlock.Previous && parentBlock.Previous.IsBlock() {
previous = parentBlock.Previous.ID
@@ -239,6 +249,7 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
break
}
}
+
parentBlock = treenode.ParentBlock(current)
for ; nil != parentBlock; parentBlock = treenode.ParentBlock(parentBlock) {
if nil != parentBlock.Next && parentBlock.Next.IsBlock() {