@hirokisakabe/pom 5.0.1 → 5.2.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 +17 -0
- package/dist/autoFit/autoFit.d.ts +15 -0
- package/dist/autoFit/autoFit.d.ts.map +1 -0
- package/dist/autoFit/autoFit.js +73 -0
- package/dist/autoFit/freeYogaTree.d.ts +7 -0
- package/dist/autoFit/freeYogaTree.d.ts.map +1 -0
- package/dist/autoFit/freeYogaTree.js +29 -0
- package/dist/autoFit/strategies/reduceFontSize.d.ts +8 -0
- package/dist/autoFit/strategies/reduceFontSize.d.ts.map +1 -0
- package/dist/autoFit/strategies/reduceFontSize.js +56 -0
- package/dist/autoFit/strategies/reduceGapAndPadding.d.ts +7 -0
- package/dist/autoFit/strategies/reduceGapAndPadding.d.ts.map +1 -0
- package/dist/autoFit/strategies/reduceGapAndPadding.js +46 -0
- package/dist/autoFit/strategies/reduceTableRowHeight.d.ts +7 -0
- package/dist/autoFit/strategies/reduceTableRowHeight.d.ts.map +1 -0
- package/dist/autoFit/strategies/reduceTableRowHeight.js +32 -0
- package/dist/autoFit/strategies/uniformScale.d.ts +7 -0
- package/dist/autoFit/strategies/uniformScale.d.ts.map +1 -0
- package/dist/autoFit/strategies/uniformScale.js +108 -0
- package/dist/autoFit/walkTree.d.ts +6 -0
- package/dist/autoFit/walkTree.d.ts.map +1 -0
- package/dist/autoFit/walkTree.js +18 -0
- package/dist/buildPptx.d.ts +1 -0
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +7 -1
- package/dist/calcYogaLayout/calcYogaLayout.js +77 -0
- package/dist/parseXml/inputSchema.d.ts +352 -0
- package/dist/parseXml/inputSchema.d.ts.map +1 -1
- package/dist/parseXml/inputSchema.js +13 -1
- package/dist/parseXml/parseXml.d.ts.map +1 -1
- package/dist/parseXml/parseXml.js +38 -1
- package/dist/renderPptx/renderPptx.d.ts.map +1 -1
- package/dist/renderPptx/renderPptx.js +14 -4
- package/dist/types.d.ts +373 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +21 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XMLParser } from "fast-xml-parser";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { inputTextNodeSchema, inputUlNodeSchema, inputOlNodeSchema, inputLiNodeSchema, inputImageNodeSchema, inputTableNodeSchema, inputShapeNodeSchema, inputChartNodeSchema, inputTimelineNodeSchema, inputMatrixNodeSchema, inputTreeNodeSchema, inputFlowNodeSchema, inputProcessArrowNodeSchema, inputPyramidNodeSchema, inputLineNodeSchema, inputIconNodeSchema, inputBaseNodeSchema, } from "./inputSchema.js";
|
|
4
|
-
import { alignItemsSchema, justifyContentSchema, shadowStyleSchema, processArrowStepSchema, pyramidLevelSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, flowNodeItemSchema, flowConnectionSchema, chartDataSchema, tableColumnSchema, tableCellSchema, } from "../types.js";
|
|
4
|
+
import { alignItemsSchema, justifyContentSchema, shadowStyleSchema, processArrowStepSchema, pyramidLevelSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, flowNodeItemSchema, flowConnectionSchema, chartDataSchema, tableColumnSchema, tableCellSchema, flexWrapSchema, } from "../types.js";
|
|
5
5
|
// ===== ParseXmlError =====
|
|
6
6
|
export class ParseXmlError extends Error {
|
|
7
7
|
errors;
|
|
@@ -62,11 +62,15 @@ const containerShapes = {
|
|
|
62
62
|
gap: z.number().optional(),
|
|
63
63
|
alignItems: alignItemsSchema.optional(),
|
|
64
64
|
justifyContent: justifyContentSchema.optional(),
|
|
65
|
+
shadow: shadowStyleSchema.optional(),
|
|
66
|
+
flexWrap: flexWrapSchema.optional(),
|
|
65
67
|
})),
|
|
66
68
|
hstack: extractShape(inputBaseNodeSchema.extend({
|
|
67
69
|
gap: z.number().optional(),
|
|
68
70
|
alignItems: alignItemsSchema.optional(),
|
|
69
71
|
justifyContent: justifyContentSchema.optional(),
|
|
72
|
+
shadow: shadowStyleSchema.optional(),
|
|
73
|
+
flexWrap: flexWrapSchema.optional(),
|
|
70
74
|
})),
|
|
71
75
|
layer: extractShape(inputBaseNodeSchema),
|
|
72
76
|
};
|
|
@@ -371,6 +375,21 @@ function coerceFallback(value) {
|
|
|
371
375
|
}
|
|
372
376
|
return value;
|
|
373
377
|
}
|
|
378
|
+
// ===== Dot notation helpers =====
|
|
379
|
+
/**
|
|
380
|
+
* Checks if a schema is a union containing both boolean and object types.
|
|
381
|
+
* Used to allow `endArrow="true" endArrow.type="triangle"` coexistence.
|
|
382
|
+
*/
|
|
383
|
+
function isBooleanObjectUnion(schema) {
|
|
384
|
+
const unwrapped = unwrapSchema(schema);
|
|
385
|
+
const typeName = getZodType(unwrapped);
|
|
386
|
+
if (typeName !== "union")
|
|
387
|
+
return false;
|
|
388
|
+
const def = getDef(unwrapped);
|
|
389
|
+
const options = def.options;
|
|
390
|
+
const typeNames = options.map((opt) => getZodType(unwrapSchema(opt)));
|
|
391
|
+
return typeNames.includes("boolean") && typeNames.includes("object");
|
|
392
|
+
}
|
|
374
393
|
// ===== Dot notation expansion =====
|
|
375
394
|
function expandDotNotation(attrs) {
|
|
376
395
|
const regular = {};
|
|
@@ -510,6 +529,15 @@ function coerceChildAttrs(parentTagName, tagName, attrs, errors) {
|
|
|
510
529
|
// Process regular attributes
|
|
511
530
|
for (const [key, value] of Object.entries(regularAttrs)) {
|
|
512
531
|
if (key in dotGroups) {
|
|
532
|
+
// When the schema is a union of boolean and object,
|
|
533
|
+
// allow boolean shorthand to coexist with dot-notation by ignoring the boolean value.
|
|
534
|
+
if (shape &&
|
|
535
|
+
shape[key] &&
|
|
536
|
+
isBooleanObjectUnion(shape[key]) &&
|
|
537
|
+
(value === "true" || value === "false")) {
|
|
538
|
+
// Silently skip the boolean value; dot-notation takes priority
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
513
541
|
errors.push(`<${parentTagName}>.<${tagName}>: Attribute "${key}" conflicts with dot-notation attributes. Use one or the other, not both`);
|
|
514
542
|
continue;
|
|
515
543
|
}
|
|
@@ -832,6 +860,15 @@ function convertPomNode(nodeType, tagName, attrs, childElements, textContent, er
|
|
|
832
860
|
continue;
|
|
833
861
|
// Conflict check: dot-notation and regular attribute for the same key
|
|
834
862
|
if (key in dotGroups) {
|
|
863
|
+
// When the schema is a union of boolean and object (e.g., endArrow),
|
|
864
|
+
// allow boolean shorthand to coexist with dot-notation by ignoring the boolean value.
|
|
865
|
+
const propSchemaForConflict = getPropertySchema(nodeType, key);
|
|
866
|
+
if (propSchemaForConflict &&
|
|
867
|
+
isBooleanObjectUnion(propSchemaForConflict) &&
|
|
868
|
+
(value === "true" || value === "false")) {
|
|
869
|
+
// Silently skip the boolean value; dot-notation takes priority
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
835
872
|
errors.push(`<${tagName}>: Attribute "${key}" conflicts with dot-notation attributes (e.g., "${key}.xxx"). Use one or the other, not both`);
|
|
836
873
|
continue;
|
|
837
874
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderPptx.d.ts","sourceRoot":"","sources":["../../src/renderPptx/renderPptx.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAwBrB,KAAK,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"renderPptx.d.ts","sourceRoot":"","sources":["../../src/renderPptx/renderPptx.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAwBrB,KAAK,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA+JxC;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,kBAAkB,+BAqL5B"}
|
|
@@ -11,6 +11,16 @@ import { getImageData } from "../shared/measureImage.js";
|
|
|
11
11
|
import { renderBackgroundAndBorder } from "./utils/backgroundBorder.js";
|
|
12
12
|
import { renderTextNode, renderImageNode, renderTableNode, renderShapeNode, renderChartNode, renderTimelineNode, renderMatrixNode, renderTreeNode, renderFlowNode, renderProcessArrowNode, renderPyramidNode, renderLineNode, renderUlNode, renderOlNode, renderIconNode, } from "./nodes/index.js";
|
|
13
13
|
const DEFAULT_MASTER_NAME = "POM_MASTER";
|
|
14
|
+
/**
|
|
15
|
+
* zIndex でソートして描画順を制御する(安定ソート)
|
|
16
|
+
* zIndex が小さいノードが先に描画される(PowerPoint は追加順に重ねるため)
|
|
17
|
+
*/
|
|
18
|
+
function sortByZIndex(children) {
|
|
19
|
+
// すべての子要素に zIndex が未設定の場合はそのまま返す
|
|
20
|
+
if (children.every((c) => c.zIndex === undefined))
|
|
21
|
+
return children;
|
|
22
|
+
return [...children].sort((a, b) => (a.zIndex ?? 0) - (b.zIndex ?? 0));
|
|
23
|
+
}
|
|
14
24
|
/**
|
|
15
25
|
* MasterObject を pptxgenjs の objects 形式に変換する
|
|
16
26
|
*/
|
|
@@ -256,8 +266,8 @@ export function renderPptx(pages, slidePx, master) {
|
|
|
256
266
|
break;
|
|
257
267
|
case "vstack":
|
|
258
268
|
case "hstack":
|
|
259
|
-
//
|
|
260
|
-
for (const child of node.children) {
|
|
269
|
+
// zIndex でソートして描画順を制御(値が小さいものが先に描画される)
|
|
270
|
+
for (const child of sortByZIndex(node.children)) {
|
|
261
271
|
renderNode(child);
|
|
262
272
|
}
|
|
263
273
|
break;
|
|
@@ -292,8 +302,8 @@ export function renderPptx(pages, slidePx, master) {
|
|
|
292
302
|
renderLineNode(node, ctx);
|
|
293
303
|
break;
|
|
294
304
|
case "layer":
|
|
295
|
-
//
|
|
296
|
-
for (const child of node.children) {
|
|
305
|
+
// zIndex でソートして描画順を制御(値が小さいものが先に描画される)
|
|
306
|
+
for (const child of sortByZIndex(node.children)) {
|
|
297
307
|
renderNode(child);
|
|
298
308
|
}
|
|
299
309
|
break;
|