mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Copy/Cut folded heading changed to copy/cut Headings and Bottom Blocks and support multiple headings copy/cut https://github.com/siyuan-note/siyuan/issues/8019
This commit is contained in:
parent
4767e399e2
commit
c55c413365
3 changed files with 59 additions and 6 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -629,7 +630,35 @@ func GetHeadingChildrenIDs(id string) (ret []string) {
|
|||
return
|
||||
}
|
||||
|
||||
func GetHeadingChildrenDOM(id string) (ret string) {
|
||||
func AppendHeadingChildren(id, childrenDOM string) {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
heading := treenode.GetNodeInTree(tree, id)
|
||||
if nil == heading || ast.NodeHeading != heading.Type {
|
||||
return
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
subTree := luteEngine.BlockDOM2Tree(childrenDOM)
|
||||
var nodes []*ast.Node
|
||||
for n := subTree.Root.FirstChild; nil != n; n = n.Next {
|
||||
nodes = append(nodes, n)
|
||||
}
|
||||
|
||||
slices.Reverse(nodes)
|
||||
for _, n := range nodes {
|
||||
heading.InsertAfter(n)
|
||||
}
|
||||
|
||||
if err = indexWriteTreeUpsertQueue(tree); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func GetHeadingChildrenDOM(id string, removeFoldAttr bool) (ret string) {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -650,13 +679,18 @@ func GetHeadingChildrenDOM(id string) (ret string) {
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
n.RemoveIALAttr("heading-fold")
|
||||
n.RemoveIALAttr("fold")
|
||||
if removeFoldAttr {
|
||||
n.RemoveIALAttr("heading-fold")
|
||||
n.RemoveIALAttr("fold")
|
||||
}
|
||||
return ast.WalkContinue
|
||||
})
|
||||
}
|
||||
heading.RemoveIALAttr("fold")
|
||||
heading.RemoveIALAttr("heading-fold")
|
||||
|
||||
if removeFoldAttr {
|
||||
heading.RemoveIALAttr("fold")
|
||||
heading.RemoveIALAttr("heading-fold")
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
ret = renderBlockDOMByNodes(nodes, luteEngine)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue