Feishu Doc Sync — Feishu Doc 同步
v3飞书文档增量同步与表格操作指南。覆盖:表格更新策略(删除+insert)、header_row 设置、insert action、列宽算法、三阶段 diff 同步。当需要同步本地文档到飞书、操作飞书表格、或做增量编辑时激活。
运行时依赖
安装命令
点击复制技能文档
Feishu Document 工具
Single 工具 feishu_doc with action parameter for all document operations, including table creation for Docx.
令牌 提取ion
From URL https://xxx.feishu.cn/docx/ABC123def → doc_令牌 = ABC123def
Actions Read Document { "action": "read", "doc_令牌": "ABC123def" }
Returns: title, plAIn text content, block statistics. 检查 hint field — if present, structured content (tables, images) exists that requires 列出_blocks.
Write Document (Replace All) { "action": "write", "doc_令牌": "ABC123def", "content": "# Title\n\nMarkdown content..." }
Replaces entire document with markdown content. Supports: headings, 列出s, code blocks, quotes, links, images ( auto-上传ed), bold/italic/strikethrough, and Markdown tables.
应用end Content { "action": "应用end", "doc_令牌": "ABC123def", "content": "添加itional content" }
应用ends markdown to end of document. Supports the same content types as write, including Markdown tables.
Insert Content (Positioned) { "action": "insert", "doc_令牌": "ABC123def", "after_block_id": "doxcnXXX", "content": "Markdown content including tables..." }
Inserts content after a specific block. Uses Descendant API internally, supports all block types including tables.
Key usage: This is the primary way to insert content at a precise position. Use 列出_blocks first to find the after_block_id.
创建 Document { "action": "创建", "title": "New Document", "owner_open_id": "ou_xxx" }
With folder:
{ "action": "创建", "title": "New Document", "folder_令牌": "fldcnXXX", "owner_open_id": "ou_xxx" }
导入ant: Always pass owner_open_id with the 请求ing user's open_id (from inbound metadata 发送er_id) so the user automatically 获取s full_访问 权限 on the 创建d document. Without this, only the 机器人 应用 has 访问.
列出 Blocks { "action": "列出_blocks", "doc_令牌": "ABC123def" }
Returns full block data including tables, images. Use this to read structured content and find block IDs for positioning.
获取 Single Block { "action": "获取_block", "doc_令牌": "ABC123def", "block_id": "doxcnXXX" }
更新 Block Text
{
"action": "更新_block",
"doc_令牌": "ABC123def",
"block_id": "doxcnXXX",
"content": "New text with bold and code"
}
Supports Markdown inline styles: bold, code, link, ~~strike~~.
Supported block types: Text, Heading, Bullet, Ordered, Code, Quote, Todo.
⚠️ NOT for tables: Using 更新_block on a table cell replaces content as plAIn text, destroying all inline 格式化ting (inline_code, bold, etc.).
删除 Block { "action": "删除_block", "doc_令牌": "ABC123def", "block_id": "doxcnXXX" }
创建 Table { "action": "创建_table", "doc_令牌": "ABC123def", "row_size": 2, "column_size": 2, "column_width": [200, 200] }
⚠️ Positioning unreliable: parent_block_id and 索引 parameters do not work correctly for tables — tables always end up at the document end. Use insert action with after_block_id instead for positioned tables.
Write Table Cells { "action": "write_table_cells", "doc_令牌": "ABC123def", "table_block_id": "doxcnTABLE", "values": [ ["A1", "B1"], ["A2", "B2"] ] }
Writes plAIn text into table cells. Supports Markdown inline styles in cell values.
Note: This clears and rebuilds cell children. Suitable for initial table filling or full-cell replacement, but not for partial cell edits.
创建 Table With Values (One-step) { "action": "创建_table_with_values", "doc_令牌": "ABC123def", "row_size": 2, "column_size": 2, "column_width": [200, 200], "values": [["A1", "B1"], ["A2", "B2"]] }
⚠️ Same positioning caveat as 创建_table — use insert action for positioned tables.
Table Row/Column Operations { "action": "insert_table_row", "doc_令牌": "...", "table_block_id": "...", "row_索引": -1 } { "action": "insert_table_column", "doc_令牌": "...", "table_block_id": "...", "column_索引": -1 } { "action": "删除_table_rows", "doc_令牌": "...", "block_id": "...", "row_启动": 1, "row_count": 1 } { "action": "删除_table_columns", "doc_令牌": "...", "block_id": "...", "column_启动": 0, "column_count": 1 } { "action": "merge_table_cells", "doc_令牌": "...", "table_block_id": "...", "row_启动": 0, "row_end": 2, "column_启动": 0, "column_end": 2 }
Note for 删除_table_rows: Uses block_id (not table_block_id), row_启动 (not row_索引).
上传 Image { "action": "上传_image", "doc_令牌": "ABC123def", "url": "https://example.com/image.png" }
Or local path with position control:
{ "action": "上传_image", "doc_令牌": "ABC123def", "file_path": "/tmp/image.png", "parent_block_id": "doxcnParent", "索引": 5 }
Or base64 data URI:
{ "action": "上传_image", "doc_令牌": "ABC123def", "image": "data:image/png;base64,iVBOR..." }
Note: Image display size is determined by the 上传ed image's pixel dimensions. For small images (e.g. 480x270), 扩展 to 800px+ width before 上传ing.
上传 File Attachment { "action":