pptx-templates 0.1.1 → 0.1.2

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 CHANGED
@@ -764,6 +764,7 @@ pres.addSlide('TextReplace.pptx', 1, (slide) => {
764
764
  ```text
765
765
  {{IMAGE ({ data: logo, extension: '.png', width: 4, alt: 'Logo' })}}
766
766
  {{FOR p IN photos}}{{IMAGE ({ data: p })}}{{END-FOR}}
767
+ {{IMAGE ({ data: logo, extension: '.png', shape: 'ellipse', border: { color: '#1f4e79', width: 2 } })}}
767
768
  ```
768
769
 
769
770
  | Property | Effect |
@@ -773,6 +774,10 @@ pres.addSlide('TextReplace.pptx', 1, (slide) => {
773
774
  | `width`, `height` | Size in cm. With only one of them, the other keeps the aspect ratio. Without both, the picture fits into the shape, keeping its aspect ratio |
774
775
  | `alt` | Alternative text |
775
776
  | `rotation` | Rotation in degrees, clockwise |
777
+ | `shape` | Shape the picture is cropped to: any DrawingML preset, e.g. `'ellipse'`, `'heart'`, `'star5'` (see [Shape Geometry](https://daborsten.github.io/pptx-templates/shape-geometry.md)). Default `'rect'`, or `'roundRect'` with `cornerRadius` |
778
+ | `cornerRadius` | Corner radius on the shorter side: a number in cm, or `'10%'`, `'12px'`, `'4pt'`. At most `'50%'`. Only for `roundRect`, `round1Rect`, `round2SameRect`, `round2DiagRect`, `snipRoundRect` |
779
+ | `shapeAdjustments` | Raw adjust values of the shape, e.g. `{ adj: 25000 }`. Win over `cornerRadius` |
780
+ | `border` | `{ color, width }`: hex color (`'#1f4e79'`) and width in pt |
776
781
 
777
782
  PPTX text cannot contain pictures, so the picture is placed **at the shape
778
783
  that holds the tag**, centered in its frame. Several pictures from one shape,
@@ -871,6 +876,98 @@ const commands = await listTemplateCommands('templates/Offer.pptx');
871
876
  - Text inserted from your data is never rendered again, so a value that
872
877
  contains `{{` stays literal.
873
878
 
879
+ ## Shape Geometry
880
+
881
+ Every shape and picture in PowerPoint has a geometry: a rectangle, an
882
+ ellipse, a heart, one of about 190 presets. With a picture, the geometry is
883
+ the mask the picture is cropped to (PowerPoint: *Crop to Shape*). Two
884
+ `modify.*` helpers change it. They work on `<p:sp>` (shapes) and `<p:pic>`
885
+ (pictures).
886
+
887
+ ```ts
888
+ import { modify } from 'pptx-templates';
889
+
890
+ pres.addSlide('SlideWithImages.pptx', 2, (slide) => {
891
+ // Crop a picture to an ellipse
892
+ slide.modifyElement('imagePNG', modify.setGeometry('ellipse'));
893
+
894
+ // Any preset, with the raw adjust values (the yellow handles)
895
+ slide.modifyElement('imageJPG', modify.setGeometry('star5', { adj: 30000 }));
896
+
897
+ // Rounded corners: in percent, px, pt, cm or mm
898
+ slide.modifyElement('imagePNGduotone', [
899
+ modify.setCornerRadius('12px'),
900
+ // Border: setOutline, width in EMU (1pt = 12700)
901
+ modify.setOutline({
902
+ weight: 25400,
903
+ color: { type: 'srgbClr', value: '1F4E79' },
904
+ }),
905
+ ]);
906
+ });
907
+ ```
908
+
909
+ ### `modify.setGeometry(shape, adjustments?)`
910
+
911
+ Replaces the preset or custom geometry of the element with `shape`.
912
+ `shape` is any name of the DrawingML spec (`ShapePresets` holds the full
913
+ list), e.g. `'rect'`, `'roundRect'`, `'ellipse'`, `'triangle'`, `'hexagon'`,
914
+ `'star5'`, `'heart'`, `'cloud'`, `'flowChartDocument'`.
915
+
916
+ `adjustments` sets the adjust values of the shape, keyed by guide name, e.g.
917
+ `{ adj: 25000 }`. Names and value ranges depend on the shape. Most are in
918
+ 1/100000 of the shorter side, so `25000` is 25 %. Without `adjustments`,
919
+ the shape uses PowerPoint's defaults. Guides you leave out get their
920
+ default value, because PowerPoint asks to repair a file that lists only some
921
+ of them (`star5` with only `adj` is written as `adj`, `hf`, `vf`). A guide
922
+ name the shape does not have is an error.
923
+
924
+ ### `modify.setCornerRadius(radius, shape?)`
925
+
926
+ Rounds the corners. The radius is measured on the shorter side of the
927
+ element and capped at half of it.
928
+
929
+ | `radius` | Meaning |
930
+ |---|---|
931
+ | `0.5` (number) | Centimeters, as in docx-templates |
932
+ | `'10%'` | Percent of the shorter side. `'50%'` makes the short sides fully round |
933
+ | `'12px'` | CSS pixels at 96 dpi (1px = 9525 EMU) |
934
+ | `'4pt'`, `'0.5cm'`, `'5mm'` | Points, centimeters, millimeters |
935
+
936
+ PPTX stores the radius as a fraction of the shorter side, not as a
937
+ length. `px`, `pt`, `cm` and `mm` are converted with the size the element
938
+ has when the callback runs. If you resize the element afterwards, the
939
+ corners scale with it. Absolute units need an element with its own size; a
940
+ placeholder that inherits its size from the layout only takes a percentage.
941
+
942
+ `shape` picks the rounded preset:
943
+
944
+ | `shape` | Corners |
945
+ |---|---|
946
+ | `'roundRect'` (default) | all four |
947
+ | `'round1Rect'` | top right |
948
+ | `'round2SameRect'` | top two |
949
+ | `'round2DiagRect'` | top left and bottom right |
950
+ | `'snipRoundRect'` | top left round, top right cut |
951
+
952
+ Without `shape`, an element that already has one of these presets keeps it
953
+ and only its radius changes; any other element becomes a `roundRect`.
954
+
955
+ ### Borders
956
+
957
+ Borders are the outline of the shape, set with `modify.setOutline` (see
958
+ [Helpers](https://daborsten.github.io/pptx-templates/helpers.md)). On a cropped picture, the border follows the
959
+ geometry, so an ellipse gets a round border.
960
+
961
+ ### In templates
962
+
963
+ The `{{IMAGE}}` tag of [Template Logic](https://daborsten.github.io/pptx-templates/template-logic.md#images) takes the
964
+ same options as docx-templates: `shape`, `cornerRadius`, `shapeAdjustments`
965
+ and `border`.
966
+
967
+ ```text
968
+ {{IMAGE ({ data: logo, extension: '.png', width: 4, cornerRadius: '10%', border: { color: '#1f4e79', width: 2 } })}}
969
+ ```
970
+
874
971
  ## Modify Tables
875
972
 
876
973
  You can use a PowerPoint table and add/modify data and style. It is also possible to add rows and columns and to style cells.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ All notable changes to this project are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
5
  semver, with the pre-1.0 convention that **breaking changes bump the minor**.
6
6
 
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.2] - 2026-11-05
10
+
11
+ ### Added
12
+
13
+ - `modify.setGeometry(shape, adjustments?)` crops a picture or shape to any
14
+ DrawingML preset geometry (*Crop to Shape*), e.g. `'ellipse'`, `'heart'`.
15
+ - `modify.setCornerRadius(radius, shape?)` rounds corners; the radius is a
16
+ number in cm or a string in `%`, `px`, `pt`, `cm` or `mm`.
17
+ - `{{IMAGE}}` takes `shape`, `cornerRadius`, `shapeAdjustments` and `border`,
18
+ as in docx-templates (`src/extensions/shape-geometry/`).
19
+
7
20
  ## [0.1.1] - 2026-11-04
8
21
 
9
22
  ### Fixed
@@ -52,5 +65,7 @@ for that history.
52
65
  into one `.png` part. The fallback now gets the same placeholder PNG that
53
66
  pptxgenjs 3.12 wrote.
54
67
 
55
- [Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.0...HEAD
68
+ [Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.2...HEAD
69
+ [0.1.2]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.1...v0.1.2
70
+ [0.1.1]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.0...v0.1.1
56
71
  [0.1.0]: https://github.com/DaBorsten/pptx-templates/releases/tag/v0.1.0
@@ -1,5 +1,8 @@
1
1
  /** Spread into the public `modify` namespace in src/index.ts. */
2
2
  export declare const extensionModifiers: {
3
3
  renderTemplate: (data: import("./template-logic").TemplateData | Promise<import("./template-logic").TemplateData>, options?: import("./template-logic").RenderTemplateOptions) => (element: import("..").XmlDocument | import("..").XmlElement, context?: unknown) => Promise<void>;
4
+ setGeometry: (shape: import("./shape-geometry").ShapePreset, adjustments?: import("./shape-geometry").ShapeAdjustments) => (element: import("..").XmlElement) => void;
5
+ setCornerRadius: (radius: import("./shape-geometry").CornerRadius, shape?: import("./shape-geometry").RoundedShapePreset) => (element: import("..").XmlElement) => void;
4
6
  };
5
7
  export * from './template-logic';
8
+ export { ShapePresets, ShapePreset, RoundedShapePreset, CornerRadius, ShapeAdjustments, ImageBorder, } from './shape-geometry';
@@ -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.extensionModifiers = void 0;
17
+ exports.ShapePresets = exports.extensionModifiers = void 0;
18
18
  /**
19
19
  * Fork extensions (not part of upstream singerla/pptx-automizer).
20
20
  *
@@ -23,9 +23,14 @@ exports.extensionModifiers = void 0;
23
23
  * See FORK.md.
24
24
  */
25
25
  const template_logic_1 = require("./template-logic");
26
+ const shape_geometry_1 = require("./shape-geometry");
26
27
  /** Spread into the public `modify` namespace in src/index.ts. */
27
28
  exports.extensionModifiers = {
28
29
  renderTemplate: template_logic_1.renderTemplate,
30
+ setGeometry: shape_geometry_1.setGeometry,
31
+ setCornerRadius: shape_geometry_1.setCornerRadius,
29
32
  };
30
33
  __exportStar(require("./template-logic"), exports);
34
+ var shape_geometry_2 = require("./shape-geometry");
35
+ Object.defineProperty(exports, "ShapePresets", { enumerable: true, get: function () { return shape_geometry_2.ShapePresets; } });
31
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAAkD;AAElD,iEAAiE;AACpD,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAd,+BAAc;CACf,CAAC;AAEF,mDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,qDAAkD;AAClD,qDAAgE;AAEhE,iEAAiE;AACpD,QAAA,kBAAkB,GAAG;IAChC,cAAc,EAAd,+BAAc;IACd,WAAW,EAAX,4BAAW;IACX,eAAe,EAAf,gCAAe;CAChB,CAAC;AAEF,mDAAiC;AACjC,mDAO0B;AANxB,8GAAA,YAAY,OAAA"}
@@ -0,0 +1,53 @@
1
+ import { XmlElement } from '../../types/xml-types';
2
+ import { CornerRadius, RoundedShapePreset, ShapeAdjustments, ShapePreset } from './types';
3
+ /**
4
+ * Shape geometry: crop a picture or shape to any preset geometry ("Crop to
5
+ * Shape" in PowerPoint) and set corner radii in cm, px, pt or percent.
6
+ */
7
+ export { ShapePresets } from './presets';
8
+ export * from './types';
9
+ export type Geometry = {
10
+ prst: ShapePreset;
11
+ adjustments: ShapeAdjustments;
12
+ };
13
+ export declare const isShapePreset: (name: unknown) => name is ShapePreset;
14
+ export declare const isRoundedShapePreset: (name: unknown) => name is RoundedShapePreset;
15
+ /**
16
+ * Corner radius as fraction of the shorter side. `shorterSide` (EMU) is only
17
+ * needed for absolute units.
18
+ */
19
+ export declare const cornerRadiusFraction: (radius: CornerRadius, shorterSide?: number) => number;
20
+ /**
21
+ * Resolves the docx-templates style options into a preset geometry and its
22
+ * adjust values. `shapeAdjustments` win over `cornerRadius`.
23
+ */
24
+ export declare const resolveGeometry: (options: {
25
+ shape?: string;
26
+ cornerRadius?: CornerRadius;
27
+ shapeAdjustments?: ShapeAdjustments;
28
+ }, size?: {
29
+ cx: number;
30
+ cy: number;
31
+ }) => Geometry;
32
+ /** Writes <a:prstGeom> into p:spPr, replacing a preset or custom geometry. */
33
+ export declare const applyGeometry: (spPr: XmlElement, geometry: Geometry) => void;
34
+ /**
35
+ * Crops a picture or shape to a preset geometry, like "Crop to Shape" in
36
+ * PowerPoint: `setGeometry('ellipse')`, `setGeometry('heart')`. Replaces the
37
+ * current preset or custom geometry.
38
+ *
39
+ * @param shape - Any DrawingML preset geometry (see `ShapePresets`)
40
+ * @param adjustments - Optional raw adjust values, e.g. `{ adj: 25000 }`
41
+ */
42
+ export declare const setGeometry: (shape: ShapePreset, adjustments?: ShapeAdjustments) => (element: XmlElement) => void;
43
+ /**
44
+ * Rounds the corners of a picture or shape. The radius is measured on the
45
+ * shorter side and capped at half of it:
46
+ * `setCornerRadius('10%')`, `setCornerRadius('12px')`, `setCornerRadius(0.5)`
47
+ * (cm). A shape that already is one of the rounded presets keeps it;
48
+ * anything else becomes a `roundRect`, unless `shape` says otherwise.
49
+ *
50
+ * @param radius - Number in cm, or a string in %, px, pt, cm or mm
51
+ * @param shape - Rounded preset to use, e.g. 'round2SameRect' (top corners)
52
+ */
53
+ export declare const setCornerRadius: (radius: CornerRadius, shape?: RoundedShapePreset) => (element: XmlElement) => void;
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
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;
18
+ const xml_helper_1 = require("../../helper/xml-helper");
19
+ const presets_1 = require("./presets");
20
+ /**
21
+ * Shape geometry: crop a picture or shape to any preset geometry ("Crop to
22
+ * Shape" in PowerPoint) and set corner radii in cm, px, pt or percent.
23
+ */
24
+ var presets_2 = require("./presets");
25
+ Object.defineProperty(exports, "ShapePresets", { enumerable: true, get: function () { return presets_2.ShapePresets; } });
26
+ __exportStar(require("./types"), exports);
27
+ /** Name of the adjust value that holds the corner radius, per shape. */
28
+ const CORNER_RADIUS_ADJUSTMENTS = {
29
+ roundRect: 'adj',
30
+ round1Rect: 'adj',
31
+ round2SameRect: 'adj1',
32
+ round2DiagRect: 'adj1',
33
+ snipRoundRect: 'adj1',
34
+ };
35
+ const EMU_PER_UNIT = {
36
+ cm: 360000,
37
+ mm: 36000,
38
+ pt: 12700,
39
+ px: 9525, // CSS pixel, 96 dpi
40
+ };
41
+ /** CT_ShapeProperties sequence (children of p:spPr). */
42
+ const SPPR_CHILD_ORDER = [
43
+ 'a:xfrm',
44
+ 'a:custGeom',
45
+ 'a:prstGeom',
46
+ 'a:noFill',
47
+ 'a:solidFill',
48
+ 'a:gradFill',
49
+ 'a:blipFill',
50
+ 'a:pattFill',
51
+ 'a:grpFill',
52
+ 'a:ln',
53
+ 'a:effectLst',
54
+ 'a:effectDag',
55
+ 'a:scene3d',
56
+ 'a:sp3d',
57
+ 'a:extLst',
58
+ ];
59
+ const isShapePreset = (name) => typeof name === 'string' &&
60
+ presets_1.ShapePresets.includes(name);
61
+ exports.isShapePreset = isShapePreset;
62
+ const isRoundedShapePreset = (name) => typeof name === 'string' && Object.hasOwn(CORNER_RADIUS_ADJUSTMENTS, name);
63
+ exports.isRoundedShapePreset = isRoundedShapePreset;
64
+ const assertPreset = (shape) => {
65
+ if (!(0, exports.isShapePreset)(shape)) {
66
+ throw new Error(`invalid shape: ${String(shape)} (must be a DrawingML preset geometry, e.g. 'roundRect' or 'ellipse')`);
67
+ }
68
+ return shape;
69
+ };
70
+ /**
71
+ * Validates adjust values and completes them: PowerPoint asks to repair a
72
+ * file whose <a:avLst> names only some of the guides of a preset, so the
73
+ * missing ones get their defaults (in definition order). Empty stays empty,
74
+ * which means "all defaults".
75
+ */
76
+ const completeAdjustments = (prst, adjustments = {}) => {
77
+ var _a;
78
+ const defaults = (_a = presets_1.PresetAdjustmentDefaults[prst]) !== null && _a !== void 0 ? _a : {};
79
+ for (const [name, value] of Object.entries(adjustments)) {
80
+ if (!Object.hasOwn(defaults, name)) {
81
+ const known = Object.keys(defaults);
82
+ throw new Error(`shape ${prst} has no adjustment ${name} ` +
83
+ (known.length ? `(use ${known.join(', ')})` : '(it has none)'));
84
+ }
85
+ if (!Number.isFinite(value)) {
86
+ throw new Error(`invalid shape adjustment ${name}: ${value}`);
87
+ }
88
+ }
89
+ if (!Object.keys(adjustments).length)
90
+ return {};
91
+ return Object.assign(Object.assign({}, defaults), adjustments);
92
+ };
93
+ /**
94
+ * Corner radius as fraction of the shorter side. `shorterSide` (EMU) is only
95
+ * needed for absolute units.
96
+ */
97
+ const cornerRadiusFraction = (radius, shorterSide) => {
98
+ var _a;
99
+ let fraction = NaN;
100
+ let absolute;
101
+ if (typeof radius === 'number') {
102
+ absolute = radius * EMU_PER_UNIT.cm;
103
+ }
104
+ else if (typeof radius === 'string') {
105
+ const match = /^\s*(\d+(?:\.\d+)?)\s*(%|cm|mm|pt|px)?\s*$/i.exec(radius);
106
+ if (match) {
107
+ const value = Number(match[1]);
108
+ const unit = ((_a = match[2]) !== null && _a !== void 0 ? _a : 'cm').toLowerCase();
109
+ if (unit === '%')
110
+ fraction = value / 100;
111
+ else
112
+ absolute = value * EMU_PER_UNIT[unit];
113
+ }
114
+ }
115
+ if (absolute !== undefined) {
116
+ if (!(shorterSide > 0)) {
117
+ throw new Error(`corner radius ${radius} needs the size of the shape; ` +
118
+ `use a percentage (e.g. '10%') for shapes without their own size`);
119
+ }
120
+ fraction = absolute / shorterSide;
121
+ }
122
+ if (!Number.isFinite(fraction) || fraction < 0) {
123
+ throw new Error(`invalid corner radius: ${String(radius)} ` +
124
+ `(a number in cm, or a string like '10%', '12px', '4pt', '0.5cm')`);
125
+ }
126
+ return Math.min(fraction, 0.5);
127
+ };
128
+ exports.cornerRadiusFraction = cornerRadiusFraction;
129
+ /**
130
+ * Resolves the docx-templates style options into a preset geometry and its
131
+ * adjust values. `shapeAdjustments` win over `cornerRadius`.
132
+ */
133
+ const resolveGeometry = (options, size) => {
134
+ var _a;
135
+ if (options.cornerRadius == null) {
136
+ const prst = options.shape == null ? 'rect' : assertPreset(options.shape);
137
+ return {
138
+ prst,
139
+ adjustments: completeAdjustments(prst, options.shapeAdjustments),
140
+ };
141
+ }
142
+ const prst = assertPreset((_a = options.shape) !== null && _a !== void 0 ? _a : 'roundRect');
143
+ if (!(0, exports.isRoundedShapePreset)(prst)) {
144
+ throw new Error(`cornerRadius is not supported for shape ${prst} (use one of ` +
145
+ `${Object.keys(CORNER_RADIUS_ADJUSTMENTS).join(', ')} or shapeAdjustments)`);
146
+ }
147
+ const fraction = (0, exports.cornerRadiusFraction)(options.cornerRadius, size ? Math.min(size.cx, size.cy) : undefined);
148
+ return {
149
+ prst,
150
+ adjustments: completeAdjustments(prst, Object.assign({ [CORNER_RADIUS_ADJUSTMENTS[prst]]: Math.round(fraction * 100000) }, options.shapeAdjustments)),
151
+ };
152
+ };
153
+ exports.resolveGeometry = resolveGeometry;
154
+ /** The p:spPr of a shape, picture or connector (direct child only). */
155
+ const shapeProperties = (element, helper) => {
156
+ const spPr = xml_helper_1.XmlHelper.getFirstDirectChild(element, ['p:spPr']);
157
+ if (!spPr) {
158
+ throw new Error(`${helper}: <${element.nodeName}> has no shape properties ` +
159
+ `(only shapes and pictures have a geometry; modify group members individually)`);
160
+ }
161
+ return spPr;
162
+ };
163
+ const shapeSize = (spPr) => {
164
+ const xfrm = xml_helper_1.XmlHelper.getFirstDirectChild(spPr, ['a:xfrm']);
165
+ const ext = xfrm && xml_helper_1.XmlHelper.getFirstDirectChild(xfrm, ['a:ext']);
166
+ if (!ext)
167
+ return undefined;
168
+ return {
169
+ cx: Number(ext.getAttribute('cx')),
170
+ cy: Number(ext.getAttribute('cy')),
171
+ };
172
+ };
173
+ const currentPreset = (spPr) => { var _a; return (_a = xml_helper_1.XmlHelper.getFirstDirectChild(spPr, ['a:prstGeom'])) === null || _a === void 0 ? void 0 : _a.getAttribute('prst'); };
174
+ /** Writes <a:prstGeom> into p:spPr, replacing a preset or custom geometry. */
175
+ const applyGeometry = (spPr, geometry) => {
176
+ const doc = spPr.ownerDocument;
177
+ const prstGeom = doc.createElement('a:prstGeom');
178
+ prstGeom.setAttribute('prst', geometry.prst);
179
+ const avLst = doc.createElement('a:avLst');
180
+ for (const [name, value] of Object.entries(geometry.adjustments)) {
181
+ const gd = doc.createElement('a:gd');
182
+ gd.setAttribute('name', name);
183
+ gd.setAttribute('fmla', `val ${Math.round(value)}`);
184
+ avLst.appendChild(gd);
185
+ }
186
+ prstGeom.appendChild(avLst);
187
+ const existing = xml_helper_1.XmlHelper.getFirstDirectChild(spPr, [
188
+ 'a:prstGeom',
189
+ 'a:custGeom',
190
+ ]);
191
+ if (existing) {
192
+ spPr.replaceChild(prstGeom, existing);
193
+ }
194
+ else {
195
+ xml_helper_1.XmlHelper.insertInSchemaOrder(spPr, prstGeom, SPPR_CHILD_ORDER);
196
+ }
197
+ };
198
+ exports.applyGeometry = applyGeometry;
199
+ /**
200
+ * Crops a picture or shape to a preset geometry, like "Crop to Shape" in
201
+ * PowerPoint: `setGeometry('ellipse')`, `setGeometry('heart')`. Replaces the
202
+ * current preset or custom geometry.
203
+ *
204
+ * @param shape - Any DrawingML preset geometry (see `ShapePresets`)
205
+ * @param adjustments - Optional raw adjust values, e.g. `{ adj: 25000 }`
206
+ */
207
+ const setGeometry = (shape, adjustments) => (element) => {
208
+ const spPr = shapeProperties(element, 'setGeometry');
209
+ const prst = assertPreset(shape);
210
+ (0, exports.applyGeometry)(spPr, {
211
+ prst,
212
+ adjustments: completeAdjustments(prst, adjustments),
213
+ });
214
+ };
215
+ exports.setGeometry = setGeometry;
216
+ /**
217
+ * Rounds the corners of a picture or shape. The radius is measured on the
218
+ * shorter side and capped at half of it:
219
+ * `setCornerRadius('10%')`, `setCornerRadius('12px')`, `setCornerRadius(0.5)`
220
+ * (cm). A shape that already is one of the rounded presets keeps it;
221
+ * anything else becomes a `roundRect`, unless `shape` says otherwise.
222
+ *
223
+ * @param radius - Number in cm, or a string in %, px, pt, cm or mm
224
+ * @param shape - Rounded preset to use, e.g. 'round2SameRect' (top corners)
225
+ */
226
+ const setCornerRadius = (radius, shape) => (element) => {
227
+ const spPr = shapeProperties(element, 'setCornerRadius');
228
+ const current = currentPreset(spPr);
229
+ const preset = shape !== null && shape !== void 0 ? shape : ((0, exports.isRoundedShapePreset)(current) ? current : 'roundRect');
230
+ let geometry;
231
+ try {
232
+ geometry = (0, exports.resolveGeometry)({ shape: preset, cornerRadius: radius }, shapeSize(spPr));
233
+ }
234
+ catch (error) {
235
+ throw new Error(`setCornerRadius: ${error.message}`, {
236
+ cause: error,
237
+ });
238
+ }
239
+ (0, exports.applyGeometry)(spPr, geometry);
240
+ };
241
+ exports.setCornerRadius = setCornerRadius;
242
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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;AACxD,MAAM,gBAAgB,GAAG;IACvB,QAAQ;IACR,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,MAAM;IAC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,IAAI,EAAE,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;AAnBS,QAAA,eAAe,mBAmBxB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * ST_ShapeType of the DrawingML spec: every preset geometry PowerPoint knows.
3
+ * Same list as docx-templates' `ImageShapes`.
4
+ */
5
+ export declare const ShapePresets: readonly ["line", "lineInv", "triangle", "rtTriangle", "rect", "diamond", "parallelogram", "trapezoid", "nonIsoscelesTrapezoid", "pentagon", "hexagon", "heptagon", "octagon", "decagon", "dodecagon", "star4", "star5", "star6", "star7", "star8", "star10", "star12", "star16", "star24", "star32", "roundRect", "round1Rect", "round2SameRect", "round2DiagRect", "snipRoundRect", "snip1Rect", "snip2SameRect", "snip2DiagRect", "plaque", "ellipse", "teardrop", "homePlate", "chevron", "pieWedge", "pie", "blockArc", "donut", "noSmoking", "rightArrow", "leftArrow", "upArrow", "downArrow", "stripedRightArrow", "notchedRightArrow", "bentUpArrow", "leftRightArrow", "upDownArrow", "leftUpArrow", "leftRightUpArrow", "quadArrow", "leftArrowCallout", "rightArrowCallout", "upArrowCallout", "downArrowCallout", "leftRightArrowCallout", "upDownArrowCallout", "quadArrowCallout", "bentArrow", "uturnArrow", "circularArrow", "leftCircularArrow", "leftRightCircularArrow", "curvedRightArrow", "curvedLeftArrow", "curvedUpArrow", "curvedDownArrow", "swooshArrow", "cube", "can", "lightningBolt", "heart", "sun", "moon", "smileyFace", "irregularSeal1", "irregularSeal2", "foldedCorner", "bevel", "frame", "halfFrame", "corner", "diagStripe", "chord", "arc", "leftBracket", "rightBracket", "leftBrace", "rightBrace", "bracketPair", "bracePair", "straightConnector1", "bentConnector2", "bentConnector3", "bentConnector4", "bentConnector5", "curvedConnector2", "curvedConnector3", "curvedConnector4", "curvedConnector5", "callout1", "callout2", "callout3", "accentCallout1", "accentCallout2", "accentCallout3", "borderCallout1", "borderCallout2", "borderCallout3", "accentBorderCallout1", "accentBorderCallout2", "accentBorderCallout3", "wedgeRectCallout", "wedgeRoundRectCallout", "wedgeEllipseCallout", "cloudCallout", "cloud", "ribbon", "ribbon2", "ellipseRibbon", "ellipseRibbon2", "leftRightRibbon", "verticalScroll", "horizontalScroll", "wave", "doubleWave", "plus", "flowChartProcess", "flowChartDecision", "flowChartInputOutput", "flowChartPredefinedProcess", "flowChartInternalStorage", "flowChartDocument", "flowChartMultidocument", "flowChartTerminator", "flowChartPreparation", "flowChartManualInput", "flowChartManualOperation", "flowChartConnector", "flowChartPunchedCard", "flowChartPunchedTape", "flowChartSummingJunction", "flowChartOr", "flowChartCollate", "flowChartSort", "flowChartExtract", "flowChartMerge", "flowChartOfflineStorage", "flowChartOnlineStorage", "flowChartMagneticTape", "flowChartMagneticDisk", "flowChartMagneticDrum", "flowChartDisplay", "flowChartDelay", "flowChartAlternateProcess", "flowChartOffpageConnector", "actionButtonBlank", "actionButtonHome", "actionButtonHelp", "actionButtonInformation", "actionButtonForwardNext", "actionButtonBackPrevious", "actionButtonEnd", "actionButtonBeginning", "actionButtonReturn", "actionButtonDocument", "actionButtonSound", "actionButtonMovie", "gear6", "gear9", "funnel", "mathPlus", "mathMinus", "mathMultiply", "mathDivide", "mathEqual", "mathNotEqual", "cornerTabs", "squareTabs", "plaqueTabs", "chartX", "chartStar", "chartPlus"];
6
+ /**
7
+ * Default adjust values of the presets that have any, from
8
+ * presetShapeDefinitions.xml (ECMA-376 Part 1, Annex D). PowerPoint asks to
9
+ * repair a file whose <a:avLst> lists only some guides of a shape, so a
10
+ * partial set is completed with these defaults.
11
+ */
12
+ export declare const PresetAdjustmentDefaults: Partial<Record<(typeof ShapePresets)[number], Record<string, number>>>;
@@ -0,0 +1,421 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PresetAdjustmentDefaults = exports.ShapePresets = void 0;
4
+ /**
5
+ * ST_ShapeType of the DrawingML spec: every preset geometry PowerPoint knows.
6
+ * Same list as docx-templates' `ImageShapes`.
7
+ */
8
+ exports.ShapePresets = [
9
+ 'line',
10
+ 'lineInv',
11
+ 'triangle',
12
+ 'rtTriangle',
13
+ 'rect',
14
+ 'diamond',
15
+ 'parallelogram',
16
+ 'trapezoid',
17
+ 'nonIsoscelesTrapezoid',
18
+ 'pentagon',
19
+ 'hexagon',
20
+ 'heptagon',
21
+ 'octagon',
22
+ 'decagon',
23
+ 'dodecagon',
24
+ 'star4',
25
+ 'star5',
26
+ 'star6',
27
+ 'star7',
28
+ 'star8',
29
+ 'star10',
30
+ 'star12',
31
+ 'star16',
32
+ 'star24',
33
+ 'star32',
34
+ 'roundRect',
35
+ 'round1Rect',
36
+ 'round2SameRect',
37
+ 'round2DiagRect',
38
+ 'snipRoundRect',
39
+ 'snip1Rect',
40
+ 'snip2SameRect',
41
+ 'snip2DiagRect',
42
+ 'plaque',
43
+ 'ellipse',
44
+ 'teardrop',
45
+ 'homePlate',
46
+ 'chevron',
47
+ 'pieWedge',
48
+ 'pie',
49
+ 'blockArc',
50
+ 'donut',
51
+ 'noSmoking',
52
+ 'rightArrow',
53
+ 'leftArrow',
54
+ 'upArrow',
55
+ 'downArrow',
56
+ 'stripedRightArrow',
57
+ 'notchedRightArrow',
58
+ 'bentUpArrow',
59
+ 'leftRightArrow',
60
+ 'upDownArrow',
61
+ 'leftUpArrow',
62
+ 'leftRightUpArrow',
63
+ 'quadArrow',
64
+ 'leftArrowCallout',
65
+ 'rightArrowCallout',
66
+ 'upArrowCallout',
67
+ 'downArrowCallout',
68
+ 'leftRightArrowCallout',
69
+ 'upDownArrowCallout',
70
+ 'quadArrowCallout',
71
+ 'bentArrow',
72
+ 'uturnArrow',
73
+ 'circularArrow',
74
+ 'leftCircularArrow',
75
+ 'leftRightCircularArrow',
76
+ 'curvedRightArrow',
77
+ 'curvedLeftArrow',
78
+ 'curvedUpArrow',
79
+ 'curvedDownArrow',
80
+ 'swooshArrow',
81
+ 'cube',
82
+ 'can',
83
+ 'lightningBolt',
84
+ 'heart',
85
+ 'sun',
86
+ 'moon',
87
+ 'smileyFace',
88
+ 'irregularSeal1',
89
+ 'irregularSeal2',
90
+ 'foldedCorner',
91
+ 'bevel',
92
+ 'frame',
93
+ 'halfFrame',
94
+ 'corner',
95
+ 'diagStripe',
96
+ 'chord',
97
+ 'arc',
98
+ 'leftBracket',
99
+ 'rightBracket',
100
+ 'leftBrace',
101
+ 'rightBrace',
102
+ 'bracketPair',
103
+ 'bracePair',
104
+ 'straightConnector1',
105
+ 'bentConnector2',
106
+ 'bentConnector3',
107
+ 'bentConnector4',
108
+ 'bentConnector5',
109
+ 'curvedConnector2',
110
+ 'curvedConnector3',
111
+ 'curvedConnector4',
112
+ 'curvedConnector5',
113
+ 'callout1',
114
+ 'callout2',
115
+ 'callout3',
116
+ 'accentCallout1',
117
+ 'accentCallout2',
118
+ 'accentCallout3',
119
+ 'borderCallout1',
120
+ 'borderCallout2',
121
+ 'borderCallout3',
122
+ 'accentBorderCallout1',
123
+ 'accentBorderCallout2',
124
+ 'accentBorderCallout3',
125
+ 'wedgeRectCallout',
126
+ 'wedgeRoundRectCallout',
127
+ 'wedgeEllipseCallout',
128
+ 'cloudCallout',
129
+ 'cloud',
130
+ 'ribbon',
131
+ 'ribbon2',
132
+ 'ellipseRibbon',
133
+ 'ellipseRibbon2',
134
+ 'leftRightRibbon',
135
+ 'verticalScroll',
136
+ 'horizontalScroll',
137
+ 'wave',
138
+ 'doubleWave',
139
+ 'plus',
140
+ 'flowChartProcess',
141
+ 'flowChartDecision',
142
+ 'flowChartInputOutput',
143
+ 'flowChartPredefinedProcess',
144
+ 'flowChartInternalStorage',
145
+ 'flowChartDocument',
146
+ 'flowChartMultidocument',
147
+ 'flowChartTerminator',
148
+ 'flowChartPreparation',
149
+ 'flowChartManualInput',
150
+ 'flowChartManualOperation',
151
+ 'flowChartConnector',
152
+ 'flowChartPunchedCard',
153
+ 'flowChartPunchedTape',
154
+ 'flowChartSummingJunction',
155
+ 'flowChartOr',
156
+ 'flowChartCollate',
157
+ 'flowChartSort',
158
+ 'flowChartExtract',
159
+ 'flowChartMerge',
160
+ 'flowChartOfflineStorage',
161
+ 'flowChartOnlineStorage',
162
+ 'flowChartMagneticTape',
163
+ 'flowChartMagneticDisk',
164
+ 'flowChartMagneticDrum',
165
+ 'flowChartDisplay',
166
+ 'flowChartDelay',
167
+ 'flowChartAlternateProcess',
168
+ 'flowChartOffpageConnector',
169
+ 'actionButtonBlank',
170
+ 'actionButtonHome',
171
+ 'actionButtonHelp',
172
+ 'actionButtonInformation',
173
+ 'actionButtonForwardNext',
174
+ 'actionButtonBackPrevious',
175
+ 'actionButtonEnd',
176
+ 'actionButtonBeginning',
177
+ 'actionButtonReturn',
178
+ 'actionButtonDocument',
179
+ 'actionButtonSound',
180
+ 'actionButtonMovie',
181
+ 'gear6',
182
+ 'gear9',
183
+ 'funnel',
184
+ 'mathPlus',
185
+ 'mathMinus',
186
+ 'mathMultiply',
187
+ 'mathDivide',
188
+ 'mathEqual',
189
+ 'mathNotEqual',
190
+ 'cornerTabs',
191
+ 'squareTabs',
192
+ 'plaqueTabs',
193
+ 'chartX',
194
+ 'chartStar',
195
+ 'chartPlus',
196
+ ];
197
+ /**
198
+ * Default adjust values of the presets that have any, from
199
+ * presetShapeDefinitions.xml (ECMA-376 Part 1, Annex D). PowerPoint asks to
200
+ * repair a file whose <a:avLst> lists only some guides of a shape, so a
201
+ * partial set is completed with these defaults.
202
+ */
203
+ exports.PresetAdjustmentDefaults = {
204
+ triangle: { adj: 50000 },
205
+ parallelogram: { adj: 25000 },
206
+ trapezoid: { adj: 25000 },
207
+ nonIsoscelesTrapezoid: { adj1: 25000, adj2: 25000 },
208
+ pentagon: { hf: 105146, vf: 110557 },
209
+ hexagon: { adj: 25000, vf: 115470 },
210
+ heptagon: { hf: 102572, vf: 105210 },
211
+ octagon: { adj: 29289 },
212
+ decagon: { vf: 105146 },
213
+ star4: { adj: 12500 },
214
+ star5: { adj: 19098, hf: 105146, vf: 110557 },
215
+ star6: { adj: 28868, hf: 115470 },
216
+ star7: { adj: 34601, hf: 102572, vf: 105210 },
217
+ star8: { adj: 37500 },
218
+ star10: { adj: 42533, hf: 105146 },
219
+ star12: { adj: 37500 },
220
+ star16: { adj: 37500 },
221
+ star24: { adj: 37500 },
222
+ star32: { adj: 37500 },
223
+ roundRect: { adj: 16667 },
224
+ round1Rect: { adj: 16667 },
225
+ round2SameRect: { adj1: 16667, adj2: 0 },
226
+ round2DiagRect: { adj1: 16667, adj2: 0 },
227
+ snipRoundRect: { adj1: 16667, adj2: 16667 },
228
+ snip1Rect: { adj: 16667 },
229
+ snip2SameRect: { adj1: 16667, adj2: 0 },
230
+ snip2DiagRect: { adj1: 0, adj2: 16667 },
231
+ plaque: { adj: 16667 },
232
+ teardrop: { adj: 100000 },
233
+ homePlate: { adj: 50000 },
234
+ chevron: { adj: 50000 },
235
+ pie: { adj1: 0, adj2: 16200000 },
236
+ blockArc: { adj1: 10800000, adj2: 0, adj3: 25000 },
237
+ donut: { adj: 25000 },
238
+ noSmoking: { adj: 18750 },
239
+ rightArrow: { adj1: 50000, adj2: 50000 },
240
+ leftArrow: { adj1: 50000, adj2: 50000 },
241
+ upArrow: { adj1: 50000, adj2: 50000 },
242
+ downArrow: { adj1: 50000, adj2: 50000 },
243
+ stripedRightArrow: { adj1: 50000, adj2: 50000 },
244
+ notchedRightArrow: { adj1: 50000, adj2: 50000 },
245
+ bentUpArrow: { adj1: 25000, adj2: 25000, adj3: 25000 },
246
+ leftRightArrow: { adj1: 50000, adj2: 50000 },
247
+ upDownArrow: { adj1: 50000, adj2: 50000 },
248
+ leftUpArrow: { adj1: 25000, adj2: 25000, adj3: 25000 },
249
+ leftRightUpArrow: { adj1: 25000, adj2: 25000, adj3: 25000 },
250
+ quadArrow: { adj1: 22500, adj2: 22500, adj3: 22500 },
251
+ leftArrowCallout: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 64977 },
252
+ rightArrowCallout: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 64977 },
253
+ upArrowCallout: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 64977 },
254
+ downArrowCallout: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 64977 },
255
+ leftRightArrowCallout: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 48123 },
256
+ upDownArrowCallout: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 48123 },
257
+ quadArrowCallout: { adj1: 18515, adj2: 18515, adj3: 18515, adj4: 48123 },
258
+ bentArrow: { adj1: 25000, adj2: 25000, adj3: 25000, adj4: 43750 },
259
+ uturnArrow: {
260
+ adj1: 25000,
261
+ adj2: 25000,
262
+ adj3: 25000,
263
+ adj4: 43750,
264
+ adj5: 75000,
265
+ },
266
+ circularArrow: {
267
+ adj1: 12500,
268
+ adj2: 1142319,
269
+ adj3: 20457681,
270
+ adj4: 10800000,
271
+ adj5: 12500,
272
+ },
273
+ leftCircularArrow: {
274
+ adj1: 12500,
275
+ adj2: -1142319,
276
+ adj3: 1142319,
277
+ adj4: 10800000,
278
+ adj5: 12500,
279
+ },
280
+ leftRightCircularArrow: {
281
+ adj1: 12500,
282
+ adj2: 1142319,
283
+ adj3: 20457681,
284
+ adj4: 11942319,
285
+ adj5: 12500,
286
+ },
287
+ curvedRightArrow: { adj1: 25000, adj2: 50000, adj3: 25000 },
288
+ curvedLeftArrow: { adj1: 25000, adj2: 50000, adj3: 25000 },
289
+ curvedUpArrow: { adj1: 25000, adj2: 50000, adj3: 25000 },
290
+ curvedDownArrow: { adj1: 25000, adj2: 50000, adj3: 25000 },
291
+ swooshArrow: { adj1: 25000, adj2: 16667 },
292
+ cube: { adj: 25000 },
293
+ can: { adj: 25000 },
294
+ sun: { adj: 25000 },
295
+ moon: { adj: 50000 },
296
+ smileyFace: { adj: 4653 },
297
+ foldedCorner: { adj: 16667 },
298
+ bevel: { adj: 12500 },
299
+ frame: { adj1: 12500 },
300
+ halfFrame: { adj1: 33333, adj2: 33333 },
301
+ corner: { adj1: 50000, adj2: 50000 },
302
+ diagStripe: { adj: 50000 },
303
+ chord: { adj1: 2700000, adj2: 16200000 },
304
+ arc: { adj1: 16200000, adj2: 0 },
305
+ leftBracket: { adj: 8333 },
306
+ rightBracket: { adj: 8333 },
307
+ leftBrace: { adj1: 8333, adj2: 50000 },
308
+ rightBrace: { adj1: 8333, adj2: 50000 },
309
+ bracketPair: { adj: 16667 },
310
+ bracePair: { adj: 8333 },
311
+ bentConnector3: { adj1: 50000 },
312
+ bentConnector4: { adj1: 50000, adj2: 50000 },
313
+ bentConnector5: { adj1: 50000, adj2: 50000, adj3: 50000 },
314
+ curvedConnector3: { adj1: 50000 },
315
+ curvedConnector4: { adj1: 50000, adj2: 50000 },
316
+ curvedConnector5: { adj1: 50000, adj2: 50000, adj3: 50000 },
317
+ callout1: { adj1: 18750, adj2: -8333, adj3: 112500, adj4: -38333 },
318
+ callout2: {
319
+ adj1: 18750,
320
+ adj2: -8333,
321
+ adj3: 18750,
322
+ adj4: -16667,
323
+ adj5: 112500,
324
+ adj6: -46667,
325
+ },
326
+ callout3: {
327
+ adj1: 18750,
328
+ adj2: -8333,
329
+ adj3: 18750,
330
+ adj4: -16667,
331
+ adj5: 100000,
332
+ adj6: -16667,
333
+ adj7: 112963,
334
+ adj8: -8333,
335
+ },
336
+ accentCallout1: { adj1: 18750, adj2: -8333, adj3: 112500, adj4: -38333 },
337
+ accentCallout2: {
338
+ adj1: 18750,
339
+ adj2: -8333,
340
+ adj3: 18750,
341
+ adj4: -16667,
342
+ adj5: 112500,
343
+ adj6: -46667,
344
+ },
345
+ accentCallout3: {
346
+ adj1: 18750,
347
+ adj2: -8333,
348
+ adj3: 18750,
349
+ adj4: -16667,
350
+ adj5: 100000,
351
+ adj6: -16667,
352
+ adj7: 112963,
353
+ adj8: -8333,
354
+ },
355
+ borderCallout1: { adj1: 18750, adj2: -8333, adj3: 112500, adj4: -38333 },
356
+ borderCallout2: {
357
+ adj1: 18750,
358
+ adj2: -8333,
359
+ adj3: 18750,
360
+ adj4: -16667,
361
+ adj5: 112500,
362
+ adj6: -46667,
363
+ },
364
+ borderCallout3: {
365
+ adj1: 18750,
366
+ adj2: -8333,
367
+ adj3: 18750,
368
+ adj4: -16667,
369
+ adj5: 100000,
370
+ adj6: -16667,
371
+ adj7: 112963,
372
+ adj8: -8333,
373
+ },
374
+ accentBorderCallout1: {
375
+ adj1: 18750,
376
+ adj2: -8333,
377
+ adj3: 112500,
378
+ adj4: -38333,
379
+ },
380
+ accentBorderCallout2: {
381
+ adj1: 18750,
382
+ adj2: -8333,
383
+ adj3: 18750,
384
+ adj4: -16667,
385
+ adj5: 112500,
386
+ adj6: -46667,
387
+ },
388
+ accentBorderCallout3: {
389
+ adj1: 18750,
390
+ adj2: -8333,
391
+ adj3: 18750,
392
+ adj4: -16667,
393
+ adj5: 100000,
394
+ adj6: -16667,
395
+ adj7: 112963,
396
+ adj8: -8333,
397
+ },
398
+ wedgeRectCallout: { adj1: -20833, adj2: 62500 },
399
+ wedgeRoundRectCallout: { adj1: -20833, adj2: 62500, adj3: 16667 },
400
+ wedgeEllipseCallout: { adj1: -20833, adj2: 62500 },
401
+ cloudCallout: { adj1: -20833, adj2: 62500 },
402
+ ribbon: { adj1: 16667, adj2: 50000 },
403
+ ribbon2: { adj1: 16667, adj2: 50000 },
404
+ ellipseRibbon: { adj1: 25000, adj2: 50000, adj3: 12500 },
405
+ ellipseRibbon2: { adj1: 25000, adj2: 50000, adj3: 12500 },
406
+ leftRightRibbon: { adj1: 50000, adj2: 50000, adj3: 16667 },
407
+ verticalScroll: { adj: 12500 },
408
+ horizontalScroll: { adj: 12500 },
409
+ wave: { adj1: 12500, adj2: 0 },
410
+ doubleWave: { adj1: 6250, adj2: 0 },
411
+ plus: { adj: 25000 },
412
+ gear6: { adj1: 15000, adj2: 3526 },
413
+ gear9: { adj1: 10000, adj2: 1763 },
414
+ mathPlus: { adj1: 23520 },
415
+ mathMinus: { adj1: 23520 },
416
+ mathMultiply: { adj1: 23520 },
417
+ mathDivide: { adj1: 23520, adj2: 5880, adj3: 11760 },
418
+ mathEqual: { adj1: 23520, adj2: 11760 },
419
+ mathNotEqual: { adj1: 23520, adj2: 6600000, adj3: 11760 },
420
+ };
421
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/extensions/shape-geometry/presets.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,YAAY,GAAG;IAC1B,MAAM;IACN,SAAS;IACT,UAAU;IACV,YAAY;IACZ,MAAM;IACN,SAAS;IACT,eAAe;IACf,WAAW;IACX,uBAAuB;IACvB,UAAU;IACV,SAAS;IACT,UAAU;IACV,SAAS;IACT,SAAS;IACT,WAAW;IACX,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,WAAW;IACX,YAAY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,WAAW;IACX,eAAe;IACf,eAAe;IACf,QAAQ;IACR,SAAS;IACT,UAAU;IACV,WAAW;IACX,SAAS;IACT,UAAU;IACV,KAAK;IACL,UAAU;IACV,OAAO;IACP,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;IACT,WAAW;IACX,mBAAmB;IACnB,mBAAmB;IACnB,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,kBAAkB;IAClB,WAAW;IACX,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,kBAAkB;IAClB,uBAAuB;IACvB,oBAAoB;IACpB,kBAAkB;IAClB,WAAW;IACX,YAAY;IACZ,eAAe;IACf,mBAAmB;IACnB,wBAAwB;IACxB,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,iBAAiB;IACjB,aAAa;IACb,MAAM;IACN,KAAK;IACL,eAAe;IACf,OAAO;IACP,KAAK;IACL,MAAM;IACN,YAAY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,cAAc;I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,EAAE;IAC9B,gBAAgB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;IAChC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;IAC9B,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE;IACnC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;IACpB,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE;IAClC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE;IAClC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IACzB,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IAC1B,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE;IACpD,SAAS,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IACvC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;CAC1D,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { ShapePresets } from './presets';
2
+ /** A DrawingML preset geometry, e.g. 'roundRect', 'ellipse', 'heart'. */
3
+ export type ShapePreset = (typeof ShapePresets)[number];
4
+ /** Preset geometries whose corner radius `setCornerRadius` can set. */
5
+ export type RoundedShapePreset = 'roundRect' | 'round1Rect' | 'round2SameRect' | 'round2DiagRect' | 'snipRoundRect';
6
+ /**
7
+ * Corner radius, measured on the shorter side of the shape:
8
+ * - a number: centimeters (as in docx-templates)
9
+ * - a string with unit: `'10%'` (of the shorter side), `'12px'` (96 dpi),
10
+ * `'4pt'`, `'0.5cm'`, `'5mm'`
11
+ *
12
+ * The radius is capped at half the shorter side (`'50%'`).
13
+ */
14
+ export type CornerRadius = number | string;
15
+ /**
16
+ * Raw adjust values of a preset geometry (the yellow handles in
17
+ * PowerPoint), keyed by guide name, e.g. `{ adj: 25000 }`. Names and value
18
+ * ranges depend on the shape; most are in 1/100000 of the shorter side.
19
+ */
20
+ export type ShapeAdjustments = {
21
+ [name: string]: number;
22
+ };
23
+ /** Border of an `{{IMAGE}}` picture (docx-templates compatible). */
24
+ export type ImageBorder = {
25
+ /** Hex RGB color, e.g. '#ff0000' or 'ff0000'. */
26
+ color: string;
27
+ /** Width in points. */
28
+ width: number;
29
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extensions/shape-geometry/types.ts"],"names":[],"mappings":""}
@@ -8,12 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.placeImages = exports.loadImage = void 0;
13
16
  const xml_helper_1 = require("../../helper/xml-helper");
14
17
  const xml_relationship_helper_1 = require("../../helper/xml-relationship-helper");
15
18
  const ppt_paths_1 = require("../../helper/ppt-paths");
16
19
  const image_dimensions_1 = require("../../helper/image-dimensions");
20
+ const modify_shape_helper_1 = __importDefault(require("../../helper/modify-shape-helper"));
21
+ const shape_geometry_1 = require("../shape-geometry");
17
22
  /**
18
23
  * {{IMAGE …}} support: writes the image into ppt/media (deduplicated), adds
19
24
  * the content type and the slide relationship, and places a <p:pic> where
@@ -28,6 +33,7 @@ const MIME_EXTENSIONS = {
28
33
  };
29
34
  const SUPPORTED = ['png', 'jpg', 'jpeg', 'gif'];
30
35
  const EMU_PER_CM = 360000;
36
+ const EMU_PER_PT = 12700;
31
37
  /** Validates an IMAGE value and decodes its data. */
32
38
  const loadImage = (value) => {
33
39
  var _a;
@@ -57,9 +63,43 @@ const loadImage = (value) => {
57
63
  if (!extension || !SUPPORTED.includes(extension)) {
58
64
  throw new Error(`IMAGE: unsupported extension "${extension !== null && extension !== void 0 ? extension : ''}" (use ${SUPPORTED.join(', ')})`);
59
65
  }
66
+ if (spec.border) {
67
+ const { color, width } = spec.border;
68
+ if (typeof color !== 'string' || !/^#?[0-9a-f]{6}$/i.test(color)) {
69
+ throw new Error(`IMAGE: invalid border color ${String(color)} (a hex RGB color, e.g. '#ff0000')`);
70
+ }
71
+ if (!Number.isFinite(width) || width < 0) {
72
+ throw new Error(`IMAGE: invalid border width ${String(width)} (in pt)`);
73
+ }
74
+ }
75
+ // Fails early on a bad shape or radius; the real size comes with the slot.
76
+ geometryFor(spec, { cx: 1, cy: 1 });
60
77
  return { spec, content, extension };
61
78
  };
62
79
  exports.loadImage = loadImage;
80
+ const geometryFor = (spec, size) => {
81
+ try {
82
+ return (0, shape_geometry_1.resolveGeometry)(spec, size);
83
+ }
84
+ catch (error) {
85
+ throw new Error(`IMAGE: ${error.message}`, { cause: error });
86
+ }
87
+ };
88
+ /** shape/cornerRadius/shapeAdjustments and border of an IMAGE picture. */
89
+ const styleShape = (picture, image, box) => {
90
+ const { spec } = image;
91
+ const spPr = xml_helper_1.XmlHelper.getFirstDirectChild(picture, ['p:spPr']);
92
+ (0, shape_geometry_1.applyGeometry)(spPr, geometryFor(spec, box));
93
+ if (spec.border) {
94
+ modify_shape_helper_1.default.setOutline({
95
+ weight: Math.round(spec.border.width * EMU_PER_PT),
96
+ color: {
97
+ type: 'srgbClr',
98
+ value: spec.border.color.replace(/^#/, '').toUpperCase(),
99
+ },
100
+ })(picture);
101
+ }
102
+ };
63
103
  const childElement = (parent, tagName) => {
64
104
  for (let node = parent === null || parent === void 0 ? void 0 : parent.firstChild; node; node = node.nextSibling) {
65
105
  if (node.nodeType === 1 && node.tagName === tagName) {
@@ -152,7 +192,7 @@ const createPicture = (shape, relId, image, box, id) => {
152
192
  if (image.spec.rotation) {
153
193
  xfrmAttrs.rot = Math.round(image.spec.rotation * 60000);
154
194
  }
155
- return el('p:pic', {}, el('p:nvPicPr', {}, el('p:cNvPr', Object.assign({ id, name: `Picture ${id}` }, (image.spec.alt ? { descr: image.spec.alt } : {}))), el('p:cNvPicPr', {}, el('a:picLocks', { noChangeAspect: 1 })), el('p:nvPr')), el('p:blipFill', {}, el('a:blip', { 'r:embed': relId }), el('a:stretch', {}, el('a:fillRect'))), el('p:spPr', {}, el('a:xfrm', xfrmAttrs, el('a:off', { x: Math.round(box.x), y: Math.round(box.y) }), el('a:ext', { cx: Math.round(box.cx), cy: Math.round(box.cy) })), el('a:prstGeom', { prst: 'rect' }, el('a:avLst'))));
195
+ return el('p:pic', {}, el('p:nvPicPr', {}, el('p:cNvPr', Object.assign({ id, name: `Picture ${id}` }, (image.spec.alt ? { descr: image.spec.alt } : {}))), el('p:cNvPicPr', {}, el('a:picLocks', { noChangeAspect: 1 })), el('p:nvPr')), el('p:blipFill', {}, el('a:blip', { 'r:embed': relId }), el('a:stretch', {}, el('a:fillRect'))), el('p:spPr', {}, el('a:xfrm', xfrmAttrs, el('a:off', { x: Math.round(box.x), y: Math.round(box.y) }), el('a:ext', { cx: Math.round(box.cx), cy: Math.round(box.cy) }))));
156
196
  };
157
197
  /**
158
198
  * Places the images rendered from one shape's text: side by side, each in
@@ -173,6 +213,7 @@ const placeImages = (target, shape, images, removeShape) => __awaiter(void 0, vo
173
213
  const box = Object.assign({ x: slot.x + (slot.cx - size.cx) / 2, y: slot.y + (slot.cy - size.cy) / 2 }, size);
174
214
  const relId = addRelation(target, yield mediaFile(target, images[i]));
175
215
  const picture = createPicture(shape, relId, images[i], box, nextShapeId(target, shape));
216
+ styleShape(picture, images[i], box);
176
217
  shape.parentNode.insertBefore(picture, anchor);
177
218
  anchor = picture.nextSibling;
178
219
  }
@@ -1 +1 @@
1
- {"version":3,"file":"images.js","sourceRoot":"","sources":["../../../src/extensions/template-logic/images.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,wDAAoD;AACpD,kFAA6E;AAC7E,sDAAkD;AAClD,oEAAgE;AAIhE;;;;GAIG;AAEH,MAAM,cAAc,GAClB,2EAA2E,CAAC;AAE9E,MAAM,eAAe,GAA2B;IAC9C,WAAW,EAAE,KAAK;IAClB,YAAY,EAAE,MAAM;IACpB,WAAW,EAAE,KAAK;IAClB,WAAW,EAAE,KAAK;CACnB,CAAC;AACF,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAEhD,MAAM,UAAU,GAAG,MAAM,CAAC;AAmB1B,qDAAqD;AAC9C,MAAM,SAAS,GAAG,CAAC,KAAc,EAAe,EAAE;;IACvD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,KAAsB,CAAC;IACpC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACpB,IAAI,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC;IAEjE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,OAAO,EAAE,CAAC;YACZ,SAAS,aAAT,SAAS,cAAT,SAAS,IAAT,SAAS,GAAK,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,EAAC;YACxD,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACpB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AAC,CAAC,CAAC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,aAAa,CAC3B,KAAK,EACL,KAAK,EACL,MAAM,CAAC,CAAC,CAAC,EACT,GAAG,EACH,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAC3B,CAAC;QACF,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACpC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAC/B,CAAC;IAED,IAAI,WAAW;QAAE,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC,CAAA,CAAC;AAtCW,QAAA,WAAW,eAsCtB"}
@@ -1,3 +1,4 @@
1
+ import { CornerRadius, ImageBorder, ShapeAdjustments, ShapePreset } from '../shape-geometry/types';
1
2
  /** Values (and functions) the expressions in template tags can reference. */
2
3
  export type TemplateData = Record<string, unknown>;
3
4
  export type RenderTemplateOptions = {
@@ -47,6 +48,23 @@ export type TemplateImage = {
47
48
  alt?: string;
48
49
  /** Rotation in degrees, clockwise. */
49
50
  rotation?: number;
51
+ /**
52
+ * Shape the picture is cropped to ("Crop to Shape"): any DrawingML preset
53
+ * geometry, e.g. 'roundRect', 'ellipse', 'heart'. Defaults to 'rect', or to
54
+ * 'roundRect' when `cornerRadius` is given.
55
+ */
56
+ shape?: ShapePreset;
57
+ /**
58
+ * Corner radius on the shorter side of the picture: a number in cm, or a
59
+ * string like '10%', '12px', '4pt'. '50%' is the maximum. Only for the
60
+ * rounded shapes ('roundRect', 'round1Rect', 'round2SameRect',
61
+ * 'round2DiagRect', 'snipRoundRect').
62
+ */
63
+ cornerRadius?: CornerRadius;
64
+ /** Raw adjust values of the shape, e.g. `{ adj: 25000 }`. Win over `cornerRadius`. */
65
+ shapeAdjustments?: ShapeAdjustments;
66
+ /** Border along the outline of the shape: hex `color`, `width` in pt. */
67
+ border?: ImageBorder;
50
68
  };
51
69
  export type TemplateCommand = {
52
70
  /** 1-based slide number (file name based: ppt/slides/slide<N>.xml). */
package/dist/index.d.ts CHANGED
@@ -66,6 +66,8 @@ export declare const modify: {
66
66
  addHyperlink: (target: string | number, isInternalLink?: boolean) => ShapeModificationCallback;
67
67
  removeHyperlink: () => ShapeModificationCallback;
68
68
  renderTemplate: (data: import("./extensions").TemplateData | Promise<import("./extensions").TemplateData>, options?: import("./extensions").RenderTemplateOptions) => (element: XmlDocument | XmlElement, context?: unknown) => Promise<void>;
69
+ setGeometry: (shape: import("./extensions").ShapePreset, adjustments?: import("./extensions").ShapeAdjustments) => (element: XmlElement) => void;
70
+ setCornerRadius: (radius: import("./extensions").CornerRadius, shape?: import("./extensions").RoundedShapePreset) => (element: XmlElement) => void;
69
71
  };
70
72
  export declare const read: {
71
73
  readWorkbookData: (data: WorkbookData) => import("./types/types").ChartModificationCallback;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptx-templates",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A template based pptx generator",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "docs:start": "yarn --cwd website start",
24
24
  "docs:build": "yarn --cwd website build",
25
25
  "docs:serve": "yarn --cwd website serve",
26
- "validate:pptx": "docker build -q -t pptx-validator tools/validate-pptx && docker run --rm -v \"$PWD:/repo:ro\" pptx-validator --allowlist /repo/tools/validate-pptx/allowlist.json /repo/__tests__/pptx-templates /repo/__tests__/pptx-output",
26
+ "validate:pptx": "node tools/fork/validate-pptx.mjs",
27
27
  "lint": "eslint .",
28
28
  "lint:fix": "eslint . --fix",
29
29
  "prettier": "prettier --config .prettierrc 'src/**/*.ts' --write"