mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Improve search jump focus block and then exit focus positioning https://github.com/siyuan-note/siyuan/issues/13577
This commit is contained in:
parent
c24c0d6af7
commit
9e2bab6718
3 changed files with 40 additions and 0 deletions
|
|
@ -224,6 +224,22 @@ func setBlockReminder(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUnfoldedParentID(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)
|
||||||
|
parentID := model.GetUnfoldedParentID(id)
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"parentID": parentID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func checkBlockFold(c *gin.Context) {
|
func checkBlockFold(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/block/getDocInfo", model.CheckAuth, getDocInfo)
|
ginServer.Handle("POST", "/api/block/getDocInfo", model.CheckAuth, getDocInfo)
|
||||||
ginServer.Handle("POST", "/api/block/getDocsInfo", model.CheckAuth, getDocsInfo)
|
ginServer.Handle("POST", "/api/block/getDocsInfo", model.CheckAuth, getDocsInfo)
|
||||||
ginServer.Handle("POST", "/api/block/checkBlockExist", model.CheckAuth, checkBlockExist)
|
ginServer.Handle("POST", "/api/block/checkBlockExist", model.CheckAuth, checkBlockExist)
|
||||||
|
ginServer.Handle("POST", "/api/block/getUnfoldedParentID", model.CheckAuth, getUnfoldedParentID)
|
||||||
ginServer.Handle("POST", "/api/block/checkBlockFold", model.CheckAuth, checkBlockFold)
|
ginServer.Handle("POST", "/api/block/checkBlockFold", model.CheckAuth, checkBlockFold)
|
||||||
ginServer.Handle("POST", "/api/block/insertBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, insertBlock)
|
ginServer.Handle("POST", "/api/block/insertBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, insertBlock)
|
||||||
ginServer.Handle("POST", "/api/block/prependBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, prependBlock)
|
ginServer.Handle("POST", "/api/block/prependBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, prependBlock)
|
||||||
|
|
|
||||||
|
|
@ -257,6 +257,29 @@ func GetBlockSiblingID(id string) (parent, previous, next string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetUnfoldedParentID(id string) (parentID string) {
|
||||||
|
tree, err := LoadTreeByBlockID(id)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
node := treenode.GetNodeInTree(tree, id)
|
||||||
|
if nil == node {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !node.IsBlock() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for parent := treenode.HeadingParent(node); nil != parent && ast.NodeDocument != parent.Type; parent = treenode.HeadingParent(parent) {
|
||||||
|
if "1" != parent.IALAttr("fold") {
|
||||||
|
return parent.ID
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func IsBlockFolded(id string) (isFolded, isRoot bool) {
|
func IsBlockFolded(id string) (isFolded, isRoot bool) {
|
||||||
tree, _ := LoadTreeByBlockID(id)
|
tree, _ := LoadTreeByBlockID(id)
|
||||||
if nil == tree {
|
if nil == tree {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue