mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 08:51:07 +08:00
🎨 移动折叠标题后自动展开 https://github.com/siyuan-note/siyuan/issues/6673
This commit is contained in:
parent
f23cd5005d
commit
5afffdb0f7
@ -52,6 +52,20 @@ func swapBlockRef(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func getHeadingChildrenIDs(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
ids := model.GetHeadingChildrenIDs(id)
|
||||
ret.Data = ids
|
||||
}
|
||||
|
||||
func getHeadingChildrenDOM(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
@ -160,6 +160,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||
ginServer.Handle("POST", "/api/block/setBlockReminder", model.CheckAuth, setBlockReminder)
|
||||
ginServer.Handle("POST", "/api/block/getHeadingLevelTransaction", model.CheckAuth, getHeadingLevelTransaction)
|
||||
ginServer.Handle("POST", "/api/block/getHeadingDeleteTransaction", model.CheckAuth, getHeadingDeleteTransaction)
|
||||
ginServer.Handle("POST", "/api/block/getHeadingChildrenIDs", model.CheckAuth, getHeadingChildrenIDs)
|
||||
ginServer.Handle("POST", "/api/block/getHeadingChildrenDOM", model.CheckAuth, getHeadingChildrenDOM)
|
||||
ginServer.Handle("POST", "/api/block/swapBlockRef", model.CheckAuth, swapBlockRef)
|
||||
|
||||
|
@ -252,6 +252,25 @@ func GetHeadingDeleteTransaction(id string) (transaction *Transaction, err error
|
||||
return
|
||||
}
|
||||
|
||||
func GetHeadingChildrenIDs(id string) (ret []string) {
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
heading := treenode.GetNodeInTree(tree, id)
|
||||
if nil == heading || ast.NodeHeading != heading.Type {
|
||||
return
|
||||
}
|
||||
|
||||
nodes := append([]*ast.Node{}, heading)
|
||||
children := treenode.HeadingChildren(heading)
|
||||
nodes = append(nodes, children...)
|
||||
for _, n := range nodes {
|
||||
ret = append(ret, n.ID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetHeadingChildrenDOM(id string) (ret string) {
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
|
Loading…
Reference in New Issue
Block a user