Skip to content

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

:art: Add a new API `Move block` https://github.com/siyuan-note/siyuan/issues/7903

Liang Ding1a09c04b92cd
diff --git a/API.md b/API.md
index 741f9ef116..d812967e61 100644
--- a/API.md
+++ b/API.md
@@ -27,6 +27,7 @@
* [Append blocks](#Append-blocks)
* [Update a block](#Update-a-block)
* [Delete a block](#Delete-a-block)
+ * [Move a block](#Move-a-block)
* [Get a block kramdown](#Get-a-block-kramdown)
* [Attributes](#Attributes)
* [Set block attributes](#Set-block-attributes)
@@ -696,6 +697,50 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
}
```
+### Move a block
+
+* `/api/block/moveBlock`
+* Parameters
+
+ ```json
+ {
+ "id": "20230406180530-3o1rqkc",
+ "previousID": "20230406152734-if5kyx6",
+ "parentID": "20230404183855-woe52ko"
+ }
+ ```
+
+ * `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
+* Return value
+
+ ```json
+ {
+ "code": 0,
+ "msg": "",
+ "data": [
+ {
+ "doOperations": [
+ {
+ "action": "move",
+ "data": null,
+ "id": "20230406180530-3o1rqkc",
+ "parentID": "20230404183855-woe52ko",
+ "previousID": "20230406152734-if5kyx6",
+ "nextID": "",
+ "retData": null,
+ "srcIDs": null,
+ "name": "",
+ "type": ""
+ }
+ ],
+ "undoOperations": null
+ }
+ ]
+ }
+ ```
+
### Get a block kramdown
* `/api/block/getBlockKramdown`
diff --git a/API_zh_CN.md b/API_zh_CN.md
index d159064bed..340f155ad6 100644
--- a/API_zh_CN.md
+++ b/API_zh_CN.md
@@ -27,6 +27,7 @@
* [插入后置子块](#插入后置子块)
* [更新块](#更新块)
* [删除块](#删除块)
+ * [移动块](#移动块)
* [获取块 kramdown 源码](#获取块-kramdown-源码)
* [属性](#属性)
* [设置块属性](#设置块属性)
@@ -690,6 +691,50 @@
}
```
+### 移动块
+
+* `/api/block/moveBlock`
+* 参数
+
+ ```json
+ {
+ "id": "20230406180530-3o1rqkc",
+ "previousID": "20230406152734-if5kyx6",
+ "parentID": "20230404183855-woe52ko"
+ }
+ ```
+
+ * `id`:待移动块 ID
+ * `previousID`:前一个块的 ID,用于锚定插入位置
+ * `parentID`:父块的 ID,用于锚定插入位置,`previousID` 和 `parentID` 不能同时为空,同时存在的话优先使用 `previousID`
+* 返回值
+
+ ```json
+ {
+ "code": 0,
+ "msg": "",
+ "data": [
+ {
+ "doOperations": [
+ {
+ "action": "move",
+ "data": null,
+ "id": "20230406180530-3o1rqkc",
+ "parentID": "20230404183855-woe52ko",
+ "previousID": "20230406152734-if5kyx6",
+ "nextID": "",
+ "retData": null,
+ "srcIDs": null,
+ "name": "",
+ "type": ""
+ }
+ ],
+ "undoOperations": null
+ }
+ ]
+ }
+ ```
+
### 获取块 kramdown 源码
* `/api/block/getBlockKramdown`