@hirokisakabe/pom 5.1.0 → 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.
@@ -5,7 +5,7 @@
5
5
  * Used by `parseXml` to validate parsed XML input.
6
6
  */
7
7
  import { z } from "zod";
8
- import { lengthSchema, paddingSchema, borderStyleSchema, borderDashSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, chartTypeSchema, chartDataSchema, liNodeSchema, radarStyleSchema, bulletNumberTypeSchema, timelineDirectionSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, treeLayoutSchema, treeNodeShapeSchema, treeConnectorStyleSchema, flowDirectionSchema, flowNodeItemSchema, flowConnectionSchema, flowConnectorStyleSchema, processArrowDirectionSchema, processArrowStepSchema, pyramidDirectionSchema, pyramidLevelSchema, lineArrowSchema, underlineSchema, backgroundImageSchema, iconNameSchema, iconColorSchema, } from "../types.js";
8
+ import { lengthSchema, paddingSchema, borderStyleSchema, borderDashSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, chartTypeSchema, chartDataSchema, liNodeSchema, radarStyleSchema, bulletNumberTypeSchema, timelineDirectionSchema, timelineItemSchema, matrixAxisSchema, matrixQuadrantsSchema, matrixItemSchema, treeLayoutSchema, treeNodeShapeSchema, treeConnectorStyleSchema, flowDirectionSchema, flowNodeItemSchema, flowConnectionSchema, flowConnectorStyleSchema, processArrowDirectionSchema, processArrowStepSchema, pyramidDirectionSchema, pyramidLevelSchema, lineArrowSchema, underlineSchema, backgroundImageSchema, iconNameSchema, iconColorSchema, alignSelfSchema, positionTypeSchema, flexWrapSchema, } from "../types.js";
9
9
  // ===== Base Node Schema =====
10
10
  export const inputBaseNodeSchema = z.object({
11
11
  w: lengthSchema.optional(),
@@ -15,11 +15,19 @@ export const inputBaseNodeSchema = z.object({
15
15
  minH: z.number().optional(),
16
16
  maxH: z.number().optional(),
17
17
  padding: paddingSchema.optional(),
18
+ margin: paddingSchema.optional(),
18
19
  backgroundColor: z.string().optional(),
19
20
  backgroundImage: backgroundImageSchema.optional(),
20
21
  border: borderStyleSchema.optional(),
21
22
  borderRadius: z.number().optional(),
22
23
  opacity: z.number().min(0).max(1).optional(),
24
+ zIndex: z.number().optional(),
25
+ position: positionTypeSchema.optional(),
26
+ top: z.number().optional(),
27
+ right: z.number().optional(),
28
+ bottom: z.number().optional(),
29
+ left: z.number().optional(),
30
+ alignSelf: alignSelfSchema.optional(),
23
31
  });
24
32
  // ===== Node Schemas =====
25
33
  export const inputTextNodeSchema = inputBaseNodeSchema.extend({
@@ -204,6 +212,7 @@ const inputVStackNodeSchemaBase = inputBaseNodeSchema.extend({
204
212
  alignItems: alignItemsSchema.optional(),
205
213
  justifyContent: justifyContentSchema.optional(),
206
214
  shadow: shadowStyleSchema.optional(),
215
+ flexWrap: flexWrapSchema.optional(),
207
216
  });
208
217
  const inputHStackNodeSchemaBase = inputBaseNodeSchema.extend({
209
218
  type: z.literal("hstack"),
@@ -212,6 +221,7 @@ const inputHStackNodeSchemaBase = inputBaseNodeSchema.extend({
212
221
  alignItems: alignItemsSchema.optional(),
213
222
  justifyContent: justifyContentSchema.optional(),
214
223
  shadow: shadowStyleSchema.optional(),
224
+ flexWrap: flexWrapSchema.optional(),
215
225
  });
216
226
  const inputLayerChildSchemaBase = z.lazy(() => inputPomNodeSchema.and(z.object({
217
227
  x: z.number(),
@@ -1 +1 @@
1
- {"version":3,"file":"parseXml.d.ts","sourceRoot":"","sources":["../../src/parseXml/parseXml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAsC3C,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAC;gBACrB,MAAM,EAAE,MAAM,EAAE;CAM7B;AA2qCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,CAiCrD"}
1
+ {"version":3,"file":"parseXml.d.ts","sourceRoot":"","sources":["../../src/parseXml/parseXml.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAuC3C,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,MAAM,EAAE,MAAM,EAAE,CAAC;gBACrB,MAAM,EAAE,MAAM,EAAE;CAM7B;AA6qCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE,CAiCrD"}
@@ -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;
@@ -63,12 +63,14 @@ const containerShapes = {
63
63
  alignItems: alignItemsSchema.optional(),
64
64
  justifyContent: justifyContentSchema.optional(),
65
65
  shadow: shadowStyleSchema.optional(),
66
+ flexWrap: flexWrapSchema.optional(),
66
67
  })),
67
68
  hstack: extractShape(inputBaseNodeSchema.extend({
68
69
  gap: z.number().optional(),
69
70
  alignItems: alignItemsSchema.optional(),
70
71
  justifyContent: justifyContentSchema.optional(),
71
72
  shadow: shadowStyleSchema.optional(),
73
+ flexWrap: flexWrapSchema.optional(),
72
74
  })),
73
75
  layer: extractShape(inputBaseNodeSchema),
74
76
  };
@@ -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;AAqJxC;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,cAAc,EAAE,EACvB,OAAO,EAAE,OAAO,EAChB,MAAM,CAAC,EAAE,kBAAkB,+BAqL5B"}
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
- // layer の子要素を配列順に描画(後の要素が上に来る)
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;