@hirokisakabe/pom 2.0.0 → 4.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.
- package/README.md +171 -38
- package/dist/buildPptx.js +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.d.ts.map +1 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +121 -20
- package/dist/calcYogaLayout/fontLoader.d.ts +16 -0
- package/dist/calcYogaLayout/fontLoader.d.ts.map +1 -1
- package/dist/calcYogaLayout/fontLoader.js +28 -0
- package/dist/calcYogaLayout/measureCompositeNodes.d.ts +13 -1
- package/dist/calcYogaLayout/measureCompositeNodes.d.ts.map +1 -1
- package/dist/calcYogaLayout/measureCompositeNodes.js +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{inputSchema.d.ts → parseXml/inputSchema.d.ts} +305 -24
- package/dist/parseXml/inputSchema.d.ts.map +1 -0
- package/dist/{inputSchema.js → parseXml/inputSchema.js} +44 -2
- package/dist/{parseXml.d.ts → parseXml/parseXml.d.ts} +1 -1
- package/dist/parseXml/parseXml.d.ts.map +1 -0
- package/dist/{parseXml.js → parseXml/parseXml.js} +76 -30
- package/dist/renderPptx/nodes/flow.d.ts.map +1 -1
- package/dist/renderPptx/nodes/flow.js +26 -16
- package/dist/renderPptx/nodes/index.d.ts +2 -0
- package/dist/renderPptx/nodes/index.d.ts.map +1 -1
- package/dist/renderPptx/nodes/index.js +2 -0
- package/dist/renderPptx/nodes/list.d.ts +12 -0
- package/dist/renderPptx/nodes/list.d.ts.map +1 -0
- package/dist/renderPptx/nodes/list.js +145 -0
- package/dist/renderPptx/nodes/matrix.d.ts.map +1 -1
- package/dist/renderPptx/nodes/matrix.js +43 -31
- package/dist/renderPptx/nodes/processArrow.d.ts.map +1 -1
- package/dist/renderPptx/nodes/processArrow.js +14 -6
- package/dist/renderPptx/nodes/pyramid.d.ts +8 -0
- package/dist/renderPptx/nodes/pyramid.d.ts.map +1 -0
- package/dist/renderPptx/nodes/pyramid.js +81 -0
- package/dist/renderPptx/nodes/shape.js +2 -2
- package/dist/renderPptx/nodes/table.d.ts.map +1 -1
- package/dist/renderPptx/nodes/table.js +3 -1
- package/dist/renderPptx/nodes/timeline.d.ts.map +1 -1
- package/dist/renderPptx/nodes/timeline.js +58 -37
- package/dist/renderPptx/nodes/tree.d.ts.map +1 -1
- package/dist/renderPptx/nodes/tree.js +49 -40
- package/dist/renderPptx/renderPptx.d.ts.map +1 -1
- package/dist/renderPptx/renderPptx.js +11 -2
- package/dist/renderPptx/textOptions.d.ts +1 -28
- package/dist/renderPptx/textOptions.d.ts.map +1 -1
- package/dist/renderPptx/textOptions.js +1 -27
- package/dist/renderPptx/utils/backgroundBorder.js +1 -1
- package/dist/renderPptx/utils/scaleToFit.d.ts +8 -0
- package/dist/renderPptx/utils/scaleToFit.d.ts.map +1 -0
- package/dist/renderPptx/utils/scaleToFit.js +19 -0
- package/dist/shared/measureImage.d.ts.map +1 -0
- package/dist/{table/utils.d.ts → shared/tableUtils.d.ts} +1 -1
- package/dist/shared/tableUtils.d.ts.map +1 -0
- package/dist/toPositioned/toPositioned.d.ts.map +1 -1
- package/dist/toPositioned/toPositioned.js +13 -2
- package/dist/types.d.ts +345 -53
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +66 -8
- package/package.json +1 -1
- package/dist/calcYogaLayout/measureImage.d.ts.map +0 -1
- package/dist/inputSchema.d.ts.map +0 -1
- package/dist/parseXml.d.ts.map +0 -1
- package/dist/table/utils.d.ts.map +0 -1
- /package/dist/{calcYogaLayout → shared}/measureImage.d.ts +0 -0
- /package/dist/{calcYogaLayout → shared}/measureImage.js +0 -0
- /package/dist/{table/utils.js → shared/tableUtils.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XMLParser } from "fast-xml-parser";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { inputTextNodeSchema, inputImageNodeSchema, inputTableNodeSchema, inputShapeNodeSchema, inputChartNodeSchema, inputTimelineNodeSchema, inputMatrixNodeSchema, inputTreeNodeSchema, inputFlowNodeSchema, inputProcessArrowNodeSchema, inputLineNodeSchema, inputBaseNodeSchema, } from "./inputSchema.js";
|
|
4
|
-
import { alignItemsSchema, justifyContentSchema, shadowStyleSchema, processArrowStepSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, flowNodeItemSchema, flowConnectionSchema, chartDataSchema, tableColumnSchema, tableCellSchema, } from "
|
|
3
|
+
import { inputTextNodeSchema, inputUlNodeSchema, inputOlNodeSchema, inputLiNodeSchema, inputImageNodeSchema, inputTableNodeSchema, inputShapeNodeSchema, inputChartNodeSchema, inputTimelineNodeSchema, inputMatrixNodeSchema, inputTreeNodeSchema, inputFlowNodeSchema, inputProcessArrowNodeSchema, inputPyramidNodeSchema, inputLineNodeSchema, inputBaseNodeSchema, } from "./inputSchema.js";
|
|
4
|
+
import { alignItemsSchema, justifyContentSchema, shadowStyleSchema, processArrowStepSchema, pyramidLevelSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, flowNodeItemSchema, flowConnectionSchema, chartDataSchema, tableColumnSchema, tableCellSchema, } from "../types.js";
|
|
5
5
|
// ===== ParseXmlError =====
|
|
6
6
|
export class ParseXmlError extends Error {
|
|
7
7
|
errors;
|
|
@@ -24,6 +24,9 @@ const TAG_TO_TYPE = {
|
|
|
24
24
|
Tree: "tree",
|
|
25
25
|
Flow: "flow",
|
|
26
26
|
ProcessArrow: "processArrow",
|
|
27
|
+
Pyramid: "pyramid",
|
|
28
|
+
Ul: "ul",
|
|
29
|
+
Ol: "ol",
|
|
27
30
|
Line: "line",
|
|
28
31
|
Box: "box",
|
|
29
32
|
VStack: "vstack",
|
|
@@ -46,7 +49,10 @@ const leafNodeShapes = {
|
|
|
46
49
|
tree: extractShape(inputTreeNodeSchema),
|
|
47
50
|
flow: extractShape(inputFlowNodeSchema),
|
|
48
51
|
processArrow: extractShape(inputProcessArrowNodeSchema),
|
|
52
|
+
pyramid: extractShape(inputPyramidNodeSchema),
|
|
49
53
|
line: extractShape(inputLineNodeSchema),
|
|
54
|
+
ul: extractShape(inputUlNodeSchema),
|
|
55
|
+
ol: extractShape(inputOlNodeSchema),
|
|
50
56
|
};
|
|
51
57
|
const containerShapes = {
|
|
52
58
|
box: extractShape(inputBaseNodeSchema.extend({ shadow: shadowStyleSchema.optional() })),
|
|
@@ -122,7 +128,10 @@ const leafNodeValidationSchemas = {
|
|
|
122
128
|
tree: inputTreeNodeSchema,
|
|
123
129
|
flow: inputFlowNodeSchema,
|
|
124
130
|
processArrow: inputProcessArrowNodeSchema,
|
|
131
|
+
pyramid: inputPyramidNodeSchema,
|
|
125
132
|
line: inputLineNodeSchema,
|
|
133
|
+
ul: inputUlNodeSchema,
|
|
134
|
+
ol: inputOlNodeSchema,
|
|
126
135
|
};
|
|
127
136
|
function formatZodIssue(issue, tagName) {
|
|
128
137
|
const path = issue.path;
|
|
@@ -179,7 +188,10 @@ const CHILD_ELEMENT_PROPS = {
|
|
|
179
188
|
timeline: new Set(["items"]),
|
|
180
189
|
matrix: new Set(["axes", "items", "quadrants"]),
|
|
181
190
|
processArrow: new Set(["steps"]),
|
|
191
|
+
pyramid: new Set(["levels"]),
|
|
182
192
|
tree: new Set(["data"]),
|
|
193
|
+
ul: new Set(["items"]),
|
|
194
|
+
ol: new Set(["items"]),
|
|
183
195
|
};
|
|
184
196
|
function validateLeafNode(nodeType, result, errors) {
|
|
185
197
|
const schema = leafNodeValidationSchemas[nodeType];
|
|
@@ -400,15 +412,17 @@ function getTextContent(node) {
|
|
|
400
412
|
}
|
|
401
413
|
// ===== Child element schemas for type coercion =====
|
|
402
414
|
const childElementShapes = {
|
|
403
|
-
|
|
415
|
+
ProcessArrowStep: extractShape(processArrowStepSchema),
|
|
416
|
+
PyramidLevel: extractShape(pyramidLevelSchema),
|
|
404
417
|
TimelineItem: extractShape(timelineItemSchema),
|
|
405
|
-
|
|
406
|
-
|
|
418
|
+
MatrixAxes: extractShape(matrixAxisSchema),
|
|
419
|
+
MatrixQuadrants: extractShape(matrixQuadrantsSchema),
|
|
407
420
|
MatrixItem: extractShape(matrixItemSchema),
|
|
408
421
|
FlowNode: extractShape(flowNodeItemSchema),
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
422
|
+
FlowConnection: extractShape(flowConnectionSchema),
|
|
423
|
+
TableColumn: extractShape(tableColumnSchema),
|
|
424
|
+
TableCell: extractShape(tableCellSchema),
|
|
425
|
+
Li: extractShape(inputLiNodeSchema),
|
|
412
426
|
};
|
|
413
427
|
function coerceChildAttrs(parentTagName, tagName, attrs, errors) {
|
|
414
428
|
const shape = childElementShapes[tagName];
|
|
@@ -439,14 +453,26 @@ function convertProcessArrowChildren(childElements, result, errors) {
|
|
|
439
453
|
const steps = [];
|
|
440
454
|
for (const child of childElements) {
|
|
441
455
|
const tag = getTagName(child);
|
|
442
|
-
if (tag !== "
|
|
443
|
-
errors.push(`Unknown child element <${tag}> inside <ProcessArrow>. Expected: <
|
|
456
|
+
if (tag !== "ProcessArrowStep") {
|
|
457
|
+
errors.push(`Unknown child element <${tag}> inside <ProcessArrow>. Expected: <ProcessArrowStep>`);
|
|
444
458
|
continue;
|
|
445
459
|
}
|
|
446
460
|
steps.push(coerceChildAttrs("ProcessArrow", tag, getAttributes(child), errors));
|
|
447
461
|
}
|
|
448
462
|
result.steps = steps;
|
|
449
463
|
}
|
|
464
|
+
function convertPyramidChildren(childElements, result, errors) {
|
|
465
|
+
const levels = [];
|
|
466
|
+
for (const child of childElements) {
|
|
467
|
+
const tag = getTagName(child);
|
|
468
|
+
if (tag !== "PyramidLevel") {
|
|
469
|
+
errors.push(`Unknown child element <${tag}> inside <Pyramid>. Expected: <PyramidLevel>`);
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
levels.push(coerceChildAttrs("Pyramid", tag, getAttributes(child), errors));
|
|
473
|
+
}
|
|
474
|
+
result.levels = levels;
|
|
475
|
+
}
|
|
450
476
|
function convertTimelineChildren(childElements, result, errors) {
|
|
451
477
|
const items = [];
|
|
452
478
|
for (const child of childElements) {
|
|
@@ -464,17 +490,17 @@ function convertMatrixChildren(childElements, result, errors) {
|
|
|
464
490
|
for (const child of childElements) {
|
|
465
491
|
const tag = getTagName(child);
|
|
466
492
|
switch (tag) {
|
|
467
|
-
case "
|
|
493
|
+
case "MatrixAxes":
|
|
468
494
|
result.axes = coerceChildAttrs("Matrix", tag, getAttributes(child), errors);
|
|
469
495
|
break;
|
|
470
|
-
case "
|
|
496
|
+
case "MatrixQuadrants":
|
|
471
497
|
result.quadrants = coerceChildAttrs("Matrix", tag, getAttributes(child), errors);
|
|
472
498
|
break;
|
|
473
499
|
case "MatrixItem":
|
|
474
500
|
items.push(coerceChildAttrs("Matrix", tag, getAttributes(child), errors));
|
|
475
501
|
break;
|
|
476
502
|
default:
|
|
477
|
-
errors.push(`Unknown child element <${tag}> inside <Matrix>. Expected: <
|
|
503
|
+
errors.push(`Unknown child element <${tag}> inside <Matrix>. Expected: <MatrixAxes>, <MatrixQuadrants>, or <MatrixItem>`);
|
|
478
504
|
}
|
|
479
505
|
}
|
|
480
506
|
if (items.length > 0) {
|
|
@@ -490,11 +516,11 @@ function convertFlowChildren(childElements, result, errors) {
|
|
|
490
516
|
case "FlowNode":
|
|
491
517
|
nodes.push(coerceChildAttrs("Flow", tag, getAttributes(child), errors));
|
|
492
518
|
break;
|
|
493
|
-
case "
|
|
519
|
+
case "FlowConnection":
|
|
494
520
|
connections.push(coerceChildAttrs("Flow", tag, getAttributes(child), errors));
|
|
495
521
|
break;
|
|
496
522
|
default:
|
|
497
|
-
errors.push(`Unknown child element <${tag}> inside <Flow>. Expected: <FlowNode> or <
|
|
523
|
+
errors.push(`Unknown child element <${tag}> inside <Flow>. Expected: <FlowNode> or <FlowConnection>`);
|
|
498
524
|
}
|
|
499
525
|
}
|
|
500
526
|
if (nodes.length > 0) {
|
|
@@ -509,8 +535,8 @@ function convertChartChildren(childElements, result, errors) {
|
|
|
509
535
|
const data = [];
|
|
510
536
|
for (const child of childElements) {
|
|
511
537
|
const tag = getTagName(child);
|
|
512
|
-
if (tag !== "
|
|
513
|
-
errors.push(`Unknown child element <${tag}> inside <Chart>. Expected: <
|
|
538
|
+
if (tag !== "ChartSeries") {
|
|
539
|
+
errors.push(`Unknown child element <${tag}> inside <Chart>. Expected: <ChartSeries>`);
|
|
514
540
|
continue;
|
|
515
541
|
}
|
|
516
542
|
const attrs = getAttributes(child);
|
|
@@ -523,7 +549,7 @@ function convertChartChildren(childElements, result, errors) {
|
|
|
523
549
|
if (nameSchema) {
|
|
524
550
|
const coerced = coerceValue(attrs.name, nameSchema);
|
|
525
551
|
if (coerced.error !== null) {
|
|
526
|
-
errors.push(`<Chart>.<
|
|
552
|
+
errors.push(`<Chart>.<ChartSeries>: ${coerced.error}`);
|
|
527
553
|
}
|
|
528
554
|
else {
|
|
529
555
|
series.name = coerced.value;
|
|
@@ -535,23 +561,23 @@ function convertChartChildren(childElements, result, errors) {
|
|
|
535
561
|
}
|
|
536
562
|
for (const dp of getChildElements(child)) {
|
|
537
563
|
const dpTag = getTagName(dp);
|
|
538
|
-
if (dpTag !== "
|
|
539
|
-
errors.push(`Unknown child element <${dpTag}> inside <
|
|
564
|
+
if (dpTag !== "ChartDataPoint") {
|
|
565
|
+
errors.push(`Unknown child element <${dpTag}> inside <ChartSeries>. Expected: <ChartDataPoint>`);
|
|
540
566
|
continue;
|
|
541
567
|
}
|
|
542
568
|
const dpAttrs = getAttributes(dp);
|
|
543
569
|
if (dpAttrs.label === undefined) {
|
|
544
|
-
errors.push('<
|
|
570
|
+
errors.push('<ChartDataPoint> requires a "label" attribute');
|
|
545
571
|
}
|
|
546
572
|
if (dpAttrs.value === undefined) {
|
|
547
|
-
errors.push('<
|
|
573
|
+
errors.push('<ChartDataPoint> requires a "value" attribute');
|
|
548
574
|
}
|
|
549
575
|
if (dpAttrs.label === undefined || dpAttrs.value === undefined) {
|
|
550
576
|
continue;
|
|
551
577
|
}
|
|
552
578
|
const numValue = Number(dpAttrs.value);
|
|
553
579
|
if (isNaN(numValue)) {
|
|
554
|
-
errors.push(`Cannot convert "${dpAttrs.value}" to number in <
|
|
580
|
+
errors.push(`Cannot convert "${dpAttrs.value}" to number in <ChartDataPoint> "value" attribute`);
|
|
555
581
|
continue;
|
|
556
582
|
}
|
|
557
583
|
series.labels.push(dpAttrs.label);
|
|
@@ -567,19 +593,19 @@ function convertTableChildren(childElements, result, errors) {
|
|
|
567
593
|
for (const child of childElements) {
|
|
568
594
|
const tag = getTagName(child);
|
|
569
595
|
switch (tag) {
|
|
570
|
-
case "
|
|
596
|
+
case "TableColumn":
|
|
571
597
|
columns.push(coerceChildAttrs("Table", tag, getAttributes(child), errors));
|
|
572
598
|
break;
|
|
573
|
-
case "
|
|
599
|
+
case "TableRow": {
|
|
574
600
|
const rowAttrs = getAttributes(child);
|
|
575
601
|
const cells = [];
|
|
576
602
|
for (const cellEl of getChildElements(child)) {
|
|
577
603
|
const cellTag = getTagName(cellEl);
|
|
578
|
-
if (cellTag !== "
|
|
579
|
-
errors.push(`Unknown child element <${cellTag}> inside <
|
|
604
|
+
if (cellTag !== "TableCell") {
|
|
605
|
+
errors.push(`Unknown child element <${cellTag}> inside <TableRow>. Expected: <TableCell>`);
|
|
580
606
|
continue;
|
|
581
607
|
}
|
|
582
|
-
const cellAttrs = coerceChildAttrs("
|
|
608
|
+
const cellAttrs = coerceChildAttrs("TableRow", cellTag, getAttributes(cellEl), errors);
|
|
583
609
|
const cellText = getTextContent(cellEl);
|
|
584
610
|
if (cellText !== undefined && !("text" in cellAttrs)) {
|
|
585
611
|
cellAttrs.text = cellText;
|
|
@@ -590,7 +616,7 @@ function convertTableChildren(childElements, result, errors) {
|
|
|
590
616
|
if (rowAttrs.height !== undefined) {
|
|
591
617
|
const h = Number(rowAttrs.height);
|
|
592
618
|
if (isNaN(h)) {
|
|
593
|
-
errors.push(`Cannot convert "${rowAttrs.height}" to number in <
|
|
619
|
+
errors.push(`Cannot convert "${rowAttrs.height}" to number in <TableRow> "height" attribute`);
|
|
594
620
|
}
|
|
595
621
|
else {
|
|
596
622
|
row.height = h;
|
|
@@ -600,7 +626,7 @@ function convertTableChildren(childElements, result, errors) {
|
|
|
600
626
|
break;
|
|
601
627
|
}
|
|
602
628
|
default:
|
|
603
|
-
errors.push(`Unknown child element <${tag}> inside <Table>. Expected: <
|
|
629
|
+
errors.push(`Unknown child element <${tag}> inside <Table>. Expected: <TableColumn> or <TableRow>`);
|
|
604
630
|
}
|
|
605
631
|
}
|
|
606
632
|
if (columns.length > 0) {
|
|
@@ -650,8 +676,28 @@ function convertTreeChildren(childElements, result, errors) {
|
|
|
650
676
|
}
|
|
651
677
|
result.data = convertTreeItem(child, errors);
|
|
652
678
|
}
|
|
679
|
+
function convertListChildren(parentTag, childElements, result, errors) {
|
|
680
|
+
const items = [];
|
|
681
|
+
for (const child of childElements) {
|
|
682
|
+
const tag = getTagName(child);
|
|
683
|
+
if (tag !== "Li") {
|
|
684
|
+
errors.push(`Unknown child element <${tag}> inside <${parentTag}>. Expected: <Li>`);
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
const attrs = coerceChildAttrs(parentTag, tag, getAttributes(child), errors);
|
|
688
|
+
const textContent = getTextContent(child);
|
|
689
|
+
if (textContent !== undefined && !("text" in attrs)) {
|
|
690
|
+
attrs.text = textContent;
|
|
691
|
+
}
|
|
692
|
+
items.push(attrs);
|
|
693
|
+
}
|
|
694
|
+
result.items = items;
|
|
695
|
+
}
|
|
653
696
|
const CHILD_ELEMENT_CONVERTERS = {
|
|
697
|
+
ul: (childElements, result, errors) => convertListChildren("Ul", childElements, result, errors),
|
|
698
|
+
ol: (childElements, result, errors) => convertListChildren("Ol", childElements, result, errors),
|
|
654
699
|
processArrow: convertProcessArrowChildren,
|
|
700
|
+
pyramid: convertPyramidChildren,
|
|
655
701
|
timeline: convertTimelineChildren,
|
|
656
702
|
matrix: convertMatrixChildren,
|
|
657
703
|
flow: convertFlowChildren,
|
|
@@ -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;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,
|
|
21
|
+
calculateHorizontalLayout(node, layouts, nodeCount, scaledNodeWidth, scaledNodeHeight, scaledNodeGap, scaleFactor);
|
|
14
22
|
}
|
|
15
23
|
else {
|
|
16
|
-
calculateVerticalLayout(node, layouts, nodeCount,
|
|
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 -
|
|
42
|
-
y: pxToIn(labelY -
|
|
43
|
-
w: pxToIn(
|
|
44
|
-
h: pxToIn(
|
|
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,
|
|
@@ -8,5 +8,7 @@ export { renderMatrixNode } from "./matrix.ts";
|
|
|
8
8
|
export { renderTreeNode } from "./tree.ts";
|
|
9
9
|
export { renderFlowNode } from "./flow.ts";
|
|
10
10
|
export { renderProcessArrowNode } from "./processArrow.ts";
|
|
11
|
+
export { renderPyramidNode } from "./pyramid.ts";
|
|
11
12
|
export { renderLineNode } from "./line.ts";
|
|
13
|
+
export { renderUlNode, renderOlNode } from "./list.ts";
|
|
12
14
|
//# 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,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -8,4 +8,6 @@ export { renderMatrixNode } from "./matrix.js";
|
|
|
8
8
|
export { renderTreeNode } from "./tree.js";
|
|
9
9
|
export { renderFlowNode } from "./flow.js";
|
|
10
10
|
export { renderProcessArrowNode } from "./processArrow.js";
|
|
11
|
+
export { renderPyramidNode } from "./pyramid.js";
|
|
11
12
|
export { renderLineNode } from "./line.js";
|
|
13
|
+
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;
|
|
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"}
|