Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 数据历史文档支持只读可视化预览 https://github.com/siyuan-note/siyuan/issues/5735

Liang Ding5d403e3505df
diff --git a/kernel/api/history.go b/kernel/api/history.go
index 4320479165..b3652d0de2 100644
--- a/kernel/api/history.go
+++ b/kernel/api/history.go
@@ -121,7 +121,7 @@ func getDocHistoryContent(c *gin.Context) {
if nil != k {
keyword = k.(string)
}
- content, isLargeDoc, err := model.GetDocHistoryContent(historyPath, keyword)
+ id, rootID, content, isLargeDoc, err := model.GetDocHistoryContent(historyPath, keyword)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@@ -129,6 +129,8 @@ func getDocHistoryContent(c *gin.Context) {
}
ret.Data = map[string]interface{}{
+ "id": id,
+ "rootID": rootID,
"content": content,
"isLargeDoc": isLargeDoc,
}
diff --git a/kernel/model/history.go b/kernel/model/history.go
index 8c7961d47b..e7e301f8d9 100644
--- a/kernel/model/history.go
+++ b/kernel/model/history.go
@@ -141,7 +141,7 @@ func ClearWorkspaceHistory() (err error) {
return
}
-func GetDocHistoryContent(historyPath, keyword string) (content string, isLargeDoc bool, err error) {
+func GetDocHistoryContent(historyPath, keyword string) (id, rootID, content string, isLargeDoc bool, err error) {
if !gulu.File.IsExist(historyPath) {
return
}
@@ -160,6 +160,8 @@ func GetDocHistoryContent(historyPath, keyword string) (content string, isLargeD
os.RemoveAll(historyPath)
return
}
+ id = historyTree.Root.ID
+ rootID = historyTree.Root.ID
if !isLargeDoc {
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}