feishu-doc-writer

飞书文档写入。Markdown 转 Block、创建文档块、处理并发。

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "feishu-doc-writer" with this command: npx skills add alextangson/feishu_skills/alextangson-feishu-skills-feishu-doc-writer

飞书文档写入

通过 Docx API 写入内容到飞书云文档。飞书文档使用 Block 树模型,不接受原始 Markdown。

Base URL: https://open.feishu.cn/open-apis/docx/v1


推荐方式:转换 API

飞书提供官方 Markdown → Blocks 转换端点:

POST /documents/{document_id}/convert
{
  "content": "# 标题\n\n正文\n\n- 列表项",
  "content_type": "markdown"
}

✅ 无需手动构建 Block JSON,支持标准 Markdown ⚠️ 不支持飞书特有块(Callout 等)— 需手动创建


Block 类型

block_type名称JSON Key说明
1页面page文档根节点
2文本text段落
3-11标题1-9heading1-heading9-
12无序列表bullet每项单独一个 block
13有序列表ordered-
14代码块code需指定 style.language
15引用quote-
17待办todostyle.done
19高亮块callout飞书特有,容器块
22分割线divider-
27图片image两步:创建占位 + 上传
31表格table-

创建 Blocks

POST /documents/{document_id}/blocks/{block_id}/children?document_revision_id=-1
{
  "children": [...],
  "index": 0
}
  • block_id: 父块 ID(根节点用 document_id
  • index: 插入位置(0=开头,-1=末尾)

Block 示例

文本:

{"block_type": 2, "text": {"elements": [{"text_run": {"content": "段落"}}]}}

标题:

{"block_type": 3, "heading1": {"elements": [{"text_run": {"content": "标题"}}]}}

代码块:

{
  "block_type": 14,
  "code": {
    "style": {"language": 1},
    "elements": [{"text_run": {"content": "console.log('hello')"}}]
  }
}

高亮块(Callout):

{
  "block_type": 19,
  "callout": {
    "background_color": 1,
    "border_color": 1,
    "emoji_id": "bulb"
  },
  "children": [
    {"block_type": 2, "text": {"elements": [{"text_run": {"content": "提示内容"}}]}}
  ]
}

图片(两步):

  1. 创建占位:{"block_type": 27, "image": {}}
  2. 上传:PUT /documents/{document_id}/blocks/{block_id}/image

文本样式

{
  "text_run": {
    "content": "样式文本",
    "text_element_style": {
      "bold": true,
      "italic": true,
      "strikethrough": true,
      "underline": true,
      "inline_code": true,
      "background_color": 1,
      "text_color": 1
    }
  }
}

并发处理

飞书文档支持多人协作,需处理并发:

  1. 获取最新 revision: GET /documents/{document_id}
  2. 带 revision 写入: ?document_revision_id={revision}
  3. 冲突时重试(HTTP 409)

最佳实践

  1. 优先用转换 API(简化开发)
  2. 批量创建 blocks(减少 API 调用)
  3. 处理并发冲突(带 revision 参数)
  4. 图片分两步(占位 + 上传)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

feishu-calendar

No summary provided by upstream source.

Repository SourceNeeds Review
General

feishu-bitable

No summary provided by upstream source.

Repository SourceNeeds Review
General

feishu-card

No summary provided by upstream source.

Repository SourceNeeds Review
General

feishu-im

No summary provided by upstream source.

Repository SourceNeeds Review