@officedk/pptxdk 0.0.0-stage → 0.1.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.
Files changed (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2272 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +48 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
@@ -0,0 +1,539 @@
1
+ import { matchLayoutPlaceholderKey } from "../../../core/dist/placeholders.js";
2
+ import "../../../core/dist/capability.js";
3
+ import { A_NS, P_NS, TABLE_NS_URI, emuToPx } from "../../../import/dist/namespaces.js";
4
+ import { readDrawingColor, readLineBorder, readTransformXml } from "../../../import/dist/visual.js";
5
+ import "../../../import/dist/index.js";
6
+ import { readClickLink } from "../shared/identity.js";
7
+ import { isPlaceholderGraphicFrameElement, readNvPrPlaceholder } from "../shared/placeholder-import.js";
8
+ import "../shared/visual.js";
9
+ import { populateRichTextNode, readRichTextBody } from "../text/text-import.js";
10
+ import { createCellNode, createRowNode, createTableNode } from "./table-declaration.js";
11
+ import { graphicFrameLocksXmlSchema, nonVisualGraphicFrameIdSchema, tblCellPrXmlSchema, tblCellXmlSchema, tblGridColXmlSchema, tblPrXmlSchema, tblRowXmlSchema } from "./table-schemas.js";
12
+ // ../capabilities/dist/table/table-import.js
13
+ const anchorToVerticalAlign = {
14
+ t: "top",
15
+ ctr: "middle",
16
+ b: "bottom"
17
+ };
18
+ function directElementChild(parent, namespaceUri, localName) {
19
+ for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
20
+ if (child.nodeType !== 1) continue;
21
+ const el = child;
22
+ if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
23
+ }
24
+ }
25
+ /** Side-effect-free predicate matching `<p:graphicFrame>` elements containing DrawingML tables. */
26
+ function isTableGraphicFrame(cursor) {
27
+ const graphic = directElementChild(cursor.element, A_NS, "graphic");
28
+ if (graphic === void 0) return false;
29
+ const graphicData = directElementChild(graphic, A_NS, "graphicData");
30
+ if (graphicData === void 0) return false;
31
+ return graphicData.getAttribute("uri") === TABLE_NS_URI;
32
+ }
33
+ function consumeContinuationCell(tcCursor) {
34
+ const txBody = tcCursor.child(A_NS, "txBody");
35
+ if (txBody !== void 0) {
36
+ txBody.ignoreEmptyChild(A_NS, "bodyPr");
37
+ txBody.ignoreEmptyChild(A_NS, "lstStyle");
38
+ for (const p of txBody.children(A_NS, "p")) {
39
+ const endParaRPr = p.child(A_NS, "endParaRPr");
40
+ if (endParaRPr !== void 0) {
41
+ endParaRPr.consumeAttr("lang");
42
+ endParaRPr.consumeAttr("dirty");
43
+ endParaRPr.consumeAttr("smtClean");
44
+ }
45
+ p.suppressUnconsumed();
46
+ }
47
+ txBody.suppressUnconsumed();
48
+ }
49
+ tcCursor.ignoreEmptyChild(A_NS, "tcPr");
50
+ tcCursor.suppressUnconsumed();
51
+ }
52
+ function readCellProperties(tcPr, cellLocation, diagnostics) {
53
+ if (tcPr === void 0) return {};
54
+ const rawAttrs = tcPr.attrsObject([
55
+ "marL",
56
+ "marR",
57
+ "marT",
58
+ "marB",
59
+ "anchor",
60
+ "vert",
61
+ "horzOverflow",
62
+ "anchorCtr"
63
+ ]);
64
+ const parsedAttrs = tblCellPrXmlSchema.safeParse(rawAttrs);
65
+ let paddingTop;
66
+ let paddingRight;
67
+ let paddingBottom;
68
+ let paddingLeft;
69
+ let verticalAlign;
70
+ if (!parsedAttrs.success) diagnostics.push({
71
+ code: "invalid-xml-value",
72
+ category: "corrupt-input",
73
+ disposition: "recovered",
74
+ location: {
75
+ ...cellLocation,
76
+ xpath: tcPr.xpath
77
+ },
78
+ attributeOrElement: "a:tcPr",
79
+ rawValue: JSON.stringify(rawAttrs)
80
+ });
81
+ else {
82
+ const attrs = parsedAttrs.data;
83
+ if (attrs.marT !== void 0 && attrs.marT !== 0) paddingTop = emuToPx(attrs.marT);
84
+ if (attrs.marR !== void 0 && attrs.marR !== 0) paddingRight = emuToPx(attrs.marR);
85
+ if (attrs.marB !== void 0 && attrs.marB !== 0) paddingBottom = emuToPx(attrs.marB);
86
+ if (attrs.marL !== void 0 && attrs.marL !== 0) paddingLeft = emuToPx(attrs.marL);
87
+ if (attrs.anchor !== void 0) verticalAlign = anchorToVerticalAlign[attrs.anchor];
88
+ if (attrs.vert !== void 0 && attrs.vert !== "horz") diagnostics.push({
89
+ code: "unsupported-mechanism",
90
+ category: "unsupported",
91
+ disposition: "omitted",
92
+ location: {
93
+ ...cellLocation,
94
+ xpath: `${tcPr.xpath}/@vert`
95
+ },
96
+ namespaceUri: "",
97
+ localName: "vert",
98
+ mechanismHint: `table-cell-vert:${attrs.vert}`
99
+ });
100
+ }
101
+ let border;
102
+ for (const side of [
103
+ "lnL",
104
+ "lnR",
105
+ "lnT",
106
+ "lnB"
107
+ ]) {
108
+ const ln = tcPr.child(A_NS, side);
109
+ if (ln === void 0) continue;
110
+ const parsedBorder = readLineBorder(ln, cellLocation, diagnostics);
111
+ if (border === void 0 && parsedBorder.borderColor !== void 0) border = parsedBorder;
112
+ }
113
+ tcPr.ignoreEmptyChild(A_NS, "noFill");
114
+ let backgroundColor;
115
+ const solidFill = tcPr.child(A_NS, "solidFill");
116
+ if (solidFill !== void 0) backgroundColor = readDrawingColor(solidFill, cellLocation, diagnostics);
117
+ return {
118
+ ...backgroundColor === void 0 ? {} : { backgroundColor },
119
+ ...border?.borderColor === void 0 ? {} : { borderColor: border.borderColor },
120
+ ...border?.borderWidth === void 0 ? {} : { borderWidth: border.borderWidth },
121
+ ...border?.borderStyle === void 0 ? {} : { borderStyle: border.borderStyle },
122
+ ...paddingTop === void 0 ? {} : { paddingTop },
123
+ ...paddingRight === void 0 ? {} : { paddingRight },
124
+ ...paddingBottom === void 0 ? {} : { paddingBottom },
125
+ ...paddingLeft === void 0 ? {} : { paddingLeft },
126
+ ...verticalAlign === void 0 ? {} : { verticalAlign }
127
+ };
128
+ }
129
+ function readAnchorCell(tcCursor, colSpan, rowSpan, cellLocation, part, slideIndex, diagnostics) {
130
+ const txBody = tcCursor.child(A_NS, "txBody");
131
+ const cellPropsStyle = readCellProperties(tcCursor.child(A_NS, "tcPr"), cellLocation, diagnostics);
132
+ let hoistedRunStyle = {};
133
+ let singleTextContent;
134
+ let richParagraphs;
135
+ if (txBody !== void 0) {
136
+ const { importedParagraphs } = readRichTextBody(txBody, part, slideIndex, diagnostics);
137
+ const singleParagraph = importedParagraphs.length === 1 ? importedParagraphs[0] : void 0;
138
+ const hasParagraphLevelStyle = singleParagraph !== void 0 && Object.keys(singleParagraph.style).length > 0;
139
+ const singleTextRun = singleParagraph !== void 0 && !hasParagraphLevelStyle && singleParagraph.runs.length === 1 && singleParagraph.runs[0].kind === "text" ? singleParagraph.runs[0] : void 0;
140
+ const isSingleEmptyParagraph = singleParagraph !== void 0 && !hasParagraphLevelStyle && singleParagraph.runs.length === 0;
141
+ if (singleTextRun !== void 0) {
142
+ const { fontFamily, fontSize, fontWeight, fontStyle, color, letterSpacing, textTransform, textDecoration, textShadow, lang } = singleTextRun.style;
143
+ hoistedRunStyle = {
144
+ ...fontFamily === void 0 ? {} : { fontFamily },
145
+ ...fontSize === void 0 ? {} : { fontSize },
146
+ ...fontWeight === void 0 ? {} : { fontWeight },
147
+ ...fontStyle === void 0 ? {} : { fontStyle },
148
+ ...color === void 0 ? {} : { color },
149
+ ...letterSpacing === void 0 ? {} : { letterSpacing },
150
+ ...textTransform === void 0 ? {} : { textTransform },
151
+ ...textDecoration === void 0 ? {} : { textDecoration },
152
+ ...textShadow === void 0 ? {} : { textShadow },
153
+ ...lang === void 0 ? {} : { lang }
154
+ };
155
+ singleTextContent = singleTextRun.text;
156
+ } else if (!isSingleEmptyParagraph && importedParagraphs.length > 0) richParagraphs = importedParagraphs;
157
+ }
158
+ const mergedStyle = {
159
+ ...cellPropsStyle,
160
+ ...hoistedRunStyle
161
+ };
162
+ const cellProps = {
163
+ ...colSpan > 1 ? { colSpan } : {},
164
+ ...rowSpan > 1 ? { rowSpan } : {},
165
+ ...Object.keys(mergedStyle).length === 0 ? {} : { style: mergedStyle }
166
+ };
167
+ const cellNode = createCellNode(cellProps);
168
+ if (singleTextContent !== void 0) cellNode.content(singleTextContent);
169
+ else if (richParagraphs !== void 0) populateRichTextNode(cellNode, richParagraphs);
170
+ return cellNode;
171
+ }
172
+ /**
173
+ * Reads a Transitional `<p:graphicFrame>` containing a DrawingML `<a:tbl>` into an editable `TableNode`
174
+ * preserving solved column widths, row heights, 2D merge ranges, cell borders/fills/padding, and rich text.
175
+ */
176
+ function readTableGraphicFrame(context) {
177
+ const { cursor, part, slideIndex, layoutPlaceholders } = context;
178
+ const diagnostics = [];
179
+ const nvGraphicFramePr = cursor.child(P_NS, "nvGraphicFramePr");
180
+ if (nvGraphicFramePr === void 0) {
181
+ diagnostics.push({
182
+ code: "corrupt-part",
183
+ category: "corrupt-input",
184
+ disposition: "omitted",
185
+ location: {
186
+ part,
187
+ xpath: cursor.xpath,
188
+ slideIndex
189
+ }
190
+ });
191
+ return { diagnostics };
192
+ }
193
+ let objectId;
194
+ let objectName;
195
+ let clickResult;
196
+ const cNvPr = nvGraphicFramePr.child(P_NS, "cNvPr");
197
+ if (cNvPr !== void 0) {
198
+ const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
199
+ const parsedCNvPr = nonVisualGraphicFrameIdSchema.safeParse(rawCNvPr);
200
+ if (!parsedCNvPr.success) diagnostics.push({
201
+ code: "invalid-xml-value",
202
+ category: "corrupt-input",
203
+ disposition: "recovered",
204
+ location: {
205
+ part,
206
+ xpath: cNvPr.xpath,
207
+ slideIndex
208
+ },
209
+ attributeOrElement: "p:cNvPr",
210
+ rawValue: JSON.stringify(rawCNvPr)
211
+ });
212
+ else {
213
+ objectId = parsedCNvPr.data.id;
214
+ if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
215
+ }
216
+ const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
217
+ if (hlinkClick !== void 0) {
218
+ clickResult = readClickLink(hlinkClick, context, {
219
+ ...objectId === void 0 ? {} : { objectId },
220
+ ...objectName === void 0 ? {} : { objectName }
221
+ });
222
+ diagnostics.push(...clickResult.diagnostics);
223
+ }
224
+ cNvPr.ignoreEmptyChild(A_NS, "extLst");
225
+ }
226
+ const cNvGraphicFramePr = nvGraphicFramePr.child(P_NS, "cNvGraphicFramePr");
227
+ if (cNvGraphicFramePr !== void 0) {
228
+ const locks = cNvGraphicFramePr.child(A_NS, "graphicFrameLocks");
229
+ if (locks !== void 0) {
230
+ const rawLocks = locks.attrsObject([
231
+ "noGrp",
232
+ "noDrilldown",
233
+ "noSelect",
234
+ "noChangeAspect",
235
+ "noMove",
236
+ "noResize"
237
+ ]);
238
+ graphicFrameLocksXmlSchema.safeParse(rawLocks);
239
+ }
240
+ }
241
+ const tableLocation = {
242
+ part,
243
+ xpath: cursor.xpath,
244
+ slideIndex,
245
+ ...objectId === void 0 ? {} : { objectId },
246
+ ...objectName === void 0 ? {} : { objectName }
247
+ };
248
+ const nvPr = nvGraphicFramePr.child(P_NS, "nvPr");
249
+ const phResult = readNvPrPlaceholder(nvPr, tableLocation, diagnostics);
250
+ if (phResult.kind === "error") return { diagnostics };
251
+ const nativeRef = phResult.kind === "ok" ? phResult.nativeRef : void 0;
252
+ const matchedKey = nativeRef === void 0 ? void 0 : matchLayoutPlaceholderKey(layoutPlaceholders, {
253
+ type: nativeRef.type,
254
+ idx: nativeRef.idx
255
+ });
256
+ const xfrmCursor = cursor.child("http://schemas.openxmlformats.org/presentationml/2006/main", "xfrm") ?? cursor.child("http://schemas.openxmlformats.org/drawingml/2006/main", "xfrm");
257
+ if (xfrmCursor === void 0) {
258
+ diagnostics.push({
259
+ code: "corrupt-part",
260
+ category: "corrupt-input",
261
+ disposition: "omitted",
262
+ location: tableLocation
263
+ });
264
+ return { diagnostics };
265
+ }
266
+ const transform = readTransformXml(xfrmCursor, tableLocation, diagnostics);
267
+ if (transform === void 0) return { diagnostics };
268
+ const graphicData = cursor.child(A_NS, "graphic")?.child(A_NS, "graphicData");
269
+ if (graphicData !== void 0) graphicData.consumeAttr("uri");
270
+ const tbl = graphicData?.child(A_NS, "tbl");
271
+ if (tbl === void 0) {
272
+ diagnostics.push({
273
+ code: "corrupt-part",
274
+ category: "corrupt-input",
275
+ disposition: "omitted",
276
+ location: tableLocation
277
+ });
278
+ return { diagnostics };
279
+ }
280
+ const tblPr = tbl.child(A_NS, "tblPr");
281
+ if (tblPr !== void 0) {
282
+ const rawTblPr = tblPr.attrsObject([
283
+ "firstRow",
284
+ "firstCol",
285
+ "lastRow",
286
+ "lastCol",
287
+ "bandRow",
288
+ "bandCol",
289
+ "rtl"
290
+ ]);
291
+ if (!tblPrXmlSchema.safeParse(rawTblPr).success) diagnostics.push({
292
+ code: "invalid-xml-value",
293
+ category: "corrupt-input",
294
+ disposition: "recovered",
295
+ location: {
296
+ ...tableLocation,
297
+ xpath: tblPr.xpath
298
+ },
299
+ attributeOrElement: "a:tblPr",
300
+ rawValue: JSON.stringify(rawTblPr)
301
+ });
302
+ tblPr.ignoreEmptyChild(A_NS, "noFill");
303
+ const tableStyleId = tblPr.child(A_NS, "tableStyleId");
304
+ if (tableStyleId !== void 0) {
305
+ const styleIdText = tableStyleId.textContent.trim();
306
+ diagnostics.push({
307
+ code: "unsupported-mechanism",
308
+ category: "unsupported",
309
+ disposition: "omitted",
310
+ location: {
311
+ ...tableLocation,
312
+ xpath: tableStyleId.xpath
313
+ },
314
+ namespaceUri: A_NS,
315
+ localName: "tableStyleId",
316
+ ...styleIdText === "" ? {} : { mechanismHint: styleIdText }
317
+ });
318
+ tableStyleId.suppressUnconsumed();
319
+ }
320
+ }
321
+ const tblGrid = tbl.child(A_NS, "tblGrid");
322
+ if (tblGrid === void 0) {
323
+ diagnostics.push({
324
+ code: "corrupt-part",
325
+ category: "corrupt-input",
326
+ disposition: "omitted",
327
+ location: {
328
+ ...tableLocation,
329
+ xpath: tbl.xpath
330
+ }
331
+ });
332
+ return { diagnostics };
333
+ }
334
+ const gridCols = tblGrid.children(A_NS, "gridCol");
335
+ if (gridCols.length === 0) {
336
+ diagnostics.push({
337
+ code: "corrupt-part",
338
+ category: "corrupt-input",
339
+ disposition: "omitted",
340
+ location: {
341
+ ...tableLocation,
342
+ xpath: tblGrid.xpath
343
+ }
344
+ });
345
+ return { diagnostics };
346
+ }
347
+ const columnWidths = [];
348
+ for (const gridCol of gridCols) {
349
+ const rawCol = gridCol.attrsObject(["w"]);
350
+ const parsedCol = tblGridColXmlSchema.safeParse(rawCol);
351
+ if (!parsedCol.success) {
352
+ diagnostics.push({
353
+ code: "invalid-xml-value",
354
+ category: "corrupt-input",
355
+ disposition: "omitted",
356
+ location: {
357
+ ...tableLocation,
358
+ xpath: gridCol.xpath
359
+ },
360
+ attributeOrElement: "a:gridCol/@w",
361
+ rawValue: rawCol["w"] ?? ""
362
+ });
363
+ return { diagnostics };
364
+ }
365
+ columnWidths.push(emuToPx(parsedCol.data.w));
366
+ }
367
+ const trCursors = tbl.children(A_NS, "tr");
368
+ if (trCursors.length === 0) {
369
+ diagnostics.push({
370
+ code: "corrupt-part",
371
+ category: "corrupt-input",
372
+ disposition: "omitted",
373
+ location: {
374
+ ...tableLocation,
375
+ xpath: tbl.xpath
376
+ }
377
+ });
378
+ return { diagnostics };
379
+ }
380
+ const rowHeights = [];
381
+ const rawGrid = [];
382
+ for (const trCursor of trCursors) {
383
+ const rawRow = trCursor.attrsObject(["h"]);
384
+ const parsedRow = tblRowXmlSchema.safeParse(rawRow);
385
+ if (!parsedRow.success) {
386
+ diagnostics.push({
387
+ code: "invalid-xml-value",
388
+ category: "corrupt-input",
389
+ disposition: "omitted",
390
+ location: {
391
+ ...tableLocation,
392
+ xpath: trCursor.xpath
393
+ },
394
+ attributeOrElement: "a:tr/@h",
395
+ rawValue: rawRow["h"] ?? ""
396
+ });
397
+ return { diagnostics };
398
+ }
399
+ rowHeights.push(emuToPx(parsedRow.data.h));
400
+ const tcCursors = trCursor.children(A_NS, "tc");
401
+ if (tcCursors.length !== columnWidths.length) {
402
+ diagnostics.push({
403
+ code: "corrupt-part",
404
+ category: "corrupt-input",
405
+ disposition: "omitted",
406
+ location: {
407
+ ...tableLocation,
408
+ xpath: trCursor.xpath
409
+ }
410
+ });
411
+ return { diagnostics };
412
+ }
413
+ const rowCells = [];
414
+ for (const tcCursor of tcCursors) {
415
+ const rawCell = tcCursor.attrsObject([
416
+ "gridSpan",
417
+ "rowSpan",
418
+ "hMerge",
419
+ "vMerge"
420
+ ]);
421
+ const parsedCell = tblCellXmlSchema.safeParse(rawCell);
422
+ if (!parsedCell.success) {
423
+ diagnostics.push({
424
+ code: "invalid-xml-value",
425
+ category: "corrupt-input",
426
+ disposition: "recovered",
427
+ location: {
428
+ ...tableLocation,
429
+ xpath: tcCursor.xpath
430
+ },
431
+ attributeOrElement: "a:tc",
432
+ rawValue: JSON.stringify(rawCell)
433
+ });
434
+ rowCells.push({
435
+ cursor: tcCursor,
436
+ hMerge: false,
437
+ vMerge: false
438
+ });
439
+ } else rowCells.push({
440
+ cursor: tcCursor,
441
+ ...parsedCell.data.gridSpan === void 0 ? {} : { gridSpan: parsedCell.data.gridSpan },
442
+ ...parsedCell.data.rowSpan === void 0 ? {} : { rowSpan: parsedCell.data.rowSpan },
443
+ hMerge: parsedCell.data.hMerge ?? false,
444
+ vMerge: parsedCell.data.vMerge ?? false
445
+ });
446
+ }
447
+ rawGrid.push(rowCells);
448
+ }
449
+ const numRows = rawGrid.length;
450
+ const numCols = columnWidths.length;
451
+ const occupied = Array.from({ length: numRows }, () => Array.from({ length: numCols }, () => false));
452
+ const rowNodes = [];
453
+ for (let r = 0; r < numRows; r += 1) {
454
+ const rowNode = createRowNode({ style: { height: rowHeights[r] } });
455
+ for (let c = 0; c < numCols; c += 1) {
456
+ const rawCell = rawGrid[r][c];
457
+ if (occupied[r][c]) {
458
+ consumeContinuationCell(rawCell.cursor);
459
+ continue;
460
+ }
461
+ if (rawCell.hMerge || rawCell.vMerge) diagnostics.push({
462
+ code: "invalid-xml-value",
463
+ category: "corrupt-input",
464
+ disposition: "recovered",
465
+ location: {
466
+ ...tableLocation,
467
+ xpath: rawCell.cursor.xpath
468
+ },
469
+ attributeOrElement: rawCell.hMerge ? "a:tc/@hMerge" : "a:tc/@vMerge",
470
+ rawValue: "1"
471
+ });
472
+ let contiguousH = 0;
473
+ while (c + 1 + contiguousH < numCols && rawGrid[r][c + 1 + contiguousH].hMerge && !rawGrid[r][c + 1 + contiguousH].vMerge) contiguousH += 1;
474
+ let contiguousV = 0;
475
+ while (r + 1 + contiguousV < numRows && rawGrid[r + 1 + contiguousV][c].vMerge && !rawGrid[r + 1 + contiguousV][c].hMerge) contiguousV += 1;
476
+ const maxColSpan = numCols - c;
477
+ const maxRowSpan = numRows - r;
478
+ if (rawCell.gridSpan !== void 0 && rawCell.gridSpan > maxColSpan || rawCell.rowSpan !== void 0 && rawCell.rowSpan > maxRowSpan) diagnostics.push({
479
+ code: "invalid-xml-value",
480
+ category: "corrupt-input",
481
+ disposition: "recovered",
482
+ location: {
483
+ ...tableLocation,
484
+ xpath: rawCell.cursor.xpath
485
+ },
486
+ attributeOrElement: "a:tc"
487
+ });
488
+ const colSpan = Math.min(maxColSpan, Math.max(rawCell.gridSpan ?? 1, contiguousH + 1));
489
+ const rowSpan = Math.min(maxRowSpan, Math.max(rawCell.rowSpan ?? 1, contiguousV + 1));
490
+ for (let rr = r; rr < r + rowSpan; rr += 1) for (let cc = c; cc < c + colSpan; cc += 1) occupied[rr][cc] = true;
491
+ const cellNode = readAnchorCell(rawCell.cursor, colSpan, rowSpan, {
492
+ ...tableLocation,
493
+ xpath: rawCell.cursor.xpath
494
+ }, part, slideIndex, diagnostics);
495
+ rowNode.append(cellNode);
496
+ }
497
+ rowNodes.push(rowNode);
498
+ }
499
+ const columns = columnWidths;
500
+ const tableProps = {
501
+ ...objectName === void 0 ? {} : { name: objectName },
502
+ ...matchedKey === void 0 ? {} : { placeholder: matchedKey },
503
+ ...nativeRef === void 0 ? {} : { nativePlaceholder: nativeRef },
504
+ ...clickResult?.link === void 0 ? {} : { link: clickResult.link },
505
+ x: transform.x,
506
+ y: transform.y,
507
+ columns
508
+ };
509
+ const tableNode = createTableNode(tableProps);
510
+ tableNode.append(...rowNodes);
511
+ if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
512
+ const deferred = clickResult.deferredSlideLink;
513
+ context.registerDeferredSlideLink({
514
+ ...deferred,
515
+ apply(targetSlideId) {
516
+ tableNode.set({ link: { id: targetSlideId } });
517
+ }
518
+ });
519
+ }
520
+ return {
521
+ node: tableNode,
522
+ diagnostics
523
+ };
524
+ }
525
+ /** Shape-tree import handler wired into `tableMechanism` for free DrawingML `<a:tbl>` graphicFrames. */
526
+ const tableImportHandler = {
527
+ target: "shape-tree",
528
+ localName: "graphicFrame",
529
+ matches: (cursor) => isTableGraphicFrame(cursor) && !isPlaceholderGraphicFrameElement(cursor),
530
+ read: readTableGraphicFrame
531
+ };
532
+ /** Shape-tree import handler wired into `tablePlaceholderMechanism` for placeholder-bound `<a:tbl>` graphicFrames. */
533
+ const tablePlaceholderImportHandler = {
534
+ target: "shape-tree",
535
+ localName: "graphicFrame",
536
+ matches: (cursor) => isTableGraphicFrame(cursor) && isPlaceholderGraphicFrameElement(cursor),
537
+ read: readTableGraphicFrame
538
+ };
539
+ export { isTableGraphicFrame, readTableGraphicFrame, tableImportHandler, tablePlaceholderImportHandler };