Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
3ea7daa308
10 changed files with 59 additions and 34 deletions
|
@ -24,6 +24,8 @@ Below are the detailed changes in this version.
|
|||
* [Add SQL query template function `querySQL`](https://github.com/siyuan-note/siyuan/issues/13455)
|
||||
* [Search preview area supports inline memo positioning](https://github.com/siyuan-note/siyuan/issues/13465)
|
||||
* [Add Arabic support](https://github.com/siyuan-note/siyuan/pull/13475)
|
||||
* [Improve exporting data](https://github.com/siyuan-note/siyuan/issues/13500)
|
||||
* [Improve serving assets performance](https://github.com/siyuan-note/siyuan/issues/13501)
|
||||
|
||||
### Bugfix
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
* [新增 SQL 查詢範本函數 `querySQL`](https://github.com/siyuan-note/siyuan/issues/13455)
|
||||
* [搜尋預覽區域支援行級備註定位](https://github.com/siyuan-note/siyuan/issues/13465)
|
||||
* [新增阿拉伯語支援](https://github.com/siyuan-note/siyuan/pull/13475)
|
||||
* [改進匯出資料](https://github.com/siyuan-note/siyuan/issues/13500)
|
||||
* [改進資源檔案載入效能](https://github.com/siyuan-note/siyuan/issues/13501)
|
||||
|
||||
### 修復缺陷
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
* [添加 SQL 查询模板函数 `querySQL`](https://github.com/siyuan-note/siyuan/issues/13455)
|
||||
* [搜索预览区域支持行级备注定位](https://github.com/siyuan-note/siyuan/issues/13465)
|
||||
* [添加阿拉伯语支持](https://github.com/siyuan-note/siyuan/pull/13475)
|
||||
* [改进导出数据](https://github.com/siyuan-note/siyuan/issues/13500)
|
||||
* [改进资源文件加载性能](https://github.com/siyuan-note/siyuan/issues/13501)
|
||||
|
||||
### 修复缺陷
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
if (refreshElement) {
|
||||
refreshElement.style.display = ""
|
||||
}
|
||||
}, 2000)
|
||||
}, 7000)
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
2
app/stage/protyle/js/lute/lute.min.js
vendored
2
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
|
||||
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
|
||||
github.com/88250/gulu v1.2.3-0.20241212012748-c4dc08fe45ec
|
||||
github.com/88250/lute v1.7.7-0.20241213121436-8647e479e280
|
||||
github.com/88250/lute v1.7.7-0.20241216140552-8ec551250ce3
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
|
||||
github.com/ConradIrwin/font v0.0.0-20240627033111-8567075b2bfe
|
||||
|
|
|
@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20241212012748-c4dc08fe45ec h1:YsUSpByWJP+x8C+IT+C3QlFvU7ZQ6+E95SFd9+zy6QU=
|
||||
github.com/88250/gulu v1.2.3-0.20241212012748-c4dc08fe45ec/go.mod h1:c8uVw25vW2W4dhJ/j4iYsX5H1hc19spim266jO5x2hU=
|
||||
github.com/88250/lute v1.7.7-0.20241213121436-8647e479e280 h1:Ub4MpkyCTOvf3L1po5FUSJ1h52qlrThN8YQtbxbUu2s=
|
||||
github.com/88250/lute v1.7.7-0.20241213121436-8647e479e280/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/lute v1.7.7-0.20241216140552-8ec551250ce3 h1:5f7we6cT8uIaU6pPO3gU916JUxSodJEKwnykhhZFs50=
|
||||
github.com/88250/lute v1.7.7-0.20241216140552-8ec551250ce3/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20241201033812-5a93b7586a01 h1:AcFe63RXjIh1XtX/dc4Es3U8bYKjlEkvavHd1nFBOHM=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20241201033812-5a93b7586a01/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
@ -322,13 +322,24 @@ func GetAssetAbsPath(relativePath string) (ret string, err error) {
|
|||
if strings.Contains(relativePath, "?") {
|
||||
relativePath = relativePath[:strings.Index(relativePath, "?")]
|
||||
}
|
||||
|
||||
// 在全局 assets 路径下搜索
|
||||
p := filepath.Join(util.DataDir, relativePath)
|
||||
if gulu.File.IsExist(p) {
|
||||
ret = p
|
||||
if !util.IsSubPath(util.WorkspaceDir, ret) {
|
||||
err = fmt.Errorf("[%s] is not sub path of workspace", ret)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 在笔记本下搜索
|
||||
notebooks, err := ListNotebooks()
|
||||
if err != nil {
|
||||
err = errors.New(Conf.Language(0))
|
||||
return
|
||||
}
|
||||
|
||||
// 在笔记本下搜索
|
||||
for _, notebook := range notebooks {
|
||||
notebookAbsPath := filepath.Join(util.DataDir, notebook.ID)
|
||||
filelock.Walk(notebookAbsPath, func(path string, d fs.DirEntry, err error) error {
|
||||
|
@ -356,16 +367,6 @@ func GetAssetAbsPath(relativePath string) (ret string, err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// 在全局 assets 路径下搜索
|
||||
p := filepath.Join(util.DataDir, relativePath)
|
||||
if gulu.File.IsExist(p) {
|
||||
ret = p
|
||||
if !util.IsSubPath(util.WorkspaceDir, ret) {
|
||||
err = fmt.Errorf("[%s] is not sub path of workspace", ret)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
return "", errors.New(fmt.Sprintf(Conf.Language(12), relativePath))
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package model
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha1"
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -1706,6 +1707,11 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||
}
|
||||
|
||||
// 导出引用的资源文件
|
||||
assetPathMap, err := allAssetAbsPaths()
|
||||
if nil != err {
|
||||
logging.LogWarnf("get assets abs path failed: %s", err)
|
||||
return
|
||||
}
|
||||
copiedAssets := hashset.New()
|
||||
for _, tree := range trees {
|
||||
var assets []string
|
||||
|
@ -1729,14 +1735,14 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||
continue
|
||||
}
|
||||
|
||||
srcPath, assetErr := GetAssetAbsPath(asset)
|
||||
if nil != assetErr {
|
||||
logging.LogWarnf("get asset [%s] abs path failed: %s", asset, assetErr)
|
||||
srcPath := assetPathMap[asset]
|
||||
if "" == srcPath {
|
||||
logging.LogWarnf("get asset [%s] abs path failed", asset)
|
||||
continue
|
||||
}
|
||||
|
||||
destPath := filepath.Join(exportFolder, asset)
|
||||
assetErr = filelock.Copy(srcPath, destPath)
|
||||
assetErr := filelock.Copy(srcPath, destPath)
|
||||
if nil != assetErr {
|
||||
logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", srcPath, destPath, assetErr)
|
||||
continue
|
||||
|
@ -1794,9 +1800,9 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||
}
|
||||
|
||||
destPath := filepath.Join(exportFolder, asset.Content)
|
||||
srcPath, assetErr := GetAssetAbsPath(asset.Content)
|
||||
if nil != assetErr {
|
||||
logging.LogWarnf("get asset [%s] abs path failed: %s", asset.Content, assetErr)
|
||||
srcPath := assetPathMap[asset.Content]
|
||||
if "" == srcPath {
|
||||
logging.LogWarnf("get asset [%s] abs path failed", asset.Content)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -3086,6 +3092,8 @@ func processFileAnnotationRef(refID string, n *ast.Node, fileAnnotationRefMode i
|
|||
|
||||
func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
||||
pandocFrom, pandocTo, ext string) (zipPath string) {
|
||||
defer util.ClearPushProgress(100)
|
||||
|
||||
dir, name := path.Split(baseFolderName)
|
||||
name = util.FilterFileName(name)
|
||||
if strings.HasSuffix(name, "..") {
|
||||
|
@ -3146,8 +3154,15 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
docPaths = gulu.Str.RemoveDuplicatedElem(docPaths)
|
||||
}
|
||||
|
||||
wrotePathHash := map[string]string{}
|
||||
assetsPathMap, err := allAssetAbsPaths()
|
||||
if nil != err {
|
||||
logging.LogWarnf("get assets abs path failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
for _, p := range docPaths {
|
||||
for i, p := range docPaths {
|
||||
id := util.GetTreeID(p)
|
||||
hPath, md := exportMarkdownContent(id, exportRefMode, defBlockIDs)
|
||||
dir, name = path.Split(hPath)
|
||||
|
@ -3156,7 +3171,8 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
hPath = path.Join(dir, name)
|
||||
p = hPath + ext
|
||||
writePath := filepath.Join(exportFolder, p)
|
||||
if gulu.File.IsExist(writePath) {
|
||||
hash := fmt.Sprintf("%x", sha1.Sum([]byte(md)))
|
||||
if gulu.File.IsExist(writePath) && hash != wrotePathHash[writePath] {
|
||||
// 重名文档加 ID
|
||||
p = hPath + "-" + id + ext
|
||||
writePath = filepath.Join(exportFolder, p)
|
||||
|
@ -3181,15 +3197,14 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
continue
|
||||
}
|
||||
|
||||
srcPath, err := GetAssetAbsPath(asset)
|
||||
if err != nil {
|
||||
logging.LogWarnf("get asset [%s] abs path failed: %s", asset, err)
|
||||
srcPath := assetsPathMap[asset]
|
||||
if "" == srcPath {
|
||||
logging.LogWarnf("get asset [%s] abs path failed", asset)
|
||||
continue
|
||||
}
|
||||
|
||||
destPath := filepath.Join(writeFolder, asset)
|
||||
err = filelock.Copy(srcPath, destPath)
|
||||
if err != nil {
|
||||
if copyErr := filelock.Copy(srcPath, destPath); copyErr != nil {
|
||||
logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", srcPath, destPath, err)
|
||||
continue
|
||||
}
|
||||
|
@ -3201,6 +3216,9 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
logging.LogErrorf("pandoc failed: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
wrotePathHash[writePath] = hash
|
||||
util.PushEndlessProgress(Conf.language(65) + " " + fmt.Sprintf(Conf.language(70), fmt.Sprintf("%d/%d %s", i+1, len(docPaths), name)))
|
||||
}
|
||||
|
||||
zipPath = exportFolder + ".zip"
|
||||
|
|
|
@ -592,7 +592,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTokens(n, method, keyword, replacement, r)
|
||||
replaceNodeTokens(n, method, keyword, strings.TrimSpace(replacement), r)
|
||||
case ast.NodeLinkText:
|
||||
if !replaceTypes["imgText"] {
|
||||
return ast.WalkContinue
|
||||
|
@ -673,11 +673,11 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
if replaceTypes["aHref"] {
|
||||
if 0 == method {
|
||||
if strings.Contains(n.TextMarkAHref, keyword) {
|
||||
n.TextMarkAHref = strings.ReplaceAll(n.TextMarkAHref, keyword, replacement)
|
||||
n.TextMarkAHref = strings.ReplaceAll(n.TextMarkAHref, keyword, strings.TrimSpace(replacement))
|
||||
}
|
||||
} else if 3 == method {
|
||||
if nil != r && r.MatchString(n.TextMarkAHref) {
|
||||
n.TextMarkAHref = r.ReplaceAllString(n.TextMarkAHref, replacement)
|
||||
n.TextMarkAHref = r.ReplaceAllString(n.TextMarkAHref, strings.TrimSpace(replacement))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue