pptx-templates 0.1.1 → 0.1.3
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 +97 -0
- package/CHANGELOG.md +26 -1
- package/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/index.js +6 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/shape-geometry/index.d.ts +53 -0
- package/dist/extensions/shape-geometry/index.js +242 -0
- package/dist/extensions/shape-geometry/index.js.map +1 -0
- package/dist/extensions/shape-geometry/presets.d.ts +12 -0
- package/dist/extensions/shape-geometry/presets.js +421 -0
- package/dist/extensions/shape-geometry/presets.js.map +1 -0
- package/dist/extensions/shape-geometry/types.d.ts +29 -0
- package/dist/extensions/shape-geometry/types.js +3 -0
- package/dist/extensions/shape-geometry/types.js.map +1 -0
- package/dist/extensions/template-logic/images.js +42 -1
- package/dist/extensions/template-logic/images.js.map +1 -1
- package/dist/extensions/template-logic/types.d.ts +18 -0
- package/dist/helper/modify-image-helper.js +1 -1
- package/dist/helper/modify-image-helper.js.map +1 -1
- package/dist/helper/xml-relationship-helper.js +2 -2
- package/dist/helper/xml-relationship-helper.js.map +1 -1
- package/dist/helper/xml-template-helper.js +2 -2
- package/dist/helper/xml-template-helper.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +5 -3
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,28 @@ 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.3] - 2026-11-05
|
|
10
|
+
|
|
11
|
+
### Security
|
|
12
|
+
|
|
13
|
+
- Fixed CodeQL findings: a relationship filename like `a000…0` no longer
|
|
14
|
+
triggers exponential regex backtracking, and the corner-radius parser no
|
|
15
|
+
longer runs in polynomial time on long whitespace input. Relative targets
|
|
16
|
+
(`../media/…`) are resolved with an anchored pattern.
|
|
17
|
+
|
|
18
|
+
## [0.1.2] - 2026-11-05
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `modify.setGeometry(shape, adjustments?)` crops a picture or shape to any
|
|
23
|
+
DrawingML preset geometry (*Crop to Shape*), e.g. `'ellipse'`, `'heart'`.
|
|
24
|
+
- `modify.setCornerRadius(radius, shape?)` rounds corners; the radius is a
|
|
25
|
+
number in cm or a string in `%`, `px`, `pt`, `cm` or `mm`.
|
|
26
|
+
- `{{IMAGE}}` takes `shape`, `cornerRadius`, `shapeAdjustments` and `border`,
|
|
27
|
+
as in docx-templates (`src/extensions/shape-geometry/`).
|
|
28
|
+
|
|
7
29
|
## [0.1.1] - 2026-11-04
|
|
8
30
|
|
|
9
31
|
### Fixed
|
|
@@ -52,5 +74,8 @@ for that history.
|
|
|
52
74
|
into one `.png` part. The fallback now gets the same placeholder PNG that
|
|
53
75
|
pptxgenjs 3.12 wrote.
|
|
54
76
|
|
|
55
|
-
[Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.
|
|
77
|
+
[Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.3...HEAD
|
|
78
|
+
[0.1.3]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.2...v0.1.3
|
|
79
|
+
[0.1.2]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.1...v0.1.2
|
|
80
|
+
[0.1.1]: https://github.com/DaBorsten/pptx-templates/compare/v0.1.0...v0.1.1
|
|
56
81
|
[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';
|
package/dist/extensions/index.js
CHANGED
|
@@ -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;
|
|
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 = /^(\d+(?:\.\d+)?)\s*(%|cm|mm|pt|px)?$/i.exec(radius.trim());
|
|
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
|
+
{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AAE,EAAE,CACrD,CAAC,OAAmB,EAAQ,EAAE;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"}
|
|
@@ -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>>>;
|