pptx-templates 0.0.0-stage → 0.1.1

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 (323) hide show
  1. package/AI-INSTRUCTOR.md +2253 -0
  2. package/CHANGELOG.md +56 -0
  3. package/LICENSE +23 -0
  4. package/README.md +84 -2
  5. package/dist/automizer.d.ts +224 -0
  6. package/dist/automizer.js +704 -0
  7. package/dist/automizer.js.map +1 -0
  8. package/dist/classes/content-type-registry.d.ts +46 -0
  9. package/dist/classes/content-type-registry.js +170 -0
  10. package/dist/classes/content-type-registry.js.map +1 -0
  11. package/dist/classes/element-importer.d.ts +49 -0
  12. package/dist/classes/element-importer.js +254 -0
  13. package/dist/classes/element-importer.js.map +1 -0
  14. package/dist/classes/has-shapes.d.ts +286 -0
  15. package/dist/classes/has-shapes.js +385 -0
  16. package/dist/classes/has-shapes.js.map +1 -0
  17. package/dist/classes/layout.d.ts +42 -0
  18. package/dist/classes/layout.js +113 -0
  19. package/dist/classes/layout.js.map +1 -0
  20. package/dist/classes/master.d.ts +45 -0
  21. package/dist/classes/master.js +146 -0
  22. package/dist/classes/master.js.map +1 -0
  23. package/dist/classes/placeholder-normalizer.d.ts +42 -0
  24. package/dist/classes/placeholder-normalizer.js +136 -0
  25. package/dist/classes/placeholder-normalizer.js.map +1 -0
  26. package/dist/classes/related-content-copier.d.ts +18 -0
  27. package/dist/classes/related-content-copier.js +114 -0
  28. package/dist/classes/related-content-copier.js.map +1 -0
  29. package/dist/classes/shape.d.ts +62 -0
  30. package/dist/classes/shape.js +194 -0
  31. package/dist/classes/shape.js.map +1 -0
  32. package/dist/classes/slide-master-remover.d.ts +44 -0
  33. package/dist/classes/slide-master-remover.js +201 -0
  34. package/dist/classes/slide-master-remover.js.map +1 -0
  35. package/dist/classes/slide-notes-copier.d.ts +26 -0
  36. package/dist/classes/slide-notes-copier.js +76 -0
  37. package/dist/classes/slide-notes-copier.js.map +1 -0
  38. package/dist/classes/slide.d.ts +91 -0
  39. package/dist/classes/slide.js +286 -0
  40. package/dist/classes/slide.js.map +1 -0
  41. package/dist/classes/template.d.ts +137 -0
  42. package/dist/classes/template.js +311 -0
  43. package/dist/classes/template.js.map +1 -0
  44. package/dist/constants/constants.d.ts +11 -0
  45. package/dist/constants/constants.js +182 -0
  46. package/dist/constants/constants.js.map +1 -0
  47. package/dist/enums/chart-type.d.ts +11 -0
  48. package/dist/enums/chart-type.js +16 -0
  49. package/dist/enums/chart-type.js.map +1 -0
  50. package/dist/enums/content-type-map.d.ts +16 -0
  51. package/dist/enums/content-type-map.js +23 -0
  52. package/dist/enums/content-type-map.js.map +1 -0
  53. package/dist/enums/element-type.d.ts +14 -0
  54. package/dist/enums/element-type.js +20 -0
  55. package/dist/enums/element-type.js.map +1 -0
  56. package/dist/errors.d.ts +81 -0
  57. package/dist/errors.js +100 -0
  58. package/dist/errors.js.map +1 -0
  59. package/dist/extensions/index.d.ts +5 -0
  60. package/dist/extensions/index.js +31 -0
  61. package/dist/extensions/index.js.map +1 -0
  62. package/dist/extensions/pptxgenjs-compat/img-broken-png.d.ts +5 -0
  63. package/dist/extensions/pptxgenjs-compat/img-broken-png.js +9 -0
  64. package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -0
  65. package/dist/extensions/pptxgenjs-compat/index.d.ts +5 -0
  66. package/dist/extensions/pptxgenjs-compat/index.js +10 -0
  67. package/dist/extensions/pptxgenjs-compat/index.js.map +1 -0
  68. package/dist/extensions/pptxgenjs-compat/svg-fallback.d.ts +14 -0
  69. package/dist/extensions/pptxgenjs-compat/svg-fallback.js +139 -0
  70. package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -0
  71. package/dist/extensions/run-merge/index.d.ts +13 -0
  72. package/dist/extensions/run-merge/index.js +89 -0
  73. package/dist/extensions/run-merge/index.js.map +1 -0
  74. package/dist/extensions/template-logic/commands.d.ts +22 -0
  75. package/dist/extensions/template-logic/commands.js +83 -0
  76. package/dist/extensions/template-logic/commands.js.map +1 -0
  77. package/dist/extensions/template-logic/expression.d.ts +61 -0
  78. package/dist/extensions/template-logic/expression.js +499 -0
  79. package/dist/extensions/template-logic/expression.js.map +1 -0
  80. package/dist/extensions/template-logic/images.d.ts +26 -0
  81. package/dist/extensions/template-logic/images.js +183 -0
  82. package/dist/extensions/template-logic/images.js.map +1 -0
  83. package/dist/extensions/template-logic/index.d.ts +14 -0
  84. package/dist/extensions/template-logic/index.js +64 -0
  85. package/dist/extensions/template-logic/index.js.map +1 -0
  86. package/dist/extensions/template-logic/list-commands.d.ts +9 -0
  87. package/dist/extensions/template-logic/list-commands.js +72 -0
  88. package/dist/extensions/template-logic/list-commands.js.map +1 -0
  89. package/dist/extensions/template-logic/renderer.d.ts +85 -0
  90. package/dist/extensions/template-logic/renderer.js +867 -0
  91. package/dist/extensions/template-logic/renderer.js.map +1 -0
  92. package/dist/extensions/template-logic/types.d.ts +62 -0
  93. package/dist/extensions/template-logic/types.js +3 -0
  94. package/dist/extensions/template-logic/types.js.map +1 -0
  95. package/dist/helper/archive/archive-fs.d.ts +45 -0
  96. package/dist/helper/archive/archive-fs.js +206 -0
  97. package/dist/helper/archive/archive-fs.js.map +1 -0
  98. package/dist/helper/archive/archive-jszip.d.ts +31 -0
  99. package/dist/helper/archive/archive-jszip.js +173 -0
  100. package/dist/helper/archive/archive-jszip.js.map +1 -0
  101. package/dist/helper/archive/archive.d.ts +27 -0
  102. package/dist/helper/archive/archive.js +78 -0
  103. package/dist/helper/archive/archive.js.map +1 -0
  104. package/dist/helper/cell-id-helper.d.ts +25 -0
  105. package/dist/helper/cell-id-helper.js +95 -0
  106. package/dist/helper/cell-id-helper.js.map +1 -0
  107. package/dist/helper/compute-src-rect.d.ts +9 -0
  108. package/dist/helper/compute-src-rect.js +52 -0
  109. package/dist/helper/compute-src-rect.js.map +1 -0
  110. package/dist/helper/content-tracker.d.ts +31 -0
  111. package/dist/helper/content-tracker.js +227 -0
  112. package/dist/helper/content-tracker.js.map +1 -0
  113. package/dist/helper/count-helper.d.ts +33 -0
  114. package/dist/helper/count-helper.js +140 -0
  115. package/dist/helper/count-helper.js.map +1 -0
  116. package/dist/helper/css-style-parser.d.ts +52 -0
  117. package/dist/helper/css-style-parser.js +246 -0
  118. package/dist/helper/css-style-parser.js.map +1 -0
  119. package/dist/helper/file-helper.d.ts +36 -0
  120. package/dist/helper/file-helper.js +150 -0
  121. package/dist/helper/file-helper.js.map +1 -0
  122. package/dist/helper/general-helper.d.ts +6 -0
  123. package/dist/helper/general-helper.js +34 -0
  124. package/dist/helper/general-helper.js.map +1 -0
  125. package/dist/helper/generate/generate-pptxgenjs.d.ts +37 -0
  126. package/dist/helper/generate/generate-pptxgenjs.js +134 -0
  127. package/dist/helper/generate/generate-pptxgenjs.js.map +1 -0
  128. package/dist/helper/html-to-multitext-helper.d.ts +84 -0
  129. package/dist/helper/html-to-multitext-helper.js +490 -0
  130. package/dist/helper/html-to-multitext-helper.js.map +1 -0
  131. package/dist/helper/hyperlink-processor.d.ts +54 -0
  132. package/dist/helper/hyperlink-processor.js +289 -0
  133. package/dist/helper/hyperlink-processor.js.map +1 -0
  134. package/dist/helper/image-dimensions.d.ts +21 -0
  135. package/dist/helper/image-dimensions.js +202 -0
  136. package/dist/helper/image-dimensions.js.map +1 -0
  137. package/dist/helper/jszip-helper.d.ts +21 -0
  138. package/dist/helper/jszip-helper.js +162 -0
  139. package/dist/helper/jszip-helper.js.map +1 -0
  140. package/dist/helper/layout-index.d.ts +55 -0
  141. package/dist/helper/layout-index.js +155 -0
  142. package/dist/helper/layout-index.js.map +1 -0
  143. package/dist/helper/logger.d.ts +53 -0
  144. package/dist/helper/logger.js +73 -0
  145. package/dist/helper/logger.js.map +1 -0
  146. package/dist/helper/media-deduplicator.d.ts +42 -0
  147. package/dist/helper/media-deduplicator.js +88 -0
  148. package/dist/helper/media-deduplicator.js.map +1 -0
  149. package/dist/helper/modify-background-helper.d.ts +19 -0
  150. package/dist/helper/modify-background-helper.js +59 -0
  151. package/dist/helper/modify-background-helper.js.map +1 -0
  152. package/dist/helper/modify-chart-helper.d.ts +159 -0
  153. package/dist/helper/modify-chart-helper.js +642 -0
  154. package/dist/helper/modify-chart-helper.js.map +1 -0
  155. package/dist/helper/modify-cleanup-helper.d.ts +69 -0
  156. package/dist/helper/modify-cleanup-helper.js +343 -0
  157. package/dist/helper/modify-cleanup-helper.js.map +1 -0
  158. package/dist/helper/modify-color-helper.d.ts +35 -0
  159. package/dist/helper/modify-color-helper.js +211 -0
  160. package/dist/helper/modify-color-helper.js.map +1 -0
  161. package/dist/helper/modify-helper.d.ts +23 -0
  162. package/dist/helper/modify-helper.js +61 -0
  163. package/dist/helper/modify-helper.js.map +1 -0
  164. package/dist/helper/modify-hyperlink-element.d.ts +9 -0
  165. package/dist/helper/modify-hyperlink-element.js +34 -0
  166. package/dist/helper/modify-hyperlink-element.js.map +1 -0
  167. package/dist/helper/modify-hyperlink-helper.d.ts +42 -0
  168. package/dist/helper/modify-hyperlink-helper.js +258 -0
  169. package/dist/helper/modify-hyperlink-helper.js.map +1 -0
  170. package/dist/helper/modify-image-helper.d.ts +23 -0
  171. package/dist/helper/modify-image-helper.js +157 -0
  172. package/dist/helper/modify-image-helper.js.map +1 -0
  173. package/dist/helper/modify-presentation-helper.d.ts +55 -0
  174. package/dist/helper/modify-presentation-helper.js +177 -0
  175. package/dist/helper/modify-presentation-helper.js.map +1 -0
  176. package/dist/helper/modify-shape-helper.d.ts +111 -0
  177. package/dist/helper/modify-shape-helper.js +340 -0
  178. package/dist/helper/modify-shape-helper.js.map +1 -0
  179. package/dist/helper/modify-table-helper.d.ts +11 -0
  180. package/dist/helper/modify-table-helper.js +100 -0
  181. package/dist/helper/modify-table-helper.js.map +1 -0
  182. package/dist/helper/modify-text-helper.d.ts +62 -0
  183. package/dist/helper/modify-text-helper.js +244 -0
  184. package/dist/helper/modify-text-helper.js.map +1 -0
  185. package/dist/helper/modify-xml-helper.d.ts +52 -0
  186. package/dist/helper/modify-xml-helper.js +305 -0
  187. package/dist/helper/modify-xml-helper.js.map +1 -0
  188. package/dist/helper/multitext-helper.d.ts +116 -0
  189. package/dist/helper/multitext-helper.js +462 -0
  190. package/dist/helper/multitext-helper.js.map +1 -0
  191. package/dist/helper/ppt-paths.d.ts +76 -0
  192. package/dist/helper/ppt-paths.js +116 -0
  193. package/dist/helper/ppt-paths.js.map +1 -0
  194. package/dist/helper/shape-type-detector.d.ts +34 -0
  195. package/dist/helper/shape-type-detector.js +99 -0
  196. package/dist/helper/shape-type-detector.js.map +1 -0
  197. package/dist/helper/text-replace-helper.d.ts +30 -0
  198. package/dist/helper/text-replace-helper.js +149 -0
  199. package/dist/helper/text-replace-helper.js.map +1 -0
  200. package/dist/helper/xml/lnLRTB.d.ts +1 -0
  201. package/dist/helper/xml/lnLRTB.js +62 -0
  202. package/dist/helper/xml/lnLRTB.js.map +1 -0
  203. package/dist/helper/xml/prstGeom.d.ts +1 -0
  204. package/dist/helper/xml/prstGeom.js +11 -0
  205. package/dist/helper/xml/prstGeom.js.map +1 -0
  206. package/dist/helper/xml-elements.d.ts +134 -0
  207. package/dist/helper/xml-elements.js +538 -0
  208. package/dist/helper/xml-elements.js.map +1 -0
  209. package/dist/helper/xml-helper.d.ts +120 -0
  210. package/dist/helper/xml-helper.js +495 -0
  211. package/dist/helper/xml-helper.js.map +1 -0
  212. package/dist/helper/xml-placeholder-helper.d.ts +92 -0
  213. package/dist/helper/xml-placeholder-helper.js +454 -0
  214. package/dist/helper/xml-placeholder-helper.js.map +1 -0
  215. package/dist/helper/xml-pretty-print.d.ts +17 -0
  216. package/dist/helper/xml-pretty-print.js +88 -0
  217. package/dist/helper/xml-pretty-print.js.map +1 -0
  218. package/dist/helper/xml-relationship-helper.d.ts +103 -0
  219. package/dist/helper/xml-relationship-helper.js +397 -0
  220. package/dist/helper/xml-relationship-helper.js.map +1 -0
  221. package/dist/helper/xml-slide-helper.d.ts +107 -0
  222. package/dist/helper/xml-slide-helper.js +676 -0
  223. package/dist/helper/xml-slide-helper.js.map +1 -0
  224. package/dist/helper/xml-template-helper.d.ts +42 -0
  225. package/dist/helper/xml-template-helper.js +252 -0
  226. package/dist/helper/xml-template-helper.js.map +1 -0
  227. package/dist/helper/xmldom-sax-patch.d.ts +18 -0
  228. package/dist/helper/xmldom-sax-patch.js +58 -0
  229. package/dist/helper/xmldom-sax-patch.js.map +1 -0
  230. package/dist/index.d.ts +81 -0
  231. package/dist/index.js +177 -0
  232. package/dist/index.js.map +1 -0
  233. package/dist/interfaces/iarchive.d.ts +43 -0
  234. package/dist/interfaces/iarchive.js +3 -0
  235. package/dist/interfaces/iarchive.js.map +1 -0
  236. package/dist/interfaces/ichart.d.ts +7 -0
  237. package/dist/interfaces/ichart.js +3 -0
  238. package/dist/interfaces/ichart.js.map +1 -0
  239. package/dist/interfaces/icounter.d.ts +7 -0
  240. package/dist/interfaces/icounter.js +3 -0
  241. package/dist/interfaces/icounter.js.map +1 -0
  242. package/dist/interfaces/igenerator.d.ts +4 -0
  243. package/dist/interfaces/igenerator.js +3 -0
  244. package/dist/interfaces/igenerator.js.map +1 -0
  245. package/dist/interfaces/iimage.d.ts +7 -0
  246. package/dist/interfaces/iimage.js +3 -0
  247. package/dist/interfaces/iimage.js.map +1 -0
  248. package/dist/interfaces/ilayout.d.ts +14 -0
  249. package/dist/interfaces/ilayout.js +3 -0
  250. package/dist/interfaces/ilayout.js.map +1 -0
  251. package/dist/interfaces/imaster.d.ts +15 -0
  252. package/dist/interfaces/imaster.js +3 -0
  253. package/dist/interfaces/imaster.js.map +1 -0
  254. package/dist/interfaces/imulti-text.d.ts +50 -0
  255. package/dist/interfaces/imulti-text.js +3 -0
  256. package/dist/interfaces/imulti-text.js.map +1 -0
  257. package/dist/interfaces/ipptxgenjs-slide.d.ts +40 -0
  258. package/dist/interfaces/ipptxgenjs-slide.js +3 -0
  259. package/dist/interfaces/ipptxgenjs-slide.js.map +1 -0
  260. package/dist/interfaces/ipresentation-props.d.ts +16 -0
  261. package/dist/interfaces/ipresentation-props.js +3 -0
  262. package/dist/interfaces/ipresentation-props.js.map +1 -0
  263. package/dist/interfaces/ishape-action.d.ts +18 -0
  264. package/dist/interfaces/ishape-action.js +3 -0
  265. package/dist/interfaces/ishape-action.js.map +1 -0
  266. package/dist/interfaces/ishape.d.ts +5 -0
  267. package/dist/interfaces/ishape.js +3 -0
  268. package/dist/interfaces/ishape.js.map +1 -0
  269. package/dist/interfaces/islide.d.ts +71 -0
  270. package/dist/interfaces/islide.js +3 -0
  271. package/dist/interfaces/islide.js.map +1 -0
  272. package/dist/interfaces/itemplate.d.ts +9 -0
  273. package/dist/interfaces/itemplate.js +3 -0
  274. package/dist/interfaces/itemplate.js.map +1 -0
  275. package/dist/interfaces/pres-template.d.ts +9 -0
  276. package/dist/interfaces/pres-template.js +3 -0
  277. package/dist/interfaces/pres-template.js.map +1 -0
  278. package/dist/interfaces/root-pres-template.d.ts +38 -0
  279. package/dist/interfaces/root-pres-template.js +3 -0
  280. package/dist/interfaces/root-pres-template.js.map +1 -0
  281. package/dist/modify/modify-chart.d.ts +74 -0
  282. package/dist/modify/modify-chart.js +753 -0
  283. package/dist/modify/modify-chart.js.map +1 -0
  284. package/dist/modify/modify-table.d.ts +64 -0
  285. package/dist/modify/modify-table.js +435 -0
  286. package/dist/modify/modify-table.js.map +1 -0
  287. package/dist/shapes/chart.d.ts +91 -0
  288. package/dist/shapes/chart.js +437 -0
  289. package/dist/shapes/chart.js.map +1 -0
  290. package/dist/shapes/diagram.d.ts +33 -0
  291. package/dist/shapes/diagram.js +167 -0
  292. package/dist/shapes/diagram.js.map +1 -0
  293. package/dist/shapes/generic.d.ts +27 -0
  294. package/dist/shapes/generic.js +118 -0
  295. package/dist/shapes/generic.js.map +1 -0
  296. package/dist/shapes/hyperlink.d.ts +27 -0
  297. package/dist/shapes/hyperlink.js +193 -0
  298. package/dist/shapes/hyperlink.js.map +1 -0
  299. package/dist/shapes/image.d.ts +47 -0
  300. package/dist/shapes/image.js +244 -0
  301. package/dist/shapes/image.js.map +1 -0
  302. package/dist/shapes/ole.d.ts +30 -0
  303. package/dist/shapes/ole.js +237 -0
  304. package/dist/shapes/ole.js.map +1 -0
  305. package/dist/types/chart-types.d.ts +115 -0
  306. package/dist/types/chart-types.js +3 -0
  307. package/dist/types/chart-types.js.map +1 -0
  308. package/dist/types/modify-types.d.ts +128 -0
  309. package/dist/types/modify-types.js +3 -0
  310. package/dist/types/modify-types.js.map +1 -0
  311. package/dist/types/shape-types.d.ts +40 -0
  312. package/dist/types/shape-types.js +3 -0
  313. package/dist/types/shape-types.js.map +1 -0
  314. package/dist/types/table-types.d.ts +38 -0
  315. package/dist/types/table-types.js +3 -0
  316. package/dist/types/table-types.js.map +1 -0
  317. package/dist/types/types.d.ts +317 -0
  318. package/dist/types/types.js +16 -0
  319. package/dist/types/types.js.map +1 -0
  320. package/dist/types/xml-types.d.ts +168 -0
  321. package/dist/types/xml-types.js +3 -0
  322. package/dist/types/xml-types.js.map +1 -0
  323. package/package.json +92 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
+ semver, with the pre-1.0 convention that **breaking changes bump the minor**.
6
+
7
+ ## [0.1.1] - 2026-11-04
8
+
9
+ ### Fixed
10
+
11
+ - `modify.replaceText` now finds `{{tags}}` that PowerPoint split over several
12
+ runs (spell check `err="1"`, edit history). Before the search, a split tag
13
+ is moved into the run it starts in; text before and after the tag keeps its
14
+ own run and formatting (`src/extensions/run-merge/`).
15
+
16
+ ## [0.1.0]
17
+
18
+ First release as `pptx-templates`, a fork of
19
+ [pptx-automizer](https://github.com/singerla/pptx-automizer). It contains
20
+ everything in pptx-automizer up to upstream commit `2ef0cf7` (2026-10-14,
21
+ after 0.9.4). See the
22
+ [upstream changelog](https://github.com/singerla/pptx-automizer/blob/main/CHANGELOG.md)
23
+ for that history.
24
+
25
+ ### Breaking
26
+
27
+ - pptxgenjs 3.12 → 4.0.1. pptxgenjs 4 loads `node:fs` and `node:https` with
28
+ a dynamic `import()` on every export. Projects that test `slide.generate()`
29
+ with **Jest** must run Jest with `node --experimental-vm-modules`;
30
+ otherwise the write fails and Jest reports an unhandled rejection. Plain
31
+ Node is not affected.
32
+
33
+ ### Added
34
+
35
+ - `modify.renderTemplate(data, options?)` renders docx-templates-style logic
36
+ written into slide text: `{{expr}}`/`{{= …}}`/`{{INS …}}`,
37
+ `IF`/`ELSE-IF`/`ELSE`/`END-IF`, `FOR … IN …`/`END-FOR` (also across table
38
+ rows), `EXEC`/`!`, `ALIAS`/`*alias`, `HTML`, `LINK` and `IMAGE`. `IMAGE`
39
+ places pictures at the shape that holds the tag (via `slide.modify`) and
40
+ stores identical media only once. Expressions are evaluated by a built-in
41
+ interpreter (no `eval`). They support arrow functions, object and array
42
+ literals, optional chaining and async data. Options: `cmdDelimiter`,
43
+ `openingTag`/`closingTag`, `additionalJsContext`, `strict`,
44
+ `rejectNullish`, `errorHandler`, `failFast`, `processLineBreaks`.
45
+ - `listTemplateCommands(pptx, options?)` lists the template commands of a
46
+ .pptx per slide and shape, like `listCommands` in docx-templates.
47
+
48
+ ### Fixed
49
+
50
+ - pptxgenjs 4 writes the SVG bytes into the PNG fallback of an SVG image
51
+ added via `slide.generate()`, and the media deduplication then merged both
52
+ into one `.png` part. The fallback now gets the same placeholder PNG that
53
+ pptxgenjs 3.12 wrote.
54
+
55
+ [Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.0...HEAD
56
+ [0.1.0]: https://github.com/DaBorsten/pptx-templates/releases/tag/v0.1.0
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Boas Rautmann
4
+ Copyright (c) 2021 Thomas Singer from pptx-automizer
5
+ Copyright (c) 2016-2017 Guillermo Grau Panea from docx-templates
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,85 @@
1
- # Temporary Holding Version
1
+ # pptx-templates: A Powerful .pptx Modifier for Node.js
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm version](https://img.shields.io/npm/v/pptx-templates.svg)](https://www.npmjs.com/package/pptx-templates)
4
+ [![CI](https://github.com/DaBorsten/pptx-templates/actions/workflows/ci.yml/badge.svg)](https://github.com/DaBorsten/pptx-templates/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/DaBorsten/pptx-templates/blob/main/LICENSE)
6
+
7
+ `pptx-templates` is a Node.js-based PowerPoint (.pptx) generator that automates the manipulation of existing .pptx files. With `pptx-templates`, you can import your library of .pptx templates, merge templates, and customize slide content. `pptx-templates` will edit and merge existing pptx files. You can style template slides within PowerPoint, and these templates will be seamlessly integrated into the output presentation. Most of the content can be modified by using callbacks with [xmldom](https://github.com/xmldom/xmldom).
8
+
9
+ If you require to create elements from scratch, `pptx-templates` wraps around [PptxGenJS](https://github.com/gitbrent/PptxGenJS). Use the powerful syntax of `PptxGenJS` to add dynamic content to your existing .pptx template files.
10
+
11
+ `pptx-templates` is particularly well-suited for users who aim to manage their own library of .pptx template files, making it an ideal choice for those who work with intricate, well-designed customized layouts. With this tool, any existing slide or even a single element can serve as a data-driven template for generating output .pptx files.
12
+
13
+ ## Documentation
14
+
15
+ **The full documentation lives at [daborsten.github.io/pptx-templates](https://daborsten.github.io/pptx-templates/)** — guides for every feature area plus the generated API reference:
16
+
17
+ - [Getting started](https://daborsten.github.io/pptx-templates/getting-started) · [Concepts](https://daborsten.github.io/pptx-templates/concepts) · [Selecting slides and shapes](https://daborsten.github.io/pptx-templates/selectors)
18
+ - Modify [Text](https://daborsten.github.io/pptx-templates/text) · [Tables](https://daborsten.github.io/pptx-templates/tables) · [Charts](https://daborsten.github.io/pptx-templates/charts) · [Images](https://daborsten.github.io/pptx-templates/images) · [Masters & Layouts](https://daborsten.github.io/pptx-templates/masters-layouts)
19
+ - [Generate shapes with PptxGenJS](https://daborsten.github.io/pptx-templates/generation) · [Hyperlinks](https://daborsten.github.io/pptx-templates/hyperlinks) · [Slide management](https://daborsten.github.io/pptx-templates/slide-management)
20
+ - [Helper utilities](https://daborsten.github.io/pptx-templates/helpers) · [Output](https://daborsten.github.io/pptx-templates/output) · [Requirements and limitations](https://daborsten.github.io/pptx-templates/limitations) · [Troubleshooting](https://daborsten.github.io/pptx-templates/troubleshooting)
21
+ - [API reference](https://daborsten.github.io/pptx-templates/api)
22
+
23
+ AI assistants consuming this library should read [AI-INSTRUCTOR.md](https://github.com/DaBorsten/pptx-templates/blob/main/AI-INSTRUCTOR.md), a condensed, self-contained guide that is also shipped in the npm package.
24
+
25
+ ## Installation
26
+
27
+ ```
28
+ $ yarn add pptx-templates
29
+ ```
30
+
31
+ or
32
+
33
+ ```
34
+ $ npm install pptx-templates
35
+ ```
36
+
37
+ To explore the library from a clone instead, see [Getting started](https://daborsten.github.io/pptx-templates/getting-started).
38
+
39
+ ## Example
40
+
41
+ ```ts
42
+ import Automizer, { modify } from 'pptx-templates';
43
+
44
+ const automizer = new Automizer({
45
+ // where your template pptx files are coming from:
46
+ templateDir: 'my/pptx/templates',
47
+ // where to write the final pptx output files:
48
+ outputDir: 'my/pptx/output',
49
+ // truncate the root presentation and start with zero slides:
50
+ removeExistingSlides: true,
51
+ });
52
+
53
+ const pres = automizer
54
+ .loadRoot('RootTemplate.pptx')
55
+ .load('SlideWithGraph.pptx', 'graph')
56
+ .load('SlideWithShapes.pptx', 'shapes');
57
+
58
+ pres
59
+ .addSlide('graph', 1)
60
+ .addSlide('shapes', 1, (slide) => {
61
+ slide.modifyElement('Drum', [modify.setText('Hello world!')]);
62
+ });
63
+
64
+ // Nothing has happened yet: all calls above only queue work.
65
+ // write() executes the whole queue and produces the output file.
66
+ const summary = await pres.write('myPresentation.pptx');
67
+ console.log(summary);
68
+ ```
69
+
70
+ The single most important concept: calls like `addSlide()` and `modifyElement()` only **queue** work — including every modification callback you pass. Nothing is applied until `await pres.write(...)` (or `.stream()` / `.getJSZip()`) executes the whole queue in order. Read more in [Concepts](https://daborsten.github.io/pptx-templates/concepts).
71
+
72
+ Take a look into the [`__tests__`-directory](https://github.com/DaBorsten/pptx-templates/blob/main/__tests__) to see a lot of examples for several use cases. You will also find the example .pptx-files there.
73
+
74
+ ## Support
75
+
76
+ Thanks to all contributors! You are always welcome to share code, tipps and ideas. We appreciate all levels of expertise and encourage everyone to get involved. Whether you're a seasoned pro or just starting out, your contributions are invaluable. [Get started](https://github.com/DaBorsten/pptx-templates/issues/new)
77
+
78
+ Found a security problem? Please follow the [security policy](https://github.com/DaBorsten/pptx-templates/blob/main/SECURITY.md) instead of opening a public issue.
79
+
80
+ # Special Thanks
81
+
82
+ This project was inspired by:
83
+
84
+ - [pptx-automizer](https://github.com/singerla/pptx-automizer)
85
+ - [docx-templates](https://github.com/guigrpa/docx-templates)
@@ -0,0 +1,224 @@
1
+ import { ArchiveParams, AutomizerFile, AutomizerParams, AutomizerSummary, PresentationInfo, SourceIdentifier, StatusTracker } from './types/types';
2
+ import { IPresentationProps } from './interfaces/ipresentation-props';
3
+ import { PresTemplate } from './interfaces/pres-template';
4
+ import { RootPresTemplate } from './interfaces/root-pres-template';
5
+ import { ModifyXmlCallback, TemplateInfo } from './types/xml-types';
6
+ import { ILogger } from './helper/logger';
7
+ import { ILayout } from './interfaces/ilayout';
8
+ import { ContentTracker } from './helper/content-tracker';
9
+ import JSZip from 'jszip';
10
+ import { ISlide } from './interfaces/islide';
11
+ import { IMaster } from './interfaces/imaster';
12
+ /**
13
+ * Automizer
14
+ *
15
+ * The basic class for `pptx-templates` package.
16
+ * This class will be exported as `Automizer` by `index.ts`.
17
+ */
18
+ export default class Automizer implements IPresentationProps {
19
+ rootTemplate: RootPresTemplate;
20
+ /**
21
+ * Templates of automizer
22
+ * @internal
23
+ */
24
+ templates: PresTemplate[];
25
+ templateDir: string;
26
+ templateFallbackDir: string;
27
+ outputDir: string;
28
+ archiveParams: ArchiveParams;
29
+ /**
30
+ * Timer of automizer
31
+ * @internal
32
+ */
33
+ timer: number;
34
+ params: AutomizerParams;
35
+ status: StatusTracker;
36
+ /**
37
+ * Logger used for all library output. Defaults to a `ConsoleLogger`
38
+ * filtered by `params.verbosity`; inject your own via `params.logger`.
39
+ */
40
+ logger: ILogger;
41
+ content: ContentTracker;
42
+ modifyPresentation: ModifyXmlCallback[];
43
+ /**
44
+ * Masters queued for removal (`removeMaster`), by number.
45
+ * @internal
46
+ */
47
+ mastersToRemove: number[];
48
+ /**
49
+ * Creates an instance of `pptx-templates`.
50
+ * @param [params]
51
+ */
52
+ constructor(params: AutomizerParams);
53
+ setStatusTracker(statusTracker: StatusTracker['next']): void;
54
+ /**
55
+
56
+ */
57
+ presentation(): Promise<this>;
58
+ /**
59
+ * Load a pptx file and set it as root template.
60
+ * @param file - Filename, path to the template or Buffer containing the file.
61
+ * Filenames and paths will be prefixed with 'templateDir'
62
+ * @returns Instance of Automizer
63
+ */
64
+ loadRoot(file: AutomizerFile): this;
65
+ /**
66
+ * Load a template pptx file.
67
+ * @param file - Filename, path to the template or Buffer containing the file.
68
+ * Filenames and paths will be prefixed with 'templateDir'
69
+ * @param name - Optional short name for a template loaded from a file. If skipped, the template will be named by its location.
70
+ * if the file is a Buffer the name is required.
71
+ * @returns Instance of Automizer
72
+ */
73
+ load(file: AutomizerFile, name?: string): this;
74
+ /**
75
+ * Loads a pptx file either as a root template as a template file.
76
+ * A name can be specified to give templates an alias.
77
+ * @param location
78
+ * @param [name]
79
+ * @returns template
80
+ */
81
+ private loadTemplate;
82
+ /**
83
+ * Load media files to output presentation.
84
+ * @returns Instance of Automizer
85
+ * @param filename Filename or path to the media file.
86
+ * @param dir Specify custom path for media instead of mediaDir from AutomizerParams.
87
+ */
88
+ loadMedia(filename: string | string[], dir?: string, prefix?: string): this;
89
+ /**
90
+ * Load media files from buffers to output presentation.
91
+ * @returns Instance of Automizer
92
+ * @param filename Filename(s) to use (must include extension).
93
+ * @param buffer Buffer(s) containing the media data.
94
+ * @param prefix Optional prefix to prepend to filename in archive.
95
+ */
96
+ loadMediaBuffer(filename: string | string[], buffer: Buffer | Buffer[], prefix?: string): this;
97
+ /**
98
+ * Parses all loaded templates and collects creationIds for slides and
99
+ * elements. This will make finding templates and elements independent
100
+ * of slide number and element name.
101
+ * @returns Promise<TemplateInfo[]>
102
+ */
103
+ setCreationIds(): Promise<TemplateInfo[]>;
104
+ /**
105
+ * Get some info about the imported templates
106
+ * @returns Promise<PresentationInfo>
107
+ */
108
+ getInfo(): Promise<PresentationInfo>;
109
+ /**
110
+ * Add a slide from one of the imported templates by slide number or creationId.
111
+ * @param name - Name or alias of the template; must have been loaded with `Automizer.load()`
112
+ * @param slideIdentifier - Number or creationId of slide in template presentation
113
+ * @param callback - Executed after slide was added. The newly created slide will be passed to the callback as first argument.
114
+ * @returns Instance of Automizer
115
+ */
116
+ addSlide(name: string, slideIdentifier: SourceIdentifier, callback?: (slide: ISlide) => void): this;
117
+ /**
118
+ * Copy and modify a master and the associated layouts from template to output.
119
+ *
120
+ * @param name
121
+ * @param sourceIdentifier
122
+ * @param callback
123
+ */
124
+ addMaster(name: string, sourceIdentifier: number, callback?: (slideMaster: IMaster) => void): this;
125
+ /**
126
+ * Modify a slide master that is already part of the root template, in
127
+ * place: no copy is made, the master keeps its number and every slide
128
+ * using it keeps using it. The callback gets the same
129
+ * `modifyElement` / `addElement` / `removeElement` vocabulary as
130
+ * `addMaster`. Deferred: applied on write, before the slides are
131
+ * written, in call order with `addMaster` imports.
132
+ *
133
+ * @param masterNumber - 1-based number of the master in the root
134
+ * template as loaded (`ppt/slideMasters/slideMaster<n>.xml`). Imported
135
+ * masters are modified through their `addMaster` callback instead.
136
+ * @param callback - Receives the master; queue element actions on it.
137
+ */
138
+ modifyMaster(masterNumber: number, callback: (slideMaster: IMaster) => void): this;
139
+ /**
140
+ * Modify a slide layout that is already part of the root template, in
141
+ * place (see `modifyMaster`).
142
+ *
143
+ * @param layoutNumber - 1-based number of the layout in the root template
144
+ * as loaded (`ppt/slideLayouts/slideLayout<n>.xml`).
145
+ * @param callback - Receives the layout; queue element actions on it.
146
+ */
147
+ modifyLayout(layoutNumber: number, callback: (slideLayout: ILayout) => void): this;
148
+ /**
149
+ * Remove a slide master from the output together with its layouts, its
150
+ * theme (unless another part still uses it) and all entries referring
151
+ * to them. Deferred: applied on write after all slides have been
152
+ * written. Fails if a slide of the output still uses one of the
153
+ * master's layouts — switch those slides with `useSlideLayout()` first
154
+ * (or drop the root template's slides with `removeExistingSlides`).
155
+ *
156
+ * @param masterNumber - 1-based number of the master in the root
157
+ * template as loaded (`ppt/slideMasters/slideMaster<n>.xml`).
158
+ */
159
+ removeMaster(masterNumber: number): this;
160
+ /**
161
+ * Searches this.templates to find template by given name.
162
+ * @internal
163
+ * @param name Alias name if given to loaded template.
164
+ * @returns template
165
+ */
166
+ getTemplate(name: string): PresTemplate;
167
+ /**
168
+ * Write all imports and modifications to a file.
169
+ * @param location - Filename or path for the file. Will be prefixed with 'outputDir'
170
+ * @returns summary object.
171
+ */
172
+ write(location: string): Promise<AutomizerSummary>;
173
+ /**
174
+ * Create a ReadableStream from output pptx file.
175
+ * @param generatorOptions - JSZipGeneratorOptions for nodebuffer Output type
176
+ * @returns Promise<NodeJS.ReadableStream>
177
+ */
178
+ stream(generatorOptions?: JSZip.JSZipGeneratorOptions<'nodebuffer'>): Promise<NodeJS.ReadableStream>;
179
+ /**
180
+ * Pass final JSZip instance.
181
+ * @returns Promise<NodeJS.ReadableStream>
182
+ */
183
+ getJSZip(): Promise<JSZip>;
184
+ finalizePresentation(): Promise<void>;
185
+ /**
186
+ * Write all masterSlides to archive.
187
+ */
188
+ writeMasterSlides(): Promise<void>;
189
+ /**
190
+ * Remove the masters queued by `removeMaster()`. Runs after the slides
191
+ * are written, so layout switches have been applied when the "still in
192
+ * use" check runs.
193
+ */
194
+ removeSlideMasters(): Promise<void>;
195
+ /**
196
+ * Write all slides to archive.
197
+ */
198
+ writeSlides(): Promise<void>;
199
+ /**
200
+ * Write all media files to archive.
201
+ */
202
+ writeMediaFiles(): Promise<void>;
203
+ /**
204
+ * Applies all callbacks in this.modifyPresentation-array.
205
+ * The callback array can be pushed by this.modify()
206
+ */
207
+ applyModifyPresentationCallbacks(): Promise<void>;
208
+ /**
209
+ * Apply some callbacks to restore archive/xml structure
210
+ * and prevent corrupted pptx files.
211
+ *
212
+ * TODO: Use every imported image only once
213
+ * TODO: Check for lost relations
214
+ */
215
+ normalizePresentation(): Promise<void>;
216
+ modify(cb: ModifyXmlCallback): this;
217
+ /**
218
+ * Applies path prefix to given location string.
219
+ * @param location path and/or filename
220
+ * @param [type] template or output
221
+ * @returns location
222
+ */
223
+ private getLocation;
224
+ }