bug(whiteboard): SVG 转 OpenAPI 时连线不绑定形状,独立三角箭头被转成单独节点(whiteboard-cli 0.2.13)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with routes/svg.md and trace the SVG-to-OpenAPI conversion for line, path, and polygon elements; the payload does not name converter source files or tests. Reproduce with the supplied c.svg and CLI command, then compare the result with the DSL connector output. Done means endpoints on shapes are attached and small arrow triangles are represented by the connector’s arrow_style instead of separate nodes, or the SVG route documents the stated limitations.
Written by the indexing model from the issue text.
Description
问题描述
按 lark-whiteboard skill 的 SVG 路线(routes/svg.md)绘图并用 whiteboard-cli -f svg --to openapi 转换后,连线有两个问题:
- 连线不绑定形状。 SVG 中的
<line>/<path>只转成带绝对坐标position的connector,即使端点正好落在<rect>边上,也不会生成attached_object/start_object/end_object。写入画板后,连线看起来连着方块,拖动方块时线不跟着动。 - 单独画的箭头变成独立对象。 用
<polygon>画的三角箭头被转成一个独立的svg节点,没有并入连线的arrow_style。一条带箭头的线因此变成“线 + 三角”两个对象,移动或修改时要分别处理。
飞书画板本身有原生的带箭头连线,并且支持连线吸附到形状。DSL 路线已经能输出绑定好的连线(见下方对照),所以这是 SVG 解析的输出方式问题。
环境
lark-cli version 1.0.97@larksuite/whiteboard-cli 0.2.13- macOS 27.0.1 arm64,飞书国内版
最小复现:无需飞书账号
c.svg:
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="200" viewBox="0 0 500 200">
<rect x="20" y="60" width="160" height="80" rx="8" fill="#EEF" stroke="#36C"/>
<rect x="320" y="60" width="160" height="80" rx="8" fill="#EEF" stroke="#36C"/>
<line x1="180" y1="100" x2="308" y2="100" stroke="#6D8EBE" stroke-width="2"/>
<polygon points="320,100 308,94 308,106" fill="#6D8EBE"/>
</svg>
npx -y @larksuite/[email protected] -i c.svg -f svg --to openapi --format json
得到(省略无关字段):
composite_shape (矩形 A)
composite_shape (矩形 B)
connector start.position={x:180,y:100} end.position={x:308,y:100} end.arrow_style=none (无 attached_object)
svg (三角箭头,独立节点)
用 marker-end 画箭头时箭头能变成 arrow_style: triangle_arrow,但连线同样只有绝对坐标,不绑定形状。
对照:同样的两个矩形和一条连线用 DSL("connector": {"from":"r1","to":"r2","fromAnchor":"right","toAnchor":"left","endArrow":"arrow"})转换,得到的 connector 带 start_object / end_object,拖动形状时线会跟着走。
期望行为
- 连线端点落在形状边缘(或在一定容差内)时,自动输出
attached_object/start_object/end_object,并换算出snap_to与相对position。 - 紧贴连线端点、作为箭头使用的小三角
<polygon>/<path>,识别后并入该连线的arrow_style,不再输出独立节点。 - 如果暂不支持,希望在
routes/svg.md中说明:需要可维护连线的图优先走 DSL 路线,SVG 中箭头只用marker-end。
影响
- 以 SVG 生成、后续需要人工维护的流程图和架构图,每条连线都要手动重新连接;带箭头的线对象数翻倍。
- 后续用户在画板上拖动方块调整布局时,连线和箭头会和方块脱离。
补充
- 与 #2855(带文字的形状被拆成“空形状 + 独立文字节点”)同属转换器输出问题,现象不同。
- 我们本地的临时绕过:转换后用后处理脚本,把端点落在形状边缘上的连线改成绑定形状,删掉紧贴端点的三角形节点,并把对应连线的
arrow_style设为原生箭头,再用lark-cli whiteboard +update --input_format raw写入。
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from larksuite/cli
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
domain/im
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug domain/doc
Difficulty 1/5 Under an hour Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
mail: all-ASCII draft bodies are hard-wrapped every 998 bytes, inserting newlines inside words and tagsPossibly taken @linye157 claimed this 26 days ago. Opendomain/mail
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
auth: a 429 from the Token Endpoint during refresh deletes a still-valid loginPossibly taken @linye157 claimed this 26 days ago. Openbug domain/auth domain/im
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
larksuite/cli#2869 · 5 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
github/github-mcp-server#3960 ·
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
JuliusBrussee/caveman#1594 ·
Maintainers usually reply within 1 day
-
C-bug O-community X-blathers-triaged
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
cockroachdb/cockroach#176264 · 1 comment ·
-
security trivy
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
kubefleet-dev/kubefleet#1068 ·
Maintainers usually reply within 3 days