Request

... 2022-7-14 大约 3 分钟

# Request

参数说明: 更新 Doc 文档的单个请求

{
  // 下列字段只能填写其中一个
  "replaceText":{
    object(ReplaceText)
  },
  "insertText":{
    object(InsertText)
  },
  "deleteContent":{
    object(DeleteContent)
	},
  "insertImage":{
    object(InsertImage)
  },
  "insertPageBreak":{
    object(InsertPageBreak)
  },
  "insertTable":{
    object(InsertTable)
  },
  "insertParagraph": {
    object(InsertParagraph)
  },
  "updateTextProperty":{
    object(UpdateTextProperty)
  },
  "insertComment": {
    object(InsertComment)
  }, 
  "deleteComment": {
    object(DeleteComment)
  }
  // TODO: 待补充
}
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
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
参数名称 类型 描述
replaceText object(ReplaceText) 替换指定位置文本内容
insertText object(InsertText) 在指定位置插入文本内容
deleteContent object(DeleteContent) 删除指定位置内容
insertImage object(InsertImage) 在指定位置插入图片
insertPageBreak object(InsertPageBreak) 在指定位置插入分页符
insertTable object(InsertTable) 在指定位置插入表格
insertParagraph object(InsertParagraph) 在指定位置插入段落
updateTextProperty object(UpdateTextProperty) 更新指定位置文本属性
insertComment object(InsertComment) 在指定位置插入批注
deleteComment object(DeleteComment) 删除指定批注

# ReplaceText

说明: 替换指定位置的文本内容。

{
  "text": string,
  "ranges": [
    object(Range)
  ]
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 类型 描述
text string 要替换的文本
ranges[] Object(Range) 要替换的文档范围,可同时替换多个位置的文本,同一个请求里range 数量不能超过10个。

# Range

说明: 文档范围。

{
  "startIndex": int,
  "length": int
}
1
2
3
4
1
2
3
4
参数名称 类型 描述
startIndex integer 文档指定范围的起始位置
length integer 文档指定范围的长度

# InsertText

说明: 在指定位置插入文本内容。

{
  "text": string,
  "location": object(Location)
}
1
2
3
4
1
2
3
4
参数名称 类型 描述
text string 要插入的文本内容
location Object(Location) 插入的文档位置

# Location

说明: 文档指定位置。

{
  "index": int,
}
1
2
3
1
2
3
参数名称 类型 描述
index integer 文档指定位置

# DeleteContent

说明: 删除指定位置的内容。

{
  "range": object(Range)
}
1
2
3
1
2
3
参数名称 类型 描述
range Object(Range) 要删除的文档范围

# InsertImage

说明: 在指定位置插入图片

{
  "imageId": string,
  "location": object(Location)
}
1
2
3
4
1
2
3
4
参数名称 类型 描述
imageId string 使用图片上传接口获取 imageId
location Object(Location) 插入的文档位置

# InsertPageBreak

说明: 在指定位置插入分页符

{
  "location": object(Location)
}
1
2
3
1
2
3
参数名称 类型 描述
location Object(Location) 插入的文档位置

# InsertTable

说明: 在指定位置插入表格

{
  "rows": int,
  "cols": int
  "location": object(Location)
}
1
2
3
4
5
1
2
3
4
5

注意: 插入的表格单元格数量不能超过1000。

参数名称 类型 是否必填 描述
rows integer 插入的表格的行数,行数需要大于0,小于100
cols integer 插入的表格的列数,列数需要大于0,小于60
location Object(Location) 插入的文档位置

# InsertParagraph

说明: 在指定位置插入段落

{
  "location": object(Location)
}
1
2
3
1
2
3
参数名称 类型 描述
location Object(Location) 插入的文档位置

# UpdateTextProperty

说明: 更新指定位置文本属性

{
  "textProperty": object(TextProperty),
  "ranges": [
    object(Range)
  ]
}
1
2
3
4
5
6
1
2
3
4
5
6
参数名称 类型 描述
textProperty Object(TextProperty) 文本属性
ranges[] Object(Range) 要更新的文档范围,可同时更新多个位置的文本属性,同一个请求里range 数量不能超过10个。

# TextProperty

说明: 文本属性

{
  "bold": bool,
  "color": string,
  "backgroundColor": string
}
1
2
3
4
5
1
2
3
4
5
参数名称 类型 描述
bold bool 是否加粗
color string 文字的颜色,颜色使用十六进制,RRGGBB 格式
backgroundColor string 文字的背景颜色,颜色使用十六进制,RRGGBB 格式

# InsertComment

说明: 在指定位置插入批注

{
  "text":  string,
  "range": object(Range)
}
1
2
3
4
1
2
3
4
参数名称 类型 描述
text string 评论内容
range Object(Range) 要插入批注的文档范围

# DeleteComment

说明: 删除指定批注

{
  "id":  string,
  "refId": string
}
1
2
3
4
1
2
3
4
参数名称 类型 描述
id string 批注 ID, 可通过 获取 Doc 文档内容 获取
refId string 批注组 ID, 可通过 获取 Doc 文档内容 获取
上次编辑于: 2023年12月8日 18:27
贡献者: livlin , mylochen , muyanyang