mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 块引用与所引用的内容块进行交换 https://github.com/siyuan-note/siyuan/issues/4981
This commit is contained in:
parent
5bd06ea506
commit
f4a918cd5b
1 changed files with 10 additions and 0 deletions
|
|
@ -113,6 +113,11 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
|
||||||
var defNodeChildren []*ast.Node
|
var defNodeChildren []*ast.Node
|
||||||
if ast.NodeListItem == defNode.Parent.Type {
|
if ast.NodeListItem == defNode.Parent.Type {
|
||||||
defNode = defNode.Parent
|
defNode = defNode.Parent
|
||||||
|
for c := defNode.FirstChild; nil != c; c = c.Next {
|
||||||
|
if ast.NodeList == c.Type {
|
||||||
|
defNodeChildren = append(defNodeChildren, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if ast.NodeHeading == defNode.Type && includeChildren {
|
} else if ast.NodeHeading == defNode.Type && includeChildren {
|
||||||
defNodeChildren = treenode.HeadingChildren(defNode)
|
defNodeChildren = treenode.HeadingChildren(defNode)
|
||||||
}
|
}
|
||||||
|
|
@ -131,6 +136,11 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
|
||||||
li.SetIALAttr("updated", newID[:14])
|
li.SetIALAttr("updated", newID[:14])
|
||||||
li.AppendChild(refNode)
|
li.AppendChild(refNode)
|
||||||
defNode.InsertAfter(li)
|
defNode.InsertAfter(li)
|
||||||
|
if !includeChildren {
|
||||||
|
for _, c := range defNodeChildren {
|
||||||
|
li.AppendChild(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
newID = ast.NewNodeID()
|
newID = ast.NewNodeID()
|
||||||
list := &ast.Node{ID: newID, Type: ast.NodeList, ListData: &ast.ListData{Typ: defNode.Parent.ListData.Typ}}
|
list := &ast.Node{ID: newID, Type: ast.NodeList, ListData: &ast.ListData{Typ: defNode.Parent.ListData.Typ}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue