Skip to content

1.支持的节点类型

image.png

2.数据结构

javascript
// 导入的数据结构
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 错误入参示例

json
{
  "main_body_data": {
    "content": [
      {
        "type": "groupCard",
        "attrs": {
          "id": "2327281,8yrkdJj0byz",
          "name": "一个人的群聊",
          "masterName": "陈洋"
        }
      }
    ]
  }
}

3.1.2 错误原因

不支持 groupCard 类型

3.2 示例2 - 入参的节点嵌套格式是否是允许的

3.2.1 错误入参示例

json
{
  "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 错误入参示例

json
{
  "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 错误入参示例

json
{
  "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 错误入参示例

json
{
  "main_body_data": {
    "content": [
      {
        "type": "paragraph",
        "content": [
          {
            "type": "text",
            "content": "普通居中段落"
          }
        ],
        "attrs": {
          "align": 6
        }
      }]
  }
}

3.5.2 错误原因

paragraph 节点的 align 属性越界

3.6 示例6 - 评论跨域了标题和正文

3.6.1 错误入参示例

json
{
    "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 错误入参示例

json
{
  "main_body_data": {
    "content": [
        {
            "type": "rangeMarkBegin"
        }
    ]
  }
}

3.7.2 错误原因

rangeMarkBegin 节点无效

3.8 示例8 - rangeMarkBegin自身的id重复

3.8.1 错误入参示例

json
{
  "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 错误入参示例

json
{
  "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 错误入参示例

json
{
  "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 错误入参示例

json
{
  "main_body_data": {
    "content": [
        {
            "type": "rangeMarkBegin",
            "id": "mark1",
            "data": [
                {
                    "type": "comment",
                    "ids": [
                        "comment1-1"
                    ]
                }
            ]
        }
    ]
  },
  "comments": [
        {
            "id": "comment2-1",
            ...
        }
    ]
}

3.11.2 错误原因

comment1-1comments body 中无数据

3.12 示例12 - angeMarkEnd缺少id

3.12.1 错误入参示例

json
{
  "main_body_data": {
    "content": [
        {
            "type": "rangeMarkEnd"
        }
    ]
  }
}

3.12.2 错误原因

rangeMarkEnd 节点无数据

3.13 示例13 - rangeMarkEnd的id重复

3.13.1 错误入参示例

json
{
  "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 错误入参示例

json
{
  "main_body_data": {
    "content": [
        {
            "type": "rangeMarkBegin",
            "id": "mark1"
        },
        // 后续没有对应的rangeMarkEnd
    ]
  }
}

3.14.2 错误原因

只有 rangeMarkBegin 没有对应的 rangeMarkEnd 节点

3.15 示例15 - rangeMarkEnd没有对应的rangeMarkBegin

3.15.1 错误入参示例

json
{
  "main_body_data": {
    "content": [
        // 前面没有对应的rangeMarkBegin
        {
            "type": "rangeMarkEnd",
            "id": "mark1"
        }
    ]
  }
}

3.15.2 错误原因

只有 rangeMarkEnd 没有对应的 rangeMarkBegin 节点

3.16 示例16 - comment body里,重复的id超过最大限制100

3.16.1 错误入参示例

json
{
  "comments": [
        {
            "id": "comment1"
        },
        {
            "id": "comment1"
        }
        // .. 重复的id超过了100
    ]
}

3.16.2 错误原因

comment body里,重复的id超过最大限制100

3.17 示例17 - comment body里没有传入userId

3.17.1 错误入参示例

json
{
  "comments": [
        {
            "id": "comment1", 
            "resolved": false,
            "content": [
                {
                    "type": "text",
                    "content": "评论1"
                }
            ]
        }
    ]
}

3.17.2 错误原因

comments 里没有传入 userId

3.18 示例18 - comment body里的content为空

3.18.1 错误入参示例

json
{
  "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

json
{
    "type": "text",
    "attrs": {},
    "content": "xxx"
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
code行内代码块falsebool--false
link超链接falseobject----

attrs.link 字段说明

属性名描述是否必填数据类型取值范围默认值
href超链接跳转地址falsestring----
hrefTitle超链接标题falsestring----

4.1.2 WPSUser

联系人

json
{
    "type": "WPSUser",
    "attrs": {}
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
userId用户idtruestring----
name用户名truestring----
avatar用户头像地址falsestring----

4.1.3 staticTime

静态时间

json
{
    "type": "staticTime",
    "attrs": {}
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
time毫秒级时间戳trueint----
timeType时间类型falseenum1日期1
2日期时间

4.1.4 WPSDocument

云文档/本地附件

当传入wpsDocumentType不在AP支持的范围内时,此节点回落为普通超链接文本。

version与上传附件时的接口有关,version不对可能导致附件的交互出错

当云文档视图非标题视图时,其父节点只能为paragraph,且不能有其他兄弟节点

json
{
    "type": "WPSDocument",
    "attrs": {}
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
wpsDocumentId云文档idtruestring----
wpsDocumentName云文档名字truestring----
wpsDocumentType云文档文件类型truestring----
wpsDocumentLink云文档链接true(附件无云文档链接可不填)stringhttp、https协议头的超链接--
viewType云文档视图falseenum1标题视图1
2预览视图2
3卡片视图3
4附件视图4
size附件大小,仅附件视图有效附件视图时必填int(0, +∞)--
version存储版本falseint[1,2]2

4.1.5 schedule

日程

json
{
    "type": "schedule",
    "attrs": {}
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
id日程组合id
(组合方式:日程的taskId+'|' +sid +'|' + teamId)
truestring----
name日程名字truestring----
startTime日程开始时间trueint毫秒级时间戳--
endTime日程结束时间trueint毫秒级时间戳--
actionType日程类型falseenum1非全天1
2全天

4.1.6 emoji

emoji表情

不符合AP支持的emoji,回落为普通文本

json
{
    "type": "emoji",
    "attrs": {}
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
emojiemoji表情文本truestring单个emoji--

4.1.7 latex

latex公式

json
{
    "type": "latex",
    "attrs": {
        "width": 36,
        "height": 20,
        "latexStr": "\\sqrt[n]{ab}"
    }
}

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
width宽度truestring正数--
height高度truestring正数--
latexStrlatex公式字符串truestring----

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字体渐变色enum1. 殷红琥珀
2. 浅烙翡翠
3. 海涛魏紫
4. 金盏糖蓝
5. 蔚蓝桃红
6. 梦幻极光
--

4.1.9 示例

4.1.9.1 text

JSON 示例 1
json
{
  "type": "text",
  "content": "普通文本"
}

JSON 示例 2
json
{
  "type": "text",
  "content": "超链接",
  "attrs": {
    "link": {
      "href": "https://www.kdocs.cn",
      "hrefTitle": "超链接"
    }
  }
}

JSON 示例 3
json
{
  "type": "text",
  "content": "加粗加大文本",
  "attrs": {
    "bold": true,
    "fontSize": {
      "fontSize": 13
    }
  }
}

JSON 示例 4
json
{
  "type": "text",
  "content": "行内代码块",
  "attrs": {
    "code": true
  }
}

JSON 示例 5
json
{
  "type": "text",
  "content": "黄底红字文本",
  "attrs": {
    "color": {
      "fontColor": "#FBF5B3",
      "backgroundColor": "#C21C13"
    }
  }
}

JSON 示例 6
json
{
  "type": "text",
  "content": "渐变色文本",
  "attrs": {
    "color": {
      "fontGradientColor": 1
    }
  }
}

4.1.9.2 WPSUser

JSON 示例 1
json
{
  "type": "WPSUser",
  "attrs": {
    "userId": "1388384431",
    "name": "陈洋"
  }
}

4.1.9.3 staticTime

JSON 示例 1
json
{
  "type": "staticTime",
  "attrs": {
    "time": 1666713600000
  }
}

JSON 示例 2
json
{
  "type": "staticTime",
  "attrs": {
    "time": 1666713600000,
    "timeType": 2
  }
}

4.1.9.4 WPSDocument

JSON 示例 1
json
{
  "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
json
{
  "type": "schedule",
  "attrs": {
    "id": "101199635|e_0E4CbNlpi|69743236",
    "name": "示例日程",
    "startTime": 1717574400000,
    "endTime": 1717574700000
  }
}

JSON 示例 2
json
{
  "type": "schedule",
  "attrs": {
    "id": "101199867|e_0hOdQNjb1|69743236",
    "name": "示例日程(全天)",
    "startTime": 1717603199000,
    "endTime": 1717603199000,
    "actionType": 2
  }
}

4.1.9.5 emoji

JSON 示例
json
{
  "type": "emoji",
  "attrs": {
    "emoji": "🚩"
  }
}

4.1.9.6 latex

JSON 示例
json
{
  "type": "latex",
  "attrs": {
    "width": 36,
    "height": 20,
    "latexStr": "\\sqrt[n]{ab}"
  }
}

4.2 块级内容节点

4.2.1 picture

图片

使用接口上传的图片,version属性与传参相关

json
{

   "type": "picture",

   "attrs": {

       "sourceKey": "AC6GUAYASE",

       "width": 2048,

       "height": 1152,

       "version": 3

   }

}

示例👇

image

属性名描述是否必填数据类型取值范围说明默认值
sourceKey图片资源 IDtruestring------
width图片原始宽度truenumber------
height图片原始高度truenumber------
renderWidth图片渲染宽度falsenumber------
rotate旋转角度(单位:deg)falseint[0, -90, -180, -270]----
borderType边框类型falseenum0无边框0
1灰色 1px 边框
align水平对齐方式falseenum1左对齐1
2居中
3右对齐
version图片版本falseint1已不支持新增2
2对象存储的图片
3基础存储的图片

4.2.2 procession

流程图/思维导图

json
{
    "type": "processon",
    "attrs": {
        "type": 2,
        "sourceId": "PQYBL2YZADQDQ",
        "sourceKey": "UE2BL2YZAAAHG",
        "width": 1499,
        "height": 616
    }
}

流程图示例👇

image

属性名描述是否必填数据类型取值范围默认值
typepo类型enum1: 流程图
2: 思维导图
--
sourceIdpo资源idstring----
sourceKey图片资源idstring----
width图片原始宽度(必传,否则影响预览效果)number----
height图片原始高度(必传,否则影响预览效果)number----
renderWidth图片渲染宽度number----
borderType边框类型enum0: 无边框
1: 灰色边框
0
align水平对齐方式enum1: 左对齐
2: 居中
3: 右对齐
1

4.2.3 video

视频

json
{
    "type": "video",
    "attrs": {
        "sourceId": "asdfghjklqwertyuiopzxcvbnm",
        "sourceKey": "ababasdfghjkl",
        "width": 500,
        "height": 288,
    }
}

示例👇

属性名描述是否必填数据类型取值范围及说明默认值
sourceId视频资源 idtruestring----
sourceKey视频封面图资源 idtruestring----
width视频原始宽度truenumber----
height视频原始高度truenumber----
title视频文件名falsestring----
align水平对齐方式falseenum1:左对齐 2:居中 3:右对齐1

4.2.4 hr

分隔线

json
{
    "type": "hr"
}

示例👇


4.2.5 countdown

倒计时

json
{
    "type": "countdown",
    "attrs": {
        "timestamp": 1720777977001,
        "duration": 86395000
    }
}

示例👇

countdown

属性名描述是否必填数据类型取值范围及说明默认值
type倒计时模式trueint1:日期模式 2:时间模式--
duration倒计时时长与 endTimestamp 必填一个int毫秒级时间--
endTimestamp倒计时结束时间与 duration 必填一个int毫秒级时间--

4.2.6 dbsheet

轻维表

使用接口创建dbsheet,version属性与传参相关

json
{
    "type": "dbsheet",
    "attrs": {
        "sourceId": "MKECB2YZADQF2"
    }
}

示例👇

dbsheet

属性名描述是否必填数据类型取值范围默认值
sourceId轻维表idtruestring----
version存储版本falseint--2

4.2.7 spreadsheet

电子表格

json
{
    "type": "spreadsheet",
    "attrs": {
        "sourceId": "ZFWSB2YZACAEY"
    }
}

示例👇

spreadsheet

属性名描述是否必填数据类型取值范围默认值
sourceId电子表格idtruestring----
version存储版本falseint--2

*使用接口创建spreadsheet,version属性与传参相关

4.2.8 appComponent

应用组件-投票组件

json
{
    "type": "appComponent",
    "attrs": {
        "type": 1,
        "metaData": {
            "id": "100000001234",
            "title": "这是一个投票",
            "options": [
                {
                    "value": "选项1",
                    "selectId": "100001"
                },
                {
                    "value": "选项2",
                    "selectId": "100002"
                }
            ]
        }
    }
}

示例👇

appComponent

attrs 字段说明

属性名描述是否必填数据类型取值范围默认值
type应用组件类型 (1 - 投票)trueint[1]--
metaData应用组件数据trueobject(见二级属性表)--

attrs.metaData 字段说明

属性名描述是否必填数据类型取值范围默认值
id投票 idtruestring----
title投票标题truestring----
options投票选项true[] object(数组对象)minLen: 1(至少 1 项)--
anonymous是否匿名falseboolfalse/truefalse
multiType投票类型falsestring----
voteResultShow投票结果显示方式falsestring----

attrs.metaData.options 字段说明

子元素属性名描述是否必填数据类型取值范围默认值
value选项值truestring----
selectId选项 idtruestring----

4.2.9 blockAnchor

块级占位

json
{
    "type": "blockAnchor",
    "attrs": {
        "aimType": "picture",
        "width": 200,
        "height": 100,
        "id": "asdfghjklqwertyuio"
    }
}
属性名描述是否必填数据类型取值范围默认值
aimType占位目标类型truestringpicturevideoprocessonspreadsheet--
width占位宽度truenumber----
height占位高度truenumber----
id占位 idtruestring----

4.3 段节点

4.3.1 注意事项

传入的content是string时,默认生成text行内节传入的content是array时,里面的节点都必须是行内节点,除非特别约定

4.3.2 paragraph

普通段落

json
{
    "type": "paragraph",
    "attrs": {},
    "content": ""
}

attrs 字段说明

属性名描述数据类型取值范围及说明默认值
indent首行缩进int0-10
contentIndent内容缩进int[0,∞)0
align水平对齐方式enum1:左对齐 2:居中 3:右对齐1
listAttrs列表属性object包含子属性(见二级属性表)--

attrs.listAttrs 字段说明

属性名描述是否必填数据类型取值范围及说明默认值
id列表 idfalsestring----
type列表类型falseenum1:无序列表 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列表级别falseint[0,∞)--
styleFormat列表分隔项类型falseenum1:1. 2:1、 3:1] 4:1】 5:1) 6:(1) 7:【1】 8:[1] 9:1 --

4.3.2.1 示例

普通段落:

json
{
    "type": "paragraph",
    "content": "普通段落"
}

普通居中段落

json
{
    "type": "paragraph",
    "content": [
        {
            "type": "text",
            "content": "普通居中段落"
        }
    ],
    "attrs": {
        "align": 2
    }
}

有序列表:

json
{
    "type": "paragraph",
    "content": "有序列表",
    "attrs": {
        "listAttrs": {
            "type": 2,
            "styleType": 4
        }
    }
}

无序列表:

json
{
    "type": "paragraph",
    "content": "无序列表",
    "attrs": {
        "listAttrs": {
            "type": 1,
            "styleType": 1
        },
        "align": 2
    }
}

任务列表:

json
{
    "type": "paragraph",
    "content": [
        {
            "type": "text",
            "content": "任务列表"
        }
    ],
    "attrs": {
        "listAttrs": {
            "type": 3,
            "styleType": 8
        }
    }
}

4.3.3 heading

标题,无需为attrs和content的attrs设置加粗、字号属性

json
{
    "type": "heading",
    "attrs": {},
    "content": ""
}

attrs 字段说明

属性名描述数据类型取值范围及说明默认值
level标题级别int[1, 6]1
indent首行缩进int0-10
contentIndent内容缩进int[0,∞)0
align水平对齐方式enum1:左对齐 2:居中 3:右对齐1
listAttrs列表属性object包含子属性(见二级属性表)--

attrs.listAttrs 字段说明

属性名描述是否必填数据类型取值范围及说明默认值
id列表 idfalsestring----
type列表类型falseenum1:无序列表 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列表级别falseint[0,∞)--
styleFormat列表分隔项类型falseenum1:1. 2:1、 3:1] 4:1】 5:1) 6:(1) 7:【1】 8:[1] 9:1 --

4.3.3.1 示例

标题一

json
{
    "type": "heading",
    "content": [
        {
            "type": "text",
            "content": "标题一"
        }
    ],
    "attrs": {
        "level": 1,
        "align": 1
    }
}

4.3.4 blockQuote

引用段落

json
{
    "type": "blockQuote",
    "attrs": {},
    "content": ""
}
属性名描述是否必填数据类型取值范围及说明默认值
indent首行缩进falseint[0, 1]0
contentIndent内容缩进falseint[0,∞)0
align水平对齐方式falseenum1:左对齐 2:居中 3:右对齐1

4.3.4.1.示例

json
{
    "type": "blockQuote",
    "content": [
        {
            "type": "text",
            "content": "引用段落"
        }
    ]
}

4.3.5 codeBlock

代码块

json
{
    "type": "codeBlock",
    "attrs": {},
    "content": ""
}

4.3.5.1 支持的子节点

结点名备注
text不支持行内节点属性
属性名描述数据类型取值范围及说明默认值
lang语言类型enum1: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:yaml1
autoWrap自动换行boolfalse/true--
theme主题enum1:亮色主题 2:暗色主题1

4.3.5.2 示例

json
{
    "type": "codeBlock",
    "content": "{\n    \"type\": \"br\"\n}",
    "attrs": {
        "lang": 17
    }
}

示例👇

codeBlock

4.4 布局节点

4.4.1 table

表格,只可包含tableRow节点

建议不超过100行x50列,否则可能有性能问题

json
{
    "type": "table",
    "attrs": {},
    "content": [] // tableRow 节点
}

4.4.2 tableRow

表格行,只可包含tableCell节点

json
{
    "type": "tableRow",
    "attrs": {},
    "content": [] // tableCell 节点
}

4.4.3 tableCell

单元格

json
{
    "type": "tableCell",
    "attrs": {},
    "content": []
}

4.4.3.1 支持的子节点

子节点备注
paragraph--
blockQuote--
codeBlock--
picture--
hr--
pictureColumn--
属性名描述是否必填数据类型取值范围及说明默认值
width宽度falsenumber----
height高度falsenumber----
colspan合并列数falseint[0, ∞)1
rowspan合并行数falseint[0, ∞)1
verticalAlign垂直对齐方式falseenum1:顶端对齐 2:垂直居中 3:底端对齐1

4.4.3.2 示例

json
{
    "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
                    }
                }
            ]
        }
    ]
}

此处为截图效果图:

grids

json
{
    "type": "table",
    "content": [
        {
            "type": "tableRow",
            "content": [
                {
                    "type": "tableCell",
                    "content": [
                        {
                            "type": "paragraph",
                            "content": "1x1合并单元格表格"
                        }
                    ],
                    "attrs": {
                        "width": 200,
                        "height": 44,
                        "colspan": 2
                    }
                }
            ]
        }
    ]
}

此处为截图效果图:

mergeGrids

json
{
    "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
                    }
                }
            ]
        }
    ]
}

此处为截图效果图:

grids3png

4.4.4 pictureColumn

分栏图

4.4.4.1 支持的子节点

子节点备注
picture上限5个
属性名描述是否必填数据类型取值范围及说明默认值
width宽度(百分比)falsenumber(0, 100]--
align水平对齐方式falseenum1:左对齐 2:居中 3:右对齐1

4.4.4.2 示例

json
{
    "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
            }
        }
    ]
},

fenlantu

4.4.5 highLightBlock

高亮块

json
{
    "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高亮块默认字体颜色enum1:黑色 2:灰色 3:红色 4:粉色 5:橙色 6:黄色 7:绿色 1 8:绿色 2 9:绿色 3 10:蓝色 1 11:蓝色 2 12:紫色--

style 子属性 - 背景颜色(backgroundColor

子属性名描述是否必填数据类型取值及对应颜色默认值
backgroundColor高亮块背景颜色enum1:灰色 2:粉色 3:橙色 4:绿色 5:蓝色 6:紫色--

4.4.5.2 示例

json
{
    "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
            }
        }
    ]
}

gaoliang

4.4.6 column

分栏容器,只可包含1-10个ColumnItem节点

json
{
    "type": "column",
    "attrs": {},
    "content": [] // ColumnItem节点
}
属性名描述是否必填数据类型取值范围及说明默认值
backgroundColor背景颜色falseenum1:单色 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

分栏列

json
{
    "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%falsestring----
backgroundColor背景颜色,优先级高于column的背景颜色falseenum[1-42]--

4.4.7.2 示例

json
{
    "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

封面图

json
"doc_attrs": {
    "cover": {
        "sourceKey": "P6A5GBAANI"
    }
}
功能功能描述
cover文档封面图 推荐尺寸:2000×360px

cover 字段说明

属性名描述是否必填数据类型默认值
sourceKey封面图 sourceKeytruestring--
coverId图库中的封面图 IDfalsestring"0"
offsetXX 轴偏移量falsenumber0
offsetYY 轴偏移量falsenumber0

6.评论

6.1 rangeMarkBegin

区间标识的起点,携带区间额外的数据,比如评论。需和rangeMarkEnd配对使用,以id作为唯一标识。

属性名描述是否必填数据类型
idrangeMarkBegin 的 id,用于与 rangeMarkEnd 进行配对truestring
datarangeMark 携带的数据truearray

data 字段说明

属性名描述数据类型是否必填取值范围
type数据类型stringtrue"comment"
ids对应的评论 idarray[string]true--

6.2 rangeMarkEnd

区间标识的终点,和rangeMarkBegin配对使用,以id作为唯一标识

json
{
    "type": "rangeMarkEnd",
    "id": "1"
}
属性名描述是否必填数据类型
idrangeMarkEnd的id,用于与rangeMarkBegin进行配对truestring

6.3 comment

评论内容,依赖rangeMarkBegin和rangeMarkEnd进行区间标识和评论ID关联

json
{
    "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评论作者IDstring----
resolved是否已解决booleantrue,falsefalse
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 示例

json
{
    "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-