@shbernal/ts-pptx 3.2.0 → 3.4.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 +19 -20
- package/dist/{autopage-QQyfRtoK.js → autopage-BYlTzX-l.js} +21 -17
- package/dist/autopage-BYlTzX-l.js.map +1 -0
- package/dist/browser.d.ts +6 -6
- package/dist/browser.js +11 -12
- package/dist/browser.js.map +1 -1
- package/dist/{diagnostics-Chjz_4_Q.d.ts → diagnostics-B0OmTOoz.d.ts} +65 -16
- package/dist/diagnostics-B0OmTOoz.d.ts.map +1 -0
- package/dist/{diagnostics-DYQC7xLV.js → diagnostics-CPVADSL1.js} +0 -0
- package/dist/{diagnostics-DYQC7xLV.js.map → diagnostics-CPVADSL1.js.map} +1 -1
- package/dist/{enums-CoXnxiCI.d.ts → enums-CvRYniUA.d.ts} +13 -3
- package/dist/{enums-CoXnxiCI.d.ts.map → enums-CvRYniUA.d.ts.map} +1 -1
- package/dist/{errors-BVLCFr-t.d.ts → errors-fB1KDJKQ.d.ts} +5 -5
- package/dist/{errors-BVLCFr-t.d.ts.map → errors-fB1KDJKQ.d.ts.map} +1 -1
- package/dist/{fit-DhMbQG5O.js → fit-TjpNbMru.js} +0 -0
- package/dist/fit-TjpNbMru.js.map +1 -0
- package/dist/{html-dom-DajBuobe.js → html-dom-yUSdCExA.js} +5 -6
- package/dist/html-dom-yUSdCExA.js.map +1 -0
- package/dist/html.d.ts +3 -3
- package/dist/html.js +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +16 -34
- package/dist/index.js.map +1 -1
- package/dist/inspect.d.ts +1 -1
- package/dist/inspect.js +5 -4
- package/dist/inspect.js.map +1 -1
- package/dist/math.d.ts +1 -1
- package/dist/measure.d.ts +96 -6
- package/dist/measure.d.ts.map +1 -1
- package/dist/measure.js +2 -2
- package/dist/{st-enums-evQG2A7Z.js → namespaces-Sy_m7Nhd.js} +318 -209
- package/dist/namespaces-Sy_m7Nhd.js.map +1 -0
- package/dist/node.d.ts +6 -6
- package/dist/node.js +7 -20
- package/dist/node.js.map +1 -1
- package/dist/notes-bWApshah.js +1727 -0
- package/dist/notes-bWApshah.js.map +1 -0
- package/dist/{pres-C-EU3SkN.d.ts → pres-Dybf7ZUl.d.ts} +4 -4
- package/dist/{pres-C-EU3SkN.d.ts.map → pres-Dybf7ZUl.d.ts.map} +1 -1
- package/dist/{presentation-CxnUVhK9.js → presentation-3rAKKRfm.js} +1247 -743
- package/dist/presentation-3rAKKRfm.js.map +1 -0
- package/dist/{presentation-Osx1cDdJ.d.ts → presentation-types-D7cgT-eG.d.ts} +867 -24
- package/dist/presentation-types-D7cgT-eG.d.ts.map +1 -0
- package/dist/read.d.ts +4 -5
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +3 -3
- package/dist/script.d.ts +2 -2
- package/dist/script.d.ts.map +1 -1
- package/dist/script.js +0 -0
- package/dist/script.js.map +1 -1
- package/dist/{shapes-DoJBPrwN.js → shapes-Dyw5bxwO.js} +371 -52
- package/dist/shapes-Dyw5bxwO.js.map +1 -0
- package/dist/{slide-BTfn1Pyp.d.ts → slide-B_aInw3N.d.ts} +246 -182
- package/dist/slide-B_aInw3N.d.ts.map +1 -0
- package/dist/{text-C4P9MNdf.js → text-DSN3anEh.js} +3609 -4932
- package/dist/text-DSN3anEh.js.map +1 -0
- package/dist/{units-internal-CR8s8YQa.js → units-internal-DNvK2I6o.js} +207 -35
- package/dist/units-internal-DNvK2I6o.js.map +1 -0
- package/dist/zip.d.ts +2 -2
- package/package.json +36 -27
- package/dist/autopage-QQyfRtoK.js.map +0 -1
- package/dist/diagnostics-Chjz_4_Q.d.ts.map +0 -1
- package/dist/embedded-fonts-MaynAHa9.js +0 -94
- package/dist/embedded-fonts-MaynAHa9.js.map +0 -1
- package/dist/fit-DhMbQG5O.js.map +0 -1
- package/dist/html-dom-DajBuobe.js.map +0 -1
- package/dist/presentation-CxnUVhK9.js.map +0 -1
- package/dist/presentation-Osx1cDdJ.d.ts.map +0 -1
- package/dist/presentation-types-Dj4riuDs.d.ts +0 -538
- package/dist/presentation-types-Dj4riuDs.d.ts.map +0 -1
- package/dist/shapes-DoJBPrwN.js.map +0 -1
- package/dist/slide-BTfn1Pyp.d.ts.map +0 -1
- package/dist/st-enums-evQG2A7Z.js.map +0 -1
- package/dist/text-C4P9MNdf.js.map +0 -1
- package/dist/units-C7QM1KgH.js +0 -144
- package/dist/units-C7QM1KgH.js.map +0 -1
- package/dist/units-internal-CR8s8YQa.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as warn } from "./diagnostics-CPVADSL1.js";
|
|
2
2
|
import { i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, t as InternalError } from "./errors-Bvln0H-7.js";
|
|
3
|
-
import {
|
|
3
|
+
import { A as TEXT_ANCHORS, M as TEXT_VERTICAL, N as checkEnumOrThrow, _ as THEME_REL, a as NOTES_MASTER_REL, b as getImageSizeFromBytes, c as OFFICE_DOCUMENT_REL, f as SLIDE_LAYOUT_REL, j as TEXT_HORZ_OVERFLOW, m as SLIDE_MASTER_REL, r as IMAGE_REL, t as OOXML_NS, v as fitSrcRectPercents } from "./namespaces-Sy_m7Nhd.js";
|
|
4
4
|
import { DOMParser, MIME_TYPE, XMLSerializer, onErrorStopParsing } from "@xmldom/xmldom";
|
|
5
5
|
/** Parse an XML string strictly: any well-formedness error throws. */
|
|
6
6
|
function parseXml(xml) {
|
|
@@ -14,24 +14,6 @@ function parseXml(xml) {
|
|
|
14
14
|
function serializeXml(doc) {
|
|
15
15
|
return new XMLSerializer().serializeToString(doc);
|
|
16
16
|
}
|
|
17
|
-
/** Canonical OOXML prefix → namespace URI registry. */
|
|
18
|
-
const OOXML_NS = Object.freeze({
|
|
19
|
-
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
20
|
-
c: "http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
21
|
-
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
22
|
-
ct: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
23
|
-
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
24
|
-
dc: "http://purl.org/dc/elements/1.1/",
|
|
25
|
-
dcterms: "http://purl.org/dc/terms/",
|
|
26
|
-
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
27
|
-
ep: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
|
|
28
|
-
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
29
|
-
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
30
|
-
p14: "http://schemas.microsoft.com/office/powerpoint/2010/main",
|
|
31
|
-
p188: "http://schemas.microsoft.com/office/powerpoint/2018/8/main",
|
|
32
|
-
pr: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
33
|
-
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
34
|
-
});
|
|
35
17
|
function splitQName(qname) {
|
|
36
18
|
const colon = qname.indexOf(":");
|
|
37
19
|
if (colon < 0) throw new InvalidOptionError("oxml/invalid-qname", `Expected a prefixed qname like "p:sld", got: ${qname}`);
|
|
@@ -686,6 +668,94 @@ function intAttr(el, name) {
|
|
|
686
668
|
return Number.isFinite(n) ? n : null;
|
|
687
669
|
}
|
|
688
670
|
//#endregion
|
|
671
|
+
//#region src/read/oxml/slide-dom.ts
|
|
672
|
+
/**
|
|
673
|
+
* The `p:cSld` of a slide/layout/master/notes part root.
|
|
674
|
+
*
|
|
675
|
+
* Takes a nullable root and returns a nullable element so a caller can chain from
|
|
676
|
+
* `part?.dom.documentElement` without a guard of its own — which is what a dozen callers were
|
|
677
|
+
* writing by hand, each in a slightly different spelling (`root && …`, `root ? … : null`).
|
|
678
|
+
*/
|
|
679
|
+
function cSldOf(root) {
|
|
680
|
+
return root ? firstChild(root, "p:cSld") : null;
|
|
681
|
+
}
|
|
682
|
+
/** The `p:spTree` of a slide/layout/master/notes part root, through its `p:cSld`. */
|
|
683
|
+
function spTreeOf(root) {
|
|
684
|
+
const cSld = cSldOf(root);
|
|
685
|
+
return cSld ? firstChild(cSld, "p:spTree") : null;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* The `p:nvPr` of a shape, whichever `*nvPr` wrapper its kind uses.
|
|
689
|
+
*
|
|
690
|
+
* The wrapper's name varies by shape kind — `p:nvSpPr` on a `p:sp`, `p:nvPicPr` on a `p:pic`,
|
|
691
|
+
* `p:nvGraphicFramePr`, `p:nvCxnSpPr`, `p:nvGrpSpPr` — but it is always the shape's first child
|
|
692
|
+
* element, and `p:nvPr` is always inside it. Taking the first child element rather than naming
|
|
693
|
+
* the wrapper is what lets one helper serve every kind; the callers that named `p:nvSpPr`
|
|
694
|
+
* silently returned null on a picture.
|
|
695
|
+
*/
|
|
696
|
+
function nvPrOf(shape) {
|
|
697
|
+
const nv = firstChildElement(shape);
|
|
698
|
+
return nv ? firstChild(nv, "p:nvPr") : null;
|
|
699
|
+
}
|
|
700
|
+
/** The `p:cSld@name` of a slide/layout/master part (`''` when absent). */
|
|
701
|
+
function cSldName(part) {
|
|
702
|
+
const cSld = cSldOf(part?.dom.documentElement);
|
|
703
|
+
return (cSld && attr(cSld, "name")) ?? "";
|
|
704
|
+
}
|
|
705
|
+
/** Whether `el` is a `p:spTree`'s own group properties (`p:nvGrpSpPr`/`p:grpSpPr`), not a shape. */
|
|
706
|
+
function isSpTreeProperty(el) {
|
|
707
|
+
return el.namespaceURI === OOXML_NS.p && (el.localName === "nvGrpSpPr" || el.localName === "grpSpPr");
|
|
708
|
+
}
|
|
709
|
+
/** Whether a `p:spTree` child is a placeholder shape (its `*nvPr` carries a `p:ph`). */
|
|
710
|
+
function isPlaceholderShape(shape) {
|
|
711
|
+
const nvPr = nvPrOf(shape);
|
|
712
|
+
return !!(nvPr && firstChild(nvPr, "p:ph"));
|
|
713
|
+
}
|
|
714
|
+
/** The decorative shapes on a layout/master `p:spTree`: every shape child except placeholders. */
|
|
715
|
+
function carriedDecorations(root) {
|
|
716
|
+
const spTree = spTreeOf(root);
|
|
717
|
+
if (!spTree) return [];
|
|
718
|
+
const out = [];
|
|
719
|
+
for (let node = spTree.firstChild; node; node = node.nextSibling) {
|
|
720
|
+
if (node.nodeType !== 1) continue;
|
|
721
|
+
const el = node;
|
|
722
|
+
if (isSpTreeProperty(el) || isPlaceholderShape(el)) continue;
|
|
723
|
+
out.push(el);
|
|
724
|
+
}
|
|
725
|
+
return out;
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* The `n`-th shape child of a `p:spTree` in document (z-)order, skipping the
|
|
729
|
+
* tree's own `nvGrpSpPr`/`grpSpPr` and any trailing `p:extLst`. Returns `null`
|
|
730
|
+
* when `n` is past the last shape (the caller then appends).
|
|
731
|
+
*/
|
|
732
|
+
function nthShapeChild(spTree, n) {
|
|
733
|
+
let i = 0;
|
|
734
|
+
for (let node = spTree.firstChild; node; node = node.nextSibling) {
|
|
735
|
+
if (node.nodeType !== 1) continue;
|
|
736
|
+
const el = node;
|
|
737
|
+
if (isSpTreeProperty(el)) continue;
|
|
738
|
+
if (el.namespaceURI === OOXML_NS.p && el.localName === "extLst") continue;
|
|
739
|
+
if (i === n) return el;
|
|
740
|
+
i++;
|
|
741
|
+
}
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
/** The first shape child of a `p:spTree` (skipping `nvGrpSpPr`/`grpSpPr`), or `null`. */
|
|
745
|
+
function firstShapeChild(spTree) {
|
|
746
|
+
for (let node = spTree.firstChild; node; node = node.nextSibling) {
|
|
747
|
+
if (node.nodeType !== 1) continue;
|
|
748
|
+
const el = node;
|
|
749
|
+
if (!isSpTreeProperty(el)) return el;
|
|
750
|
+
}
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
/** Collect `node` and all its descendant elements (document order) into `out`. */
|
|
754
|
+
function collectElements(node, out) {
|
|
755
|
+
out.push(node);
|
|
756
|
+
for (let child = node.firstChild; child; child = child.nextSibling) if (child.nodeType === 1) collectElements(child, out);
|
|
757
|
+
}
|
|
758
|
+
//#endregion
|
|
689
759
|
//#region src/read/oxml/placeholder-inherit.ts
|
|
690
760
|
/**
|
|
691
761
|
* Resolving what a placeholder shape *inherits* from its source layout/master chain.
|
|
@@ -733,8 +803,7 @@ const RUN_PROP_NAMES = [
|
|
|
733
803
|
];
|
|
734
804
|
/** The `p:ph` element of a shape (`p:sp/p:nvSpPr/p:nvPr/p:ph`), or `null`. */
|
|
735
805
|
function placeholderOf(sp) {
|
|
736
|
-
const
|
|
737
|
-
const nvPr = nvSpPr && firstChild(nvSpPr, "p:nvPr");
|
|
806
|
+
const nvPr = nvPrOf(sp);
|
|
738
807
|
return nvPr ? firstChild(nvPr, "p:ph") : null;
|
|
739
808
|
}
|
|
740
809
|
/**
|
|
@@ -2649,6 +2718,21 @@ var Shape = class {
|
|
|
2649
2718
|
this.host = host;
|
|
2650
2719
|
}
|
|
2651
2720
|
/**
|
|
2721
|
+
* The transform element carrying this shape's geometry, or `null` if inherited.
|
|
2722
|
+
*
|
|
2723
|
+
* Defaults to `p:spPr/a:xfrm`, which is where three of the four shape kinds keep it
|
|
2724
|
+
* (`p:sp`, `p:pic`, `p:cxnSp`). {@link GraphicFrame} overrides it: a `p:graphicFrame`
|
|
2725
|
+
* has no `p:spPr` and carries a `p:xfrm` of its own directly.
|
|
2726
|
+
*/
|
|
2727
|
+
xfrm() {
|
|
2728
|
+
const spPr = firstChild(this.element, "p:spPr");
|
|
2729
|
+
return spPr ? firstChild(spPr, "a:xfrm") : null;
|
|
2730
|
+
}
|
|
2731
|
+
/** The transform element, creating it (and its container) in document order if absent. */
|
|
2732
|
+
getOrAddXfrm() {
|
|
2733
|
+
return getOrAddSpPrXfrm(this.element);
|
|
2734
|
+
}
|
|
2735
|
+
/**
|
|
2652
2736
|
* Mark the owning host's part dirty so `save()` reserializes it. Public
|
|
2653
2737
|
* because {@link element_} hands out the live DOM node: the hatch and the
|
|
2654
2738
|
* obligation that comes with it belong on the same object.
|
|
@@ -3366,13 +3450,6 @@ var Shape = class {
|
|
|
3366
3450
|
/** An auto shape, text box, or placeholder (`p:sp`). The only kind that holds text. */
|
|
3367
3451
|
var AutoShape = class extends Shape {
|
|
3368
3452
|
shapeType = "autoShape";
|
|
3369
|
-
xfrm() {
|
|
3370
|
-
const spPr = firstChild(this.element, "p:spPr");
|
|
3371
|
-
return spPr ? firstChild(spPr, "a:xfrm") : null;
|
|
3372
|
-
}
|
|
3373
|
-
getOrAddXfrm() {
|
|
3374
|
-
return getOrAddSpPrXfrm(this.element);
|
|
3375
|
-
}
|
|
3376
3453
|
get hasTextFrame() {
|
|
3377
3454
|
return firstChild(this.element, "p:txBody") !== null;
|
|
3378
3455
|
}
|
|
@@ -3394,8 +3471,7 @@ var AutoShape = class extends Shape {
|
|
|
3394
3471
|
* PowerPoint does. Use {@link Slide.placeholder} to find a placeholder by type.
|
|
3395
3472
|
*/
|
|
3396
3473
|
get placeholder() {
|
|
3397
|
-
const
|
|
3398
|
-
const nvPr = nvSpPr && firstChild(nvSpPr, "p:nvPr");
|
|
3474
|
+
const nvPr = nvPrOf(this.element);
|
|
3399
3475
|
const ph = nvPr && firstChild(nvPr, "p:ph");
|
|
3400
3476
|
return ph ? {
|
|
3401
3477
|
type: attr(ph, "type"),
|
|
@@ -3470,13 +3546,6 @@ function recolorColorOf(color) {
|
|
|
3470
3546
|
/** A picture (`p:pic`). */
|
|
3471
3547
|
var Picture = class extends Shape {
|
|
3472
3548
|
shapeType = "picture";
|
|
3473
|
-
xfrm() {
|
|
3474
|
-
const spPr = firstChild(this.element, "p:spPr");
|
|
3475
|
-
return spPr ? firstChild(spPr, "a:xfrm") : null;
|
|
3476
|
-
}
|
|
3477
|
-
getOrAddXfrm() {
|
|
3478
|
-
return getOrAddSpPrXfrm(this.element);
|
|
3479
|
-
}
|
|
3480
3549
|
get supportsFill() {
|
|
3481
3550
|
return false;
|
|
3482
3551
|
}
|
|
@@ -3719,13 +3788,6 @@ var Picture = class extends Shape {
|
|
|
3719
3788
|
/** A connector / line (`p:cxnSp`). */
|
|
3720
3789
|
var Connector = class extends Shape {
|
|
3721
3790
|
shapeType = "connector";
|
|
3722
|
-
xfrm() {
|
|
3723
|
-
const spPr = firstChild(this.element, "p:spPr");
|
|
3724
|
-
return spPr ? firstChild(spPr, "a:xfrm") : null;
|
|
3725
|
-
}
|
|
3726
|
-
getOrAddXfrm() {
|
|
3727
|
-
return getOrAddSpPrXfrm(this.element);
|
|
3728
|
-
}
|
|
3729
3791
|
/**
|
|
3730
3792
|
* The connector's **start**-point shape binding (`p:nvCxnSpPr/p:cNvCxnSpPr/a:stCxn`),
|
|
3731
3793
|
* or `null` when the start point is unbound (a bare `p:cNvCxnSpPr`, i.e. a
|
|
@@ -4405,6 +4467,227 @@ function floatValue(value) {
|
|
|
4405
4467
|
return Number.isFinite(number) ? number : null;
|
|
4406
4468
|
}
|
|
4407
4469
|
//#endregion
|
|
4470
|
+
//#region src/read/api/diagram.ts
|
|
4471
|
+
const POINT_TYPES = [
|
|
4472
|
+
"node",
|
|
4473
|
+
"asst",
|
|
4474
|
+
"doc",
|
|
4475
|
+
"pres",
|
|
4476
|
+
"parTrans",
|
|
4477
|
+
"sibTrans"
|
|
4478
|
+
];
|
|
4479
|
+
const CONNECTION_TYPES = [
|
|
4480
|
+
"parOf",
|
|
4481
|
+
"presOf",
|
|
4482
|
+
"presParOf",
|
|
4483
|
+
"unknownRelationship"
|
|
4484
|
+
];
|
|
4485
|
+
/** The MS extension (`dgm:extLst/a:ext`) whose `@relId` names the fallback drawing part. */
|
|
4486
|
+
const DRAWING_EXT_URI = "http://schemas.microsoft.com/office/drawing/2008/diagram";
|
|
4487
|
+
/** One point (`dgm:pt`) of a diagram's data model. */
|
|
4488
|
+
var DiagramPoint = class {
|
|
4489
|
+
pt;
|
|
4490
|
+
part;
|
|
4491
|
+
themeContext;
|
|
4492
|
+
relationships;
|
|
4493
|
+
constructor(pt, part, themeContext, relationships) {
|
|
4494
|
+
this.pt = pt;
|
|
4495
|
+
this.part = part;
|
|
4496
|
+
this.themeContext = themeContext;
|
|
4497
|
+
this.relationships = relationships;
|
|
4498
|
+
}
|
|
4499
|
+
/** This point's id (`@modelId`), which connections reference. */
|
|
4500
|
+
get modelId() {
|
|
4501
|
+
return attr(this.pt, "modelId");
|
|
4502
|
+
}
|
|
4503
|
+
/** What kind of point this is (`@type`); `node` when absent, its schema default. */
|
|
4504
|
+
get type() {
|
|
4505
|
+
const raw = attr(this.pt, "type");
|
|
4506
|
+
return raw !== null && POINT_TYPES.includes(raw) ? raw : "node";
|
|
4507
|
+
}
|
|
4508
|
+
/**
|
|
4509
|
+
* For a transition point, the edge it labels (`@cxnId`), or `null`. The schema's default
|
|
4510
|
+
* is the literal `0`, which means "none" rather than naming a point, so it reads `null`.
|
|
4511
|
+
*/
|
|
4512
|
+
get connectionId() {
|
|
4513
|
+
return idAttr(this.pt, "cxnId");
|
|
4514
|
+
}
|
|
4515
|
+
/**
|
|
4516
|
+
* Whether this point is an unfilled prompt (`dgm:prSet/@phldr`) — a node PowerPoint draws
|
|
4517
|
+
* with a grey placeholder string and treats as empty. Excluded from {@link Diagram.text}:
|
|
4518
|
+
* a layout that stores its prompt in `dgm:t` would otherwise extract as content.
|
|
4519
|
+
*/
|
|
4520
|
+
get isPlaceholder() {
|
|
4521
|
+
const prSet = this.#prSet();
|
|
4522
|
+
return prSet ? boolValue(attr(prSet, "phldr")) === true : false;
|
|
4523
|
+
}
|
|
4524
|
+
/** The prompt string a placeholder point displays (`dgm:prSet/@phldrT`), or `null`. */
|
|
4525
|
+
get placeholderText() {
|
|
4526
|
+
const prSet = this.#prSet();
|
|
4527
|
+
return prSet ? attr(prSet, "phldrT") : null;
|
|
4528
|
+
}
|
|
4529
|
+
/**
|
|
4530
|
+
* This point's text body (`dgm:t`) as a {@link TextFrame}, or `null` when the point
|
|
4531
|
+
* carries none. It is an `a:CT_TextBody` like any other, so `paragraphs`, `runs` and the
|
|
4532
|
+
* `resolved*` getters all apply.
|
|
4533
|
+
*/
|
|
4534
|
+
get textFrame() {
|
|
4535
|
+
const t = firstChild(this.pt, "dgm:t");
|
|
4536
|
+
return t ? new TextFrame(t, this.part, this.themeContext, void 0, this.relationships) : null;
|
|
4537
|
+
}
|
|
4538
|
+
/** This point's text, paragraphs joined by `\n`; `''` when it carries none. */
|
|
4539
|
+
get text() {
|
|
4540
|
+
return this.textFrame?.text ?? "";
|
|
4541
|
+
}
|
|
4542
|
+
/** Escape hatch: the underlying `dgm:pt` element. After mutating it call {@link Diagram.markDirty}. */
|
|
4543
|
+
get element_() {
|
|
4544
|
+
return this.pt;
|
|
4545
|
+
}
|
|
4546
|
+
#prSet() {
|
|
4547
|
+
return firstChild(this.pt, "dgm:prSet");
|
|
4548
|
+
}
|
|
4549
|
+
};
|
|
4550
|
+
/** A SmartArt graphic frame's diagram, backed by its `dgm:dataModel` part. */
|
|
4551
|
+
var Diagram = class {
|
|
4552
|
+
part;
|
|
4553
|
+
relIds;
|
|
4554
|
+
opc;
|
|
4555
|
+
frameRelationships;
|
|
4556
|
+
themeContext;
|
|
4557
|
+
constructor(part, relIds, opc, frameRelationships, themeContext) {
|
|
4558
|
+
this.part = part;
|
|
4559
|
+
this.relIds = relIds;
|
|
4560
|
+
this.opc = opc;
|
|
4561
|
+
this.frameRelationships = frameRelationships;
|
|
4562
|
+
this.themeContext = themeContext;
|
|
4563
|
+
}
|
|
4564
|
+
/** Partname of the diagram data part. */
|
|
4565
|
+
get partName() {
|
|
4566
|
+
return this.part.partName;
|
|
4567
|
+
}
|
|
4568
|
+
/**
|
|
4569
|
+
* Every point (`dgm:ptLst/dgm:pt`) in document order, unfiltered — generated `pres`
|
|
4570
|
+
* points and the `doc` root included. Filter on {@link DiagramPoint.type} for the user's
|
|
4571
|
+
* nodes; {@link text} is the shortcut for the common case.
|
|
4572
|
+
*/
|
|
4573
|
+
get points() {
|
|
4574
|
+
const root = this.#root();
|
|
4575
|
+
const ptLst = root && firstChild(root, "dgm:ptLst");
|
|
4576
|
+
if (!ptLst) return [];
|
|
4577
|
+
const relationships = this.opc.relationshipsFor(this.part.partName);
|
|
4578
|
+
return getElements(ptLst, "dgm:pt").map((pt) => new DiagramPoint(pt, this.part, this.themeContext, relationships));
|
|
4579
|
+
}
|
|
4580
|
+
/** Every edge (`dgm:cxnLst/dgm:cxn`) in document order. */
|
|
4581
|
+
get connections() {
|
|
4582
|
+
const root = this.#root();
|
|
4583
|
+
const cxnLst = root && firstChild(root, "dgm:cxnLst");
|
|
4584
|
+
if (!cxnLst) return [];
|
|
4585
|
+
return getElements(cxnLst, "dgm:cxn").map((cxn) => {
|
|
4586
|
+
const rawType = attr(cxn, "type");
|
|
4587
|
+
return {
|
|
4588
|
+
modelId: attr(cxn, "modelId"),
|
|
4589
|
+
type: rawType !== null && CONNECTION_TYPES.includes(rawType) ? rawType : "parOf",
|
|
4590
|
+
sourceId: attr(cxn, "srcId"),
|
|
4591
|
+
destinationId: attr(cxn, "destId"),
|
|
4592
|
+
sourceOrder: intValue(attr(cxn, "srcOrd")),
|
|
4593
|
+
destinationOrder: intValue(attr(cxn, "destOrd")),
|
|
4594
|
+
parentTransitionId: idAttr(cxn, "parTransId"),
|
|
4595
|
+
siblingTransitionId: idAttr(cxn, "sibTransId"),
|
|
4596
|
+
presentationId: attr(cxn, "presId") || null
|
|
4597
|
+
};
|
|
4598
|
+
});
|
|
4599
|
+
}
|
|
4600
|
+
/**
|
|
4601
|
+
* The diagram's text in document order, blocks joined by `\n` — the counterpart to
|
|
4602
|
+
* `TextFrame.text` for a construct that has no single text body.
|
|
4603
|
+
*
|
|
4604
|
+
* Contributing points are the ones a user can type into: everything except the generated
|
|
4605
|
+
* `pres` points, the `doc` root, and any point flagged as an unfilled placeholder. A
|
|
4606
|
+
* point with no text contributes no blank line. Transition labels (`parTrans`/`sibTrans`)
|
|
4607
|
+
* are included where a layout has them, which is why this is not simply the node list.
|
|
4608
|
+
*/
|
|
4609
|
+
get text() {
|
|
4610
|
+
return this.points.filter((point) => point.type !== "pres" && point.type !== "doc" && !point.isPlaceholder).map((point) => point.text).filter((text) => text.length > 0).join("\n");
|
|
4611
|
+
}
|
|
4612
|
+
/**
|
|
4613
|
+
* The layout preset the diagram is drawn with (the `doc` point's `dgm:prSet/@loTypeId`),
|
|
4614
|
+
* e.g. `urn:microsoft.com/office/officeart/2005/8/layout/hList1`. This is what names the
|
|
4615
|
+
* SmartArt *kind*; {@link layoutPart} is that preset's definition.
|
|
4616
|
+
*/
|
|
4617
|
+
get layoutTypeId() {
|
|
4618
|
+
return this.#docPrSetAttr("loTypeId");
|
|
4619
|
+
}
|
|
4620
|
+
/** The quick-style preset (the `doc` point's `dgm:prSet/@qsTypeId`). */
|
|
4621
|
+
get quickStyleTypeId() {
|
|
4622
|
+
return this.#docPrSetAttr("qsTypeId");
|
|
4623
|
+
}
|
|
4624
|
+
/** The colour preset (the `doc` point's `dgm:prSet/@csTypeId`). */
|
|
4625
|
+
get colorsTypeId() {
|
|
4626
|
+
return this.#docPrSetAttr("csTypeId");
|
|
4627
|
+
}
|
|
4628
|
+
/** The layout definition part (`dgm:relIds/@r:lo`), or `null` when missing from the package. */
|
|
4629
|
+
get layoutPart() {
|
|
4630
|
+
return this.#relPart("r:lo");
|
|
4631
|
+
}
|
|
4632
|
+
/** The quick-style part (`dgm:relIds/@r:qs`), or `null` when missing from the package. */
|
|
4633
|
+
get quickStylePart() {
|
|
4634
|
+
return this.#relPart("r:qs");
|
|
4635
|
+
}
|
|
4636
|
+
/** The colours part (`dgm:relIds/@r:cs`), or `null` when missing from the package. */
|
|
4637
|
+
get colorsPart() {
|
|
4638
|
+
return this.#relPart("r:cs");
|
|
4639
|
+
}
|
|
4640
|
+
/**
|
|
4641
|
+
* The fallback drawing part (`dsp:drawing`) that renders the diagram for a consumer with
|
|
4642
|
+
* no SmartArt layout engine, or `null` when the deck carries none. It is named by an MS
|
|
4643
|
+
* extension on the data model rather than by `dgm:relIds`, so a slide holding two
|
|
4644
|
+
* diagrams still resolves each to its own drawing.
|
|
4645
|
+
*/
|
|
4646
|
+
get drawingPart() {
|
|
4647
|
+
const root = this.#root();
|
|
4648
|
+
const extLst = root && firstChild(root, "dgm:extLst");
|
|
4649
|
+
if (!extLst) return null;
|
|
4650
|
+
for (const ext of getElements(extLst, "a:ext")) {
|
|
4651
|
+
if (attr(ext, "uri") !== DRAWING_EXT_URI) continue;
|
|
4652
|
+
const dataModelExt = firstChildElement(ext);
|
|
4653
|
+
if (!dataModelExt || dataModelExt.localName !== "dataModelExt") continue;
|
|
4654
|
+
return this.#partForRelId(attr(dataModelExt, "relId"));
|
|
4655
|
+
}
|
|
4656
|
+
return null;
|
|
4657
|
+
}
|
|
4658
|
+
/** Escape hatch: the underlying `dgm:dataModel` element. After mutating it call {@link markDirty}, or `save()` writes the original bytes. */
|
|
4659
|
+
get element_() {
|
|
4660
|
+
return this.part.dom.documentElement;
|
|
4661
|
+
}
|
|
4662
|
+
/** Mark the diagram data part dirty so `save()` reserializes it. Call after mutating {@link element_}. */
|
|
4663
|
+
markDirty() {
|
|
4664
|
+
this.part.markDirty();
|
|
4665
|
+
}
|
|
4666
|
+
#root() {
|
|
4667
|
+
return this.part.dom.documentElement;
|
|
4668
|
+
}
|
|
4669
|
+
#docPrSetAttr(name) {
|
|
4670
|
+
const root = this.#root();
|
|
4671
|
+
const ptLst = root && firstChild(root, "dgm:ptLst");
|
|
4672
|
+
if (!ptLst) return null;
|
|
4673
|
+
const doc = getElements(ptLst, "dgm:pt").find((pt) => attr(pt, "type") === "doc");
|
|
4674
|
+
const prSet = doc && firstChild(doc, "dgm:prSet");
|
|
4675
|
+
return prSet ? attr(prSet, name) : null;
|
|
4676
|
+
}
|
|
4677
|
+
#relPart(qname) {
|
|
4678
|
+
return this.#partForRelId(attr(this.relIds, qname));
|
|
4679
|
+
}
|
|
4680
|
+
#partForRelId(relId) {
|
|
4681
|
+
if (!relId) return null;
|
|
4682
|
+
return this.opc.part(this.frameRelationships.resolveTarget(relId)) ?? null;
|
|
4683
|
+
}
|
|
4684
|
+
};
|
|
4685
|
+
/** An `ST_ModelId` attribute whose schema default `0` means "unset" rather than naming a point. */
|
|
4686
|
+
function idAttr(element, name) {
|
|
4687
|
+
const raw = attr(element, name);
|
|
4688
|
+
return raw === null || raw === "" || raw === "0" ? null : raw;
|
|
4689
|
+
}
|
|
4690
|
+
//#endregion
|
|
4408
4691
|
//#region src/read/api/table-edit.ts
|
|
4409
4692
|
/**
|
|
4410
4693
|
* Ordered mutation of a table cell's `a:tcPr`, and the cell-scoped schema facts every such
|
|
@@ -5675,16 +5958,20 @@ var TableCell = class {
|
|
|
5675
5958
|
//#endregion
|
|
5676
5959
|
//#region src/read/api/shapes/graphic-frame.ts
|
|
5677
5960
|
/**
|
|
5678
|
-
* A graphic frame (`p:graphicFrame`) — the host element for a table, a chart,
|
|
5961
|
+
* A graphic frame (`p:graphicFrame`) — the host element for a table, a chart, a chartEx
|
|
5962
|
+
* chart, or a SmartArt diagram.
|
|
5679
5963
|
*
|
|
5680
|
-
* Which one it holds is told by the `a:graphicData/@uri`, so the accessors below each check
|
|
5681
|
-
* URI before wrapping the payload
|
|
5682
|
-
*
|
|
5964
|
+
* Which one it holds is told by the `a:graphicData/@uri`, so the accessors below each check
|
|
5965
|
+
* that URI before wrapping the payload. {@link GraphicFrame.graphicDataUri} reports it raw,
|
|
5966
|
+
* which is the only signal for the frames this library still does not model (OLE, ink):
|
|
5967
|
+
* without it a consumer cannot tell "this frame holds content I cannot reach" from "this
|
|
5968
|
+
* frame holds a chart with nothing in it", since every predicate answers `false` for both.
|
|
5683
5969
|
*/
|
|
5684
5970
|
const A_TABLE_URI = "http://schemas.openxmlformats.org/drawingml/2006/table";
|
|
5685
5971
|
const A_CHART_URI = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
5686
5972
|
const A_CHARTEX_URI = "http://schemas.microsoft.com/office/drawing/2014/chartex";
|
|
5687
|
-
|
|
5973
|
+
const A_DIAGRAM_URI = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
|
|
5974
|
+
/** A graphic frame (`p:graphicFrame`) — host for tables, charts and SmartArt diagrams. */
|
|
5688
5975
|
var GraphicFrame = class extends Shape {
|
|
5689
5976
|
shapeType = "graphicFrame";
|
|
5690
5977
|
xfrm() {
|
|
@@ -5708,6 +5995,22 @@ var GraphicFrame = class extends Shape {
|
|
|
5708
5995
|
get hasChartEx() {
|
|
5709
5996
|
return this.#graphicDataUri() === A_CHARTEX_URI;
|
|
5710
5997
|
}
|
|
5998
|
+
/** Whether this frame hosts a SmartArt diagram (`a:graphicData/@uri` is the diagram URI). */
|
|
5999
|
+
get hasDiagram() {
|
|
6000
|
+
return this.#graphicDataUri() === A_DIAGRAM_URI;
|
|
6001
|
+
}
|
|
6002
|
+
/**
|
|
6003
|
+
* The `a:graphicData/@uri` verbatim — the namespace naming what this frame hosts, or
|
|
6004
|
+
* `null` when the frame carries no `a:graphicData`.
|
|
6005
|
+
*
|
|
6006
|
+
* Every `has*` predicate is a comparison against this, so a frame whose URI matches none
|
|
6007
|
+
* of them is one the read model does not decode (an OLE object, an ink `p:contentPart`).
|
|
6008
|
+
* Reading the URI is what lets a consumer say *which* construct it could not reach
|
|
6009
|
+
* instead of inferring loss from four `false`s.
|
|
6010
|
+
*/
|
|
6011
|
+
get graphicDataUri() {
|
|
6012
|
+
return this.#graphicDataUri();
|
|
6013
|
+
}
|
|
5711
6014
|
/** The hosted table, or `null` when this frame is not a table. */
|
|
5712
6015
|
get table() {
|
|
5713
6016
|
if (!this.hasTable) return null;
|
|
@@ -5742,6 +6045,22 @@ var GraphicFrame = class extends Shape {
|
|
|
5742
6045
|
const part = this.host.opc.part(partName);
|
|
5743
6046
|
return part ? new ChartEx(part) : null;
|
|
5744
6047
|
}
|
|
6048
|
+
/**
|
|
6049
|
+
* The hosted SmartArt diagram, or `null` when this frame is not a diagram or its data
|
|
6050
|
+
* part is missing. The payload child is `dgm:relIds`, which names four parts by
|
|
6051
|
+
* relationship id; the `@r:dm` one is the data model this resolves.
|
|
6052
|
+
*/
|
|
6053
|
+
get diagram() {
|
|
6054
|
+
if (!this.hasDiagram) return null;
|
|
6055
|
+
const graphicData = this.#graphicData();
|
|
6056
|
+
const relIds = graphicData && firstChild(graphicData, "dgm:relIds");
|
|
6057
|
+
if (!relIds) return null;
|
|
6058
|
+
const relId = attr(relIds, "r:dm");
|
|
6059
|
+
if (!relId) return null;
|
|
6060
|
+
const partName = this.host.relationships.resolveTarget(relId);
|
|
6061
|
+
const part = this.host.opc.part(partName);
|
|
6062
|
+
return part ? new Diagram(part, relIds, this.host.opc, this.host.relationships, this.host.themeContext()) : null;
|
|
6063
|
+
}
|
|
5745
6064
|
#graphicData() {
|
|
5746
6065
|
const graphic = firstChild(this.element, "a:graphic");
|
|
5747
6066
|
return graphic ? firstChild(graphic, "a:graphicData") : null;
|
|
@@ -5923,6 +6242,6 @@ function findShapeByIdDeep(shapes, id) {
|
|
|
5923
6242
|
}
|
|
5924
6243
|
}
|
|
5925
6244
|
//#endregion
|
|
5926
|
-
export {
|
|
6245
|
+
export { collectElements as $, readPatternFill as A, zipPathToPartName as At, LST_STYLE_LEVELS as B, getOrAddChild as Bt, Picture as C, SPPR_SP3D_AFTER as Ct, Run as D, relsPartNameFor as Dt, Paragraph as E, relativePartName as Et, resolveMasterColorContext as F, descendantsByTag as Ft, placeholderInheritedRunProps as G, removeAttr as Gt, placeholderInheritedAnchor as H, intValue as Ht, resolveNotesColorContext as I, escapeXmlAttribute as It, slideDefinesColor as J, serializeXml as Jt, placeholderInheritedXfrm as K, removeChildrenByQName as Kt, resolveSlideColorContext as L, firstChild as Lt, readGradientFill as M, boolValue as Mt, resolveColorElement as N, childElements as Nt, TextFrame as O, resolveRelativePartName as Ot, resolveLayoutColorContext as P, createElement as Pt, carriedDecorations as Q, resolveSlideThemeParts as R, firstChildElement as Rt, Connector as S, SPPR_SCENE3D_AFTER as St, Shape as T, partNameToZipPath as Tt, placeholderInheritedColor as U, ownerDocumentOf as Ut, RUN_PROP_NAMES as V, insertInOrder as Vt, placeholderInheritedListStyles as W, parseXml as Wt, cSldName as X, slideDefinesProp as Y, setAttr as Yt, cSldOf as Z, ChartExAxis as _, SHAPE_AFTER_SPPR as _t, isConnector as a, fmtEntry as at, ChartAxis as b, SPPR_FILL_AFTER as bt, isPicture as c, parseClrMap as ct, Table as d, resolveSchemeToken as dt, firstShapeChild as et, TableCell as f, styleRefFill as ft, ChartEx as g, RPR_FILL_AFTER as gt, DiagramPoint as h, FILL_CHOICES as ht, isAutoShape as i, SCHEME_SLOTS as it, readPictureFill as j, attr as jt, spPrXfrmEmu as k, resolveSingleRel as kt, wrapShapeElement as l, parseClrScheme as lt, Diagram as m, substitutePhClr as mt, buildShapes as n, nvPrOf as nt, isGraphicFrame as o, intAttr as ot, TableRow as p, styleRefLine as pt, placeholderOf as q, replaceInParent as qt, findShapeByIdDeep as r, spTreeOf as rt, isGroupShape as s, isA as st, GroupShape as t, nthShapeChild as tt, GraphicFrame as u, resolveColor as ut, ChartExSeries as v, SPPR_AFTER_XFRM as vt, AutoShape as w, partNameExtension as wt, ChartSeries as x, SPPR_LN_AFTER as xt, Chart as y, SPPR_EFFECT_AFTER as yt, applyColorTransforms as z, getElements as zt };
|
|
5927
6246
|
|
|
5928
|
-
//# sourceMappingURL=shapes-
|
|
6247
|
+
//# sourceMappingURL=shapes-Dyw5bxwO.js.map
|