@hirokisakabe/pom 3.0.0 → 4.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 +36 -24
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +29 -4
- package/dist/calcYogaLayout/fontLoader.d.ts +16 -0
- package/dist/calcYogaLayout/fontLoader.d.ts.map +1 -1
- package/dist/calcYogaLayout/fontLoader.js +28 -0
- package/dist/calcYogaLayout/measureCompositeNodes.d.ts +13 -1
- package/dist/calcYogaLayout/measureCompositeNodes.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureCompositeNodes.js +26 -3
- package/dist/parseXml/inputSchema.d.ts +52 -0
- package/dist/parseXml/inputSchema.d.ts.map +1 -1
- package/dist/parseXml/inputSchema.js +9 -1
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +48 -30
- package/dist/renderPptx/nodes/index.d.ts +1 -0
- package/dist/renderPptx/nodes/index.d.ts.map +1 -1
- package/dist/renderPptx/nodes/index.js +1 -0
- package/dist/renderPptx/nodes/processArrow.d.ts.map +1 -1
- package/dist/renderPptx/nodes/processArrow.js +75 -15
- package/dist/renderPptx/nodes/pyramid.d.ts +8 -0
- package/dist/renderPptx/nodes/pyramid.d.ts.map +1 -0
- package/dist/renderPptx/nodes/pyramid.js +81 -0
- package/dist/renderPptx/nodes/table.d.ts.map +1 -1
- package/dist/renderPptx/nodes/table.js +2 -0
- package/dist/renderPptx/renderPptx.d.ts.map +1 -1
- package/dist/renderPptx/renderPptx.js +4 -1
- package/dist/shared/processArrowConstants.d.ts +7 -0
- package/dist/shared/processArrowConstants.d.ts.map +1 -0
- package/dist/shared/processArrowConstants.js +6 -0
- package/dist/toPositioned/toPositioned.d.ts.map +1 -1
- package/dist/toPositioned/toPositioned.js +9 -0
- package/dist/types.d.ts +69 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +18 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<h1 align="center">pom</h1>
|
|
2
2
|
<p align="center">
|
|
3
|
-
|
|
3
|
+
AI-friendly PowerPoint generation with a Flexbox layout engine.
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
6
|
<p align="center">
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
|
-
<b>pom (PowerPoint Object Model)</b> is a TypeScript library that converts XML into PowerPoint files (.pptx)
|
|
14
|
-
Flexbox-style layout powered by <a href="https://www.yogalayout.dev/">yoga-layout</a>, rendered with <a href="https://github.com/nicktomlin/pptxgenjs">pptxgenjs</a>.
|
|
13
|
+
<b>pom (PowerPoint Object Model)</b> is a TypeScript library that converts XML into editable PowerPoint files (.pptx).
|
|
15
14
|
</p>
|
|
16
15
|
|
|
17
16
|
<p align="center">
|
|
@@ -85,6 +84,7 @@ await pptx.writeFile({ fileName: "presentation.pptx" });
|
|
|
85
84
|
| Tree | Organization charts and decision trees |
|
|
86
85
|
| Flow | Flowcharts with nodes and edges |
|
|
87
86
|
| ProcessArrow | Chevron-style process diagrams |
|
|
87
|
+
| Pyramid | Pyramid diagrams for hierarchies |
|
|
88
88
|
| Line | Horizontal / vertical lines |
|
|
89
89
|
| Layer | Absolute-positioned overlay container |
|
|
90
90
|
| Box | Container for single child with padding |
|
|
@@ -99,10 +99,10 @@ For detailed node documentation, see [Nodes Reference](./docs/nodes.md).
|
|
|
99
99
|
|
|
100
100
|
```xml
|
|
101
101
|
<Chart chartType="bar" w="350" h="250" showTitle="true" title="Bar Chart" showLegend="true">
|
|
102
|
-
<
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
</
|
|
102
|
+
<ChartSeries name="Q1">
|
|
103
|
+
<ChartDataPoint label="Jan" value="30" />
|
|
104
|
+
<ChartDataPoint label="Feb" value="45" />
|
|
105
|
+
</ChartSeries>
|
|
106
106
|
</Chart>
|
|
107
107
|
```
|
|
108
108
|
|
|
@@ -115,8 +115,8 @@ For detailed node documentation, see [Nodes Reference](./docs/nodes.md).
|
|
|
115
115
|
<FlowNode id="start" shape="flowChartTerminator" text="Start" color="16A34A" />
|
|
116
116
|
<FlowNode id="process" shape="flowChartProcess" text="Process" color="1D4ED8" />
|
|
117
117
|
<FlowNode id="end" shape="flowChartTerminator" text="End" color="DC2626" />
|
|
118
|
-
<
|
|
119
|
-
<
|
|
118
|
+
<FlowConnection from="start" to="process" />
|
|
119
|
+
<FlowConnection from="process" to="end" />
|
|
120
120
|
</Flow>
|
|
121
121
|
```
|
|
122
122
|
|
|
@@ -143,16 +143,16 @@ For detailed node documentation, see [Nodes Reference](./docs/nodes.md).
|
|
|
143
143
|
|
|
144
144
|
```xml
|
|
145
145
|
<Table defaultRowHeight="36">
|
|
146
|
-
<
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
</
|
|
152
|
-
<
|
|
153
|
-
<
|
|
154
|
-
<
|
|
155
|
-
</
|
|
146
|
+
<TableColumn width="80" />
|
|
147
|
+
<TableColumn width="200" />
|
|
148
|
+
<TableRow>
|
|
149
|
+
<TableCell bold="true" backgroundColor="0F172A" color="FFFFFF">ID</TableCell>
|
|
150
|
+
<TableCell bold="true" backgroundColor="0F172A" color="FFFFFF">Name</TableCell>
|
|
151
|
+
</TableRow>
|
|
152
|
+
<TableRow>
|
|
153
|
+
<TableCell>001</TableCell>
|
|
154
|
+
<TableCell>Project Alpha</TableCell>
|
|
155
|
+
</TableRow>
|
|
156
156
|
</Table>
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -174,16 +174,28 @@ For detailed node documentation, see [Nodes Reference](./docs/nodes.md).
|
|
|
174
174
|
|
|
175
175
|
```xml
|
|
176
176
|
<ProcessArrow direction="horizontal" w="100%" h="100">
|
|
177
|
-
<
|
|
178
|
-
<
|
|
179
|
-
<
|
|
180
|
-
<
|
|
181
|
-
<
|
|
177
|
+
<ProcessArrowStep label="Planning" color="4472C4" />
|
|
178
|
+
<ProcessArrowStep label="Design" color="5B9BD5" />
|
|
179
|
+
<ProcessArrowStep label="Development" color="70AD47" />
|
|
180
|
+
<ProcessArrowStep label="Testing" color="FFC000" />
|
|
181
|
+
<ProcessArrowStep label="Release" color="ED7D31" />
|
|
182
182
|
</ProcessArrow>
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
<img src="./docs/images/processArrow.png" alt="ProcessArrow example" width="600">
|
|
186
186
|
|
|
187
|
+
### Pyramid
|
|
188
|
+
|
|
189
|
+
```xml
|
|
190
|
+
<Pyramid direction="up" w="600" h="300">
|
|
191
|
+
<PyramidLevel label="Strategy" color="E91E63" />
|
|
192
|
+
<PyramidLevel label="Tactics" color="9C27B0" />
|
|
193
|
+
<PyramidLevel label="Execution" color="673AB7" />
|
|
194
|
+
</Pyramid>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
<img src="./docs/images/pyramid.png" alt="Pyramid example" width="600">
|
|
198
|
+
|
|
187
199
|
## Documentation
|
|
188
200
|
|
|
189
201
|
| Document | Description |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calcYogaLayout.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/calcYogaLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"calcYogaLayout.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/calcYogaLayout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAA0B,MAAM,aAAa,CAAC;AA+BnE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,OAAO,EACb,SAAS,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,iBAiBpC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { loadYoga } from "yoga-layout/load";
|
|
2
2
|
import { measureText } from "./measureText.js";
|
|
3
|
+
import { measureFontLineHeightRatio } from "./fontLoader.js";
|
|
3
4
|
import { measureImage, prefetchImageSize } from "../shared/measureImage.js";
|
|
4
5
|
import { calcTableIntrinsicSize } from "../shared/tableUtils.js";
|
|
5
|
-
import { measureProcessArrow, measureTimeline, measureMatrix, measureTree, measureFlow, } from "./measureCompositeNodes.js";
|
|
6
|
+
import { measureProcessArrow, measureTimeline, measureMatrix, measureTree, measureFlow, measurePyramid, } from "./measureCompositeNodes.js";
|
|
6
7
|
/**
|
|
7
8
|
* コンポジットノードの最小スケール閾値。
|
|
8
9
|
* renderPptx/utils/scaleToFit.ts の MIN_SCALE_THRESHOLD と同じ値を維持すること。
|
|
@@ -124,6 +125,7 @@ async function buildPomWithYogaTree(node, parentYoga, parentNode) {
|
|
|
124
125
|
case "tree":
|
|
125
126
|
case "flow":
|
|
126
127
|
case "processArrow":
|
|
128
|
+
case "pyramid":
|
|
127
129
|
case "line":
|
|
128
130
|
// 子要素なし
|
|
129
131
|
break;
|
|
@@ -249,7 +251,13 @@ async function applyStyleToYogaNode(node, yn) {
|
|
|
249
251
|
const fontSizePx = node.fontPx ?? 24;
|
|
250
252
|
const fontFamily = "Noto Sans JP";
|
|
251
253
|
const fontWeight = node.bold ? "bold" : "normal";
|
|
252
|
-
const
|
|
254
|
+
const lineSpacingMultiple = node.lineSpacingMultiple ?? 1.3;
|
|
255
|
+
// PowerPoint の lineSpacingMultiple はフォントメトリクス(ascent + descent)に
|
|
256
|
+
// 対する倍率。fontSizePx × fontMetricsRatio × lineSpacingMultiple で計算する。
|
|
257
|
+
const fontMetricsRatio = measureFontLineHeightRatio(fontWeight);
|
|
258
|
+
const lineHeight = fontMetricsRatio * lineSpacingMultiple;
|
|
259
|
+
// バレット/番号のインデント幅(pptxgenjs DEF_BULLET_MARGIN = 27pt = 36px @96dpi)
|
|
260
|
+
const bulletIndentPx = 36;
|
|
253
261
|
yn.setMeasureFunc((width, widthMode) => {
|
|
254
262
|
const maxWidthPx = (() => {
|
|
255
263
|
switch (widthMode) {
|
|
@@ -260,14 +268,16 @@ async function applyStyleToYogaNode(node, yn) {
|
|
|
260
268
|
return width;
|
|
261
269
|
}
|
|
262
270
|
})();
|
|
263
|
-
|
|
271
|
+
// バレットインデント分を除いたテキスト利用可能幅で計測
|
|
272
|
+
const textMaxWidthPx = Math.max(0, maxWidthPx - bulletIndentPx);
|
|
273
|
+
const { widthPx, heightPx } = measureText(combinedText, textMaxWidthPx, {
|
|
264
274
|
fontFamily,
|
|
265
275
|
fontSizePx,
|
|
266
276
|
lineHeight,
|
|
267
277
|
fontWeight,
|
|
268
278
|
});
|
|
269
279
|
return {
|
|
270
|
-
width: widthPx,
|
|
280
|
+
width: widthPx + bulletIndentPx,
|
|
271
281
|
height: heightPx,
|
|
272
282
|
};
|
|
273
283
|
});
|
|
@@ -346,6 +356,21 @@ async function applyStyleToYogaNode(node, yn) {
|
|
|
346
356
|
});
|
|
347
357
|
}
|
|
348
358
|
break;
|
|
359
|
+
case "pyramid":
|
|
360
|
+
{
|
|
361
|
+
yn.setMeasureFunc((width, widthMode, height, heightMode) => {
|
|
362
|
+
const intrinsic = measurePyramid(node);
|
|
363
|
+
return {
|
|
364
|
+
width: widthMode !== yoga.MEASURE_MODE_UNDEFINED
|
|
365
|
+
? constrainWithMinScale(intrinsic.width, width)
|
|
366
|
+
: intrinsic.width,
|
|
367
|
+
height: heightMode !== yoga.MEASURE_MODE_UNDEFINED
|
|
368
|
+
? constrainWithMinScale(intrinsic.height, height)
|
|
369
|
+
: intrinsic.height,
|
|
370
|
+
};
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
349
374
|
case "timeline":
|
|
350
375
|
{
|
|
351
376
|
yn.setMeasureFunc((width, widthMode, height, heightMode) => {
|
|
@@ -10,4 +10,20 @@
|
|
|
10
10
|
* @returns テキスト幅(ピクセル)
|
|
11
11
|
*/
|
|
12
12
|
export declare function measureTextWidth(text: string, fontSizePx: number, weight: "normal" | "bold"): number;
|
|
13
|
+
/**
|
|
14
|
+
* フォントの自然な行高さ比率を取得する
|
|
15
|
+
*
|
|
16
|
+
* PowerPoint の lineSpacingMultiple はフォントサイズではなく、
|
|
17
|
+
* フォントメトリクス(ascent + descent)に対する倍率として適用される。
|
|
18
|
+
* この関数は fontSizePx に対する自然な行高さの比率を返す。
|
|
19
|
+
*
|
|
20
|
+
* - USE_TYPO_METRICS (fsSelection bit 7) が設定されている場合:
|
|
21
|
+
* sTypoAscender, sTypoDescender, sTypoLineGap を使用
|
|
22
|
+
* - 設定されていない場合:
|
|
23
|
+
* usWinAscent, usWinDescent を使用
|
|
24
|
+
*
|
|
25
|
+
* @param weight フォントウェイト
|
|
26
|
+
* @returns fontSizePx に対する行高さの比率(例: 1.448)
|
|
27
|
+
*/
|
|
28
|
+
export declare function measureFontLineHeightRatio(weight: "normal" | "bold"): number;
|
|
13
29
|
//# sourceMappingURL=fontLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fontLoader.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/fontLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2DH;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,GAAG,MAAM,GACxB,MAAM,CAGR"}
|
|
1
|
+
{"version":3,"file":"fontLoader.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/fontLoader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2DH;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,QAAQ,GAAG,MAAM,GACxB,MAAM,CAGR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,MAAM,CAgB5E"}
|
|
@@ -57,3 +57,31 @@ export function measureTextWidth(text, fontSizePx, weight) {
|
|
|
57
57
|
const font = getFont(weight);
|
|
58
58
|
return font.getAdvanceWidth(text, fontSizePx, { kerning: true });
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* フォントの自然な行高さ比率を取得する
|
|
62
|
+
*
|
|
63
|
+
* PowerPoint の lineSpacingMultiple はフォントサイズではなく、
|
|
64
|
+
* フォントメトリクス(ascent + descent)に対する倍率として適用される。
|
|
65
|
+
* この関数は fontSizePx に対する自然な行高さの比率を返す。
|
|
66
|
+
*
|
|
67
|
+
* - USE_TYPO_METRICS (fsSelection bit 7) が設定されている場合:
|
|
68
|
+
* sTypoAscender, sTypoDescender, sTypoLineGap を使用
|
|
69
|
+
* - 設定されていない場合:
|
|
70
|
+
* usWinAscent, usWinDescent を使用
|
|
71
|
+
*
|
|
72
|
+
* @param weight フォントウェイト
|
|
73
|
+
* @returns fontSizePx に対する行高さの比率(例: 1.448)
|
|
74
|
+
*/
|
|
75
|
+
export function measureFontLineHeightRatio(weight) {
|
|
76
|
+
const font = getFont(weight);
|
|
77
|
+
const upm = font.unitsPerEm;
|
|
78
|
+
const os2 = font.tables?.os2;
|
|
79
|
+
if (!os2) {
|
|
80
|
+
return 1.0;
|
|
81
|
+
}
|
|
82
|
+
const useTypoMetrics = Boolean(os2.fsSelection & (1 << 7));
|
|
83
|
+
if (useTypoMetrics) {
|
|
84
|
+
return (os2.sTypoAscender - os2.sTypoDescender + os2.sTypoLineGap) / upm;
|
|
85
|
+
}
|
|
86
|
+
return (os2.usWinAscent + os2.usWinDescent) / upm;
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProcessArrowNode, TimelineNode, MatrixNode, TreeNode, FlowNode } from "../types.ts";
|
|
1
|
+
import type { ProcessArrowNode, TimelineNode, MatrixNode, TreeNode, FlowNode, PyramidNode } from "../types.ts";
|
|
2
2
|
/**
|
|
3
3
|
* ProcessArrow ノードの intrinsic size を計算する
|
|
4
4
|
*/
|
|
@@ -46,4 +46,16 @@ export declare function measureFlow(node: FlowNode): {
|
|
|
46
46
|
width: number;
|
|
47
47
|
height: number;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Pyramid ノードの intrinsic size を計算する
|
|
51
|
+
*
|
|
52
|
+
* ピラミッドの描画には以下のデフォルト値が使用される:
|
|
53
|
+
* - baseWidth: 400px (最も広い層の幅)
|
|
54
|
+
* - layerHeight: 50px (各層の高さ)
|
|
55
|
+
* - gap: 2px (層間の隙間)
|
|
56
|
+
*/
|
|
57
|
+
export declare function measurePyramid(node: PyramidNode): {
|
|
58
|
+
width: number;
|
|
59
|
+
height: number;
|
|
60
|
+
};
|
|
49
61
|
//# sourceMappingURL=measureCompositeNodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measureCompositeNodes.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/measureCompositeNodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,
|
|
1
|
+
{"version":3,"file":"measureCompositeNodes.d.ts","sourceRoot":"","sources":["../../src/calcYogaLayout/measureCompositeNodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,WAAW,EAEZ,MAAM,aAAa,CAAC;AAOrB;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAuBA;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAoCA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,GAAG;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAQA;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAuCA;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,GAAG;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAcA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ARROW_DEPTH_RATIO, DEFAULT_PROCESS_ARROW_ITEM_WIDTH, DEFAULT_PROCESS_ARROW_ITEM_HEIGHT, } from "../shared/processArrowConstants.js";
|
|
1
2
|
/**
|
|
2
3
|
* ProcessArrow ノードの intrinsic size を計算する
|
|
3
4
|
*/
|
|
@@ -6,9 +7,10 @@ export function measureProcessArrow(node) {
|
|
|
6
7
|
if (stepCount === 0) {
|
|
7
8
|
return { width: 0, height: 0 };
|
|
8
9
|
}
|
|
9
|
-
const itemWidth = node.itemWidth ??
|
|
10
|
-
const itemHeight = node.itemHeight ??
|
|
11
|
-
const
|
|
10
|
+
const itemWidth = node.itemWidth ?? DEFAULT_PROCESS_ARROW_ITEM_WIDTH;
|
|
11
|
+
const itemHeight = node.itemHeight ?? DEFAULT_PROCESS_ARROW_ITEM_HEIGHT;
|
|
12
|
+
const arrowDepth = itemHeight * ARROW_DEPTH_RATIO;
|
|
13
|
+
const gap = node.gap ?? -arrowDepth;
|
|
12
14
|
const direction = node.direction ?? "horizontal";
|
|
13
15
|
if (direction === "horizontal") {
|
|
14
16
|
return {
|
|
@@ -141,3 +143,24 @@ export function measureFlow(node) {
|
|
|
141
143
|
};
|
|
142
144
|
}
|
|
143
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Pyramid ノードの intrinsic size を計算する
|
|
148
|
+
*
|
|
149
|
+
* ピラミッドの描画には以下のデフォルト値が使用される:
|
|
150
|
+
* - baseWidth: 400px (最も広い層の幅)
|
|
151
|
+
* - layerHeight: 50px (各層の高さ)
|
|
152
|
+
* - gap: 2px (層間の隙間)
|
|
153
|
+
*/
|
|
154
|
+
export function measurePyramid(node) {
|
|
155
|
+
const levelCount = node.levels.length;
|
|
156
|
+
if (levelCount === 0) {
|
|
157
|
+
return { width: 0, height: 0 };
|
|
158
|
+
}
|
|
159
|
+
const baseWidth = 400;
|
|
160
|
+
const layerHeight = 50;
|
|
161
|
+
const gap = 2;
|
|
162
|
+
return {
|
|
163
|
+
width: baseWidth,
|
|
164
|
+
height: levelCount * layerHeight + (levelCount - 1) * gap,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -508,6 +508,8 @@ export declare const inputTableNodeSchema: z.ZodObject<{
|
|
|
508
508
|
center: "center";
|
|
509
509
|
}>>;
|
|
510
510
|
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
511
|
+
colspan: z.ZodOptional<z.ZodNumber>;
|
|
512
|
+
rowspan: z.ZodOptional<z.ZodNumber>;
|
|
511
513
|
}, z.core.$strip>>;
|
|
512
514
|
height: z.ZodOptional<z.ZodNumber>;
|
|
513
515
|
}, z.core.$strip>>;
|
|
@@ -1179,6 +1181,56 @@ export declare const inputProcessArrowNodeSchema: z.ZodObject<{
|
|
|
1179
1181
|
strike: z.ZodOptional<z.ZodBoolean>;
|
|
1180
1182
|
highlight: z.ZodOptional<z.ZodString>;
|
|
1181
1183
|
}, z.core.$strip>;
|
|
1184
|
+
export declare const inputPyramidNodeSchema: z.ZodObject<{
|
|
1185
|
+
w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
|
|
1186
|
+
h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
|
|
1187
|
+
minW: z.ZodOptional<z.ZodNumber>;
|
|
1188
|
+
maxW: z.ZodOptional<z.ZodNumber>;
|
|
1189
|
+
minH: z.ZodOptional<z.ZodNumber>;
|
|
1190
|
+
maxH: z.ZodOptional<z.ZodNumber>;
|
|
1191
|
+
padding: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodObject<{
|
|
1192
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
1193
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
1194
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
1195
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
1196
|
+
}, z.core.$strip>]>>;
|
|
1197
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
1198
|
+
backgroundImage: z.ZodOptional<z.ZodObject<{
|
|
1199
|
+
src: z.ZodString;
|
|
1200
|
+
sizing: z.ZodOptional<z.ZodEnum<{
|
|
1201
|
+
cover: "cover";
|
|
1202
|
+
contain: "contain";
|
|
1203
|
+
}>>;
|
|
1204
|
+
}, z.core.$strip>>;
|
|
1205
|
+
border: z.ZodOptional<z.ZodObject<{
|
|
1206
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1207
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
1208
|
+
dashType: z.ZodOptional<z.ZodEnum<{
|
|
1209
|
+
solid: "solid";
|
|
1210
|
+
dash: "dash";
|
|
1211
|
+
dashDot: "dashDot";
|
|
1212
|
+
lgDash: "lgDash";
|
|
1213
|
+
lgDashDot: "lgDashDot";
|
|
1214
|
+
lgDashDotDot: "lgDashDotDot";
|
|
1215
|
+
sysDash: "sysDash";
|
|
1216
|
+
sysDot: "sysDot";
|
|
1217
|
+
}>>;
|
|
1218
|
+
}, z.core.$strip>>;
|
|
1219
|
+
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
1220
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
1221
|
+
type: z.ZodLiteral<"pyramid">;
|
|
1222
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
1223
|
+
up: "up";
|
|
1224
|
+
down: "down";
|
|
1225
|
+
}>>;
|
|
1226
|
+
levels: z.ZodArray<z.ZodObject<{
|
|
1227
|
+
label: z.ZodString;
|
|
1228
|
+
color: z.ZodOptional<z.ZodString>;
|
|
1229
|
+
textColor: z.ZodOptional<z.ZodString>;
|
|
1230
|
+
}, z.core.$strip>>;
|
|
1231
|
+
fontPx: z.ZodOptional<z.ZodNumber>;
|
|
1232
|
+
bold: z.ZodOptional<z.ZodBoolean>;
|
|
1233
|
+
}, z.core.$strip>;
|
|
1182
1234
|
export declare const inputLineNodeSchema: z.ZodObject<{
|
|
1183
1235
|
w: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
|
|
1184
1236
|
h: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<"max">, z.ZodString]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../../src/parseXml/inputSchema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../../src/parseXml/inputSchema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAsCL,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa9B,CAAC;AAKH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAe,CAAC;AAE9C,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAa5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAe5B,CAAC;AAUH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiB/B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU/B,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIlC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKhC,CAAC;AAUH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAS9B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAatC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMjC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW9B,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Used by `parseXml` to validate parsed XML input.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from "zod";
|
|
8
|
-
import { lengthSchema, paddingSchema, borderStyleSchema, borderDashSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, chartTypeSchema, chartDataSchema, liNodeSchema, radarStyleSchema, bulletNumberTypeSchema, timelineDirectionSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, treeLayoutSchema, treeNodeShapeSchema, treeConnectorStyleSchema, flowDirectionSchema, flowNodeItemSchema, flowConnectionSchema, flowConnectorStyleSchema, processArrowDirectionSchema, processArrowStepSchema, lineArrowSchema, underlineSchema, backgroundImageSchema, } from "../types.js";
|
|
8
|
+
import { lengthSchema, paddingSchema, borderStyleSchema, borderDashSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, chartTypeSchema, chartDataSchema, liNodeSchema, radarStyleSchema, bulletNumberTypeSchema, timelineDirectionSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, treeLayoutSchema, treeNodeShapeSchema, treeConnectorStyleSchema, flowDirectionSchema, flowNodeItemSchema, flowConnectionSchema, flowConnectorStyleSchema, processArrowDirectionSchema, processArrowStepSchema, pyramidDirectionSchema, pyramidLevelSchema, lineArrowSchema, underlineSchema, backgroundImageSchema, } from "../types.js";
|
|
9
9
|
// ===== Base Node Schema =====
|
|
10
10
|
export const inputBaseNodeSchema = z.object({
|
|
11
11
|
w: lengthSchema.optional(),
|
|
@@ -166,6 +166,13 @@ export const inputProcessArrowNodeSchema = inputBaseNodeSchema.extend({
|
|
|
166
166
|
strike: z.boolean().optional(),
|
|
167
167
|
highlight: z.string().optional(),
|
|
168
168
|
});
|
|
169
|
+
export const inputPyramidNodeSchema = inputBaseNodeSchema.extend({
|
|
170
|
+
type: z.literal("pyramid"),
|
|
171
|
+
direction: pyramidDirectionSchema.optional(),
|
|
172
|
+
levels: z.array(pyramidLevelSchema).min(1),
|
|
173
|
+
fontPx: z.number().optional(),
|
|
174
|
+
bold: z.boolean().optional(),
|
|
175
|
+
});
|
|
169
176
|
export const inputLineNodeSchema = inputBaseNodeSchema.extend({
|
|
170
177
|
type: z.literal("line"),
|
|
171
178
|
x1: z.number(),
|
|
@@ -223,6 +230,7 @@ const inputPomNodeSchema = z.lazy(() => z.discriminatedUnion("type", [
|
|
|
223
230
|
inputTreeNodeSchema,
|
|
224
231
|
inputFlowNodeSchema,
|
|
225
232
|
inputProcessArrowNodeSchema,
|
|
233
|
+
inputPyramidNodeSchema,
|
|
226
234
|
inputLineNodeSchema,
|
|
227
235
|
inputLayerNodeSchemaBase,
|
|
228
236
|
]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseXml.d.ts","sourceRoot":"","sources":["../../src/parseXml/parseXml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"parseXml.d.ts","sourceRoot":"","sources":["../../src/parseXml/parseXml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAqC3C,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAC;gBACrB,MAAM,EAAE,MAAM,EAAE;CAM7B;AA2+BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,CAiCrD"}
|