bug(whiteboard): whiteboard-cli 把 DSL 转成 OpenAPI 时,带文字的形状被拆成“空形状 + 独立文字节点”(whiteboard-cli 0.2.13)

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
54/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, node.js
Domain
backend, cli

Research direction

Start by locating the whiteboard-cli code that converts DSL nodes to OpenAPI nodes; the issue provides a minimal JSON input and an exact command to reproduce the split. Check how rect and ellipse text is represented in the converter and compare it with the raw shape structure described in the issue. Done means the conversion produces one composite_shape with its text inline, or adds a documented option for that output.

Written by the indexing model from the issue text.

Description

bug domain/core domain/doc domain/whiteboard
问题描述

用 DSL 描述一个带 text 的 rect / ellipse,whiteboard-cli --to openapi 生成的节点里,形状(composite_shape)本身没有文字,文字被放进另一个覆盖在形状上的 text_shape。一个带文字的形状因此变成两个对象,节点数翻倍,维护时要同时处理两个对象。

飞书画板本身支持把文字内置在形状里:在画板里手动给形状输入文字,再用 whiteboard +export --output-type raw 导出,得到的是单个 composite_shape,文字在它自己的 text 字段里。所以这不是画板能力的限制,而是转换器的输出方式。

目前没有找到开关可以关闭这一行为:whiteboard-cli --help 列出的全部选项(-i -o -f -t -s -l -F -b -d --check 等)里没有与文字相关的;lark-whiteboard skill 的 DSL schema 中,Shape 的 text 字段说明的也是形状自带文字,与实际输出不一致。

环境
  • lark-cli version 1.0.97
  • @larksuite/whiteboard-cli 0.2.13(npm latest)
  • Node.js v24.19.0
  • macOS 27.0.1 arm64
  • 飞书国内版
最小复现:无需飞书账号

建立 a.json:

{"version":2,"nodes":[
 {"type":"rect","id":"r1","x":0,"y":0,"width":200,"height":80,"text":"plain text",
  "fillColor":"#E8F0FE","borderColor":"#3370FF","borderWidth":2,"borderRadius":8}
]}

执行:

npx -y @larksuite/[email protected] -i a.json --to openapi --format json

data.result.nodes 中得到两个节点(省略无关字段):

o001:1  type=composite_shape  composite_shape.type=round_rect  (无 text 字段)  width=200 height=80
a001:1  type=text_shape       text.text="plain text"            width=200 height=20  (覆盖在形状上)

ellipse、带 textAlign: "left"、带富文本 run 的矩形、以及 frame 内的文字子节点,都是同样的拆分结果。

期望行为

带文字的形状直接输出一个 composite_shape,文字写在它自己的 text 里(与画板导出的形状文字结构一致),不再额外生成覆盖用的 text_shape;或者提供一个选项(例如 --inline-text)让使用者选择。

影响
  • 用 DSL 绘制泳道图、架构图时,每个带文字的节点、每条泳道容器的标题都会多出一个独立对象。
  • 对已经习惯“文字属于形状”的维护方式(形状内编辑文字、整体选中与移动)不友好。
临时绕过

转换后写一个后处理脚本,把每个 text_shape 并回包含它的形状的 text 字段,再用 lark-cli whiteboard +update --input_format raw 写入。需要注意:写入形状文字时,字段要使用画板自己返回的形状文字结构;把云端导出的文字对象(含 theme_text_color_code 等)原样写回会被接口以 field validation failed 拒绝。

补充
  • 与 #2829 同属 whiteboard-cli 0.2.13 的输出问题,但现象不同,没有发现重复 issue。
  • 若这是有意设计(例如为了精确控制文字位置),希望文档中说明,并提供内置文字的写法。
Dominant language
Go
Stars
18.2k
Forks
1.4k
Avg merge
1d 3h
Merged PRs (30d)
18

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

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.

More from larksuite/cli

All issues in larksuite/cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.