mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Add scenes for expanding and collapsing headings https://github.com/siyuan-note/siyuan/issues/15726
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
b8e67bec2d
commit
3f7421a393
3 changed files with 63 additions and 0 deletions
|
|
@ -628,6 +628,46 @@ func GetHeadingDeleteTransaction(id string) (transaction *Transaction, err error
|
|||
return
|
||||
}
|
||||
|
||||
func GetHeadingInsertTransaction(id string) (transaction *Transaction, err error) {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
if nil == node {
|
||||
err = errors.New(fmt.Sprintf(Conf.Language(15), id))
|
||||
return
|
||||
}
|
||||
|
||||
if ast.NodeHeading != node.Type {
|
||||
return
|
||||
}
|
||||
|
||||
var nodes []*ast.Node
|
||||
nodes = append(nodes, node)
|
||||
nodes = append(nodes, treenode.HeadingChildren(node)...)
|
||||
|
||||
transaction = &Transaction{}
|
||||
luteEngine := util.NewLute()
|
||||
for _, n := range nodes {
|
||||
n.ID = ast.NewNodeID()
|
||||
n.SetIALAttr("id", n.ID)
|
||||
|
||||
op := &Operation{}
|
||||
op.ID = n.ID
|
||||
op.Action = "insert"
|
||||
op.Data = luteEngine.RenderNodeBlockDOM(n)
|
||||
transaction.DoOperations = append(transaction.DoOperations, op)
|
||||
|
||||
op = &Operation{}
|
||||
op.ID = n.ID
|
||||
op.Action = "delete"
|
||||
transaction.UndoOperations = append(transaction.UndoOperations, op)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetHeadingChildrenIDs(id string) (ret []string) {
|
||||
tree, err := LoadTreeByBlockID(id)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue