pptx-templates 0.3.7 → 0.3.9
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 +96 -3
- package/CHANGELOG.md +49 -1
- package/dist/extensions/master-parts/index.d.ts +13 -0
- package/dist/extensions/master-parts/index.js +84 -0
- package/dist/extensions/master-parts/index.js.map +1 -0
- package/dist/extensions/shape-geometry/index.d.ts +2 -0
- package/dist/extensions/shape-geometry/index.js +3 -3
- package/dist/extensions/shape-geometry/index.js.map +1 -1
- package/dist/extensions/template-lint/lint.js +119 -5
- package/dist/extensions/template-lint/lint.js.map +1 -1
- package/dist/extensions/template-logic/clone.d.ts +16 -0
- package/dist/extensions/template-logic/clone.js +94 -0
- package/dist/extensions/template-logic/clone.js.map +1 -0
- package/dist/extensions/template-logic/commands.d.ts +8 -0
- package/dist/extensions/template-logic/commands.js +15 -1
- package/dist/extensions/template-logic/commands.js.map +1 -1
- package/dist/extensions/template-logic/expression.d.ts +6 -0
- package/dist/extensions/template-logic/expression.js +27 -0
- package/dist/extensions/template-logic/expression.js.map +1 -1
- package/dist/extensions/template-logic/images.d.ts +14 -0
- package/dist/extensions/template-logic/images.js +249 -14
- package/dist/extensions/template-logic/images.js.map +1 -1
- package/dist/extensions/template-logic/index.js +6 -5
- package/dist/extensions/template-logic/index.js.map +1 -1
- package/dist/extensions/template-logic/list-commands.js +26 -0
- package/dist/extensions/template-logic/list-commands.js.map +1 -1
- package/dist/extensions/template-logic/renderer.d.ts +25 -0
- package/dist/extensions/template-logic/renderer.js +189 -17
- package/dist/extensions/template-logic/renderer.js.map +1 -1
- package/dist/extensions/template-logic/types.d.ts +5 -0
- package/dist/extensions/template-logic/types.js +6 -0
- package/dist/extensions/template-logic/types.js.map +1 -1
- package/dist/extensions/template-render/index.js +65 -58
- package/dist/extensions/template-render/index.js.map +1 -1
- package/dist/extensions/text-flow/flow.d.ts +10 -0
- package/dist/extensions/text-flow/flow.js +28 -8
- package/dist/extensions/text-flow/flow.js.map +1 -1
- package/dist/extensions/text-flow/styles.d.ts +5 -0
- package/dist/extensions/text-flow/styles.js +17 -2
- package/dist/extensions/text-flow/styles.js.map +1 -1
- package/dist/helper/modify-presentation-helper.js +4 -1
- package/dist/helper/modify-presentation-helper.js.map +1 -1
- package/package.json +1 -1
package/AI-INSTRUCTOR.md
CHANGED
|
@@ -813,7 +813,8 @@ equal share of the frame. If no text is left in the shape after rendering,
|
|
|
813
813
|
the shape is removed and only the pictures remain.
|
|
814
814
|
|
|
815
815
|
- The shape needs its own position and size. Placeholders that inherit
|
|
816
|
-
them from the layout are not supported
|
|
816
|
+
them from the layout are not supported in the text; write the tag into
|
|
817
|
+
their alt text instead (see below).
|
|
817
818
|
- A string that ends in `.png`, `.jpg`, `.jpeg` or `.gif` is a file path
|
|
818
819
|
(base64 has no dot). It is read from `imageRoot` and cannot leave that
|
|
819
820
|
folder; without `imageRoot` it is an error. `null`, `undefined` and `''`
|
|
@@ -823,6 +824,91 @@ the shape is removed and only the pictures remain.
|
|
|
823
824
|
- `IMAGE` writes a media file, so it needs `slide.modify(modify.renderTemplate(…))`.
|
|
824
825
|
A `modifyElement()` callback cannot add files and rejects with an error.
|
|
825
826
|
|
|
827
|
+
#### Picture placeholders: the tag in the alt text
|
|
828
|
+
|
|
829
|
+
To fill a picture placeholder of the slide master, for example a circle,
|
|
830
|
+
write the tag into the **alt text** of the placeholder on the slide (right
|
|
831
|
+
click → *View Alt Text*), not into its text:
|
|
832
|
+
|
|
833
|
+
```text
|
|
834
|
+
{{IMAGE foto}}
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
The picture then fills the placeholder the way a picture inserted in
|
|
838
|
+
PowerPoint does:
|
|
839
|
+
|
|
840
|
+
- It covers the whole shape **without distortion**. A picture with another
|
|
841
|
+
aspect ratio than the placeholder is cropped evenly on both sides
|
|
842
|
+
(`a:srcRect`), so no edge stays empty, also in a circle.
|
|
843
|
+
- Position, size and shape stay the ones of the placeholder, inherited
|
|
844
|
+
from the layout. The result is a picture *in the placeholder*: in
|
|
845
|
+
PowerPoint you can still replace it by hand (*Change Picture*), and
|
|
846
|
+
deleting it brings back the empty placeholder.
|
|
847
|
+
- **Backup picture:** if the placeholder already holds a picture, the new
|
|
848
|
+
one replaces it. Without a value (`null`, `undefined`, `''`) the backup
|
|
849
|
+
stays. The alt text is removed either way, or set to `alt`.
|
|
850
|
+
|
|
851
|
+
The same works in the alt text of an empty picture or content placeholder
|
|
852
|
+
(it becomes a picture in that placeholder) and of any picture. Every other
|
|
853
|
+
shape keeps its text and gets the picture as its fill, cropped the same
|
|
854
|
+
way: a shape that is no placeholder, a title or text placeholder, and a
|
|
855
|
+
placeholder that already holds text. Tables, charts and groups cannot
|
|
856
|
+
take a picture; a tag in their alt text is an error.
|
|
857
|
+
|
|
858
|
+
The object form takes `alt`, `shape`, `cornerRadius`, `shapeAdjustments`
|
|
859
|
+
and `border` as above. `width`, `height` and `rotation` are an error here,
|
|
860
|
+
since the shape decides them; `lintTemplate` reports them as well.
|
|
861
|
+
|
|
862
|
+
An alt text counts as a template only when it holds **nothing but tags,
|
|
863
|
+
with an `IMAGE` among them**. Any other alt text stays as it is, so a
|
|
864
|
+
description like `Preis {{ in Euro`, `Foto: {{IMAGE foto}}` or `{{name}}`
|
|
865
|
+
is not rendered; `lintTemplate` warns about the last two, since their tag
|
|
866
|
+
most likely was meant to work. The tags use the configured delimiters
|
|
867
|
+
(`openingTag`/`closingTag` or `cmdDelimiter`, see
|
|
868
|
+
[Options](#options)), like the text.
|
|
869
|
+
|
|
870
|
+
Only the alt texts of the template are rendered. An `alt` from the data
|
|
871
|
+
(`{{IMAGE ({ data: foto, alt: caption })}}`) is written as it is, also
|
|
872
|
+
when it contains tags.
|
|
873
|
+
|
|
874
|
+
##### Conditions and loops in the alt text
|
|
875
|
+
|
|
876
|
+
Besides `IMAGE`, these work in the alt text:
|
|
877
|
+
`IF`/`ELSE-IF`/`ELSE`/`END-IF`, `FOR`/`END-FOR` and `EXEC`. Any other
|
|
878
|
+
tag, or a block that is not closed, is an error. With an `errorHandler`,
|
|
879
|
+
the alt text is removed and the shape stays as it is. One shape takes one
|
|
880
|
+
picture: if the alt text yields more than one, that is an error. If it
|
|
881
|
+
yields none, the backup stays.
|
|
882
|
+
|
|
883
|
+
```text
|
|
884
|
+
{{IF person.foto}}{{IMAGE person.foto}}{{ELSE}}{{IMAGE 'avatar.png'}}{{END-IF}}
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
For a choice between two pictures, the ternary operator is shorter:
|
|
888
|
+
|
|
889
|
+
```text
|
|
890
|
+
{{IMAGE person.foto ? person.foto : 'avatar.png'}}
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
Alt-text tags are rendered after the text of the slide, so variables from
|
|
894
|
+
`EXEC` apply. Loop variables of a `FOR` in the text do not, because a
|
|
895
|
+
loop in the text repeats paragraphs, not shapes.
|
|
896
|
+
|
|
897
|
+
In a [`flow()` card](https://daborsten.github.io/pptx-templates/text-flow.md#cards-one-entry-in-several-text-boxes)
|
|
898
|
+
(a group), `flow(list)` in the alt text of a picture or shape gives the
|
|
899
|
+
entries of that card, the same as in the text boxes of the card. So each
|
|
900
|
+
card shows the picture of its own entry:
|
|
901
|
+
|
|
902
|
+
```text
|
|
903
|
+
{{FOR p IN flow(people, 1)}}{{IMAGE p.foto}}{{END-FOR}}
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
Outside a card, `flow()` in an alt text is an error.
|
|
907
|
+
|
|
908
|
+
PowerPoint's *Picture (fill)* and *Picture (fit)* placeholders only take
|
|
909
|
+
effect when you insert a picture by hand; a generated file stores the crop
|
|
910
|
+
itself. The tag always crops as *fill* does.
|
|
911
|
+
|
|
826
912
|
### Expressions
|
|
827
913
|
|
|
828
914
|
Expressions support property paths (`a.b`, `a[0]`, `a['key']`, `a?.b`),
|
|
@@ -1127,8 +1213,15 @@ longer than the line by characters, and a line height of 1.2 × the font size
|
|
|
1127
1213
|
(× the line spacing). Text around the loop, such as a heading above it,
|
|
1128
1214
|
counts as well. The copies are thrown away; `EXEC` assignments of these trial
|
|
1129
1215
|
renders are undone, so a counter in the loop counts every entry once.
|
|
1130
|
-
|
|
1131
|
-
|
|
1216
|
+
Boxes that are the same apart from their position and name, such as three
|
|
1217
|
+
equal columns, share one measurement. Each box is measured by itself when
|
|
1218
|
+
the loop contains an `HTML` tag or an `errorHandler` is set, since those
|
|
1219
|
+
trial renders have effects beyond their text.
|
|
1220
|
+
Functions in the data run during these trial renders as well, how often
|
|
1221
|
+
depends on the boxes and is not fixed, so they should not count or change
|
|
1222
|
+
anything outside the template: a counter belongs in `EXEC`.
|
|
1223
|
+
|
|
1224
|
+
Measuring a slide with 24 entries in three boxes takes about 0.04 seconds.
|
|
1132
1225
|
|
|
1133
1226
|
### Fonts
|
|
1134
1227
|
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,52 @@ semver, with the pre-1.0 convention that **breaking changes bump the minor**.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.3.9] - 2026-11-22
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `{{IMAGE …}}` in the **alt text** of a picture placeholder (or any
|
|
14
|
+
picture or shape) fills it with the picture, cropped to cover it
|
|
15
|
+
without distortion, also in a circle. The placeholder keeps its
|
|
16
|
+
position, shape and link to the layout, so the picture can still be
|
|
17
|
+
replaced by hand in PowerPoint. A picture already in the placeholder is
|
|
18
|
+
the backup: it stays when the value is empty. The alt text can choose the
|
|
19
|
+
picture with `IF`/`ELSE`, `FOR`, `EXEC` or the ternary operator. In a
|
|
20
|
+
`flow()` card, `flow(list)` there gives the entry of the card, so every
|
|
21
|
+
card shows its own picture. `listTemplateCommands` and `lintTemplate` see
|
|
22
|
+
these tags too.
|
|
23
|
+
- Only an alt text that holds nothing but tags, with an `IMAGE` among
|
|
24
|
+
them, is rendered, with the configured delimiters. Every other alt text
|
|
25
|
+
stays as it is, as before (`Preis {{ in Euro`, `Foto: {{IMAGE foto}}`);
|
|
26
|
+
`lintTemplate` warns when one of them contains a tag. An `alt` from the
|
|
27
|
+
data is never rendered.
|
|
28
|
+
|
|
29
|
+
## [0.3.8] - 2026-11-19
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- `flow()` measures two to four times faster, with the same result:
|
|
34
|
+
`renderDeck` with 24 entries in three columns takes about 0.07 instead
|
|
35
|
+
of 0.15 seconds, with 1,000 entries about 0.8 instead of 3.5 seconds.
|
|
36
|
+
Nodes of the template are cloned without xmldom's slow `cloneNode`,
|
|
37
|
+
boxes that are the same apart from position and name share one
|
|
38
|
+
measurement (not with `HTML` tags or an `errorHandler`), and
|
|
39
|
+
`countFlowPages` no longer packs a .pptx it throws away, nor does
|
|
40
|
+
`renderDeck` unzip the deck again for each slide.
|
|
41
|
+
Functions in the data are called fewer times while measuring; one that
|
|
42
|
+
counts in a variable outside the template sees a different number.
|
|
43
|
+
Counters in `EXEC` are not affected.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- `cleanup` (with `removeExistingSlides`, as in `renderDeck`) keeps the
|
|
48
|
+
embeddings and charts of slide masters and layouts. It deleted every
|
|
49
|
+
file in `ppt/embeddings` and `ppt/charts` that was not copied with a
|
|
50
|
+
slide, so OLE objects on a master or layout (e.g. think-cell, an
|
|
51
|
+
embedded logo) and charts there, with their workbooks, pointed at
|
|
52
|
+
missing parts and PowerPoint offered to repair the file. The 0.3.7 fix
|
|
53
|
+
only covered embeddings of slides.
|
|
54
|
+
|
|
9
55
|
## [0.3.7] - 2026-11-18
|
|
10
56
|
|
|
11
57
|
### Fixed
|
|
@@ -349,7 +395,9 @@ for that history.
|
|
|
349
395
|
into one `.png` part. The fallback now gets the same placeholder PNG that
|
|
350
396
|
pptxgenjs 3.12 wrote.
|
|
351
397
|
|
|
352
|
-
[Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.
|
|
398
|
+
[Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.9...HEAD
|
|
399
|
+
[0.3.9]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.8...v0.3.9
|
|
400
|
+
[0.3.8]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.7...v0.3.8
|
|
353
401
|
[0.3.7]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.6...v0.3.7
|
|
354
402
|
[0.3.6]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.5...v0.3.6
|
|
355
403
|
[0.3.5]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.4...v0.3.5
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import IArchive from '../../interfaces/iarchive';
|
|
2
|
+
/**
|
|
3
|
+
* Files in `ppt/charts` and `ppt/embeddings` that a slide master or layout
|
|
4
|
+
* of the archive uses, by folder: OLE objects and embedded documents (e.g.
|
|
5
|
+
* think-cell, a logo object on the master), charts, and what these point
|
|
6
|
+
* at in turn (a chart's style, colors and workbook).
|
|
7
|
+
*
|
|
8
|
+
* `cleanup` keeps masters and layouts as they are, but removed every chart
|
|
9
|
+
* and embedding that was not copied with a slide: the relationships of the
|
|
10
|
+
* masters and layouts then pointed at missing parts, and PowerPoint offered
|
|
11
|
+
* to repair the file. `removeUnusedFiles` keeps these files.
|
|
12
|
+
*/
|
|
13
|
+
export declare function partsOfMastersAndLayouts(archive: IArchive): Promise<Record<string, string[]>>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.partsOfMastersAndLayouts = partsOfMastersAndLayouts;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
/** Parts whose relationships the search starts from. */
|
|
18
|
+
const MASTER_DIRS = ['ppt/slideMasters', 'ppt/slideLayouts'];
|
|
19
|
+
/**
|
|
20
|
+
* Folders `ModifyPresentationHelper.removeUnusedFiles` empties of the files
|
|
21
|
+
* it did not copy with a slide, and whose parts masters and layouts use.
|
|
22
|
+
*/
|
|
23
|
+
const KEPT_DIRS = ['ppt/charts', 'ppt/embeddings'];
|
|
24
|
+
/**
|
|
25
|
+
* Files in `ppt/charts` and `ppt/embeddings` that a slide master or layout
|
|
26
|
+
* of the archive uses, by folder: OLE objects and embedded documents (e.g.
|
|
27
|
+
* think-cell, a logo object on the master), charts, and what these point
|
|
28
|
+
* at in turn (a chart's style, colors and workbook).
|
|
29
|
+
*
|
|
30
|
+
* `cleanup` keeps masters and layouts as they are, but removed every chart
|
|
31
|
+
* and embedding that was not copied with a slide: the relationships of the
|
|
32
|
+
* masters and layouts then pointed at missing parts, and PowerPoint offered
|
|
33
|
+
* to repair the file. `removeUnusedFiles` keeps these files.
|
|
34
|
+
*/
|
|
35
|
+
function partsOfMastersAndLayouts(archive) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const queue = [];
|
|
38
|
+
for (const dir of MASTER_DIRS) {
|
|
39
|
+
for (const file of yield archive.folder(`${dir}/_rels`)) {
|
|
40
|
+
if (file.name.endsWith('.rels'))
|
|
41
|
+
queue.push(file.name);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const keep = {};
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
while (queue.length) {
|
|
47
|
+
for (const target of yield internalTargets(archive, queue.shift())) {
|
|
48
|
+
const dir = path_1.default.posix.dirname(target);
|
|
49
|
+
if (!KEPT_DIRS.includes(dir) || seen.has(target))
|
|
50
|
+
continue;
|
|
51
|
+
seen.add(target);
|
|
52
|
+
keep[dir] = [...(keep[dir] || []), path_1.default.posix.basename(target)];
|
|
53
|
+
const rels = relsOf(target);
|
|
54
|
+
if (archive.fileExists(rels))
|
|
55
|
+
queue.push(rels);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return keep;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Archive paths of the parts a .rels file points at, external ones left out. */
|
|
62
|
+
function internalTargets(archive, relsFile) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
// Targets are relative to the part's folder, not to its _rels folder.
|
|
65
|
+
const partDir = path_1.default.posix.dirname(path_1.default.posix.dirname(relsFile));
|
|
66
|
+
const relationships = (yield archive.readXml(relsFile)).getElementsByTagName('Relationship');
|
|
67
|
+
const targets = [];
|
|
68
|
+
for (let i = 0; i < relationships.length; i++) {
|
|
69
|
+
const rel = relationships.item(i);
|
|
70
|
+
if (rel.getAttribute('TargetMode') === 'External')
|
|
71
|
+
continue;
|
|
72
|
+
const target = rel.getAttribute('Target') || '';
|
|
73
|
+
targets.push(target.startsWith('/')
|
|
74
|
+
? path_1.default.posix.normalize(target.slice(1))
|
|
75
|
+
: path_1.default.posix.normalize(path_1.default.posix.join(partDir, target)));
|
|
76
|
+
}
|
|
77
|
+
return targets;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/** `ppt/charts/chart1.xml` → `ppt/charts/_rels/chart1.xml.rels`. */
|
|
81
|
+
function relsOf(part) {
|
|
82
|
+
return `${path_1.default.posix.dirname(part)}/_rels/${path_1.default.posix.basename(part)}.rels`;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/master-parts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAuBA,4DAuBC;AA9CD,gDAAwB;AAGxB,wDAAwD;AACxD,MAAM,WAAW,GAAG,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC;AAE7D;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,SAAsB,wBAAwB,CAC5C,OAAiB;;QAEjB,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,KAAK,MAAM,IAAI,IAAI,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,GAAG,QAAQ,CAAC,EAAE,CAAC;gBACxD,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;oBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,MAAM,IAAI,GAA6B,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;YACpB,KAAK,MAAM,MAAM,IAAI,MAAM,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;gBACnE,MAAM,GAAG,GAAG,cAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACvC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;oBAAE,SAAS;gBAC3D,IAAI,CAA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C,CAAC,CAAC,CAAC;gBACvC,CAAC,CAAC,cAAI,CAAC,KAAK,CAAC,SAAS,CAAC,cAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAC3D,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA;AAED,oEAAoE;AACpE,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,GAAG,cAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,cAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;AAC/E,CAAC"}
|
|
@@ -6,6 +6,8 @@ import { CornerRadius, RoundedShapePreset, ShapeAdjustments, ShapePreset } from
|
|
|
6
6
|
*/
|
|
7
7
|
export { ShapePresets } from './presets';
|
|
8
8
|
export * from './types';
|
|
9
|
+
/** CT_ShapeProperties sequence (children of p:spPr). */
|
|
10
|
+
export declare const SPPR_CHILD_ORDER: string[];
|
|
9
11
|
export type Geometry = {
|
|
10
12
|
prst: ShapePreset;
|
|
11
13
|
adjustments: ShapeAdjustments;
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.setCornerRadius = exports.setGeometry = exports.applyGeometry = exports.resolveGeometry = exports.cornerRadiusFraction = exports.isRoundedShapePreset = exports.isShapePreset = exports.ShapePresets = void 0;
|
|
17
|
+
exports.setCornerRadius = exports.setGeometry = exports.applyGeometry = exports.resolveGeometry = exports.cornerRadiusFraction = exports.isRoundedShapePreset = exports.isShapePreset = exports.SPPR_CHILD_ORDER = exports.ShapePresets = void 0;
|
|
18
18
|
const xml_helper_1 = require("../../helper/xml-helper");
|
|
19
19
|
const presets_1 = require("./presets");
|
|
20
20
|
/**
|
|
@@ -39,7 +39,7 @@ const EMU_PER_UNIT = {
|
|
|
39
39
|
px: 9525, // CSS pixel, 96 dpi
|
|
40
40
|
};
|
|
41
41
|
/** CT_ShapeProperties sequence (children of p:spPr). */
|
|
42
|
-
|
|
42
|
+
exports.SPPR_CHILD_ORDER = [
|
|
43
43
|
'a:xfrm',
|
|
44
44
|
'a:custGeom',
|
|
45
45
|
'a:prstGeom',
|
|
@@ -192,7 +192,7 @@ const applyGeometry = (spPr, geometry) => {
|
|
|
192
192
|
spPr.replaceChild(prstGeom, existing);
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
|
-
xml_helper_1.XmlHelper.insertInSchemaOrder(spPr, prstGeom, SPPR_CHILD_ORDER);
|
|
195
|
+
xml_helper_1.XmlHelper.insertInSchemaOrder(spPr, prstGeom, exports.SPPR_CHILD_ORDER);
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
exports.applyGeometry = applyGeometry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/shape-geometry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,wDAAoD;AACpD,uCAAmE;AAQnE;;;GAGG;AAEH,qCAAyC;AAAhC,uGAAA,YAAY,OAAA;AACrB,0CAAwB;AAExB,wEAAwE;AACxE,MAAM,yBAAyB,GAAuC;IACpE,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,KAAK;IACjB,cAAc,EAAE,MAAM;IACtB,cAAc,EAAE,MAAM;IACtB,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF,MAAM,YAAY,GAA2B;IAC3C,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,IAAI,EAAE,oBAAoB;CAC/B,CAAC;AAEF,wDAAwD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/shape-ge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;IAC5B,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,MAAM,GACV,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,CAAC,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACnE,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAA,uBAAe,EACxB,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,EACvC,SAAS,CAAC,IAAI,CAAC,CAChB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,oBAAqB,KAAe,CAAC,OAAO,EAAE,EAAE;YAC9D,KAAK,EAAE,KAAK;SACb,CAAC,CAAC;IACL,CAAC;IACD,IAAA,qBAAa,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AAnBS,QAAA,eAAe,mBAmBxB"}
|
|
@@ -18,6 +18,7 @@ const jszip_1 = __importDefault(require("jszip"));
|
|
|
18
18
|
const xmldom_1 = require("@xmldom/xmldom");
|
|
19
19
|
const commands_1 = require("../template-logic/commands");
|
|
20
20
|
const expression_1 = require("../template-logic/expression");
|
|
21
|
+
const types_1 = require("../template-logic/types");
|
|
21
22
|
const data_model_1 = require("./data-model");
|
|
22
23
|
const hints_1 = require("./hints");
|
|
23
24
|
const usage_1 = require("./usage");
|
|
@@ -30,6 +31,17 @@ const BUILTIN_HELPERS = {
|
|
|
30
31
|
flowPage: 1,
|
|
31
32
|
flowPages: 1,
|
|
32
33
|
};
|
|
34
|
+
/** Commands that work in alt text (renderAltTexts). */
|
|
35
|
+
const ALT_TEXT_COMMANDS = [
|
|
36
|
+
'IMAGE',
|
|
37
|
+
'IF',
|
|
38
|
+
'ELSE-IF',
|
|
39
|
+
'ELSE',
|
|
40
|
+
'END-IF',
|
|
41
|
+
'FOR',
|
|
42
|
+
'END-FOR',
|
|
43
|
+
'EXEC',
|
|
44
|
+
];
|
|
33
45
|
const ANY = { kind: 'any' };
|
|
34
46
|
const children = (parent, tagName) => {
|
|
35
47
|
const result = [];
|
|
@@ -45,7 +57,7 @@ const descendants = (parent, tagName) => Array.from(parent.getElementsByTagName(
|
|
|
45
57
|
const parseXml = (xml) => new xmldom_1.DOMParser().parseFromString(xml, 'application/xml');
|
|
46
58
|
const shapeOf = (node) => {
|
|
47
59
|
for (let n = node.parentNode; n; n = n.parentNode) {
|
|
48
|
-
if (
|
|
60
|
+
if (['p:sp', 'p:pic', 'p:graphicFrame'].includes(n.tagName))
|
|
49
61
|
return n;
|
|
50
62
|
}
|
|
51
63
|
return undefined;
|
|
@@ -103,6 +115,16 @@ const containersOf = (doc) => {
|
|
|
103
115
|
});
|
|
104
116
|
};
|
|
105
117
|
visit(doc);
|
|
118
|
+
// {{IMAGE …}} in alt text, rendered after all text (renderAltTexts)
|
|
119
|
+
descendants(doc, 'p:cNvPr').forEach((cNvPr) => {
|
|
120
|
+
const descr = cNvPr.getAttribute('descr');
|
|
121
|
+
if (descr) {
|
|
122
|
+
containers.push({
|
|
123
|
+
kind: 'alt',
|
|
124
|
+
segments: [{ text: descr, paragraph: cNvPr }],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
106
128
|
return containers;
|
|
107
129
|
};
|
|
108
130
|
const resolvePath = (base, target) => {
|
|
@@ -207,9 +229,76 @@ class TemplateLinter {
|
|
|
207
229
|
inner: m[1],
|
|
208
230
|
})).filter((tag) => !(0, commands_1.isTableMarker)(tag.inner));
|
|
209
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Splits off the alt texts the renderer leaves as they are (not
|
|
234
|
+
* isAltTextTemplate): one with a tag in it gets a warning, as the tag
|
|
235
|
+
* most likely was meant to work.
|
|
236
|
+
*/
|
|
237
|
+
altTextTemplates(all, report) {
|
|
238
|
+
// ALIAS definitions in the text, which the renderer knows by then
|
|
239
|
+
const aliases = new Map();
|
|
240
|
+
all
|
|
241
|
+
.filter((container) => container.kind !== 'alt')
|
|
242
|
+
.flatMap((container) => container.segments)
|
|
243
|
+
.flatMap((segment) => this.tagsIn(segment.text))
|
|
244
|
+
.forEach(({ raw, inner }) => {
|
|
245
|
+
try {
|
|
246
|
+
const command = this.parse(inner, aliases, raw);
|
|
247
|
+
if (command.type === 'ALIAS') {
|
|
248
|
+
aliases.set(command.name, command.code);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (_a) {
|
|
252
|
+
// reported at the tag
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
const commandType = (inner, raw) => {
|
|
256
|
+
try {
|
|
257
|
+
return this.parse(inner, aliases, raw).type;
|
|
258
|
+
}
|
|
259
|
+
catch (_a) {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const { opening, closing, pattern } = this.syntax;
|
|
264
|
+
return all.filter((container) => {
|
|
265
|
+
if (container.kind !== 'alt')
|
|
266
|
+
return true;
|
|
267
|
+
const { text, paragraph } = container.segments[0];
|
|
268
|
+
if ((0, commands_1.isAltTextTemplate)(text, pattern, commandType))
|
|
269
|
+
return true;
|
|
270
|
+
const [first] = this.tagsIn(text);
|
|
271
|
+
if (first) {
|
|
272
|
+
report({
|
|
273
|
+
severity: 'warning',
|
|
274
|
+
rule: 'unsupported-location',
|
|
275
|
+
shape: shapeName(shapeOf(paragraph)),
|
|
276
|
+
tag: first.raw,
|
|
277
|
+
message: 'This alt text stays as it is: tags in alt text work only when ' +
|
|
278
|
+
'it holds nothing but tags, with an IMAGE among them',
|
|
279
|
+
hint: `Remove the other text (a description for screen readers goes into ` +
|
|
280
|
+
`${opening}IMAGE ({ data: …, alt: "…" })${closing}), or remove the tag.`,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
/** Alt text that is a template: on a picture or shape. */
|
|
287
|
+
checkAltText(segment, report) {
|
|
288
|
+
var _a;
|
|
289
|
+
const holder = (_a = segment.paragraph.parentNode) === null || _a === void 0 ? void 0 : _a.parentNode;
|
|
290
|
+
if (holder && !['p:sp', 'p:pic'].includes(holder.tagName)) {
|
|
291
|
+
report({
|
|
292
|
+
severity: 'error',
|
|
293
|
+
rule: 'unsupported-location',
|
|
294
|
+
message: `IMAGE in alt text works on pictures, placeholders and shapes, not on <${holder.tagName}>`,
|
|
295
|
+
hint: 'Write the tag into the alt text of a picture or shape.',
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
210
299
|
lintSlide(part, slide, doc) {
|
|
211
300
|
const report = (issue) => this.report(part, slide, issue);
|
|
212
|
-
const containers = containersOf(doc);
|
|
301
|
+
const containers = this.altTextTemplates(containersOf(doc), report);
|
|
213
302
|
const allTags = containers.flatMap((c) => c.segments.flatMap((s) => this.tagsIn(s.text)));
|
|
214
303
|
// ALIAS and EXEC names apply to the whole render call: collect up front
|
|
215
304
|
const aliases = new Map();
|
|
@@ -238,10 +327,13 @@ class TemplateLinter {
|
|
|
238
327
|
const stack = [];
|
|
239
328
|
const where = container.kind === 'table' ? 'table' : 'shape';
|
|
240
329
|
container.segments.forEach((segment) => {
|
|
241
|
-
var _a, _b, _c, _d, _e;
|
|
330
|
+
var _a, _b, _c, _d, _e, _f;
|
|
242
331
|
const shape = shapeOf(segment.paragraph);
|
|
243
332
|
const name = shapeName(shape);
|
|
244
333
|
this.checkDelimiters(segment.text, (issue) => report(Object.assign(Object.assign({}, issue), { shape: name })));
|
|
334
|
+
if (container.kind === 'alt') {
|
|
335
|
+
this.checkAltText(segment, (issue) => report(Object.assign(Object.assign({}, issue), { shape: name })));
|
|
336
|
+
}
|
|
245
337
|
for (const { raw, inner } of this.tagsIn(segment.text)) {
|
|
246
338
|
// Without a more precise range, the whole tag is marked
|
|
247
339
|
const tagReport = (issue) => {
|
|
@@ -268,6 +360,16 @@ class TemplateLinter {
|
|
|
268
360
|
});
|
|
269
361
|
continue;
|
|
270
362
|
}
|
|
363
|
+
if (container.kind === 'alt' &&
|
|
364
|
+
!ALT_TEXT_COMMANDS.includes(command.type)) {
|
|
365
|
+
tagReport({
|
|
366
|
+
severity: 'error',
|
|
367
|
+
rule: 'unsupported-location',
|
|
368
|
+
message: `${raw} does not work in alt text; only IMAGE, IF, FOR and EXEC do`,
|
|
369
|
+
hint: 'Put the tag into the text of a shape.',
|
|
370
|
+
});
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
271
373
|
const loopVars = new Map(stack.flatMap((block) => block.vars));
|
|
272
374
|
const paths = new Map([
|
|
273
375
|
...execPaths,
|
|
@@ -416,14 +518,26 @@ class TemplateLinter {
|
|
|
416
518
|
hint: 'Put the tag into a text box or shape on top of the table.',
|
|
417
519
|
});
|
|
418
520
|
}
|
|
521
|
+
else if (container.kind === 'alt') {
|
|
522
|
+
// Location checked by checkAltText; size and rotation
|
|
523
|
+
// come from the shape it fills
|
|
524
|
+
const fixed = ((_f = expr === null || expr === void 0 ? void 0 : expr.imageOptionKeys()) !== null && _f !== void 0 ? _f : []).filter((key) => types_1.FILL_FIXED_OPTIONS.includes(key));
|
|
525
|
+
[...new Set(fixed)].forEach((key) => tagReport({
|
|
526
|
+
severity: 'error',
|
|
527
|
+
rule: 'unsupported-location',
|
|
528
|
+
message: `IMAGE in alt text fills the shape; "${key}" is not supported there`,
|
|
529
|
+
hint: 'Size and rotation come from the shape: remove the option, or resize the shape in PowerPoint.',
|
|
530
|
+
}));
|
|
531
|
+
}
|
|
419
532
|
else if (!hasOwnFrame(shape)) {
|
|
420
533
|
tagReport({
|
|
421
534
|
severity: 'error',
|
|
422
535
|
rule: 'unsupported-location',
|
|
423
536
|
message: 'IMAGE needs a shape with its own position and size; ' +
|
|
424
537
|
'this one inherits them from the layout',
|
|
425
|
-
hint: '
|
|
426
|
-
'
|
|
538
|
+
hint: 'Write the tag into the alt text of the placeholder ' +
|
|
539
|
+
'instead (it then fills the placeholder), move or resize ' +
|
|
540
|
+
'the placeholder once in PowerPoint, or use a text box.',
|
|
427
541
|
});
|
|
428
542
|
}
|
|
429
543
|
break;
|