@shbernal/ts-pptx 3.1.0 → 3.2.0
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/README.md +39 -3
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +1 -1
- package/dist/{diagnostics-PMINsVP6.d.ts → diagnostics-Chjz_4_Q.d.ts} +4 -4
- package/dist/{diagnostics-PMINsVP6.d.ts.map → diagnostics-Chjz_4_Q.d.ts.map} +1 -1
- package/dist/{errors-BeUEkNWL.d.ts → errors-BVLCFr-t.d.ts} +2 -2
- package/dist/{errors-BeUEkNWL.d.ts.map → errors-BVLCFr-t.d.ts.map} +1 -1
- package/dist/html.d.ts +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +1 -1
- package/dist/inspect.js +2 -2
- package/dist/math.d.ts +1 -1
- package/dist/measure.d.ts +2 -2
- package/dist/node.d.ts +4 -4
- package/dist/node.js +1 -1
- package/dist/{pres-BgvxhQ_m.d.ts → pres-C-EU3SkN.d.ts} +2 -2
- package/dist/{pres-BgvxhQ_m.d.ts.map → pres-C-EU3SkN.d.ts.map} +1 -1
- package/dist/{presentation-BP1B8PCF.js → presentation-CxnUVhK9.js} +100 -24
- package/dist/presentation-CxnUVhK9.js.map +1 -0
- package/dist/{presentation-DyIRDKkp.d.ts → presentation-Osx1cDdJ.d.ts} +128 -31
- package/dist/presentation-Osx1cDdJ.d.ts.map +1 -0
- package/dist/read.d.ts +4 -4
- package/dist/read.js +2 -2
- package/dist/script.d.ts +32 -4
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +0 -0
- package/dist/script.js.map +1 -1
- package/dist/{shapes-DMThLsZN.js → shapes-DoJBPrwN.js} +79 -61
- package/dist/shapes-DoJBPrwN.js.map +1 -0
- package/dist/{slide-BRAtT8Dl.d.ts → slide-BTfn1Pyp.d.ts} +92 -9
- package/dist/slide-BTfn1Pyp.d.ts.map +1 -0
- package/dist/{text-B6PbMFih.js → text-C4P9MNdf.js} +157 -77
- package/dist/text-C4P9MNdf.js.map +1 -0
- package/dist/zip.d.ts +1 -1
- package/package.json +5 -2
- package/skills/ts-pptx-upstream/SKILL.md +107 -14
- package/dist/presentation-BP1B8PCF.js.map +0 -1
- package/dist/presentation-DyIRDKkp.d.ts.map +0 -1
- package/dist/shapes-DMThLsZN.js.map +0 -1
- package/dist/slide-BRAtT8Dl.d.ts.map +0 -1
- package/dist/text-B6PbMFih.js.map +0 -1
|
@@ -2632,28 +2632,29 @@ function setTextBodyText(txBody, value) {
|
|
|
2632
2632
|
*
|
|
2633
2633
|
* It owns everything a shape has regardless of kind: non-visual identity (id / name / hidden /
|
|
2634
2634
|
* description / decorative), geometry through the subclass-supplied `a:xfrm`, and the `p:spPr`
|
|
2635
|
-
* surface — fill, line, gradient, effects — resolved against the
|
|
2635
|
+
* surface — fill, line, gradient, effects — resolved against the host's theme. Kind-specific
|
|
2636
2636
|
* reads live on the subclasses in the sibling modules.
|
|
2637
2637
|
*
|
|
2638
|
-
* A proxy holds a back-reference to its owning
|
|
2639
|
-
* colours, and so a mutation can mark
|
|
2638
|
+
* A proxy holds a back-reference to its owning {@link ShapeHost} — a `Slide`, a `SlideLayout` or a
|
|
2639
|
+
* `SlideMaster` — so it can resolve relationships and theme colours, and so a mutation can mark
|
|
2640
|
+
* that host's part dirty.
|
|
2640
2641
|
*/
|
|
2641
2642
|
const ADEC_NS = "http://schemas.microsoft.com/office/drawing/2017/decorative";
|
|
2642
|
-
/** Common base for every shape in a slide's
|
|
2643
|
+
/** Common base for every shape in a shape tree — a slide's, a layout's, or a master's. */
|
|
2643
2644
|
var Shape = class {
|
|
2644
2645
|
element;
|
|
2645
|
-
|
|
2646
|
-
constructor(element,
|
|
2646
|
+
host;
|
|
2647
|
+
constructor(element, host) {
|
|
2647
2648
|
this.element = element;
|
|
2648
|
-
this.
|
|
2649
|
+
this.host = host;
|
|
2649
2650
|
}
|
|
2650
2651
|
/**
|
|
2651
|
-
* Mark the owning
|
|
2652
|
+
* Mark the owning host's part dirty so `save()` reserializes it. Public
|
|
2652
2653
|
* because {@link element_} hands out the live DOM node: the hatch and the
|
|
2653
2654
|
* obligation that comes with it belong on the same object.
|
|
2654
2655
|
*/
|
|
2655
2656
|
markDirty() {
|
|
2656
|
-
this.
|
|
2657
|
+
this.host.part.markDirty();
|
|
2657
2658
|
}
|
|
2658
2659
|
/** Drawing id (`p:cNvPr/@id`), or `null` if absent. */
|
|
2659
2660
|
get id() {
|
|
@@ -2777,7 +2778,7 @@ var Shape = class {
|
|
|
2777
2778
|
};
|
|
2778
2779
|
const ph = this.placeholder;
|
|
2779
2780
|
if (!ph) return null;
|
|
2780
|
-
return resolveInheritedFrame(ph, this.
|
|
2781
|
+
return resolveInheritedFrame(ph, this.host.themeContext());
|
|
2781
2782
|
}
|
|
2782
2783
|
/**
|
|
2783
2784
|
* Clockwise rotation in degrees (`a:xfrm/@rot` ÷ 60000), or `null` when the
|
|
@@ -3070,7 +3071,7 @@ var Shape = class {
|
|
|
3070
3071
|
* when the gradient carries no stop list.
|
|
3071
3072
|
*/
|
|
3072
3073
|
#gradientStopsIn(container) {
|
|
3073
|
-
return readGradientStops(container, this.
|
|
3074
|
+
return readGradientStops(container, this.host.themeContext());
|
|
3074
3075
|
}
|
|
3075
3076
|
/**
|
|
3076
3077
|
* Read the full `a:gradFill` (stops + linear angle / path shape) from a
|
|
@@ -3078,7 +3079,7 @@ var Shape = class {
|
|
|
3078
3079
|
* container has no gradient.
|
|
3079
3080
|
*/
|
|
3080
3081
|
#gradientFillIn(container) {
|
|
3081
|
-
return readGradientFill(container, this.
|
|
3082
|
+
return readGradientFill(container, this.host.themeContext());
|
|
3082
3083
|
}
|
|
3083
3084
|
/**
|
|
3084
3085
|
* The shape's gradient fill with its geometry (`spPr/a:gradFill`), or `null`
|
|
@@ -3129,7 +3130,7 @@ var Shape = class {
|
|
|
3129
3130
|
}
|
|
3130
3131
|
/**
|
|
3131
3132
|
* The shape's outer drop shadow (`spPr/a:effectLst/a:outerShdw`), resolved
|
|
3132
|
-
* against the
|
|
3133
|
+
* against the host's theme, or `null` when the shape has no outer shadow. The
|
|
3133
3134
|
* soft brand shadows the eye reads as "floating" panels live here and are
|
|
3134
3135
|
* invisible in geometry/fill alone.
|
|
3135
3136
|
*/
|
|
@@ -3139,7 +3140,7 @@ var Shape = class {
|
|
|
3139
3140
|
}
|
|
3140
3141
|
/**
|
|
3141
3142
|
* The shape's **inner** shadow (`spPr/a:effectLst/a:innerShdw`), resolved against
|
|
3142
|
-
* the
|
|
3143
|
+
* the host's theme, or `null` when the shape has no inner shadow. The inset
|
|
3143
3144
|
* counterpart of {@link shadow}: the write-side `shadow: { type: 'inner' }`
|
|
3144
3145
|
* emits it, and it is invisible in geometry/fill alone.
|
|
3145
3146
|
*/
|
|
@@ -3148,7 +3149,7 @@ var Shape = class {
|
|
|
3148
3149
|
return shdw ? this.#readShadow(shdw) : null;
|
|
3149
3150
|
}
|
|
3150
3151
|
/**
|
|
3151
|
-
* The shape's glow halo (`spPr/a:effectLst/a:glow`), resolved against the
|
|
3152
|
+
* The shape's glow halo (`spPr/a:effectLst/a:glow`), resolved against the host's
|
|
3152
3153
|
* theme, or `null` when the shape has no glow. Same element the write-side text
|
|
3153
3154
|
* glow emits, so its {@link Glow.radiusPt} and colour round-trip.
|
|
3154
3155
|
*/
|
|
@@ -3197,13 +3198,13 @@ var Shape = class {
|
|
|
3197
3198
|
/**
|
|
3198
3199
|
* The shape's pattern (hatch) fill (`spPr/a:pattFill`), or `null` when the fill
|
|
3199
3200
|
* is not a pattern. Surfaces the {@link PatternFill.preset} name and both
|
|
3200
|
-
* colours resolved against the
|
|
3201
|
+
* colours resolved against the host's theme — the pattern counterpart of
|
|
3201
3202
|
* {@link resolvedFill}, which reports `null` for a non-solid fill and so drops a
|
|
3202
3203
|
* hatched surface entirely.
|
|
3203
3204
|
*/
|
|
3204
3205
|
get patternFill() {
|
|
3205
3206
|
const props = this.properties();
|
|
3206
|
-
return props ? readPatternFill(props, this.
|
|
3207
|
+
return props ? readPatternFill(props, this.host.themeContext()) : null;
|
|
3207
3208
|
}
|
|
3208
3209
|
/**
|
|
3209
3210
|
* The shape's picture (image) fill (`spPr/a:blipFill`), or `null` when the fill
|
|
@@ -3216,7 +3217,7 @@ var Shape = class {
|
|
|
3216
3217
|
*/
|
|
3217
3218
|
get pictureFill() {
|
|
3218
3219
|
const props = this.properties();
|
|
3219
|
-
return props ? readPictureFill(props, this.
|
|
3220
|
+
return props ? readPictureFill(props, this.host.relationships) : null;
|
|
3220
3221
|
}
|
|
3221
3222
|
/** A named child of the shape's effect list (`spPr/a:effectLst/<qname>`), or `null`. */
|
|
3222
3223
|
#effect(qname) {
|
|
@@ -3226,7 +3227,7 @@ var Shape = class {
|
|
|
3226
3227
|
}
|
|
3227
3228
|
/** Resolve `colorEl` against the theme and stamp `color`/`colorToken`/`alpha` onto an effect result. */
|
|
3228
3229
|
#applyEffectColor(out, colorEl) {
|
|
3229
|
-
const resolved = resolveColorElement(colorEl, this.
|
|
3230
|
+
const resolved = resolveColorElement(colorEl, this.host.themeContext());
|
|
3230
3231
|
if (resolved) {
|
|
3231
3232
|
out.color = resolved.effectiveHex;
|
|
3232
3233
|
if (resolved.alpha !== void 0) out.alpha = resolved.alpha;
|
|
@@ -3246,7 +3247,7 @@ var Shape = class {
|
|
|
3246
3247
|
return out;
|
|
3247
3248
|
}
|
|
3248
3249
|
/**
|
|
3249
|
-
* The shape's solid fill resolved against the
|
|
3250
|
+
* The shape's solid fill resolved against the host's theme
|
|
3250
3251
|
* ({@link Slide.themeContext}) to a literal hex — the resolved counterpart of
|
|
3251
3252
|
* {@link fillColor}/{@link fillSchemeColor}, which report the raw reference.
|
|
3252
3253
|
* `null` when the shape has no `a:solidFill` (a gradient/none/inherited fill)
|
|
@@ -3260,13 +3261,13 @@ var Shape = class {
|
|
|
3260
3261
|
* matrix), resolved the same way the `theme: 'preserve'` flatten path bakes it.
|
|
3261
3262
|
*/
|
|
3262
3263
|
get resolvedFill() {
|
|
3263
|
-
const ctx = this.
|
|
3264
|
+
const ctx = this.host.themeContext();
|
|
3264
3265
|
const props = this.properties();
|
|
3265
3266
|
if (props && FILL_CHOICES.some((q) => firstChild(props, q))) return resolveSolidFillColor(props, ctx);
|
|
3266
3267
|
return resolveStyleFillColor(this.element, ctx);
|
|
3267
3268
|
}
|
|
3268
3269
|
/**
|
|
3269
|
-
* The shape's line/border solid fill resolved against the
|
|
3270
|
+
* The shape's line/border solid fill resolved against the host's theme to a
|
|
3270
3271
|
* literal hex — the resolved counterpart of {@link lineColor}/{@link lineSchemeColor}.
|
|
3271
3272
|
* `null` when the shape has no `a:ln/a:solidFill` or it cannot be made literal.
|
|
3272
3273
|
* Like {@link resolvedFill}, the result carries `effectiveHex` (the base colour
|
|
@@ -3276,7 +3277,7 @@ var Shape = class {
|
|
|
3276
3277
|
* the shape inherits from its `p:style` `a:lnRef` (the theme style matrix).
|
|
3277
3278
|
*/
|
|
3278
3279
|
get resolvedLine() {
|
|
3279
|
-
const ctx = this.
|
|
3280
|
+
const ctx = this.host.themeContext();
|
|
3280
3281
|
const ln = this.#line();
|
|
3281
3282
|
return ln ? resolveSolidFillColor(ln, ctx) : resolveStyleLineColor(this.element, ctx);
|
|
3282
3283
|
}
|
|
@@ -3343,8 +3344,8 @@ var Shape = class {
|
|
|
3343
3344
|
return null;
|
|
3344
3345
|
}
|
|
3345
3346
|
/**
|
|
3346
|
-
* Remove this shape from its parent (the
|
|
3347
|
-
* group) and mark the owning
|
|
3347
|
+
* Remove this shape from its parent (the host's shape tree, or an enclosing
|
|
3348
|
+
* group) and mark the owning host's part dirty. The proxy is dead afterwards.
|
|
3348
3349
|
*/
|
|
3349
3350
|
delete() {
|
|
3350
3351
|
const parent = this.element.parentNode;
|
|
@@ -3378,14 +3379,14 @@ var AutoShape = class extends Shape {
|
|
|
3378
3379
|
get textFrame() {
|
|
3379
3380
|
const txBody = firstChild(this.element, "p:txBody");
|
|
3380
3381
|
if (!txBody) return null;
|
|
3381
|
-
const flatten = this.
|
|
3382
|
+
const flatten = this.host.themeContext();
|
|
3382
3383
|
const ph = this.placeholder;
|
|
3383
3384
|
const fontRef = resolveStyleFontRef(this.element, flatten);
|
|
3384
|
-
return new TextFrame(txBody, this.
|
|
3385
|
+
return new TextFrame(txBody, this.host.part, flatten, {
|
|
3385
3386
|
ph,
|
|
3386
3387
|
flatten,
|
|
3387
3388
|
fontRef
|
|
3388
|
-
}, this.
|
|
3389
|
+
}, this.host.relationships);
|
|
3389
3390
|
}
|
|
3390
3391
|
/**
|
|
3391
3392
|
* This shape's placeholder identity (`p:ph` `type`/`idx`), or `null` when it is
|
|
@@ -3486,7 +3487,7 @@ var Picture = class extends Shape {
|
|
|
3486
3487
|
return blip ? attr(blip, "r:embed") : null;
|
|
3487
3488
|
}
|
|
3488
3489
|
/**
|
|
3489
|
-
* Repoint the blip at a relationship id already present in the
|
|
3490
|
+
* Repoint the blip at a relationship id already present in the owning part's
|
|
3490
3491
|
* relationships, without minting a new media part. The caller owns ensuring
|
|
3491
3492
|
* the id exists and targets an image; use {@link setImage} to add fresh bytes.
|
|
3492
3493
|
*/
|
|
@@ -3494,10 +3495,10 @@ var Picture = class extends Shape {
|
|
|
3494
3495
|
setAttr(this.#getOrAddBlip(), "r:embed", value);
|
|
3495
3496
|
this.markDirty();
|
|
3496
3497
|
}
|
|
3497
|
-
/** Absolute partname of the embedded image, resolved via the
|
|
3498
|
+
/** Absolute partname of the embedded image, resolved via the owning part's relationships, or `null`. */
|
|
3498
3499
|
get imagePartName() {
|
|
3499
3500
|
const relId = this.imageRelId;
|
|
3500
|
-
return relId ? this.
|
|
3501
|
+
return relId ? this.host.relationships.resolveTarget(relId) : null;
|
|
3501
3502
|
}
|
|
3502
3503
|
/**
|
|
3503
3504
|
* Relationship id of the embedded **vector (SVG)** image, read from the
|
|
@@ -3511,10 +3512,10 @@ var Picture = class extends Shape {
|
|
|
3511
3512
|
const svg = this.#svgBlip();
|
|
3512
3513
|
return svg ? attr(svg, "r:embed") : null;
|
|
3513
3514
|
}
|
|
3514
|
-
/** Absolute partname of the embedded SVG image, resolved via the
|
|
3515
|
+
/** Absolute partname of the embedded SVG image, resolved via the owning part's relationships, or `null`. */
|
|
3515
3516
|
get svgPartName() {
|
|
3516
3517
|
const relId = this.svgRelId;
|
|
3517
|
-
return relId ? this.
|
|
3518
|
+
return relId ? this.host.relationships.resolveTarget(relId) : null;
|
|
3518
3519
|
}
|
|
3519
3520
|
/**
|
|
3520
3521
|
* Which drawable media this picture carries:
|
|
@@ -3638,7 +3639,7 @@ var Picture = class extends Shape {
|
|
|
3638
3639
|
/**
|
|
3639
3640
|
* Replace this picture's image with new bytes. Mints a fresh media part under
|
|
3640
3641
|
* `/ppt/media/`, registers its content type, wires an `image` relationship
|
|
3641
|
-
* from the owning
|
|
3642
|
+
* from the owning part, and repoints the blip's `@r:embed` at it.
|
|
3642
3643
|
*
|
|
3643
3644
|
* Copy-on-write: the previous media part is never mutated or removed, so any
|
|
3644
3645
|
* other picture sharing it (common after `importSlide`/dedup) is unaffected;
|
|
@@ -3665,10 +3666,10 @@ var Picture = class extends Shape {
|
|
|
3665
3666
|
const { contentType } = options;
|
|
3666
3667
|
if (!contentType) throw new InvalidOptionError("image/missing-content-type", "setImage requires a contentType (e.g. \"image/png\")");
|
|
3667
3668
|
const extension = (options.extension ?? extFromContentType(contentType)).toLowerCase().replace(/^\./, "");
|
|
3668
|
-
const opc = this.
|
|
3669
|
+
const opc = this.host.opc;
|
|
3669
3670
|
const mediaPartName = opc.reserveMediaPartName(extension);
|
|
3670
3671
|
opc.addPart(mediaPartName, contentType, bytes);
|
|
3671
|
-
const relId = this.
|
|
3672
|
+
const relId = this.host.relationships.add(IMAGE_REL, relativePartName(this.host.partName, mediaPartName)).id;
|
|
3672
3673
|
setAttr(this.#getOrAddBlip(), "r:embed", relId);
|
|
3673
3674
|
if (options.fit) this.#applyFit(options.fit, bytes);
|
|
3674
3675
|
this.markDirty();
|
|
@@ -3741,7 +3742,7 @@ var Connector = class extends Shape {
|
|
|
3741
3742
|
get endConnection() {
|
|
3742
3743
|
return this.#connection("a:endCxn");
|
|
3743
3744
|
}
|
|
3744
|
-
/** Decode one `a:stCxn` / `a:endCxn` binding, resolving its `@id` to a
|
|
3745
|
+
/** Decode one `a:stCxn` / `a:endCxn` binding, resolving its `@id` to a shape in the same tree. */
|
|
3745
3746
|
#connection(qname) {
|
|
3746
3747
|
const nvCxnSpPr = firstChild(this.element, "p:nvCxnSpPr");
|
|
3747
3748
|
const cNvCxnSpPr = nvCxnSpPr && firstChild(nvCxnSpPr, "p:cNvCxnSpPr");
|
|
@@ -3753,7 +3754,7 @@ var Connector = class extends Shape {
|
|
|
3753
3754
|
return {
|
|
3754
3755
|
shapeId,
|
|
3755
3756
|
siteIndex,
|
|
3756
|
-
boundShape: this.
|
|
3757
|
+
boundShape: this.host.shapeByIdDeep(shapeId) ?? null
|
|
3757
3758
|
};
|
|
3758
3759
|
}
|
|
3759
3760
|
};
|
|
@@ -5713,7 +5714,7 @@ var GraphicFrame = class extends Shape {
|
|
|
5713
5714
|
const graphicData = this.#graphicData();
|
|
5714
5715
|
const tbl = graphicData && firstChild(graphicData, "a:tbl");
|
|
5715
5716
|
if (!tbl) return null;
|
|
5716
|
-
return new Table(tbl, this.
|
|
5717
|
+
return new Table(tbl, this.host.part, this.host.themeContext(), this.host.opc, this.host.relationships);
|
|
5717
5718
|
}
|
|
5718
5719
|
/** The hosted chart, or `null` when this frame is not a chart or its part is missing. */
|
|
5719
5720
|
get chart() {
|
|
@@ -5722,8 +5723,8 @@ var GraphicFrame = class extends Shape {
|
|
|
5722
5723
|
const chartRef = graphicData && firstChild(graphicData, "c:chart");
|
|
5723
5724
|
const relId = chartRef && attr(chartRef, "r:id");
|
|
5724
5725
|
if (!relId) return null;
|
|
5725
|
-
const partName = this.
|
|
5726
|
-
const part = this.
|
|
5726
|
+
const partName = this.host.relationships.resolveTarget(relId);
|
|
5727
|
+
const part = this.host.opc.part(partName);
|
|
5727
5728
|
return part ? new Chart(part) : null;
|
|
5728
5729
|
}
|
|
5729
5730
|
/**
|
|
@@ -5737,8 +5738,8 @@ var GraphicFrame = class extends Shape {
|
|
|
5737
5738
|
const chartRef = graphicData && firstChild(graphicData, "cx:chart");
|
|
5738
5739
|
const relId = chartRef && attr(chartRef, "r:id");
|
|
5739
5740
|
if (!relId) return null;
|
|
5740
|
-
const partName = this.
|
|
5741
|
-
const part = this.
|
|
5741
|
+
const partName = this.host.relationships.resolveTarget(relId);
|
|
5742
|
+
const part = this.host.opc.part(partName);
|
|
5742
5743
|
return part ? new ChartEx(part) : null;
|
|
5743
5744
|
}
|
|
5744
5745
|
#graphicData() {
|
|
@@ -5753,13 +5754,14 @@ var GraphicFrame = class extends Shape {
|
|
|
5753
5754
|
//#endregion
|
|
5754
5755
|
//#region src/read/api/shapes.ts
|
|
5755
5756
|
/**
|
|
5756
|
-
* Read-model proxies for the shapes
|
|
5757
|
+
* Read-model proxies for the shapes in a `p:spTree`.
|
|
5757
5758
|
*
|
|
5758
5759
|
* The `p:spTree` holds five shape kinds; each wraps its element and exposes
|
|
5759
5760
|
* non-visual identity (id/name), geometry (left/top/width/height in EMU), and
|
|
5760
|
-
* kind-specific reads. Proxies hold a back-reference to the owning
|
|
5761
|
-
*
|
|
5762
|
-
*
|
|
5761
|
+
* kind-specific reads. Proxies hold a back-reference to the owning
|
|
5762
|
+
* {@link ShapeHost} — the slide, layout, or master whose part carries the tree —
|
|
5763
|
+
* so pictures can resolve their image relationship and so edits can mark that
|
|
5764
|
+
* part dirty.
|
|
5763
5765
|
*
|
|
5764
5766
|
* This module is the entry point for that model: the `Shape` base and the four leaf kinds live in
|
|
5765
5767
|
* `./shapes/`, and only the dispatch that turns an element into a proxy — plus `GroupShape`, which
|
|
@@ -5827,7 +5829,7 @@ var GroupShape = class extends Shape {
|
|
|
5827
5829
|
}
|
|
5828
5830
|
/** The shapes nested directly inside this group, in document order. */
|
|
5829
5831
|
get shapes() {
|
|
5830
|
-
return buildShapes(this.element, this.
|
|
5832
|
+
return buildShapes(this.element, this.host);
|
|
5831
5833
|
}
|
|
5832
5834
|
};
|
|
5833
5835
|
/** Narrow a shape to an {@link AutoShape} (`p:sp` — auto shape, text box, or placeholder). */
|
|
@@ -5855,14 +5857,14 @@ function isGroupShape(shape) {
|
|
|
5855
5857
|
* `p:grpSp`) in its concrete `Shape` proxy, or `null` if it is not a shape kind
|
|
5856
5858
|
* (e.g. `p:nvGrpSpPr`, `p:grpSpPr`, `p:extLst`).
|
|
5857
5859
|
*/
|
|
5858
|
-
function wrapShapeElement(element,
|
|
5860
|
+
function wrapShapeElement(element, host) {
|
|
5859
5861
|
if (element.namespaceURI !== OOXML_NS.p) return null;
|
|
5860
5862
|
switch (element.localName) {
|
|
5861
|
-
case "sp": return new AutoShape(element,
|
|
5862
|
-
case "pic": return new Picture(element,
|
|
5863
|
-
case "cxnSp": return new Connector(element,
|
|
5864
|
-
case "graphicFrame": return new GraphicFrame(element,
|
|
5865
|
-
case "grpSp": return new GroupShape(element,
|
|
5863
|
+
case "sp": return new AutoShape(element, host);
|
|
5864
|
+
case "pic": return new Picture(element, host);
|
|
5865
|
+
case "cxnSp": return new Connector(element, host);
|
|
5866
|
+
case "graphicFrame": return new GraphicFrame(element, host);
|
|
5867
|
+
case "grpSp": return new GroupShape(element, host);
|
|
5866
5868
|
default: return null;
|
|
5867
5869
|
}
|
|
5868
5870
|
}
|
|
@@ -5874,11 +5876,11 @@ function wrapShapeElement(element, slide) {
|
|
|
5874
5876
|
* chartEx chart's `p:graphicFrame`, a zoom frame, an inline-math shape. Returns
|
|
5875
5877
|
* the wrapped inner shape, or `null` when neither branch holds one.
|
|
5876
5878
|
*/
|
|
5877
|
-
function unwrapAlternateContent(altContent,
|
|
5879
|
+
function unwrapAlternateContent(altContent, host) {
|
|
5878
5880
|
const branches = [...getElements(altContent, "mc:Choice"), ...getElements(altContent, "mc:Fallback")];
|
|
5879
5881
|
for (const branch of branches) for (let node = branch.firstChild; node; node = node.nextSibling) {
|
|
5880
5882
|
if (node.nodeType !== 1) continue;
|
|
5881
|
-
const shape = wrapShapeElement(node,
|
|
5883
|
+
const shape = wrapShapeElement(node, host);
|
|
5882
5884
|
if (shape) return shape;
|
|
5883
5885
|
}
|
|
5884
5886
|
return null;
|
|
@@ -5889,22 +5891,38 @@ function unwrapAlternateContent(altContent, slide) {
|
|
|
5889
5891
|
* `mc:AlternateContent` wrapper (chartEx charts, zoom frames, inline math) is
|
|
5890
5892
|
* unwrapped to the shape inside its preferred branch.
|
|
5891
5893
|
*/
|
|
5892
|
-
function buildShapes(parent,
|
|
5894
|
+
function buildShapes(parent, host) {
|
|
5893
5895
|
const shapes = [];
|
|
5894
5896
|
for (let node = parent.firstChild; node; node = node.nextSibling) {
|
|
5895
5897
|
if (node.nodeType !== 1) continue;
|
|
5896
5898
|
const element = node;
|
|
5897
5899
|
if (element.namespaceURI === OOXML_NS.mc && element.localName === "AlternateContent") {
|
|
5898
|
-
const unwrapped = unwrapAlternateContent(element,
|
|
5900
|
+
const unwrapped = unwrapAlternateContent(element, host);
|
|
5899
5901
|
if (unwrapped) shapes.push(unwrapped);
|
|
5900
5902
|
continue;
|
|
5901
5903
|
}
|
|
5902
|
-
const shape = wrapShapeElement(element,
|
|
5904
|
+
const shape = wrapShapeElement(element, host);
|
|
5903
5905
|
if (shape) shapes.push(shape);
|
|
5904
5906
|
}
|
|
5905
5907
|
return shapes;
|
|
5906
5908
|
}
|
|
5909
|
+
/**
|
|
5910
|
+
* The first shape in `shapes` with the given drawing id (`p:cNvPr/@id`), walked
|
|
5911
|
+
* pre-order so a group is visited before its children. Backs
|
|
5912
|
+
* {@link ShapeHost.shapeByIdDeep} on all three hosts — drawing ids are unique
|
|
5913
|
+
* within a part, so the first match is the only match and the walk order just
|
|
5914
|
+
* fixes a deterministic one.
|
|
5915
|
+
*/
|
|
5916
|
+
function findShapeByIdDeep(shapes, id) {
|
|
5917
|
+
for (const shape of shapes) {
|
|
5918
|
+
if (shape.id === id) return shape;
|
|
5919
|
+
if (shape instanceof GroupShape) {
|
|
5920
|
+
const found = findShapeByIdDeep(shape.shapes, id);
|
|
5921
|
+
if (found) return found;
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5907
5925
|
//#endregion
|
|
5908
|
-
export {
|
|
5926
|
+
export { parseClrScheme as $, readGradientFill as A, getElements as At, placeholderInheritedAnchor as B, setAttr as Bt, Shape as C, boolValue as Ct, spPrXfrmEmu as D, escapeXmlAttribute as Dt, TextFrame as E, descendantsByTag as Et, resolveSlideColorContext as F, parseXml as Ft, placeholderOf as G, placeholderInheritedListStyles as H, resolveSlideThemeParts as I, removeAttr as It, SCHEME_SLOTS as J, slideDefinesColor as K, applyColorTransforms as L, removeChildrenByQName as Lt, resolveLayoutColorContext as M, insertInOrder as Mt, resolveMasterColorContext as N, intValue as Nt, readPatternFill as O, firstChild as Ot, resolveNotesColorContext as P, ownerDocumentOf as Pt, parseClrMap as Q, LST_STYLE_LEVELS as R, replaceInParent as Rt, AutoShape as S, attr as St, Run as T, createElement as Tt, placeholderInheritedRunProps as U, placeholderInheritedColor as V, placeholderInheritedXfrm as W, intAttr as X, fmtEntry as Y, isA as Z, Chart as _, relsPartNameFor as _t, isConnector as a, FILL_CHOICES as at, Connector as b, zipPathToPartName as bt, isPicture as c, SPPR_AFTER_XFRM as ct, Table as d, SPPR_LN_AFTER as dt, resolveColor as et, TableCell as f, SPPR_SCENE3D_AFTER as ft, ChartExSeries as g, relativePartName as gt, ChartExAxis as h, partNameToZipPath as ht, isAutoShape as i, substitutePhClr as it, resolveColorElement as j, getOrAddChild as jt, readPictureFill as k, firstChildElement as kt, wrapShapeElement as l, SPPR_EFFECT_AFTER as lt, ChartEx as m, partNameExtension as mt, buildShapes as n, styleRefFill as nt, isGraphicFrame as o, RPR_FILL_AFTER as ot, TableRow as p, SPPR_SP3D_AFTER as pt, slideDefinesProp as q, findShapeByIdDeep as r, styleRefLine as rt, isGroupShape as s, SHAPE_AFTER_SPPR as st, GroupShape as t, resolveSchemeToken as tt, GraphicFrame as u, SPPR_FILL_AFTER as ut, ChartAxis as v, resolveRelativePartName as vt, Paragraph as w, childElements as wt, Picture as x, OOXML_NS as xt, ChartSeries as y, resolveSingleRel as yt, RUN_PROP_NAMES as z, serializeXml as zt };
|
|
5909
5927
|
|
|
5910
|
-
//# sourceMappingURL=shapes-
|
|
5928
|
+
//# sourceMappingURL=shapes-DoJBPrwN.js.map
|