feat(diagram-engine): flex knobs (grow/align/pad) + inline rich-text labels

The expressiveness gap between engine output and hand-written XML came down
to two missing capabilities, both generic:

- Block layout inside a box: nested containers already existed, but there was
  no way to split space by weight, pin a child to an edge, or tighten padding.
  Added grow (flex-grow over the parent's leftover flow-axis space, TeX's
  glue), align (start/center/end/stretch on the cross axis) and pad
  (per-group interior padding). All three round-trip via dai_grow/dai_align/
  dai_pad markers.

- Inline rich text: labels already render HTML (html=1 on every style, esc()
  entities decode back), but the measure pass counted markup as text. The
  visibleText() strip makes autoBoxSize measure what draw.io draws: <br> is a
  line, other inline tags are invisible.

Graphviz (HTML-like table labels), D2 (grid containers + markdown-in-shape)
and TeX (box+glue) converged on exactly this design: nested boxes for block
structure, proportional glue, a small inline set for text — never full HTML.

Prompts teach the composition with a comparison-card recipe; verified by
rebuilding the CoT poster end to end in the real editor.
This commit is contained in:
dayuan.jiang
2026-08-09 20:55:12 +09:00
parent e78322ca52
commit db9db1ff4e
9 changed files with 432 additions and 23 deletions

View File

@@ -25,6 +25,12 @@ export interface PoolCell {
col: number
}
/**
* Cross-axis behaviour of a child inside a row/col group, CSS's align-items per child:
* pin to either edge, centre (the default), or stretch to fill the axis.
*/
export type Align = "start" | "center" | "end" | "stretch"
/**
* The outline a flowchart box is drawn with.
*
@@ -73,6 +79,10 @@ export interface BoxNode {
role?: Role
/** Semantic zone name; every node sharing a group gets the same hue ramp. */
group?: string
/** Share of the parent's leftover flow-axis space, like flex-grow. 0/absent = natural size. */
grow?: number
/** Cross-axis behaviour within the parent. Absent = center; stretch = fill it. */
align?: Align
/** Flowchart outline. Absent means a plain rectangle. */
shape?: BoxShape
style?: string
@@ -109,6 +119,12 @@ export interface GroupNode {
role?: Role
/** Semantic zone name; the panel takes this hue's tint. */
group?: string
/** Share of the parent's leftover flow-axis space, like flex-grow. */
grow?: number
/** Cross-axis behaviour within the parent. Absent = center; stretch = fill it. */
align?: Align
/** Interior padding, px. Absent = the default (24). */
pad?: number
style?: string
pinned?: boolean
rect?: Rect