pptx-templates 0.1.0 → 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
@@ -6,6 +6,26 @@ semver, with the pre-1.0 convention that **breaking changes bump the minor**.
6
6
 
7
7
  ## [Unreleased]
8
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
+
20
+ ## [0.1.1] - 2026-11-04
21
+
22
+ ### Fixed
23
+
24
+ - `modify.replaceText` now finds `{{tags}}` that PowerPoint split over several
25
+ runs (spell check `err="1"`, edit history). Before the search, a split tag
26
+ is moved into the run it starts in; text before and after the tag keeps its
27
+ own run and formatting (`src/extensions/run-merge/`).
28
+
9
29
  ## [0.1.0]
10
30
 
11
31
  First release as `pptx-templates`, a fork of
@@ -45,5 +65,7 @@ for that history.
45
65
  into one `.png` part. The fallback now gets the same placeholder PNG that
46
66
  pptxgenjs 3.12 wrote.
47
67
 
48
- [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
49
71
  [0.1.0]: https://github.com/DaBorsten/pptx-templates/releases/tag/v0.1.0
package/README.md CHANGED
@@ -81,7 +81,5 @@ Found a security problem? Please follow the [security policy](https://github.com
81
81
 
82
82
  This project was inspired by:
83
83
 
84
- - [PptxGenJS](https://github.com/gitbrent/PptxGenJS)
85
- - [officegen](https://github.com/Ziv-Barber/officegen)
86
- - [node-pptx](https://github.com/heavysixer/node-pptx)
87
- - [docxtemplater](https://github.com/open-xml-templating/docxtemplater)
84
+ - [pptx-automizer](https://github.com/singerla/pptx-automizer)
85
+ - [docx-templates](https://github.com/guigrpa/docx-templates)
@@ -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,13 @@
1
+ import { XmlElement } from '../../types/xml-types';
2
+ /**
3
+ * PowerPoint splits text into several `a:r` runs whenever it likes (spell
4
+ * check `err="1"`, edit history, formatting changes). A tag such as `{{name}}`
5
+ * can then be spread over runs and a per-run search never finds it.
6
+ *
7
+ * This moves, per paragraph, every tag that spans directly adjacent runs
8
+ * completely into the run it starts in. Only the tag characters move: text
9
+ * before and after the tag stays in its own run with its own formatting, and
10
+ * runs left empty are removed. The tag (and so its replacement) takes the
11
+ * formatting of the run it starts in.
12
+ */
13
+ export declare function mergeRunsSplitByTags(element: XmlElement, openingTag: string, closingTag: string): void;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mergeRunsSplitByTags = mergeRunsSplitByTags;
7
+ const regexp_escape_1 = __importDefault(require("regexp.escape"));
8
+ const modify_text_helper_1 = __importDefault(require("../../helper/modify-text-helper"));
9
+ /**
10
+ * PowerPoint splits text into several `a:r` runs whenever it likes (spell
11
+ * check `err="1"`, edit history, formatting changes). A tag such as `{{name}}`
12
+ * can then be spread over runs and a per-run search never finds it.
13
+ *
14
+ * This moves, per paragraph, every tag that spans directly adjacent runs
15
+ * completely into the run it starts in. Only the tag characters move: text
16
+ * before and after the tag stays in its own run with its own formatting, and
17
+ * runs left empty are removed. The tag (and so its replacement) takes the
18
+ * formatting of the run it starts in.
19
+ */
20
+ function mergeRunsSplitByTags(element, openingTag, closingTag) {
21
+ const open = (0, regexp_escape_1.default)(openingTag);
22
+ const close = (0, regexp_escape_1.default)(closingTag);
23
+ const pattern = new RegExp(`${open}[^${open}${close}]+${close}`, 'g');
24
+ const paragraphs = element.getElementsByTagName('a:p');
25
+ for (let p = 0; p < paragraphs.length; p++) {
26
+ adjacentRunGroups(paragraphs[p]).forEach((runs) => mergeGroup(runs, pattern));
27
+ }
28
+ }
29
+ /** Runs that follow each other without another element in between. */
30
+ function adjacentRunGroups(paragraph) {
31
+ const groups = [];
32
+ let current = [];
33
+ const flush = () => {
34
+ if (current.length > 1)
35
+ groups.push(current);
36
+ current = [];
37
+ };
38
+ for (let n = paragraph.firstChild; n; n = n.nextSibling) {
39
+ if (n.nodeType !== 1)
40
+ continue;
41
+ const el = n;
42
+ if (el.tagName === 'a:r')
43
+ current.push(el);
44
+ else if (el.tagName !== 'a:pPr' && el.tagName !== 'a:endParaRPr')
45
+ flush();
46
+ }
47
+ flush();
48
+ return groups;
49
+ }
50
+ function runText(run) {
51
+ var _a, _b;
52
+ return (_b = (_a = run.getElementsByTagName('a:t')[0]) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : '';
53
+ }
54
+ function mergeGroup(runs, pattern) {
55
+ const texts = runs.map(runText);
56
+ const full = texts.join('');
57
+ // owner[pos] = index of the run that character pos ends up in.
58
+ const owner = [];
59
+ texts.forEach((t, r) => {
60
+ for (let i = 0; i < t.length; i++)
61
+ owner.push(r);
62
+ });
63
+ // A tag spanning several runs moves completely into the run it starts in.
64
+ // Text before and after the tag stays where it was, so the boundary runs
65
+ // keep their formatting. owner stays non-decreasing, so each run's new
66
+ // text is still one contiguous slice of `full`.
67
+ const changed = new Set();
68
+ for (const match of full.matchAll(pattern)) {
69
+ const start = match.index;
70
+ const end = start + match[0].length;
71
+ const first = owner[start];
72
+ if (owner[end - 1] === first)
73
+ continue;
74
+ for (let pos = start; pos < end; pos++) {
75
+ changed.add(owner[pos]);
76
+ owner[pos] = first;
77
+ }
78
+ }
79
+ changed.forEach((r) => {
80
+ const from = owner.indexOf(r);
81
+ const text = from === -1 ? '' : full.slice(from, owner.lastIndexOf(r) + 1);
82
+ const textElement = runs[r].getElementsByTagName('a:t')[0];
83
+ if (!text)
84
+ runs[r].parentNode.removeChild(runs[r]);
85
+ else if (textElement)
86
+ modify_text_helper_1.default.content(text)(textElement);
87
+ });
88
+ }
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/run-merge/index.ts"],"names":[],"mappings":";;;;;AAeA,oDAeC;AA9BD,kEAAmC;AACnC,yFAA+D;AAG/D;;;;;;;;;;GAUG;AACH,SAAgB,oBAAoB,CAClC,OAAmB,EACnB,UAAkB,EAClB,UAAkB;IAElB,MAAM,IAAI,GAAG,IAAA,uBAAM,EAAC,UAAU,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,IAAA,uBAAM,EAAC,UAAU,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,GAAG,IAAI,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC;IAEtE,MAAM,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACvD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC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AAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3E,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9C,IAAI,WAAW;YAAE,4BAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -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,MAA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A,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>>>;