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