节点属性定义规范请参考:OpenAPI Specification v3.1.0
节点总览

1.块节点(Block)
interface IBlock {
id: string; // 查询可获得,凭此进行块相关操作
type: string; // 块节点类型
attrs: Record<string, any>; // 块属性
content?: IBlock[]|IInline[] // 块内容
}1.文档标题(title)
全文档唯一,且必须为doc的第一个子块
Attrs:
type: object
properties:
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐2.段落(paragraph)
分为普通段落,有序列表段落、无序列表段落和任务列表段落
Attrs:
type: object
properties:
indent:
type: integer
enum: [0, 1]
default: 0
description: 首行缩进
contentIndent:
type: integer
minimum: 0
default: 0
description: 内容缩进
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐
listAttrs:
type: object
description: 列表属性
properties:
id:
type: string
description: 编号树id
type:
type: integer
enum: [1, 2, 3]
description: |
列表类型
1 - 无序列表
2 - 有序列表
3 - 任务列表
styleType:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
description: |
列表项标记的类型(type有值时必填)
type=1 时:
1 - 实心点
2 - 空心点
3 - 方块
type=2 时:
4 - 阿拉伯数字
5 - 字母
6 - 罗马数字
9 - 大写字母
10 - 大写罗马数字
11 - 圆圈数字
12 - 中文数字
13 - 大写中文数字
type=3 时:
7 - 未勾选
8 - 勾选
level:
type: integer
minimum: 0
description: 列表级别
styleFormat:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9]
description: |
列表分隔项类型
1 - {0}.
2 - {0}、
3 - {0}]
4 - {0}】
5 - {0})
6 - ({0})
7 - 【{0}】
8 - [{0}]
9 - {0}3.标题(heading)
标题1-6,注意不是文档的标题。
Attrs:
type: object
properties:
level:
type: integer
enum: [1, 2, 3, 4, 5, 6]
default: 1
description: 标题级别
indent:
type: integer
enum: [0, 1]
default: 0
description: 首行缩进
contentIndent:
type: integer
minimum: 0
default: 0
description: 内容缩进
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐
listAttrs:
type: object
description: 列表属性
properties:
id:
type: string
description: 编号树id
type:
type: integer
enum: [1, 2, 3]
description: |
列表类型
1 - 无序列表
2 - 有序列表
3 - 任务列表
styleType:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
description: |
列表项标记的类型(type有值时必填)
type=1 时:
1 - 实心点
2 - 空心点
3 - 方块
type=2 时:
4 - 阿拉伯数字
5 - 字母
6 - 罗马数字
9 - 大写字母
10 - 大写罗马数字
11 - 圆圈数字
12 - 中文数字
13 - 大写中文数字
type=3 时:
7 - 未勾选
8 - 勾选
level:
type: integer
minimum: 0
description: 列表级别
styleFormat:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9]
description: |
列表分隔项类型
1 - {0}.
2 - {0}、
3 - {0}]
4 - {0}】
5 - {0})
6 - ({0})
7 - 【{0}】
8 - [{0}]
9 - {0}4.引用(blockQuote)
Attrs:
type: object
properties:
indent:
type: integer
enum: [0, 1]
default: 0
description: 首行缩进
contentIndent:
type: integer
minimum: 0
default: 0
description: 内容缩进
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中对齐
3 - 右对齐5.代码块(codeBlock)
CodeBlockAttrs:
type: object
properties:
lang:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]
default: 1
description: |
语言类型
1 - plaintext
2 - css
3 - go
4 - python
5 - shell
6 - objectivec
7 - markdown
8 - lua
9 - scss
10 - less
11 - swift
12 - typescript
13 - sql
14 - ruby
15 - http
16 - java
17 - json
18 - php
19 - javascript
20 - c-like
21 - xml
22 - fortran
23 - r
24 - cmake
25 - bash
26 - csharp
27 - dockerfile
28 - julia
29 - latex
30 - makefile
31 - matlab
32 - rust
33 - nginx
34 - dart
35 - erlang
36 - groovy
37 - haskell
38 - kotlin
39 - lisp
40 - perl
41 - scala
42 - scheme
43 - yaml
autoWrap:
type: boolean
default: true
description: 自动换行
theme:
type: integer
enum: [1, 2]
default: 1
description: |
主题
1 - 亮色主题
2 - 暗色主题- 仅代码块中的text节点可包含换行符\n
6.高亮块(highLightBlock)
通常用于美化文档结构或突出重要内容
Attrs:
type: object
required:
- emoji
properties:
emoji:
type: string
description: 表情
style:
type: object
description: 高亮块样式
properties:
fontColor:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
description: |
字体颜色
1 - 黑色
2 - 灰色
3 - 红色
4 - 粉色
5 - 橙色
6 - 黄色
7 - 绿色1
8 - 绿色2
9 - 绿色3
10 - 蓝色1
11 - 蓝色2
12 - 紫色
backgroundColor:
type: integer
enum: [1, 2, 3, 4, 5, 6]
description: |
背景颜色
1 - 灰色
2 - 粉色
3 - 橙色
4 - 绿色
5 - 蓝色
6 - 紫色
borderColor:
type: string
description: 边框颜色,rgb(a)十六进制代码,如"#112233"7.内容保护区(lockBlock)
区域中的内容仅文件创建者可以编辑。无属性
8.表格(table)
Attrs:
type: object
properties:
borderStyle:
type: integer
enum: [1, 2]
description: |
边框样式
1 - 无边框
2 - 实线8.1.表格行(tableRow)
单元格的容器。无属性
8.1.1.单元格(tableCell)
Attrs:
type: object
properties:
width:
type: number
description: 宽度(同列单元格宽度需一致)
height:
type: number
description: 高度(同行单元格高度需一致)
colspan:
type: integer
minimum: 1
default: 1
description: 合并列数(为1代表不合并)
rowspan:
type: integer
minimum: 1
default: 1
description: 合并行数(为1代表不合并)
verticalAlign:
type: integer
enum: [1, 2, 3]
default: 1
description: |
垂直对齐方式
1 - 顶端对齐
2 - 垂直居中
3 - 底端对齐9.分栏(column)
分栏列的容器,支持1-10个分栏列
Attrs:
type: object
properties:
backgroundColor:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
description: |
背景颜色(作为未设置背景颜色或新增的分栏列的默认背景)1-6为单色,7-12为多色9.1.分栏列(columnItem)
Attrs:
type: object
properties:
width:
type: string
description: 宽度(至多两位小数的百分比字符串)
backgroundColor:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42]
description: 背景颜色分栏背景颜色说明
如下图所示,1-6为单色,7-12为多色(每组6个颜色),共42种颜色类型

10.并排图(pictureColumn)
可将多张图片并排展示,支持2-5张图片
Attrs:
type: object
properties:
width:
type: number
exclusiveMinimum: 0
maximum: 100
description: 宽度(百分比单位)
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐11.图片(picture)
图片资源id可通过附件传接口获得
Attrs:
type: object
required:
- sourceKey
- width
- height
properties:
sourceKey:
type: string
description: 图片资源id
width:
type: number
description: 图片原始宽度
height:
type: number
description: 图片原始高度
renderWidth:
type: number
description: 图片渲染宽度
caption:
type: string
description: 图片描述
rotate:
type: integer
enum: [0, -90, -180, -270]
description: 旋转角度(单位:deg)
borderType:
type: integer
enum: [0, 1]
default: 0
description: |
边框类型
0 - 无边框
1 - 灰色1px边框
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐12.占位节点(blockAnchor)
可作为图片等节点的占位,调用ReplaceAnchor替换为占位目标。前端显示为loading样式。
Attrs:
type: object
required:
- id
- aimType
- width
- height
properties:
id:
type: string
description: 占位id(用于替换的标识)
aimType:
type: string
enum: ['picture', 'video', 'processon', 'spreadsheet']
description: 占位目标类型
width:
type: number
description: 占位宽度
height:
type: number
description: 占位高度- blockAnchor是否能存在于某个块容器内,取决于它的aimType
13.分隔线(hr)
对应前端插入列表中的分隔线。无属性
14.音视频类
14.1.视频(video)
视频资源id和视频封面图id可通过附件上传接口获得
Attrs:
type: object
required:
- sourceId
- sourceKey
- width
- height
properties:
sourceId:
type: string
description: 视频资源id
sourceKey:
type: string
description: 视频封面图id
width:
type: number
description: 视频原始宽度
height:
type: number
description: 视频原始高度
title:
type: string
description: 视频文件名
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐14.2.音频(audio)
音频资源id可通过附件上传接口获得
Attrs:
type: object
required:
- sourceId
properties:
sourceId:
type: string
description: 音频资源id
title:
type: string
description: 音频标题14.3.videoLink
Attrs:
type: object
required:
- url
properties:
url:
type: string
description: 视频资源链接
platform:
type: integer
enum: [1]
default: 1
description: |
资源平台
1 - bilibili
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐15.应用类
15.1.倒计时(countdown)
Attrs:
type: object
required:
- type
properties:
type:
type: integer
enum: [1, 2]
description: |
倒计时模式
1 - 日期模式
2 - 时间模式
duration:
type: integer
minimum: 0
maximum: 86399999000
default: 0
description: 倒计时时长(毫秒单位)15.2.地图(map)
目前支持高德地图
Attrs:
type: object
required:
- lng
- lat
- address
- addressName
properties:
lng:
type: number
minimum: -180
maximum: 180
description: 经度
lat:
type: number
minimum: -90
maximum: 90
description: 纬度
address:
type: string
description: 详细地址描述
addressName:
type: string
description: 地点名称
platform:
type: integer
enum: [1]
default: 1
description: |
地图平台
1 - 高德地图
mapZoom:
type: integer
description: 地图缩放尺度
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐15.3.第三方资源(thirdResource)
ThirdResourceAttrs:
type: object
required:
- url
properties:
url:
type: string
description: 资源链接(对应资源类型正确的url)
type:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9]
default: 1
description: |
1 - 慕客
2 - 墨刀
3 - masterGo
4 - 网易云音乐
5 - 阿里云盘视频
6 - 意向收集
7 - figma
8 - pixso
9 - 小画桌
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中对齐
3 - 右对齐15.4.多维表(dbsheet)
Attrs:
type: object
required:
- sourceId
properties:
sourceId:
type: string
description: 多维表id
width:
type: number
description: 宽度
height:
type: number
description: 高度15.5.电子表格(spreadsheet)
Attrs:
type: object
required:
- sourceId
properties:
sourceId:
type: string
description: 电子表格id
sheetId:
type: integer
default: 0
description: 电子表格索引id15.6.群名片(groupCard)
Attrs:
type: object
required:
- id
- name
- masterName
properties:
id:
type: string
description: 群名片id
name:
type: string
description: 群名
masterName:
type: string
description: 群主名15.7.appComponent
Attrs:
type: object
properties:
type:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8]
default: 1
description: |
插件类型
1 - 投票
2 - 视频号
3 - 关注文档更新
4 - 内部特定插件
5 - 数据联动
6 - 金山待办
7 - 文档数据看板
8 - 画板15.8.流程图/思维导图(processon)
预览图id可通过附件上传接口获得
Attrs:
type: object
required:
- type
- sourceId
- sourceKey
- width
- height
properties:
type:
type: integer
enum: [1, 2]
description: |
po类型
1 - 流程图
2 - 思维导图
sourceId:
type: string
description: 元数据id
sourceKey:
type: string
description: 预览图id
caption:
type: string
description: po描述
rotate:
type: integer
enum: [0, -90, -180, -270]
default: 0
description: po旋转角度
width:
type: number
description: po原始宽度
height:
type: number
description: po原始高度
renderWidth:
type: number
description: po渲染宽度
borderType:
type: integer
enum: [0, 1]
default: 0
description: |
边框类型
0 - 无边框
1 - 灰色边框
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
水平对齐方式
1 - 左对齐
2 - 居中
3 - 右对齐2.内联节点(Inline)
interface IInline {
type: string // 节点类型
attrs: Record<string, any> // 节点属性
content?: string; // 仅text节点有该字段
}1.文本(text)
文本。text节点的内容是一个非空字符串。特别说明:仅代码块(codeBlock)下的text可携带换行符\n
2.云文档/本地文件(WPSDocument)
云文档与本地文件共用该节点,作为云文档时可切换视图展示。
属性wpsDocumentId可通过附件上传接口获得
Attrs:
type: object
required:
- wpsDocumentId
- wpsDocumentName
- wpsDocumentType
properties:
wpsDocumentId:
type: string
description: 云文档(本地文件)id
wpsDocumentName:
type: string
description: 云文档(本地文件)名
wpsDocumentType:
type: string
description: 云文档(本地文件)类型
wpsDocumentLink:
type: string
description: 云文档链接(http、https协议头的超链接,本地文件无此属性,云文档必填)
viewType:
type: integer
enum: [1, 2, 3, 4]
default: 1
description: |
云文档视图
1 - 标题视图
2 - 预览视图(该视图下,父块必须是paragraph,且不能有兄弟节点)
3 - 卡片视图(该视图下,父块必须是paragraph,且不能有兄弟节点)
4 - 附件视图(本地文件请选择该视图,该视图下,父块必须是paragraph,且不能有兄弟节点)
size:
type: integer
exclusiveMinimum: 0
description: 本地文件大小(单位Byte,云文档无此属性,本地文件必填)
width:
type: number
description: 预览视图窗口宽度(推荐400-800)
height:
type: number
description: 预览视图窗口高度(推荐400-800)
align:
type: integer
enum: [1, 2, 3]
default: 1
description: |
预览视图水平对齐方式
1 - 左对齐
2 - 居中对齐
3 - 右对齐3.表情符号(emoji)
对应前端插入列表中的表情符号
Attrs:
type: object
required:
- emoji
properties:
emoji:
type: string
description: 表情(单个emoji表情,AP不支持的emoji回落为text节点)4.引用换行(br)
引用块中的换行
5.公式(latex)
对应前端插入列表中的公式
Attrs:
type: object
required:
- width
- height
- latexStr
properties:
width:
type: number
description: 宽度
height:
type: number
description: 高度
latexStr:
type: string
description: latex公式字符串6.超链接视图(linkView)
超链接的标题/卡片视图,可带图标和描述
图标id可通过附件上传接口获得
Attrs:
type: object
required:
- title
- url
- viewType
- sourceKey
- description
properties:
title:
type: string
description: 标题
url:
type: string
description: 超链接(http(s)://开头的链接)
viewType:
type: integer
enum: [1, 2]
description: |
视图
1 - 标题视图
2 - 卡片视图(该视图下,父块必须是paragraph,且不能有兄弟节点)
sourceKey:
type: string
description: 图标id
description:
type: string
description: 超链接描述7.日程(schedule)
Attrs:
type: object
required:
- id
- name
- startTime
- endTime
properties:
id:
type: string
description: 日程组合id(组合方式:日程的taskId+'|'+sid+'|'+teamId)
name:
type: string
description: 日程名字
startTime:
type: number
description: 日程开始时间(unix毫秒时间戳)
endTime:
type: number
description: 日程结束时间(unix毫秒时间戳)
actionType:
type: integer
enum: [1, 2]
default: 1
description: |
日程类型
1 - 非全天
2 - 全天8.日期(staticTime)
Attrs:
type: object
required:
- time
properties:
time:
type: number
description: 时间(unix毫秒时间戳)
timeType:
type: integer
enum: [1, 2]
default: 1
description: |
时间类型
1 - 日期
2 - 日期时间9.@人(WPSUser)
Attrs:
type: object
required:
- userId
- name
properties:
userId:
type: string
description: 用户id
name:
type: string
description: 用户名
avatar:
type: string
description: 用户头像地址内联节点通用属性
Attrs:
type: object
description: 内联节点通用属性(文档标题和代码块里的text节点不支持设置通用属性)
properties:
bold:
type: boolean
default: false
description: 加粗
italic:
type: boolean
default: false
description: 斜体
underline:
type: boolean
default: false
description: 下划线
strike:
type: boolean
default: false
description: 删除线
sup:
type: boolean
default: false
description: 上标
sub:
type: boolean
default: false
description: 下标
fontSize:
type: object
properties:
fontSize:
type: number
enum: [9, 11, 13, 15, 16, 19, 22]
default: 11
description: 字号(单位:pt)
color:
type: object
properties:
fontColor:
type: string
enum: ['#080F17', '#C21C13', '#DB7800', '#078654', '#0E52D4', '#0080A0', '#757575', '#DA326B', '#D1A300', '#58A401', '#116AF0', '#A639D7']
description: 字体颜色
backgroundColor:
type: string
enum: ['#FBF5B3', '#F8D7B7', '#F7C7D3', '#DFF0C4', '#C6EADD', '#D9EEFB', '#D5DCF7', '#E6D6F0', '#E6E6E6']
description: 背景颜色
fontGradientColor:
type: integer
enum: [1, 2, 3, 4, 5, 6]
description: |
字体渐变色
1 - 殷红琥珀
2 - 浅烙翡翠
3 - 海涛魏紫
4 - 金盏糖蓝
5 - 蔚蓝桃红
6 - 梦幻极光- 文档标题(title)和代码块(title)里的text节点不支持设置通用属性
- 在内联容器上设置通用属性,等价于为内联容器中每个内联节点设置通用属性
fontColor、backgroundColor请勿使用取值范围外的值,否则可能不生效。
3.区间信息
用于表示区间等信息,不是真实存在的节点,调用api若涉及到index,需要忽略虚拟节点。
interface IRangeMark {
type: string; // rangeMarkBegin/rangeMarkEnd
id: string; // 用于配对的id
data?: IRangeData[]; // 仅rangeMarkBegin携带
}
interface IRangeData {
type: string;
ids: string[];
}1.rangeMarkBegin
区间标识的起点,携带区间额外的数据,比如评论。需和rangeMarkEnd配对使用,以id作为唯一标识。
rangeMarkBegin:
type: object
required:
- id
- data
properties:
id:
type: string
description: rangeMarkBegin的id,用于与rangeMarkEnd进行配对
data:
type: array
description: rangeMark携带的数据
items:
type: object
required:
- type
- ids
properties:
type:
type: string
enum: ['comment']
description: 数据类型
ids:
type: array
items:
type: string
description: 对应的评论id2.rangeMarkEnd
区间标识的终点,和rangeMarkBegin配对使用,以id作为唯一标识
rangeMarkEnd:
type: object
required:
- id
properties:
id:
type: string
description: rangeMarkEnd的id,用于与rangeMarkBegin进行配对