1.支持的节点类型
2.数据结构
// 导入的数据结构
interface ImportJSON
{
title_data: {
is_insert: boolean
is_insert_begin: boolean
content: [](INode|IRangeMark)
},
main_body_data: { // content不能是行内结点
is_insert: boolean
is_insert_begin: boolean
content: [](INode|IRangeMark)
},
doc_attrs?: any,
comments?: []IComment
}
// 结点
interface INode {
type: string
attrs?: {
[key:string]: string | boolean | number | object
}
content?: string | [](INode|IRangeMark) | null
}
// rangeMarkBegin和rangeMarkEnd配对使用,标识已特定区间,比如评论
interface IRangeMark {
type: string // rangeMarkBegin | rangeMarkEnd
id: number
data?: []{
type: string // comment
ids: []string
}
}
// 评论
interface IComment {
id: string
userId: string
resolved: boolean // 是否已解决
content: []INode
time?: number
replys?: []IComment // 回复
}
- INode详见结点清单
- comment详见评论
- doc_attrs详见文档属性
3.导入结构检查❗❗❗
JSON导入接口会按此文档进行严格的数据结构校验,在使用此结构时,建议按此文档进行入参检查。若检查失败,接口会返回失败信息,请根失败信息进行调用调整。
以下是部分结构错误导致的调用返回示例:
3.1 示例1 - 入参的节点类型是否是支出导入的
3.1.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "groupCard",
"attrs": {
"id": "2327281,8yrkdJj0byz",
"name": "一个人的群聊",
"masterName": "陈洋"
}
}
]
}
}
3.1.2 错误原因
不支持 groupCard
类型
3.2 示例2 - 入参的节点嵌套格式是否是允许的
3.2.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "1x1合并单元格表格"
}
]
}
]
}
]
}
]
}
}
3.2.2 错误原因
paragraph
节点不支持嵌套在 tableRow
节点中
3.3 示例3 - 入参的节点必填属性是否都已设置
3.3.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "picture",
"attrs": {
"sourceKey": "AC6GUAYASE",
"height": 156.38,
"version": 3
}
}
]
}
}
3.3.2 错误原因
必填属性缺失。width
属性是 picture
节点的必填属性
3.4 示例4 - 入参的节点属性数据类型是否符合
3.4.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "picture",
"attrs": {
"sourceKey": "AC6GUAYASE",
"width": "278",
"height": 156.38,
"version": 3
}
}
]
}
}
3.4.2 错误原因
width
属性是 number
类型,却被定义为 string
类型
3.5 示例5 - 入参的节点属性取值范围是否越界
3.5.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "普通居中段落"
}
],
"attrs": {
"align": 6
}
}]
}
}
3.5.2 错误原因
paragraph
节点的 align
属性越界
3.6 示例6 - 评论跨域了标题和正文
3.6.1 错误入参示例
{
"title_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment",
"ids": [
"comment1-1"
]
}
]
},
{
"type": "text",
"content": "Title Text标题区"
}
]
},
"main_body_data": {
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "我是文本内容,我是文本内容,我是文本内容,我是文本内容",
"attrs": {
"fontSize": {
"fontSize": 16
}
}
},
{
"type": "rangeMarkEnd",
"id": "mark1"
}
],
"attrs": {}
},
{
"type": "paragraph",
"attrs": {}
}
]
},
"comments": [
{
"id": "comment1-1",
"userId": "250005300",
"content": [
{
"type": "text",
"content": "评论内容"
}
]
}
]
}
3.6.2 错误原因
评论节点无法跨越标题和正文
3.7 示例7 - rangeMarkBegin结构无效,例如缺少了id或者data
3.7.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin"
}
]
}
}
3.7.2 错误原因
rangeMarkBegin
节点无效
3.8 示例8 - rangeMarkBegin自身的id重复
3.8.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment",
"ids": [
"comment1-1"
]
}
]
},
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment",
"ids": [
"comment2-1"
]
}
]
}
]
}
}
3.8.2 错误原因
rangeMarkBegin
节点的 id
属性重复
3.9 示例9 - rangeMarkBegin存在type为comment的data,但是未传入对应的ids
3.9.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment"
}
]
}
]
}
}
3.9.2 错误原因
rangeMarkBegin存在type为comment的data,但是未传入对应的ids
3.10 示例10 - rangeMarkBegin的data中comment id重复
3.10.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment",
"ids": [
"comment1-1"
]
}
]
},
{
"type": "rangeMarkBegin",
"id": "mark2",
"data": [
{
"type": "comment",
"ids": [
"comment1-1"
]
}
]
}
]
}
}
3.10.2 错误原因
两个 rangeMarkBegin
节点的 comment
属性 ids
字段重复
3.11 示例11 - comment id在comment body里无对应数据
3.11.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment",
"ids": [
"comment1-1"
]
}
]
}
]
},
"comments": [
{
"id": "comment2-1",
...
}
]
}
3.11.2 错误原因
comment1-1
在 comments
body 中无数据
3.12 示例12 - angeMarkEnd缺少id
3.12.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkEnd"
}
]
}
}
3.12.2 错误原因
rangeMarkEnd
节点无数据
3.13 示例13 - rangeMarkEnd的id重复
3.13.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkEnd",
"id": "mark1"
},
{
"type": "rangeMarkEnd",
"id": "mark1"
}
]
}
}
3.13.2 错误原因
rangeMarkEnd
节点的 id
重复
3.14 示例14 - rangeMarkBegin没有对应的rangeMarkEnd
3.14.1 错误入参示例
{
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1"
},
// 后续没有对应的rangeMarkEnd
]
}
}
3.14.2 错误原因
只有 rangeMarkBegin
没有对应的 rangeMarkEnd
节点
3.15 示例15 - rangeMarkEnd没有对应的rangeMarkBegin
3.15.1 错误入参示例
{
"main_body_data": {
"content": [
// 前面没有对应的rangeMarkBegin
{
"type": "rangeMarkEnd",
"id": "mark1"
}
]
}
}
3.15.2 错误原因
只有 rangeMarkEnd
没有对应的 rangeMarkBegin
节点
3.16 示例16 - comment body里,重复的id超过最大限制100
3.16.1 错误入参示例
{
"comments": [
{
"id": "comment1"
},
{
"id": "comment1"
}
// .. 重复的id超过了100
]
}
3.16.2 错误原因
comment body里,重复的id超过最大限制100
3.17 示例17 - comment body里没有传入userId
3.17.1 错误入参示例
{
"comments": [
{
"id": "comment1",
"resolved": false,
"content": [
{
"type": "text",
"content": "评论1"
}
]
}
]
}
3.17.2 错误原因
comments
里没有传入 userId
3.18 示例18 - comment body里的content为空
3.18.1 错误入参示例
{
"comments": [
{
"id": "comment1-1",
"userId": "240002600",
"resolved": false,
"content": []
}
]
}
3.18.2 错误原因
comment1-1
没有传入 content
4.结点INode
4.1 行内内容节点
行内内容节点请勿直接填入mainBody中,应填入段节点的content中
4.1.1 text
普通文本节点
text节点content不允许为空字符串
text节点仅在codeBlock里可以传入\n
{
"type": "text",
"attrs": {},
"content": "xxx"
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
code | 行内代码块 | false | bool | -- | false |
link | 超链接 | false | object | -- | -- |
attrs.link
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
href | 超链接跳转地址 | false | string | -- | -- |
hrefTitle | 超链接标题 | false | string | -- | -- |
4.1.2 WPSUser
联系人
{
"type": "WPSUser",
"attrs": {}
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
userId | 用户id | true | string | -- | -- |
name | 用户名 | true | string | -- | -- |
avatar | 用户头像地址 | false | string | -- | -- |
4.1.3 staticTime
静态时间
{
"type": "staticTime",
"attrs": {}
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
time | 毫秒级时间戳 | true | int | -- | -- | |
timeType | 时间类型 | false | enum | 1 | 日期 | 1 |
2 | 日期时间 |
4.1.4 WPSDocument
云文档/本地附件
当传入wpsDocumentType不在AP支持的范围内时,此节点回落为普通超链接文本。
version与上传附件时的接口有关,version不对可能导致附件的交互出错
当云文档视图非标题视图时,其父节点只能为paragraph,且不能有其他兄弟节点
{
"type": "WPSDocument",
"attrs": {}
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
wpsDocumentId | 云文档id | true | string | -- | -- | |
wpsDocumentName | 云文档名字 | true | string | -- | -- | |
wpsDocumentType | 云文档文件类型 | true | string | -- | -- | |
wpsDocumentLink | 云文档链接 | true(附件无云文档链接可不填) | string | http、https协议头的超链接 | -- | |
viewType | 云文档视图 | false | enum | 1 | 标题视图 | 1 |
2 | 预览视图 | 2 | ||||
3 | 卡片视图 | 3 | ||||
4 | 附件视图 | 4 | ||||
size | 附件大小,仅附件视图有效 | 附件视图时必填 | int | (0, +∞) | -- | |
version | 存储版本 | false | int | [1,2] | 2 |
4.1.5 schedule
日程
{
"type": "schedule",
"attrs": {}
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
id | 日程组合id (组合方式:日程的taskId+'|' +sid +'|' + teamId) | true | string | -- | -- | |
name | 日程名字 | true | string | -- | -- | |
startTime | 日程开始时间 | true | int | 毫秒级时间戳 | -- | |
endTime | 日程结束时间 | true | int | 毫秒级时间戳 | -- | |
actionType | 日程类型 | false | enum | 1 | 非全天 | 1 |
2 | 全天 |
4.1.6 emoji
emoji表情
不符合AP支持的emoji,回落为普通文本
{
"type": "emoji",
"attrs": {}
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
emoji | emoji表情文本 | true | string | 单个emoji | -- |
4.1.7 latex
latex公式
{
"type": "latex",
"attrs": {
"width": 36,
"height": 20,
"latexStr": "\\sqrt[n]{ab}"
}
}
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
width | 宽度 | true | string | 正数 | -- | |
height | 高度 | true | string | 正数 | -- | |
latexStr | latex公式字符串 | true | string | -- | -- |
4.1.8 通用属性
如果行内节点的通用属性设置在了段节点上,那么段节点的所有行内节点都会设置上
title_data 的 text 节点,不支持设置任何属性(包括通用属性),即attrs不存在或为空对象
codeBlock节点中 的 text 节点,不支持设置任何属性(包括通用属性),即attrs不存在或为空对象
fontColor、backgroundColor请勿使用取值范围外的值,否则可能不生效。
文本样式属性
属性名 | 描述 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|
bold | 加粗 | bool | -- | false |
italic | 斜体 | bool | -- | false |
underline | 下划线 | bool | -- | false |
strike | 删除线 | bool | -- | false |
sup | 上标 | bool | -- | false |
sub | 下标 | bool | -- | false |
fontSize (字号)
属性名 | 描述 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|
fontSize | 字号(单位:pt) | number | (0, ∞) | 11 |
color (颜色样式)
属性名 | 描述 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|
fontColor | 字体颜色 | string | #080F17 、#C21C13 、#DB7800 、#078654 、#0E52D4 、#0080A0 、#757575 、#DA326B 、#D1A300 、#58A401 、#116AF0 、#A639D7 | -- |
backgroundColor | 背景颜色 | string | #FBF5B3 、#F8D7B7 、#F7C7D3 、#DFF0C4 、#C6EADD 、#D9EEFB 、#D5DCF7 、#E6D6F0 、#E6E6E6 | -- |
fontGradientColor | 字体渐变色 | enum | 1. 殷红琥珀 2. 浅烙翡翠 3. 海涛魏紫 4. 金盏糖蓝 5. 蔚蓝桃红 6. 梦幻极光 | -- |
4.1.9 示例
4.1.9.1 text
JSON 示例 1
{
"type": "text",
"content": "普通文本"
}
JSON 示例 2
{
"type": "text",
"content": "超链接",
"attrs": {
"link": {
"href": "https://www.kdocs.cn",
"hrefTitle": "超链接"
}
}
}
JSON 示例 3
{
"type": "text",
"content": "加粗加大文本",
"attrs": {
"bold": true,
"fontSize": {
"fontSize": 13
}
}
}
JSON 示例 4
{
"type": "text",
"content": "行内代码块",
"attrs": {
"code": true
}
}
JSON 示例 5
{
"type": "text",
"content": "黄底红字文本",
"attrs": {
"color": {
"fontColor": "#FBF5B3",
"backgroundColor": "#C21C13"
}
}
}
JSON 示例 6
{
"type": "text",
"content": "渐变色文本",
"attrs": {
"color": {
"fontGradientColor": 1
}
}
}
4.1.9.2 WPSUser
JSON 示例 1
{
"type": "WPSUser",
"attrs": {
"userId": "1388384431",
"name": "陈洋"
}
}
4.1.9.3 staticTime
JSON 示例 1
{
"type": "staticTime",
"attrs": {
"time": 1666713600000
}
}
JSON 示例 2
{
"type": "staticTime",
"attrs": {
"time": 1666713600000,
"timeType": 2
}
}
4.1.9.4 WPSDocument
JSON 示例 1
{
"type": "WPSDocument",
"attrs": {
"wpsDocumentId": "xxxxxxxx",
"wpsDocumentName": "AP写入JSON数据-节点属性配置项说明文档v2.otl",
"wpsDocumentType": "otl",
"wpsDocumentLink": "https://www.kdocs.cn/l/coSdlIEkSmwc"
}
}
4.1.9.4 schedule
JSON 示例 1
{
"type": "schedule",
"attrs": {
"id": "101199635|e_0E4CbNlpi|69743236",
"name": "示例日程",
"startTime": 1717574400000,
"endTime": 1717574700000
}
}
JSON 示例 2
{
"type": "schedule",
"attrs": {
"id": "101199867|e_0hOdQNjb1|69743236",
"name": "示例日程(全天)",
"startTime": 1717603199000,
"endTime": 1717603199000,
"actionType": 2
}
}
4.1.9.5 emoji
JSON 示例
{
"type": "emoji",
"attrs": {
"emoji": "🚩"
}
}
4.1.9.6 latex
JSON 示例
{
"type": "latex",
"attrs": {
"width": 36,
"height": 20,
"latexStr": "\\sqrt[n]{ab}"
}
}
4.2 块级内容节点
4.2.1 picture
图片
使用接口上传的图片,version属性与传参相关
{
"type": "picture",
"attrs": {
"sourceKey": "AC6GUAYASE",
"width": 2048,
"height": 1152,
"version": 3
}
}
示例👇
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 说明 | 默认值 |
---|---|---|---|---|---|---|
sourceKey | 图片资源 ID | true | string | -- | -- | -- |
width | 图片原始宽度 | true | number | -- | -- | -- |
height | 图片原始高度 | true | number | -- | -- | -- |
renderWidth | 图片渲染宽度 | false | number | -- | -- | -- |
rotate | 旋转角度(单位:deg) | false | int | [0, -90, -180, -270] | -- | -- |
borderType | 边框类型 | false | enum | 0 | 无边框 | 0 |
1 | 灰色 1px 边框 | |||||
align | 水平对齐方式 | false | enum | 1 | 左对齐 | 1 |
2 | 居中 | |||||
3 | 右对齐 | |||||
version | 图片版本 | false | int | 1 | 已不支持新增 | 2 |
2 | 对象存储的图片 | |||||
3 | 基础存储的图片 |
4.2.2 procession
流程图/思维导图
{
"type": "processon",
"attrs": {
"type": 2,
"sourceId": "PQYBL2YZADQDQ",
"sourceKey": "UE2BL2YZAAAHG",
"width": 1499,
"height": 616
}
}
流程图示例👇
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
type | po类型 | 是 | enum | 1 : 流程图2 : 思维导图 | -- |
sourceId | po资源id | 是 | string | -- | -- |
sourceKey | 图片资源id | 是 | string | -- | -- |
width | 图片原始宽度(必传,否则影响预览效果) | 是 | number | -- | -- |
height | 图片原始高度(必传,否则影响预览效果) | 是 | number | -- | -- |
renderWidth | 图片渲染宽度 | 否 | number | -- | -- |
borderType | 边框类型 | 否 | enum | 0 : 无边框1 : 灰色边框 | 0 |
align | 水平对齐方式 | 否 | enum | 1 : 左对齐2 : 居中3 : 右对齐 | 1 |
4.2.3 video
视频
{
"type": "video",
"attrs": {
"sourceId": "asdfghjklqwertyuiopzxcvbnm",
"sourceKey": "ababasdfghjkl",
"width": 500,
"height": 288,
}
}
示例👇
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
sourceId | 视频资源 id | true | string | -- | -- |
sourceKey | 视频封面图资源 id | true | string | -- | -- |
width | 视频原始宽度 | true | number | -- | -- |
height | 视频原始高度 | true | number | -- | -- |
title | 视频文件名 | false | string | -- | -- |
align | 水平对齐方式 | false | enum | 1:左对齐 2:居中 3:右对齐 | 1 |
4.2.4 hr
分隔线
{
"type": "hr"
}
示例👇
4.2.5 countdown
倒计时
{
"type": "countdown",
"attrs": {
"timestamp": 1720777977001,
"duration": 86395000
}
}
示例👇
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
type | 倒计时模式 | true | int | 1:日期模式 2:时间模式 | -- |
duration | 倒计时时长 | 与 endTimestamp 必填一个 | int | 毫秒级时间 | -- |
endTimestamp | 倒计时结束时间 | 与 duration 必填一个 | int | 毫秒级时间 | -- |
4.2.6 dbsheet
轻维表
使用接口创建dbsheet,version属性与传参相关
{
"type": "dbsheet",
"attrs": {
"sourceId": "MKECB2YZADQF2"
}
}
示例👇
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
sourceId | 轻维表id | true | string | -- | -- | |
version | 存储版本 | false | int | -- | 2 |
4.2.7 spreadsheet
电子表格
{
"type": "spreadsheet",
"attrs": {
"sourceId": "ZFWSB2YZACAEY"
}
}
示例👇
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
sourceId | 电子表格id | true | string | -- | -- | |
version | 存储版本 | false | int | -- | 2 |
*使用接口创建spreadsheet,version属性与传参相关
4.2.8 appComponent
应用组件-投票组件
{
"type": "appComponent",
"attrs": {
"type": 1,
"metaData": {
"id": "100000001234",
"title": "这是一个投票",
"options": [
{
"value": "选项1",
"selectId": "100001"
},
{
"value": "选项2",
"selectId": "100002"
}
]
}
}
}
示例👇
attrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
type | 应用组件类型 (1 - 投票) | true | int | [1] | -- |
metaData | 应用组件数据 | true | object | (见二级属性表) | -- |
attrs.metaData
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
id | 投票 id | true | string | -- | -- |
title | 投票标题 | true | string | -- | -- |
options | 投票选项 | true | [] object(数组对象) | minLen: 1(至少 1 项) | -- |
anonymous | 是否匿名 | false | bool | false/true | false |
multiType | 投票类型 | false | string | -- | -- |
voteResultShow | 投票结果显示方式 | false | string | -- | -- |
attrs.metaData.options
字段说明
子元素属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
value | 选项值 | true | string | -- | -- |
selectId | 选项 id | true | string | -- | -- |
4.2.9 blockAnchor
块级占位
{
"type": "blockAnchor",
"attrs": {
"aimType": "picture",
"width": 200,
"height": 100,
"id": "asdfghjklqwertyuio"
}
}
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
aimType | 占位目标类型 | true | string | picture 、video 、processon 、spreadsheet | -- | |
width | 占位宽度 | true | number | -- | -- | |
height | 占位高度 | true | number | -- | -- | |
id | 占位 id | true | string | -- | -- |
4.3 段节点
4.3.1 注意事项
传入的content是string时,默认生成text行内节传入的content是array时,里面的节点都必须是行内节点,除非特别约定
4.3.2 paragraph
普通段落
{
"type": "paragraph",
"attrs": {},
"content": ""
}
attrs
字段说明
属性名 | 描述 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|
indent | 首行缩进 | int | 0-1 | 0 |
contentIndent | 内容缩进 | int | [0,∞) | 0 |
align | 水平对齐方式 | enum | 1:左对齐 2:居中 3:右对齐 | 1 |
listAttrs | 列表属性 | object | 包含子属性(见二级属性表) | -- |
attrs.listAttrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
id | 列表 id | false | string | -- | -- |
type | 列表类型 | false | enum | 1:无序列表 2:有序列表 3:任务列表 | -- |
styleType | 列表项标记的类型 | false(type 有值时为 true) | enum | - 当type=1 (无序列表)时:1(实心点)、2(空心点)、3(方块) - 当type=2 (有序列表)时:4(阿拉伯数字)、5(字母)、6(罗马数字)、9(大写字母)、10(大写罗马数字)、11(圆圈数字)、12(中文数字)、13(大写中文数字) - 当type=3 (任务列表)时:7(未勾选)、8(勾选) | -- |
level | 列表级别 | false | int | [0,∞) | -- |
styleFormat | 列表分隔项类型 | false | enum | 1:1. 2:1、 3:1] 4:1】 5:1) 6:(1) 7:【1】 8:[1] 9:1 | -- |
4.3.2.1 示例
普通段落:
{
"type": "paragraph",
"content": "普通段落"
}
普通居中段落
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "普通居中段落"
}
],
"attrs": {
"align": 2
}
}
有序列表:
{
"type": "paragraph",
"content": "有序列表",
"attrs": {
"listAttrs": {
"type": 2,
"styleType": 4
}
}
}
无序列表:
{
"type": "paragraph",
"content": "无序列表",
"attrs": {
"listAttrs": {
"type": 1,
"styleType": 1
},
"align": 2
}
}
任务列表:
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "任务列表"
}
],
"attrs": {
"listAttrs": {
"type": 3,
"styleType": 8
}
}
}
4.3.3 heading
标题,无需为attrs和content的attrs设置加粗、字号属性
{
"type": "heading",
"attrs": {},
"content": ""
}
attrs
字段说明
属性名 | 描述 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|
level | 标题级别 | int | [1, 6] | 1 |
indent | 首行缩进 | int | 0-1 | 0 |
contentIndent | 内容缩进 | int | [0,∞) | 0 |
align | 水平对齐方式 | enum | 1:左对齐 2:居中 3:右对齐 | 1 |
listAttrs | 列表属性 | object | 包含子属性(见二级属性表) | -- |
attrs.listAttrs
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
id | 列表 id | false | string | -- | -- |
type | 列表类型 | false | enum | 1:无序列表 2:有序列表 3:任务列表 | -- |
styleType | 列表项标记的类型 | false(type 有值时为 true) | enum | - 当type=1 (无序列表)时:1(实心点)、2(空心点)、3(方块) - 当type=2 (有序列表)时:4(阿拉伯数字)、5(字母)、6(罗马数字)、9(大写字母)、10(大写罗马数字)、11(圆圈数字)、12(中文数字)、13(大写中文数字) - 当type=3 (任务列表)时:7(未勾选)、8(勾选) | -- |
level | 列表级别 | false | int | [0,∞) | -- |
styleFormat | 列表分隔项类型 | false | enum | 1:1. 2:1、 3:1] 4:1】 5:1) 6:(1) 7:【1】 8:[1] 9:1 | -- |
4.3.3.1 示例
标题一
{
"type": "heading",
"content": [
{
"type": "text",
"content": "标题一"
}
],
"attrs": {
"level": 1,
"align": 1
}
}
4.3.4 blockQuote
引用段落
{
"type": "blockQuote",
"attrs": {},
"content": ""
}
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
indent | 首行缩进 | false | int | [0, 1] | 0 |
contentIndent | 内容缩进 | false | int | [0,∞) | 0 |
align | 水平对齐方式 | false | enum | 1:左对齐 2:居中 3:右对齐 | 1 |
4.3.4.1.示例
{
"type": "blockQuote",
"content": [
{
"type": "text",
"content": "引用段落"
}
]
}
4.3.5 codeBlock
代码块
{
"type": "codeBlock",
"attrs": {},
"content": ""
}
4.3.5.1 支持的子节点
结点名 | 备注 |
---|---|
text | 不支持行内节点属性 |
属性名 | 描述 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|
lang | 语言类型 | enum | 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 | 1 |
autoWrap | 自动换行 | bool | false/true | -- |
theme | 主题 | enum | 1:亮色主题 2:暗色主题 | 1 |
4.3.5.2 示例
{
"type": "codeBlock",
"content": "{\n \"type\": \"br\"\n}",
"attrs": {
"lang": 17
}
}
示例👇
4.4 布局节点
4.4.1 table
表格,只可包含tableRow节点
建议不超过100行x50列,否则可能有性能问题
{
"type": "table",
"attrs": {},
"content": [] // tableRow 节点
}
4.4.2 tableRow
表格行,只可包含tableCell节点
{
"type": "tableRow",
"attrs": {},
"content": [] // tableCell 节点
}
4.4.3 tableCell
单元格
{
"type": "tableCell",
"attrs": {},
"content": []
}
4.4.3.1 支持的子节点
子节点 | 备注 |
---|---|
paragraph | -- |
blockQuote | -- |
codeBlock | -- |
picture | -- |
hr | -- |
pictureColumn | -- |
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
width | 宽度 | false | number | -- | -- |
height | 高度 | false | number | -- | -- |
colspan | 合并列数 | false | int | [0, ∞) | 1 |
rowspan | 合并行数 | false | int | [0, ∞) | 1 |
verticalAlign | 垂直对齐方式 | false | enum | 1:顶端对齐 2:垂直居中 3:底端对齐 | 1 |
4.4.3.2 示例
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"content": [
{
"type": "paragraph",
"content": "1x2"
}
],
"attrs": {
"width": 120,
"height": 44
}
},
{
"type": "tableCell",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "表格"
}
]
}
],
"attrs": {
"width": 120,
"height": 44
}
}
]
}
]
}
此处为截图效果图:
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"content": [
{
"type": "paragraph",
"content": "1x1合并单元格表格"
}
],
"attrs": {
"width": 200,
"height": 44,
"colspan": 2
}
}
]
}
]
}
此处为截图效果图:
{
"type": "table",
"content": [
{
"type": "tableRow",
"content": [
{
"type": "tableCell",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "单元格设置"
}
],
"attrs": {
"align": 2
}
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "水平居中"
}
],
"attrs": {
"align": 2
}
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "+"
}
],
"attrs": {
"align": 2
}
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "竖直居中"
}
],
"attrs": {
"align": 2
}
}
],
"attrs": {
"width": 258,
"height": 240.5,
"verticalAlign": 2
}
}
]
}
]
}
此处为截图效果图:
4.4.4 pictureColumn
分栏图
4.4.4.1 支持的子节点
子节点 | 备注 |
---|---|
picture | 上限5个 |
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
width | 宽度(百分比) | false | number | (0, 100] | -- |
align | 水平对齐方式 | false | enum | 1:左对齐 2:居中 3:右对齐 | 1 |
4.4.4.2 示例
{
"type": "pictureColumn",
"attrs": {
"width": 73,
"align": 2
},
"content": [
{
"type": "picture",
"attrs": {
"sourceKey": "PO3EUBAAFQ",
"version": 3,
"width": 2048,
"height": 1152
}
},
{
"type": "picture",
"attrs": {
"sourceKey": "PO3EUBAAWY",
"version": 3,
"width": 533,
"height": 300
}
}
]
},
4.4.5 highLightBlock
高亮块
{
"type": "highLightBlock",
"attrs": {},
"content": [] // 支持 paragraph节点、heading节点、picture节点、hr节点
}
4.4.5.1 支持的子节点
子节点 | 备注 |
---|---|
paragraph | -- |
heading | -- |
picture | -- |
hr | -- |
pictureColumn | -- |
spreadsheet dbsheet | 250507公网 |
属性名 | 描述 | 是否必填 | 数据类型 | 详细说明 | 默认值 |
---|---|---|---|---|---|
emoji | 表情 | 是 | enum | 取值及对应表情: 1:📌 2:🚩 3:📞 4:🚨 5:📖 6:👀 7:💬 8:💡 9:⭐ 10:💯 11:⭕ 12:❌ | -- |
style | 高亮块样式 | 否 | object | 包含以下子属性,用于定义高亮块的字体颜色、背景颜色等样式,具体见后续子属性表格说明 | -- |
style
子属性 - 字体颜色(fontColor
)
子属性名 | 描述 | 是否必填 | 数据类型 | 取值及对应颜色 | 默认值 |
---|---|---|---|---|---|
fontColor | 高亮块默认字体颜色 | 否 | enum | 1:黑色 2:灰色 3:红色 4:粉色 5:橙色 6:黄色 7:绿色 1 8:绿色 2 9:绿色 3 10:蓝色 1 11:蓝色 2 12:紫色 | -- |
style
子属性 - 背景颜色(backgroundColor
)
子属性名 | 描述 | 是否必填 | 数据类型 | 取值及对应颜色 | 默认值 |
---|---|---|---|---|---|
backgroundColor | 高亮块背景颜色 | 否 | enum | 1:灰色 2:粉色 3:橙色 4:绿色 5:蓝色 6:紫色 | -- |
4.4.5.2 示例
{
"type": "highLightBlock",
"attrs": {
"emoji": "📖",
"styleMap": {
"fontColor": 2,
"backgroundColor": 1
}
},
"content": [
{
"type": "heading",
"content": "高亮块标题1文本"
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "高亮块普通段落文本"
}
]
},
{
"type": "hr"
},
{
"type": "picture",
"attrs": {
"sourceKey": "PJ3LIAYAPM",
"width": 240,
"height": 125,
"version": 3
}
}
]
}
4.4.6 column
分栏容器,只可包含1-10个ColumnItem节点
{
"type": "column",
"attrs": {},
"content": [] // ColumnItem节点
}
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围及说明 | 默认值 |
---|---|---|---|---|---|
backgroundColor | 背景颜色 | false | enum | 1:单色 1 2:单色 2 3:单色 3 4:单色 4 5:单色 5 6:单色 6 7:多色 1 8:多色 2 9:多色 3 10:多色 4 11:多色 5 12:多色 6 | -- |
4.4.7 columnItem
分栏列
{
"type": "columnItem",
"attrs": {},
"content": []
}
4.4.7.1支持的子节点
子节点 | 备注 |
---|---|
paragraph | -- |
heading | -- |
blockQuote | -- |
codeBlock | -- |
picture | -- |
hr | -- |
processon | -- |
dbsheet | -- |
spreadsheet | -- |
countdown | -- |
appComponent | -- |
blockAnchor | -- |
highLightBlock | -- |
pictureColumn | -- |
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 | |
---|---|---|---|---|---|---|
width | 列宽度,百分比字符串,最多支持两位小数,如10.00% | false | string | -- | -- | |
backgroundColor | 背景颜色,优先级高于column的背景颜色 | false | enum | [1-42] | -- |
4.4.7.2 示例
{
"type": "column",
"attrs": {
"backgroundColor": 4
},
"content": [
{
"type": "columnItem",
"attrs": {
"width": "30%"
},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "分栏1"
}
]
}
]
},
{
"type": "columnItem",
"attrs": {
"width": "20%",
"backgroundColor": 30
},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "分栏2"
}
]
}
]
},
{
"type": "columnItem",
"attrs": {
"width": "50%"
},
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "分栏3"
}
]
}
]
}
]
}
5.文档属性
5.1 cover
封面图
"doc_attrs": {
"cover": {
"sourceKey": "P6A5GBAANI"
}
}
功能 | 功能描述 |
---|---|
cover | 文档封面图 推荐尺寸:2000×360px |
cover
字段说明
属性名 | 描述 | 是否必填 | 数据类型 | 默认值 |
---|---|---|---|---|
sourceKey | 封面图 sourceKey | true | string | -- |
coverId | 图库中的封面图 ID | false | string | "0" |
offsetX | X 轴偏移量 | false | number | 0 |
offsetY | Y 轴偏移量 | false | number | 0 |
6.评论
6.1 rangeMarkBegin
区间标识的起点,携带区间额外的数据,比如评论。需和rangeMarkEnd配对使用,以id作为唯一标识。
属性名 | 描述 | 是否必填 | 数据类型 |
---|---|---|---|
id | rangeMarkBegin 的 id,用于与 rangeMarkEnd 进行配对 | true | string |
data | rangeMark 携带的数据 | true | array |
data
字段说明
属性名 | 描述 | 数据类型 | 是否必填 | 取值范围 |
---|---|---|---|---|
type | 数据类型 | string | true | "comment" |
ids | 对应的评论 id | array[string] | true | -- |
6.2 rangeMarkEnd
区间标识的终点,和rangeMarkBegin配对使用,以id作为唯一标识
{
"type": "rangeMarkEnd",
"id": "1"
}
属性名 | 描述 | 是否必填 | 数据类型 |
---|---|---|---|
id | rangeMarkEnd的id,用于与rangeMarkBegin进行配对 | true | string |
6.3 comment
评论内容,依赖rangeMarkBegin和rangeMarkEnd进行区间标识和评论ID关联
{
"title_data": {},
"main_body_data": {},
"doc_attrs": {},
"comments": [
{
"id": "1",
"userId": "250005300",
"resolved": false,
"content": [
{
"type": "text",
"content": "评论内容"
}
],
"replys": [
{
"userId": "250005300",
"content": [
{
"type": "text",
"content": "评论内容"
}
],
"time": 1743672346000
}
],
"time": 1743672346000
}
]
}
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
comments | 存放每个评论的信息 | 否 | []IComment | -- | -- |
IComment 类型说明
属性名 | 描述 | 是否必填 | 数据类型 | 取值范围 | 默认值 |
---|---|---|---|---|---|
id | 评论的id,允许重复,重复则放在同一卡片,同一卡片最多容纳100条评论 | 否,根评论必填 | string | -- | -- |
userID | 评论作者ID | 是 | string | -- | -- |
resolved | 是否已解决 | 否 | boolean | true,false | false |
content | 评论内容 | 是 | 节点Node,与AP-JSON导入-节点属性配置项说明文档v2.otl格式相同 | [paragraph节点、text节点、WPSUser节点] | -- |
replys | 评论的回复 | 否 | []IComment | -- | -- |
time | 评论创建时间,Unix毫秒时间戳 | 否 | number | -- | 当前时间 |
6.3.1 支持的子节点
结点名 | 备注 | |
---|---|---|
paragraph | 多段时需要,单个段落可省略。 | 250521支持 |
text | 文本 | 250521支持 |
WPSUser | @人 | 250521支持 |
6.4 示例
{
"title_data": {
"content": [
{
"type": "text",
"content": "Title Text标题区"
}
]
},
"main_body_data": {
"content": [
{
"type": "rangeMarkBegin",
"id": "mark1",
"data": [
{
"type": "comment",
"ids": [
"comment1-1"
]
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"content": "我是段落我是段落我是段落我是段落我是段落我是段落我是段落我是段落我是段落我是段落我是段落我是段落。",
"attrs": {
"code": true,
"color": {
"fontColor": "#080F17"
}
}
}
],
"attrs": {}
},
{
"type": "rangeMarkEnd",
"id": "mark1"
},
{
"type": "paragraph",
"attrs": {}
}
]
},
"comments": [
{
"id": "comment1-1",
"userId": "250005300",
"content": [
{
"type": "text",
"content": "评论内容"
}
]
}
]
}
-End-Thanks-