@hirokisakabe/pom 5.4.0 → 5.5.1
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 +6 -5
- package/dist/autoFit/autoFit.d.ts +2 -1
- package/dist/autoFit/autoFit.d.ts.map +1 -1
- package/dist/autoFit/autoFit.js +33 -17
- package/dist/buildContext.d.ts +2 -0
- package/dist/buildContext.d.ts.map +1 -1
- package/dist/buildContext.js +2 -0
- package/dist/buildPptx.d.ts +7 -1
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +14 -5
- package/dist/calcYogaLayout/calcYogaLayout.d.ts +4 -2
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +76 -16
- package/dist/calcYogaLayout/fontLoader.d.ts +4 -0
- package/dist/calcYogaLayout/fontLoader.d.ts.map +1 -1
- package/dist/calcYogaLayout/fontLoader.js +8 -0
- package/dist/calcYogaLayout/measureText.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureText.js +4 -3
- package/dist/calcYogaLayout/types.d.ts +16 -0
- package/dist/calcYogaLayout/types.d.ts.map +1 -0
- package/dist/calcYogaLayout/types.js +14 -0
- package/dist/diagnostics.d.ts +14 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +17 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/parseXml/parseXml.d.ts +1 -1
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +16 -16
- package/dist/registry/definitions/icon.d.ts.map +1 -1
- package/dist/registry/definitions/icon.js +26 -14
- package/dist/registry/definitions/image.d.ts.map +1 -1
- package/dist/registry/definitions/image.js +2 -3
- package/dist/registry/definitions/layer.d.ts.map +1 -1
- package/dist/registry/definitions/layer.js +9 -6
- package/dist/registry/definitions/line.d.ts.map +1 -1
- package/dist/registry/definitions/line.js +1 -2
- package/dist/registry/definitions/list.d.ts.map +1 -1
- package/dist/registry/definitions/list.js +3 -1
- package/dist/registry/definitions/shape.d.ts.map +1 -1
- package/dist/registry/definitions/shape.js +2 -0
- package/dist/registry/definitions/text.d.ts.map +1 -1
- package/dist/registry/definitions/text.js +3 -1
- package/dist/registry/types.d.ts +2 -1
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/renderPptx/nodes/chart.d.ts.map +1 -1
- package/dist/renderPptx/nodes/chart.js +6 -4
- package/dist/renderPptx/nodes/flow.d.ts.map +1 -1
- package/dist/renderPptx/nodes/flow.js +14 -4
- package/dist/renderPptx/nodes/image.d.ts.map +1 -1
- package/dist/renderPptx/nodes/image.js +9 -7
- package/dist/renderPptx/nodes/list.d.ts.map +1 -1
- package/dist/renderPptx/nodes/list.js +19 -16
- package/dist/renderPptx/nodes/matrix.d.ts.map +1 -1
- package/dist/renderPptx/nodes/matrix.js +11 -9
- package/dist/renderPptx/nodes/processArrow.d.ts.map +1 -1
- package/dist/renderPptx/nodes/processArrow.js +14 -4
- package/dist/renderPptx/nodes/pyramid.d.ts.map +1 -1
- package/dist/renderPptx/nodes/pyramid.js +6 -4
- package/dist/renderPptx/nodes/shape.d.ts.map +1 -1
- package/dist/renderPptx/nodes/shape.js +7 -5
- package/dist/renderPptx/nodes/table.d.ts.map +1 -1
- package/dist/renderPptx/nodes/table.js +7 -5
- package/dist/renderPptx/nodes/timeline.d.ts.map +1 -1
- package/dist/renderPptx/nodes/timeline.js +14 -4
- package/dist/renderPptx/nodes/tree.d.ts.map +1 -1
- package/dist/renderPptx/nodes/tree.js +6 -4
- package/dist/renderPptx/textOptions.d.ts +6 -6
- package/dist/renderPptx/textOptions.d.ts.map +1 -1
- package/dist/renderPptx/textOptions.js +6 -4
- package/dist/renderPptx/utils/backgroundBorder.js +1 -1
- package/dist/renderPptx/utils/contentArea.d.ts +26 -0
- package/dist/renderPptx/utils/contentArea.d.ts.map +1 -0
- package/dist/renderPptx/utils/contentArea.js +26 -0
- package/dist/renderPptx/utils/scaleToFit.d.ts +3 -2
- package/dist/renderPptx/utils/scaleToFit.d.ts.map +1 -1
- package/dist/renderPptx/utils/scaleToFit.js +3 -3
- package/dist/shared/freeYogaTree.d.ts +3 -3
- package/dist/shared/freeYogaTree.d.ts.map +1 -1
- package/dist/shared/freeYogaTree.js +16 -21
- package/dist/shared/measureImage.d.ts +3 -2
- package/dist/shared/measureImage.d.ts.map +1 -1
- package/dist/shared/measureImage.js +5 -5
- package/dist/toPositioned/toPositioned.d.ts +3 -6
- package/dist/toPositioned/toPositioned.d.ts.map +1 -1
- package/dist/toPositioned/toPositioned.js +11 -19
- package/dist/types.d.ts +12 -445
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +43 -50
- package/package.json +6 -3
- package/dist/parseXml/inputSchema.d.ts +0 -1622
- package/dist/parseXml/inputSchema.d.ts.map +0 -1
- package/dist/parseXml/inputSchema.js +0 -257
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { XMLParser } from "fast-xml-parser";
|
|
2
|
-
import {
|
|
2
|
+
import { textNodeSchema, ulNodeSchema, olNodeSchema, imageNodeSchema, tableNodeSchema, shapeNodeSchema, chartNodeSchema, timelineNodeSchema, matrixNodeSchema, treeNodeSchema, flowNodeSchema, processArrowNodeSchema, pyramidNodeSchema, lineNodeSchema, iconNodeSchema, } from "../types.js";
|
|
3
3
|
import { NODE_COERCION_MAP, CHILD_ELEMENT_COERCION_MAP, coerceWithRule, coerceFallback, getObjectShapeFromRule, isBooleanObjectUnionRule, } from "./coercionRules.js";
|
|
4
4
|
// ===== ParseXmlError =====
|
|
5
5
|
export class ParseXmlError extends Error {
|
|
@@ -85,21 +85,21 @@ function getKnownChildAttributes(tagName) {
|
|
|
85
85
|
}
|
|
86
86
|
// ===== Leaf node Zod validation schemas =====
|
|
87
87
|
const leafNodeValidationSchemas = {
|
|
88
|
-
text:
|
|
89
|
-
image:
|
|
90
|
-
table:
|
|
91
|
-
shape:
|
|
92
|
-
chart:
|
|
93
|
-
timeline:
|
|
94
|
-
matrix:
|
|
95
|
-
tree:
|
|
96
|
-
flow:
|
|
97
|
-
processArrow:
|
|
98
|
-
pyramid:
|
|
99
|
-
line:
|
|
100
|
-
ul:
|
|
101
|
-
ol:
|
|
102
|
-
icon:
|
|
88
|
+
text: textNodeSchema,
|
|
89
|
+
image: imageNodeSchema,
|
|
90
|
+
table: tableNodeSchema,
|
|
91
|
+
shape: shapeNodeSchema,
|
|
92
|
+
chart: chartNodeSchema,
|
|
93
|
+
timeline: timelineNodeSchema,
|
|
94
|
+
matrix: matrixNodeSchema,
|
|
95
|
+
tree: treeNodeSchema,
|
|
96
|
+
flow: flowNodeSchema,
|
|
97
|
+
processArrow: processArrowNodeSchema,
|
|
98
|
+
pyramid: pyramidNodeSchema,
|
|
99
|
+
line: lineNodeSchema,
|
|
100
|
+
ul: ulNodeSchema,
|
|
101
|
+
ol: olNodeSchema,
|
|
102
|
+
icon: iconNodeSchema,
|
|
103
103
|
};
|
|
104
104
|
function formatZodIssue(issue, tagName) {
|
|
105
105
|
const path = issue.path;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/icon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/icon.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,eAAO,MAAM,WAAW,EAAE,cAqEzB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { rasterizeIcon } from "../../icons/index.js";
|
|
2
|
-
import { omitYogaNode } from "../../toPositioned/toPositioned.js";
|
|
3
2
|
import { renderIconNode } from "../../renderPptx/nodes/icon.js";
|
|
3
|
+
import { getContentArea } from "../../renderPptx/utils/contentArea.js";
|
|
4
4
|
export const iconNodeDef = {
|
|
5
5
|
type: "icon",
|
|
6
6
|
category: "leaf",
|
|
@@ -14,11 +14,19 @@ export const iconNodeDef = {
|
|
|
14
14
|
toPositioned(pom, absoluteX, absoluteY, layout, ctx) {
|
|
15
15
|
const n = pom;
|
|
16
16
|
const iconSize = n.size ?? 24;
|
|
17
|
-
|
|
17
|
+
// padding を考慮したコンテンツ領域で bg/icon の座標を計算
|
|
18
|
+
const content = getContentArea({
|
|
19
|
+
x: absoluteX,
|
|
20
|
+
y: absoluteY,
|
|
21
|
+
w: layout.width,
|
|
22
|
+
h: layout.height,
|
|
23
|
+
padding: n.padding,
|
|
24
|
+
});
|
|
25
|
+
// 実描画サイズに合わせてラスタライズ(不要に大きい PNG を防ぐ)
|
|
26
|
+
const rasterSize = Math.max(Math.ceil(n.variant ? iconSize : Math.min(content.w, content.h)), iconSize);
|
|
18
27
|
const iconImageData = rasterizeIcon(n.name, rasterSize, n.color ?? "#000000", ctx.iconRasterCache);
|
|
19
|
-
// variant 指定時はアイコンを中央に配置
|
|
20
28
|
const positioned = {
|
|
21
|
-
...
|
|
29
|
+
...n,
|
|
22
30
|
x: absoluteX,
|
|
23
31
|
y: absoluteY,
|
|
24
32
|
w: layout.width,
|
|
@@ -27,21 +35,25 @@ export const iconNodeDef = {
|
|
|
27
35
|
};
|
|
28
36
|
if (n.variant) {
|
|
29
37
|
const totalSize = Math.ceil(iconSize * 1.75);
|
|
30
|
-
// 背景図形は totalSize
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
positioned.bgX = absoluteX + bgOffsetX;
|
|
34
|
-
positioned.bgY = absoluteY + bgOffsetY;
|
|
38
|
+
// 背景図形は totalSize の正方形として、コンテンツ領域の中央に配置
|
|
39
|
+
positioned.bgX = content.x + (content.w - totalSize) / 2;
|
|
40
|
+
positioned.bgY = content.y + (content.h - totalSize) / 2;
|
|
35
41
|
positioned.bgW = totalSize;
|
|
36
42
|
positioned.bgH = totalSize;
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
positioned.iconX = absoluteX + iconOffsetX;
|
|
41
|
-
positioned.iconY = absoluteY + iconOffsetY;
|
|
43
|
+
// アイコンはコンテンツ領域の中央に配置
|
|
44
|
+
positioned.iconX = content.x + (content.w - iconSize) / 2;
|
|
45
|
+
positioned.iconY = content.y + (content.h - iconSize) / 2;
|
|
42
46
|
positioned.iconW = iconSize;
|
|
43
47
|
positioned.iconH = iconSize;
|
|
44
48
|
}
|
|
49
|
+
else {
|
|
50
|
+
// variant なしの場合もアスペクト比を維持し、コンテンツ領域の中央に配置
|
|
51
|
+
const iconSide = Math.min(content.w, content.h);
|
|
52
|
+
positioned.iconX = content.x + (content.w - iconSide) / 2;
|
|
53
|
+
positioned.iconY = content.y + (content.h - iconSide) / 2;
|
|
54
|
+
positioned.iconW = iconSide;
|
|
55
|
+
positioned.iconH = iconSide;
|
|
56
|
+
}
|
|
45
57
|
return positioned;
|
|
46
58
|
},
|
|
47
59
|
render(node, ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/image.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/image.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;AAMxD,eAAO,MAAM,YAAY,EAAE,cAmC1B,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { measureImage, getImageData } from "../../shared/measureImage.js";
|
|
2
2
|
import { renderImageNode } from "../../renderPptx/nodes/image.js";
|
|
3
|
-
import { omitYogaNode } from "../../toPositioned/toPositioned.js";
|
|
4
3
|
export const imageNodeDef = {
|
|
5
4
|
type: "image",
|
|
6
5
|
category: "leaf",
|
|
@@ -8,7 +7,7 @@ export const imageNodeDef = {
|
|
|
8
7
|
const n = node;
|
|
9
8
|
const src = n.src;
|
|
10
9
|
yn.setMeasureFunc(() => {
|
|
11
|
-
const { widthPx, heightPx } = measureImage(src, ctx.imageSizeCache);
|
|
10
|
+
const { widthPx, heightPx } = measureImage(src, ctx.imageSizeCache, ctx.diagnostics);
|
|
12
11
|
return { width: widthPx, height: heightPx };
|
|
13
12
|
});
|
|
14
13
|
},
|
|
@@ -16,7 +15,7 @@ export const imageNodeDef = {
|
|
|
16
15
|
const n = pom;
|
|
17
16
|
const imageData = getImageData(n.src, ctx.imageDataCache);
|
|
18
17
|
return {
|
|
19
|
-
...
|
|
18
|
+
...n,
|
|
20
19
|
x: absoluteX,
|
|
21
20
|
y: absoluteY,
|
|
22
21
|
w: layout.width,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/layer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"layer.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/layer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,YAAY,EAAE,cA4D1B,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { toPositioned
|
|
1
|
+
import { toPositioned } from "../../toPositioned/toPositioned.js";
|
|
2
2
|
export const layerNodeDef = {
|
|
3
3
|
type: "layer",
|
|
4
4
|
category: "absolute-child",
|
|
5
5
|
// applyYogaStyle: layer は子を絶対配置するコンテナ。サイズは明示的に指定されることを期待
|
|
6
|
-
toPositioned(pom, absoluteX, absoluteY, layout, ctx) {
|
|
6
|
+
toPositioned(pom, absoluteX, absoluteY, layout, ctx, map) {
|
|
7
7
|
const n = pom;
|
|
8
8
|
// layer の子要素は layer 内の相対座標(child.x, child.y)を持つ
|
|
9
9
|
// layer の絶対座標に加算してスライド上の絶対座標に変換
|
|
10
10
|
return {
|
|
11
|
-
...
|
|
11
|
+
...n,
|
|
12
12
|
x: absoluteX,
|
|
13
13
|
y: absoluteY,
|
|
14
14
|
w: layout.width,
|
|
@@ -26,7 +26,7 @@ export const layerNodeDef = {
|
|
|
26
26
|
const adjustedX2 = child.x2 + lineAbsoluteX;
|
|
27
27
|
const adjustedY2 = child.y2 + lineAbsoluteY;
|
|
28
28
|
return {
|
|
29
|
-
...
|
|
29
|
+
...child,
|
|
30
30
|
x1: adjustedX1,
|
|
31
31
|
y1: adjustedY1,
|
|
32
32
|
x2: adjustedX2,
|
|
@@ -38,10 +38,13 @@ export const layerNodeDef = {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
// その他のノードは通常の処理
|
|
41
|
-
const childLayout =
|
|
41
|
+
const childLayout = map.get(child);
|
|
42
|
+
if (!childLayout) {
|
|
43
|
+
throw new Error("Layout result not found in map for layer child");
|
|
44
|
+
}
|
|
42
45
|
const adjustedParentX = absoluteX + childX - childLayout.left;
|
|
43
46
|
const adjustedParentY = absoluteY + childY - childLayout.top;
|
|
44
|
-
return toPositioned(child, ctx, adjustedParentX, adjustedParentY);
|
|
47
|
+
return toPositioned(child, ctx, map, adjustedParentX, adjustedParentY);
|
|
45
48
|
}),
|
|
46
49
|
};
|
|
47
50
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/line.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/line.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,eAAO,MAAM,WAAW,EAAE,cAuBzB,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { renderLineNode } from "../../renderPptx/nodes/line.js";
|
|
2
|
-
import { omitYogaNode } from "../../toPositioned/toPositioned.js";
|
|
3
2
|
export const lineNodeDef = {
|
|
4
3
|
type: "line",
|
|
5
4
|
category: "leaf",
|
|
@@ -13,7 +12,7 @@ export const lineNodeDef = {
|
|
|
13
12
|
// line ノードは絶対座標(x1, y1, x2, y2)を持つため、
|
|
14
13
|
// yogaNode の座標ではなく自身の座標からバウンディングボックスを計算
|
|
15
14
|
return {
|
|
16
|
-
...
|
|
15
|
+
...n,
|
|
17
16
|
x: Math.min(n.x1, n.x2),
|
|
18
17
|
y: Math.min(n.y1, n.y2),
|
|
19
18
|
w: Math.abs(n.x2 - n.x1),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/list.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;AA4DxD,eAAO,MAAM,SAAS,EAAE,cAOvB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,cAOvB,CAAC"}
|
|
@@ -5,7 +5,7 @@ function applyListYogaStyle(node, yn, yoga, ctx) {
|
|
|
5
5
|
const n = node;
|
|
6
6
|
const combinedText = n.items.map((item) => item.text).join("\n");
|
|
7
7
|
const fontSizePx = n.fontSize ?? 24;
|
|
8
|
-
const fontFamily = "Noto Sans JP";
|
|
8
|
+
const fontFamily = n.fontFamily ?? "Noto Sans JP";
|
|
9
9
|
const fontWeight = n.bold ? "bold" : "normal";
|
|
10
10
|
const spacingMultiple = n.lineHeight ?? 1.3;
|
|
11
11
|
const fontMetricsRatio = measureFontLineHeightRatio(fontWeight);
|
|
@@ -20,6 +20,8 @@ function applyListYogaStyle(node, yn, yoga, ctx) {
|
|
|
20
20
|
case yoga.MEASURE_MODE_EXACTLY:
|
|
21
21
|
case yoga.MEASURE_MODE_AT_MOST:
|
|
22
22
|
return width;
|
|
23
|
+
default:
|
|
24
|
+
return Number.POSITIVE_INFINITY;
|
|
23
25
|
}
|
|
24
26
|
})();
|
|
25
27
|
const textMaxWidthPx = Math.max(0, maxWidthPx - bulletIndentPx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/shape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;AAMxD,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/shape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;AAMxD,eAAO,MAAM,YAAY,EAAE,cA4C1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;AAMxD,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/registry/definitions/text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAQ,MAAM,aAAa,CAAC;AAMxD,eAAO,MAAM,WAAW,EAAE,cA0CzB,CAAC"}
|
|
@@ -7,7 +7,7 @@ export const textNodeDef = {
|
|
|
7
7
|
const n = node;
|
|
8
8
|
const text = n.text;
|
|
9
9
|
const fontSizePx = n.fontSize ?? 24;
|
|
10
|
-
const fontFamily = "Noto Sans JP";
|
|
10
|
+
const fontFamily = n.fontFamily ?? "Noto Sans JP";
|
|
11
11
|
const fontWeight = n.bold ? "bold" : "normal";
|
|
12
12
|
const lineHeight = 1.3;
|
|
13
13
|
yn.setMeasureFunc((width, widthMode) => {
|
|
@@ -18,6 +18,8 @@ export const textNodeDef = {
|
|
|
18
18
|
case yoga.MEASURE_MODE_EXACTLY:
|
|
19
19
|
case yoga.MEASURE_MODE_AT_MOST:
|
|
20
20
|
return width;
|
|
21
|
+
default:
|
|
22
|
+
return Number.POSITIVE_INFINITY;
|
|
21
23
|
}
|
|
22
24
|
})();
|
|
23
25
|
const { widthPx, heightPx } = measureText(text, maxWidthPx, {
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Node as YogaNode } from "yoga-layout";
|
|
|
3
3
|
import type { RenderContext } from "../renderPptx/types.ts";
|
|
4
4
|
import type { loadYoga } from "yoga-layout/load";
|
|
5
5
|
import type { BuildContext } from "../buildContext.ts";
|
|
6
|
+
import type { LayoutResultMap } from "../calcYogaLayout/types.ts";
|
|
6
7
|
export type Yoga = Awaited<ReturnType<typeof loadYoga>>;
|
|
7
8
|
/** ノードのカテゴリ。子要素の扱い方を決定する */
|
|
8
9
|
export type NodeCategory = "leaf" | "single-child" | "multi-child" | "absolute-child";
|
|
@@ -17,7 +18,7 @@ export interface NodeDefinition {
|
|
|
17
18
|
toPositioned?: (pom: POMNode, absoluteX: number, absoluteY: number, layout: {
|
|
18
19
|
width: number;
|
|
19
20
|
height: number;
|
|
20
|
-
}, ctx: BuildContext) => PositionedNode;
|
|
21
|
+
}, ctx: BuildContext, map: LayoutResultMap) => PositionedNode;
|
|
21
22
|
/** PositionedNode をスライドにレンダリングする(リーフノード用) */
|
|
22
23
|
render?: (node: PositionedNode, ctx: RenderContext) => void;
|
|
23
24
|
/** 画像ソース収集(prefetch 用) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC;AAExD,4BAA4B;AAC5B,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,cAAc,GACd,aAAa,GACb,gBAAgB,CAAC;AAErB,MAAM,WAAW,cAAc;IAC7B,cAAc;IACd,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtB,cAAc;IACd,QAAQ,EAAE,YAAY,CAAC;IAEvB,6CAA6C;IAC7C,cAAc,CAAC,EAAE,CACf,IAAI,EAAE,OAAO,EACb,EAAE,EAAE,QAAQ,EACZ,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,YAAY,KACd,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B,kEAAkE;IAClE,YAAY,CAAC,EAAE,CACb,GAAG,EAAE,OAAO,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EACzC,GAAG,EAAE,YAAY,EACjB,GAAG,EAAE,eAAe,KACjB,cAAc,CAAC;IAEpB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,aAAa,KAAK,IAAI,CAAC;IAE5D,0BAA0B;IAC1B,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,EAAE,CAAC;CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/chart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,KAAK,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEtE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,mBAAmB,EACzB,GAAG,EAAE,aAAa,GACjB,IAAI,CAyBN"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { pxToIn } from "../units.js";
|
|
2
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
2
3
|
export function renderChartNode(node, ctx) {
|
|
3
4
|
const chartData = node.data.map((d) => ({
|
|
4
5
|
name: d.name,
|
|
5
6
|
labels: d.labels,
|
|
6
7
|
values: d.values,
|
|
7
8
|
}));
|
|
9
|
+
const content = getContentArea(node);
|
|
8
10
|
const chartOptions = {
|
|
9
|
-
x: pxToIn(
|
|
10
|
-
y: pxToIn(
|
|
11
|
-
w: pxToIn(
|
|
12
|
-
h: pxToIn(
|
|
11
|
+
x: pxToIn(content.x),
|
|
12
|
+
y: pxToIn(content.y),
|
|
13
|
+
w: pxToIn(content.w),
|
|
14
|
+
h: pxToIn(content.h),
|
|
13
15
|
showLegend: node.showLegend ?? false,
|
|
14
16
|
showTitle: node.showTitle ?? false,
|
|
15
17
|
title: node.title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,KAAK,kBAAkB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAWpE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,kBAAkB,EACxB,GAAG,EAAE,aAAa,GACjB,IAAI,CAwIN"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "../units.js";
|
|
2
2
|
import { measureFlow } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
3
3
|
import { calcScaleFactor } from "../utils/scaleToFit.js";
|
|
4
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
4
5
|
export function renderFlowNode(node, ctx) {
|
|
5
6
|
const direction = node.direction ?? "horizontal";
|
|
6
7
|
const nodeWidth = node.nodeWidth ?? 120;
|
|
@@ -8,20 +9,29 @@ export function renderFlowNode(node, ctx) {
|
|
|
8
9
|
const nodeGap = node.nodeGap ?? 80;
|
|
9
10
|
const connectorStyle = node.connectorStyle ?? {};
|
|
10
11
|
const defaultColor = "1D4ED8";
|
|
11
|
-
//
|
|
12
|
+
// スケール係数を計算(コンテンツ領域基準)
|
|
13
|
+
const content = getContentArea(node);
|
|
12
14
|
const intrinsic = measureFlow(node);
|
|
13
|
-
const scaleFactor = calcScaleFactor(
|
|
15
|
+
const scaleFactor = calcScaleFactor(content.w, content.h, intrinsic.width, intrinsic.height, "flow", ctx.buildContext.diagnostics);
|
|
14
16
|
const scaledNodeWidth = nodeWidth * scaleFactor;
|
|
15
17
|
const scaledNodeHeight = nodeHeight * scaleFactor;
|
|
16
18
|
const scaledNodeGap = nodeGap * scaleFactor;
|
|
17
19
|
const layouts = new Map();
|
|
18
20
|
const nodeCount = node.nodes.length;
|
|
21
|
+
// コンテンツ領域を使用するための仮想ノードを作成
|
|
22
|
+
const contentNode = {
|
|
23
|
+
...node,
|
|
24
|
+
x: content.x,
|
|
25
|
+
y: content.y,
|
|
26
|
+
w: content.w,
|
|
27
|
+
h: content.h,
|
|
28
|
+
};
|
|
19
29
|
// ノードのレイアウトを計算
|
|
20
30
|
if (direction === "horizontal") {
|
|
21
|
-
calculateHorizontalLayout(
|
|
31
|
+
calculateHorizontalLayout(contentNode, layouts, nodeCount, scaledNodeWidth, scaledNodeHeight, scaledNodeGap, scaleFactor);
|
|
22
32
|
}
|
|
23
33
|
else {
|
|
24
|
-
calculateVerticalLayout(
|
|
34
|
+
calculateVerticalLayout(contentNode, layouts, nodeCount, scaledNodeWidth, scaledNodeHeight, scaledNodeGap, scaleFactor);
|
|
25
35
|
}
|
|
26
36
|
// 接続線を描画(ノードより先に描画して背面に配置)
|
|
27
37
|
for (const conn of node.connections) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,KAAK,mBAAmB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEtE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,mBAAmB,EACzB,GAAG,EAAE,aAAa,GACjB,IAAI,CAoCN"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { pxToIn } from "../units.js";
|
|
2
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
2
3
|
export function renderImageNode(node, ctx) {
|
|
4
|
+
const content = getContentArea(node);
|
|
3
5
|
const imageOptions = {
|
|
4
|
-
x: pxToIn(
|
|
5
|
-
y: pxToIn(
|
|
6
|
-
w: pxToIn(
|
|
7
|
-
h: pxToIn(
|
|
6
|
+
x: pxToIn(content.x),
|
|
7
|
+
y: pxToIn(content.y),
|
|
8
|
+
w: pxToIn(content.w),
|
|
9
|
+
h: pxToIn(content.h),
|
|
8
10
|
shadow: node.shadow
|
|
9
11
|
? {
|
|
10
|
-
type: node.shadow.type,
|
|
12
|
+
type: node.shadow.type ?? "outer",
|
|
11
13
|
opacity: node.shadow.opacity,
|
|
12
14
|
blur: node.shadow.blur,
|
|
13
15
|
angle: node.shadow.angle,
|
|
@@ -19,8 +21,8 @@ export function renderImageNode(node, ctx) {
|
|
|
19
21
|
if (node.sizing) {
|
|
20
22
|
imageOptions.sizing = {
|
|
21
23
|
type: node.sizing.type,
|
|
22
|
-
w: pxToIn(node.sizing.w ??
|
|
23
|
-
h: pxToIn(node.sizing.h ??
|
|
24
|
+
w: pxToIn(node.sizing.w ?? content.w),
|
|
25
|
+
h: pxToIn(node.sizing.h ?? content.h),
|
|
24
26
|
...(node.sizing.x !== undefined && { x: pxToIn(node.sizing.x) }),
|
|
25
27
|
...(node.sizing.y !== undefined && { y: pxToIn(node.sizing.y) }),
|
|
26
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAU,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAU,MAAM,gBAAgB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,KAAK,gBAAgB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AAChE,KAAK,gBAAgB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC;AA6BhE,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CA4D7E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAkE7E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "../units.js";
|
|
2
2
|
import { convertUnderline, convertStrike } from "../textOptions.js";
|
|
3
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
3
4
|
function resolveStyle(li, parent) {
|
|
4
5
|
return {
|
|
5
6
|
fontSize: li.fontSize ?? parent.fontSize ?? 24,
|
|
@@ -26,6 +27,7 @@ export function renderUlNode(node, ctx) {
|
|
|
26
27
|
const fontSizePx = node.fontSize ?? 24;
|
|
27
28
|
const fontFamily = node.fontFamily ?? "Noto Sans JP";
|
|
28
29
|
const lineHeight = node.lineHeight ?? 1.3;
|
|
30
|
+
const content = getContentArea(node);
|
|
29
31
|
if (hasItemStyleOverride(node.items)) {
|
|
30
32
|
// Li に個別スタイルがある場合は配列形式を使用
|
|
31
33
|
const textItems = node.items.map((li, i) => {
|
|
@@ -46,10 +48,10 @@ export function renderUlNode(node, ctx) {
|
|
|
46
48
|
};
|
|
47
49
|
});
|
|
48
50
|
ctx.slide.addText(textItems, {
|
|
49
|
-
x: pxToIn(
|
|
50
|
-
y: pxToIn(
|
|
51
|
-
w: pxToIn(
|
|
52
|
-
h: pxToIn(
|
|
51
|
+
x: pxToIn(content.x),
|
|
52
|
+
y: pxToIn(content.y),
|
|
53
|
+
w: pxToIn(content.w),
|
|
54
|
+
h: pxToIn(content.h),
|
|
53
55
|
align: node.textAlign ?? "left",
|
|
54
56
|
valign: "top",
|
|
55
57
|
margin: 0,
|
|
@@ -60,10 +62,10 @@ export function renderUlNode(node, ctx) {
|
|
|
60
62
|
// Li にスタイルオーバーライドがない場合は単一文字列形式を使用
|
|
61
63
|
const text = node.items.map((li) => li.text).join("\n");
|
|
62
64
|
ctx.slide.addText(text, {
|
|
63
|
-
x: pxToIn(
|
|
64
|
-
y: pxToIn(
|
|
65
|
-
w: pxToIn(
|
|
66
|
-
h: pxToIn(
|
|
65
|
+
x: pxToIn(content.x),
|
|
66
|
+
y: pxToIn(content.y),
|
|
67
|
+
w: pxToIn(content.w),
|
|
68
|
+
h: pxToIn(content.h),
|
|
67
69
|
fontSize: pxToPt(fontSizePx),
|
|
68
70
|
fontFace: fontFamily,
|
|
69
71
|
align: node.textAlign ?? "left",
|
|
@@ -84,6 +86,7 @@ export function renderOlNode(node, ctx) {
|
|
|
84
86
|
const fontSizePx = node.fontSize ?? 24;
|
|
85
87
|
const fontFamily = node.fontFamily ?? "Noto Sans JP";
|
|
86
88
|
const lineHeight = node.lineHeight ?? 1.3;
|
|
89
|
+
const content = getContentArea(node);
|
|
87
90
|
const bulletOptions = { type: "number" };
|
|
88
91
|
if (node.numberType !== undefined) {
|
|
89
92
|
bulletOptions.numberType = node.numberType;
|
|
@@ -110,10 +113,10 @@ export function renderOlNode(node, ctx) {
|
|
|
110
113
|
};
|
|
111
114
|
});
|
|
112
115
|
ctx.slide.addText(textItems, {
|
|
113
|
-
x: pxToIn(
|
|
114
|
-
y: pxToIn(
|
|
115
|
-
w: pxToIn(
|
|
116
|
-
h: pxToIn(
|
|
116
|
+
x: pxToIn(content.x),
|
|
117
|
+
y: pxToIn(content.y),
|
|
118
|
+
w: pxToIn(content.w),
|
|
119
|
+
h: pxToIn(content.h),
|
|
117
120
|
align: node.textAlign ?? "left",
|
|
118
121
|
valign: "top",
|
|
119
122
|
margin: 0,
|
|
@@ -123,10 +126,10 @@ export function renderOlNode(node, ctx) {
|
|
|
123
126
|
else {
|
|
124
127
|
const text = node.items.map((li) => li.text).join("\n");
|
|
125
128
|
ctx.slide.addText(text, {
|
|
126
|
-
x: pxToIn(
|
|
127
|
-
y: pxToIn(
|
|
128
|
-
w: pxToIn(
|
|
129
|
-
h: pxToIn(
|
|
129
|
+
x: pxToIn(content.x),
|
|
130
|
+
y: pxToIn(content.y),
|
|
131
|
+
w: pxToIn(content.w),
|
|
132
|
+
h: pxToIn(content.h),
|
|
130
133
|
fontSize: pxToPt(fontSizePx),
|
|
131
134
|
fontFace: fontFamily,
|
|
132
135
|
align: node.textAlign ?? "left",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"matrix.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/matrix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,KAAK,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAExE,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,oBAAoB,EAC1B,GAAG,EAAE,aAAa,GACjB,IAAI,CAwIN"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "../units.js";
|
|
2
2
|
import { measureMatrix } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
3
3
|
import { calcScaleFactor } from "../utils/scaleToFit.js";
|
|
4
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
4
5
|
export function renderMatrixNode(node, ctx) {
|
|
5
6
|
const items = node.items;
|
|
6
7
|
const axes = node.axes;
|
|
@@ -9,17 +10,18 @@ export function renderMatrixNode(node, ctx) {
|
|
|
9
10
|
const baseItemSize = 24; // px
|
|
10
11
|
const baseLineWidth = 2; // px
|
|
11
12
|
const axisColor = "E2E8F0";
|
|
12
|
-
//
|
|
13
|
+
// スケール係数を計算(コンテンツ領域基準)
|
|
14
|
+
const content = getContentArea(node);
|
|
13
15
|
const intrinsic = measureMatrix(node);
|
|
14
|
-
const scaleFactor = calcScaleFactor(
|
|
16
|
+
const scaleFactor = calcScaleFactor(content.w, content.h, intrinsic.width, intrinsic.height, "matrix", ctx.buildContext.diagnostics);
|
|
15
17
|
const itemSize = baseItemSize * scaleFactor;
|
|
16
18
|
const lineWidth = baseLineWidth * scaleFactor;
|
|
17
|
-
//
|
|
18
|
-
const
|
|
19
|
-
const areaX =
|
|
20
|
-
const areaY =
|
|
21
|
-
const areaW =
|
|
22
|
-
const areaH =
|
|
19
|
+
// マトリクスの描画領域(軸ラベル用の余白を考慮)
|
|
20
|
+
const axisMargin = 60 * scaleFactor; // 軸ラベル用の余白
|
|
21
|
+
const areaX = content.x + axisMargin;
|
|
22
|
+
const areaY = content.y + axisMargin;
|
|
23
|
+
const areaW = content.w - axisMargin * 2;
|
|
24
|
+
const areaH = content.h - axisMargin * 2;
|
|
23
25
|
// 中心座標
|
|
24
26
|
const centerX = areaX + areaW / 2;
|
|
25
27
|
const centerY = areaY + areaH / 2;
|
|
@@ -57,7 +59,7 @@ export function renderMatrixNode(node, ctx) {
|
|
|
57
59
|
});
|
|
58
60
|
// Y軸ラベル(左部中央)
|
|
59
61
|
ctx.slide.addText(axes.y, {
|
|
60
|
-
x: pxToIn(
|
|
62
|
+
x: pxToIn(content.x + 4 * scaleFactor),
|
|
61
63
|
y: pxToIn(centerY - 12 * scaleFactor),
|
|
62
64
|
w: pxToIn(48 * scaleFactor),
|
|
63
65
|
h: pxToIn(axisLabelH),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processArrow.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/processArrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"processArrow.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/processArrow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAYjD,KAAK,0BAA0B,GAAG,OAAO,CACvC,cAAc,EACd;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CACzB,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,0BAA0B,EAChC,GAAG,EAAE,aAAa,GACjB,IAAI,CAqEN"}
|
|
@@ -3,6 +3,7 @@ import { convertUnderline, convertStrike } from "../textOptions.js";
|
|
|
3
3
|
import { measureProcessArrow } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
4
4
|
import { calcScaleFactor } from "../utils/scaleToFit.js";
|
|
5
5
|
import { ARROW_DEPTH_RATIO, DEFAULT_PROCESS_ARROW_ITEM_WIDTH, DEFAULT_PROCESS_ARROW_ITEM_HEIGHT, } from "../../shared/processArrowConstants.js";
|
|
6
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
6
7
|
export function renderProcessArrowNode(node, ctx) {
|
|
7
8
|
const direction = node.direction ?? "horizontal";
|
|
8
9
|
const steps = node.steps;
|
|
@@ -15,18 +16,27 @@ export function renderProcessArrowNode(node, ctx) {
|
|
|
15
16
|
const itemHeight = node.itemHeight ?? DEFAULT_PROCESS_ARROW_ITEM_HEIGHT;
|
|
16
17
|
const arrowDepth = itemHeight * ARROW_DEPTH_RATIO;
|
|
17
18
|
const gap = node.gap ?? -arrowDepth;
|
|
18
|
-
//
|
|
19
|
+
// スケール係数を計算(コンテンツ領域基準)
|
|
20
|
+
const content = getContentArea(node);
|
|
19
21
|
const intrinsic = measureProcessArrow(node);
|
|
20
|
-
const scaleFactor = calcScaleFactor(
|
|
22
|
+
const scaleFactor = calcScaleFactor(content.w, content.h, intrinsic.width, intrinsic.height, "processArrow", ctx.buildContext.diagnostics);
|
|
21
23
|
const scaledItemWidth = itemWidth * scaleFactor;
|
|
22
24
|
const scaledItemHeight = itemHeight * scaleFactor;
|
|
23
25
|
const scaledGap = gap * scaleFactor;
|
|
24
26
|
const scaledArrowDepth = arrowDepth * scaleFactor;
|
|
27
|
+
// コンテンツ領域を使用するための仮想ノードを作成
|
|
28
|
+
const contentNode = {
|
|
29
|
+
...node,
|
|
30
|
+
x: content.x,
|
|
31
|
+
y: content.y,
|
|
32
|
+
w: content.w,
|
|
33
|
+
h: content.h,
|
|
34
|
+
};
|
|
25
35
|
if (direction === "horizontal") {
|
|
26
|
-
renderHorizontalProcessArrow(
|
|
36
|
+
renderHorizontalProcessArrow(contentNode, ctx, steps, stepCount, scaledItemWidth, scaledItemHeight, scaledGap, scaledArrowDepth, defaultColor, defaultTextColor, scaleFactor);
|
|
27
37
|
}
|
|
28
38
|
else {
|
|
29
|
-
renderVerticalProcessArrow(
|
|
39
|
+
renderVerticalProcessArrow(contentNode, ctx, steps, stepCount, scaledItemWidth, scaledItemHeight, scaledGap, scaledArrowDepth, defaultColor, defaultTextColor, scaleFactor);
|
|
30
40
|
}
|
|
31
41
|
}
|
|
32
42
|
function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, arrowDepth, defaultColor, defaultTextColor, scaleFactor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pyramid.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/pyramid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"pyramid.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/pyramid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,KAAK,qBAAqB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAE1E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,qBAAqB,EAC3B,GAAG,EAAE,aAAa,GACjB,IAAI,CAkGN"}
|