larksuite / larksuite/cli

[Feat] docs +update 不支持创建或替换 Docx 中的 Base 视图嵌入块

Open
#2,402 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

domain/doc enhancement
Dominant language
Go
Stars
17.3k
Forks
1.4k
Avg merge
2d 4h
Merged PRs (30d)
105

Description

问题描述

目前 lark-cli docs +fetch
可以从 Docx 文档中读取到已有的 Base 嵌入展示块,例如:

<base_refer
  token="<BASE_TOKEN>"
  table-id="<TABLE_ID>"
  view-id="<VIEW_ID>">
</base_refer>

但使用 lark-cli docs +update
尝试创建或替换同类嵌入块时会失败。即使先删除文档中已有的 Base 嵌入块,再重新插入新的
<base_refer>,也无法成功创建嵌入展示效果。

这会导致无法通过 CLI 完成“在 Docx 模板中替换开发日志 Base 视图”的自动化流程。

环境信息

  • lark-cli version: 1.0.87
  • 操作对象:Docx 文档
  • 相关能力:docs +fetch / docs +update / base +view-create /
    base +view-set-filter

复现步骤

  1. 准备一个 Base 视图链接:
https://example.larksuite.com/base/<BASE_TOKEN>?table=<TABLE_ID>&view=<VIEW_ID>
  1. 在 Docx 文档中选择一个锚点 block,尝试插入 Base 视图嵌入块:
lark-cli docs +update \
  --doc '<DOCX_URL>' \
  --command block_insert_after \
  --block-id '<ANCHOR_BLOCK_ID>' \
  --doc-format xml \
  --content '<base_refer token="<BASE_TOKEN>" table-id="<TABLE_ID>" view-id="<VIEW_ID>"></base_refer>' \
  --as user \
  --format json
  1. 或尝试使用 <bitable>
lark-cli docs +update \
  --doc '<DOCX_URL>' \
  --command block_insert_after \
  --block-id '<ANCHOR_BLOCK_ID>' \
  --doc-format xml \
  --content '<bitable token="<BASE_TOKEN>" table-id="<TABLE_ID>" view-id="<VIEW_ID>"></bitable>' \
  --as user \
  --format json

实际结果

<base_refer> 写入失败,返回类似 warning:

Unsupported attribute "table-id" on <base_refer>
Unsupported attribute "view-id" on <base_refer>
Instruction produced no document changes

如果尝试替换已有的
<base_refer>,也会因为属性不被支持而导致嵌入块无法保真写回。

预期结果

希望 docs +update
支持一种明确、文档化的方式,在 Docx 中创建或替换 Base 视图嵌入展示块,效果等价于用户在飞书客户端中粘贴 Base 视图链接并选择嵌入展示。

例如支持以下 XML:

<base_refer
  token="<BASE_TOKEN>"
  table-id="<TABLE_ID>"
  view-id="<VIEW_ID>">
</base_refer>

或者提供其他文档化写法,例如通过 reference_map 或专用 shortcut 完成:

lark-cli docs +base-embed \
  --doc '<DOCX_URL>' \
  --block-id '<ANCHOR_BLOCK_ID>' \
  --base-token '<BASE_TOKEN>' \
  --table-id '<TABLE_ID>' \
  --view-id '<VIEW_ID>'

影响场景

一个典型场景是需求记录模板中预置了“开发日志”Base 嵌入块。自动化流程需要:

  1. 复制模板文档;
  2. 在同一个 Base 表中创建新需求视图;
  3. 配置视图过滤;
  4. 删除模板中的旧 Base 嵌入块;
  5. 插入指向新需求视图的 Base 嵌入块。

目前第 1-4 步可以通过 CLI 完成,但第 5 步无法完成,只能人工在飞书 UI 中粘贴 Base 视图链接并生成嵌入展示。

已排除的情况

这不是 Base 视图管理能力缺失。当前 lark-cli base已支持视图创建和筛选配置,例如:

lark-cli base +view-create
lark-cli base +view-set-filter

也不是因为同一文档中不能共存多个 Base 嵌入块导致失败。实测先删除旧的 Base 嵌入块后,再插入新的<base_refer>,仍然会因为 table-id / view-id 属性不被支持而失败。

建议

希望在 docs +update 的 XML 写入能力中支持 <base_refer> / <bitable>
tokentable-idview-id 属性;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with docs +update using both <base_refer> and , then compare it with docs +fetch output. Read the document XML handling and the existing base +view-create and +view-set-filter entry points to determine how embedded views are represented. Done means a documented, working way to create and replace a Base view embed while preserving it through fetch and update.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.