@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,20 @@
1
+ import { defineObjectCodegen } from "../../../codegen/dist/types.js";
2
+ import "../../../codegen/dist/index.js";
3
+ import { blockRichTextChildKinds, createRichTextCodegenHandler } from "../text/text-codegen.js";
4
+ import { notesDeclarationPropsSchema } from "./notes-schemas.js";
5
+ // ../capabilities/dist/notes/notes-codegen.js
6
+ const notesAllowedPropKeys = new Set(Object.keys(notesDeclarationPropsSchema.unwrap().shape));
7
+ /**
8
+ * Source codegen contribution for page-affiliated `notes` (`notes()` / `<Notes>`) declarations.
9
+ *
10
+ * Registered via `declarations.notes` so `@pptxdk/codegen` resolves `Notes` child nodes inside
11
+ * `Slide` while preserving all rich-text children and speaker-note styles.
12
+ */
13
+ const notesCodegen = defineObjectCodegen({ declarations: { notes: createRichTextCodegenHandler({
14
+ vanillaFactory: "notes",
15
+ reactComponent: "Notes",
16
+ allowedPropKeys: notesAllowedPropKeys,
17
+ allowedChildKinds: blockRichTextChildKinds,
18
+ supportObjectExtras: false
19
+ }) } });
20
+ export { notesCodegen };
@@ -0,0 +1,8 @@
1
+ import { RichTextContainer } from "../../../core/dist/document.js";
2
+ import "./notes-schemas.js";
3
+ // ../capabilities/dist/notes/notes-declaration.js
4
+ /** Creates the editable notes container shared by the command factory and Notes JSX. */
5
+ function createNotesNode(props) {
6
+ return new RichTextContainer("notes", "notes", props, { pageAffiliated: true });
7
+ }
8
+ export { createNotesNode };
@@ -0,0 +1,12 @@
1
+ import { hostNodeCreator } from "../../../core/dist/host.js";
2
+ import { createNotesNode } from "./notes-declaration.js";
3
+ import { createElement } from "react";
4
+ // ../capabilities/dist/notes/notes-elements.js
5
+ /** Declares one page's rich-text speaker notes; repeated declarations on a page are a build error. */
6
+ function Notes(props) {
7
+ return createElement("notes", {
8
+ ...props,
9
+ [hostNodeCreator]: createNotesNode
10
+ }, props.children);
11
+ }
12
+ export { Notes };
@@ -0,0 +1,292 @@
1
+ import { textStyleKeys } from "../../../core/dist/theme.js";
2
+ import "../../../core/dist/capability.js";
3
+ import { CommonContainer, CommonNode } from "../../../core/dist/document.js";
4
+ import { A_NS, P_NS, REL_NOTES_SLIDE } from "../../../import/dist/namespaces.js";
5
+ import { XmlElementCursor, parseXmlPart } from "../../../import/dist/xml-reader.js";
6
+ import { resolvePartPath } from "../../../import/dist/opc.js";
7
+ import { peekShapeTreeObjectIdentity } from "../../../import/dist/resources.js";
8
+ import { appendUnconsumedDiagnostics, consumeIdentityShapeTreeBoilerplate } from "../../../import/dist/masters.js";
9
+ import { importPresentationSections } from "../../../import/dist/sections.js";
10
+ import "../../../import/dist/index.js";
11
+ import { populateRichTextNode, readRichTextBody } from "../text/text-import.js";
12
+ import { createNotesNode } from "./notes-declaration.js";
13
+ import { notesPlaceholderXmlSchema, notesRootAttrsXmlSchema, notesShapeIdentityXmlSchema } from "./notes-schemas.js";
14
+ // ../capabilities/dist/notes/notes-import.js
15
+ const baselineNotesSlidePlaceholders = /* @__PURE__ */ new Set([
16
+ "sldImg",
17
+ "hdr",
18
+ "ftr",
19
+ "dt",
20
+ "sldNum"
21
+ ]);
22
+ function consumeNotesCreationIdExtLst(cSld) {
23
+ const extLst = cSld.child(P_NS, "extLst");
24
+ if (extLst === void 0) return;
25
+ for (const ext of extLst.children(P_NS, "ext")) {
26
+ if (ext.element.getAttribute("uri") !== "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}") continue;
27
+ ext.consumeAttr("uri");
28
+ ext.suppressUnconsumed();
29
+ }
30
+ }
31
+ function readNotesPlaceholderInfo(spCursor, part, slideIndex, diagnostics) {
32
+ const nvSpPr = spCursor.child(P_NS, "nvSpPr");
33
+ if (nvSpPr === void 0) return {};
34
+ let objectId;
35
+ let objectName;
36
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
37
+ if (cNvPr !== void 0) {
38
+ const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
39
+ const parsedCNvPr = notesShapeIdentityXmlSchema.safeParse(rawCNvPr);
40
+ if (parsedCNvPr.success) {
41
+ objectId = parsedCNvPr.data.id;
42
+ if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
43
+ }
44
+ }
45
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
46
+ if (cNvSpPr !== void 0) cNvSpPr.suppressUnconsumed();
47
+ const nvPr = nvSpPr.child(P_NS, "nvPr");
48
+ if (nvPr === void 0) return {
49
+ ...objectId === void 0 ? {} : { objectId },
50
+ ...objectName === void 0 ? {} : { objectName }
51
+ };
52
+ const ph = nvPr.child(P_NS, "ph");
53
+ if (ph === void 0) return {
54
+ ...objectId === void 0 ? {} : { objectId },
55
+ ...objectName === void 0 ? {} : { objectName }
56
+ };
57
+ const rawPh = ph.attrsObject([
58
+ "type",
59
+ "idx",
60
+ "sz",
61
+ "orient",
62
+ "hasCustomPrompt"
63
+ ]);
64
+ const parsedPh = notesPlaceholderXmlSchema.safeParse(rawPh);
65
+ if (!parsedPh.success) {
66
+ diagnostics.push({
67
+ code: "invalid-xml-value",
68
+ category: "corrupt-input",
69
+ disposition: "recovered",
70
+ location: {
71
+ part,
72
+ xpath: ph.xpath,
73
+ slideIndex
74
+ },
75
+ attributeOrElement: "p:ph",
76
+ rawValue: JSON.stringify(rawPh)
77
+ });
78
+ return {
79
+ ...rawPh["type"] === void 0 ? {} : { phType: rawPh["type"] },
80
+ ...objectId === void 0 ? {} : { objectId },
81
+ ...objectName === void 0 ? {} : { objectName }
82
+ };
83
+ }
84
+ return {
85
+ ...parsedPh.data.type === void 0 ? {} : { phType: parsedPh.data.type },
86
+ ...objectId === void 0 ? {} : { objectId },
87
+ ...objectName === void 0 ? {} : { objectName }
88
+ };
89
+ }
90
+ function consumeNotesBodyShapeProperties(spPr) {
91
+ spPr.suppressUnconsumed();
92
+ }
93
+ /**
94
+ * Slide-level import handler for `speaker-notes`, reading `ppt/notesSlides/notesSlide{n}.xml`
95
+ * body rich text into a page-affiliated `NotesNode` on the owning `SlideNode`.
96
+ */
97
+ const speakerNotesImportHandler = {
98
+ target: "slide",
99
+ slot: "notes",
100
+ read(context) {
101
+ const { slideNode, part, slideIndex, package: pkg } = context;
102
+ if (slideIndex === void 0) return {};
103
+ const diagnostics = [];
104
+ const notesRel = pkg.readRelationships(part).entries.find((entry) => entry.Type === REL_NOTES_SLIDE);
105
+ if (notesRel === void 0) return {};
106
+ const notesPartPath = notesRel.TargetMode === "External" ? void 0 : resolvePartPath(part, notesRel.Target);
107
+ if (notesPartPath === void 0) {
108
+ diagnostics.push({
109
+ code: "broken-relationship",
110
+ category: "corrupt-input",
111
+ disposition: "omitted",
112
+ location: {
113
+ part,
114
+ xpath: notesRel.xpath,
115
+ slideIndex
116
+ },
117
+ relationshipId: notesRel.Id
118
+ });
119
+ return { diagnostics };
120
+ }
121
+ if (!pkg.hasPart(notesPartPath)) {
122
+ diagnostics.push({
123
+ code: "missing-target-part",
124
+ category: "corrupt-input",
125
+ disposition: "omitted",
126
+ location: {
127
+ part,
128
+ xpath: notesRel.xpath,
129
+ slideIndex
130
+ },
131
+ relationshipId: notesRel.Id,
132
+ targetPart: notesPartPath
133
+ });
134
+ return { diagnostics };
135
+ }
136
+ const xmlText = pkg.readTextPart(notesPartPath);
137
+ if (xmlText === void 0) return { diagnostics };
138
+ let notesEl;
139
+ try {
140
+ notesEl = parseXmlPart(notesPartPath, xmlText);
141
+ } catch {
142
+ diagnostics.push({
143
+ code: "corrupt-part",
144
+ category: "corrupt-input",
145
+ disposition: "omitted",
146
+ location: {
147
+ part: notesPartPath,
148
+ slideIndex
149
+ }
150
+ });
151
+ return { diagnostics };
152
+ }
153
+ if ((notesEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main" || (notesEl.localName ?? notesEl.tagName) !== "notes") {
154
+ diagnostics.push({
155
+ code: "corrupt-part",
156
+ category: "corrupt-input",
157
+ disposition: "omitted",
158
+ location: {
159
+ part: notesPartPath,
160
+ slideIndex
161
+ }
162
+ });
163
+ return { diagnostics };
164
+ }
165
+ const notesRels = pkg.readRelationships(notesPartPath);
166
+ diagnostics.push(...notesRels.diagnostics);
167
+ const notesCursor = XmlElementCursor.createRoot(notesEl, notesPartPath, "/p:notes");
168
+ const rawRootAttrs = notesCursor.attrsObject(["showMasterSp", "showMasterPhAnim"]);
169
+ if (!notesRootAttrsXmlSchema.safeParse(rawRootAttrs).success) diagnostics.push({
170
+ code: "invalid-xml-value",
171
+ category: "corrupt-input",
172
+ disposition: "recovered",
173
+ location: {
174
+ part: notesPartPath,
175
+ xpath: notesCursor.xpath,
176
+ slideIndex
177
+ },
178
+ attributeOrElement: "p:notes",
179
+ rawValue: JSON.stringify(rawRootAttrs)
180
+ });
181
+ const clrMapOvr = notesCursor.child(P_NS, "clrMapOvr");
182
+ if (clrMapOvr !== void 0) clrMapOvr.ignoreEmptyChild(A_NS, "masterClrMapping");
183
+ const cSld = notesCursor.child(P_NS, "cSld");
184
+ if (cSld === void 0) {
185
+ diagnostics.push({
186
+ code: "corrupt-part",
187
+ category: "corrupt-input",
188
+ disposition: "omitted",
189
+ location: {
190
+ part: notesPartPath,
191
+ xpath: notesCursor.xpath,
192
+ slideIndex
193
+ }
194
+ });
195
+ return { diagnostics };
196
+ }
197
+ cSld.consumeAttr("name");
198
+ consumeNotesCreationIdExtLst(cSld);
199
+ const spTree = cSld.child(P_NS, "spTree");
200
+ if (spTree !== void 0) {
201
+ consumeIdentityShapeTreeBoilerplate(spTree);
202
+ let importedNotesBody = false;
203
+ for (const item of spTree.remainingElementChildren()) {
204
+ if (item.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && item.localName === "sp") {
205
+ const info = readNotesPlaceholderInfo(item, notesPartPath, slideIndex, diagnostics);
206
+ if (info.phType === "body" && !importedNotesBody) {
207
+ importedNotesBody = true;
208
+ const spPr = item.child(P_NS, "spPr");
209
+ if (spPr !== void 0) consumeNotesBodyShapeProperties(spPr);
210
+ const txBody = item.child(P_NS, "txBody");
211
+ if (txBody !== void 0) {
212
+ const { boxStyle, importedParagraphs } = readRichTextBody(txBody, notesPartPath, slideIndex, diagnostics);
213
+ const notesStyle = {};
214
+ const boxRecord = boxStyle;
215
+ for (const key of textStyleKeys) if (Object.hasOwn(boxRecord, key) && boxRecord[key] !== void 0) notesStyle[key] = boxRecord[key];
216
+ const hasNotesStyle = Object.keys(notesStyle).length > 0;
217
+ if (!(!hasNotesStyle && (importedParagraphs.length === 0 || importedParagraphs.length === 1 && importedParagraphs[0].runs.length === 0 && Object.keys(importedParagraphs[0].style).length === 0))) {
218
+ const notesNode = createNotesNode(hasNotesStyle ? { style: notesStyle } : {});
219
+ populateRichTextNode(notesNode, importedParagraphs);
220
+ if (slideNode instanceof CommonContainer) slideNode.append(notesNode);
221
+ }
222
+ }
223
+ continue;
224
+ }
225
+ if (info.phType !== void 0 && baselineNotesSlidePlaceholders.has(info.phType)) {
226
+ item.suppressUnconsumed();
227
+ continue;
228
+ }
229
+ }
230
+ const identity = peekShapeTreeObjectIdentity(item.element);
231
+ diagnostics.push({
232
+ code: "unsupported-mechanism",
233
+ category: "unsupported",
234
+ disposition: "omitted",
235
+ location: {
236
+ part: notesPartPath,
237
+ xpath: item.xpath,
238
+ slideIndex,
239
+ ...identity
240
+ },
241
+ namespaceUri: item.namespaceUri,
242
+ localName: item.localName,
243
+ mechanismHint: "notes-slide-custom-object",
244
+ loss: {
245
+ lost: "custom-print-layout",
246
+ retainedAs: "notes-body-only"
247
+ }
248
+ });
249
+ item.suppressUnconsumed();
250
+ }
251
+ }
252
+ appendUnconsumedDiagnostics(notesCursor, slideIndex, diagnostics);
253
+ return diagnostics.length === 0 ? {} : { diagnostics };
254
+ }
255
+ };
256
+ /**
257
+ * Deck-level import handler for `presentation-sections` (`<p14:sectionLst>`).
258
+ *
259
+ * When invoked inside `createImporter`, `importPresentationSections` has already grouped
260
+ * slides into `SectionNode`s; this handler remains idempotent and also supports standalone
261
+ * mechanism calls against an ungrouped `DeckContainer`.
262
+ */
263
+ const presentationSectionsImportHandler = {
264
+ target: "deck",
265
+ stage: "post-slides",
266
+ read(context) {
267
+ const { presentationCursor, deckNode, package: pkg, slideNodeByPresentationSldId } = context;
268
+ if (deckNode.children.some((child) => child instanceof CommonNode && child.type === "section")) return {};
269
+ let slideNodeBySldId = slideNodeByPresentationSldId;
270
+ if (slideNodeBySldId === void 0) {
271
+ const fallbackMap = /* @__PURE__ */ new Map();
272
+ const slideNodes = deckNode.children.filter((child) => child instanceof CommonNode && child.type === "slide");
273
+ const sldIdLst = presentationCursor.child(P_NS, "sldIdLst");
274
+ if (sldIdLst !== void 0) {
275
+ const sldIds = sldIdLst.children(P_NS, "sldId");
276
+ for (let index = 0; index < sldIds.length; index += 1) {
277
+ const rawId = sldIds[index]?.attr("id");
278
+ const slideNode = slideNodes[index];
279
+ if (rawId !== void 0 && slideNode !== void 0) {
280
+ const parsedId = Number(rawId);
281
+ if (Number.isInteger(parsedId)) fallbackMap.set(parsedId, slideNode);
282
+ }
283
+ }
284
+ }
285
+ slideNodeBySldId = fallbackMap;
286
+ }
287
+ const diagnostics = [];
288
+ importPresentationSections(presentationCursor, deckNode, slideNodeBySldId, pkg.presentationPath, diagnostics);
289
+ return diagnostics.length === 0 ? {} : { diagnostics };
290
+ }
291
+ };
292
+ export { presentationSectionsImportHandler, speakerNotesImportHandler };
@@ -0,0 +1,35 @@
1
+ import { authorIdSchema } from "../../../core/dist/author-ids.js";
2
+ import { textStyleSchema } from "../../../core/dist/theme.js";
3
+ import "../../../core/dist/capability.js";
4
+ import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../../import/dist/xml-fragments.js";
5
+ import "../../../import/dist/index.js";
6
+ import { z } from "zod";
7
+ // ../capabilities/dist/notes/notes-schemas.js
8
+ /** Pure-data Zod v4 contract for page-affiliated speaker notes declarations (`Notes` / `notes()`). */
9
+ const notesDeclarationPropsSchema = z.strictObject({
10
+ id: authorIdSchema.optional(),
11
+ style: textStyleSchema.optional()
12
+ }).readonly();
13
+ /** Validates `<p:notes>` root attributes in Transitional OOXML. */
14
+ const notesRootAttrsXmlSchema = z.object({
15
+ showMasterSp: ooxmlBoolSchema.optional(),
16
+ showMasterPhAnim: ooxmlBoolSchema.optional()
17
+ });
18
+ /** Validates `<p:cNvPr>` attributes inside notes slide shapes. */
19
+ const notesShapeIdentityXmlSchema = z.object({
20
+ id: ooxmlNonNegativeIntSchema,
21
+ name: z.string().optional()
22
+ });
23
+ /** Validates `<p:ph>` placeholder attributes inside notes slides. */
24
+ const notesPlaceholderXmlSchema = z.object({
25
+ type: z.string().optional(),
26
+ idx: ooxmlNonNegativeIntSchema.optional(),
27
+ sz: z.enum([
28
+ "full",
29
+ "half",
30
+ "quarter"
31
+ ]).optional(),
32
+ orient: z.enum(["horz", "vert"]).optional(),
33
+ hasCustomPrompt: ooxmlBoolSchema.optional()
34
+ });
35
+ export { notesDeclarationPropsSchema, notesPlaceholderXmlSchema, notesRootAttrsXmlSchema, notesShapeIdentityXmlSchema };
@@ -0,0 +1,38 @@
1
+ import { xmlDocument } from "../../../emit/dist/ooxml.js";
2
+ import "../../../emit/dist/index.js";
3
+ // ../capabilities/dist/notes/notes-xml.js
4
+ const drawingNamespace = "http://schemas.openxmlformats.org/drawingml/2006/main";
5
+ const presentationNamespace = "http://schemas.openxmlformats.org/presentationml/2006/main";
6
+ const relationshipNamespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
7
+ const notesMasterContentType = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
8
+ const notesSlideContentType = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
9
+ const themeContentType = "application/vnd.openxmlformats-officedocument.theme+xml";
10
+ const notesMasterRelationshipType = `${relationshipNamespace}/notesMaster`;
11
+ const notesSlideRelationshipType = `${relationshipNamespace}/notesSlide`;
12
+ const themeRelationshipType = `${relationshipNamespace}/theme`;
13
+ const slideRelationshipType = `${relationshipNamespace}/slide`;
14
+ const notesMasterPathTemplate = "ppt/notesMasters/notesMaster{n}.xml";
15
+ const notesSlidePathTemplate = "ppt/notesSlides/notesSlide{n}.xml";
16
+ const themePathTemplate = "ppt/theme/theme{n}.xml";
17
+ const colorMap = "<p:clrMap bg1=\"lt1\" tx1=\"dk1\" bg2=\"lt2\" tx2=\"dk2\" accent1=\"accent1\" accent2=\"accent2\" accent3=\"accent3\" accent4=\"accent4\" accent5=\"accent5\" accent6=\"accent6\" hlink=\"hlink\" folHlink=\"folHlink\"/>";
18
+ function groupShapeTree(shapes) {
19
+ return `<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>${shapes}`;
20
+ }
21
+ /**
22
+ * Shared notes master for one deck.
23
+ *
24
+ * The master is intentionally fixed rather than author-composed: it supplies the slide-image and
25
+ * body placeholders plus the notes text defaults, while the page's notes body carries the actual
26
+ * rich-text content. Its theme relationship targets a notes-owned theme part with the deck theme
27
+ * values, so the notes master never shares the slide master's theme part.
28
+ */
29
+ function notesMasterXml() {
30
+ return xmlDocument(`<p:notesMaster xmlns:a="${drawingNamespace}" xmlns:r="${relationshipNamespace}" xmlns:p="${presentationNamespace}"><p:cSld><p:bg><p:bgRef idx="1001"><a:schemeClr val="bg1"/></p:bgRef></p:bg><p:spTree>${groupShapeTree("<p:sp><p:nvSpPr><p:cNvPr id=\"2\" name=\"Slide Image Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\" noRot=\"1\" noChangeAspect=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldImg\" idx=\"2\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"685800\" y=\"1143000\"/><a:ext cx=\"5486400\" cy=\"3086100\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom><a:noFill/><a:ln><a:noFill/></a:ln></p:spPr></p:sp><p:sp><p:nvSpPr><p:cNvPr id=\"3\" name=\"Notes Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"body\" idx=\"1\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"685800\" y=\"4400550\"/><a:ext cx=\"5486400\" cy=\"3600450\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\" sz=\"1200\"/></a:p></p:txBody></p:sp>")}</p:spTree></p:cSld>${colorMap}<p:notesStyle><a:lvl1pPr><a:defRPr sz="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/></a:defRPr></a:lvl1pPr></p:notesStyle></p:notesMaster>`);
31
+ }
32
+ /** One notes slide body placeholder containing the parsed notes rich text. */
33
+ function notesSlideXml(textBody) {
34
+ const slideImage = "<p:sp><p:nvSpPr><p:cNvPr id=\"2\" name=\"Slide Image Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\" noRot=\"1\" noChangeAspect=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldImg\"/></p:nvPr></p:nvSpPr><p:spPr/></p:sp>";
35
+ const body = `<p:sp><p:nvSpPr><p:cNvPr id="3" name="Notes Placeholder 2"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr/>${textBody}</p:sp>`;
36
+ return xmlDocument(`<p:notes xmlns:a="${drawingNamespace}" xmlns:r="${relationshipNamespace}" xmlns:p="${presentationNamespace}"><p:cSld><p:spTree>${groupShapeTree(slideImage + body)}</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:notes>`);
37
+ }
38
+ export { notesMasterContentType, notesMasterPathTemplate, notesMasterRelationshipType, notesMasterXml, notesSlideContentType, notesSlidePathTemplate, notesSlideRelationshipType, notesSlideXml, slideRelationshipType, themeContentType, themePathTemplate, themeRelationshipType };
@@ -0,0 +1,191 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import "../../../core/dist/capability.js";
3
+ import { sectionListXml, themeXml, xmlEscape } from "../../../emit/dist/ooxml.js";
4
+ import "../../../emit/dist/index.js";
5
+ import { defineShowMechanism } from "../../../import/dist/mechanism.js";
6
+ import "../../../import/dist/index.js";
7
+ import { emitTextBody, parseTextContent, resolveTextBody } from "../shared/text-service.js";
8
+ import { notesCodegen } from "./notes-codegen.js";
9
+ import { presentationSectionsImportHandler, speakerNotesImportHandler } from "./notes-import.js";
10
+ import { notesDeclarationPropsSchema } from "./notes-schemas.js";
11
+ import { notesMasterContentType, notesMasterPathTemplate, notesMasterRelationshipType, notesMasterXml, notesSlideContentType, notesSlidePathTemplate, notesSlideRelationshipType, notesSlideXml, slideRelationshipType, themeContentType, themePathTemplate, themeRelationshipType } from "./notes-xml.js";
12
+ // ../capabilities/dist/notes/notes.js
13
+ /**
14
+ * Notes text defaults are independent of slide projection styles.
15
+ *
16
+ * Colors and font tokens still resolve through the owning page theme; the inherited projection
17
+ * text defaults are replaced instead of being overridden property by property.
18
+ */
19
+ const notesDefaultTextStyle = Object.freeze({
20
+ fontFamily: "minor",
21
+ fontSize: "12pt",
22
+ fontWeight: "normal",
23
+ fontStyle: "normal",
24
+ color: "dk1",
25
+ verticalAlign: "top",
26
+ align: "left",
27
+ spacingAfter: 0,
28
+ letterSpacing: 0,
29
+ textTransform: "none",
30
+ textDecoration: "none",
31
+ textShadow: "none",
32
+ textWrap: "normal"
33
+ });
34
+ const boundNotesEntries = /* @__PURE__ */ new WeakMap();
35
+ function parseNotes(input, pageTheme, slideNumber) {
36
+ const parsedProps = notesDeclarationPropsSchema.safeParse(input.props);
37
+ if (!parsedProps.success) {
38
+ const issue = parsedProps.error.issues[0];
39
+ if (issue?.code === "unrecognized_keys" && issue.path.length === 0) throw new CapabilityError("unknown-parameter", `Notes contains unsupported parameter ${issue.keys[0]}`);
40
+ if (issue?.path[0] === "id") throw new CapabilityError("invalid-notes", "Notes.id must be a string");
41
+ }
42
+ const theme = pageTheme.withTextStyle(notesDefaultTextStyle);
43
+ return {
44
+ ...parseTextContent(input.children, input.props["style"], theme, { slideNumber }, "Notes.style"),
45
+ theme
46
+ };
47
+ }
48
+ function emitSpeakerNotes(model, emitContext) {
49
+ const embedFonts = emitContext.options.embedFonts;
50
+ const body = emitTextBody(model.resolvedBody, model.entryTheme, {
51
+ createFieldId: emitContext.createTextFieldId,
52
+ ...embedFonts === void 0 ? {} : { embedFonts }
53
+ });
54
+ emitContext.registerSharedPart("notes-theme", {
55
+ part: {
56
+ pathTemplate: themePathTemplate,
57
+ contentType: themeContentType
58
+ },
59
+ content: () => themeXml(emitContext.theme.theme)
60
+ });
61
+ emitContext.registerSharedPart("notes-master", {
62
+ part: {
63
+ pathTemplate: notesMasterPathTemplate,
64
+ contentType: notesMasterContentType
65
+ },
66
+ presentationRelationshipType: notesMasterRelationshipType,
67
+ relationships: [{
68
+ relationshipType: themeRelationshipType,
69
+ target: {
70
+ kind: "part",
71
+ key: "notes-theme"
72
+ }
73
+ }],
74
+ presentationElement: {
75
+ position: "before-slides",
76
+ content: (relationshipId) => `<p:notesMasterIdLst><p:notesMasterId r:id="${xmlEscape(relationshipId)}"/></p:notesMasterIdLst>`
77
+ },
78
+ content: () => notesMasterXml()
79
+ });
80
+ emitContext.registerPackagePart({
81
+ part: {
82
+ pathTemplate: notesSlidePathTemplate,
83
+ contentType: notesSlideContentType
84
+ },
85
+ slideRelationshipType: notesSlideRelationshipType,
86
+ relationships: [{
87
+ relationshipType: slideRelationshipType,
88
+ target: { kind: "slide" }
89
+ }, {
90
+ relationshipType: notesMasterRelationshipType,
91
+ target: {
92
+ kind: "part",
93
+ key: "notes-master"
94
+ }
95
+ }],
96
+ content: () => notesSlideXml(body.xml)
97
+ });
98
+ return {
99
+ xml: "",
100
+ ...body.presentationContributions.length === 0 ? {} : { presentationContributions: body.presentationContributions }
101
+ };
102
+ }
103
+ /** Typed native show mechanism connecting emit and import for `speaker-notes`. */
104
+ const speakerNotesMechanism = defineShowMechanism({
105
+ key: "speaker-notes",
106
+ role: "show",
107
+ emit: emitSpeakerNotes,
108
+ import: speakerNotesImportHandler
109
+ });
110
+ /** Typed native show mechanism connecting emit and import for `presentation-sections`. */
111
+ const presentationSectionsMechanism = defineShowMechanism({
112
+ key: "presentation-sections",
113
+ role: "show",
114
+ emit: (model) => ({ xml: sectionListXml(model.sections) }),
115
+ import: presentationSectionsImportHandler
116
+ });
117
+ function notesObservation(text, paragraphs) {
118
+ return {
119
+ text,
120
+ paragraphCount: paragraphs.length
121
+ };
122
+ }
123
+ /**
124
+ * Page-affiliated rich-text notes capability.
125
+ *
126
+ * The visible slide tree never contains the notes body: core treats the declaration subtree as
127
+ * owned by this module, while this module parses the shared P/Span content once into an opaque
128
+ * per-build binding, resolves text metrics and resource claims during resolve, and emits the notes
129
+ * part, body placeholder, notes master, relationships, and font resources during emit. Notes has
130
+ * no canvas geometry or static slide preview layer.
131
+ */
132
+ const notesCapability = Object.freeze({
133
+ declaration: "notes",
134
+ slideProp: "notes",
135
+ slideProps: [],
136
+ slot: "timing",
137
+ always: true,
138
+ codegen: notesCodegen,
139
+ mechanisms: [speakerNotesMechanism, presentationSectionsMechanism],
140
+ bindSections(sections) {
141
+ return {
142
+ extensions: ["p14"],
143
+ emit: () => presentationSectionsMechanism.emit({ sections })
144
+ };
145
+ },
146
+ transparentDeclarations: [{
147
+ declaration: "notes",
148
+ children: "owned",
149
+ compileDeclaration(input, context) {
150
+ if (context.theme === void 0 || context.slideNumber === void 0) throw new CapabilityError("invalid-notes", "Notes declaration requires slide theme and number context");
151
+ const entry = parseNotes(input, context.theme, context.slideNumber);
152
+ const token = Object.freeze({});
153
+ boundNotesEntries.set(token, entry);
154
+ return [{
155
+ capability: "notes",
156
+ value: token
157
+ }];
158
+ }
159
+ }],
160
+ bindSlide(_input, parseContext) {
161
+ const contributions = parseContext.contributions.filter((contribution) => contribution.capability === "notes");
162
+ if (contributions.length === 0) return { resolveSlide() {
163
+ return {
164
+ extensions: [],
165
+ emit() {
166
+ return { xml: "" };
167
+ }
168
+ };
169
+ } };
170
+ if (contributions.length > 1) throw new CapabilityError("duplicate-notes", "A slide can declare at most one Notes", contributions[1].path);
171
+ const contribution = contributions[0];
172
+ const entry = typeof contribution.value === "object" && contribution.value !== null ? boundNotesEntries.get(contribution.value) : void 0;
173
+ if (entry === void 0) throw new CapabilityError("invalid-notes", "Notes declaration is missing its bound content", contribution.path);
174
+ return { resolveSlide() {
175
+ const resolvedBody = resolveTextBody(entry.paragraphs, entry.style, entry.theme, "top", void 0, "text-box");
176
+ return {
177
+ observation: notesObservation(resolvedBody.text, entry.paragraphs),
178
+ extensions: [],
179
+ resourceClaims: resolvedBody.resourceClaims,
180
+ ...resolvedBody.warnings.length === 0 ? {} : { warnings: resolvedBody.warnings },
181
+ emit(emitContext) {
182
+ return speakerNotesMechanism.emit({
183
+ resolvedBody,
184
+ entryTheme: entry.theme
185
+ }, emitContext);
186
+ }
187
+ };
188
+ } };
189
+ }
190
+ });
191
+ export { notesCapability, presentationSectionsMechanism, speakerNotesMechanism };
@@ -0,0 +1,23 @@
1
+ import { defineObjectCodegen } from "../../../codegen/dist/types.js";
2
+ import "../../../codegen/dist/index.js";
3
+ // ../capabilities/dist/placeholder/placeholder-codegen.js
4
+ function collectPlaceholderProps(node, ctx) {
5
+ if (node.children.length > 0) return ctx.fail("unexpressible-value", "Unpopulated placeholder cannot contain children");
6
+ const entries = [];
7
+ for (const [key, value] of Object.entries(node.props)) if (value !== void 0) entries.push([key, value]);
8
+ return entries;
9
+ }
10
+ /** Source codegen contribution for unpopulated `placeholder` declarations. */
11
+ const placeholderCodegen = defineObjectCodegen({ declarations: { placeholder: {
12
+ emitVanilla: (node, ctx) => {
13
+ const callee = ctx.useImport("placeholder");
14
+ const propsEntries = collectPlaceholderProps(node, ctx);
15
+ return propsEntries.length === 0 ? ctx.formatVanillaCall(callee, []) : ctx.formatVanillaCall(callee, [ctx.formatProps(propsEntries)]);
16
+ },
17
+ emitReact: (node, ctx) => {
18
+ const tag = ctx.useImport("Placeholder");
19
+ const propsEntries = collectPlaceholderProps(node, ctx);
20
+ return ctx.formatJsxElement(tag, propsEntries);
21
+ }
22
+ } } });
23
+ export { placeholderCodegen };
@@ -0,0 +1,12 @@
1
+ import { hostNodeCreator } from "../../../core/dist/host.js";
2
+ import { createPlaceholderNode } from "./placeholder.js";
3
+ import { createElement } from "react";
4
+ // ../capabilities/dist/placeholder/placeholder-elements.js
5
+ /** Declares an unpopulated native content placeholder bound to a layout placeholder slot. */
6
+ function Placeholder(props) {
7
+ return createElement("placeholder", {
8
+ ...props,
9
+ [hostNodeCreator]: createPlaceholderNode
10
+ });
11
+ }
12
+ export { Placeholder };