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.
- package/AI-INSTRUCTOR.md +2253 -0
- package/CHANGELOG.md +56 -0
- package/LICENSE +23 -0
- package/README.md +84 -2
- package/dist/automizer.d.ts +224 -0
- package/dist/automizer.js +704 -0
- package/dist/automizer.js.map +1 -0
- package/dist/classes/content-type-registry.d.ts +46 -0
- package/dist/classes/content-type-registry.js +170 -0
- package/dist/classes/content-type-registry.js.map +1 -0
- package/dist/classes/element-importer.d.ts +49 -0
- package/dist/classes/element-importer.js +254 -0
- package/dist/classes/element-importer.js.map +1 -0
- package/dist/classes/has-shapes.d.ts +286 -0
- package/dist/classes/has-shapes.js +385 -0
- package/dist/classes/has-shapes.js.map +1 -0
- package/dist/classes/layout.d.ts +42 -0
- package/dist/classes/layout.js +113 -0
- package/dist/classes/layout.js.map +1 -0
- package/dist/classes/master.d.ts +45 -0
- package/dist/classes/master.js +146 -0
- package/dist/classes/master.js.map +1 -0
- package/dist/classes/placeholder-normalizer.d.ts +42 -0
- package/dist/classes/placeholder-normalizer.js +136 -0
- package/dist/classes/placeholder-normalizer.js.map +1 -0
- package/dist/classes/related-content-copier.d.ts +18 -0
- package/dist/classes/related-content-copier.js +114 -0
- package/dist/classes/related-content-copier.js.map +1 -0
- package/dist/classes/shape.d.ts +62 -0
- package/dist/classes/shape.js +194 -0
- package/dist/classes/shape.js.map +1 -0
- package/dist/classes/slide-master-remover.d.ts +44 -0
- package/dist/classes/slide-master-remover.js +201 -0
- package/dist/classes/slide-master-remover.js.map +1 -0
- package/dist/classes/slide-notes-copier.d.ts +26 -0
- package/dist/classes/slide-notes-copier.js +76 -0
- package/dist/classes/slide-notes-copier.js.map +1 -0
- package/dist/classes/slide.d.ts +91 -0
- package/dist/classes/slide.js +286 -0
- package/dist/classes/slide.js.map +1 -0
- package/dist/classes/template.d.ts +137 -0
- package/dist/classes/template.js +311 -0
- package/dist/classes/template.js.map +1 -0
- package/dist/constants/constants.d.ts +11 -0
- package/dist/constants/constants.js +182 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/enums/chart-type.d.ts +11 -0
- package/dist/enums/chart-type.js +16 -0
- package/dist/enums/chart-type.js.map +1 -0
- package/dist/enums/content-type-map.d.ts +16 -0
- package/dist/enums/content-type-map.js +23 -0
- package/dist/enums/content-type-map.js.map +1 -0
- package/dist/enums/element-type.d.ts +14 -0
- package/dist/enums/element-type.js +20 -0
- package/dist/enums/element-type.js.map +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +100 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/index.js +31 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.d.ts +5 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js +9 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/index.d.ts +5 -0
- package/dist/extensions/pptxgenjs-compat/index.js +10 -0
- package/dist/extensions/pptxgenjs-compat/index.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.d.ts +14 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js +139 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -0
- package/dist/extensions/run-merge/index.d.ts +13 -0
- package/dist/extensions/run-merge/index.js +89 -0
- package/dist/extensions/run-merge/index.js.map +1 -0
- package/dist/extensions/template-logic/commands.d.ts +22 -0
- package/dist/extensions/template-logic/commands.js +83 -0
- package/dist/extensions/template-logic/commands.js.map +1 -0
- package/dist/extensions/template-logic/expression.d.ts +61 -0
- package/dist/extensions/template-logic/expression.js +499 -0
- package/dist/extensions/template-logic/expression.js.map +1 -0
- package/dist/extensions/template-logic/images.d.ts +26 -0
- package/dist/extensions/template-logic/images.js +183 -0
- package/dist/extensions/template-logic/images.js.map +1 -0
- package/dist/extensions/template-logic/index.d.ts +14 -0
- package/dist/extensions/template-logic/index.js +64 -0
- package/dist/extensions/template-logic/index.js.map +1 -0
- package/dist/extensions/template-logic/list-commands.d.ts +9 -0
- package/dist/extensions/template-logic/list-commands.js +72 -0
- package/dist/extensions/template-logic/list-commands.js.map +1 -0
- package/dist/extensions/template-logic/renderer.d.ts +85 -0
- package/dist/extensions/template-logic/renderer.js +867 -0
- package/dist/extensions/template-logic/renderer.js.map +1 -0
- package/dist/extensions/template-logic/types.d.ts +62 -0
- package/dist/extensions/template-logic/types.js +3 -0
- package/dist/extensions/template-logic/types.js.map +1 -0
- package/dist/helper/archive/archive-fs.d.ts +45 -0
- package/dist/helper/archive/archive-fs.js +206 -0
- package/dist/helper/archive/archive-fs.js.map +1 -0
- package/dist/helper/archive/archive-jszip.d.ts +31 -0
- package/dist/helper/archive/archive-jszip.js +173 -0
- package/dist/helper/archive/archive-jszip.js.map +1 -0
- package/dist/helper/archive/archive.d.ts +27 -0
- package/dist/helper/archive/archive.js +78 -0
- package/dist/helper/archive/archive.js.map +1 -0
- package/dist/helper/cell-id-helper.d.ts +25 -0
- package/dist/helper/cell-id-helper.js +95 -0
- package/dist/helper/cell-id-helper.js.map +1 -0
- package/dist/helper/compute-src-rect.d.ts +9 -0
- package/dist/helper/compute-src-rect.js +52 -0
- package/dist/helper/compute-src-rect.js.map +1 -0
- package/dist/helper/content-tracker.d.ts +31 -0
- package/dist/helper/content-tracker.js +227 -0
- package/dist/helper/content-tracker.js.map +1 -0
- package/dist/helper/count-helper.d.ts +33 -0
- package/dist/helper/count-helper.js +140 -0
- package/dist/helper/count-helper.js.map +1 -0
- package/dist/helper/css-style-parser.d.ts +52 -0
- package/dist/helper/css-style-parser.js +246 -0
- package/dist/helper/css-style-parser.js.map +1 -0
- package/dist/helper/file-helper.d.ts +36 -0
- package/dist/helper/file-helper.js +150 -0
- package/dist/helper/file-helper.js.map +1 -0
- package/dist/helper/general-helper.d.ts +6 -0
- package/dist/helper/general-helper.js +34 -0
- package/dist/helper/general-helper.js.map +1 -0
- package/dist/helper/generate/generate-pptxgenjs.d.ts +37 -0
- package/dist/helper/generate/generate-pptxgenjs.js +134 -0
- package/dist/helper/generate/generate-pptxgenjs.js.map +1 -0
- package/dist/helper/html-to-multitext-helper.d.ts +84 -0
- package/dist/helper/html-to-multitext-helper.js +490 -0
- package/dist/helper/html-to-multitext-helper.js.map +1 -0
- package/dist/helper/hyperlink-processor.d.ts +54 -0
- package/dist/helper/hyperlink-processor.js +289 -0
- package/dist/helper/hyperlink-processor.js.map +1 -0
- package/dist/helper/image-dimensions.d.ts +21 -0
- package/dist/helper/image-dimensions.js +202 -0
- package/dist/helper/image-dimensions.js.map +1 -0
- package/dist/helper/jszip-helper.d.ts +21 -0
- package/dist/helper/jszip-helper.js +162 -0
- package/dist/helper/jszip-helper.js.map +1 -0
- package/dist/helper/layout-index.d.ts +55 -0
- package/dist/helper/layout-index.js +155 -0
- package/dist/helper/layout-index.js.map +1 -0
- package/dist/helper/logger.d.ts +53 -0
- package/dist/helper/logger.js +73 -0
- package/dist/helper/logger.js.map +1 -0
- package/dist/helper/media-deduplicator.d.ts +42 -0
- package/dist/helper/media-deduplicator.js +88 -0
- package/dist/helper/media-deduplicator.js.map +1 -0
- package/dist/helper/modify-background-helper.d.ts +19 -0
- package/dist/helper/modify-background-helper.js +59 -0
- package/dist/helper/modify-background-helper.js.map +1 -0
- package/dist/helper/modify-chart-helper.d.ts +159 -0
- package/dist/helper/modify-chart-helper.js +642 -0
- package/dist/helper/modify-chart-helper.js.map +1 -0
- package/dist/helper/modify-cleanup-helper.d.ts +69 -0
- package/dist/helper/modify-cleanup-helper.js +343 -0
- package/dist/helper/modify-cleanup-helper.js.map +1 -0
- package/dist/helper/modify-color-helper.d.ts +35 -0
- package/dist/helper/modify-color-helper.js +211 -0
- package/dist/helper/modify-color-helper.js.map +1 -0
- package/dist/helper/modify-helper.d.ts +23 -0
- package/dist/helper/modify-helper.js +61 -0
- package/dist/helper/modify-helper.js.map +1 -0
- package/dist/helper/modify-hyperlink-element.d.ts +9 -0
- package/dist/helper/modify-hyperlink-element.js +34 -0
- package/dist/helper/modify-hyperlink-element.js.map +1 -0
- package/dist/helper/modify-hyperlink-helper.d.ts +42 -0
- package/dist/helper/modify-hyperlink-helper.js +258 -0
- package/dist/helper/modify-hyperlink-helper.js.map +1 -0
- package/dist/helper/modify-image-helper.d.ts +23 -0
- package/dist/helper/modify-image-helper.js +157 -0
- package/dist/helper/modify-image-helper.js.map +1 -0
- package/dist/helper/modify-presentation-helper.d.ts +55 -0
- package/dist/helper/modify-presentation-helper.js +177 -0
- package/dist/helper/modify-presentation-helper.js.map +1 -0
- package/dist/helper/modify-shape-helper.d.ts +111 -0
- package/dist/helper/modify-shape-helper.js +340 -0
- package/dist/helper/modify-shape-helper.js.map +1 -0
- package/dist/helper/modify-table-helper.d.ts +11 -0
- package/dist/helper/modify-table-helper.js +100 -0
- package/dist/helper/modify-table-helper.js.map +1 -0
- package/dist/helper/modify-text-helper.d.ts +62 -0
- package/dist/helper/modify-text-helper.js +244 -0
- package/dist/helper/modify-text-helper.js.map +1 -0
- package/dist/helper/modify-xml-helper.d.ts +52 -0
- package/dist/helper/modify-xml-helper.js +305 -0
- package/dist/helper/modify-xml-helper.js.map +1 -0
- package/dist/helper/multitext-helper.d.ts +116 -0
- package/dist/helper/multitext-helper.js +462 -0
- package/dist/helper/multitext-helper.js.map +1 -0
- package/dist/helper/ppt-paths.d.ts +76 -0
- package/dist/helper/ppt-paths.js +116 -0
- package/dist/helper/ppt-paths.js.map +1 -0
- package/dist/helper/shape-type-detector.d.ts +34 -0
- package/dist/helper/shape-type-detector.js +99 -0
- package/dist/helper/shape-type-detector.js.map +1 -0
- package/dist/helper/text-replace-helper.d.ts +30 -0
- package/dist/helper/text-replace-helper.js +149 -0
- package/dist/helper/text-replace-helper.js.map +1 -0
- package/dist/helper/xml/lnLRTB.d.ts +1 -0
- package/dist/helper/xml/lnLRTB.js +62 -0
- package/dist/helper/xml/lnLRTB.js.map +1 -0
- package/dist/helper/xml/prstGeom.d.ts +1 -0
- package/dist/helper/xml/prstGeom.js +11 -0
- package/dist/helper/xml/prstGeom.js.map +1 -0
- package/dist/helper/xml-elements.d.ts +134 -0
- package/dist/helper/xml-elements.js +538 -0
- package/dist/helper/xml-elements.js.map +1 -0
- package/dist/helper/xml-helper.d.ts +120 -0
- package/dist/helper/xml-helper.js +495 -0
- package/dist/helper/xml-helper.js.map +1 -0
- package/dist/helper/xml-placeholder-helper.d.ts +92 -0
- package/dist/helper/xml-placeholder-helper.js +454 -0
- package/dist/helper/xml-placeholder-helper.js.map +1 -0
- package/dist/helper/xml-pretty-print.d.ts +17 -0
- package/dist/helper/xml-pretty-print.js +88 -0
- package/dist/helper/xml-pretty-print.js.map +1 -0
- package/dist/helper/xml-relationship-helper.d.ts +103 -0
- package/dist/helper/xml-relationship-helper.js +397 -0
- package/dist/helper/xml-relationship-helper.js.map +1 -0
- package/dist/helper/xml-slide-helper.d.ts +107 -0
- package/dist/helper/xml-slide-helper.js +676 -0
- package/dist/helper/xml-slide-helper.js.map +1 -0
- package/dist/helper/xml-template-helper.d.ts +42 -0
- package/dist/helper/xml-template-helper.js +252 -0
- package/dist/helper/xml-template-helper.js.map +1 -0
- package/dist/helper/xmldom-sax-patch.d.ts +18 -0
- package/dist/helper/xmldom-sax-patch.js +58 -0
- package/dist/helper/xmldom-sax-patch.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +177 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/iarchive.d.ts +43 -0
- package/dist/interfaces/iarchive.js +3 -0
- package/dist/interfaces/iarchive.js.map +1 -0
- package/dist/interfaces/ichart.d.ts +7 -0
- package/dist/interfaces/ichart.js +3 -0
- package/dist/interfaces/ichart.js.map +1 -0
- package/dist/interfaces/icounter.d.ts +7 -0
- package/dist/interfaces/icounter.js +3 -0
- package/dist/interfaces/icounter.js.map +1 -0
- package/dist/interfaces/igenerator.d.ts +4 -0
- package/dist/interfaces/igenerator.js +3 -0
- package/dist/interfaces/igenerator.js.map +1 -0
- package/dist/interfaces/iimage.d.ts +7 -0
- package/dist/interfaces/iimage.js +3 -0
- package/dist/interfaces/iimage.js.map +1 -0
- package/dist/interfaces/ilayout.d.ts +14 -0
- package/dist/interfaces/ilayout.js +3 -0
- package/dist/interfaces/ilayout.js.map +1 -0
- package/dist/interfaces/imaster.d.ts +15 -0
- package/dist/interfaces/imaster.js +3 -0
- package/dist/interfaces/imaster.js.map +1 -0
- package/dist/interfaces/imulti-text.d.ts +50 -0
- package/dist/interfaces/imulti-text.js +3 -0
- package/dist/interfaces/imulti-text.js.map +1 -0
- package/dist/interfaces/ipptxgenjs-slide.d.ts +40 -0
- package/dist/interfaces/ipptxgenjs-slide.js +3 -0
- package/dist/interfaces/ipptxgenjs-slide.js.map +1 -0
- package/dist/interfaces/ipresentation-props.d.ts +16 -0
- package/dist/interfaces/ipresentation-props.js +3 -0
- package/dist/interfaces/ipresentation-props.js.map +1 -0
- package/dist/interfaces/ishape-action.d.ts +18 -0
- package/dist/interfaces/ishape-action.js +3 -0
- package/dist/interfaces/ishape-action.js.map +1 -0
- package/dist/interfaces/ishape.d.ts +5 -0
- package/dist/interfaces/ishape.js +3 -0
- package/dist/interfaces/ishape.js.map +1 -0
- package/dist/interfaces/islide.d.ts +71 -0
- package/dist/interfaces/islide.js +3 -0
- package/dist/interfaces/islide.js.map +1 -0
- package/dist/interfaces/itemplate.d.ts +9 -0
- package/dist/interfaces/itemplate.js +3 -0
- package/dist/interfaces/itemplate.js.map +1 -0
- package/dist/interfaces/pres-template.d.ts +9 -0
- package/dist/interfaces/pres-template.js +3 -0
- package/dist/interfaces/pres-template.js.map +1 -0
- package/dist/interfaces/root-pres-template.d.ts +38 -0
- package/dist/interfaces/root-pres-template.js +3 -0
- package/dist/interfaces/root-pres-template.js.map +1 -0
- package/dist/modify/modify-chart.d.ts +74 -0
- package/dist/modify/modify-chart.js +753 -0
- package/dist/modify/modify-chart.js.map +1 -0
- package/dist/modify/modify-table.d.ts +64 -0
- package/dist/modify/modify-table.js +435 -0
- package/dist/modify/modify-table.js.map +1 -0
- package/dist/shapes/chart.d.ts +91 -0
- package/dist/shapes/chart.js +437 -0
- package/dist/shapes/chart.js.map +1 -0
- package/dist/shapes/diagram.d.ts +33 -0
- package/dist/shapes/diagram.js +167 -0
- package/dist/shapes/diagram.js.map +1 -0
- package/dist/shapes/generic.d.ts +27 -0
- package/dist/shapes/generic.js +118 -0
- package/dist/shapes/generic.js.map +1 -0
- package/dist/shapes/hyperlink.d.ts +27 -0
- package/dist/shapes/hyperlink.js +193 -0
- package/dist/shapes/hyperlink.js.map +1 -0
- package/dist/shapes/image.d.ts +47 -0
- package/dist/shapes/image.js +244 -0
- package/dist/shapes/image.js.map +1 -0
- package/dist/shapes/ole.d.ts +30 -0
- package/dist/shapes/ole.js +237 -0
- package/dist/shapes/ole.js.map +1 -0
- package/dist/types/chart-types.d.ts +115 -0
- package/dist/types/chart-types.js +3 -0
- package/dist/types/chart-types.js.map +1 -0
- package/dist/types/modify-types.d.ts +128 -0
- package/dist/types/modify-types.js +3 -0
- package/dist/types/modify-types.js.map +1 -0
- package/dist/types/shape-types.d.ts +40 -0
- package/dist/types/shape-types.js +3 -0
- package/dist/types/shape-types.js.map +1 -0
- package/dist/types/table-types.d.ts +38 -0
- package/dist/types/table-types.js +3 -0
- package/dist/types/table-types.js.map +1 -0
- package/dist/types/types.d.ts +317 -0
- package/dist/types/types.js +16 -0
- package/dist/types/types.js.map +1 -0
- package/dist/types/xml-types.d.ts +168 -0
- package/dist/types/xml-types.js +3 -0
- package/dist/types/xml-types.js.map +1 -0
- 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
|
-
#
|
|
1
|
+
# pptx-templates: A Powerful .pptx Modifier for Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/pptx-templates)
|
|
4
|
+
[](https://github.com/DaBorsten/pptx-templates/actions/workflows/ci.yml)
|
|
5
|
+
[](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
|
+
}
|