@md2nativedocx/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/diagrams/architecture-diagram/parser.d.ts +29 -0
- package/dist/diagrams/architecture-diagram/parser.js +142 -0
- package/dist/diagrams/architecture-diagram/parser.js.map +1 -0
- package/dist/diagrams/architecture-diagram/translator.d.ts +41 -0
- package/dist/diagrams/architecture-diagram/translator.js +172 -0
- package/dist/diagrams/architecture-diagram/translator.js.map +1 -0
- package/dist/diagrams/architecture-diagram/types.d.ts +39 -0
- package/dist/diagrams/architecture-diagram/types.js +18 -0
- package/dist/diagrams/architecture-diagram/types.js.map +1 -0
- package/dist/diagrams/block/parser.d.ts +17 -0
- package/dist/diagrams/block/parser.js +312 -0
- package/dist/diagrams/block/parser.js.map +1 -0
- package/dist/diagrams/block/translator.d.ts +16 -0
- package/dist/diagrams/block/translator.js +137 -0
- package/dist/diagrams/block/translator.js.map +1 -0
- package/dist/diagrams/block/types.d.ts +38 -0
- package/dist/diagrams/block/types.js +6 -0
- package/dist/diagrams/block/types.js.map +1 -0
- package/dist/diagrams/c4/parser.d.ts +29 -0
- package/dist/diagrams/c4/parser.js +264 -0
- package/dist/diagrams/c4/parser.js.map +1 -0
- package/dist/diagrams/c4/translator.d.ts +50 -0
- package/dist/diagrams/c4/translator.js +240 -0
- package/dist/diagrams/c4/translator.js.map +1 -0
- package/dist/diagrams/c4/types.d.ts +74 -0
- package/dist/diagrams/c4/types.js +46 -0
- package/dist/diagrams/c4/types.js.map +1 -0
- package/dist/diagrams/class-diagram/parser.d.ts +40 -0
- package/dist/diagrams/class-diagram/parser.js +213 -0
- package/dist/diagrams/class-diagram/parser.js.map +1 -0
- package/dist/diagrams/class-diagram/translator.d.ts +48 -0
- package/dist/diagrams/class-diagram/translator.js +197 -0
- package/dist/diagrams/class-diagram/translator.js.map +1 -0
- package/dist/diagrams/class-diagram/types.d.ts +54 -0
- package/dist/diagrams/class-diagram/types.js +16 -0
- package/dist/diagrams/class-diagram/types.js.map +1 -0
- package/dist/diagrams/cynefin/parser.d.ts +24 -0
- package/dist/diagrams/cynefin/parser.js +102 -0
- package/dist/diagrams/cynefin/parser.js.map +1 -0
- package/dist/diagrams/cynefin/translator.d.ts +37 -0
- package/dist/diagrams/cynefin/translator.js +190 -0
- package/dist/diagrams/cynefin/translator.js.map +1 -0
- package/dist/diagrams/cynefin/types.d.ts +45 -0
- package/dist/diagrams/cynefin/types.js +36 -0
- package/dist/diagrams/cynefin/types.js.map +1 -0
- package/dist/diagrams/er-diagram/parser.d.ts +29 -0
- package/dist/diagrams/er-diagram/parser.js +156 -0
- package/dist/diagrams/er-diagram/parser.js.map +1 -0
- package/dist/diagrams/er-diagram/translator.d.ts +26 -0
- package/dist/diagrams/er-diagram/translator.js +151 -0
- package/dist/diagrams/er-diagram/translator.js.map +1 -0
- package/dist/diagrams/er-diagram/types.d.ts +44 -0
- package/dist/diagrams/er-diagram/types.js +17 -0
- package/dist/diagrams/er-diagram/types.js.map +1 -0
- package/dist/diagrams/event-modeling/parser.d.ts +16 -0
- package/dist/diagrams/event-modeling/parser.js +193 -0
- package/dist/diagrams/event-modeling/parser.js.map +1 -0
- package/dist/diagrams/event-modeling/translator.d.ts +17 -0
- package/dist/diagrams/event-modeling/translator.js +154 -0
- package/dist/diagrams/event-modeling/translator.js.map +1 -0
- package/dist/diagrams/event-modeling/types.d.ts +46 -0
- package/dist/diagrams/event-modeling/types.js +6 -0
- package/dist/diagrams/event-modeling/types.js.map +1 -0
- package/dist/diagrams/gantt/date-utils.d.ts +51 -0
- package/dist/diagrams/gantt/date-utils.js +131 -0
- package/dist/diagrams/gantt/date-utils.js.map +1 -0
- package/dist/diagrams/gantt/parser.d.ts +37 -0
- package/dist/diagrams/gantt/parser.js +221 -0
- package/dist/diagrams/gantt/parser.js.map +1 -0
- package/dist/diagrams/gantt/translator.d.ts +23 -0
- package/dist/diagrams/gantt/translator.js +259 -0
- package/dist/diagrams/gantt/translator.js.map +1 -0
- package/dist/diagrams/gantt/types.d.ts +31 -0
- package/dist/diagrams/gantt/types.js +14 -0
- package/dist/diagrams/gantt/types.js.map +1 -0
- package/dist/diagrams/git-graph/parser.d.ts +29 -0
- package/dist/diagrams/git-graph/parser.js +237 -0
- package/dist/diagrams/git-graph/parser.js.map +1 -0
- package/dist/diagrams/git-graph/translator.d.ts +49 -0
- package/dist/diagrams/git-graph/translator.js +224 -0
- package/dist/diagrams/git-graph/translator.js.map +1 -0
- package/dist/diagrams/git-graph/types.d.ts +72 -0
- package/dist/diagrams/git-graph/types.js +35 -0
- package/dist/diagrams/git-graph/types.js.map +1 -0
- package/dist/diagrams/ishikawa/parser.d.ts +15 -0
- package/dist/diagrams/ishikawa/parser.js +85 -0
- package/dist/diagrams/ishikawa/parser.js.map +1 -0
- package/dist/diagrams/ishikawa/translator.d.ts +12 -0
- package/dist/diagrams/ishikawa/translator.js +95 -0
- package/dist/diagrams/ishikawa/translator.js.map +1 -0
- package/dist/diagrams/ishikawa/types.d.ts +19 -0
- package/dist/diagrams/ishikawa/types.js +6 -0
- package/dist/diagrams/ishikawa/types.js.map +1 -0
- package/dist/diagrams/journey/parser.d.ts +14 -0
- package/dist/diagrams/journey/parser.js +78 -0
- package/dist/diagrams/journey/parser.js.map +1 -0
- package/dist/diagrams/journey/translator.d.ts +11 -0
- package/dist/diagrams/journey/translator.js +90 -0
- package/dist/diagrams/journey/translator.js.map +1 -0
- package/dist/diagrams/journey/types.d.ts +20 -0
- package/dist/diagrams/journey/types.js +6 -0
- package/dist/diagrams/journey/types.js.map +1 -0
- package/dist/diagrams/kanban/parser.d.ts +17 -0
- package/dist/diagrams/kanban/parser.js +129 -0
- package/dist/diagrams/kanban/parser.js.map +1 -0
- package/dist/diagrams/kanban/translator.d.ts +13 -0
- package/dist/diagrams/kanban/translator.js +72 -0
- package/dist/diagrams/kanban/translator.js.map +1 -0
- package/dist/diagrams/kanban/types.d.ts +21 -0
- package/dist/diagrams/kanban/types.js +6 -0
- package/dist/diagrams/kanban/types.js.map +1 -0
- package/dist/diagrams/mindmap/parser.d.ts +23 -0
- package/dist/diagrams/mindmap/parser.js +108 -0
- package/dist/diagrams/mindmap/parser.js.map +1 -0
- package/dist/diagrams/mindmap/translator.d.ts +31 -0
- package/dist/diagrams/mindmap/translator.js +249 -0
- package/dist/diagrams/mindmap/translator.js.map +1 -0
- package/dist/diagrams/mindmap/types.d.ts +19 -0
- package/dist/diagrams/mindmap/types.js +10 -0
- package/dist/diagrams/mindmap/types.js.map +1 -0
- package/dist/diagrams/packet/parser.d.ts +15 -0
- package/dist/diagrams/packet/parser.js +99 -0
- package/dist/diagrams/packet/parser.js.map +1 -0
- package/dist/diagrams/packet/translator.d.ts +14 -0
- package/dist/diagrams/packet/translator.js +66 -0
- package/dist/diagrams/packet/translator.js.map +1 -0
- package/dist/diagrams/packet/types.d.ts +14 -0
- package/dist/diagrams/packet/types.js +6 -0
- package/dist/diagrams/packet/types.js.map +1 -0
- package/dist/diagrams/pie/chart.d.ts +26 -0
- package/dist/diagrams/pie/chart.js +64 -0
- package/dist/diagrams/pie/chart.js.map +1 -0
- package/dist/diagrams/pie/parser.d.ts +18 -0
- package/dist/diagrams/pie/parser.js +93 -0
- package/dist/diagrams/pie/parser.js.map +1 -0
- package/dist/diagrams/pie/translator.d.ts +15 -0
- package/dist/diagrams/pie/translator.js +150 -0
- package/dist/diagrams/pie/translator.js.map +1 -0
- package/dist/diagrams/pie/types.d.ts +16 -0
- package/dist/diagrams/pie/types.js +6 -0
- package/dist/diagrams/pie/types.js.map +1 -0
- package/dist/diagrams/quadrant/parser.d.ts +24 -0
- package/dist/diagrams/quadrant/parser.js +96 -0
- package/dist/diagrams/quadrant/parser.js.map +1 -0
- package/dist/diagrams/quadrant/translator.d.ts +21 -0
- package/dist/diagrams/quadrant/translator.js +204 -0
- package/dist/diagrams/quadrant/translator.js.map +1 -0
- package/dist/diagrams/quadrant/types.d.ts +41 -0
- package/dist/diagrams/quadrant/types.js +10 -0
- package/dist/diagrams/quadrant/types.js.map +1 -0
- package/dist/diagrams/radar/chart.d.ts +21 -0
- package/dist/diagrams/radar/chart.js +65 -0
- package/dist/diagrams/radar/chart.js.map +1 -0
- package/dist/diagrams/radar/parser.d.ts +15 -0
- package/dist/diagrams/radar/parser.js +186 -0
- package/dist/diagrams/radar/parser.js.map +1 -0
- package/dist/diagrams/radar/translator.d.ts +12 -0
- package/dist/diagrams/radar/translator.js +98 -0
- package/dist/diagrams/radar/translator.js.map +1 -0
- package/dist/diagrams/radar/types.d.ts +29 -0
- package/dist/diagrams/radar/types.js +6 -0
- package/dist/diagrams/radar/types.js.map +1 -0
- package/dist/diagrams/requirement-diagram/parser.d.ts +29 -0
- package/dist/diagrams/requirement-diagram/parser.js +156 -0
- package/dist/diagrams/requirement-diagram/parser.js.map +1 -0
- package/dist/diagrams/requirement-diagram/translator.d.ts +24 -0
- package/dist/diagrams/requirement-diagram/translator.js +214 -0
- package/dist/diagrams/requirement-diagram/translator.js.map +1 -0
- package/dist/diagrams/requirement-diagram/types.d.ts +37 -0
- package/dist/diagrams/requirement-diagram/types.js +18 -0
- package/dist/diagrams/requirement-diagram/types.js.map +1 -0
- package/dist/diagrams/sankey/parser.d.ts +14 -0
- package/dist/diagrams/sankey/parser.js +123 -0
- package/dist/diagrams/sankey/parser.js.map +1 -0
- package/dist/diagrams/sankey/translator.d.ts +15 -0
- package/dist/diagrams/sankey/translator.js +132 -0
- package/dist/diagrams/sankey/translator.js.map +1 -0
- package/dist/diagrams/sankey/types.d.ts +16 -0
- package/dist/diagrams/sankey/types.js +6 -0
- package/dist/diagrams/sankey/types.js.map +1 -0
- package/dist/diagrams/sequence/parser.d.ts +22 -0
- package/dist/diagrams/sequence/parser.js +256 -0
- package/dist/diagrams/sequence/parser.js.map +1 -0
- package/dist/diagrams/sequence/translator.d.ts +21 -0
- package/dist/diagrams/sequence/translator.js +309 -0
- package/dist/diagrams/sequence/translator.js.map +1 -0
- package/dist/diagrams/sequence/types.d.ts +62 -0
- package/dist/diagrams/sequence/types.js +8 -0
- package/dist/diagrams/sequence/types.js.map +1 -0
- package/dist/diagrams/state-diagram/parser.d.ts +37 -0
- package/dist/diagrams/state-diagram/parser.js +215 -0
- package/dist/diagrams/state-diagram/parser.js.map +1 -0
- package/dist/diagrams/state-diagram/translator.d.ts +25 -0
- package/dist/diagrams/state-diagram/translator.js +165 -0
- package/dist/diagrams/state-diagram/translator.js.map +1 -0
- package/dist/diagrams/state-diagram/types.d.ts +38 -0
- package/dist/diagrams/state-diagram/types.js +13 -0
- package/dist/diagrams/state-diagram/types.js.map +1 -0
- package/dist/diagrams/timeline/parser.d.ts +17 -0
- package/dist/diagrams/timeline/parser.js +82 -0
- package/dist/diagrams/timeline/parser.js.map +1 -0
- package/dist/diagrams/timeline/translator.d.ts +13 -0
- package/dist/diagrams/timeline/translator.js +90 -0
- package/dist/diagrams/timeline/translator.js.map +1 -0
- package/dist/diagrams/timeline/types.d.ts +18 -0
- package/dist/diagrams/timeline/types.js +6 -0
- package/dist/diagrams/timeline/types.js.map +1 -0
- package/dist/diagrams/tree-view/parser.d.ts +16 -0
- package/dist/diagrams/tree-view/parser.js +129 -0
- package/dist/diagrams/tree-view/parser.js.map +1 -0
- package/dist/diagrams/tree-view/translator.d.ts +11 -0
- package/dist/diagrams/tree-view/translator.js +73 -0
- package/dist/diagrams/tree-view/translator.js.map +1 -0
- package/dist/diagrams/tree-view/types.d.ts +22 -0
- package/dist/diagrams/tree-view/types.js +6 -0
- package/dist/diagrams/tree-view/types.js.map +1 -0
- package/dist/diagrams/treemap/parser.d.ts +15 -0
- package/dist/diagrams/treemap/parser.js +131 -0
- package/dist/diagrams/treemap/parser.js.map +1 -0
- package/dist/diagrams/treemap/translator.d.ts +15 -0
- package/dist/diagrams/treemap/translator.js +136 -0
- package/dist/diagrams/treemap/translator.js.map +1 -0
- package/dist/diagrams/treemap/types.d.ts +22 -0
- package/dist/diagrams/treemap/types.js +6 -0
- package/dist/diagrams/treemap/types.js.map +1 -0
- package/dist/diagrams/venn/parser.d.ts +27 -0
- package/dist/diagrams/venn/parser.js +129 -0
- package/dist/diagrams/venn/parser.js.map +1 -0
- package/dist/diagrams/venn/translator.d.ts +25 -0
- package/dist/diagrams/venn/translator.js +214 -0
- package/dist/diagrams/venn/translator.js.map +1 -0
- package/dist/diagrams/venn/types.d.ts +33 -0
- package/dist/diagrams/venn/types.js +11 -0
- package/dist/diagrams/venn/types.js.map +1 -0
- package/dist/diagrams/wardley/parser.d.ts +14 -0
- package/dist/diagrams/wardley/parser.js +254 -0
- package/dist/diagrams/wardley/parser.js.map +1 -0
- package/dist/diagrams/wardley/translator.d.ts +15 -0
- package/dist/diagrams/wardley/translator.js +196 -0
- package/dist/diagrams/wardley/translator.js.map +1 -0
- package/dist/diagrams/wardley/types.d.ts +74 -0
- package/dist/diagrams/wardley/types.js +8 -0
- package/dist/diagrams/wardley/types.js.map +1 -0
- package/dist/diagrams/xychart/chart.d.ts +24 -0
- package/dist/diagrams/xychart/chart.js +113 -0
- package/dist/diagrams/xychart/chart.js.map +1 -0
- package/dist/diagrams/xychart/parser.d.ts +16 -0
- package/dist/diagrams/xychart/parser.js +190 -0
- package/dist/diagrams/xychart/parser.js.map +1 -0
- package/dist/diagrams/xychart/translator.d.ts +14 -0
- package/dist/diagrams/xychart/translator.js +187 -0
- package/dist/diagrams/xychart/translator.js.map +1 -0
- package/dist/diagrams/xychart/types.d.ts +32 -0
- package/dist/diagrams/xychart/types.js +6 -0
- package/dist/diagrams/xychart/types.js.map +1 -0
- package/dist/diagrams/zenuml/parser.d.ts +21 -0
- package/dist/diagrams/zenuml/parser.js +228 -0
- package/dist/diagrams/zenuml/parser.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -0
- package/dist/label-runs.d.ts +16 -0
- package/dist/label-runs.js +30 -0
- package/dist/label-runs.js.map +1 -0
- package/dist/layout/layout.d.ts +53 -0
- package/dist/layout/layout.js +536 -0
- package/dist/layout/layout.js.map +1 -0
- package/dist/parser/diagram-type.d.ts +41 -0
- package/dist/parser/diagram-type.js +97 -0
- package/dist/parser/diagram-type.js.map +1 -0
- package/dist/parser/index.d.ts +2 -0
- package/dist/parser/index.js +2 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/parser.d.ts +25 -0
- package/dist/parser/parser.js +1134 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/render-diagram.d.ts +156 -0
- package/dist/render-diagram.js +326 -0
- package/dist/render-diagram.js.map +1 -0
- package/dist/rendering-plan.d.ts +47 -0
- package/dist/rendering-plan.js +43 -0
- package/dist/rendering-plan.js.map +1 -0
- package/dist/smartart/chain.d.ts +216 -0
- package/dist/smartart/chain.js +558 -0
- package/dist/smartart/chain.js.map +1 -0
- package/dist/smartart/classify.d.ts +96 -0
- package/dist/smartart/classify.js +162 -0
- package/dist/smartart/classify.js.map +1 -0
- package/dist/smartart/cycle.d.ts +91 -0
- package/dist/smartart/cycle.js +323 -0
- package/dist/smartart/cycle.js.map +1 -0
- package/dist/smartart/dispatch.d.ts +48 -0
- package/dist/smartart/dispatch.js +49 -0
- package/dist/smartart/dispatch.js.map +1 -0
- package/dist/smartart/drawing.d.ts +155 -0
- package/dist/smartart/drawing.js +574 -0
- package/dist/smartart/drawing.js.map +1 -0
- package/dist/smartart/embed.d.ts +78 -0
- package/dist/smartart/embed.js +136 -0
- package/dist/smartart/embed.js.map +1 -0
- package/dist/smartart/from-graph.d.ts +42 -0
- package/dist/smartart/from-graph.js +106 -0
- package/dist/smartart/from-graph.js.map +1 -0
- package/dist/smartart/from-timeline.d.ts +30 -0
- package/dist/smartart/from-timeline.js +59 -0
- package/dist/smartart/from-timeline.js.map +1 -0
- package/dist/smartart/from-tree.d.ts +36 -0
- package/dist/smartart/from-tree.js +74 -0
- package/dist/smartart/from-tree.js.map +1 -0
- package/dist/smartart/generate-options.d.ts +12 -0
- package/dist/smartart/generate-options.js +2 -0
- package/dist/smartart/generate-options.js.map +1 -0
- package/dist/smartart/kanban.d.ts +24 -0
- package/dist/smartart/kanban.js +250 -0
- package/dist/smartart/kanban.js.map +1 -0
- package/dist/smartart/node-shape.d.ts +16 -0
- package/dist/smartart/node-shape.js +22 -0
- package/dist/smartart/node-shape.js.map +1 -0
- package/dist/smartart/styles.d.ts +114 -0
- package/dist/smartart/styles.js +141 -0
- package/dist/smartart/styles.js.map +1 -0
- package/dist/smartart/text.d.ts +16 -0
- package/dist/smartart/text.js +48 -0
- package/dist/smartart/text.js.map +1 -0
- package/dist/smartart/timeline-grouped.d.ts +40 -0
- package/dist/smartart/timeline-grouped.js +279 -0
- package/dist/smartart/timeline-grouped.js.map +1 -0
- package/dist/smartart/timeline.d.ts +51 -0
- package/dist/smartart/timeline.js +276 -0
- package/dist/smartart/timeline.js.map +1 -0
- package/dist/smartart/tree-deep.d.ts +61 -0
- package/dist/smartart/tree-deep.js +293 -0
- package/dist/smartart/tree-deep.js.map +1 -0
- package/dist/smartart/tree.d.ts +159 -0
- package/dist/smartart/tree.js +497 -0
- package/dist/smartart/tree.js.map +1 -0
- package/dist/translator/boxes.d.ts +36 -0
- package/dist/translator/boxes.js +95 -0
- package/dist/translator/boxes.js.map +1 -0
- package/dist/translator/canvas.d.ts +82 -0
- package/dist/translator/canvas.js +135 -0
- package/dist/translator/canvas.js.map +1 -0
- package/dist/translator/graph-shapes.d.ts +98 -0
- package/dist/translator/graph-shapes.js +223 -0
- package/dist/translator/graph-shapes.js.map +1 -0
- package/dist/translator/native-chart.d.ts +64 -0
- package/dist/translator/native-chart.js +109 -0
- package/dist/translator/native-chart.js.map +1 -0
- package/dist/translator/ooxml-translator.d.ts +79 -0
- package/dist/translator/ooxml-translator.js +1213 -0
- package/dist/translator/ooxml-translator.js.map +1 -0
- package/dist/translator/path-shape.d.ts +11 -0
- package/dist/translator/path-shape.js +37 -0
- package/dist/translator/path-shape.js.map +1 -0
- package/dist/translator/unsupported-diagram-note.d.ts +16 -0
- package/dist/translator/unsupported-diagram-note.js +34 -0
- package/dist/translator/unsupported-diagram-note.js.map +1 -0
- package/dist/translator/xml-escape.d.ts +28 -0
- package/dist/translator/xml-escape.js +40 -0
- package/dist/translator/xml-escape.js.map +1 -0
- package/dist/types.d.ts +158 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartArt generator for the `cycle` topology (`docs/specs/FUTURE_mmd2smartart_SPEC.md`
|
|
3
|
+
* §7 step 4; classification comes from {@link classifyTopology} in
|
|
4
|
+
* `./classify.ts`, not repeated here).
|
|
5
|
+
*
|
|
6
|
+
* Same four-part self-authored recipe as `chain.ts`/`tree.ts` (data/layout/
|
|
7
|
+
* colors/style, none copied from or derived from a real Word-emitted file —
|
|
8
|
+
* ADR 0004 "Round 5"), built around the public ECMA-376 `dgm:alg
|
|
9
|
+
* type="cycle"` algorithm (the one Word's own built-in "Basic Cycle" layout
|
|
10
|
+
* also uses, per `docs/smartart-layout-catalog.md` — but this `layoutDef` is
|
|
11
|
+
* original, not extracted from Word). `cycle` arranges its `forEach`-matched
|
|
12
|
+
* children evenly around a circle on its own; unlike `chain.ts`'s `lin`, it
|
|
13
|
+
* needs no manual spacer nodes between items.
|
|
14
|
+
*
|
|
15
|
+
* Verified this session by rendering the actual output under headless
|
|
16
|
+
* LibreOffice (session that built `docs/markdown-mermaid-compliance-table.md`):
|
|
17
|
+
* a 4-node cycle rendered as 4 correctly-styled boxes at top/right/bottom/
|
|
18
|
+
* left, in the right order, first try — no geometry bug like `tree.ts` hit.
|
|
19
|
+
* Same known limitation as `chain`/`tree`: no connector line is drawn
|
|
20
|
+
* between the boxes, only their circular position conveys the relationship.
|
|
21
|
+
*/
|
|
22
|
+
import { validateHexColor } from '../translator/xml-escape.js';
|
|
23
|
+
import { buildColorsXml, buildStyleXml } from './styles.js';
|
|
24
|
+
import { CYCLE_FRAME, DRAWING_EXT_LST_XML, buildDiagramDrawingXml, cycleBoxWidth, cycleShapes } from './drawing.js';
|
|
25
|
+
import { nodeGeom, presSpPrXml } from './node-shape.js';
|
|
26
|
+
import { boxText, pointTextXml } from './text.js';
|
|
27
|
+
const DGM_NS = 'http://schemas.openxmlformats.org/drawingml/2006/diagram';
|
|
28
|
+
const A_NS = 'http://schemas.openxmlformats.org/drawingml/2006/main';
|
|
29
|
+
/** `layoutDef` URN for the cycle algorithm (direction-independent — see module doc comment on `generateCycle`). */
|
|
30
|
+
export const CYCLE_LAYOUT_URN = 'urn:md2nativedocx/smartart-layout/cycle1';
|
|
31
|
+
/** `layoutDef` URN for a cycle of `n` nodes: the box size depends on `n`, so each count has its own definition. */
|
|
32
|
+
export function cycleLayoutUrn(n) {
|
|
33
|
+
return `${CYCLE_LAYOUT_URN}-n${n}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Original `dgm:layoutDef`: a `cycle` algorithm root and, per node, one leaf `Main` layoutNode via
|
|
37
|
+
* `forEach axis="ch"` — the same two-level shape as `chain.ts`'s `CHAIN_LAYOUT_XML`, which real Word
|
|
38
|
+
* renders correctly. The root sizes every `Main` child (`w` = 30% of the diagram's width, so the
|
|
39
|
+
* children fit around the circle); `Main` derives its own height from its width, exactly as `chain`'s
|
|
40
|
+
* `Main` does.
|
|
41
|
+
*
|
|
42
|
+
* This replaces an earlier three-level version (`root` → `composite` → `Main`) that real Word drew as an
|
|
43
|
+
* empty frame (2026-09-06 round 2: container and data pane present, no shape) while LibreOffice drew four
|
|
44
|
+
* boxes. The cause is **suspected, not proven**: that version sized its children with a `diam` constraint
|
|
45
|
+
* and gave the `composite` wrapper no `w`/`h` of its own, whereas `chain.ts` sizes `Main` with plain
|
|
46
|
+
* `w`/`h` constraints from the root. (`tree.ts` also has a constraint-free `composite` and renders in Word,
|
|
47
|
+
* so the wrapper alone is not the explanation.) Real-Word confirmation: CHECKLIST Round 6. With the
|
|
48
|
+
* pre-rendered `dsp:drawing` (`drawing.ts`) Word shows the cached shapes either way until the diagram is
|
|
49
|
+
* edited. No `sibTrans` spacer nodes — `cycle` positions its children
|
|
50
|
+
* itself, it doesn't need `lin`'s manual inter-item spacer.
|
|
51
|
+
*/
|
|
52
|
+
export function cycleLayoutXml(n) {
|
|
53
|
+
const widthFact = (cycleBoxWidth(n) / CYCLE_FRAME.cx).toFixed(4);
|
|
54
|
+
return ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
55
|
+
`<dgm:layoutDef xmlns:dgm="${DGM_NS}" xmlns:a="${A_NS}" uniqueId="${cycleLayoutUrn(n)}">` +
|
|
56
|
+
'<dgm:title val=""/><dgm:desc val=""/>' +
|
|
57
|
+
'<dgm:catLst><dgm:cat type="cycle" pri="1"/></dgm:catLst>' +
|
|
58
|
+
'<dgm:sampData useDef="1"><dgm:dataModel><dgm:ptLst/><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:sampData>' +
|
|
59
|
+
'<dgm:styleData useDef="1"><dgm:dataModel><dgm:ptLst/><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:styleData>' +
|
|
60
|
+
'<dgm:clrData useDef="1"><dgm:dataModel><dgm:ptLst/><dgm:bg/><dgm:whole/></dgm:dataModel></dgm:clrData>' +
|
|
61
|
+
'<dgm:layoutNode name="root">' +
|
|
62
|
+
'<dgm:alg type="cycle"><dgm:param type="stAng" val="0"/></dgm:alg><dgm:shape/>' +
|
|
63
|
+
'<dgm:constrLst>' +
|
|
64
|
+
'<dgm:constr op="equ" type="primFontSz" for="des" ptType="node" val="20"/>' +
|
|
65
|
+
`<dgm:constr type="w" for="ch" forName="Main" refType="w" fact="${widthFact}"/>` +
|
|
66
|
+
'<dgm:constr op="equ" type="h" for="ch" forName="Main"/>' +
|
|
67
|
+
'<dgm:constr op="equ" type="w" for="ch" forName="sibTrans" refType="w" refFor="ch" refForName="Main" fact="0.4"/>' +
|
|
68
|
+
'<dgm:constr op="equ" type="h" for="ch" forName="sibTrans"/>' +
|
|
69
|
+
'</dgm:constrLst>' +
|
|
70
|
+
'<dgm:forEach name="nodesForEach" axis="ch" ptType="node">' +
|
|
71
|
+
'<dgm:layoutNode name="Main" styleLbl="node1">' +
|
|
72
|
+
'<dgm:alg type="tx"/>' +
|
|
73
|
+
'<dgm:shape type="roundRect"/>' +
|
|
74
|
+
'<dgm:presOf axis="self" ptType="node" st="1" cnt="0"/>' +
|
|
75
|
+
'<dgm:constrLst>' +
|
|
76
|
+
'<dgm:constr type="h" refType="w" fact="0.6"/>' +
|
|
77
|
+
'<dgm:constr type="lMarg" refType="primFontSz" fact="0.15"/>' +
|
|
78
|
+
'<dgm:constr type="rMarg" refType="primFontSz" fact="0.15"/>' +
|
|
79
|
+
'<dgm:constr type="tMarg" refType="primFontSz" fact="0.15"/>' +
|
|
80
|
+
'<dgm:constr type="bMarg" refType="primFontSz" fact="0.15"/>' +
|
|
81
|
+
'</dgm:constrLst>' +
|
|
82
|
+
'<dgm:ruleLst><dgm:rule type="primFontSz" val="5"/></dgm:ruleLst>' +
|
|
83
|
+
'</dgm:layoutNode>' +
|
|
84
|
+
// One transition arrow after every node, the last one closing the loop back to the first. Same
|
|
85
|
+
// `conn` node as chain.ts (nested in the node forEach, a sibling of `Main`). `hideLastTrans` defaults
|
|
86
|
+
// to true in the schema, which hides the arrow after the last node — right for a process, wrong for a
|
|
87
|
+
// loop: Word's own cycle layout sets it to 0, and without it the closing arrow is never drawn (found
|
|
88
|
+
// in real Word: every cycle lacked the last-to-first arrow, with and without the cached drawing).
|
|
89
|
+
'<dgm:forEach name="sibTransForEach" axis="followSib" ptType="sibTrans" hideLastTrans="0" cnt="1">' +
|
|
90
|
+
'<dgm:layoutNode name="sibTrans" styleLbl="sibTrans">' +
|
|
91
|
+
'<dgm:alg type="conn">' +
|
|
92
|
+
'<dgm:param type="begPts" val="auto"/>' +
|
|
93
|
+
'<dgm:param type="endPts" val="auto"/>' +
|
|
94
|
+
'</dgm:alg>' +
|
|
95
|
+
'<dgm:shape xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" type="conn" r:blip=""/>' +
|
|
96
|
+
'<dgm:presOf axis="self"/>' +
|
|
97
|
+
'<dgm:constrLst>' +
|
|
98
|
+
'<dgm:constr type="h" refType="w" fact="0.62"/>' +
|
|
99
|
+
'<dgm:constr type="connDist"/>' +
|
|
100
|
+
'<dgm:constr type="begPad" refType="connDist" fact="0.25"/>' +
|
|
101
|
+
'<dgm:constr type="endPad" refType="connDist" fact="0.22"/>' +
|
|
102
|
+
'</dgm:constrLst>' +
|
|
103
|
+
'</dgm:layoutNode>' +
|
|
104
|
+
'</dgm:forEach>' +
|
|
105
|
+
'</dgm:forEach>' +
|
|
106
|
+
'</dgm:layoutNode>' +
|
|
107
|
+
'</dgm:layoutDef>');
|
|
108
|
+
}
|
|
109
|
+
/** The layout for the most common case (4 nodes); `generateCycle` writes the one matching the node count. */
|
|
110
|
+
export const CYCLE_LAYOUT_XML = cycleLayoutXml(4);
|
|
111
|
+
/**
|
|
112
|
+
* Original `dgm:colorsDef` — single `styleLbl` (`node1`, the only style used
|
|
113
|
+
* by {@link CYCLE_LAYOUT_XML}'s `Main` layoutNode), theme-linked
|
|
114
|
+
* `a:schemeClr` fills (spec §10.4 theme-matching). Same pattern as
|
|
115
|
+
* `chain.ts`'s `CHAIN_COLORS_XML`.
|
|
116
|
+
*/
|
|
117
|
+
export const CYCLE_COLORS_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
118
|
+
`<dgm:colorsDef xmlns:dgm="${DGM_NS}" xmlns:a="${A_NS}" uniqueId="urn:md2nativedocx/smartart-colors/cycle1" minVer="12.0">` +
|
|
119
|
+
'<dgm:title val=""/><dgm:desc val=""/>' +
|
|
120
|
+
'<dgm:catLst><dgm:cat type="mainScheme" pri="1"/></dgm:catLst>' +
|
|
121
|
+
'<dgm:styleLbl name="node1">' +
|
|
122
|
+
'<dgm:fillClrLst><a:schemeClr val="accent1"/></dgm:fillClrLst>' +
|
|
123
|
+
'<dgm:linClrLst><a:schemeClr val="accent1"><a:shade val="75000"/></a:schemeClr></dgm:linClrLst>' +
|
|
124
|
+
'<dgm:effectClrLst/><dgm:txLinClrLst/>' +
|
|
125
|
+
'<dgm:txFillClrLst><a:schemeClr val="bg1"/></dgm:txFillClrLst>' +
|
|
126
|
+
'<dgm:txEffectClrLst/>' +
|
|
127
|
+
'</dgm:styleLbl>' +
|
|
128
|
+
'<dgm:styleLbl name="sibTrans">' +
|
|
129
|
+
'<dgm:fillClrLst><a:schemeClr val="accent1"><a:shade val="75000"/></a:schemeClr></dgm:fillClrLst>' +
|
|
130
|
+
'<dgm:linClrLst/>' +
|
|
131
|
+
'<dgm:effectClrLst/><dgm:txLinClrLst/><dgm:txFillClrLst/><dgm:txEffectClrLst/>' +
|
|
132
|
+
'</dgm:styleLbl>' +
|
|
133
|
+
'</dgm:colorsDef>';
|
|
134
|
+
/**
|
|
135
|
+
* Original `dgm:styleDef` — single `styleLbl`, same reference-based style
|
|
136
|
+
* vocabulary as `chain.ts`'s `CHAIN_STYLE_XML`.
|
|
137
|
+
*/
|
|
138
|
+
export const CYCLE_STYLE_XML = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
139
|
+
`<dgm:styleDef xmlns:dgm="${DGM_NS}" xmlns:a="${A_NS}" uniqueId="urn:md2nativedocx/smartart-quickstyle/cycle1" minVer="12.0">` +
|
|
140
|
+
'<dgm:title val=""/><dgm:desc val=""/>' +
|
|
141
|
+
'<dgm:catLst><dgm:cat type="simple" pri="1"/></dgm:catLst>' +
|
|
142
|
+
'<dgm:styleLbl name="node1">' +
|
|
143
|
+
'<dgm:style>' +
|
|
144
|
+
'<a:lnRef idx="0"><a:schemeClr val="accent1"/></a:lnRef>' +
|
|
145
|
+
'<a:fillRef idx="1"><a:schemeClr val="accent1"/></a:fillRef>' +
|
|
146
|
+
'<a:effectRef idx="0"><a:schemeClr val="accent1"/></a:effectRef>' +
|
|
147
|
+
'<a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef>' +
|
|
148
|
+
'</dgm:style>' +
|
|
149
|
+
'</dgm:styleLbl>' +
|
|
150
|
+
'<dgm:styleLbl name="sibTrans">' +
|
|
151
|
+
'<dgm:style>' +
|
|
152
|
+
'<a:lnRef idx="0"><a:schemeClr val="accent1"/></a:lnRef>' +
|
|
153
|
+
'<a:fillRef idx="1"><a:schemeClr val="accent1"/></a:fillRef>' +
|
|
154
|
+
'<a:effectRef idx="0"><a:schemeClr val="accent1"/></a:effectRef>' +
|
|
155
|
+
'<a:fontRef idx="minor"><a:schemeClr val="tx1"/></a:fontRef>' +
|
|
156
|
+
'</dgm:style>' +
|
|
157
|
+
'</dgm:styleLbl>' +
|
|
158
|
+
'</dgm:styleDef>';
|
|
159
|
+
/**
|
|
160
|
+
* Order a `cycle`-classified flowchart's nodes around the loop, starting
|
|
161
|
+
* arbitrarily at `flowchart.nodes[0]` and following `from -> to` edges.
|
|
162
|
+
* Assumes the flowchart has already been confirmed `cycle`-eligible by
|
|
163
|
+
* {@link classifyTopology} (`./classify.ts`) — every node in-degree ==
|
|
164
|
+
* out-degree == 1, connected, no root — so following `next` edges from any
|
|
165
|
+
* starting node visits every node exactly once and returns to the start.
|
|
166
|
+
* This function does not re-validate that; a non-cycle flowchart could loop
|
|
167
|
+
* forever or drop nodes silently.
|
|
168
|
+
*/
|
|
169
|
+
function orderedCycleNodes(flowchart) {
|
|
170
|
+
const byId = new Map(flowchart.nodes.map((n) => [n.id, n]));
|
|
171
|
+
const nextId = new Map(flowchart.edges.map((e) => [e.from, e.to]));
|
|
172
|
+
const startNode = flowchart.nodes[0];
|
|
173
|
+
if (!startNode) {
|
|
174
|
+
throw new Error('orderedCycleNodes: flowchart has no nodes -- not a valid cycle');
|
|
175
|
+
}
|
|
176
|
+
const ordered = [];
|
|
177
|
+
let currentId = startNode.id;
|
|
178
|
+
while (currentId !== undefined) {
|
|
179
|
+
const node = byId.get(currentId);
|
|
180
|
+
if (!node)
|
|
181
|
+
break;
|
|
182
|
+
ordered.push(node);
|
|
183
|
+
const next = nextId.get(currentId);
|
|
184
|
+
currentId = next === startNode.id ? undefined : next;
|
|
185
|
+
}
|
|
186
|
+
return ordered;
|
|
187
|
+
}
|
|
188
|
+
/** Map each node id to the label of the (single) edge that leads into it. */
|
|
189
|
+
function incomingLabelByNodeId(flowchart) {
|
|
190
|
+
const labels = new Map();
|
|
191
|
+
for (const edge of flowchart.edges) {
|
|
192
|
+
if (edge.label)
|
|
193
|
+
labels.set(edge.to, edge.label);
|
|
194
|
+
}
|
|
195
|
+
return labels;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Build the `dgm:dataModel` for a cycle of `nodes`, including the hand-built
|
|
199
|
+
* `presOf`/`presParOf` presentation mirror {@link CYCLE_LAYOUT_XML}'s own
|
|
200
|
+
* `root`/`Main` layoutNodes need to render under LibreOffice
|
|
201
|
+
* (same requirement as `chain.ts`/`tree.ts`, ADR 0004 "Round 5") — including
|
|
202
|
+
* the `doc`-point-to-`p-root` `presOf` that both those modules needed to fix
|
|
203
|
+
* an otherwise fully blank render.
|
|
204
|
+
*
|
|
205
|
+
* Also applies `edge.label` and `node.fill` the same way `chain.ts` does
|
|
206
|
+
* (spec §5.2 convention; content-point `spPr` solidFill) — see that
|
|
207
|
+
* module's doc comment for the full rationale and verification history.
|
|
208
|
+
*/
|
|
209
|
+
function buildCycleDataXml(flowchart, nodes, withDrawing, style) {
|
|
210
|
+
const docId = '0';
|
|
211
|
+
const layoutUrn = cycleLayoutUrn(nodes.length);
|
|
212
|
+
const nodeIds = nodes.map((_, i) => String(i + 1));
|
|
213
|
+
const incomingLabel = incomingLabelByNodeId(flowchart);
|
|
214
|
+
// ST_ModelId (ECMA-376 §21.4) only accepts an unsigned integer or a GUID
|
|
215
|
+
// -- never an arbitrary string. Content point ids above were already
|
|
216
|
+
// numeric ("0", "1", "2"...) and passed; every presentation point and
|
|
217
|
+
// connection id below used to be a custom string ("p-root", "c1", "po0",
|
|
218
|
+
// "pp1a"...), which is schema-invalid. Found with the Open XML SDK's
|
|
219
|
+
// OpenXmlValidator (the same validator/schema real Word enforces
|
|
220
|
+
// strictly, which is why this was never caught by LibreOffice or by
|
|
221
|
+
// manual XML-well-formedness checks) -- this, not the presence/absence of
|
|
222
|
+
// any dsp:drawing fallback, was the actual cause of TODO.md's "Incident
|
|
223
|
+
// SmartArt 'cycle' cassé en Word réel". ADR 0004 "Round 3"'s finding that
|
|
224
|
+
// "modelId format has no effect on rendering" was only ever verified
|
|
225
|
+
// under LibreOffice, which does not validate against the schema at all.
|
|
226
|
+
let nextModelId = nodes.length + 1;
|
|
227
|
+
const newModelId = () => String(nextModelId++);
|
|
228
|
+
const pRootId = newModelId();
|
|
229
|
+
const pMainIds = new Map(nodeIds.map((id) => [id, newModelId()]));
|
|
230
|
+
// One transition per node — the last one closes the loop back to the first.
|
|
231
|
+
const sibTransIds = nodeIds.map(() => newModelId());
|
|
232
|
+
const parTransIds = nodeIds.map(() => newModelId());
|
|
233
|
+
const pSibTransIds = nodeIds.map(() => newModelId());
|
|
234
|
+
const contentPts = nodes
|
|
235
|
+
.map((node, i) => {
|
|
236
|
+
const label = incomingLabel.get(node.id);
|
|
237
|
+
const text = boxText(node, label);
|
|
238
|
+
const fill = validateHexColor(node.fill, '');
|
|
239
|
+
const spPr = fill
|
|
240
|
+
? `<dgm:spPr><a:solidFill><a:srgbClr val="${fill}"/></a:solidFill></dgm:spPr>`
|
|
241
|
+
: '<dgm:spPr/>';
|
|
242
|
+
return (`<dgm:pt modelId="${nodeIds[i]}"><dgm:prSet phldrT="[Texte]"/>${spPr}${pointTextXml(text)}</dgm:pt>` +
|
|
243
|
+
`<dgm:pt modelId="${parTransIds[i]}" type="parTrans"><dgm:prSet/></dgm:pt>` +
|
|
244
|
+
`<dgm:pt modelId="${sibTransIds[i]}" type="sibTrans"><dgm:prSet/></dgm:pt>`);
|
|
245
|
+
})
|
|
246
|
+
.join('');
|
|
247
|
+
const presPts = `<dgm:pt modelId="${pRootId}" type="pres"><dgm:prSet presAssocID="${docId}" presName="root" presStyleCnt="0"/><dgm:spPr/></dgm:pt>` +
|
|
248
|
+
nodeIds
|
|
249
|
+
.map((id, i) => `<dgm:pt modelId="${pMainIds.get(id)}" type="pres"><dgm:prSet presAssocID="${id}" presName="Main" presStyleLbl="node1" presStyleIdx="${i}" presStyleCnt="${nodeIds.length}"/>${presSpPrXml(nodeGeom(nodes[i]))}</dgm:pt>`)
|
|
250
|
+
.join('') +
|
|
251
|
+
sibTransIds
|
|
252
|
+
.map((id, i) => `<dgm:pt modelId="${pSibTransIds[i]}" type="pres"><dgm:prSet presAssocID="${id}" presName="sibTrans" presStyleLbl="sibTrans" presStyleIdx="${i}" presStyleCnt="${sibTransIds.length}"/><dgm:spPr/></dgm:pt>`)
|
|
253
|
+
.join('');
|
|
254
|
+
const parOfCxns = nodeIds
|
|
255
|
+
.map((id, i) => `<dgm:cxn modelId="${newModelId()}" type="parOf" srcId="${docId}" destId="${id}" srcOrd="${i}" destOrd="0" parTransId="${parTransIds[i]}" sibTransId="${sibTransIds[i]}"/>`)
|
|
256
|
+
.join('');
|
|
257
|
+
const presOfCxns = `<dgm:cxn modelId="${newModelId()}" type="presOf" srcId="${docId}" destId="${pRootId}" srcOrd="0" destOrd="0" presId="${layoutUrn}"/>` +
|
|
258
|
+
nodeIds
|
|
259
|
+
.map((id) => `<dgm:cxn modelId="${newModelId()}" type="presOf" srcId="${id}" destId="${pMainIds.get(id)}" srcOrd="0" destOrd="0" presId="${layoutUrn}"/>`)
|
|
260
|
+
.join('') +
|
|
261
|
+
sibTransIds
|
|
262
|
+
.map((id, i) => `<dgm:cxn modelId="${newModelId()}" type="presOf" srcId="${id}" destId="${pSibTransIds[i]}" srcOrd="0" destOrd="0" presId="${layoutUrn}"/>`)
|
|
263
|
+
.join('');
|
|
264
|
+
// Interleaved Main, transition, Main, transition, … : root's presParOf srcOrd is one sequence.
|
|
265
|
+
const presParOfCxns = nodeIds
|
|
266
|
+
.map((id, i) => `<dgm:cxn modelId="${newModelId()}" type="presParOf" srcId="${pRootId}" destId="${pMainIds.get(id)}" srcOrd="${2 * i}" destOrd="0" presId="${layoutUrn}"/>` +
|
|
267
|
+
`<dgm:cxn modelId="${newModelId()}" type="presParOf" srcId="${pRootId}" destId="${pSibTransIds[i]}" srcOrd="${2 * i + 1}" destOrd="0" presId="${layoutUrn}"/>`)
|
|
268
|
+
.join('');
|
|
269
|
+
const xml = ('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' +
|
|
270
|
+
`<dgm:dataModel xmlns:dgm="${DGM_NS}" xmlns:a="${A_NS}">` +
|
|
271
|
+
`<dgm:ptLst><dgm:pt modelId="${docId}" type="doc"><dgm:prSet ` +
|
|
272
|
+
`loTypeId="${layoutUrn}" loCatId="cycle" ` +
|
|
273
|
+
'qsTypeId="urn:md2nativedocx/smartart-quickstyle/cycle1" qsCatId="simple" ' +
|
|
274
|
+
'csTypeId="urn:md2nativedocx/smartart-colors/cycle1" csCatId="accent1"/></dgm:pt>' +
|
|
275
|
+
contentPts +
|
|
276
|
+
presPts +
|
|
277
|
+
`</dgm:ptLst><dgm:cxnLst>${parOfCxns}${presOfCxns}${presParOfCxns}</dgm:cxnLst>` +
|
|
278
|
+
`<dgm:bg/><dgm:whole/>${withDrawing ? DRAWING_EXT_LST_XML : ''}</dgm:dataModel>`);
|
|
279
|
+
if (!withDrawing)
|
|
280
|
+
return { xml };
|
|
281
|
+
const drawingXml = buildDiagramDrawingXml(cycleShapes(nodes.map((node, i) => {
|
|
282
|
+
const label = incomingLabel.get(node.id);
|
|
283
|
+
const fill = validateHexColor(node.fill, '');
|
|
284
|
+
return {
|
|
285
|
+
id: pMainIds.get(nodeIds[i]),
|
|
286
|
+
text: boxText(node, label),
|
|
287
|
+
...(nodeGeom(node) ? { geom: nodeGeom(node) } : {}),
|
|
288
|
+
...(fill ? { fill } : {}),
|
|
289
|
+
};
|
|
290
|
+
}), pSibTransIds, style), style);
|
|
291
|
+
return { xml, drawingXml };
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Generate a `cycle` SmartArt's four diagram parts for `flowchart`.
|
|
295
|
+
*
|
|
296
|
+
* `flowchart` must already have been classified `cycle` by
|
|
297
|
+
* {@link classifyTopology} (`./classify.ts`) — this function does not
|
|
298
|
+
* re-run that check, and produces undefined results (or throws, via
|
|
299
|
+
* {@link orderedCycleNodes}) on a flowchart that isn't actually a closed
|
|
300
|
+
* loop.
|
|
301
|
+
*
|
|
302
|
+
* Unlike `chain`/`tree`, there is no direction-dependent layout variant: a
|
|
303
|
+
* circle has no "top-to-bottom" or "left-to-right" orientation to mirror
|
|
304
|
+
* Mermaid's `TD`/`LR`, so a single fixed layout covers both.
|
|
305
|
+
*/
|
|
306
|
+
export function generateCycle(flowchart, options = {}) {
|
|
307
|
+
const style = options.style ?? 'simple';
|
|
308
|
+
const nodes = orderedCycleNodes(flowchart);
|
|
309
|
+
const data = buildCycleDataXml(flowchart, nodes, options.drawing === true, style);
|
|
310
|
+
return {
|
|
311
|
+
dataXml: data.xml,
|
|
312
|
+
layoutXml: cycleLayoutXml(nodes.length),
|
|
313
|
+
frame: CYCLE_FRAME,
|
|
314
|
+
colorsXml: style === 'simple'
|
|
315
|
+
? CYCLE_COLORS_XML
|
|
316
|
+
: buildColorsXml(style, 'urn:md2nativedocx/smartart-colors/cycle1', ['node1', 'sibTrans']),
|
|
317
|
+
styleXml: style === 'simple'
|
|
318
|
+
? CYCLE_STYLE_XML
|
|
319
|
+
: buildStyleXml(style, 'urn:md2nativedocx/smartart-quickstyle/cycle1', ['node1', 'sibTrans']),
|
|
320
|
+
...(data.drawingXml !== undefined ? { drawingXml: data.drawingXml } : {}),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
//# sourceMappingURL=cycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cycle.js","sourceRoot":"","sources":["../../src/smartart/cycle.ts"],"names":[],"mappings":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ED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,aAAa,CAAC,SAAoB,EAAE,UAAmC,EAAE;IACvF,MAAM,KAAK,GAAkB,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC;IACvD,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,iBAAiB,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,CAAC;IAClF,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,GAAG;QACjB,SAAS,EAAE,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC;QACvC,KAAK,EAAE,WAAW;QAClB,SAAS,EACP,KAAK,KAAK,QAAQ;YAChB,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,0CAA0C,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAC9F,QAAQ,EACN,KAAK,KAAK,QAAQ;YAChB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,8CAA8C,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACjG,GAAG,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartArt dispatch: classify a flowchart and, if eligible, run the matching
|
|
3
|
+
* generator (`docs/specs/FUTURE_mmd2smartart_SPEC.md` §7 step 5). Centralizes the
|
|
4
|
+
* classification-result -> generator mapping so callers (the pandoc-filter
|
|
5
|
+
* core bridge) don't each need to know which of `chain.ts`/`tree.ts`/
|
|
6
|
+
* `cycle.ts` handles which {@link SmartArtLayout}.
|
|
7
|
+
*
|
|
8
|
+
* Still a pure function: no filesystem, no ZIP, no knowledge of Pandoc or
|
|
9
|
+
* the eventual `.docx` package structure. Turning the four XML strings this
|
|
10
|
+
* returns into new `word/diagrams/*.xml` parts + relationships + a
|
|
11
|
+
* placeholder-bearing `<w:drawing>` fragment is the pandoc-filter/cli
|
|
12
|
+
* layer's job (`packages/pandoc-filter/bin/md2nativedocx-core.mjs`,
|
|
13
|
+
* `packages/cli/src/postprocess.mjs`) — this module knows nothing about
|
|
14
|
+
* that, deliberately, matching `types.ts`'s "no knowledge of Pandoc, VS
|
|
15
|
+
* Code, or Office.js" boundary for `packages/core`.
|
|
16
|
+
*/
|
|
17
|
+
import type { Flowchart } from '../types.js';
|
|
18
|
+
import { type SmartArtLayout } from './classify.js';
|
|
19
|
+
import type { SmartArtGenerateOptions } from './generate-options.js';
|
|
20
|
+
/** Which SmartArt generator produced a diagram: a flowchart topology, the time line, or the grouped list (kanban). */
|
|
21
|
+
export type SmartArtGeneratedLayout = SmartArtLayout | 'timeline' | 'list';
|
|
22
|
+
/** The four OOXML diagram parts for whichever topology `flowchart` matched. */
|
|
23
|
+
export interface SmartArtGenerated {
|
|
24
|
+
/** Which generator produced this — lets a caller log/report the choice. */
|
|
25
|
+
layout: SmartArtGeneratedLayout;
|
|
26
|
+
dataXml: string;
|
|
27
|
+
layoutXml: string;
|
|
28
|
+
colorsXml: string;
|
|
29
|
+
styleXml: string;
|
|
30
|
+
/** Pre-rendered `dsp:drawing` part; present only when `options.drawing` was set. */
|
|
31
|
+
drawingXml?: string;
|
|
32
|
+
/** Frame size (EMU) to embed the diagram in; absent = the default frame. */
|
|
33
|
+
frame?: {
|
|
34
|
+
cx: number;
|
|
35
|
+
cy: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Classify `flowchart` and run its matching generator.
|
|
40
|
+
*
|
|
41
|
+
* Returns `null` for anything {@link classifyTopology} doesn't accept —
|
|
42
|
+
* subgraphs, merge-after-branch, disconnected graphs, a tree larger than
|
|
43
|
+
* the tree generators support, etc. A `null` result is the expected, common case for
|
|
44
|
+
* a real-world flowchart (spec §6: merge-after-branch is probably the most
|
|
45
|
+
* frequent shape) and callers should silently fall back to the existing
|
|
46
|
+
* `wpg:wgp` translator, not treat it as an error.
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateSmartArt(flowchart: Flowchart, options?: SmartArtGenerateOptions): SmartArtGenerated | null;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmartArt dispatch: classify a flowchart and, if eligible, run the matching
|
|
3
|
+
* generator (`docs/specs/FUTURE_mmd2smartart_SPEC.md` §7 step 5). Centralizes the
|
|
4
|
+
* classification-result -> generator mapping so callers (the pandoc-filter
|
|
5
|
+
* core bridge) don't each need to know which of `chain.ts`/`tree.ts`/
|
|
6
|
+
* `cycle.ts` handles which {@link SmartArtLayout}.
|
|
7
|
+
*
|
|
8
|
+
* Still a pure function: no filesystem, no ZIP, no knowledge of Pandoc or
|
|
9
|
+
* the eventual `.docx` package structure. Turning the four XML strings this
|
|
10
|
+
* returns into new `word/diagrams/*.xml` parts + relationships + a
|
|
11
|
+
* placeholder-bearing `<w:drawing>` fragment is the pandoc-filter/cli
|
|
12
|
+
* layer's job (`packages/pandoc-filter/bin/md2nativedocx-core.mjs`,
|
|
13
|
+
* `packages/cli/src/postprocess.mjs`) — this module knows nothing about
|
|
14
|
+
* that, deliberately, matching `types.ts`'s "no knowledge of Pandoc, VS
|
|
15
|
+
* Code, or Office.js" boundary for `packages/core`.
|
|
16
|
+
*/
|
|
17
|
+
import { classifyTopology, flowchartTreeDepth } from './classify.js';
|
|
18
|
+
import { generateChain } from './chain.js';
|
|
19
|
+
import { generateTree } from './tree.js';
|
|
20
|
+
import { generateDeepTree } from './tree-deep.js';
|
|
21
|
+
import { generateCycle } from './cycle.js';
|
|
22
|
+
/**
|
|
23
|
+
* Classify `flowchart` and run its matching generator.
|
|
24
|
+
*
|
|
25
|
+
* Returns `null` for anything {@link classifyTopology} doesn't accept —
|
|
26
|
+
* subgraphs, merge-after-branch, disconnected graphs, a tree larger than
|
|
27
|
+
* the tree generators support, etc. A `null` result is the expected, common case for
|
|
28
|
+
* a real-world flowchart (spec §6: merge-after-branch is probably the most
|
|
29
|
+
* frequent shape) and callers should silently fall back to the existing
|
|
30
|
+
* `wpg:wgp` translator, not treat it as an error.
|
|
31
|
+
*/
|
|
32
|
+
export function generateSmartArt(flowchart, options = {}) {
|
|
33
|
+
const classification = classifyTopology(flowchart);
|
|
34
|
+
if (!classification.eligible)
|
|
35
|
+
return null;
|
|
36
|
+
switch (classification.layout) {
|
|
37
|
+
case 'chain':
|
|
38
|
+
return { layout: 'chain', ...generateChain(flowchart, options) };
|
|
39
|
+
case 'tree':
|
|
40
|
+
// Two levels keep the original generator; deeper trees need the size-aware multi-level one.
|
|
41
|
+
return {
|
|
42
|
+
layout: 'tree',
|
|
43
|
+
...(flowchartTreeDepth(flowchart) > 2 ? generateDeepTree(flowchart, options) : generateTree(flowchart, options)),
|
|
44
|
+
};
|
|
45
|
+
case 'cycle':
|
|
46
|
+
return { layout: 'cycle', ...generateCycle(flowchart, options) };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/smartart/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAuB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAoB3C;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAoB,EAAE,UAAmC,EAAE;IAC1F,MAAM,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACnD,IAAI,CAAC,cAAc,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAE1C,QAAQ,cAAc,CAAC,MAAM,EAAE,CAAC;QAC9B,KAAK,OAAO;YACV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;QACnE,KAAK,MAAM;YACT,4FAA4F;YAC5F,OAAO;gBACL,MAAM,EAAE,MAAM;gBACd,GAAG,CAAC,kBAAkB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;aACjH,CAAC;QACJ,KAAK,OAAO;YACV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-rendered SmartArt drawing (`dsp:drawing`, the fifth diagram part a real Word always writes).
|
|
3
|
+
*
|
|
4
|
+
* Word and LibreOffice both show this part as the diagram's **cached rendering** and only re-run the layout
|
|
5
|
+
* algorithm when the diagram is edited, so emitting it makes the two applications display exactly the same
|
|
6
|
+
* shapes — the "pixel perfect" lever (ADR 0006: LibreOffice displays a present `dsp:drawing` as an
|
|
7
|
+
* authoritative cache instead of running its own layout, which for `chain` stretched the boxes tall).
|
|
8
|
+
*
|
|
9
|
+
* Each `dsp:sp/@modelId` references the diagram's **presentation** point for that shape (never a content
|
|
10
|
+
* point) — rule confirmed on a real Word-authored sample, see ADR 0006 "Résultat 1".
|
|
11
|
+
*
|
|
12
|
+
* Geometry here approximates what the self-authored `layoutDef`s ask Word to compute (same constraints:
|
|
13
|
+
* `chain.ts`, `tree.ts`, `cycle.ts`); after an edit Word recomputes and may differ slightly. All text is
|
|
14
|
+
* XML-escaped (AGENTS.md rule #2).
|
|
15
|
+
*/
|
|
16
|
+
import type { Flowchart, LabelToken } from '../types.js';
|
|
17
|
+
import { type SmartArtStyle } from './styles.js';
|
|
18
|
+
/** Frame size (EMU) the diagram is embedded in — keep in sync with `embed.ts`'s defaults. */
|
|
19
|
+
export declare const DRAWING_FRAME: {
|
|
20
|
+
cx: number;
|
|
21
|
+
cy: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Taller frame for a cycle (6 in x 4.6 in): the ring needs vertical room for its boxes **and** the arrows
|
|
25
|
+
* between them. Word recomputes a cycle's layout from the `layoutDef` rather than showing this file's cached
|
|
26
|
+
* shapes, so the sizes below are also written into the `layoutDef` (`cycle.ts`) — one source of truth.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CYCLE_FRAME: {
|
|
29
|
+
cx: number;
|
|
30
|
+
cy: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Box width (EMU) for a cycle of `n` nodes: up to 30% of the frame, shrunk until neighbouring boxes leave a gap
|
|
34
|
+
* of at least 0.7 box widths for the arrow between them. The ring radius is taken conservatively from the box
|
|
35
|
+
* *width* on both axes, so the guarantee holds whichever dimension Word's cycle algorithm uses.
|
|
36
|
+
*/
|
|
37
|
+
export declare function cycleBoxWidth(n: number, frame?: {
|
|
38
|
+
cx: number;
|
|
39
|
+
cy: number;
|
|
40
|
+
}): number;
|
|
41
|
+
/** Placeholder written into `dgm:dataModelExt/@relId`; the bridge swaps it for `SMARTART_PLACEHOLDER:<id>:dr`. */
|
|
42
|
+
export declare const DRAWING_REL_TOKEN = "SMARTART_DRAWING_REL";
|
|
43
|
+
/** `dgm:extLst` that points the data model at its drawing part (appended after `dgm:whole`). */
|
|
44
|
+
export declare const DRAWING_EXT_LST_XML: string;
|
|
45
|
+
/** One shape of the cached drawing. Coordinates are EMU inside the frame. */
|
|
46
|
+
export interface DrawingShape {
|
|
47
|
+
/** Presentation point id this shape renders (`dsp:sp/@modelId`). */
|
|
48
|
+
modelId: string;
|
|
49
|
+
x: number;
|
|
50
|
+
y: number;
|
|
51
|
+
cx: number;
|
|
52
|
+
cy: number;
|
|
53
|
+
/** Preset geometry: `roundRect` for nodes (`ellipse` for timeline dots), an arrow for chain transitions. */
|
|
54
|
+
prst: 'roundRect' | 'ellipse' | 'homePlate' | 'rightArrow' | 'leftArrow' | 'downArrow' | 'upArrow' | 'connector';
|
|
55
|
+
/** `connector` only: the elbow line's corner points, in EMU relative to the shape's own top-left. */
|
|
56
|
+
path?: Array<[number, number]>;
|
|
57
|
+
/** Node text (absent for arrows). */
|
|
58
|
+
text?: LabelToken[];
|
|
59
|
+
/** Font size in hundredths of a point. */
|
|
60
|
+
fontSize?: number;
|
|
61
|
+
/** `RRGGBB` override from `classDef`/`style`; otherwise the theme's accent colour. */
|
|
62
|
+
fill?: string;
|
|
63
|
+
/** Clockwise rotation in degrees (cycle arrows follow the circle). */
|
|
64
|
+
rotation?: number;
|
|
65
|
+
/** Theme accent (`accent1`…`accent6`) the shape is painted with; default `accent1`. */
|
|
66
|
+
accent?: string;
|
|
67
|
+
/** Tint of that accent for transitions (60 = lighter), in percent. */
|
|
68
|
+
tintPercent?: number;
|
|
69
|
+
/** `RRGGBB` outline (a neutral card); otherwise the profile's white outline. */
|
|
70
|
+
line?: string;
|
|
71
|
+
/** A node box drawn with another preset (`diamond`…, the Mermaid node's shape) — styled as a node all the same. */
|
|
72
|
+
geom?: string;
|
|
73
|
+
}
|
|
74
|
+
/** The complete `word/diagrams/drawingN.xml` part for `shapes`. */
|
|
75
|
+
export declare function buildDiagramDrawingXml(shapes: DrawingShape[], style?: SmartArtStyle): string;
|
|
76
|
+
/**
|
|
77
|
+
* Whether `labels` fit a `cx` x `cy` box at `size` pt without breaking a word: at most three wrapped lines, or one
|
|
78
|
+
* per explicit line break when a label has more.
|
|
79
|
+
*/
|
|
80
|
+
export declare function textFits(labels: LabelToken[][], cx: number, cy: number, size: number): boolean;
|
|
81
|
+
/** Largest font (1/100 pt, `minPt`-24 pt, default floor 10 pt) at which `labels` fit a `cx` x `cy` box ({@link textFits}). */
|
|
82
|
+
export declare function fitFontSize(labels: LabelToken[][], cx: number, cy: number, minPt?: number): number;
|
|
83
|
+
interface Labelled {
|
|
84
|
+
/** Presentation point id of the node's shape. */
|
|
85
|
+
id: string;
|
|
86
|
+
text: LabelToken[];
|
|
87
|
+
fill?: string;
|
|
88
|
+
/** Preset of the Mermaid node's shape, when it is not a plain box (see `node-shape.ts`). */
|
|
89
|
+
geom?: string;
|
|
90
|
+
/** Presentation point id of the connector line leading into this node (tree children only). */
|
|
91
|
+
connId?: string;
|
|
92
|
+
}
|
|
93
|
+
/** Box width/height and gap (EMU) of an `n`-box chain in the default frame, box height `aspect` of its width. */
|
|
94
|
+
export declare function chainBoxSize(direction: Flowchart['direction'], n: number, aspect?: number): {
|
|
95
|
+
bw: number;
|
|
96
|
+
bh: number;
|
|
97
|
+
gap: number;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Chain geometry: `n` boxes in a row (or column) with a transition arrow between consecutive ones,
|
|
101
|
+
* using the `layoutDef`'s ratios — box height `aspect` (default 0.6) of its width, transition 0.4 of a box wide.
|
|
102
|
+
*/
|
|
103
|
+
export declare function chainShapes(direction: Flowchart['direction'], nodes: Labelled[], transIds: string[], style?: SmartArtStyle, aspect?: number): DrawingShape[];
|
|
104
|
+
/**
|
|
105
|
+
* Tree geometry (root + one row/column of children): the `layoutDef` gives the root a 35% strip across the
|
|
106
|
+
* whole frame and the children the remaining 55% area, each child `1 / (n + 0.1 (n - 1))` of it with a 10% gap.
|
|
107
|
+
* `TD`: root on top; `BT`: root at the bottom; `LR`: root on the left; `RL`: root on the right.
|
|
108
|
+
*/
|
|
109
|
+
export declare function treeShapes(direction: Flowchart['direction'], root: Labelled, children: Labelled[], style?: SmartArtStyle): DrawingShape[];
|
|
110
|
+
/** A node of a multi-level tree, as {@link deepTreeShapes} lays it out. */
|
|
111
|
+
export interface DeepTreeNode extends Labelled {
|
|
112
|
+
children: DeepTreeNode[];
|
|
113
|
+
}
|
|
114
|
+
/** Compact (org-chart) layout: how far right of its parent's left edge a column of leaves starts, in box widths. */
|
|
115
|
+
export declare const DEEP_COLUMN_INDENT = 0.6;
|
|
116
|
+
/** Number of levels (the root counts as 1) and of leaves of a tree. */
|
|
117
|
+
export declare function deepTreeSize(root: {
|
|
118
|
+
children: unknown[];
|
|
119
|
+
}): {
|
|
120
|
+
depth: number;
|
|
121
|
+
leaves: number;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Whether a multi-level tree should use the compact (org-chart) layout: only top-down, only when the ordinary
|
|
125
|
+
* layout would make boxes narrower than 0.9 in, and only if stacking leaf families actually narrows the tree.
|
|
126
|
+
* This is how Word's own organisation chart keeps wide trees readable (leaves in a column under their parent).
|
|
127
|
+
*/
|
|
128
|
+
export declare function deepTreeIsCompact(root: DeepTreeNode, direction: Flowchart['direction']): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Multi-level tree geometry, in the four Mermaid directions. Space is shared by the **real shape of each
|
|
131
|
+
* subtree**: a leaf takes one box along the sibling axis, a parent's subtree the sum of its children's (plus
|
|
132
|
+
* a gap between siblings), and the parent is centred on its first and last child — so a branch with
|
|
133
|
+
* grandchildren is wide and a lone leaf next to it stays narrow. Each parent→child link is an elbow bending
|
|
134
|
+
* halfway across the gap between the two levels. The frame is sized to the result.
|
|
135
|
+
*
|
|
136
|
+
* Computed on two abstract axes — *cross* (siblings) and *flow* (levels, root first) — then mapped to x/y:
|
|
137
|
+
* `TD` flow = down, `BT` flow = up, `LR` flow = right, `RL` flow = left.
|
|
138
|
+
*
|
|
139
|
+
* `compact` (top-down only, see {@link deepTreeIsCompact}): a node whose children are all leaves keeps its
|
|
140
|
+
* box at the left of its slot and stacks the leaves in a column below it, indented by
|
|
141
|
+
* {@link DEEP_COLUMN_INDENT}; each leaf's line runs down from the parent and enters the leaf's left side.
|
|
142
|
+
*/
|
|
143
|
+
export declare function deepTreeShapes(root: DeepTreeNode, style?: SmartArtStyle, direction?: Flowchart['direction'], compact?: boolean): {
|
|
144
|
+
shapes: DrawingShape[];
|
|
145
|
+
frame: {
|
|
146
|
+
cx: number;
|
|
147
|
+
cy: number;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Cycle geometry: boxes evenly spaced clockwise from the top, a transition arrow between each pair (the last
|
|
152
|
+
* one closing the loop). Sizes come from {@link cycleBoxWidth}, the same rule the `layoutDef` states.
|
|
153
|
+
*/
|
|
154
|
+
export declare function cycleShapes(nodes: Labelled[], transIds: string[], style?: SmartArtStyle): DrawingShape[];
|
|
155
|
+
export {};
|