Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-03-01 00:27:33 +08:00
commit 923b82bca4
2 changed files with 27 additions and 4 deletions

View File

@ -238,6 +238,26 @@ func extensionCopy(c *gin.Context) {
if "" != assetPath { if "" != assetPath {
dest.Tokens = []byte(assetPath) dest.Tokens = []byte(assetPath)
} }
// 检测 alt 和 title 格式,如果不是文本的话转换为文本 https://github.com/siyuan-note/siyuan/issues/14233
if linkText := n.ChildByType(ast.NodeLinkText); nil != linkText {
if inlineTree := parse.Inline("", linkText.Tokens, luteEngine.ParseOptions); nil != inlineTree && nil != inlineTree.Root && nil != inlineTree.Root.FirstChild {
if fc := inlineTree.Root.FirstChild.FirstChild; nil != fc {
if ast.NodeText != fc.Type {
linkText.Tokens = []byte(fc.Text())
}
}
}
}
if title := n.ChildByType(ast.NodeLinkTitle); nil != title {
if inlineTree := parse.Inline("", title.Tokens, luteEngine.ParseOptions); nil != inlineTree && nil != inlineTree.Root && nil != inlineTree.Root.FirstChild {
if fc := inlineTree.Root.FirstChild.FirstChild; nil != fc {
if ast.NodeText != fc.Type {
title.Tokens = []byte(fc.Text())
}
}
}
}
} }
} }
return ast.WalkContinue return ast.WalkContinue

View File

@ -245,7 +245,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
} }
} }
destPath, parentHPath, err = getRollbackDockPath(boxID, workingDoc) destPath, parentHPath, err = getRollbackDockPath(boxID, historyPath, workingDoc)
if err != nil { if err != nil {
return return
} }
@ -338,13 +338,16 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
return nil return nil
} }
func getRollbackDockPath(boxID string, workingDoc *treenode.BlockTree) (destPath, parentHPath string, err error) { func getRollbackDockPath(boxID, historyPath string, workingDoc *treenode.BlockTree) (destPath, parentHPath string, err error) {
var parentID, baseName string var parentID string
baseName := filepath.Base(historyPath)
var parentWorkingDoc *treenode.BlockTree var parentWorkingDoc *treenode.BlockTree
if nil != workingDoc { if nil != workingDoc {
baseName = path.Base(workingDoc.Path)
parentID = path.Base(path.Dir(workingDoc.Path)) parentID = path.Base(path.Dir(workingDoc.Path))
parentWorkingDoc = treenode.GetBlockTree(parentID) parentWorkingDoc = treenode.GetBlockTree(parentID)
} else {
parentID = filepath.Base(filepath.Dir(historyPath))
parentWorkingDoc = treenode.GetBlockTree(parentID)
} }
if nil != parentWorkingDoc { if nil != parentWorkingDoc {