Skip to content

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

♻️ Migrate clipboard API contracts https://github.com/siyuan-note/siyuan/issues/19378

Danield943b7c0b931
diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts
index 70c1f84873..3596cbb08a 100644
--- a/app/src/protyle/util/compatibility.ts
+++ b/app/src/protyle/util/compatibility.ts
@@ -233,7 +233,7 @@ export const getLocalFiles = async () => {
}
} else {
const xmlString = await fetchSyncPost("/api/clipboard/readFilePaths", {});
- if (xmlString.data.length > 0) {
+ if (xmlString.code === 0 && Array.isArray(xmlString.data) && xmlString.data.length > 0) {
localFiles = xmlString.data;
}
}
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index fe8e5ec3f2..ec72a43357 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -106,6 +106,12 @@ export type CheckSnapshotData = { "changed": boolean; };
export type ChildBlock = { "content"?: string; "id": string; "markdown"?: string; "subType"?: string; "type": string; };
+export type CleanupRichTextRequestInput = { "batch": string; "groups": Array<string>; };
+
+export type ClipboardFile = { "isDir": boolean; "name": string; "path": string; "size": number; "updated": number; };
+
+export type ClipboardPathRequestInput = { "path": string; };
+
export type CloseNotebookRequestInput = { "notebook": string; };
export type CloudBackup = { "hSize": string; "saveDir": string; "size": number; "updated": string; };
@@ -308,6 +314,8 @@ export type Petal = { "css": string; "disabledInPublish": boolean; "disallowInst
export type PinnedDoc = { "childrenSortMode": number | null; "icon": string; "id": string; "name": string; "notebook": string; "path": string; "subFileCount": number; "unavailable": boolean; };
+export type PrepareRichTextRequestInput = { "assets": Array<RichClipboardAssetInput>; };
+
export type PrependBlockRequestInput = { "data": string; "dataType": string; "parentID": string; };
export type PublishedBlockInfo = { "publishAccessRequired": true; "rootID": string; "rootIcon": string; "rootTitle": string; "rootTitleEmpty": boolean; };
@@ -348,6 +356,12 @@ export type ReorderData = { "changed": boolean; "notebook"?: string; "parentPath
export type ReorderNotebooksRequestInput = { "position"?: string | null; "sourceIDs"?: Array<string> | null; "targetID"?: string | null; };
+export type RichClipboardAssetInput = { "box"?: string; "index": number; "path": string; };
+
+export type RichClipboardPrepared = { "assets": Array<RichClipboardPreparedAsset> | null; "batch": string; "groups": Array<string> | null; };
+
+export type RichClipboardPreparedAsset = { "index": number; "path": string; };
+
export type SearchBlock = { "alias": string; "box": string; "children": Array<SearchBlock | null> | null; "content": string; "count": number; "created": string; "defID": string; "defPath": string; "depth": number; "fcontent": string; "folded": boolean; "hPath": string; "ial": Record<string, string> | null; "id": string; "markdown": string; "memo": string; "name": string; "number"?: string; "parentID": string; "path": string; "refCount": number; "refText": string; "refs": Array<SearchBlock | null> | null; "riffCard": SearchBlockCard | null; "riffCardID": string; "rootID": string; "sort": number; "subType": string; "tag": string; "type": string; "updated": string; };
export type SearchBlockCard = { "due": string; "lapses": number; "lastReview": string; "reps": number; "state": number; };
@@ -630,10 +644,6 @@ export type APILegacyPOSTPath =
"/api/bazaar/uninstallBazaarTheme" |
"/api/bazaar/uninstallBazaarWidget" |
"/api/bazaar/updateBazaarPackage" |
- "/api/clipboard/cleanupRichText" |
- "/api/clipboard/prepareRichText" |
- "/api/clipboard/readFilePaths" |
- "/api/clipboard/writeFilePath" |
"/api/export/copyExportFile" |
"/api/export/export2Liandi" |
"/api/export/exportAsFile" |
@@ -1303,6 +1313,26 @@ export interface APIPOSTRoutes {
response: { "code": 0; "data": BroadcastPublishData; "msg": string; } | { "code": -1 | 1; "data": { "closeTimeout": number; } | null; "msg": string; };
body: "multipart";
};
+ "/api/clipboard/cleanupRichText": {
+ request: CleanupRichTextRequestInput;
+ response: { "code": 0; "data": null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
+ "/api/clipboard/prepareRichText": {
+ request: PrepareRichTextRequestInput;
+ response: { "code": 0; "data": RichClipboardPrepared | null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
+ "/api/clipboard/readFilePaths": {
+ request: EmptyRequestInput;
+ response: { "code": 0; "data": Array<ClipboardFile>; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "none";
+ };
+ "/api/clipboard/writeFilePath": {
+ request: ClipboardPathRequestInput;
+ response: { "code": 0; "data": null; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
"/api/cloud/getCloudSpace": {
request: EmptyRequestInput;
response: { "code": 0; "data": CloudSpaceData; "msg": string; } | { "code": -1 | 1; "data": { "closeTimeout": number; } | null; "msg": string; };
diff --git a/kernel/api/clipboard.go b/kernel/api/clipboard.go
index e15409a75e..a2828b4490 100644
--- a/kernel/api/clipboard.go
+++ b/kernel/api/clipboard.go
@@ -17,29 +17,25 @@
package api
import (
- "fmt"
- "net/http"
"os"
- "strings"
"github.com/88250/clipboard"
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/logging"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
-func readFilePaths(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
+var readFilePaths = contractHandler(apicontract.ReadClipboardFilePaths, func(c *gin.Context, request apicontract.EmptyRequest) apicontract.Response[[]apicontract.ClipboardFile] {
var paths []string
if !gulu.OS.IsLinux() { // Linux 端不再支持 `粘贴为纯文本` 时处理文件绝对路径 https://github.com/siyuan-note/siyuan/issues/5825
paths, _ = clipboard.ReadFilePaths()
}
- data := []map[string]any{}
+ data := []apicontract.ClipboardFile{}
for _, path := range paths {
fi, err := os.Stat(path)
if nil != err {
@@ -47,143 +43,56 @@ func readFilePaths(c *gin.Context) {
continue
}
- data = append(data, map[string]any{
- "name": fi.Name(),
- "size": fi.Size(),
- "isDir": fi.IsDir(),
- "updated": fi.ModTime().UnixMilli(),
- "path": path,
- })
- }
- ret.Data = data
-}
-
-func writeFilePath(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
-
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
- }
-
- var pathArg string
- if !util.ParseJsonArgs(arg, ret, util.BindJsonArg("path", &pathArg, true, true)) {
- return
+ data = append(data, apicontract.ClipboardFile{Name: fi.Name(), Size: fi.Size(), IsDir: fi.IsDir(), Updated: fi.ModTime().UnixMilli(), Path: path})
}
+ return apicontract.Success(data)
+})
+var writeFilePath = contractHandler(apicontract.WriteClipboardFilePath, func(c *gin.Context, request apicontract.ClipboardPathRequest) apicontract.Response[apicontract.Null] {
+ pathArg := request.Path
absPath, err := model.GetAssetAbsPathInBox(pathArg, "")
if err != nil {
logging.LogErrorf("get asset [%s] abs path failed: %s", pathArg, err)
- ret.Code = -1
- ret.Msg = err.Error()
- ret.Data = map[string]any{"closeTimeout": 5000}
- return
+ return apicontract.FailureWithTimeout[apicontract.Null](-1, err.Error(), 5000)
}
if model.IsEncryptedAssetPath(absPath) {
- ret.Code = -1
- ret.Msg = model.Conf.Language(314)
- ret.Data = map[string]any{"closeTimeout": 5000}
- return
+ return apicontract.FailureWithTimeout[apicontract.Null](-1, model.Conf.Language(314), 5000)
}
if err = model.EnsureAssetPrefixLocal(absPath); err != nil {
- ret.Code = -1
- ret.Msg = err.Error()
- ret.Data = map[string]any{"closeTimeout": 7000}
- return
+ return apicontract.FailureWithTimeout[apicontract.Null](-1, err.Error(), 7000)
}
if err = util.WriteFilePaths([]string{absPath}); err != nil {
logging.LogErrorf("write file path to clipboard failed: %s", err)
- ret.Code = -1
- ret.Msg = err.Error()
- ret.Data = map[string]any{"closeTimeout": 5000}
- return
+ return apicontract.FailureWithTimeout[apicontract.Null](-1, err.Error(), 5000)
}
-}
+ return apicontract.Success(apicontract.Null{})
+})
-func prepareRichText(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
-
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
- }
- assetsArg, ok := util.ParseJsonArg[[]any]("assets", arg, ret, true, true)
- if !ok {
- return
+var prepareRichText = contractHandler(apicontract.PrepareRichText, func(c *gin.Context, request apicontract.PrepareRichTextRequest) apicontract.Response[*apicontract.RichClipboardPrepared] {
+ assets := make([]model.RichClipboardAsset, 0, len(request.Assets))
+ for _, asset := range request.Assets {
+ assets = append(assets, model.RichClipboardAsset{Index: asset.Index, Path: asset.Path, Box: asset.Box})
}
-
- assets := make([]model.RichClipboardAsset, 0, len(assetsArg))
- for i, rawAsset := range assetsArg {
- assetArg, typeOK := rawAsset.(map[string]any)
- if !typeOK {
- ret.Code = -1
- ret.Msg = fmt.Sprintf("Field [assets.%d] should be of type [Object]", i)
- return
- }
-
- index, indexOK := assetArg["index"].(float64)
- path, pathOK := assetArg["path"].(string)
- if !indexOK || index < 0 || index != float64(int(index)) || !pathOK || strings.TrimSpace(path) == "" {
- ret.Code = -1
- ret.Msg = fmt.Sprintf("Invalid rich clipboard asset at index [%d]", i)
- return
- }
-
- box := ""
- if boxArg, exists := assetArg["box"]; exists {
- box, typeOK = boxArg.(string)
- if !typeOK {
- ret.Code = -1
- ret.Msg = fmt.Sprintf("Field [assets.%d.box] should be of type [String]", i)
- return
- }
- }
- assets = append(assets, model.RichClipboardAsset{
- Index: int(index),
- Path: strings.TrimSpace(path),
- Box: strings.TrimSpace(box),
- })
- }
-
prepared, err := model.PrepareRichClipboardAssets(assets)
if err != nil {
logging.LogWarnf("prepare rich clipboard assets failed: %s", err)
- ret.Code = -1
- ret.Msg = err.Error()
- return
+ return apicontract.Failure[*apicontract.RichClipboardPrepared](-1, err.Error())
}
- ret.Data = prepared
-}
-
-func cleanupRichText(c *gin.Context) {
- ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
-
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
+ if prepared == nil {
+ return apicontract.Success[*apicontract.RichClipboardPrepared](nil)
}
- batch, ok := util.ParseJsonArg[string]("batch", arg, ret, true, true)
- if !ok {
- return
+ result := &apicontract.RichClipboardPrepared{Batch: prepared.Batch, Groups: prepared.Groups}
+ if prepared.Assets != nil {
+ result.Assets = make([]apicontract.RichClipboardPreparedAsset, 0, len(prepared.Assets))
}
- groupsArg, ok := util.ParseJsonArg[[]any]("groups", arg, ret, true, true)
- if !ok {
- return
+ for _, asset := range prepared.Assets {
+ result.Assets = append(result.Assets, apicontract.RichClipboardPreparedAsset{Index: asset.Index, Path: asset.Path})
}
+ return apicontract.Success(result)
+})
- groups := make([]string, 0, len(groupsArg))
- for i, rawGroup := range groupsArg {
- group, typeOK := rawGroup.(string)
- if !typeOK {
- ret.Code = -1
- ret.Msg = fmt.Sprintf("Field [groups.%d] should be of type [String]", i)
- return
- }
- groups = append(groups, group)
- }
- model.CleanupRichClipboardBatch(batch, groups)
-}
+var cleanupRichText = contractHandler(apicontract.CleanupRichText, func(c *gin.Context, request apicontract.CleanupRichTextRequest) apicontract.Response[apicontract.Null] {
+ model.CleanupRichClipboardBatch(request.Batch, request.Groups)
+ return apicontract.Success(apicontract.Null{})
+})
diff --git a/kernel/api/contract_clipboard_test.go b/kernel/api/contract_clipboard_test.go
new file mode 100644
index 0000000000..cc3212f95c
--- /dev/null
+++ b/kernel/api/contract_clipboard_test.go
@@ -0,0 +1,41 @@
+package api
+
+import (
+ "encoding/json"
+ "github.com/gin-gonic/gin"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
+ "net/http/httptest"
+ "strings"
+ "testing"
+)
+
+func TestAPIContractRichClipboardValidation(t *testing.T) {
+ engine := gin.New()
+ engine.POST("/api/clipboard/prepareRichText", prepareRichText)
+ engine.POST("/api/clipboard/cleanupRichText", cleanupRichText)
+ for _, entry := range []struct{ handler, body, message string }{
+ {"prepareRichText", `{"assets":[]}`, "Field [assets] must not be empty"},
+ {"prepareRichText", `{"assets":[null]}`, "Field [assets.0] should be of type [Object]"},
+ {"prepareRichText", `{"assets":[{"index":0.5,"path":"file.png"}]}`, "Invalid rich clipboard asset at index [0]"},
+ {"prepareRichText", `{"assets":[{"index":0,"path":"file.png","box":null}]}`, "Field [assets.0.box] should be of type [String]"},
+ {"cleanupRichText", `{"batch":" ","groups":["g"]}`, "Field [batch] must not be empty"},
+ {"cleanupRichText", `{"batch":"b","groups":[]}`, "Field [groups] must not be empty"},
+ {"cleanupRichText", `{"batch":"b","groups":[null]}`, "Field [groups.0] should be of type [String]"},
+ } {
+ recorder := httptest.NewRecorder()
+ path := "/api/clipboard/" + entry.handler
+ engine.ServeHTTP(recorder, httptest.NewRequest("POST", path, strings.NewReader(entry.body)))
+ requireAPIContract(t, "POST", path, recorder)
+ var response struct {
+ Code int `json:"code"`
+ Msg string `json:"msg"`
+ }
+ if err := json.Unmarshal(recorder.Body.Bytes(), &response); err != nil || response.Code != -1 || response.Msg != entry.message {
+ t.Fatalf("validation changed: %s, %v", recorder.Body.String(), err)
+ }
+ }
+ request, err := apicontract.PrepareRichText.Decode(strings.NewReader(`{"assets":[{"index":1.0,"path":" file.png ","box":" box "}]}`))
+ if err != nil || len(request.Assets) != 1 || request.Assets[0].Path != "file.png" || request.Assets[0].Box != "box" {
+ t.Fatalf("asset normalization changed: %#v, %v", request, err)
+ }
+}
diff --git a/kernel/apicontract/clipboard.go b/kernel/apicontract/clipboard.go
new file mode 100644
index 0000000000..56afc1b8fb
--- /dev/null
+++ b/kernel/apicontract/clipboard.go
@@ -0,0 +1,39 @@
+package apicontract
+
+type ClipboardFile struct {
+ Name string `json:"name"`
+ Size int64 `json:"size"`
+ IsDir bool `json:"isDir"`
+ Updated int64 `json:"updated"`
+ Path string `json:"path"`
+}
+
+type ClipboardPathRequest struct {
+ Path string `json:"path" api:"trim"`
+}
+
+type RichClipboardAsset struct {
+ Index int `json:"index"`
+ Path string `json:"path" api:"trim"`
+ Box string `json:"box" api:"optional,trim"`
+}
+
+type PrepareRichTextRequest struct {
+ Assets []RichClipboardAsset `json:"assets"`
+}
+
+type CleanupRichTextRequest struct {
+ Batch string `json:"batch" api:"trim"`
+ Groups []string `json:"groups"`
+}
+
+type RichClipboardPreparedAsset struct {
+ Index int `json:"index"`
+ Path string `json:"path"`
+}
+
+type RichClipboardPrepared struct {
+ Batch string `json:"batch"`
+ Groups []string `json:"groups"`
+ Assets []RichClipboardPreparedAsset `json:"assets"`
+}
diff --git a/kernel/apicontract/clipboard_input.go b/kernel/apicontract/clipboard_input.go
new file mode 100644
index 0000000000..d2ab1d8342
--- /dev/null
+++ b/kernel/apicontract/clipboard_input.go
@@ -0,0 +1,74 @@
+package apicontract
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "strings"
+)
+
+func init() {
+ PrepareRichText.decodeRequest = func(reader io.Reader) (request PrepareRichTextRequest, err error) {
+ fields, err := blockRequestFields(reader, "/api/clipboard/prepareRichText")
+ if err != nil {
+ return request, err
+ }
+ assets, err := legacyField[[]json.RawMessage](fields, "assets", "Array", true)
+ if err != nil {
+ return request, err
+ }
+ if len(assets) == 0 {
+ return request, fmt.Errorf("Field [assets] must not be empty")
+ }
+ request.Assets = make([]RichClipboardAsset, 0, len(assets))
+ for i, raw := range assets {
+ var asset map[string]json.RawMessage
+ if json.Unmarshal(raw, &asset) != nil || asset == nil {
+ return request, fmt.Errorf("Field [assets.%d] should be of type [Object]", i)
+ }
+ var index float64
+ var path, box string
+ if bytes.Equal(asset["index"], []byte("null")) || json.Unmarshal(asset["index"], &index) != nil || index < 0 || index != float64(int(index)) || json.Unmarshal(asset["path"], &path) != nil || strings.TrimSpace(path) == "" {
+ return request, fmt.Errorf("Invalid rich clipboard asset at index [%d]", i)
+ }
+ if value, exists := asset["box"]; exists {
+ if bytes.Equal(value, []byte("null")) || json.Unmarshal(value, &box) != nil {
+ return request, fmt.Errorf("Field [assets.%d.box] should be of type [String]", i)
+ }
+ }
+ request.Assets = append(request.Assets, RichClipboardAsset{Index: int(index), Path: strings.TrimSpace(path), Box: strings.TrimSpace(box)})
+ }
+ return
+ }
+ CleanupRichText.decodeRequest = func(reader io.Reader) (request CleanupRichTextRequest, err error) {
+ fields, err := blockRequestFields(reader, "/api/clipboard/cleanupRichText")
+ if err != nil {
+ return request, err
+ }
+ request.Batch, err = legacyField[string](fields, "batch", "String", true)
+ if err != nil {
+ return request, err
+ }
+ request.Batch = strings.TrimSpace(request.Batch)
+ if request.Batch == "" {
+ return request, fmt.Errorf("Field [batch] must not be empty")
+ }
+ groups, err := legacyField[[]json.RawMessage](fields, "groups", "Array", true)
+ if err != nil {
+ return request, err
+ }
+ request.Groups = make([]string, 0, len(groups))
+ if len(groups) == 0 {
+ return request, fmt.Errorf("Field [groups] must not be empty")
+ }
+ for i, raw := range groups {
+ var group string
+ if bytes.Equal(raw, []byte("null")) || json.Unmarshal(raw, &group) != nil {
+ return request, fmt.Errorf("Field [groups.%d] should be of type [String]", i)
+ }
+ request.Groups = append(request.Groups, group)
+ }
+ return
+ }
+}
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index 7ac0e4eeaf..ae2a400791 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -442,3 +442,8 @@ var GetCloudSpace = define[EmptyRequest, CloudSpaceData]("getCloudSpace", "/api/
var RemoveShorthands = define[RemoveShorthandsRequest, Null]("removeShorthands", "/api/inbox/removeShorthands", JSONBody, ResponseOptions{AdditionalCodes: []int{1}}, "POST")
var GetShorthand = define[TrimmedIDRequest, *Shorthand]("getShorthand", "/api/inbox/getShorthand", JSONBody, ResponseOptions{AdditionalCodes: []int{1}}, "POST")
var GetShorthands = define[ShorthandsRequest, *ShorthandsData]("getShorthands", "/api/inbox/getShorthands", JSONBody, ResponseOptions{AdditionalCodes: []int{1}}, "POST")
+
+var ReadClipboardFilePaths = define[EmptyRequest, []ClipboardFile]("readFilePaths", "/api/clipboard/readFilePaths", NoBody, ResponseOptions{NonNullable: true}, "POST")
+var WriteClipboardFilePath = define[ClipboardPathRequest, Null]("writeFilePath", "/api/clipboard/writeFilePath", JSONBody, ResponseOptions{}, "POST")
+var PrepareRichText = define[PrepareRichTextRequest, *RichClipboardPrepared]("prepareRichText", "/api/clipboard/prepareRichText", JSONBody, ResponseOptions{}, "POST")
+var CleanupRichText = define[CleanupRichTextRequest, Null]("cleanupRichText", "/api/clipboard/cleanupRichText", JSONBody, ResponseOptions{}, "POST")
diff --git a/kernel/apicontract/legacy_routes.json b/kernel/apicontract/legacy_routes.json
index 359eafbda1..b2fa78556e 100644
--- a/kernel/apicontract/legacy_routes.json
+++ b/kernel/apicontract/legacy_routes.json
@@ -155,10 +155,6 @@
{"method":"POST","path":"/api/bazaar/uninstallBazaarTheme","handler":"uninstallBazaarTheme"},
{"method":"POST","path":"/api/bazaar/uninstallBazaarWidget","handler":"uninstallBazaarWidget"},
{"method":"POST","path":"/api/bazaar/updateBazaarPackage","handler":"updateBazaarPackage"},
- {"method":"POST","path":"/api/clipboard/cleanupRichText","handler":"cleanupRichText"},
- {"method":"POST","path":"/api/clipboard/prepareRichText","handler":"prepareRichText"},
- {"method":"POST","path":"/api/clipboard/readFilePaths","handler":"readFilePaths"},
- {"method":"POST","path":"/api/clipboard/writeFilePath","handler":"writeFilePath"},
{"method":"POST","path":"/api/export/copyExportFile","handler":"copyExportFile"},
{"method":"POST","path":"/api/export/export2Liandi","handler":"export2Liandi"},
{"method":"POST","path":"/api/export/exportAsFile","handler":"exportAsFile"},
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index 6d4a8e4ab5..10f716a0e7 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -1569,6 +1569,65 @@
],
"additionalProperties": false
},
+ "CleanupRichTextRequestInput": {
+ "type": "object",
+ "properties": {
+ "batch": {
+ "type": "string"
+ },
+ "groups": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ },
+ "required": [
+ "batch",
+ "groups"
+ ],
+ "additionalProperties": false
+ },
+ "ClipboardFile": {
+ "type": "object",
+ "properties": {
+ "isDir": {
+ "type": "boolean"
+ },
+ "name": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "size": {
+ "type": "integer"
+ },
+ "updated": {
+ "type": "integer"
+ }
+ },
+ "required": [
+ "isDir",
+ "name",
+ "path",
+ "size",
+ "updated"
+ ],
+ "additionalProperties": false
+ },
+ "ClipboardPathRequestInput": {
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "path"
+ ],
+ "additionalProperties": false
+ },
"CloseNotebookRequestInput": {
"type": "object",
"properties": {
@@ -5445,6 +5504,21 @@
],
"additionalProperties": false
},
+ "PrepareRichTextRequestInput": {
+ "type": "object",
+ "properties": {
+ "assets": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/RichClipboardAssetInput"
+ }
+ }
+ },
+ "required": [
+ "assets"
+ ],
+ "additionalProperties": false
+ },
"PrependBlockRequestInput": {
"type": "object",
"properties": {
@@ -5875,6 +5949,81 @@
},
"additionalProperties": false
},
+ "RichClipboardAssetInput": {
+ "type": "object",
+ "properties": {
+ "box": {
+ "type": "string"
+ },
+ "index": {
+ "type": "integer"
+ },
+ "path": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "index",
+ "path"
+ ],
+ "additionalProperties": false
+ },
+ "RichClipboardPrepared": {
+ "type": "object",
+ "properties": {
+ "assets": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/RichClipboardPreparedAsset"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "batch": {
+ "type": "string"
+ },
+ "groups": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "required": [
+ "assets",
+ "batch",
+ "groups"
+ ],
+ "additionalProperties": false
+ },
+ "RichClipboardPreparedAsset": {
+ "type": "object",
+ "properties": {
+ "index": {
+ "type": "integer"
+ },
+ "path": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "index",
+ "path"
+ ],
+ "additionalProperties": false
+ },
"SearchBlock": {
"type": "object",
"properties": {
@@ -14119,6 +14268,316 @@
]
}
},
+ {
+ "method": "POST",
+ "path": "/api/clipboard/cleanupRichText",
+ "handler": "cleanupRichText",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/CleanupRichTextRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "type": "null"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/clipboard/prepareRichText",
+ "handler": "prepareRichText",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/PrepareRichTextRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/RichClipboardPrepared"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/clipboard/readFilePaths",
+ "handler": "readFilePaths",
+ "body": "none",
+ "request": {
+ "$ref": "#/$defs/EmptyRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "type": "array",
+ "items": {
+ "$ref": "#/$defs/ClipboardFile"
+ }
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/clipboard/writeFilePath",
+ "handler": "writeFilePath",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/ClipboardPathRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "type": "null"
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
{
"method": "POST",
"path": "/api/cloud/getCloudSpace",