mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🧑💻 Add an internal kernel API /api/av/reloadAttributeView https://github.com/siyuan-note/siyuan/issues/14491
Add an internal kernel API `/api/editor/reloadProtyle` https://github.com/siyuan-note/siyuan/issues/14492
This commit is contained in:
parent
78d86629c8
commit
31312bd7c0
7 changed files with 60 additions and 19 deletions
|
|
@ -27,19 +27,6 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func reloadAttributeView(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)
|
|
||||||
model.ReloadAttrView(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func duplicateAttributeViewBlock(c *gin.Context) {
|
func duplicateAttributeViewBlock(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
|
||||||
52
kernel/api/editor.go
Normal file
52
kernel/api/editor.go
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
// SiYuan - Refactor your thinking
|
||||||
|
// Copyright (c) 2020-present, b3log.org
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/88250/gulu"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/model"
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
func reloadProtyle(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)
|
||||||
|
model.ReloadProtyle(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func reloadAttributeView(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)
|
||||||
|
model.ReloadAttrView(id)
|
||||||
|
}
|
||||||
|
|
@ -452,7 +452,6 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/av/getAttributeViewKeysByAvID", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getAttributeViewKeysByAvID)
|
ginServer.Handle("POST", "/api/av/getAttributeViewKeysByAvID", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, getAttributeViewKeysByAvID)
|
||||||
ginServer.Handle("POST", "/api/av/duplicateAttributeViewBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, duplicateAttributeViewBlock)
|
ginServer.Handle("POST", "/api/av/duplicateAttributeViewBlock", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, duplicateAttributeViewBlock)
|
||||||
ginServer.Handle("POST", "/api/av/appendAttributeViewDetachedBlocksWithValues", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, appendAttributeViewDetachedBlocksWithValues)
|
ginServer.Handle("POST", "/api/av/appendAttributeViewDetachedBlocksWithValues", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, appendAttributeViewDetachedBlocksWithValues)
|
||||||
ginServer.Handle("POST", "/api/av/reloadAttributeView", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, reloadAttributeView)
|
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, model.CheckAdminRole, chatGPT)
|
ginServer.Handle("POST", "/api/ai/chatGPT", model.CheckAuth, model.CheckAdminRole, chatGPT)
|
||||||
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, model.CheckAdminRole, chatGPTWithAction)
|
ginServer.Handle("POST", "/api/ai/chatGPTWithAction", model.CheckAuth, model.CheckAdminRole, chatGPTWithAction)
|
||||||
|
|
@ -473,4 +472,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/archive/zip", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, zip)
|
ginServer.Handle("POST", "/api/archive/zip", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, zip)
|
||||||
ginServer.Handle("POST", "/api/archive/unzip", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, unzip)
|
ginServer.Handle("POST", "/api/archive/unzip", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, unzip)
|
||||||
|
|
||||||
|
ginServer.Handle("POST", "/api/editor/reloadAttributeView", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, reloadAttributeView)
|
||||||
|
ginServer.Handle("POST", "/api/editor/reloadProtyle", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, reloadProtyle)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshProtyle(rootID)
|
ReloadProtyle(rootID)
|
||||||
|
|
||||||
// 刷新页签名
|
// 刷新页签名
|
||||||
refText := getNodeRefText(tree.Root)
|
refText := getNodeRefText(tree.Root)
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ func refreshDocInfo0(tree *parse.Tree, size uint64) {
|
||||||
task.AppendAsyncTaskWithDelay(task.ReloadProtyle, 500*time.Millisecond, util.PushReloadDocInfo, docInfo)
|
task.AppendAsyncTaskWithDelay(task.ReloadProtyle, 500*time.Millisecond, util.PushReloadDocInfo, docInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshProtyle(rootID string) {
|
func ReloadProtyle(rootID string) {
|
||||||
// 刷新关联的引用
|
// 刷新关联的引用
|
||||||
defTree, _ := LoadTreeByBlockID(rootID)
|
defTree, _ := LoadTreeByBlockID(rootID)
|
||||||
if nil != defTree {
|
if nil != defTree {
|
||||||
|
|
|
||||||
|
|
@ -916,7 +916,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
||||||
|
|
||||||
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
||||||
for _, id := range reloadTreeIDs {
|
for _, id := range reloadTreeIDs {
|
||||||
refreshProtyle(id)
|
ReloadProtyle(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAttributeViewBlockText(updateNodes)
|
updateAttributeViewBlockText(updateNodes)
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ func RemoveTag(label string) (err error) {
|
||||||
|
|
||||||
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
||||||
for _, id := range reloadTreeIDs {
|
for _, id := range reloadTreeIDs {
|
||||||
refreshProtyle(id)
|
ReloadProtyle(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAttributeViewBlockText(updateNodes)
|
updateAttributeViewBlockText(updateNodes)
|
||||||
|
|
@ -208,7 +208,7 @@ func RenameTag(oldLabel, newLabel string) (err error) {
|
||||||
|
|
||||||
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
reloadTreeIDs = gulu.Str.RemoveDuplicatedElem(reloadTreeIDs)
|
||||||
for _, id := range reloadTreeIDs {
|
for _, id := range reloadTreeIDs {
|
||||||
refreshProtyle(id)
|
ReloadProtyle(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAttributeViewBlockText(updateNodes)
|
updateAttributeViewBlockText(updateNodes)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue