@hirokisakabe/pom 0.1.10 → 0.1.12

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 (37) hide show
  1. package/README.md +198 -177
  2. package/dist/inputSchema.d.ts +14 -0
  3. package/dist/inputSchema.d.ts.map +1 -1
  4. package/dist/inputSchema.js +4 -1
  5. package/dist/parsePptx/convertChart.d.ts +8 -0
  6. package/dist/parsePptx/convertChart.d.ts.map +1 -0
  7. package/dist/parsePptx/convertChart.js +78 -0
  8. package/dist/parsePptx/convertImage.d.ts +8 -0
  9. package/dist/parsePptx/convertImage.d.ts.map +1 -0
  10. package/dist/parsePptx/convertImage.js +13 -0
  11. package/dist/parsePptx/convertShape.d.ts +7 -0
  12. package/dist/parsePptx/convertShape.d.ts.map +1 -0
  13. package/dist/parsePptx/convertShape.js +137 -0
  14. package/dist/parsePptx/convertTable.d.ts +7 -0
  15. package/dist/parsePptx/convertTable.d.ts.map +1 -0
  16. package/dist/parsePptx/convertTable.js +46 -0
  17. package/dist/parsePptx/convertText.d.ts +7 -0
  18. package/dist/parsePptx/convertText.d.ts.map +1 -0
  19. package/dist/parsePptx/convertText.js +32 -0
  20. package/dist/parsePptx/index.d.ts +23 -0
  21. package/dist/parsePptx/index.d.ts.map +1 -0
  22. package/dist/parsePptx/index.js +114 -0
  23. package/dist/parsePptx/parseHtml.d.ts +22 -0
  24. package/dist/parsePptx/parseHtml.d.ts.map +1 -0
  25. package/dist/parsePptx/parseHtml.js +53 -0
  26. package/dist/parsePptx/types.d.ts +15 -0
  27. package/dist/parsePptx/types.d.ts.map +1 -0
  28. package/dist/parsePptx/types.js +1 -0
  29. package/dist/parsePptx/units.d.ts +13 -0
  30. package/dist/parsePptx/units.d.ts.map +1 -0
  31. package/dist/parsePptx/units.js +19 -0
  32. package/dist/renderPptx/renderPptx.d.ts.map +1 -1
  33. package/dist/renderPptx/renderPptx.js +15 -2
  34. package/dist/types.d.ts +23 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js +12 -1
  37. package/package.json +4 -4
@@ -46,6 +46,7 @@ export declare const inputBaseNodeSchema: z.ZodObject<{
46
46
  sysDot: "sysDot";
47
47
  }>>;
48
48
  }, z.core.$strip>>;
49
+ borderRadius: z.ZodOptional<z.ZodNumber>;
49
50
  }, z.core.$strip>;
50
51
  type InputBaseNode = z.infer<typeof inputBaseNodeSchema>;
51
52
  export declare const inputTextNodeSchema: z.ZodObject<{
@@ -76,6 +77,7 @@ export declare const inputTextNodeSchema: z.ZodObject<{
76
77
  sysDot: "sysDot";
77
78
  }>>;
78
79
  }, z.core.$strip>>;
80
+ borderRadius: z.ZodOptional<z.ZodNumber>;
79
81
  type: z.ZodLiteral<"text">;
80
82
  text: z.ZodString;
81
83
  fontPx: z.ZodOptional<z.ZodNumber>;
@@ -143,6 +145,7 @@ export declare const inputImageNodeSchema: z.ZodObject<{
143
145
  sysDot: "sysDot";
144
146
  }>>;
145
147
  }, z.core.$strip>>;
148
+ borderRadius: z.ZodOptional<z.ZodNumber>;
146
149
  type: z.ZodLiteral<"image">;
147
150
  src: z.ZodString;
148
151
  }, z.core.$strip>;
@@ -174,6 +177,7 @@ export declare const inputTableNodeSchema: z.ZodObject<{
174
177
  sysDot: "sysDot";
175
178
  }>>;
176
179
  }, z.core.$strip>>;
180
+ borderRadius: z.ZodOptional<z.ZodNumber>;
177
181
  type: z.ZodLiteral<"table">;
178
182
  columns: z.ZodArray<z.ZodObject<{
179
183
  width: z.ZodOptional<z.ZodNumber>;
@@ -223,6 +227,7 @@ export declare const inputShapeNodeSchema: z.ZodObject<{
223
227
  sysDot: "sysDot";
224
228
  }>>;
225
229
  }, z.core.$strip>>;
230
+ borderRadius: z.ZodOptional<z.ZodNumber>;
226
231
  type: z.ZodLiteral<"shape">;
227
232
  shapeType: z.ZodEnum<{
228
233
  accentBorderCallout1: "accentBorderCallout1";
@@ -470,11 +475,15 @@ export declare const inputChartNodeSchema: z.ZodObject<{
470
475
  sysDot: "sysDot";
471
476
  }>>;
472
477
  }, z.core.$strip>>;
478
+ borderRadius: z.ZodOptional<z.ZodNumber>;
473
479
  type: z.ZodLiteral<"chart">;
474
480
  chartType: z.ZodEnum<{
475
481
  line: "line";
476
482
  pie: "pie";
477
483
  bar: "bar";
484
+ area: "area";
485
+ doughnut: "doughnut";
486
+ radar: "radar";
478
487
  }>;
479
488
  data: z.ZodArray<z.ZodObject<{
480
489
  name: z.ZodOptional<z.ZodString>;
@@ -485,6 +494,11 @@ export declare const inputChartNodeSchema: z.ZodObject<{
485
494
  showTitle: z.ZodOptional<z.ZodBoolean>;
486
495
  title: z.ZodOptional<z.ZodString>;
487
496
  chartColors: z.ZodOptional<z.ZodArray<z.ZodString>>;
497
+ radarStyle: z.ZodOptional<z.ZodEnum<{
498
+ standard: "standard";
499
+ marker: "marker";
500
+ filled: "filled";
501
+ }>>;
488
502
  }, z.core.$strip>;
489
503
  export type InputTextNode = z.infer<typeof inputTextNodeSchema>;
490
504
  export type InputImageNode = z.infer<typeof inputImageNodeSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../src/inputSchema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAeL,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AAEH,KAAK,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAGzD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU9B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAG/B,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AC;IACZ,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,cAAc,GACd,cAAc,GACd,YAAY,GACZ,eAAe,GACf,eAAe,GACf,cAAc,GACd,cAAc,CAAC;AAwBnB,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CACJ,CAAC;AACpD,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CACJ,CAAC;AAC1D,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CACJ,CAAC;AAE1D;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAW3B,CAAC;AAG7B,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;iBAaxC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC"}
@@ -17,7 +17,7 @@
17
17
  * ```
18
18
  */
19
19
  import { z } from "zod";
20
- import { lengthSchema, paddingSchema, borderStyleSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, pageNumberPositionSchema, chartTypeSchema, chartDataSchema, bulletOptionsSchema, } from "./types";
20
+ import { lengthSchema, paddingSchema, borderStyleSchema, fillStyleSchema, shadowStyleSchema, alignItemsSchema, justifyContentSchema, shapeTypeSchema, tableColumnSchema, tableRowSchema, pageNumberPositionSchema, chartTypeSchema, chartDataSchema, bulletOptionsSchema, radarStyleSchema, } from "./types";
21
21
  // ===== Base Node Schema =====
22
22
  export const inputBaseNodeSchema = z.object({
23
23
  w: lengthSchema.optional(),
@@ -29,6 +29,7 @@ export const inputBaseNodeSchema = z.object({
29
29
  padding: paddingSchema.optional(),
30
30
  backgroundColor: z.string().optional(),
31
31
  border: borderStyleSchema.optional(),
32
+ borderRadius: z.number().optional(),
32
33
  });
33
34
  // ===== Node Schemas =====
34
35
  export const inputTextNodeSchema = inputBaseNodeSchema.extend({
@@ -71,6 +72,8 @@ export const inputChartNodeSchema = inputBaseNodeSchema.extend({
71
72
  showTitle: z.boolean().optional(),
72
73
  title: z.string().optional(),
73
74
  chartColors: z.array(z.string()).optional(),
75
+ // radar専用オプション
76
+ radarStyle: radarStyleSchema.optional(),
74
77
  });
75
78
  // ===== Recursive Node Schemas =====
76
79
  const inputBoxNodeSchemaBase = inputBaseNodeSchema.extend({
@@ -0,0 +1,8 @@
1
+ import type { ChartNode } from "../types";
2
+ import type { Chart } from "./types";
3
+ /**
4
+ * pptxtojsonのChart要素をPOMのChartNodeに変換
5
+ * scatter/bubbleチャートはサポートされていないためnullを返す
6
+ */
7
+ export declare function convertChart(element: Chart): ChartNode | null;
8
+ //# sourceMappingURL=convertChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertChart.d.ts","sourceRoot":"","sources":["../../src/parsePptx/convertChart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAwB,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,KAAK,EAA2C,MAAM,SAAS,CAAC;AA2C9E;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,GAAG,IAAI,CA4C7D"}
@@ -0,0 +1,78 @@
1
+ import { ptToPx, normalizeColor } from "./units";
2
+ /**
3
+ * pptxtojsonのchartType から POMのChartType へのマッピング
4
+ * 3Dチャートは2D相当として扱う
5
+ */
6
+ const CHART_TYPE_MAP = {
7
+ barChart: "bar",
8
+ bar3DChart: "bar",
9
+ lineChart: "line",
10
+ line3DChart: "line",
11
+ pieChart: "pie",
12
+ pie3DChart: "pie",
13
+ areaChart: "area",
14
+ area3DChart: "area",
15
+ doughnutChart: "doughnut",
16
+ radarChart: "radar",
17
+ // サポートされていないチャートタイプ
18
+ scatterChart: null,
19
+ bubbleChart: null,
20
+ surfaceChart: null,
21
+ surface3DChart: null,
22
+ stockChart: null,
23
+ };
24
+ /**
25
+ * pptxtojsonのchartTypeをPOMのChartTypeに変換
26
+ * サポートされていない場合はnullを返す
27
+ */
28
+ function mapChartType(chartType) {
29
+ return CHART_TYPE_MAP[chartType];
30
+ }
31
+ /**
32
+ * CommonChartかどうかをチェック
33
+ */
34
+ function isCommonChart(chart) {
35
+ return (chart.chartType !== "scatterChart" && chart.chartType !== "bubbleChart");
36
+ }
37
+ /**
38
+ * pptxtojsonのChart要素をPOMのChartNodeに変換
39
+ * scatter/bubbleチャートはサポートされていないためnullを返す
40
+ */
41
+ export function convertChart(element) {
42
+ // scatter/bubbleチャートはサポートされていない
43
+ if (!isCommonChart(element)) {
44
+ return null;
45
+ }
46
+ const pomChartType = mapChartType(element.chartType);
47
+ if (pomChartType === null) {
48
+ return null;
49
+ }
50
+ // データの変換
51
+ // pptxtojson: { key: string, values: { x: string, y: number }[], xlabels: { [key]: string } }
52
+ // pom: { name?: string, labels: string[], values: number[] }
53
+ const data = element.data.map((item) => {
54
+ const labels = item.values.map((v) => v.x);
55
+ const values = item.values.map((v) => v.y);
56
+ return {
57
+ name: item.key || undefined,
58
+ labels,
59
+ values,
60
+ };
61
+ });
62
+ const result = {
63
+ type: "chart",
64
+ chartType: pomChartType,
65
+ data,
66
+ w: ptToPx(element.width),
67
+ h: ptToPx(element.height),
68
+ };
69
+ // チャートの色
70
+ if (element.colors && element.colors.length > 0) {
71
+ result.chartColors = element.colors.map(normalizeColor);
72
+ }
73
+ // radarチャートのスタイル
74
+ if (pomChartType === "radar") {
75
+ result.radarStyle = "standard";
76
+ }
77
+ return result;
78
+ }
@@ -0,0 +1,8 @@
1
+ import type { ImageNode } from "../types";
2
+ import type { Image } from "./types";
3
+ /**
4
+ * pptxtojsonのImage要素をPOMのImageNodeに変換
5
+ * pptxtojsonは画像をBase64形式で提供する
6
+ */
7
+ export declare function convertImage(element: Image): ImageNode;
8
+ //# sourceMappingURL=convertImage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertImage.d.ts","sourceRoot":"","sources":["../../src/parsePptx/convertImage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,CAOtD"}
@@ -0,0 +1,13 @@
1
+ import { ptToPx } from "./units";
2
+ /**
3
+ * pptxtojsonのImage要素をPOMのImageNodeに変換
4
+ * pptxtojsonは画像をBase64形式で提供する
5
+ */
6
+ export function convertImage(element) {
7
+ return {
8
+ type: "image",
9
+ src: element.src,
10
+ w: ptToPx(element.width),
11
+ h: ptToPx(element.height),
12
+ };
13
+ }
@@ -0,0 +1,7 @@
1
+ import type { ShapeNode } from "../types";
2
+ import type { Shape } from "./types";
3
+ /**
4
+ * pptxtojsonのShape要素をPOMのShapeNodeに変換
5
+ */
6
+ export declare function convertShape(element: Shape): ShapeNode;
7
+ //# sourceMappingURL=convertShape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertShape.d.ts","sourceRoot":"","sources":["../../src/parsePptx/convertShape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,UAAU,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAsFrC;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,CA2DtD"}
@@ -0,0 +1,137 @@
1
+ import { ptToPx, normalizeColor } from "./units";
2
+ import { extractPlainText, extractStyles } from "./parseHtml";
3
+ /**
4
+ * pptxtojsonのshapType から POMのShapeType へのマッピング
5
+ * pptxtojsonのshapTypeはOpenXMLの図形名に近い形式
6
+ */
7
+ const SHAPE_TYPE_MAP = {
8
+ rect: "rect",
9
+ rectangle: "rect",
10
+ roundRect: "roundRect",
11
+ roundRectangle: "roundRect",
12
+ ellipse: "ellipse",
13
+ oval: "ellipse",
14
+ triangle: "triangle",
15
+ rtTriangle: "rtTriangle",
16
+ parallelogram: "parallelogram",
17
+ trapezoid: "trapezoid",
18
+ diamond: "diamond",
19
+ pentagon: "pentagon",
20
+ hexagon: "hexagon",
21
+ heptagon: "heptagon",
22
+ octagon: "octagon",
23
+ decagon: "decagon",
24
+ dodecagon: "dodecagon",
25
+ star4: "star4",
26
+ star5: "star5",
27
+ star6: "star6",
28
+ star7: "star7",
29
+ star8: "star8",
30
+ star10: "star10",
31
+ star12: "star12",
32
+ star16: "star16",
33
+ star24: "star24",
34
+ star32: "star32",
35
+ plus: "plus",
36
+ cross: "plus",
37
+ arrow: "rightArrow",
38
+ rightArrow: "rightArrow",
39
+ leftArrow: "leftArrow",
40
+ upArrow: "upArrow",
41
+ downArrow: "downArrow",
42
+ leftRightArrow: "leftRightArrow",
43
+ upDownArrow: "upDownArrow",
44
+ cloud: "cloud",
45
+ cloudCallout: "cloudCallout",
46
+ heart: "heart",
47
+ lightningBolt: "lightningBolt",
48
+ sun: "sun",
49
+ moon: "moon",
50
+ arc: "arc",
51
+ donut: "donut",
52
+ line: "line",
53
+ chevron: "chevron",
54
+ homePlate: "homePlate",
55
+ can: "can",
56
+ cube: "cube",
57
+ bevel: "bevel",
58
+ funnel: "funnel",
59
+ wedgeRectCallout: "wedgeRectCallout",
60
+ wedgeRoundRectCallout: "wedgeRoundRectCallout",
61
+ wedgeEllipseCallout: "wedgeEllipseCallout",
62
+ frame: "frame",
63
+ plaque: "plaque",
64
+ bracePair: "bracePair",
65
+ bracketPair: "bracketPair",
66
+ leftBrace: "leftBrace",
67
+ rightBrace: "rightBrace",
68
+ leftBracket: "leftBracket",
69
+ rightBracket: "rightBracket",
70
+ flowChartProcess: "flowChartProcess",
71
+ flowChartDecision: "flowChartDecision",
72
+ flowChartTerminator: "flowChartTerminator",
73
+ flowChartDocument: "flowChartDocument",
74
+ flowChartConnector: "flowChartConnector",
75
+ };
76
+ /**
77
+ * pptxtojsonのshapTypeをPOMのShapeTypeに変換
78
+ * マッピングに存在しない場合はデフォルトで "rect" を返す
79
+ */
80
+ function mapShapeType(shapType) {
81
+ return SHAPE_TYPE_MAP[shapType] || "rect";
82
+ }
83
+ /**
84
+ * pptxtojsonのShape要素をPOMのShapeNodeに変換
85
+ */
86
+ export function convertShape(element) {
87
+ const result = {
88
+ type: "shape",
89
+ shapeType: mapShapeType(element.shapType),
90
+ w: ptToPx(element.width),
91
+ h: ptToPx(element.height),
92
+ };
93
+ // テキストがある場合
94
+ if (element.content) {
95
+ const text = extractPlainText(element.content);
96
+ if (text) {
97
+ result.text = text;
98
+ const styles = extractStyles(element.content);
99
+ if (styles.fontSize !== undefined) {
100
+ result.fontPx = ptToPx(styles.fontSize);
101
+ }
102
+ if (styles.color) {
103
+ result.color = normalizeColor(styles.color);
104
+ }
105
+ if (styles.bold) {
106
+ result.bold = true;
107
+ }
108
+ if (styles.textAlign) {
109
+ result.alignText = styles.textAlign;
110
+ }
111
+ }
112
+ }
113
+ // 塗りつぶし
114
+ if (element.fill && element.fill.type === "color") {
115
+ result.fill = {
116
+ color: normalizeColor(element.fill.value),
117
+ };
118
+ }
119
+ // 枠線
120
+ if (element.borderColor && element.borderWidth) {
121
+ result.line = {
122
+ color: normalizeColor(element.borderColor),
123
+ width: ptToPx(element.borderWidth),
124
+ };
125
+ }
126
+ // 影
127
+ if (element.shadow) {
128
+ result.shadow = {
129
+ type: "outer",
130
+ blur: element.shadow.blur,
131
+ offset: Math.sqrt(element.shadow.h * element.shadow.h +
132
+ element.shadow.v * element.shadow.v),
133
+ color: normalizeColor(element.shadow.color),
134
+ };
135
+ }
136
+ return result;
137
+ }
@@ -0,0 +1,7 @@
1
+ import type { TableNode } from "../types";
2
+ import type { Table } from "./types";
3
+ /**
4
+ * pptxtojsonのTable要素をPOMのTableNodeに変換
5
+ */
6
+ export declare function convertTable(element: Table): TableNode;
7
+ //# sourceMappingURL=convertTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertTable.d.ts","sourceRoot":"","sources":["../../src/parsePptx/convertTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAoC,MAAM,UAAU,CAAC;AAC5E,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,SAAS,CAAC;AA2BjE;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,KAAK,GAAG,SAAS,CA2BtD"}
@@ -0,0 +1,46 @@
1
+ import { ptToPx, normalizeColor } from "./units";
2
+ import { extractPlainText } from "./parseHtml";
3
+ /**
4
+ * pptxtojsonのTableCell要素をPOMのTableCellに変換
5
+ */
6
+ function convertCell(cell) {
7
+ const result = {
8
+ text: extractPlainText(cell.text),
9
+ };
10
+ if (cell.fontColor) {
11
+ result.color = normalizeColor(cell.fontColor);
12
+ }
13
+ if (cell.fontBold) {
14
+ result.bold = true;
15
+ }
16
+ if (cell.fillColor) {
17
+ result.backgroundColor = normalizeColor(cell.fillColor);
18
+ }
19
+ return result;
20
+ }
21
+ /**
22
+ * pptxtojsonのTable要素をPOMのTableNodeに変換
23
+ */
24
+ export function convertTable(element) {
25
+ // 列幅の変換
26
+ const columns = element.colWidths.map((width) => ({
27
+ width: ptToPx(width),
28
+ }));
29
+ // 行データの変換
30
+ const rows = element.data.map((rowCells, rowIndex) => {
31
+ const cells = rowCells.map((cell) => convertCell(cell));
32
+ const row = { cells };
33
+ // 行の高さ
34
+ if (element.rowHeights && element.rowHeights[rowIndex]) {
35
+ row.height = ptToPx(element.rowHeights[rowIndex]);
36
+ }
37
+ return row;
38
+ });
39
+ return {
40
+ type: "table",
41
+ columns,
42
+ rows,
43
+ w: ptToPx(element.width),
44
+ h: ptToPx(element.height),
45
+ };
46
+ }
@@ -0,0 +1,7 @@
1
+ import type { TextNode } from "../types";
2
+ import type { Text } from "./types";
3
+ /**
4
+ * pptxtojsonのText要素をPOMのTextNodeに変換
5
+ */
6
+ export declare function convertText(element: Text): TextNode;
7
+ //# sourceMappingURL=convertText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertText.d.ts","sourceRoot":"","sources":["../../src/parsePptx/convertText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAIpC;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,IAAI,GAAG,QAAQ,CAiCnD"}
@@ -0,0 +1,32 @@
1
+ import { ptToPx, normalizeColor } from "./units";
2
+ import { extractPlainText, extractStyles } from "./parseHtml";
3
+ /**
4
+ * pptxtojsonのText要素をPOMのTextNodeに変換
5
+ */
6
+ export function convertText(element) {
7
+ const text = extractPlainText(element.content);
8
+ const styles = extractStyles(element.content);
9
+ const result = {
10
+ type: "text",
11
+ text,
12
+ w: ptToPx(element.width),
13
+ h: ptToPx(element.height),
14
+ };
15
+ // スタイル情報を設定
16
+ if (styles.fontSize !== undefined) {
17
+ result.fontPx = ptToPx(styles.fontSize);
18
+ }
19
+ if (styles.color) {
20
+ result.color = normalizeColor(styles.color);
21
+ }
22
+ if (styles.bold) {
23
+ result.bold = true;
24
+ }
25
+ if (styles.textAlign) {
26
+ result.alignText = styles.textAlign;
27
+ }
28
+ if (styles.fontFamily) {
29
+ result.fontFamily = styles.fontFamily;
30
+ }
31
+ return result;
32
+ }
@@ -0,0 +1,23 @@
1
+ import type { ParsedPptx, ParsePptxOptions } from "./types";
2
+ export type { ParsedPptx, ParsePptxOptions };
3
+ /**
4
+ * PPTXファイルを解析してPOMNode[]に変換
5
+ *
6
+ * @param data - PPTXファイルのバイナリデータ
7
+ * @param options - 解析オプション
8
+ * @returns ParsedPptx - 解析結果
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { parsePptx } from "@hirokisakabe/pom";
13
+ * import fs from "fs";
14
+ *
15
+ * const data = new Uint8Array(fs.readFileSync("presentation.pptx"));
16
+ * const result = await parsePptx(data);
17
+ *
18
+ * console.log(`スライド数: ${result.slides.length}`);
19
+ * console.log(`サイズ: ${result.metadata.slideWidth}x${result.metadata.slideHeight}`);
20
+ * ```
21
+ */
22
+ export declare function parsePptx(data: Uint8Array, options?: ParsePptxOptions): Promise<ParsedPptx>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parsePptx/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAC;AAQ5E,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;AA4E7C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,UAAU,CAAC,CAmCrB"}
@@ -0,0 +1,114 @@
1
+ import * as pptxtojson from "pptxtojson";
2
+ import { ptToPx } from "./units";
3
+ import { convertText } from "./convertText";
4
+ import { convertImage } from "./convertImage";
5
+ import { convertShape } from "./convertShape";
6
+ import { convertTable } from "./convertTable";
7
+ import { convertChart } from "./convertChart";
8
+ /**
9
+ * サポートされる要素タイプ
10
+ */
11
+ const SUPPORTED_ELEMENT_TYPES = ["text", "image", "shape", "table", "chart"];
12
+ /**
13
+ * 要素がサポートされているかチェック
14
+ */
15
+ function isSupported(element) {
16
+ return SUPPORTED_ELEMENT_TYPES.includes(element.type);
17
+ }
18
+ /**
19
+ * pptxtojsonの要素をPOMNodeに変換
20
+ */
21
+ function convertElement(element) {
22
+ switch (element.type) {
23
+ case "text":
24
+ return convertText(element);
25
+ case "image":
26
+ return convertImage(element);
27
+ case "shape":
28
+ return convertShape(element);
29
+ case "table":
30
+ return convertTable(element);
31
+ case "chart":
32
+ return convertChart(element);
33
+ case "group":
34
+ // グループ内の要素をフラット化して返す(最初の要素のみ)
35
+ // 注: グループ全体を適切に処理するには追加の実装が必要
36
+ return null;
37
+ case "diagram":
38
+ // diagramはフラット化してshapeとして扱う可能性があるが、
39
+ // 現時点では未対応
40
+ return null;
41
+ default:
42
+ return null;
43
+ }
44
+ }
45
+ /**
46
+ * スライドをPOMNodeに変換
47
+ * 各スライドはVStackとして返す
48
+ */
49
+ function convertSlide(slide, slideWidth, slideHeight) {
50
+ const children = [];
51
+ // 要素をorder順にソート
52
+ const sortedElements = [...slide.elements]
53
+ .filter(isSupported)
54
+ .sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
55
+ for (const element of sortedElements) {
56
+ const node = convertElement(element);
57
+ if (node) {
58
+ children.push(node);
59
+ }
60
+ }
61
+ // VStackでラップして返す
62
+ const result = {
63
+ type: "vstack",
64
+ w: slideWidth,
65
+ h: slideHeight,
66
+ children,
67
+ };
68
+ return result;
69
+ }
70
+ /**
71
+ * PPTXファイルを解析してPOMNode[]に変換
72
+ *
73
+ * @param data - PPTXファイルのバイナリデータ
74
+ * @param options - 解析オプション
75
+ * @returns ParsedPptx - 解析結果
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * import { parsePptx } from "@hirokisakabe/pom";
80
+ * import fs from "fs";
81
+ *
82
+ * const data = new Uint8Array(fs.readFileSync("presentation.pptx"));
83
+ * const result = await parsePptx(data);
84
+ *
85
+ * console.log(`スライド数: ${result.slides.length}`);
86
+ * console.log(`サイズ: ${result.metadata.slideWidth}x${result.metadata.slideHeight}`);
87
+ * ```
88
+ */
89
+ export async function parsePptx(data, options) {
90
+ // Uint8ArrayをArrayBufferに変換
91
+ const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
92
+ // pptxtojsonでパース
93
+ const result = await pptxtojson.parse(arrayBuffer, {
94
+ slideFactor: options?.slideFactor,
95
+ fontsizeFactor: options?.fontsizeFactor,
96
+ });
97
+ // スライドサイズをpxに変換
98
+ const slideWidth = ptToPx(result.size.width);
99
+ const slideHeight = ptToPx(result.size.height);
100
+ // 各スライドをPOMNodeに変換
101
+ const slides = result.slides.map((slide) => convertSlide(slide, slideWidth, slideHeight));
102
+ // 画像を収集
103
+ const images = new Map();
104
+ // 注: pptxtojsonは画像をBase64文字列として提供するため、
105
+ // 必要に応じてUint8Arrayに変換して保存する実装が必要
106
+ return {
107
+ slides,
108
+ images,
109
+ metadata: {
110
+ slideWidth,
111
+ slideHeight,
112
+ },
113
+ };
114
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * pptxtojsonのテキスト要素はHTML形式でスタイル情報を含んでいる
3
+ * このモジュールはHTMLからテキストとスタイル情報を抽出する
4
+ */
5
+ export interface ExtractedStyles {
6
+ fontSize?: number;
7
+ color?: string;
8
+ bold?: boolean;
9
+ textAlign?: "left" | "center" | "right";
10
+ fontFamily?: string;
11
+ }
12
+ /**
13
+ * HTMLコンテンツからプレーンテキストを抽出
14
+ * <p>タグは改行、<br>は改行、それ以外のタグは除去
15
+ */
16
+ export declare function extractPlainText(html: string): string;
17
+ /**
18
+ * HTMLのstyle属性からスタイル情報を抽出
19
+ * 最初に見つかったスタイルを使用(複数スタイルの場合は最初のもの)
20
+ */
21
+ export declare function extractStyles(html: string): ExtractedStyles;
22
+ //# sourceMappingURL=parseHtml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseHtml.d.ts","sourceRoot":"","sources":["../../src/parsePptx/parseHtml.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWrD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAkC3D"}