@hirokisakabe/pom 1.4.0 → 3.0.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.
Files changed (87) hide show
  1. package/README.md +158 -193
  2. package/dist/buildPptx.d.ts +2 -2
  3. package/dist/buildPptx.d.ts.map +1 -1
  4. package/dist/buildPptx.js +3 -1
  5. package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
  6. package/dist/calcYogaLayout/calcYogaLayout.js +95 -19
  7. package/dist/calcYogaLayout/fontLoader.d.ts +0 -7
  8. package/dist/calcYogaLayout/fontLoader.d.ts.map +1 -1
  9. package/dist/calcYogaLayout/fontLoader.js +1 -1
  10. package/dist/calcYogaLayout/measureText.d.ts +0 -4
  11. package/dist/calcYogaLayout/measureText.d.ts.map +1 -1
  12. package/dist/calcYogaLayout/measureText.js +0 -6
  13. package/dist/index.d.ts +2 -5
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -4
  16. package/dist/{inputSchema.d.ts → parseXml/inputSchema.d.ts} +254 -460
  17. package/dist/parseXml/inputSchema.d.ts.map +1 -0
  18. package/dist/{inputSchema.js → parseXml/inputSchema.js} +42 -140
  19. package/dist/{parseXml.d.ts → parseXml/parseXml.d.ts} +6 -2
  20. package/dist/parseXml/parseXml.d.ts.map +1 -0
  21. package/dist/parseXml/parseXml.js +823 -0
  22. package/dist/renderPptx/nodes/flow.d.ts.map +1 -1
  23. package/dist/renderPptx/nodes/flow.js +26 -16
  24. package/dist/renderPptx/nodes/index.d.ts +1 -0
  25. package/dist/renderPptx/nodes/index.d.ts.map +1 -1
  26. package/dist/renderPptx/nodes/index.js +1 -0
  27. package/dist/renderPptx/nodes/list.d.ts +12 -0
  28. package/dist/renderPptx/nodes/list.d.ts.map +1 -0
  29. package/dist/renderPptx/nodes/list.js +145 -0
  30. package/dist/renderPptx/nodes/matrix.d.ts.map +1 -1
  31. package/dist/renderPptx/nodes/matrix.js +43 -31
  32. package/dist/renderPptx/nodes/processArrow.d.ts.map +1 -1
  33. package/dist/renderPptx/nodes/processArrow.js +14 -6
  34. package/dist/renderPptx/nodes/shape.js +2 -2
  35. package/dist/renderPptx/nodes/table.d.ts.map +1 -1
  36. package/dist/renderPptx/nodes/table.js +1 -1
  37. package/dist/renderPptx/nodes/timeline.d.ts.map +1 -1
  38. package/dist/renderPptx/nodes/timeline.js +58 -37
  39. package/dist/renderPptx/nodes/tree.d.ts.map +1 -1
  40. package/dist/renderPptx/nodes/tree.js +49 -40
  41. package/dist/renderPptx/renderPptx.d.ts +1 -2
  42. package/dist/renderPptx/renderPptx.d.ts.map +1 -1
  43. package/dist/renderPptx/renderPptx.js +8 -4
  44. package/dist/renderPptx/textOptions.d.ts +1 -29
  45. package/dist/renderPptx/textOptions.d.ts.map +1 -1
  46. package/dist/renderPptx/textOptions.js +1 -27
  47. package/dist/renderPptx/types.d.ts +0 -2
  48. package/dist/renderPptx/types.d.ts.map +1 -1
  49. package/dist/renderPptx/utils/backgroundBorder.js +1 -1
  50. package/dist/renderPptx/utils/scaleToFit.d.ts +8 -0
  51. package/dist/renderPptx/utils/scaleToFit.d.ts.map +1 -0
  52. package/dist/renderPptx/utils/scaleToFit.js +19 -0
  53. package/dist/shared/measureImage.d.ts.map +1 -0
  54. package/dist/{table/utils.d.ts → shared/tableUtils.d.ts} +1 -3
  55. package/dist/shared/tableUtils.d.ts.map +1 -0
  56. package/dist/{table/utils.js → shared/tableUtils.js} +2 -2
  57. package/dist/toPositioned/toPositioned.d.ts.map +1 -1
  58. package/dist/toPositioned/toPositioned.js +4 -2
  59. package/dist/types.d.ts +271 -154
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/types.js +67 -33
  62. package/package.json +3 -6
  63. package/dist/calcYogaLayout/measureImage.d.ts.map +0 -1
  64. package/dist/component.d.ts +0 -90
  65. package/dist/component.d.ts.map +0 -1
  66. package/dist/component.js +0 -123
  67. package/dist/inputSchema.d.ts.map +0 -1
  68. package/dist/parseXml.d.ts.map +0 -1
  69. package/dist/parseXml.js +0 -332
  70. package/dist/renderPptx/nodes/box.d.ts +0 -2
  71. package/dist/renderPptx/nodes/box.d.ts.map +0 -1
  72. package/dist/renderPptx/nodes/box.js +0 -3
  73. package/dist/renderPptx/utils/index.d.ts +0 -6
  74. package/dist/renderPptx/utils/index.d.ts.map +0 -1
  75. package/dist/renderPptx/utils/index.js +0 -3
  76. package/dist/renderPptx/utils/shapeDrawing.d.ts +0 -27
  77. package/dist/renderPptx/utils/shapeDrawing.d.ts.map +0 -1
  78. package/dist/renderPptx/utils/shapeDrawing.js +0 -36
  79. package/dist/renderPptx/utils/textDrawing.d.ts +0 -25
  80. package/dist/renderPptx/utils/textDrawing.d.ts.map +0 -1
  81. package/dist/renderPptx/utils/textDrawing.js +0 -25
  82. package/dist/schema.d.ts +0 -23
  83. package/dist/schema.d.ts.map +0 -1
  84. package/dist/schema.js +0 -24
  85. package/dist/table/utils.d.ts.map +0 -1
  86. /package/dist/{calcYogaLayout → shared}/measureImage.d.ts +0 -0
  87. /package/dist/{calcYogaLayout → shared}/measureImage.js +0 -0
@@ -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;AAGjD,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,CA0GN"}
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;AAKjD,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,CA6HN"}
@@ -1,4 +1,6 @@
1
1
  import { pxToIn, pxToPt } from "../units.js";
2
+ import { measureFlow } from "../../calcYogaLayout/measureCompositeNodes.js";
3
+ import { calcScaleFactor } from "../utils/scaleToFit.js";
2
4
  export function renderFlowNode(node, ctx) {
3
5
  const direction = node.direction ?? "horizontal";
4
6
  const nodeWidth = node.nodeWidth ?? 120;
@@ -6,14 +8,20 @@ export function renderFlowNode(node, ctx) {
6
8
  const nodeGap = node.nodeGap ?? 80;
7
9
  const connectorStyle = node.connectorStyle ?? {};
8
10
  const defaultColor = "1D4ED8";
11
+ // スケール係数を計算
12
+ const intrinsic = measureFlow(node);
13
+ const scaleFactor = calcScaleFactor(node.w, node.h, intrinsic.width, intrinsic.height, "flow");
14
+ const scaledNodeWidth = nodeWidth * scaleFactor;
15
+ const scaledNodeHeight = nodeHeight * scaleFactor;
16
+ const scaledNodeGap = nodeGap * scaleFactor;
9
17
  const layouts = new Map();
10
18
  const nodeCount = node.nodes.length;
11
19
  // ノードのレイアウトを計算
12
20
  if (direction === "horizontal") {
13
- calculateHorizontalLayout(node, layouts, nodeCount, nodeWidth, nodeHeight, nodeGap);
21
+ calculateHorizontalLayout(node, layouts, nodeCount, scaledNodeWidth, scaledNodeHeight, scaledNodeGap, scaleFactor);
14
22
  }
15
23
  else {
16
- calculateVerticalLayout(node, layouts, nodeCount, nodeWidth, nodeHeight, nodeGap);
24
+ calculateVerticalLayout(node, layouts, nodeCount, scaledNodeWidth, scaledNodeHeight, scaledNodeGap, scaleFactor);
17
25
  }
18
26
  // 接続線を描画(ノードより先に描画して背面に配置)
19
27
  for (const conn of node.connections) {
@@ -22,7 +30,7 @@ export function renderFlowNode(node, ctx) {
22
30
  if (!fromLayout || !toLayout)
23
31
  continue;
24
32
  const lineColor = conn.color ?? connectorStyle.color ?? "333333";
25
- const lineWidth = connectorStyle.width ?? 2;
33
+ const lineWidth = (connectorStyle.width ?? 2) * scaleFactor;
26
34
  const arrowType = connectorStyle.arrowType ?? "triangle";
27
35
  drawConnection(ctx, direction, fromLayout, toLayout, lineColor, lineWidth, arrowType);
28
36
  // ラベルを描画
@@ -37,12 +45,14 @@ export function renderFlowNode(node, ctx) {
37
45
  toLayout.y +
38
46
  toLayout.height / 2) /
39
47
  2;
48
+ const labelW = 60 * scaleFactor;
49
+ const labelH = 20 * scaleFactor;
40
50
  ctx.slide.addText(conn.label, {
41
- x: pxToIn(labelX - 30),
42
- y: pxToIn(labelY - 10),
43
- w: pxToIn(60),
44
- h: pxToIn(20),
45
- fontSize: pxToPt(10),
51
+ x: pxToIn(labelX - labelW / 2),
52
+ y: pxToIn(labelY - labelH / 2),
53
+ w: pxToIn(labelW),
54
+ h: pxToIn(labelH),
55
+ fontSize: pxToPt(10 * scaleFactor),
46
56
  fontFace: "Noto Sans JP",
47
57
  color: "64748B",
48
58
  align: "center",
@@ -65,8 +75,8 @@ export function renderFlowNode(node, ctx) {
65
75
  h: pxToIn(layout.height),
66
76
  shape: item.shape,
67
77
  fill: { color: fillColor },
68
- line: { color: "333333", width: pxToPt(1) },
69
- fontSize: pxToPt(14),
78
+ line: { color: "333333", width: pxToPt(1 * scaleFactor) },
79
+ fontSize: pxToPt(14 * scaleFactor),
70
80
  fontFace: "Noto Sans JP",
71
81
  color: textColor,
72
82
  align: "center",
@@ -74,13 +84,13 @@ export function renderFlowNode(node, ctx) {
74
84
  });
75
85
  }
76
86
  }
77
- function calculateHorizontalLayout(node, layouts, nodeCount, nodeWidth, nodeHeight, nodeGap) {
87
+ function calculateHorizontalLayout(node, layouts, nodeCount, nodeWidth, nodeHeight, nodeGap, scaleFactor) {
78
88
  const totalWidth = nodeCount * nodeWidth + (nodeCount - 1) * nodeGap;
79
89
  const startX = node.x + (node.w - totalWidth) / 2;
80
90
  const centerY = node.y + node.h / 2;
81
91
  node.nodes.forEach((item, index) => {
82
- const w = item.width ?? nodeWidth;
83
- const h = item.height ?? nodeHeight;
92
+ const w = (item.width ?? nodeWidth / scaleFactor) * scaleFactor;
93
+ const h = (item.height ?? nodeHeight / scaleFactor) * scaleFactor;
84
94
  layouts.set(item.id, {
85
95
  id: item.id,
86
96
  x: startX + index * (nodeWidth + nodeGap) + (nodeWidth - w) / 2,
@@ -91,13 +101,13 @@ function calculateHorizontalLayout(node, layouts, nodeCount, nodeWidth, nodeHeig
91
101
  });
92
102
  });
93
103
  }
94
- function calculateVerticalLayout(node, layouts, nodeCount, nodeWidth, nodeHeight, nodeGap) {
104
+ function calculateVerticalLayout(node, layouts, nodeCount, nodeWidth, nodeHeight, nodeGap, scaleFactor) {
95
105
  const totalHeight = nodeCount * nodeHeight + (nodeCount - 1) * nodeGap;
96
106
  const startY = node.y + (node.h - totalHeight) / 2;
97
107
  const centerX = node.x + node.w / 2;
98
108
  node.nodes.forEach((item, index) => {
99
- const w = item.width ?? nodeWidth;
100
- const h = item.height ?? nodeHeight;
109
+ const w = (item.width ?? nodeWidth / scaleFactor) * scaleFactor;
110
+ const h = (item.height ?? nodeHeight / scaleFactor) * scaleFactor;
101
111
  layouts.set(item.id, {
102
112
  id: item.id,
103
113
  x: centerX - w / 2,
@@ -9,4 +9,5 @@ export { renderTreeNode } from "./tree.ts";
9
9
  export { renderFlowNode } from "./flow.ts";
10
10
  export { renderProcessArrowNode } from "./processArrow.ts";
11
11
  export { renderLineNode } from "./line.ts";
12
+ export { renderUlNode, renderOlNode } from "./list.ts";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
@@ -9,3 +9,4 @@ export { renderTreeNode } from "./tree.js";
9
9
  export { renderFlowNode } from "./flow.js";
10
10
  export { renderProcessArrowNode } from "./processArrow.js";
11
11
  export { renderLineNode } from "./line.js";
12
+ export { renderUlNode, renderOlNode } from "./list.js";
@@ -0,0 +1,12 @@
1
+ import type { PositionedNode } from "../../types.ts";
2
+ import type { RenderContext } from "../types.ts";
3
+ type UlPositionedNode = Extract<PositionedNode, {
4
+ type: "ul";
5
+ }>;
6
+ type OlPositionedNode = Extract<PositionedNode, {
7
+ type: "ol";
8
+ }>;
9
+ export declare function renderUlNode(node: UlPositionedNode, ctx: RenderContext): void;
10
+ export declare function renderOlNode(node: OlPositionedNode, ctx: RenderContext): void;
11
+ export {};
12
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +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;AAIjD,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,CA2D7E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAiE7E"}
@@ -0,0 +1,145 @@
1
+ import { pxToIn, pxToPt } from "../units.js";
2
+ import { convertUnderline, convertStrike } from "../textOptions.js";
3
+ function resolveStyle(li, parent) {
4
+ return {
5
+ fontPx: li.fontPx ?? parent.fontPx ?? 24,
6
+ color: li.color ?? parent.color,
7
+ bold: li.bold ?? parent.bold,
8
+ italic: li.italic ?? parent.italic,
9
+ underline: li.underline ?? parent.underline,
10
+ strike: li.strike ?? parent.strike,
11
+ highlight: li.highlight ?? parent.highlight,
12
+ fontFamily: li.fontFamily ?? parent.fontFamily ?? "Noto Sans JP",
13
+ };
14
+ }
15
+ function hasItemStyleOverride(items) {
16
+ return items.some((li) => li.fontPx !== undefined ||
17
+ li.color !== undefined ||
18
+ li.bold !== undefined ||
19
+ li.italic !== undefined ||
20
+ li.underline !== undefined ||
21
+ li.strike !== undefined ||
22
+ li.highlight !== undefined ||
23
+ li.fontFamily !== undefined);
24
+ }
25
+ export function renderUlNode(node, ctx) {
26
+ const fontSizePx = node.fontPx ?? 24;
27
+ const fontFamily = node.fontFamily ?? "Noto Sans JP";
28
+ const lineSpacingMultiple = node.lineSpacingMultiple ?? 1.3;
29
+ if (hasItemStyleOverride(node.items)) {
30
+ // Li に個別スタイルがある場合は配列形式を使用
31
+ const textItems = node.items.map((li, i) => {
32
+ const style = resolveStyle(li, node);
33
+ return {
34
+ text: i < node.items.length - 1 ? li.text + "\n" : li.text,
35
+ options: {
36
+ fontSize: pxToPt(style.fontPx),
37
+ fontFace: style.fontFamily,
38
+ color: style.color,
39
+ bold: style.bold,
40
+ italic: style.italic,
41
+ underline: convertUnderline(style.underline),
42
+ strike: convertStrike(style.strike),
43
+ highlight: style.highlight,
44
+ bullet: true,
45
+ },
46
+ };
47
+ });
48
+ ctx.slide.addText(textItems, {
49
+ x: pxToIn(node.x),
50
+ y: pxToIn(node.y),
51
+ w: pxToIn(node.w),
52
+ h: pxToIn(node.h),
53
+ align: node.alignText ?? "left",
54
+ valign: "top",
55
+ margin: 0,
56
+ lineSpacingMultiple,
57
+ });
58
+ }
59
+ else {
60
+ // Li にスタイルオーバーライドがない場合は単一文字列形式を使用
61
+ const text = node.items.map((li) => li.text).join("\n");
62
+ ctx.slide.addText(text, {
63
+ x: pxToIn(node.x),
64
+ y: pxToIn(node.y),
65
+ w: pxToIn(node.w),
66
+ h: pxToIn(node.h),
67
+ fontSize: pxToPt(fontSizePx),
68
+ fontFace: fontFamily,
69
+ align: node.alignText ?? "left",
70
+ valign: "top",
71
+ margin: 0,
72
+ lineSpacingMultiple,
73
+ color: node.color,
74
+ bold: node.bold,
75
+ italic: node.italic,
76
+ underline: convertUnderline(node.underline),
77
+ strike: convertStrike(node.strike),
78
+ highlight: node.highlight,
79
+ bullet: true,
80
+ });
81
+ }
82
+ }
83
+ export function renderOlNode(node, ctx) {
84
+ const fontSizePx = node.fontPx ?? 24;
85
+ const fontFamily = node.fontFamily ?? "Noto Sans JP";
86
+ const lineSpacingMultiple = node.lineSpacingMultiple ?? 1.3;
87
+ const bulletOptions = { type: "number" };
88
+ if (node.numberType !== undefined) {
89
+ bulletOptions.numberType = node.numberType;
90
+ }
91
+ if (node.numberStartAt !== undefined) {
92
+ bulletOptions.numberStartAt = node.numberStartAt;
93
+ }
94
+ if (hasItemStyleOverride(node.items)) {
95
+ const textItems = node.items.map((li, i) => {
96
+ const style = resolveStyle(li, node);
97
+ return {
98
+ text: i < node.items.length - 1 ? li.text + "\n" : li.text,
99
+ options: {
100
+ fontSize: pxToPt(style.fontPx),
101
+ fontFace: style.fontFamily,
102
+ color: style.color,
103
+ bold: style.bold,
104
+ italic: style.italic,
105
+ underline: convertUnderline(style.underline),
106
+ strike: convertStrike(style.strike),
107
+ highlight: style.highlight,
108
+ bullet: bulletOptions,
109
+ },
110
+ };
111
+ });
112
+ ctx.slide.addText(textItems, {
113
+ x: pxToIn(node.x),
114
+ y: pxToIn(node.y),
115
+ w: pxToIn(node.w),
116
+ h: pxToIn(node.h),
117
+ align: node.alignText ?? "left",
118
+ valign: "top",
119
+ margin: 0,
120
+ lineSpacingMultiple,
121
+ });
122
+ }
123
+ else {
124
+ const text = node.items.map((li) => li.text).join("\n");
125
+ ctx.slide.addText(text, {
126
+ x: pxToIn(node.x),
127
+ y: pxToIn(node.y),
128
+ w: pxToIn(node.w),
129
+ h: pxToIn(node.h),
130
+ fontSize: pxToPt(fontSizePx),
131
+ fontFace: fontFamily,
132
+ align: node.alignText ?? "left",
133
+ valign: "top",
134
+ margin: 0,
135
+ lineSpacingMultiple,
136
+ color: node.color,
137
+ bold: node.bold,
138
+ italic: node.italic,
139
+ underline: convertUnderline(node.underline),
140
+ strike: convertStrike(node.strike),
141
+ highlight: node.highlight,
142
+ bullet: bulletOptions,
143
+ });
144
+ }
145
+ }
@@ -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;AAGjD,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,CAkHN"}
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;AAKjD,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,CAsIN"}
@@ -1,14 +1,21 @@
1
1
  import { pxToIn, pxToPt } from "../units.js";
2
+ import { measureMatrix } from "../../calcYogaLayout/measureCompositeNodes.js";
3
+ import { calcScaleFactor } from "../utils/scaleToFit.js";
2
4
  export function renderMatrixNode(node, ctx) {
3
5
  const items = node.items;
4
6
  const axes = node.axes;
5
7
  const quadrants = node.quadrants;
6
8
  const defaultItemColor = "1D4ED8"; // blue
7
- const itemSize = 24; // px
8
- const lineWidth = 2; // px
9
+ const baseItemSize = 24; // px
10
+ const baseLineWidth = 2; // px
9
11
  const axisColor = "E2E8F0";
12
+ // スケール係数を計算
13
+ const intrinsic = measureMatrix(node);
14
+ const scaleFactor = calcScaleFactor(node.w, node.h, intrinsic.width, intrinsic.height, "matrix");
15
+ const itemSize = baseItemSize * scaleFactor;
16
+ const lineWidth = baseLineWidth * scaleFactor;
10
17
  // マトリクスの描画領域(パディングを考慮)
11
- const padding = 60; // 軸ラベル用の余白
18
+ const padding = 60 * scaleFactor; // 軸ラベル用の余白
12
19
  const areaX = node.x + padding;
13
20
  const areaY = node.y + padding;
14
21
  const areaW = node.w - padding * 2;
@@ -34,13 +41,15 @@ export function renderMatrixNode(node, ctx) {
34
41
  line: { color: axisColor, width: pxToPt(lineWidth) },
35
42
  });
36
43
  // === 2. 軸ラベルを描画 ===
44
+ const axisLabelW = 120 * scaleFactor;
45
+ const axisLabelH = 24 * scaleFactor;
37
46
  // X軸ラベル(下部中央)
38
47
  ctx.slide.addText(axes.x, {
39
- x: pxToIn(centerX - 60),
40
- y: pxToIn(areaY + areaH + 8),
41
- w: pxToIn(120),
42
- h: pxToIn(24),
43
- fontSize: pxToPt(12),
48
+ x: pxToIn(centerX - axisLabelW / 2),
49
+ y: pxToIn(areaY + areaH + 8 * scaleFactor),
50
+ w: pxToIn(axisLabelW),
51
+ h: pxToIn(axisLabelH),
52
+ fontSize: pxToPt(12 * scaleFactor),
44
53
  fontFace: "Noto Sans JP",
45
54
  color: "64748B",
46
55
  align: "center",
@@ -48,11 +57,11 @@ export function renderMatrixNode(node, ctx) {
48
57
  });
49
58
  // Y軸ラベル(左部中央)
50
59
  ctx.slide.addText(axes.y, {
51
- x: pxToIn(node.x + 4),
52
- y: pxToIn(centerY - 12),
53
- w: pxToIn(48),
54
- h: pxToIn(24),
55
- fontSize: pxToPt(12),
60
+ x: pxToIn(node.x + 4 * scaleFactor),
61
+ y: pxToIn(centerY - 12 * scaleFactor),
62
+ w: pxToIn(48 * scaleFactor),
63
+ h: pxToIn(axisLabelH),
64
+ fontSize: pxToPt(12 * scaleFactor),
56
65
  fontFace: "Noto Sans JP",
57
66
  color: "64748B",
58
67
  align: "center",
@@ -60,9 +69,11 @@ export function renderMatrixNode(node, ctx) {
60
69
  });
61
70
  // === 3. 象限ラベルを描画 ===
62
71
  if (quadrants) {
63
- renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, centerX, centerY);
72
+ renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, centerX, centerY, scaleFactor);
64
73
  }
65
74
  // === 4. アイテムをプロット ===
75
+ const itemLabelW = 100 * scaleFactor;
76
+ const itemLabelH = 18 * scaleFactor;
66
77
  for (const item of items) {
67
78
  // 座標変換: (0,0)=左下, (1,1)=右上
68
79
  // x: 0 -> areaX, 1 -> areaX + areaW
@@ -81,11 +92,11 @@ export function renderMatrixNode(node, ctx) {
81
92
  });
82
93
  // ラベルを描画(円の上)
83
94
  ctx.slide.addText(item.label, {
84
- x: pxToIn(itemX - 50),
85
- y: pxToIn(itemY - itemSize / 2 - 20),
86
- w: pxToIn(100),
87
- h: pxToIn(18),
88
- fontSize: pxToPt(11),
95
+ x: pxToIn(itemX - itemLabelW / 2),
96
+ y: pxToIn(itemY - itemSize / 2 - 20 * scaleFactor),
97
+ w: pxToIn(itemLabelW),
98
+ h: pxToIn(itemLabelH),
99
+ fontSize: pxToPt(11 * scaleFactor),
89
100
  fontFace: "Noto Sans JP",
90
101
  color: "1E293B",
91
102
  bold: true,
@@ -94,15 +105,16 @@ export function renderMatrixNode(node, ctx) {
94
105
  });
95
106
  }
96
107
  }
97
- function renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, centerX, centerY) {
98
- const quadrantFontSize = 11;
108
+ function renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, centerX, centerY, scaleFactor) {
109
+ const quadrantFontSize = 11 * scaleFactor;
99
110
  const quadrantColor = "94A3B8"; // slate-400
100
- const quadrantW = areaW / 2 - 20;
101
- const quadrantH = 48;
111
+ const quadrantInset = 10 * scaleFactor;
112
+ const quadrantW = areaW / 2 - 20 * scaleFactor;
113
+ const quadrantH = 48 * scaleFactor;
102
114
  // 左上
103
115
  ctx.slide.addText(quadrants.topLeft, {
104
- x: pxToIn(areaX + 10),
105
- y: pxToIn(areaY + 10),
116
+ x: pxToIn(areaX + quadrantInset),
117
+ y: pxToIn(areaY + quadrantInset),
106
118
  w: pxToIn(quadrantW),
107
119
  h: pxToIn(quadrantH),
108
120
  fontSize: pxToPt(quadrantFontSize),
@@ -113,8 +125,8 @@ function renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, center
113
125
  });
114
126
  // 右上
115
127
  ctx.slide.addText(quadrants.topRight, {
116
- x: pxToIn(centerX + 10),
117
- y: pxToIn(areaY + 10),
128
+ x: pxToIn(centerX + quadrantInset),
129
+ y: pxToIn(areaY + quadrantInset),
118
130
  w: pxToIn(quadrantW),
119
131
  h: pxToIn(quadrantH),
120
132
  fontSize: pxToPt(quadrantFontSize),
@@ -125,8 +137,8 @@ function renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, center
125
137
  });
126
138
  // 左下
127
139
  ctx.slide.addText(quadrants.bottomLeft, {
128
- x: pxToIn(areaX + 10),
129
- y: pxToIn(centerY + areaH / 2 - quadrantH - 10),
140
+ x: pxToIn(areaX + quadrantInset),
141
+ y: pxToIn(centerY + areaH / 2 - quadrantH - quadrantInset),
130
142
  w: pxToIn(quadrantW),
131
143
  h: pxToIn(quadrantH),
132
144
  fontSize: pxToPt(quadrantFontSize),
@@ -137,8 +149,8 @@ function renderQuadrantLabels(ctx, quadrants, areaX, areaY, areaW, areaH, center
137
149
  });
138
150
  // 右下
139
151
  ctx.slide.addText(quadrants.bottomRight, {
140
- x: pxToIn(centerX + 10),
141
- y: pxToIn(centerY + areaH / 2 - quadrantH - 10),
152
+ x: pxToIn(centerX + quadrantInset),
153
+ y: pxToIn(centerY + areaH / 2 - quadrantH - quadrantInset),
142
154
  w: pxToIn(quadrantW),
143
155
  h: pxToIn(quadrantH),
144
156
  fontSize: pxToPt(quadrantFontSize),
@@ -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;AAIjD,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,CAsCN"}
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;AAMjD,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,CAsDN"}
@@ -1,5 +1,7 @@
1
1
  import { pxToIn, pxToPt } from "../units.js";
2
2
  import { convertUnderline, convertStrike } from "../textOptions.js";
3
+ import { measureProcessArrow } from "../../calcYogaLayout/measureCompositeNodes.js";
4
+ import { calcScaleFactor } from "../utils/scaleToFit.js";
3
5
  export function renderProcessArrowNode(node, ctx) {
4
6
  const direction = node.direction ?? "horizontal";
5
7
  const steps = node.steps;
@@ -11,14 +13,20 @@ export function renderProcessArrowNode(node, ctx) {
11
13
  const itemWidth = node.itemWidth ?? 150;
12
14
  const itemHeight = node.itemHeight ?? 60;
13
15
  const gap = node.gap ?? -15; // 負の値でシェブロンを重ねる
16
+ // スケール係数を計算
17
+ const intrinsic = measureProcessArrow(node);
18
+ const scaleFactor = calcScaleFactor(node.w, node.h, intrinsic.width, intrinsic.height, "processArrow");
19
+ const scaledItemWidth = itemWidth * scaleFactor;
20
+ const scaledItemHeight = itemHeight * scaleFactor;
21
+ const scaledGap = gap * scaleFactor;
14
22
  if (direction === "horizontal") {
15
- renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, defaultColor, defaultTextColor);
23
+ renderHorizontalProcessArrow(node, ctx, steps, stepCount, scaledItemWidth, scaledItemHeight, scaledGap, defaultColor, defaultTextColor, scaleFactor);
16
24
  }
17
25
  else {
18
- renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, defaultColor, defaultTextColor);
26
+ renderVerticalProcessArrow(node, ctx, steps, stepCount, scaledItemWidth, scaledItemHeight, scaledGap, defaultColor, defaultTextColor, scaleFactor);
19
27
  }
20
28
  }
21
- function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, defaultColor, defaultTextColor) {
29
+ function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, defaultColor, defaultTextColor, scaleFactor) {
22
30
  const totalWidth = stepCount * itemWidth + (stepCount - 1) * gap;
23
31
  const startX = node.x + (node.w - totalWidth) / 2;
24
32
  const centerY = node.y + node.h / 2;
@@ -37,7 +45,7 @@ function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, it
37
45
  shape: shapeType,
38
46
  fill: { color: fillColor },
39
47
  line: { type: "none" },
40
- fontSize: pxToPt(node.fontPx ?? 14),
48
+ fontSize: pxToPt((node.fontPx ?? 14) * scaleFactor),
41
49
  fontFace: "Noto Sans JP",
42
50
  color: textColor,
43
51
  bold: node.bold ?? false,
@@ -50,7 +58,7 @@ function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, it
50
58
  });
51
59
  });
52
60
  }
53
- function renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, defaultColor, defaultTextColor) {
61
+ function renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, itemHeight, gap, defaultColor, defaultTextColor, scaleFactor) {
54
62
  const totalHeight = stepCount * itemHeight + (stepCount - 1) * gap;
55
63
  const startY = node.y + (node.h - totalHeight) / 2;
56
64
  const centerX = node.x + node.w / 2;
@@ -69,7 +77,7 @@ function renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, item
69
77
  shape: shapeType,
70
78
  fill: { color: fillColor },
71
79
  line: { type: "none" },
72
- fontSize: pxToPt(node.fontPx ?? 14),
80
+ fontSize: pxToPt((node.fontPx ?? 14) * scaleFactor),
73
81
  fontFace: "Noto Sans JP",
74
82
  color: textColor,
75
83
  bold: node.bold ?? false,
@@ -36,7 +36,7 @@ export function renderShapeNode(node, ctx) {
36
36
  ...shapeOptions,
37
37
  shape: node.shapeType,
38
38
  fontSize: pxToPt(node.fontPx ?? 24),
39
- fontFace: "Noto Sans JP",
39
+ fontFace: node.fontFamily ?? "Noto Sans JP",
40
40
  color: node.color,
41
41
  bold: node.bold,
42
42
  italic: node.italic,
@@ -45,7 +45,7 @@ export function renderShapeNode(node, ctx) {
45
45
  highlight: node.highlight,
46
46
  align: node.alignText ?? "center",
47
47
  valign: "middle",
48
- lineSpacingMultiple: 1.3,
48
+ lineSpacingMultiple: node.lineSpacingMultiple ?? 1.3,
49
49
  });
50
50
  }
51
51
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,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,CAmCN"}
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,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,CAmCN"}
@@ -1,4 +1,4 @@
1
- import { resolveColumnWidths, resolveRowHeights } from "../../table/utils.js";
1
+ import { resolveColumnWidths, resolveRowHeights, } from "../../shared/tableUtils.js";
2
2
  import { pxToIn, pxToPt } from "../units.js";
3
3
  import { convertUnderline, convertStrike } from "../textOptions.js";
4
4
  export function renderTableNode(node, ctx) {
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,KAAK,sBAAsB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE5E,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,sBAAsB,EAC5B,GAAG,EAAE,aAAa,GACjB,IAAI,CA8BN"}
1
+ {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,KAAK,sBAAsB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE5E,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,sBAAsB,EAC5B,GAAG,EAAE,aAAa,GACjB,IAAI,CA6CN"}