mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 06:11:53 +08:00
🎨 Display document title in data history preview area https://github.com/siyuan-note/siyuan/issues/12948
This commit is contained in:
parent
face9918f1
commit
a15899d421
@ -70,7 +70,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id := arg["id"].(string)
|
id := arg["id"].(string)
|
||||||
content, isProtyleDoc, updated, err := model.OpenRepoSnapshotDoc(id)
|
title, content, isProtyleDoc, updated, err := model.OpenRepoSnapshotDoc(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ret.Code = -1
|
ret.Code = -1
|
||||||
ret.Msg = err.Error()
|
ret.Msg = err.Error()
|
||||||
@ -78,6 +78,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret.Data = map[string]interface{}{
|
ret.Data = map[string]interface{}{
|
||||||
|
"title": title,
|
||||||
"content": content,
|
"content": content,
|
||||||
"isProtyleDoc": isProtyleDoc,
|
"isProtyleDoc": isProtyleDoc,
|
||||||
"updated": updated,
|
"updated": updated,
|
||||||
|
@ -79,7 +79,7 @@ func GetRepoFile(fileID string) (ret []byte, p string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, updated int64, err error) {
|
func OpenRepoSnapshotDoc(fileID string) (title, content string, isProtyleDoc bool, updated int64, err error) {
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
err = errors.New(Conf.Language(26))
|
err = errors.New(Conf.Language(26))
|
||||||
return
|
return
|
||||||
@ -110,6 +110,7 @@ func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, upda
|
|||||||
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
|
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
title = snapshotTree.Root.IALAttr("title")
|
||||||
|
|
||||||
if !isProtyleDoc {
|
if !isProtyleDoc {
|
||||||
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
renderTree := &parse.Tree{Root: &ast.Node{Type: ast.NodeDocument}}
|
||||||
@ -150,6 +151,7 @@ func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, upda
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
isProtyleDoc = true
|
isProtyleDoc = true
|
||||||
|
title = path.Base(file.Path)
|
||||||
if strings.HasSuffix(file.Path, ".json") {
|
if strings.HasSuffix(file.Path, ".json") {
|
||||||
content = gulu.Str.FromBytes(data)
|
content = gulu.Str.FromBytes(data)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user