bug(whiteboard): SVG 转 OpenAPI 时连线不绑定形状,独立三角箭头被转成单独节点(whiteboard-cli 0.2.13)

Open
#2,861 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
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

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

bug domain/core domain/whiteboard
问题描述

按 lark-whiteboard skill 的 SVG 路线(routes/svg.md)绘图并用 whiteboard-cli -f svg --to openapi 转换后,连线有两个问题:

  1. 连线不绑定形状。 SVG 中的 <line> / <path> 只转成带绝对坐标 position 的 connector,即使端点正好落在 <rect> 边上,也不会生成 attached_object / start_object / end_object。写入画板后,连线看起来连着方块,拖动方块时线不跟着动。
  2. 单独画的箭头变成独立对象。 用 <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

  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.