/api/block
appendBlock
- 🔥 在下级块尾部插入块
/api/block/appendBlock
请求
ts
/**
* Append blocks
*/
export interface IPayload {
/**
* block data content
*/
readonly data: string;
/**
* block data format
*/
readonly dataType: TDataType;
/**
* block ID: insert into this block tail
* The ID of the parent block, used to anchor the insertion position
*/
readonly parentID: string;
}
/**
* block data format
*/
export type TDataType = "dom" | "markdown";
json5
/**
* schemas/kernel/api/block/appendBlock/payload.schema.json5
* 在块内的尾部插入块 (插入后置子块)
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#append-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block_op.go#L87-L124
* @pathname: /api/block/appendBlock
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/appendBlock/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Append blocks',
type: 'object',
additionalProperties: false,
required: [
'dataType',
'data',
'parentID',
],
properties: {
dataType: {
// 块数据格式
title: 'TDataType',
type: 'string',
description: 'block data format',
enum: [
'markdown', // kramdown 文本
'dom', // HTML DOM 文本
],
},
data: {
// 块数据内容
type: 'string',
description: 'block data content',
},
parentID: {
/**
* 上级块的块 ID (插入到该块内尾部)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert into this block tail\nThe ID of the parent block, used to anchor the insertion position',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/appendBlock/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Append blocks",
"type": "object",
"additionalProperties": false,
"required": [
"dataType",
"data",
"parentID"
],
"properties": {
"dataType": {
"title": "TDataType",
"type": "string",
"description": "block data format",
"enum": [
"markdown",
"dom"
]
},
"data": {
"type": "string",
"description": "block data content"
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block tail\nThe ID of the parent block, used to anchor the insertion position",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Append blocks
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: ITransaction[];
/**
* status message
*/
readonly msg: string;
}
/**
* Insert transactions
*
* Insert transaction
*/
export interface ITransaction {
readonly doOperations: IOperation[];
/**
* timestamp
*/
readonly timestamp: number;
/**
* undo operation list
*/
readonly undoOperations: null;
}
/**
* insert operation list
*
* insert operation
*/
export interface IOperation {
/**
* operation action type
*/
readonly action: "insert";
/**
* HTML DOM of inserting blocks
*/
readonly data: string;
/**
* block ID: the first inserting block
*/
readonly id: string;
/**
* block ID: insert into this block
*/
readonly parentID: string;
[property: string]: any;
}
json5
/**
* schemas/kernel/api/block/appendBlock/response.schema.json5
* 在块内的尾部插入块 (插入后置子块)
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#append-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.6/kernel/api/block_op.go#L87-L124
* @pathname: /api/block/appendBlock
* @version: 2.10.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/appendBlock/response.schema.json5',
$comment: 'v2.10.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Append blocks',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Insert transactions',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/transaction',
},
},
transaction: {
title: 'ITransaction',
description: 'Insert transaction',
type: 'object',
additionalProperties: false,
required: [
'timestamp',
'doOperations',
'undoOperations',
],
properties: {
timestamp: {
type: 'integer',
description: 'timestamp',
},
doOperations: {
$ref: '#/$defs/operations',
},
undoOperations: {
type: 'null',
description: 'undo operation list',
},
},
},
operations: {
title: 'IOperations',
description: 'insert operation list',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/operation',
},
},
operation: {
title: 'IOperation',
description: 'insert operation',
type: 'object',
additionalProperties: true,
required: [
'action',
'data',
'id',
'parentID',
],
properties: {
action: {
// 操作活动类型: 插入
type: 'string',
const: 'insert',
description: 'operation action type',
},
data: {
// 所插入内容的 HTML DOM 文本
type: 'string',
description: 'HTML DOM of inserting blocks',
},
id: {
// 插入块的块 ID (若插入了多个块, 则为第一个块的块 ID)
type: 'string',
description: 'block ID: the first inserting block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
parentID: {
// 上级块的块 ID
type: 'string',
description: 'block ID: insert into this block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/appendBlock/response.schema.json",
"$comment": "v2.10.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Append blocks",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Insert transactions",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/transaction"
}
},
"transaction": {
"title": "ITransaction",
"description": "Insert transaction",
"type": "object",
"additionalProperties": false,
"required": [
"timestamp",
"doOperations",
"undoOperations"
],
"properties": {
"timestamp": {
"type": "integer",
"description": "timestamp"
},
"doOperations": {
"$ref": "#/$defs/operations"
},
"undoOperations": {
"type": "null",
"description": "undo operation list"
}
}
},
"operations": {
"title": "IOperations",
"description": "insert operation list",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/operation"
}
},
"operation": {
"title": "IOperation",
"description": "insert operation",
"type": "object",
"additionalProperties": true,
"required": [
"action",
"data",
"id",
"parentID"
],
"properties": {
"action": {
"type": "string",
"const": "insert",
"description": "operation action type"
},
"data": {
"type": "string",
"description": "HTML DOM of inserting blocks"
},
"id": {
"type": "string",
"description": "block ID: the first inserting block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
deleteBlock
- 🔥 删除块
/api/block/deleteBlock
请求
ts
/**
* Delete a block
*/
export interface IPayload {
/**
* ID of the block to be deleted
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/deleteBlock/payload.schema.json5
* 删除块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#delete-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block_op.go#L307-L336
* @pathname: /api/block/deleteBlock
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/deleteBlock/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Delete a block',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 待删除的块 ID
type: 'string',
description: 'ID of the block to be deleted',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/deleteBlock/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Delete a block",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "ID of the block to be deleted",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Delete a block
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: ITransaction[];
/**
* status message
*/
readonly msg: string;
}
/**
* Delete transactions
*
* Delete transaction
*/
export interface ITransaction {
readonly doOperations: IOperation[];
/**
* timestamp
*/
readonly timestamp: number;
/**
* undo operation list
*/
readonly undoOperations: null;
}
/**
* Delete operation list
*
* Delete operation
*/
export interface IOperation {
/**
* operation action type
*/
readonly action: "delete";
/**
* HTML DOM of updating blocks
*/
readonly data: null;
/**
* ID of the block to be deleted
*/
readonly id: string;
readonly parentID: any;
[property: string]: any;
}
json5
/**
* schemas/kernel/api/block/deleteBlock/response.schema.json5
* 删除块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#delete-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.6/kernel/api/block_op.go#L307-L336
* @pathname: /api/block/deleteBlock
* @version: 2.10.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/deleteBlock/response.schema.json5',
$comment: 'v2.10.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Delete a block',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Delete transactions',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/transaction',
},
},
transaction: {
title: 'ITransaction',
description: 'Delete transaction',
type: 'object',
additionalProperties: false,
required: [
'timestamp',
'doOperations',
'undoOperations',
],
properties: {
timestamp: {
type: 'integer',
description: 'timestamp',
},
doOperations: {
$ref: '#/$defs/operations',
},
undoOperations: {
type: 'null',
description: 'undo operation list',
},
},
},
operations: {
title: 'IOperations',
description: 'Delete operation list',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/operation',
},
},
operation: {
title: 'IOperation',
description: 'Delete operation',
type: 'object',
additionalProperties: true,
required: [
'action',
'data',
'id',
'parentID',
],
properties: {
action: {
// 操作活动类型: 删除
type: 'string',
const: 'delete',
description: 'operation action type',
},
data: {
// 所更新内容的 HTML DOM 文本
type: 'null',
description: 'HTML DOM of updating blocks',
},
id: {
// 删除的块 ID
type: 'string',
description: 'ID of the block to be deleted',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/deleteBlock/response.schema.json",
"$comment": "v2.10.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Delete a block",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Delete transactions",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/transaction"
}
},
"transaction": {
"title": "ITransaction",
"description": "Delete transaction",
"type": "object",
"additionalProperties": false,
"required": [
"timestamp",
"doOperations",
"undoOperations"
],
"properties": {
"timestamp": {
"type": "integer",
"description": "timestamp"
},
"doOperations": {
"$ref": "#/$defs/operations"
},
"undoOperations": {
"type": "null",
"description": "undo operation list"
}
}
},
"operations": {
"title": "IOperations",
"description": "Delete operation list",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/operation"
}
},
"operation": {
"title": "IOperation",
"description": "Delete operation",
"type": "object",
"additionalProperties": true,
"required": [
"action",
"data",
"id",
"parentID"
],
"properties": {
"action": {
"type": "string",
"const": "delete",
"description": "operation action type"
},
"data": {
"type": "null",
"description": "HTML DOM of updating blocks"
},
"id": {
"type": "string",
"description": "ID of the block to be deleted",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
foldBlock
- 🔥 折叠块
/api/block/foldBlock
请求
ts
/**
* Fold a block
*/
export interface IPayload {
/**
* ID of the block to be folded
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/foldBlock/payload.schema.json5
* 折叠块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#fold-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.4/kernel/api/block_op.go#L148-L206
* @pathname: /api/block/foldBlock
* @version: 3.0.4
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/foldBlock/payload.schema.json5',
$comment: 'v3.0.4',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Fold a block',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 待折叠的块 ID
type: 'string',
description: 'ID of the block to be folded',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/foldBlock/payload.schema.json",
"$comment": "v3.0.4",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Fold a block",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "ID of the block to be folded",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Fold a block
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/block/foldBlock/response.schema.json5
* 折叠块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#fold-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.4/kernel/api/block_op.go#L148-L206
* @pathname: /api/block/foldBlock
* @version: 3.0.4
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/foldBlock/response.schema.json5',
$comment: 'v3.0.4',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Fold a block',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'null',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/foldBlock/response.schema.json",
"$comment": "v3.0.4",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Fold a block",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}
getBlockBreadcrumb
- 🛠 获取块面包屑
/api/block/getBlockBreadcrumb
请求
ts
/**
* Get block breadcrumb
*/
export interface IPayload {
/**
* The block types that needs to be excluded
*/
readonly excludeTypes?: TBlockType[];
/**
* Block ID
*/
readonly id: string;
}
/**
* Block type
*/
export type TBlockType = "NodeAttributeView" | "NodeAudio" | "NodeBlockQueryEmbed" | "NodeBlockquote" | "NodeCodeBlock" | "NodeDocument" | "NodeHeading" | "NodeHTMLBlock" | "NodeIFrame" | "NodeList" | "NodeListItem" | "NodeMathBlock" | "NodeParagraph" | "NodeSuperBlock" | "NodeTable" | "NodeThematicBreak" | "NodeVideo" | "NodeWidget";
json5
/**
* schemas/kernel/api/block/getBlockBreadcrumb/payload.schema.json5
* 获取块面包屑
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.5/kernel/api/block.go#L355-L381
* @pathname: /api/block/getBlockBreadcrumb
* @version: 2.9.5
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockBreadcrumb/payload.schema.json5',
$comment: 'v2.9.5',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Get block breadcrumb',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
excludeTypes: {
// 需要排除的块类型
type: 'array',
description: 'The block types that needs to be excluded',
items: {
title: 'TBlockType',
type: 'string',
description: 'Block type',
enum: [
'NodeDocument', // 文档块
'NodeSuperBlock', // 超级块
'NodeBlockquote', // 引述块
'NodeList', // 列表块
'NodeListItem', // 列表项
'NodeHeading', // 标题块
'NodeParagraph', // 段落块
'NodeMathBlock', // 公式块
'NodeTable', // 表格块
'NodeCodeBlock', // 代码块
'NodeHTMLBlock', // HTML 块
'NodeThematicBreak', // 分割线
'NodeAudio', // 音频快
'NodeVideo', // 视频块
'NodeIFrame', // iframe 块
'NodeWidget', // 挂件块
'NodeBlockQueryEmbed', // 嵌入块
'NodeAttributeView', // 属性表
],
},
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockBreadcrumb/payload.schema.json",
"$comment": "v2.9.5",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Get block breadcrumb",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"excludeTypes": {
"type": "array",
"description": "The block types that needs to be excluded",
"items": {
"title": "TBlockType",
"type": "string",
"description": "Block type",
"enum": [
"NodeDocument",
"NodeSuperBlock",
"NodeBlockquote",
"NodeList",
"NodeListItem",
"NodeHeading",
"NodeParagraph",
"NodeMathBlock",
"NodeTable",
"NodeCodeBlock",
"NodeHTMLBlock",
"NodeThematicBreak",
"NodeAudio",
"NodeVideo",
"NodeIFrame",
"NodeWidget",
"NodeBlockQueryEmbed",
"NodeAttributeView"
]
}
}
}
}
}
}
响应
ts
/**
* Get block breadcrumb
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
/**
* breadcrumb item list
*/
readonly data: IBreadcrumbItem[];
/**
* status message
*/
readonly msg: string;
}
export interface IBreadcrumbItem {
/**
* Block children
*/
readonly children: null;
/**
* Block ID
*/
readonly id: string;
/**
* Block text content
*/
readonly name: string;
/**
* Block subtype
*/
readonly subType: SubTypeEnum;
/**
* Block type
*/
readonly type: TypeEnum;
}
export type SubTypeEnum = "" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "o" | "t" | "u";
export type TypeEnum = "NodeAttributeView" | "NodeAudio" | "NodeBlockQueryEmbed" | "NodeBlockquote" | "NodeCodeBlock" | "NodeDocument" | "NodeHeading" | "NodeHTMLBlock" | "NodeIFrame" | "NodeList" | "NodeListItem" | "NodeParagraph" | "NodeSuperBlock" | "NodeTable" | "NodeThematicBreak" | "NodeVideo" | "NodeWidget";
json5
/**
* schemas/kernel/api/block/getBlockBreadcrumb/response.schema.json5
* 获取块面包屑
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.5/kernel/api/block.go#L355-L381
* @pathname: /api/block/getBlockBreadcrumb
* @version: 2.9.5
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockBreadcrumb/response.schema.json5',
$comment: 'v2.9.5',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get block breadcrumb',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'array',
description: 'breadcrumb item list',
items: {
$ref: '#/$defs/datum',
},
},
},
},
datum: {
title: 'IBreadcrumbItem',
type: 'object',
additionalProperties: false,
required: [
'id',
'name',
'type',
'subType',
'children',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
name: {
// 块文本内容
type: 'string',
description: 'Block text content',
},
type: {
// 块类型
title: 'TBlockType',
type: 'string',
description: 'Block type',
},
subType: {
// 块子类型
title: 'TBlockSubType',
type: 'string',
description: 'Block subtype',
},
children: {
// 下级块
type: 'null',
description: 'Block children',
},
},
oneOf: [
{
properties: {
type: {
// 块类型
enum: [
'NodeDocument', // 文档块
'NodeSuperBlock', // 超级块
'NodeBlockquote', // 引述块
'NodeHeading', // 标题块
'NodeParagraph', // 段落块
'NodeTable', // 表格块
'NodeCodeBlock', // 代码块
'NodeHTMLBlock', // HTML 块
'NodeThematicBreak', // 分割线
'NodeAudio', // 音频快
'NodeVideo', // 视频块
'NodeIFrame', // iframe 块
'NodeWidget', // 挂件块
'NodeBlockQueryEmbed', // 嵌入块
'NodeAttributeView', // 属性表
],
},
subType: {
// 块子类型
enum: [
'', // 其他块
],
},
},
},
{
properties: {
type: {
// 块类型
enum: [
'NodeList', // 列表块
'NodeListItem', // 列表项
],
},
subType: {
// 块子类型
enum: [
'u', // 列表块/列表项
'o', // 列表块/列表项
't', // 列表块/列表项
],
},
},
},
{
properties: {
type: {
// 块类型
enum: [
'NodeHeading', // 标题块
],
},
subType: {
// 块子类型
enum: [
'h1', // 标题块
'h2', // 标题块
'h3', // 标题块
'h4', // 标题块
'h5', // 标题块
'h6', // 标题块
],
},
},
},
],
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockBreadcrumb/response.schema.json",
"$comment": "v2.9.5",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get block breadcrumb",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "array",
"description": "breadcrumb item list",
"items": {
"$ref": "#/$defs/datum"
}
}
}
},
"datum": {
"title": "IBreadcrumbItem",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"name",
"type",
"subType",
"children"
],
"properties": {
"id": {
"type": "string",
"description": "Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"name": {
"type": "string",
"description": "Block text content"
},
"type": {
"title": "TBlockType",
"type": "string",
"description": "Block type"
},
"subType": {
"title": "TBlockSubType",
"type": "string",
"description": "Block subtype"
},
"children": {
"type": "null",
"description": "Block children"
}
},
"oneOf": [
{
"properties": {
"type": {
"enum": [
"NodeDocument",
"NodeSuperBlock",
"NodeBlockquote",
"NodeHeading",
"NodeParagraph",
"NodeTable",
"NodeCodeBlock",
"NodeHTMLBlock",
"NodeThematicBreak",
"NodeAudio",
"NodeVideo",
"NodeIFrame",
"NodeWidget",
"NodeBlockQueryEmbed",
"NodeAttributeView"
]
},
"subType": {
"enum": [
""
]
}
}
},
{
"properties": {
"type": {
"enum": [
"NodeList",
"NodeListItem"
]
},
"subType": {
"enum": [
"u",
"o",
"t"
]
}
}
},
{
"properties": {
"type": {
"enum": [
"NodeHeading"
]
},
"subType": {
"enum": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6"
]
}
}
}
]
}
}
}
getBlockDOM
- 🛠 获取块 HTML DOM
/api/block/getBlockDOM
请求
ts
/**
* Get block HTML DOM string
*/
export interface IPayload {
/**
* Block ID
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/getBlockDOM/payload.schema.json5
* 获取块 DOM 字符串
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.5/kernel/api/block.go#L454-L469
* @pathname: /api/block/getBlockDOM
* @version: 2.9.5
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockDOM/payload.schema.json5',
$comment: 'v2.9.5',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Get block HTML DOM string',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockDOM/payload.schema.json",
"$comment": "v2.9.5",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Get block HTML DOM string",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Get block HTML DOM string
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* Response information
*/
export interface IData {
/**
* HTML DOM string
*/
readonly dom: string;
/**
* Block ID
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/getBlockDOM/response.schema.json5
* 获取块 DOM 字符串
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.5/kernel/api/block.go#L454-L469
* @pathname: /api/block/getBlockDOM
* @version: 2.9.5
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockDOM/response.schema.json5',
$comment: 'v2.9.5',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get block HTML DOM string',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Response information',
type: 'object',
additionalProperties: false,
required: [
'id',
'dom',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
dom: {
// HTML DOM 字符串
type: 'string',
description: 'HTML DOM string',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockDOM/response.schema.json",
"$comment": "v2.9.5",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get block HTML DOM string",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Response information",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"dom"
],
"properties": {
"id": {
"type": "string",
"description": "Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"dom": {
"type": "string",
"description": "HTML DOM string"
}
}
}
}
}
getBlockInfo
- 🛠 获取块信息
/api/block/getBlockInfo
请求
ts
/**
* Gets the document information where the block in
*/
export interface IPayload {
/**
* Block ID
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/getBlockInfo/payload.schema.json5
* 获取块所在文档信息
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.6/kernel/api/block.go#L397-L452
* @pathname: /api/block/getBlockInfo
* @version: 2.9.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockInfo/payload.schema.json5',
$comment: 'v2.9.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Gets the document information where the block in',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockInfo/payload.schema.json",
"$comment": "v2.9.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Gets the document information where the block in",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Gets the document information where the block in
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* Response information
*/
export interface IData {
/**
* Notebook ID
*/
readonly box: string;
/**
* Document path, which needs to start with / and separate levels with /
* path here corresponds to the database path field
*/
readonly path: string;
/**
* Block ID without parent block
*/
readonly rootChildID: string;
/**
* Document icon
*/
readonly rootIcon: string;
/**
* Document block ID
*/
readonly rootID: string;
/**
* Document title
*/
readonly rootTitle: string;
}
json5
/**
* schemas/kernel/api/block/getBlockInfo/response.schema.json5
* 获取块所在文档信息
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.6/kernel/api/block.go#L397-L452
* @pathname: /api/block/getBlockInfo
* @version: 2.9.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockInfo/response.schema.json5',
$comment: 'v',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Gets the document information where the block in',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Response information',
type: 'object',
additionalProperties: false,
required: [
'box',
'path',
'rootChildID',
'rootID',
'rootIcon',
'rootTitle',
],
properties: {
box: {
// 笔记本 ID
type: 'string',
description: 'Notebook ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
path: {
// 相对于笔记本目录的文档文件目录
type: 'string',
description: 'Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field',
pattern: '^(/\\d{14}-[0-9a-z]{7})+\\.sy$',
examples: [
'/20200812220555-lj3enxa.sy',
'/20200812220555-lj3enxa/20210808180320-fqgskfj.sy',
],
},
rootChildID: {
// 没有上级的块 (顶层块)
type: 'string',
description: 'Block ID without parent block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
rootID: {
// 文档块 ID
type: 'string',
description: 'Document block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
rootIcon: {
// 文档图标
type: 'string',
description: 'Document icon',
examples: [
'1f3d8',
'icon.svg',
'folder/icon.png',
],
},
rootTitle: {
// 文档图标
type: 'string',
description: 'Document title',
minLength: 1,
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockInfo/response.schema.json",
"$comment": "v",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Gets the document information where the block in",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Response information",
"type": "object",
"additionalProperties": false,
"required": [
"box",
"path",
"rootChildID",
"rootID",
"rootIcon",
"rootTitle"
],
"properties": {
"box": {
"type": "string",
"description": "Notebook ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"path": {
"type": "string",
"description": "Document path, which needs to start with / and separate levels with /\npath here corresponds to the database path field",
"pattern": "^(/\\d{14}-[0-9a-z]{7})+\\.sy$",
"examples": [
"/20200812220555-lj3enxa.sy",
"/20200812220555-lj3enxa/20210808180320-fqgskfj.sy"
]
},
"rootChildID": {
"type": "string",
"description": "Block ID without parent block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"rootID": {
"type": "string",
"description": "Document block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"rootIcon": {
"type": "string",
"description": "Document icon",
"examples": [
"1f3d8",
"icon.svg",
"folder/icon.png"
]
},
"rootTitle": {
"type": "string",
"description": "Document title",
"minLength": 1
}
}
}
}
}
getBlockKramdown
- 🔥 获取块 kramdown
/api/block/getBlockKramdown
请求
ts
/**
* Get a block kramdown
*/
export interface IPayload {
/**
* block ID
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/getBlockKramdown/payload.schema.json5
* 获取块 kramdown 源码
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-a-block-kramdown
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block.go#L471-L490
* @pathname: /api/block/getBlockKramdown
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockKramdown/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Get a block kramdown',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockKramdown/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Get a block kramdown",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Get a block kramdown
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* block kramdown info
*/
export interface IData {
/**
* block ID
*/
readonly id: string;
/**
* block kramdown text
*/
readonly kramdown: string;
}
json5
/**
* schemas/kernel/api/block/getBlockKramdown/response.schema.json5
* 获取块 kramdown 源码
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-a-block-kramdown
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block.go#L471-L490
* @pathname: /api/block/getBlockKramdown
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockKramdown/response.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get a block kramdown',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'block kramdown info',
type: 'object',
additionalProperties: false,
required: [
'id',
'kramdown',
],
properties: {
id: {
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
kramdown: {
type: 'string',
description: 'block kramdown text',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getBlockKramdown/response.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get a block kramdown",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "block kramdown info",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"kramdown"
],
"properties": {
"id": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"kramdown": {
"type": "string",
"description": "block kramdown text"
}
}
}
}
}
getChildBlocks
- 🔥 获取下级块
/api/block/getChildBlocks
请求
ts
/**
* Get child blocks
*/
export interface IPayload {
/**
* block ID
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/getChildBlocks/payload.schema.json5
* 获取下级块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-child-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block.go#L492-L507
* @pathname: /api/block/getChildBlocks
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getChildBlocks/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Get child blocks',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getChildBlocks/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Get child blocks",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Get child blocks
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IBlock[];
/**
* status message
*/
readonly msg: string;
}
/**
* sub block list
*
* sub block
*/
export interface IBlock {
/**
* block ID
*/
readonly id: string;
/**
* block subtype
*/
readonly subType?: TBlockSubType;
/**
* block type
*/
readonly type: TBlockType;
}
/**
* block subtype
*/
export type TBlockSubType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "o" | "t" | "u";
/**
* block type
*/
export type TBlockType = "audio" | "b" | "c" | "d" | "h" | "html" | "i" | "iframe" | "l" | "m" | "p" | "query_embed" | "s" | "t" | "tb" | "video" | "widget";
json5
/**
* schemas/kernel/api/block/getChildBlocks/response.schema.json5
* 获取下级块
* 如果为文档块, 则获取包含标题块的顶层块
* 如果为标题块, 则也可以获取包含下级标题块的所有下级块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#get-child-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block.go#L492-L507
* @pathname: /api/block/getChildBlocks
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getChildBlocks/response.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get child blocks',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
// 下级块列表
title: 'IData',
description: 'sub block list',
type: 'array',
items: {
$ref: '#/$defs/block',
},
},
block: {
// 块
title: 'IBlock',
description: 'sub block',
type: 'object',
additionalProperties: false,
properties: {
id: {
// 块 ID
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
type: {
// 块类型
title: 'TBlockType',
type: 'string',
description: 'block type',
enum: [
/* 容器块 */
'd', // 文档块
's', // 超级块
'b', // 引述块
'l', // 列表块
'i', // 列表项
/* 叶子块 */
'h', // 标题块
'p', // 段落块
'm', // 公式块
't', // 表格块
'c', // 代码块
'html', // HTML 块
'query_embed', // 嵌入块
'tb', // 分隔线
'audio', // 音频块
'video', // 视频块
'iframe', // iframe
'widget', // 挂件块
],
},
subType: {
// 块子类型
title: 'TBlockSubType',
type: 'string',
description: 'block subtype',
enum: [
'h1', // 一级标题
'h2', // 二级标题
'h3', // 三级标题
'h4', // 四级标题
'h5', // 五级标题
'h6', // 六级标题
'u', // 无序列表
'o', // 有序列表
't', // 任务列表
],
},
},
// REF: https://blog.csdn.net/lxz352907839/article/details/127623957
oneOf: [
/* 标题块 */
{
required: [
'id',
'type',
'subType',
],
properties: {
type: {
const: 'h',
},
// 标题块具有的子类型: 表示标题级别
subType: {
enum: [
'h1', // 一级标题
'h2', // 二级标题
'h3', // 三级标题
'h4', // 四级标题
'h5', // 五级标题
'h6', // 六级标题
],
},
},
},
/* 列表块与列表项 */
{
required: [
'id',
'type',
'subType',
],
properties: {
type: {
enum: [
'l', // 列表块
'i', // 列表项
],
},
// 列表块与列表项的子类型: 表示列表类型
subType: {
enum: [
'u', // 无序列表
'o', // 有序列表
't', // 任务列表
],
},
},
},
/* 其他块 */
{
required: [
'id',
'type',
],
properties: {
type: {
enum: [
/* 容器块 */
'd', // 文档块
's', // 超级块
'b', // 引述块
/* 叶子块 */
'p', // 段落块
'm', // 公式块
't', // 表格块
'c', // 代码块
'html', // HTML 块
'query_embed', // 嵌入块
'tb', // 分隔线
'audio', // 音频块
'video', // 视频块
'iframe', // iframe
'widget', // 挂件块
],
},
},
},
],
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getChildBlocks/response.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get child blocks",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "sub block list",
"type": "array",
"items": {
"$ref": "#/$defs/block"
}
},
"block": {
"title": "IBlock",
"description": "sub block",
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"type": {
"title": "TBlockType",
"type": "string",
"description": "block type",
"enum": [
"d",
"s",
"b",
"l",
"i",
"h",
"p",
"m",
"t",
"c",
"html",
"query_embed",
"tb",
"audio",
"video",
"iframe",
"widget"
]
},
"subType": {
"title": "TBlockSubType",
"type": "string",
"description": "block subtype",
"enum": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"u",
"o",
"t"
]
}
},
"oneOf": [
{
"required": [
"id",
"type",
"subType"
],
"properties": {
"type": {
"const": "h"
},
"subType": {
"enum": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6"
]
}
}
},
{
"required": [
"id",
"type",
"subType"
],
"properties": {
"type": {
"enum": [
"l",
"i"
]
},
"subType": {
"enum": [
"u",
"o",
"t"
]
}
}
},
{
"required": [
"id",
"type"
],
"properties": {
"type": {
"enum": [
"d",
"s",
"b",
"p",
"m",
"t",
"c",
"html",
"query_embed",
"tb",
"audio",
"video",
"iframe",
"widget"
]
}
}
}
]
}
}
}
getDocInfo
- 🛠 获取文档信息
/api/block/getDocInfo
请求
ts
/**
* Get document information
*/
export interface IPayload {
/**
* block ID
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/getDocInfo/payload.schema.json5
* 获取文档信息
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.5/kernel/api/block.go#L236-L253
* @pathname: /api/block/getDocInfo
* @version: 3.0.5
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getDocInfo/payload.schema.json5',
$comment: 'v3.0.5',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Get document information',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getDocInfo/payload.schema.json",
"$comment": "v3.0.5",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Get document information",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Get document information
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* document information
*/
export interface IData {
/**
* Attribute view reference list
*/
readonly attrViews: IAttrView[];
readonly ial: Ial;
/**
* document icon
*/
readonly icon: string;
/**
* block ID
*/
readonly id: string;
/**
* document name
*/
readonly name: string;
/**
* The number of references to the document
*/
readonly refCount: number;
/**
* ID of the block referencing the document
*/
readonly refIDs: string[];
/**
* document block ID
*/
readonly rootID: string;
/**
* The number of sub-documents
*/
readonly subFileCount: number;
}
/**
* Attribute view
*/
export interface IAttrView {
/**
* Attribute view ID
*/
readonly id: string;
/**
* Attribute view name
*/
readonly name: ID;
}
export type ID = "未命名" | "Sans titre" | "Sin título" | "Untitled";
/**
* Inline Attribute List (IAL) of document block
*/
export interface Ial {
/**
* document block ID
*/
readonly id: string;
/**
* document title
*/
readonly title: string;
/**
* The last time the block was updated
*/
readonly updated: string;
[property: string]: string;
}
json5
/**
* schemas/kernel/api/block/getDocInfo/response.schema.json5
* 获取文档信息
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.5/kernel/api/block.go#L236-L253
* @pathname: /api/block/getDocInfo
* @version: 3.0.5
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getDocInfo/response.schema.json5',
$comment: 'v3.0.5',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get document information',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'document information',
type: 'object',
additionalProperties: false,
required: [
'attrViews',
'ial',
'icon',
'id',
'name',
'refCount',
'refIDs',
'rootID',
'subFileCount',
],
properties: {
attrViews: {
// 属性视图引用列表
type: 'array',
description: 'Attribute view reference list',
items: {
$ref: '#/$defs/attrView',
},
},
id: {
// 块 ID
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
rootID: {
// 文档块 ID
type: 'string',
description: 'document block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
name: {
// 文档名
type: 'string',
description: 'document name',
},
refCount: {
// 引用该文档的数量
type: 'integer',
description: 'The number of references to the document',
},
subFileCount: {
// 下级文档数
type: 'integer',
description: 'The number of sub-documents',
},
refIDs: {
// 引用该文档的块 ID
type: 'array',
description: 'ID of the block referencing the document',
items: {
type: 'string',
description: 'block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
icon: {
// 文档图标
type: 'string',
description: 'document icon',
},
ial: {
// 文档 IAL
$ref: '#/$defs/ial',
},
},
},
attrView: {
title: 'IAttrView',
description: 'Attribute view',
type: 'object',
additionalProperties: false,
required: [
'id',
'name',
],
properties: {
id: {
// 属性视图 ID
type: 'string',
description: 'Attribute view ID',
},
name: {
// 属性视图名称
type: 'string',
description: 'Attribute view name',
},
},
oneOf: [
{
properties: {
id: {
const: '',
},
name: {
enum: [
'Untitled',
'Sin título',
'Sans titre',
'未命名',
],
},
},
},
{
properties: {
id: {
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
],
},
ial: {
// 文档块的内联属性表
title: 'IAL',
description: 'Inline Attribute List (IAL) of document block',
type: 'object',
propertyNames: {
type: 'string',
minLength: 1,
pattern: '^[_a-zA-Z][_.\\-0-9a-zA-Z]*$',
},
patternProperties: {
'^((?!id|title|update)[_a-zA-Z][_.\\-0-9a-zA-Z]*)': {
type: 'string',
minLength: 1,
},
},
additionalProperties: {
type: 'string',
},
required: [
'id',
'title',
'updated',
],
properties: {
id: {
// 文档块 ID
type: 'string',
description: 'document block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
examples: [
'20200812220555-lj3enxa',
],
},
title: {
// 文档标题
type: 'string',
description: 'document title',
pattern: '^[^/]+$',
},
updated: {
// 块上次更新时间 YYYYMMDDhhmmss
type: 'string',
description: 'The last time the block was updated',
pattern: '^((?:19|20)\\d{2})(0[1-9]|1[012])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-3])([0-5]\\d)([0-5]\\d)$',
examples: [
'20210714092948',
],
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getDocInfo/response.schema.json",
"$comment": "v3.0.5",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get document information",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "document information",
"type": "object",
"additionalProperties": false,
"required": [
"attrViews",
"ial",
"icon",
"id",
"name",
"refCount",
"refIDs",
"rootID",
"subFileCount"
],
"properties": {
"attrViews": {
"type": "array",
"description": "Attribute view reference list",
"items": {
"$ref": "#/$defs/attrView"
}
},
"id": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"rootID": {
"type": "string",
"description": "document block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"name": {
"type": "string",
"description": "document name"
},
"refCount": {
"type": "integer",
"description": "The number of references to the document"
},
"subFileCount": {
"type": "integer",
"description": "The number of sub-documents"
},
"refIDs": {
"type": "array",
"description": "ID of the block referencing the document",
"items": {
"type": "string",
"description": "block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
},
"icon": {
"type": "string",
"description": "document icon"
},
"ial": {
"$ref": "#/$defs/ial"
}
}
},
"attrView": {
"title": "IAttrView",
"description": "Attribute view",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string",
"description": "Attribute view ID"
},
"name": {
"type": "string",
"description": "Attribute view name"
}
},
"oneOf": [
{
"properties": {
"id": {
"const": ""
},
"name": {
"enum": [
"Untitled",
"Sin título",
"Sans titre",
"未命名"
]
}
}
},
{
"properties": {
"id": {
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
]
},
"ial": {
"title": "IAL",
"description": "Inline Attribute List (IAL) of document block",
"type": "object",
"propertyNames": {
"type": "string",
"minLength": 1,
"pattern": "^[_a-zA-Z][_.\\-0-9a-zA-Z]*$"
},
"patternProperties": {
"^((?!id|title|update)[_a-zA-Z][_.\\-0-9a-zA-Z]*)": {
"type": "string",
"minLength": 1
}
},
"additionalProperties": {
"type": "string"
},
"required": [
"id",
"title",
"updated"
],
"properties": {
"id": {
"type": "string",
"description": "document block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$",
"examples": [
"20200812220555-lj3enxa"
]
},
"title": {
"type": "string",
"description": "document title",
"pattern": "^[^/]+$"
},
"updated": {
"type": "string",
"description": "The last time the block was updated",
"pattern": "^((?:19|20)\\d{2})(0[1-9]|1[012])(0[1-9]|[12]\\d|3[01])([01]\\d|2[0-3])([0-5]\\d)([0-5]\\d)$",
"examples": [
"20210714092948"
]
}
}
}
}
}
insertBlock
- 🔥 插入块
/api/block/insertBlock
请求
ts
/**
* Insert blocks
*/
export interface IPayload {
/**
* block data content
*/
readonly data: string;
/**
* block data format
*/
readonly dataType: TDataType;
/**
* block ID: insert before this block
*/
readonly nextID?: string;
/**
* block ID: insert into this block head
*/
readonly parentID?: string;
/**
* block ID: insert after this block
*/
readonly previousID?: string;
}
/**
* block data format
*/
export type TDataType = "dom" | "markdown";
json5
/**
* schemas/kernel/api/block/insertBlock/payload.schema.json5
* 插入块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#insert-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block_op.go#L165-L220
* @pathname: /api/block/insertBlock
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/insertBlock/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Insert blocks',
type: 'object',
additionalProperties: false,
properties: {
dataType: {
// 块数据格式
title: 'TDataType',
type: 'string',
description: 'block data format',
enum: [
'markdown', // kramdown 文本
'dom', // HTML DOM 文本
],
},
data: {
// 块数据内容
type: 'string',
description: 'block data content',
},
nextID: {
/**
* 后一个块的块 ID (插入到该块前)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert before this block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
previousID: {
/**
* 前一个块的块 ID (插入到该块后)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert after this block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
parentID: {
/**
* 上级块的块 ID (插入到该块内的首部)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert into this block head',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
oneOf: [
{
required: [
'dataType',
'data',
'nextID',
],
},
{
required: [
'dataType',
'data',
'previousID',
],
},
{
required: [
'dataType',
'data',
'parentID',
],
},
],
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/insertBlock/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Insert blocks",
"type": "object",
"additionalProperties": false,
"properties": {
"dataType": {
"title": "TDataType",
"type": "string",
"description": "block data format",
"enum": [
"markdown",
"dom"
]
},
"data": {
"type": "string",
"description": "block data content"
},
"nextID": {
"type": "string",
"description": "block ID: insert before this block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"previousID": {
"type": "string",
"description": "block ID: insert after this block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block head",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
},
"oneOf": [
{
"required": [
"dataType",
"data",
"nextID"
]
},
{
"required": [
"dataType",
"data",
"previousID"
]
},
{
"required": [
"dataType",
"data",
"parentID"
]
}
]
}
}
}
响应
ts
/**
* Insert blocks
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: ITransaction[];
/**
* status message
*/
readonly msg: string;
}
/**
* Insert transactions
*
* Insert transaction
*/
export interface ITransaction {
readonly doOperations: IOperation[];
/**
* timestamp
*/
readonly timestamp: number;
/**
* undo operation list
*/
readonly undoOperations: null;
}
/**
* insert operation list
*
* insert operation
*/
export interface IOperation {
/**
* operation action type
*/
readonly action: "insert";
/**
* HTML DOM of inserting blocks
*/
readonly data: string;
/**
* block ID: the first inserting block
*/
readonly id: string;
/**
* block ID: insert before this block
*/
readonly nextID: string;
/**
* block ID: insert into this block
*/
readonly parentID: string;
/**
* block ID: insert after this block
*/
readonly previousID: string;
[property: string]: any;
}
json5
/**
* schemas/kernel/api/block/insertBlock/response.schema.json5
* 插入块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#insert-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.6/kernel/api/block_op.go#L165-L220
* @pathname: /api/block/insertBlock
* @version: 2.10.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/insertBlock/response.schema.json5',
$comment: 'v2.10.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Insert blocks',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Insert transactions',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/transaction',
},
},
transaction: {
title: 'ITransaction',
description: 'Insert transaction',
type: 'object',
additionalProperties: false,
required: [
'timestamp',
'doOperations',
'undoOperations',
],
properties: {
timestamp: {
type: 'integer',
description: 'timestamp',
},
doOperations: {
$ref: '#/$defs/operations',
},
undoOperations: {
type: 'null',
description: 'undo operation list',
},
},
},
operations: {
title: 'IOperations',
description: 'insert operation list',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/operation',
},
},
operation: {
title: 'IOperation',
description: 'insert operation',
type: 'object',
additionalProperties: true,
required: [
'action',
'data',
'id',
'nextID',
'previousID',
'parentID',
],
properties: {
action: {
// 操作活动类型: 插入
type: 'string',
const: 'insert',
description: 'operation action type',
},
data: {
// 所插入内容的 HTML DOM 文本
type: 'string',
description: 'HTML DOM of inserting blocks',
},
id: {
// 插入块的块 ID (若插入了多个块, 则为第一个块的块 ID)
type: 'string',
description: 'block ID: the first inserting block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
nextID: {
// 使用 nextID 插入的块
type: 'string',
description: 'block ID: insert before this block',
oneOf: [
{
const: '',
},
{
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
],
},
previousID: {
// 使用 previousID 插入的块
type: 'string',
description: 'block ID: insert after this block',
oneOf: [
{
const: '',
},
{
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
],
},
parentID: {
// 使用 parentID 插入的块
type: 'string',
description: 'block ID: insert into this block',
oneOf: [
{
const: '',
},
{
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
],
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/insertBlock/response.schema.json",
"$comment": "v2.10.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Insert blocks",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Insert transactions",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/transaction"
}
},
"transaction": {
"title": "ITransaction",
"description": "Insert transaction",
"type": "object",
"additionalProperties": false,
"required": [
"timestamp",
"doOperations",
"undoOperations"
],
"properties": {
"timestamp": {
"type": "integer",
"description": "timestamp"
},
"doOperations": {
"$ref": "#/$defs/operations"
},
"undoOperations": {
"type": "null",
"description": "undo operation list"
}
}
},
"operations": {
"title": "IOperations",
"description": "insert operation list",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/operation"
}
},
"operation": {
"title": "IOperation",
"description": "insert operation",
"type": "object",
"additionalProperties": true,
"required": [
"action",
"data",
"id",
"nextID",
"previousID",
"parentID"
],
"properties": {
"action": {
"type": "string",
"const": "insert",
"description": "operation action type"
},
"data": {
"type": "string",
"description": "HTML DOM of inserting blocks"
},
"id": {
"type": "string",
"description": "block ID: the first inserting block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"nextID": {
"type": "string",
"description": "block ID: insert before this block",
"oneOf": [
{
"const": ""
},
{
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
]
},
"previousID": {
"type": "string",
"description": "block ID: insert after this block",
"oneOf": [
{
"const": ""
},
{
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
]
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block",
"oneOf": [
{
"const": ""
},
{
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
]
}
}
}
}
}
moveBlock
- 🔥 移动块
/api/block/moveBlock
请求
ts
/**
* Move a block
*/
export interface IPayload {
/**
* Block ID to move
*/
readonly id: string;
/**
* block ID: insert into this block head
*/
readonly parentID?: string;
/**
* block ID: insert after this block
*/
readonly previousID?: string;
}
json5
/**
* schemas/kernel/api/block/moveBlock/payload.schema.json5
* 移动块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#move-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block_op.go#L32-L85
* @pathname: /api/block/moveBlock
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/moveBlock/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Move a block',
type: 'object',
additionalProperties: false,
properties: {
id: {
// 待移动的块
type: 'string',
description: 'Block ID to move',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
previousID: {
/**
* 前一个块的块 ID (移动到该块后)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert after this block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
parentID: {
/**
* 上级块的块 ID (移动到该块内的首部)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert into this block head',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
oneOf: [
{
required: [
'id',
'previousID',
],
},
{
required: [
'id',
'parentID',
],
},
],
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/moveBlock/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Move a block",
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"description": "Block ID to move",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"previousID": {
"type": "string",
"description": "block ID: insert after this block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block head",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
},
"oneOf": [
{
"required": [
"id",
"previousID"
]
},
{
"required": [
"id",
"parentID"
]
}
]
}
}
}
响应
ts
/**
* Move a block
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: ITransaction[];
/**
* status message
*/
readonly msg: string;
}
/**
* Move transactions
*
* Move transaction
*/
export interface ITransaction {
readonly doOperations: IOperation[];
/**
* timestamp
*/
readonly timestamp: number;
/**
* undo operation list
*/
readonly undoOperations: null;
}
/**
* move operation list
*
* move operation
*/
export interface IOperation {
/**
* operation action type
*/
readonly action: "move";
/**
* HTML DOM of inserting blocks
*/
readonly data: null;
/**
* Block ID to move
*/
readonly id: string;
/**
* block ID: insert into this block
*/
readonly parentID: string;
/**
* block ID: insert after this block
*/
readonly previousID: string;
[property: string]: any;
}
json5
/**
* schemas/kernel/api/block/moveBlock/response.schema.json5
* 移动块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#move-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.6/kernel/api/block_op.go#L32-L85
* @pathname: /api/block/moveBlock
* @version: 2.10.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/moveBlock/response.schema.json5',
$comment: 'v2.10.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Move a block',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Move transactions',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/transaction',
},
},
transaction: {
title: 'ITransaction',
description: 'Move transaction',
type: 'object',
additionalProperties: false,
required: [
'timestamp',
'doOperations',
'undoOperations',
],
properties: {
timestamp: {
type: 'integer',
description: 'timestamp',
},
doOperations: {
$ref: '#/$defs/operations',
},
undoOperations: {
type: 'null',
description: 'undo operation list',
},
},
},
operations: {
title: 'IOperations',
description: 'move operation list',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/operation',
},
},
operation: {
title: 'IOperation',
description: 'move operation',
type: 'object',
additionalProperties: true,
required: [
'action',
'data',
'id',
'previousID',
'parentID',
],
properties: {
action: {
// 操作活动类型: 移动
type: 'string',
const: 'move',
description: 'operation action type',
},
data: {
// 所移动内容的 HTML DOM 文本
type: 'null',
description: 'HTML DOM of inserting blocks',
},
id: {
// 移动块的块 ID
type: 'string',
description: 'Block ID to move',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
previousID: {
// 使用 previousID 移动的块
type: 'string',
description: 'block ID: insert after this block',
oneOf: [
{
const: '',
},
{
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
],
},
parentID: {
// 使用 parentID 移动的块
type: 'string',
description: 'block ID: insert into this block',
oneOf: [
{
const: '',
},
{
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
],
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/moveBlock/response.schema.json",
"$comment": "v2.10.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Move a block",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Move transactions",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/transaction"
}
},
"transaction": {
"title": "ITransaction",
"description": "Move transaction",
"type": "object",
"additionalProperties": false,
"required": [
"timestamp",
"doOperations",
"undoOperations"
],
"properties": {
"timestamp": {
"type": "integer",
"description": "timestamp"
},
"doOperations": {
"$ref": "#/$defs/operations"
},
"undoOperations": {
"type": "null",
"description": "undo operation list"
}
}
},
"operations": {
"title": "IOperations",
"description": "move operation list",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/operation"
}
},
"operation": {
"title": "IOperation",
"description": "move operation",
"type": "object",
"additionalProperties": true,
"required": [
"action",
"data",
"id",
"previousID",
"parentID"
],
"properties": {
"action": {
"type": "string",
"const": "move",
"description": "operation action type"
},
"data": {
"type": "null",
"description": "HTML DOM of inserting blocks"
},
"id": {
"type": "string",
"description": "Block ID to move",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"previousID": {
"type": "string",
"description": "block ID: insert after this block",
"oneOf": [
{
"const": ""
},
{
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
]
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block",
"oneOf": [
{
"const": ""
},
{
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
]
}
}
}
}
}
prependBlock
- 🔥 在下级块首部插入块
/api/block/prependBlock
请求
ts
/**
* Prepend blocks
*/
export interface IPayload {
/**
* block data content
*/
readonly data: string;
/**
* block data format
*/
readonly dataType: TDataType;
/**
* block ID: insert into this block head
* The ID of the parent block, used to anchor the insertion position
*/
readonly parentID: string;
}
/**
* block data format
*/
export type TDataType = "dom" | "markdown";
json5
/**
* schemas/kernel/api/block/prependBlock/payload.schema.json5
* 在块内的首部插入块 (插入前置子块)
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#prepend-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block_op.go#L126-L163
* @pathname: /api/block/prependBlock
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/prependBlock/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Prepend blocks',
type: 'object',
additionalProperties: false,
required: [
'dataType',
'data',
'parentID',
],
properties: {
dataType: {
// 块数据格式
title: 'TDataType',
type: 'string',
description: 'block data format',
enum: [
'markdown', // kramdown 文本
'dom', // HTML DOM 文本
],
},
data: {
// 块数据内容
type: 'string',
description: 'block data content',
},
parentID: {
/**
* 上级块的块 ID (插入到该块内首部)
* 用于锚定插入位置
*/
type: 'string',
description: 'block ID: insert into this block head\nThe ID of the parent block, used to anchor the insertion position',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/prependBlock/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Prepend blocks",
"type": "object",
"additionalProperties": false,
"required": [
"dataType",
"data",
"parentID"
],
"properties": {
"dataType": {
"title": "TDataType",
"type": "string",
"description": "block data format",
"enum": [
"markdown",
"dom"
]
},
"data": {
"type": "string",
"description": "block data content"
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block head\nThe ID of the parent block, used to anchor the insertion position",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Prepend blocks
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: ITransaction[];
/**
* status message
*/
readonly msg: string;
}
/**
* Insert transactions
*
* Insert transaction
*/
export interface ITransaction {
readonly doOperations: IOperation[];
/**
* timestamp
*/
readonly timestamp: number;
/**
* undo operation list
*/
readonly undoOperations: null;
}
/**
* insert operation list
*
* insert operation
*/
export interface IOperation {
/**
* operation action type
*/
readonly action: "insert";
/**
* HTML DOM of inserting blocks
*/
readonly data: string;
/**
* block ID: the first inserting block
*/
readonly id: string;
/**
* block ID: insert into this block
*/
readonly parentID: string;
[property: string]: any;
}
json5
/**
* schemas/kernel/api/block/prependBlock/response.schema.json5
* 在块内的首部插入块 (插入前置子块)
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#prepend-blocks
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.6/kernel/api/block_op.go#L126-L163
* @pathname: /api/block/prependBlock
* @version: 2.10.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/prependBlock/response.schema.json5',
$comment: 'v2.10.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Prepend blocks',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Insert transactions',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/transaction',
},
},
transaction: {
title: 'ITransaction',
description: 'Insert transaction',
type: 'object',
additionalProperties: false,
required: [
'timestamp',
'doOperations',
'undoOperations',
],
properties: {
timestamp: {
type: 'integer',
description: 'timestamp',
},
doOperations: {
$ref: '#/$defs/operations',
},
undoOperations: {
type: 'null',
description: 'undo operation list',
},
},
},
operations: {
title: 'IOperations',
description: 'insert operation list',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/operation',
},
},
operation: {
title: 'IOperation',
description: 'insert operation',
type: 'object',
additionalProperties: true,
required: [
'action',
'data',
'id',
'parentID',
],
properties: {
action: {
// 操作活动类型: 插入
type: 'string',
const: 'insert',
description: 'operation action type',
},
data: {
// 所插入内容的 HTML DOM 文本
type: 'string',
description: 'HTML DOM of inserting blocks',
},
id: {
// 插入块的块 ID (若插入了多个块, 则为第一个块的块 ID)
type: 'string',
description: 'block ID: the first inserting block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
parentID: {
// 上级块的块 ID
type: 'string',
description: 'block ID: insert into this block',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/prependBlock/response.schema.json",
"$comment": "v2.10.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Prepend blocks",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Insert transactions",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/transaction"
}
},
"transaction": {
"title": "ITransaction",
"description": "Insert transaction",
"type": "object",
"additionalProperties": false,
"required": [
"timestamp",
"doOperations",
"undoOperations"
],
"properties": {
"timestamp": {
"type": "integer",
"description": "timestamp"
},
"doOperations": {
"$ref": "#/$defs/operations"
},
"undoOperations": {
"type": "null",
"description": "undo operation list"
}
}
},
"operations": {
"title": "IOperations",
"description": "insert operation list",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/operation"
}
},
"operation": {
"title": "IOperation",
"description": "insert operation",
"type": "object",
"additionalProperties": true,
"required": [
"action",
"data",
"id",
"parentID"
],
"properties": {
"action": {
"type": "string",
"const": "insert",
"description": "operation action type"
},
"data": {
"type": "string",
"description": "HTML DOM of inserting blocks"
},
"id": {
"type": "string",
"description": "block ID: the first inserting block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"parentID": {
"type": "string",
"description": "block ID: insert into this block",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
transferBlockRef
- 🔥 转移块引用
/api/block/transferBlockRef
请求
ts
/**
* Transfer block ref
*/
export interface IPayload {
/**
* Def block ID
*/
readonly fromID: string;
readonly refIDs?: string[] | null;
/**
* Whether to refresh the UI
*/
readonly reloadUI?: boolean;
/**
* Target block ID
*/
readonly toID: string;
}
json5
/**
* schemas/kernel/api/block/transferBlockRef/payload.schema.json5
* 转移块引用
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#transfer-block-ref
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.2/kernel/api/block.go#L47-L88
* @pathname: /api/block/transferBlockRef
* @version: 3.0.2
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/transferBlockRef/payload.schema.json5',
$comment: 'v3.0.2',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Transfer block ref',
type: 'object',
additionalProperties: false,
required: [
'fromID',
'toID',
],
properties: {
fromID: {
// 移动前引用指向的块 ID
type: 'string',
description: 'Def block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
toID: {
// 移动后引用指向的块 ID
type: 'string',
description: 'Target block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
reloadUI: {
// 是否刷新 UI
type: 'boolean',
description: 'Whether to refresh the UI',
default: true,
},
refIDs: {
// 仅转移指定块的块引用目标
oneOf: [
{
// 转移所有块引用
type: 'null',
description: 'Transfer all block references',
},
{
// 转移部分引用
type: 'array',
items: {
// 块引用所在的块 ID
type: 'string',
description: 'The block where the block reference is located',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
oneOf: [
{
// 转移所有块引用
maxItems: 0,
description: 'Transfer all block references',
},
{
/**
* 仅转移部分块引用目标
* 想要转移目标的块引用所在的块 ID 列表
* 该列表中的块可以是不限层级的上级块
* @example: 若为文档块 ID, 则该文档下所有目标为 fromID 的块引用都会被转移到 toID
*/
minItems: 1,
description: 'Ref block IDs point to def block ID, optional, if not specified, all ref block IDs will be transferred',
},
],
},
],
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/transferBlockRef/payload.schema.json",
"$comment": "v3.0.2",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Transfer block ref",
"type": "object",
"additionalProperties": false,
"required": [
"fromID",
"toID"
],
"properties": {
"fromID": {
"type": "string",
"description": "Def block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"toID": {
"type": "string",
"description": "Target block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"reloadUI": {
"type": "boolean",
"description": "Whether to refresh the UI",
"default": true
},
"refIDs": {
"oneOf": [
{
"type": "null",
"description": "Transfer all block references"
},
{
"type": "array",
"items": {
"type": "string",
"description": "The block where the block reference is located",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"oneOf": [
{
"maxItems": 0,
"description": "Transfer all block references"
},
{
"minItems": 1,
"description": "Ref block IDs point to def block ID, optional, if not specified, all ref block IDs will be transferred"
}
]
}
]
}
}
}
}
}
响应
ts
/**
* Transfer block ref
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/block/transferBlockRef/response.schema.json5
* 转移块引用
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#transfer-block-ref
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block.go#L32-L64
* @pathname: /api/block/transferBlockRef
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/transferBlockRef/response.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Transfer block ref',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'null',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/transferBlockRef/response.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Transfer block ref",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}
unfoldBlock
- 🔥 展开块
/api/block/unfoldBlock
请求
ts
/**
* Unfold a block
*/
export interface IPayload {
/**
* ID of the block to be unfolded
*/
readonly id: string;
}
json5
/**
* schemas/kernel/api/block/unfoldBlock/payload.schema.json5
* 展开快
* REF: https://github.com/siyuan-note/siyuan/blob/dev/API.md#Unfold-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.4/kernel/api/block_op.go#L88-L146
* @pathname: /api/block/unfoldBlock
* @version: 3.0.4
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/unfoldBlock/payload.schema.json5',
$comment: 'v3.0.4',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Unfold a block',
type: 'object',
additionalProperties: false,
required: [
'id',
],
properties: {
id: {
// 待展开的块 ID
type: 'string',
description: 'ID of the block to be unfolded',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/unfoldBlock/payload.schema.json",
"$comment": "v3.0.4",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Unfold a block",
"type": "object",
"additionalProperties": false,
"required": [
"id"
],
"properties": {
"id": {
"type": "string",
"description": "ID of the block to be unfolded",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Unfold a block
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: null;
/**
* status message
*/
readonly msg: string;
}
json5
/**
* schemas/kernel/api/block/unfoldBlock/response.schema.json5
* 展开快
* REF: https://github.com/siyuan-note/siyuan/blob/dev/API.md#Unfold-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.4/kernel/api/block_op.go#L88-L146
* @pathname: /api/block/unfoldBlock
* @version: 3.0.4
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/unfoldBlock/response.schema.json5',
$comment: 'v3.0.4',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Unfold a block',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
type: 'null',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/unfoldBlock/response.schema.json",
"$comment": "v3.0.4",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Unfold a block",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"type": "null"
}
}
}
}
}
updateBlock
- 🔥 更新块
/api/block/updateBlock
请求
ts
/**
* Update a block
*/
export interface IPayload {
/**
* Data to be updated
*/
readonly data: string;
/**
* block data format
*/
readonly dataType: TDataType;
/**
* ID of the block to be updated
*/
readonly id: string;
}
/**
* block data format
*/
export type TDataType = "dom" | "markdown";
json5
/**
* schemas/kernel/api/block/updateBlock/payload.schema.json5
* 更新块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#update-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.3/kernel/api/block_op.go#L222-L305
* @pathname: /api/block/updateBlock
* @version: 2.9.3
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/updateBlock/payload.schema.json5',
$comment: 'v2.9.3',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Update a block',
type: 'object',
additionalProperties: false,
required: [
'dataType',
'data',
'id',
],
properties: {
dataType: {
// 块数据格式
title: 'TDataType',
type: 'string',
description: 'block data format',
enum: [
'markdown', // kramdown 文本
'dom', // HTML DOM 文本
],
},
data: {
// 块数据内容
type: 'string',
description: 'Data to be updated',
},
id: {
// 待更新的块 ID
type: 'string',
description: 'ID of the block to be updated',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/updateBlock/payload.schema.json",
"$comment": "v2.9.3",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Update a block",
"type": "object",
"additionalProperties": false,
"required": [
"dataType",
"data",
"id"
],
"properties": {
"dataType": {
"title": "TDataType",
"type": "string",
"description": "block data format",
"enum": [
"markdown",
"dom"
]
},
"data": {
"type": "string",
"description": "Data to be updated"
},
"id": {
"type": "string",
"description": "ID of the block to be updated",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}
响应
ts
/**
* Update a block
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: ITransaction[];
/**
* status message
*/
readonly msg: string;
}
/**
* Update transactions
*
* Update transaction
*/
export interface ITransaction {
readonly doOperations: IOperation[];
/**
* timestamp
*/
readonly timestamp: number;
/**
* undo operation list
*/
readonly undoOperations: null;
}
/**
* Update operation list
*
* Update operation
*/
export interface IOperation {
/**
* operation action type
*/
readonly action: "update";
/**
* HTML DOM of updating blocks
*/
readonly data: string;
/**
* ID of the block to be updated
*/
readonly id: string;
readonly parentID: any;
[property: string]: any;
}
json5
/**
* schemas/kernel/api/block/updateBlock/response.schema.json5
* 更新块
* REF: https://github.com/siyuan-note/siyuan/blob/master/API.md#update-a-block
* REF: https://github.com/siyuan-note/siyuan/blob/v2.10.6/kernel/api/block_op.go#L222-L305
* @pathname: /api/block/updateBlock
* @version: 2.10.6
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/updateBlock/response.schema.json5',
$comment: 'v2.10.6',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Update a block',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Update transactions',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/transaction',
},
},
transaction: {
title: 'ITransaction',
description: 'Update transaction',
type: 'object',
additionalProperties: false,
required: [
'timestamp',
'doOperations',
'undoOperations',
],
properties: {
timestamp: {
type: 'integer',
description: 'timestamp',
},
doOperations: {
$ref: '#/$defs/operations',
},
undoOperations: {
type: 'null',
description: 'undo operation list',
},
},
},
operations: {
title: 'IOperations',
description: 'Update operation list',
type: 'array',
minItems: 1,
maxItems: 1,
items: {
$ref: '#/$defs/operation',
},
},
operation: {
title: 'IOperation',
description: 'Update operation',
type: 'object',
additionalProperties: true,
required: [
'action',
'data',
'id',
'parentID',
],
properties: {
action: {
// 操作活动类型: 更新
type: 'string',
const: 'update',
description: 'operation action type',
},
data: {
// 所更新内容的 HTML DOM 文本
type: 'string',
description: 'HTML DOM of updating blocks',
},
id: {
// 更新的块 ID
type: 'string',
description: 'ID of the block to be updated',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/updateBlock/response.schema.json",
"$comment": "v2.10.6",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Update a block",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Update transactions",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/transaction"
}
},
"transaction": {
"title": "ITransaction",
"description": "Update transaction",
"type": "object",
"additionalProperties": false,
"required": [
"timestamp",
"doOperations",
"undoOperations"
],
"properties": {
"timestamp": {
"type": "integer",
"description": "timestamp"
},
"doOperations": {
"$ref": "#/$defs/operations"
},
"undoOperations": {
"type": "null",
"description": "undo operation list"
}
}
},
"operations": {
"title": "IOperations",
"description": "Update operation list",
"type": "array",
"minItems": 1,
"maxItems": 1,
"items": {
"$ref": "#/$defs/operation"
}
},
"operation": {
"title": "IOperation",
"description": "Update operation",
"type": "object",
"additionalProperties": true,
"required": [
"action",
"data",
"id",
"parentID"
],
"properties": {
"action": {
"type": "string",
"const": "update",
"description": "operation action type"
},
"data": {
"type": "string",
"description": "HTML DOM of updating blocks"
},
"id": {
"type": "string",
"description": "ID of the block to be updated",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
}
}