From b062d3f45f7d9d5c1c54e8aa376b477a445de7c0 Mon Sep 17 00:00:00 2001
From: Daniel <845765@qq.com>
Date: Wed, 28 Aug 2024 17:39:53 +0800
Subject: [PATCH 1/5] :bug: https://github.com/siyuan-note/siyuan/issues/12346
---
app/src/protyle/render/highlightRender.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/src/protyle/render/highlightRender.ts b/app/src/protyle/render/highlightRender.ts
index b99211850..f13289815 100644
--- a/app/src/protyle/render/highlightRender.ts
+++ b/app/src/protyle/render/highlightRender.ts
@@ -135,7 +135,8 @@ export const lineNumberRender = (block: HTMLElement) => {
lineList.map((line) => {
let lineHeight = "";
if (isWrap) {
- lineNumberTemp.textContent = line || "
";
+ // windows 下空格高度为 0 https://github.com/siyuan-note/siyuan/issues/12346
+ lineNumberTemp.textContent = line.trim() || "
";
// 不能使用 lineNumberTemp.getBoundingClientRect().height.toFixed(1) 否则
// windows 需等待字体下载完成再计算,否则导致不换行,高度计算错误
// https://github.com/siyuan-note/siyuan/issues/9029
From 593e3141ab0428b19853f705a0d44725b592143e Mon Sep 17 00:00:00 2001
From: ytm157 <110707169+ytm157@users.noreply.github.com>
Date: Wed, 28 Aug 2024 17:45:09 +0800
Subject: [PATCH 2/5] :technologist: Add a kernel API
`/api/filetree/getPathByID`
* :technologist: Add a new api '/api/filetree/getPathByID'
* :technologist: Add a new api '/api/filetree/getPathByID'
---
API.md | 22 ++++++++++++++++++++++
API_zh_CN.md | 21 +++++++++++++++++++++
kernel/api/filetree.go | 23 +++++++++++++++++++++++
kernel/api/router.go | 1 +
kernel/model/file.go | 9 +++++++++
5 files changed, 76 insertions(+)
diff --git a/API.md b/API.md
index 3cb22c74b..44d1d0fcf 100644
--- a/API.md
+++ b/API.md
@@ -462,6 +462,28 @@ View API token in Settings - About, request header: `Authorization: T
"data": "/foo/bar"
}
```
+
+### Get storage path based on ID
+
+* `/api/filetree/getPathByID`
+* Parameters
+
+ ```json
+ {
+ "id": "20210917220056-yxtyl7i"
+ }
+ ```
+
+ * `id`: Block ID
+* Return value
+
+ ```json
+ {
+ "code": 0,
+ "msg": "",
+ "data": "/20210828150719-r8edxl2/20210917220056-yxtyl7i.sy"
+ }
+ ```
### Get IDs based on human-readable path
diff --git a/API_zh_CN.md b/API_zh_CN.md
index 86cdbf40a..74b74efd4 100644
--- a/API_zh_CN.md
+++ b/API_zh_CN.md
@@ -462,6 +462,27 @@
}
```
+### 根据 ID 获取存储路径
+* `/api/filetree/getPathByID`
+* 参数
+
+ ```json
+ {
+ "id": "20210917220056-yxtyl7i"
+ }
+ ```
+
+ * `id`:块 ID
+* 返回值
+
+ ```json
+ {
+ "code": 0,
+ "msg": "",
+ "data": "/20210828150719-r8edxl2/20210917220056-yxtyl7i.sy"
+ }
+ ```
+
### 根据人类可读路径获取 IDs
* `/api/filetree/getIDsByHPath`
diff --git a/kernel/api/filetree.go b/kernel/api/filetree.go
index 84e112f95..b00c78d14 100644
--- a/kernel/api/filetree.go
+++ b/kernel/api/filetree.go
@@ -364,6 +364,29 @@ func getHPathByID(c *gin.Context) {
ret.Data = hPath
}
+func getPathByID(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)
+ if util.InvalidIDPattern(id, ret) {
+ return
+ }
+
+ _path, err := model.GetPathByID(id)
+ if nil != err {
+ ret.Code = -1
+ ret.Msg = err.Error()
+ return
+ }
+ ret.Data = _path
+}
+
func getFullHPathByID(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
diff --git a/kernel/api/router.go b/kernel/api/router.go
index 9e786324c..ff825dacb 100644
--- a/kernel/api/router.go
+++ b/kernel/api/router.go
@@ -106,6 +106,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/filetree/getHPathByPath", model.CheckAuth, getHPathByPath)
ginServer.Handle("POST", "/api/filetree/getHPathsByPaths", model.CheckAuth, getHPathsByPaths)
ginServer.Handle("POST", "/api/filetree/getHPathByID", model.CheckAuth, getHPathByID)
+ ginServer.Handle("POST", "/api/filetree/getPathByID", model.CheckAuth, getPathByID)
ginServer.Handle("POST", "/api/filetree/getFullHPathByID", model.CheckAuth, getFullHPathByID)
ginServer.Handle("POST", "/api/filetree/getIDsByHPath", model.CheckAuth, getIDsByHPath)
ginServer.Handle("POST", "/api/filetree/doc2Heading", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, doc2Heading)
diff --git a/kernel/model/file.go b/kernel/model/file.go
index c728c1ff9..32bd23026 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1327,6 +1327,15 @@ func GetHPathByID(id string) (hPath string, err error) {
return
}
+func GetPathByID(id string) (hPath string, err error) {
+ tree, err := LoadTreeByBlockID(id)
+ if nil != err {
+ return
+ }
+ hPath = tree.Path
+ return
+}
+
func GetFullHPathByID(id string) (hPath string, err error) {
tree, err := LoadTreeByBlockID(id)
if nil != err {
From 6fb69303c89d2c2338b3a7292f4867b2f901d9da Mon Sep 17 00:00:00 2001
From: Daniel <845765@qq.com>
Date: Wed, 28 Aug 2024 17:47:50 +0800
Subject: [PATCH 3/5] :art: https://github.com/siyuan-note/siyuan/pull/12353
---
API_zh_CN.md | 1 +
kernel/model/file.go | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/API_zh_CN.md b/API_zh_CN.md
index 74b74efd4..d9cf5bc5f 100644
--- a/API_zh_CN.md
+++ b/API_zh_CN.md
@@ -463,6 +463,7 @@
```
### 根据 ID 获取存储路径
+
* `/api/filetree/getPathByID`
* 参数
diff --git a/kernel/model/file.go b/kernel/model/file.go
index 32bd23026..b74a2a0fe 100644
--- a/kernel/model/file.go
+++ b/kernel/model/file.go
@@ -1327,12 +1327,13 @@ func GetHPathByID(id string) (hPath string, err error) {
return
}
-func GetPathByID(id string) (hPath string, err error) {
+func GetPathByID(id string) (path string, err error) {
tree, err := LoadTreeByBlockID(id)
if nil != err {
return
}
- hPath = tree.Path
+
+ path = tree.Path
return
}
From 79b3e17fcf3f92ad20088704ee1916429b435e50 Mon Sep 17 00:00:00 2001
From: Daniel <845765@qq.com>
Date: Wed, 28 Aug 2024 17:56:30 +0800
Subject: [PATCH 4/5] :memo: Update the dev guide
---
API.md | 28 ++++++++++------------------
API_zh_CN.md | 1 +
2 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/API.md b/API.md
index 44d1d0fcf..cf75a9ad1 100644
--- a/API.md
+++ b/API.md
@@ -19,6 +19,8 @@
* [Move documents](#Move-documents)
* [Get human-readable path based on path](#Get-human-readable-path-based-on-path)
* [Get human-readable path based on ID](#Get-human-readable-path-based-on-ID)
+ * [Get storage path based on ID](#Get-storage-path-based-on-ID)
+ * [Get IDs based on human-readable path](#Get-IDs-based-on-human-readable-path)
* [Assets](#Assets)
* [Upload assets](#Upload-assets)
* [Blocks](#Blocks)
@@ -70,8 +72,7 @@
* Endpoint: `http://127.0.0.1:6806`
* Both are POST methods
-* An interface with parameters is required, the parameter is a JSON string, placed in the body, and the header
- Content-Type is `application/json`
+* An interface with parameters is required, the parameter is a JSON string, placed in the body, and the header Content-Type is `application/json`
* Return value
````json
@@ -326,8 +327,7 @@ View API token in Settings - About, request header: `Authorization: T
```
* `notebook`: Notebook ID
- * `path`: Document path, which needs to start with / and separate levels with / (path here corresponds to the
- database hpath field)
+ * `path`: Document path, which needs to start with / and separate levels with / (path here corresponds to the database hpath field)
* `markdown`: GFM Markdown content
* Return value
@@ -522,9 +522,7 @@ View API token in Settings - About, request header: `Authorization: T
* `"/assets/"`: workspace/data/assets/ folder
* `"/assets/sub/"`: workspace/data/assets/sub/ folder
- Under normal circumstances, it is recommended to use the first method, which is stored in the assets folder
- of the workspace, putting in a subdirectory has some side effects, please refer to the assets chapter of the user
- guide.
+ Under normal circumstances, it is recommended to use the first method, which is stored in the assets folder of the workspace, putting in a subdirectory has some side effects, please refer to the assets chapter of the user guide.
* `file[]`: Uploaded file list
* Return value
@@ -542,9 +540,7 @@ View API token in Settings - About, request header: `Authorization: T
```
* `errFiles`: List of filenames with errors in upload processing
- * `succMap`: For successfully processed files, the key is the file name when uploading, and the value is
- assets/foo-id.png, which is used to replace the asset link address in the existing Markdown content with the
- uploaded address
+ * `succMap`: For successfully processed files, the key is the file name when uploading, and the value is assets/foo-id.png, which is used to replace the asset link address in the existing Markdown content with the uploaded address
## Blocks
@@ -569,8 +565,7 @@ View API token in Settings - About, request header: `Authorization: T
* `previousID`: The ID of the previous block, used to anchor the insertion position
* `parentID`: The ID of the parent block, used to anchor the insertion position
- `nextID`, `previousID`, and `parentID` must have at least one value, using
- priority: `nextID` > `previousID` > `parentID`
+ `nextID`, `previousID`, and `parentID` must have at least one value, using priority: `nextID` > `previousID` > `parentID`
* Return value
```json
@@ -777,8 +772,7 @@ View API token in Settings - About, request header: `Authorization: T
* `id`: Block ID to move
* `previousID`: The ID of the previous block, used to anchor the insertion position
- * `parentID`: The ID of the parent block, used to anchor the insertion position, `previousID` and `parentID` cannot
- be empty at the same time, if they exist at the same time, `previousID` will be used first
+ * `parentID`: The ID of the parent block, used to anchor the insertion position, `previousID` and `parentID` cannot be empty at the same time, if they exist at the same time, `previousID` will be used first
* Return value
```json
@@ -1324,8 +1318,7 @@ View API token in Settings - About, request header: `Authorization: T
"timeout": 7000
}
```
- * `timeout`: The duration of the message display in milliseconds. This field can be omitted, the default is 7000
- milliseconds
+ * `timeout`: The duration of the message display in milliseconds. This field can be omitted, the default is 7000 milliseconds
* Return value
```json
@@ -1350,8 +1343,7 @@ View API token in Settings - About, request header: `Authorization: T
"timeout": 7000
}
```
- * `timeout`: The duration of the message display in milliseconds. This field can be omitted, the default is 7000
- milliseconds
+ * `timeout`: The duration of the message display in milliseconds. This field can be omitted, the default is 7000 milliseconds
* Return value
```json
diff --git a/API_zh_CN.md b/API_zh_CN.md
index d9cf5bc5f..b629c4a42 100644
--- a/API_zh_CN.md
+++ b/API_zh_CN.md
@@ -19,6 +19,7 @@
* [移动文档](#移动文档)
* [根据路径获取人类可读路径](#根据路径获取人类可读路径)
* [根据 ID 获取人类可读路径](#根据-ID-获取人类可读路径)
+ * [根据 ID 获取存储路径](#根据-ID-获取存储路径)
* [根据人类可读路径获取 IDs](#根据人类可读路径获取-IDs)
* [资源文件](#资源文件)
* [上传资源文件](#上传资源文件)
From 4ff10086edc5fef8262aef7e9832b92b24808d5d Mon Sep 17 00:00:00 2001
From: Daniel <845765@qq.com>
Date: Wed, 28 Aug 2024 18:17:46 +0800
Subject: [PATCH 5/5] :recycle: Upgrade to FSRS-5
https://github.com/siyuan-note/siyuan/issues/12344
---
kernel/conf/flashcard.go | 3 ++-
kernel/go.mod | 4 ++--
kernel/go.sum | 8 ++++----
kernel/model/block.go | 2 +-
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/kernel/conf/flashcard.go b/kernel/conf/flashcard.go
index d56bb42e2..c20f8d5e4 100644
--- a/kernel/conf/flashcard.go
+++ b/kernel/conf/flashcard.go
@@ -19,7 +19,8 @@ package conf
import (
"bytes"
"fmt"
- "github.com/open-spaced-repetition/go-fsrs"
+
+ "github.com/open-spaced-repetition/go-fsrs/v2"
)
type Flashcard struct {
diff --git a/kernel/go.mod b/kernel/go.mod
index 3cc876bc4..bfad9e3b0 100644
--- a/kernel/go.mod
+++ b/kernel/go.mod
@@ -46,7 +46,7 @@ require (
github.com/mitchellh/go-ps v1.0.0
github.com/mssola/useragent v1.0.0
github.com/olahol/melody v1.2.1
- github.com/open-spaced-repetition/go-fsrs v1.2.1
+ github.com/open-spaced-repetition/go-fsrs/v2 v2.0.1
github.com/panjf2000/ants/v2 v2.10.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/radovskyb/watcher v1.0.7
@@ -60,7 +60,7 @@ require (
github.com/siyuan-note/filelock v0.0.0-20240724034355-d1ed7bf21d04
github.com/siyuan-note/httpclient v0.0.0-20240828084311-6bd9eb73747f
github.com/siyuan-note/logging v0.0.0-20240505035402-6430d57006a2
- github.com/siyuan-note/riff v0.0.0-20240502024535-718add51db67
+ github.com/siyuan-note/riff v0.0.0-20240828101024-443a09504726
github.com/spf13/cast v1.7.0
github.com/steambap/captcha v1.4.1
github.com/studio-b12/gowebdav v0.9.0
diff --git a/kernel/go.sum b/kernel/go.sum
index b345bce01..b344968ac 100644
--- a/kernel/go.sum
+++ b/kernel/go.sum
@@ -276,8 +276,8 @@ github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo
github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
-github.com/open-spaced-repetition/go-fsrs v1.2.1 h1:vY1hSQ3gvHtfnw8ahylcZyyqusKWDkWCd1+ca4lZoSc=
-github.com/open-spaced-repetition/go-fsrs v1.2.1/go.mod h1:WpbNs4TTKZChOHFO+ME0B9femUVZsepFT5mhAioszRg=
+github.com/open-spaced-repetition/go-fsrs/v2 v2.0.1 h1:ODpQGZqZNsKqAF4/WUdRtfuNtwDIfI6Xj3cSznxk0g0=
+github.com/open-spaced-repetition/go-fsrs/v2 v2.0.1/go.mod h1:Ry+MLx079nUXwSbYm+OYLK9pQ9yu0cCLWSo3N4H5ZBI=
github.com/otiai10/gosseract/v2 v2.4.1 h1:G8AyBpXEeSlcq8TI85LH/pM5SXk8Djy2GEXisgyblRw=
github.com/otiai10/gosseract/v2 v2.4.1/go.mod h1:1gNWP4Hgr2o7yqWfs6r5bZxAatjOIdqWxJLWsTsembk=
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
@@ -356,8 +356,8 @@ github.com/siyuan-note/httpclient v0.0.0-20240828084311-6bd9eb73747f h1:C54AUt78
github.com/siyuan-note/httpclient v0.0.0-20240828084311-6bd9eb73747f/go.mod h1:AX5fjlyJlC9Bwi0ecMQ74IP7d8BXAeq6ruqte3sjB5Y=
github.com/siyuan-note/logging v0.0.0-20240505035402-6430d57006a2 h1:/2+tlOThVB86RxSLeW0JFw2ISUrH2ZFRg15ULGAUGAE=
github.com/siyuan-note/logging v0.0.0-20240505035402-6430d57006a2/go.mod h1:3Osd2/nwzXZFl6ZcDE4hA0HD83Wyv1fds47nVuapyOM=
-github.com/siyuan-note/riff v0.0.0-20240502024535-718add51db67 h1:YuBxDIIVBOtvQc/ZLi4SOCY0J+QMRnnco4b1Jh9+SL4=
-github.com/siyuan-note/riff v0.0.0-20240502024535-718add51db67/go.mod h1:n+yT/5zCIDqRx5lEO8Vxq3kuwzjmXndXFtfJoID7jJY=
+github.com/siyuan-note/riff v0.0.0-20240828101024-443a09504726 h1:bLBpaidGUXZS18eKnpUd5WdrGRz0mymZDLMKtWJe/B8=
+github.com/siyuan-note/riff v0.0.0-20240828101024-443a09504726/go.mod h1:IThyetU+bmHp9dd9prUlwVyAwx/dBxRdUUysZQ+TYsw=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
diff --git a/kernel/model/block.go b/kernel/model/block.go
index 7fec9f204..3b4787ba4 100644
--- a/kernel/model/block.go
+++ b/kernel/model/block.go
@@ -25,7 +25,7 @@ import (
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
- "github.com/open-spaced-repetition/go-fsrs"
+ "github.com/open-spaced-repetition/go-fsrs/v2"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode"