@hirokisakabe/pom 5.4.0 → 5.5.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 +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 +29 -15
- 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/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 +8 -6
- 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 +6 -4
- 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.map +1 -1
- package/dist/renderPptx/textOptions.js +6 -4
- 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 +5 -2
- 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,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),
|
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,10 +1,12 @@
|
|
|
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
12
|
type: node.shadow.type,
|
|
@@ -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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "../units.js";
|
|
2
2
|
import { measurePyramid } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
3
3
|
import { calcScaleFactor } from "../utils/scaleToFit.js";
|
|
4
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
4
5
|
export function renderPyramidNode(node, ctx) {
|
|
5
6
|
const direction = node.direction ?? "up";
|
|
6
7
|
const levels = node.levels;
|
|
@@ -9,15 +10,16 @@ export function renderPyramidNode(node, ctx) {
|
|
|
9
10
|
return;
|
|
10
11
|
const defaultColor = "4472C4";
|
|
11
12
|
const defaultTextColor = "FFFFFF";
|
|
12
|
-
//
|
|
13
|
+
// スケール係数を計算(コンテンツ領域基準)
|
|
14
|
+
const content = getContentArea(node);
|
|
13
15
|
const intrinsic = measurePyramid(node);
|
|
14
|
-
const scaleFactor = calcScaleFactor(
|
|
16
|
+
const scaleFactor = calcScaleFactor(content.w, content.h, intrinsic.width, intrinsic.height, "pyramid", ctx.buildContext.diagnostics);
|
|
15
17
|
const baseWidth = 400 * scaleFactor;
|
|
16
18
|
const layerHeight = 50 * scaleFactor;
|
|
17
19
|
const gap = 2 * scaleFactor;
|
|
18
20
|
const totalHeight = levelCount * layerHeight + (levelCount - 1) * gap;
|
|
19
|
-
const startX =
|
|
20
|
-
const startY =
|
|
21
|
+
const startX = content.x + (content.w - baseWidth) / 2;
|
|
22
|
+
const startY = content.y + (content.h - totalHeight) / 2;
|
|
21
23
|
for (let i = 0; i < levelCount; i++) {
|
|
22
24
|
const level = levels[i];
|
|
23
25
|
const fillColor = level.color?.replace("#", "") ?? defaultColor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/shape.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":"shape.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/shape.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,CAsDN"}
|
|
@@ -1,11 +1,13 @@
|
|
|
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
|
export function renderShapeNode(node, ctx) {
|
|
5
|
+
const content = getContentArea(node);
|
|
4
6
|
const shapeOptions = {
|
|
5
|
-
x: pxToIn(
|
|
6
|
-
y: pxToIn(
|
|
7
|
-
w: pxToIn(
|
|
8
|
-
h: pxToIn(
|
|
7
|
+
x: pxToIn(content.x),
|
|
8
|
+
y: pxToIn(content.y),
|
|
9
|
+
w: pxToIn(content.w),
|
|
10
|
+
h: pxToIn(content.h),
|
|
9
11
|
fill: node.fill
|
|
10
12
|
? {
|
|
11
13
|
color: node.fill.color,
|
|
@@ -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;
|
|
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;AASjD,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,CAsCN"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
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
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
4
5
|
export function renderTableNode(node, ctx) {
|
|
5
6
|
const tableRows = node.rows.map((row) => row.cells.map((cell) => {
|
|
6
7
|
const cellOptions = {
|
|
@@ -23,12 +24,13 @@ export function renderTableNode(node, ctx) {
|
|
|
23
24
|
options: cellOptions,
|
|
24
25
|
};
|
|
25
26
|
}));
|
|
27
|
+
const content = getContentArea(node);
|
|
26
28
|
const tableOptions = {
|
|
27
|
-
x: pxToIn(
|
|
28
|
-
y: pxToIn(
|
|
29
|
-
w: pxToIn(
|
|
30
|
-
h: pxToIn(
|
|
31
|
-
colW: resolveColumnWidths(node,
|
|
29
|
+
x: pxToIn(content.x),
|
|
30
|
+
y: pxToIn(content.y),
|
|
31
|
+
w: pxToIn(content.w),
|
|
32
|
+
h: pxToIn(content.h),
|
|
33
|
+
colW: resolveColumnWidths(node, content.w).map((width) => pxToIn(width)),
|
|
32
34
|
rowH: resolveRowHeights(node).map((height) => pxToIn(height)),
|
|
33
35
|
margin: 0,
|
|
34
36
|
};
|
|
@@ -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;
|
|
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;AAMjD,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,CAwDN"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "../units.js";
|
|
2
2
|
import { measureTimeline } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
3
3
|
import { calcScaleFactor } from "../utils/scaleToFit.js";
|
|
4
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
4
5
|
export function renderTimelineNode(node, ctx) {
|
|
5
6
|
const direction = node.direction ?? "horizontal";
|
|
6
7
|
const items = node.items;
|
|
@@ -10,16 +11,25 @@ export function renderTimelineNode(node, ctx) {
|
|
|
10
11
|
const defaultColor = "1D4ED8"; // blue
|
|
11
12
|
const baseNodeRadius = 12; // px
|
|
12
13
|
const baseLineWidth = 4; // px
|
|
13
|
-
//
|
|
14
|
+
// スケール係数を計算(コンテンツ領域基準)
|
|
15
|
+
const content = getContentArea(node);
|
|
14
16
|
const intrinsic = measureTimeline(node);
|
|
15
|
-
const scaleFactor = calcScaleFactor(
|
|
17
|
+
const scaleFactor = calcScaleFactor(content.w, content.h, intrinsic.width, intrinsic.height, "timeline", ctx.buildContext.diagnostics);
|
|
16
18
|
const nodeRadius = baseNodeRadius * scaleFactor;
|
|
17
19
|
const lineWidth = baseLineWidth * scaleFactor;
|
|
20
|
+
// コンテンツ領域を使用するための仮想ノードを作成
|
|
21
|
+
const contentNode = {
|
|
22
|
+
...node,
|
|
23
|
+
x: content.x,
|
|
24
|
+
y: content.y,
|
|
25
|
+
w: content.w,
|
|
26
|
+
h: content.h,
|
|
27
|
+
};
|
|
18
28
|
if (direction === "horizontal") {
|
|
19
|
-
renderHorizontalTimeline(
|
|
29
|
+
renderHorizontalTimeline(contentNode, ctx, items, defaultColor, nodeRadius, lineWidth, scaleFactor);
|
|
20
30
|
}
|
|
21
31
|
else {
|
|
22
|
-
renderVerticalTimeline(
|
|
32
|
+
renderVerticalTimeline(contentNode, ctx, items, defaultColor, nodeRadius, lineWidth, scaleFactor);
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
function renderHorizontalTimeline(node, ctx, items, defaultColor, nodeRadius, lineWidth, scaleFactor) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/nodes/tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,gBAAgB,CAAC;AACxB,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,CA0SN"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "../units.js";
|
|
2
2
|
import { calcScaleFactor } from "../utils/scaleToFit.js";
|
|
3
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
3
4
|
export function renderTreeNode(node, ctx) {
|
|
4
5
|
const layout = node.layout ?? "vertical";
|
|
5
6
|
const nodeShape = node.nodeShape ?? "rect";
|
|
@@ -217,13 +218,14 @@ export function renderTreeNode(node, ctx) {
|
|
|
217
218
|
}
|
|
218
219
|
// ツリーのサイズを計算
|
|
219
220
|
const treeSize = calculateSubtreeSize(node.data);
|
|
220
|
-
//
|
|
221
|
-
const
|
|
221
|
+
// スケール係数を計算(コンテンツ領域基準)
|
|
222
|
+
const content = getContentArea(node);
|
|
223
|
+
const scaleFactor = calcScaleFactor(content.w, content.h, treeSize.width, treeSize.height, "tree", ctx.buildContext.diagnostics);
|
|
222
224
|
// スケール後のサイズで中央配置オフセットを計算
|
|
223
225
|
const scaledW = treeSize.width * scaleFactor;
|
|
224
226
|
const scaledH = treeSize.height * scaleFactor;
|
|
225
|
-
const offsetX =
|
|
226
|
-
const offsetY =
|
|
227
|
+
const offsetX = content.x + (content.w - scaledW) / 2;
|
|
228
|
+
const offsetY = content.y + (content.h - scaledH) / 2;
|
|
227
229
|
// レイアウト計算(原点(0,0)からの相対座標)
|
|
228
230
|
const rootLayout = calculateTreeLayout(node.data, 0, 0);
|
|
229
231
|
// 描画(接続線を先に、ノードを後に描画)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textOptions.d.ts","sourceRoot":"","sources":["../../src/renderPptx/textOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"textOptions.d.ts","sourceRoot":"","sources":["../../src/renderPptx/textOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAI7E,KAAK,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE1D;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,GAAG,SAAS,GAC/B;IAAE,KAAK,CAAC,EAAE,cAAc,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAQxD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,GAC1B,WAAW,GAAG,SAAS,CAGzB;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ;;;;;;;;;;;;;;;gBApBnC,cAAc;gBAAU,MAAM;;;;EA4C1C"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { pxToIn, pxToPt } from "./units.js";
|
|
2
|
+
import { getContentArea } from "./utils/contentArea.js";
|
|
2
3
|
/**
|
|
3
4
|
* underline プロパティを pptxgenjs 形式に変換する
|
|
4
5
|
*/
|
|
@@ -26,11 +27,12 @@ export function createTextOptions(node) {
|
|
|
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
|
return {
|
|
30
|
-
x: pxToIn(
|
|
31
|
-
y: pxToIn(
|
|
32
|
-
w: pxToIn(
|
|
33
|
-
h: pxToIn(
|
|
32
|
+
x: pxToIn(content.x),
|
|
33
|
+
y: pxToIn(content.y),
|
|
34
|
+
w: pxToIn(content.w),
|
|
35
|
+
h: pxToIn(content.h),
|
|
34
36
|
fontSize: pxToPt(fontSizePx),
|
|
35
37
|
fontFace: fontFamily,
|
|
36
38
|
align: node.textAlign ?? "left",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type Padding = number | {
|
|
2
|
+
top?: number;
|
|
3
|
+
right?: number;
|
|
4
|
+
bottom?: number;
|
|
5
|
+
left?: number;
|
|
6
|
+
};
|
|
7
|
+
interface ContentArea {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
w: number;
|
|
11
|
+
h: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* ノードの padding を考慮したコンテンツ描画領域を計算する。
|
|
15
|
+
* background/border はノード全体の領域 (node.x/y/w/h) に描画し、
|
|
16
|
+
* コンテンツはこの関数で返される領域に描画する。
|
|
17
|
+
*/
|
|
18
|
+
export declare function getContentArea(node: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
w: number;
|
|
22
|
+
h: number;
|
|
23
|
+
padding?: Padding;
|
|
24
|
+
}): ContentArea;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=contentArea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contentArea.d.ts","sourceRoot":"","sources":["../../../src/renderPptx/utils/contentArea.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GACR,MAAM,GACN;IACE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,UAAU,WAAW;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,WAAW,CAsBd"}
|