@office-open/pptx 0.6.3 → 0.6.4
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/dist/index.d.mts +88 -103
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +446 -339
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { i as __toCommonJS, n as __exportAll, r as __reExport, t as __esmMin } from "./chunk-090QGkrx.mjs";
|
|
2
|
-
import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PrettifyType, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, buildCorePropertiesXml, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, createPacker, escapeRegex, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, stringContainerObj, uniqueId, uniqueNumericIdCreator, uniqueUuid } from "@office-open/core";
|
|
2
|
+
import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PrettifyType, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, buildCorePropertiesXml, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, createPacker, escapeRegex, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, stringContainerObj, uniqueId, uniqueNumericIdCreator, uniqueUuid, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle } from "@office-open/core";
|
|
3
3
|
import { BevelPresetType, CompoundLine, LineCap, LineJoin, PathShadeType, PenAlignment, PresetDash, PresetGeometry, PresetMaterialType, Stretch, TileFlipMode, buildFill, createBevel, createBlip, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createEffectList as createEffectList$1, createGradientFill, createGradientStop, createGroupTransform2D, createOutline, createOutline as createOutline$1, createScene3D, createScene3D as createScene3D$1, createShape3D, createShape3D as createShape3D$1, createTransform2D, extractBlipFillMedia } from "@office-open/core/drawingml";
|
|
4
4
|
import { ChartCollection, ChartSpace } from "@office-open/core/chart";
|
|
5
5
|
import { DEFAULT_DRAWING_XML, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml } from "@office-open/core/smartart";
|
|
6
|
-
import { attr, attrBool, attrNum, children, findChild, findDeep, textOf, xml } from "@office-open/xml";
|
|
6
|
+
import { attr, attrBool, attrNum, children, colorAttr, findChild, findDeep, textOf, xml } from "@office-open/xml";
|
|
7
7
|
import { toUint8Array } from "undio";
|
|
8
8
|
export * from "@office-open/core/values";
|
|
9
9
|
//#region src/file/drawingml/effects.ts
|
|
@@ -59,7 +59,7 @@ function toReflection(opts) {
|
|
|
59
59
|
if (opts.scaleY !== void 0) result.scaleY = opts.scaleY * 1e3;
|
|
60
60
|
if (opts.skewX !== void 0) result.skewX = opts.skewX * 6e4;
|
|
61
61
|
if (opts.skewY !== void 0) result.skewY = opts.skewY * 6e4;
|
|
62
|
-
if (opts.alignment !== void 0) result.alignment =
|
|
62
|
+
if (opts.alignment !== void 0) result.alignment = xsdRectAlignment.to(opts.alignment);
|
|
63
63
|
if (opts.rotateWithShape === false) result.rotWithShape = 0;
|
|
64
64
|
return result;
|
|
65
65
|
}
|
|
@@ -118,15 +118,15 @@ function createPptxEffectList(options) {
|
|
|
118
118
|
var ReflectionAlignment;
|
|
119
119
|
var init_effects = __esmMin((() => {
|
|
120
120
|
ReflectionAlignment = {
|
|
121
|
-
TOP_LEFT: "
|
|
122
|
-
TOP: "
|
|
123
|
-
TOP_RIGHT: "
|
|
124
|
-
LEFT: "
|
|
125
|
-
CENTER: "
|
|
126
|
-
RIGHT: "
|
|
127
|
-
BOTTOM_LEFT: "
|
|
128
|
-
BOTTOM: "
|
|
129
|
-
BOTTOM_RIGHT: "
|
|
121
|
+
TOP_LEFT: "topLeft",
|
|
122
|
+
TOP: "top",
|
|
123
|
+
TOP_RIGHT: "topRight",
|
|
124
|
+
LEFT: "left",
|
|
125
|
+
CENTER: "center",
|
|
126
|
+
RIGHT: "right",
|
|
127
|
+
BOTTOM_LEFT: "bottomLeft",
|
|
128
|
+
BOTTOM: "bottom",
|
|
129
|
+
BOTTOM_RIGHT: "bottomRight"
|
|
130
130
|
};
|
|
131
131
|
}));
|
|
132
132
|
//#endregion
|
|
@@ -492,7 +492,7 @@ var HyperlinkCollection = class {
|
|
|
492
492
|
tooltip
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
|
-
get
|
|
495
|
+
get array() {
|
|
496
496
|
return [...this.map.values()];
|
|
497
497
|
}
|
|
498
498
|
};
|
|
@@ -526,7 +526,7 @@ var Media = class {
|
|
|
526
526
|
addMedia(key, mediaData) {
|
|
527
527
|
this.map.set(key, mediaData);
|
|
528
528
|
}
|
|
529
|
-
get
|
|
529
|
+
get array() {
|
|
530
530
|
return [...this.map.values()];
|
|
531
531
|
}
|
|
532
532
|
};
|
|
@@ -617,10 +617,10 @@ var EndParagraphRunProperties = class extends BuilderElement {
|
|
|
617
617
|
//#region src/file/shape/paragraph/paragraph-properties.ts
|
|
618
618
|
init_xml_components();
|
|
619
619
|
const TextAlignment = {
|
|
620
|
-
LEFT: "
|
|
621
|
-
CENTER: "
|
|
622
|
-
RIGHT: "
|
|
623
|
-
JUSTIFY: "
|
|
620
|
+
LEFT: "left",
|
|
621
|
+
CENTER: "center",
|
|
622
|
+
RIGHT: "right",
|
|
623
|
+
JUSTIFY: "justify"
|
|
624
624
|
};
|
|
625
625
|
function buildBulletChildren(options) {
|
|
626
626
|
const children = [];
|
|
@@ -651,7 +651,7 @@ function buildBulletChildren(options) {
|
|
|
651
651
|
function buildParagraphProperties(options) {
|
|
652
652
|
const children = [];
|
|
653
653
|
const attrs = {};
|
|
654
|
-
if (options.alignment) attrs.algn =
|
|
654
|
+
if (options.alignment) attrs.algn = xsdTextAlign.to(options.alignment);
|
|
655
655
|
if (options.indentLevel !== void 0) attrs.lvl = options.indentLevel;
|
|
656
656
|
if (options.marginIndent !== void 0) attrs.marL = options.marginIndent;
|
|
657
657
|
if (options.marginRight !== void 0) attrs.marR = options.marginRight;
|
|
@@ -686,8 +686,8 @@ init_fill();
|
|
|
686
686
|
init_xml_components();
|
|
687
687
|
let nextHyperlinkId = 1;
|
|
688
688
|
const UnderlineStyle = {
|
|
689
|
-
SINGLE: "
|
|
690
|
-
DOUBLE: "
|
|
689
|
+
SINGLE: "single",
|
|
690
|
+
DOUBLE: "double",
|
|
691
691
|
NONE: "none"
|
|
692
692
|
};
|
|
693
693
|
const StrikeStyle = {
|
|
@@ -711,11 +711,11 @@ function buildRunProperties(options, hyperlinkKey, fillObject, effectListObject,
|
|
|
711
711
|
if (options.fontSize) attrs.sz = options.fontSize * 100;
|
|
712
712
|
if (options.bold !== void 0) attrs.b = options.bold;
|
|
713
713
|
if (options.italic !== void 0) attrs.i = options.italic;
|
|
714
|
-
if (options.underline) attrs.u =
|
|
714
|
+
if (options.underline) attrs.u = xsdUnderlineStyle.to(options.underline);
|
|
715
715
|
if (options.lang) attrs.lang = options.lang;
|
|
716
|
-
if (options.strike) attrs.strike =
|
|
716
|
+
if (options.strike) attrs.strike = xsdStrikeStyle.to(options.strike);
|
|
717
717
|
if (options.baseline !== void 0) attrs.baseline = options.baseline;
|
|
718
|
-
if (options.capitalization) attrs.cap =
|
|
718
|
+
if (options.capitalization) attrs.cap = xsdTextCaps.to(options.capitalization);
|
|
719
719
|
if (options.spacing !== void 0) attrs.spc = options.spacing;
|
|
720
720
|
if (options.noProof !== void 0) attrs.noProof = options.noProof;
|
|
721
721
|
if (options.dirty !== void 0) attrs.dirty = options.dirty;
|
|
@@ -754,7 +754,7 @@ var RunProperties = class extends XmlComponent {
|
|
|
754
754
|
let hyperlinkKey;
|
|
755
755
|
if (opts.hyperlink) {
|
|
756
756
|
hyperlinkKey = `hlink_${nextHyperlinkId++}`;
|
|
757
|
-
context.fileData?.
|
|
757
|
+
context.fileData?.hyperlinks?.addHyperlink(hyperlinkKey, opts.hyperlink.url, opts.hyperlink.tooltip);
|
|
758
758
|
}
|
|
759
759
|
let fillObj;
|
|
760
760
|
if (opts.fill !== void 0) fillObj = buildFill(opts.fill).prepForXml(context) ?? void 0;
|
|
@@ -872,9 +872,9 @@ var TableCellProperties = class extends BaseXmlComponent {
|
|
|
872
872
|
//#region src/file/table/table-cell.ts
|
|
873
873
|
init_xml_components();
|
|
874
874
|
const VerticalAlignment = {
|
|
875
|
-
TOP: "
|
|
876
|
-
CENTER: "
|
|
877
|
-
BOTTOM: "
|
|
875
|
+
TOP: "top",
|
|
876
|
+
CENTER: "center",
|
|
877
|
+
BOTTOM: "bottom"
|
|
878
878
|
};
|
|
879
879
|
/**
|
|
880
880
|
* a:tc — Table cell with text body and properties.
|
|
@@ -916,7 +916,7 @@ var TableCell = class extends BaseXmlComponent {
|
|
|
916
916
|
const tcPrObj = new TableCellProperties({
|
|
917
917
|
fill: opts.fill,
|
|
918
918
|
borders: opts.borders,
|
|
919
|
-
verticalAlign: opts.verticalAlign ?
|
|
919
|
+
verticalAlign: opts.verticalAlign ? xsdTextAnchor.to(opts.verticalAlign) : void 0
|
|
920
920
|
}).prepForXml(context);
|
|
921
921
|
if (tcPrObj) children.push(tcPrObj);
|
|
922
922
|
return { "a:tc": children };
|
|
@@ -936,7 +936,7 @@ function buildBodyPr(options) {
|
|
|
936
936
|
const bodyPrContent = [];
|
|
937
937
|
const attrs = {};
|
|
938
938
|
if (options.vertical) attrs.vert = options.vertical;
|
|
939
|
-
if (options.anchor) attrs.anchor =
|
|
939
|
+
if (options.anchor) attrs.anchor = xsdTextAnchor.to(options.anchor);
|
|
940
940
|
if (options.wrap) attrs.wrap = options.wrap;
|
|
941
941
|
if (options.margins?.top !== void 0) attrs.tIns = options.margins.top;
|
|
942
942
|
if (options.margins?.bottom !== void 0) attrs.bIns = options.margins.bottom;
|
|
@@ -962,11 +962,14 @@ var TextBody = class extends XmlComponent {
|
|
|
962
962
|
const children = [];
|
|
963
963
|
children.push(buildBodyPr(this.options));
|
|
964
964
|
children.push({ "a:lstStyle": {} });
|
|
965
|
-
if (this.options.
|
|
965
|
+
if (this.options.children) for (const p of this.options.children) {
|
|
966
966
|
const obj = (typeof p === "string" ? new Paragraph({ children: [new TextRun({ text: p })] }) : p instanceof Paragraph ? p : new Paragraph(p)).prepForXml(context);
|
|
967
967
|
if (obj) children.push(obj);
|
|
968
968
|
}
|
|
969
|
-
else {
|
|
969
|
+
else if (this.options.text !== void 0) {
|
|
970
|
+
const obj = new Paragraph({ children: [new TextRun({ text: this.options.text })] }).prepForXml(context);
|
|
971
|
+
if (obj) children.push(obj);
|
|
972
|
+
} else {
|
|
970
973
|
const obj = new Paragraph().prepForXml(context);
|
|
971
974
|
if (obj) children.push(obj);
|
|
972
975
|
}
|
|
@@ -1154,7 +1157,7 @@ var NotesBodyPlaceholder = class extends XmlComponent {
|
|
|
1154
1157
|
})]
|
|
1155
1158
|
})]
|
|
1156
1159
|
}));
|
|
1157
|
-
const textBodyOptions = text ? {
|
|
1160
|
+
const textBodyOptions = text ? { children: [new Paragraph({ children: [new TextRun({ text })] })] } : void 0;
|
|
1158
1161
|
this.root.push(new TextBody(textBodyOptions));
|
|
1159
1162
|
}
|
|
1160
1163
|
};
|
|
@@ -1172,16 +1175,15 @@ function buildPresPropsXml(showOptions) {
|
|
|
1172
1175
|
}
|
|
1173
1176
|
var PresentationProperties = class PresentationProperties extends ImportedXmlComponent {
|
|
1174
1177
|
static cache = /* @__PURE__ */ new Map();
|
|
1178
|
+
key;
|
|
1175
1179
|
constructor(showOptions) {
|
|
1176
1180
|
super("p:presentationPr");
|
|
1177
|
-
|
|
1178
|
-
if (!PresentationProperties.cache.has(key)) PresentationProperties.cache.set(key, ImportedXmlComponent.fromXmlString(buildPresPropsXml(showOptions)));
|
|
1181
|
+
this.key = showOptions ? JSON.stringify(showOptions) : "";
|
|
1182
|
+
if (!PresentationProperties.cache.has(this.key)) PresentationProperties.cache.set(this.key, ImportedXmlComponent.fromXmlString(buildPresPropsXml(showOptions)));
|
|
1179
1183
|
}
|
|
1180
1184
|
prepForXml() {
|
|
1181
|
-
|
|
1182
|
-
return PresentationProperties.cache.get(key).prepForXml({ stack: [] });
|
|
1185
|
+
return PresentationProperties.cache.get(this.key).prepForXml({ stack: [] });
|
|
1183
1186
|
}
|
|
1184
|
-
showOptions;
|
|
1185
1187
|
};
|
|
1186
1188
|
//#endregion
|
|
1187
1189
|
//#region src/file/presentation/presentation.ts
|
|
@@ -1287,12 +1289,9 @@ var PresentationWrapper = class {
|
|
|
1287
1289
|
this.presentation = new Presentation(options);
|
|
1288
1290
|
this.relationships = new Relationships();
|
|
1289
1291
|
}
|
|
1290
|
-
get
|
|
1292
|
+
get view() {
|
|
1291
1293
|
return this.presentation;
|
|
1292
1294
|
}
|
|
1293
|
-
get Relationships() {
|
|
1294
|
-
return this.relationships;
|
|
1295
|
-
}
|
|
1296
1295
|
};
|
|
1297
1296
|
//#endregion
|
|
1298
1297
|
//#region src/file/drawingml/transform-2d.ts
|
|
@@ -1368,15 +1367,12 @@ var ChartFrame = class extends XmlComponent {
|
|
|
1368
1367
|
}
|
|
1369
1368
|
prepForXml(context) {
|
|
1370
1369
|
const file = context.fileData;
|
|
1371
|
-
if (file?.
|
|
1370
|
+
if (file?.charts) file.charts.addChart(this.chartKey, {
|
|
1372
1371
|
chartSpace: new ChartSpace(this.chartOptions),
|
|
1373
1372
|
key: this.chartKey
|
|
1374
1373
|
});
|
|
1375
1374
|
return super.prepForXml(context);
|
|
1376
1375
|
}
|
|
1377
|
-
get ChartKey() {
|
|
1378
|
-
return this.chartKey;
|
|
1379
|
-
}
|
|
1380
1376
|
};
|
|
1381
1377
|
var GraphicFrameNonVisual$2 = class extends XmlComponent {
|
|
1382
1378
|
constructor(id) {
|
|
@@ -1479,13 +1475,13 @@ function buildMediaData(type, fileName, width, height, data) {
|
|
|
1479
1475
|
*/
|
|
1480
1476
|
var MediaFrameBase = class extends XmlComponent {
|
|
1481
1477
|
shapeId;
|
|
1482
|
-
|
|
1478
|
+
animation;
|
|
1483
1479
|
mediaData;
|
|
1484
1480
|
posterData;
|
|
1485
1481
|
constructor(options, id, mediaFileName, params) {
|
|
1486
1482
|
super("p:pic");
|
|
1487
1483
|
this.shapeId = id;
|
|
1488
|
-
this.
|
|
1484
|
+
this.animation = options.animation;
|
|
1489
1485
|
const name = options.name ?? `Media ${id}`;
|
|
1490
1486
|
const w = options.width ?? 0;
|
|
1491
1487
|
const h = options.height ?? 0;
|
|
@@ -1576,16 +1572,10 @@ var MediaFrameBase = class extends XmlComponent {
|
|
|
1576
1572
|
children: [new Transform2D({ ...emuPosition(options) }), new PresetGeometry({ preset: "rect" })]
|
|
1577
1573
|
}));
|
|
1578
1574
|
}
|
|
1579
|
-
get ShapeId() {
|
|
1580
|
-
return this.shapeId;
|
|
1581
|
-
}
|
|
1582
|
-
get Animation() {
|
|
1583
|
-
return this.animationOptions;
|
|
1584
|
-
}
|
|
1585
1575
|
prepForXml(context) {
|
|
1586
1576
|
const file = context.fileData;
|
|
1587
|
-
if (this.posterData) file?.
|
|
1588
|
-
file?.
|
|
1577
|
+
if (this.posterData) file?.media.addImage(this.posterData.fileName, this.posterData);
|
|
1578
|
+
file?.media.addMedia(this.mediaData.fileName, this.mediaData);
|
|
1589
1579
|
return super.prepForXml(context);
|
|
1590
1580
|
}
|
|
1591
1581
|
};
|
|
@@ -1813,7 +1803,7 @@ var Picture = class Picture extends XmlComponent {
|
|
|
1813
1803
|
}));
|
|
1814
1804
|
}
|
|
1815
1805
|
prepForXml(context) {
|
|
1816
|
-
context.fileData?.
|
|
1806
|
+
context.fileData?.media.addImage(this.imageData.fileName, this.imageData);
|
|
1817
1807
|
return super.prepForXml(context);
|
|
1818
1808
|
}
|
|
1819
1809
|
};
|
|
@@ -1890,28 +1880,28 @@ var NonVisualShapeProperties = class extends EmptyElement {
|
|
|
1890
1880
|
//#endregion
|
|
1891
1881
|
//#region src/file/drawingml/outline.ts
|
|
1892
1882
|
const DASH_STYLE_MAP = {
|
|
1893
|
-
solid: "
|
|
1894
|
-
dash: "
|
|
1895
|
-
dashDot: "
|
|
1896
|
-
lgDash: "
|
|
1897
|
-
sysDot: "
|
|
1898
|
-
sysDash: "
|
|
1883
|
+
solid: "solid",
|
|
1884
|
+
dash: "dash",
|
|
1885
|
+
dashDot: "dashDot",
|
|
1886
|
+
lgDash: "lgDash",
|
|
1887
|
+
sysDot: "sysDot",
|
|
1888
|
+
sysDash: "sysDash"
|
|
1899
1889
|
};
|
|
1900
1890
|
const ARROWHEAD_MAP = {
|
|
1901
|
-
triangle: "
|
|
1902
|
-
stealth: "
|
|
1903
|
-
diamond: "
|
|
1904
|
-
oval: "
|
|
1905
|
-
open: "
|
|
1891
|
+
triangle: "triangle",
|
|
1892
|
+
stealth: "stealth",
|
|
1893
|
+
diamond: "diamond",
|
|
1894
|
+
oval: "oval",
|
|
1895
|
+
open: "arrow"
|
|
1906
1896
|
};
|
|
1907
1897
|
const ARROWHEAD_SIZE_MAP = {
|
|
1908
|
-
sm: "
|
|
1909
|
-
med: "
|
|
1910
|
-
lg: "
|
|
1898
|
+
sm: "small",
|
|
1899
|
+
med: "medium",
|
|
1900
|
+
lg: "large"
|
|
1911
1901
|
};
|
|
1912
1902
|
function toCoreLineEnd(type, width, length) {
|
|
1913
1903
|
return {
|
|
1914
|
-
type: ARROWHEAD_MAP[type] ?? "
|
|
1904
|
+
type: ARROWHEAD_MAP[type] ?? "triangle",
|
|
1915
1905
|
...width ? { width: ARROWHEAD_SIZE_MAP[width] } : {},
|
|
1916
1906
|
...length ? { length: ARROWHEAD_SIZE_MAP[length] } : {}
|
|
1917
1907
|
};
|
|
@@ -1925,7 +1915,7 @@ const createOutlineCompat = (options = {}, arrowheads) => createOutline$1({
|
|
|
1925
1915
|
type: "solidFill",
|
|
1926
1916
|
color: { value: options.color.replace("#", "") }
|
|
1927
1917
|
} : { type: "noFill" },
|
|
1928
|
-
...options.dashStyle && { dash: DASH_STYLE_MAP[options.dashStyle] ?? "
|
|
1918
|
+
...options.dashStyle && { dash: DASH_STYLE_MAP[options.dashStyle] ?? "solid" },
|
|
1929
1919
|
...arrowheads?.endType ? { headEnd: toCoreLineEnd(arrowheads.endType, arrowheads.width, arrowheads.length) } : {},
|
|
1930
1920
|
...arrowheads?.beginType ? { tailEnd: toCoreLineEnd(arrowheads.beginType, arrowheads.width, arrowheads.length) } : {}
|
|
1931
1921
|
});
|
|
@@ -2032,9 +2022,6 @@ var LineShape = class LineShape extends XmlComponent {
|
|
|
2032
2022
|
]
|
|
2033
2023
|
}));
|
|
2034
2024
|
}
|
|
2035
|
-
get ShapeId() {
|
|
2036
|
-
return this.shapeId;
|
|
2037
|
-
}
|
|
2038
2025
|
};
|
|
2039
2026
|
/**
|
|
2040
2027
|
* p:cxnSp — A connector shape on a slide (line with optional arrowheads).
|
|
@@ -2127,9 +2114,6 @@ var ConnectorShape = class ConnectorShape extends XmlComponent {
|
|
|
2127
2114
|
children: spPrChildren
|
|
2128
2115
|
}));
|
|
2129
2116
|
}
|
|
2130
|
-
get ShapeId() {
|
|
2131
|
-
return this.shapeId;
|
|
2132
|
-
}
|
|
2133
2117
|
};
|
|
2134
2118
|
//#endregion
|
|
2135
2119
|
//#region src/file/drawingml/shape-properties.ts
|
|
@@ -2156,7 +2140,7 @@ var ShapeProperties = class extends BaseXmlComponent {
|
|
|
2156
2140
|
const geomObj = new PresetGeometry({ preset: opts.geometry ?? "rect" }).prepForXml(context);
|
|
2157
2141
|
if (geomObj) children.push(geomObj);
|
|
2158
2142
|
const media = opts.fill ? extractBlipFillMedia(opts.fill) : void 0;
|
|
2159
|
-
if (media) context.fileData?.
|
|
2143
|
+
if (media) context.fileData?.media.addImage(media.fileName, {
|
|
2160
2144
|
data: media.data,
|
|
2161
2145
|
fileName: media.fileName,
|
|
2162
2146
|
type: media.type,
|
|
@@ -2226,24 +2210,18 @@ function buildPlaceholder(type, index) {
|
|
|
2226
2210
|
var Shape = class Shape extends XmlComponent {
|
|
2227
2211
|
static nextId = 2;
|
|
2228
2212
|
shapeId;
|
|
2229
|
-
|
|
2213
|
+
animation;
|
|
2230
2214
|
options;
|
|
2231
2215
|
constructor(options = {}) {
|
|
2232
2216
|
super("p:sp");
|
|
2233
2217
|
const id = options.id ?? Shape.nextId++;
|
|
2234
2218
|
this.shapeId = id;
|
|
2235
|
-
this.
|
|
2219
|
+
this.animation = options.animation;
|
|
2236
2220
|
this.options = {
|
|
2237
2221
|
...options,
|
|
2238
2222
|
id
|
|
2239
2223
|
};
|
|
2240
2224
|
}
|
|
2241
|
-
get ShapeId() {
|
|
2242
|
-
return this.shapeId;
|
|
2243
|
-
}
|
|
2244
|
-
get Animation() {
|
|
2245
|
-
return this.animationOptions;
|
|
2246
|
-
}
|
|
2247
2225
|
prepForXml(context) {
|
|
2248
2226
|
const opts = this.options;
|
|
2249
2227
|
const id = this.shapeId;
|
|
@@ -2269,16 +2247,7 @@ var Shape = class Shape extends XmlComponent {
|
|
|
2269
2247
|
rotation: opts.rotation
|
|
2270
2248
|
}).prepForXml(context);
|
|
2271
2249
|
if (spPrObj) children.push(spPrObj);
|
|
2272
|
-
const txBodyObj = new TextBody({
|
|
2273
|
-
paragraphs: opts.paragraphs ?? (opts.text ? [new Paragraph({ text: opts.text })] : void 0),
|
|
2274
|
-
vertical: opts.textVertical,
|
|
2275
|
-
anchor: opts.textAnchor,
|
|
2276
|
-
autoFit: opts.textAutoFit,
|
|
2277
|
-
wrap: opts.textWrap,
|
|
2278
|
-
margins: opts.textMargins,
|
|
2279
|
-
columns: opts.textColumns,
|
|
2280
|
-
columnSpacing: opts.textColumnSpacing
|
|
2281
|
-
}).prepForXml(context);
|
|
2250
|
+
const txBodyObj = new TextBody(opts.textBody ?? {}).prepForXml(context);
|
|
2282
2251
|
if (txBodyObj) children.push(txBodyObj);
|
|
2283
2252
|
return { "p:sp": children };
|
|
2284
2253
|
}
|
|
@@ -2311,7 +2280,7 @@ var SmartArtFrame = class extends XmlComponent {
|
|
|
2311
2280
|
}
|
|
2312
2281
|
prepForXml(context) {
|
|
2313
2282
|
const file = context.fileData;
|
|
2314
|
-
if (file?.
|
|
2283
|
+
if (file?.smartArts) file.smartArts.addSmartArt(this.smartArtKey, {
|
|
2315
2284
|
key: this.smartArtKey,
|
|
2316
2285
|
dataModel: this.dataModel,
|
|
2317
2286
|
layout: this.layoutId,
|
|
@@ -2909,8 +2878,8 @@ function buildChildrenXml(children) {
|
|
|
2909
2878
|
}
|
|
2910
2879
|
return result;
|
|
2911
2880
|
}
|
|
2912
|
-
function buildSlideMasterXml(layoutCount,
|
|
2913
|
-
const hfXml =
|
|
2881
|
+
function buildSlideMasterXml(layoutCount, _headerFooter, masterOptions, slideWidth = SW_REF, masterIndex = 0) {
|
|
2882
|
+
const hfXml = `<p:hf dt="0" hdr="0" ftr="0" sldNum="0"/>`;
|
|
2914
2883
|
const ph = masterOptions?.placeholders ?? {};
|
|
2915
2884
|
const layoutIdBase = 2147483648 + masterIndex * 12 + 1;
|
|
2916
2885
|
const layoutIdEntries = [];
|
|
@@ -2945,7 +2914,7 @@ var DefaultSlideMaster = class DefaultSlideMaster extends ImportedXmlComponent {
|
|
|
2945
2914
|
cacheKey;
|
|
2946
2915
|
constructor(layoutCount = 1, headerFooter, masterOptions, slideWidth = SW_REF, masterIndex = 0) {
|
|
2947
2916
|
super("p:sldMaster");
|
|
2948
|
-
this.cacheKey = `${layoutCount}:${
|
|
2917
|
+
this.cacheKey = `${layoutCount}:${masterOptions ? JSON.stringify(masterOptions) : ""}:${slideWidth}:${masterIndex}`;
|
|
2949
2918
|
if (!DefaultSlideMaster.cache.has(this.cacheKey)) DefaultSlideMaster.cache.set(this.cacheKey, ImportedXmlComponent.fromXmlString(buildSlideMasterXml(layoutCount, headerFooter, masterOptions, slideWidth, masterIndex)));
|
|
2950
2919
|
}
|
|
2951
2920
|
prepForXml() {
|
|
@@ -4076,14 +4045,14 @@ var Transition = class extends BaseXmlComponent {
|
|
|
4076
4045
|
//#region src/file/slide/slide.ts
|
|
4077
4046
|
init_xml_components();
|
|
4078
4047
|
function isAnimatable(child) {
|
|
4079
|
-
return "
|
|
4048
|
+
return "shapeId" in child && "animation" in child;
|
|
4080
4049
|
}
|
|
4081
4050
|
function collectAnimations(children) {
|
|
4082
4051
|
const entries = [];
|
|
4083
4052
|
for (const child of children) if (isAnimatable(child)) {
|
|
4084
|
-
const anim = child.
|
|
4053
|
+
const anim = child.animation;
|
|
4085
4054
|
if (anim) entries.push({
|
|
4086
|
-
spid: child.
|
|
4055
|
+
spid: child.shapeId,
|
|
4087
4056
|
options: anim
|
|
4088
4057
|
});
|
|
4089
4058
|
}
|
|
@@ -4336,27 +4305,27 @@ var File = class {
|
|
|
4336
4305
|
slideWidthEmus;
|
|
4337
4306
|
slideHeightEmus;
|
|
4338
4307
|
masterDefs;
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4308
|
+
_coreProperties;
|
|
4309
|
+
_appProperties;
|
|
4310
|
+
_contentTypes;
|
|
4311
|
+
_media;
|
|
4312
|
+
_charts;
|
|
4313
|
+
_smartArts;
|
|
4314
|
+
_hyperlinks;
|
|
4315
|
+
_presentationWrapper;
|
|
4316
|
+
_tableStyles;
|
|
4317
|
+
_presProps;
|
|
4318
|
+
_viewProps;
|
|
4319
|
+
_notesMasterRels;
|
|
4351
4320
|
masterMap;
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4321
|
+
_allLayouts;
|
|
4322
|
+
_allLayoutRels;
|
|
4323
|
+
_slides;
|
|
4324
|
+
_slideWrappers;
|
|
4325
|
+
_notesSlides;
|
|
4326
|
+
_commentAuthorList;
|
|
4327
|
+
_slideCommentLists;
|
|
4328
|
+
_fileRels;
|
|
4360
4329
|
constructor(options) {
|
|
4361
4330
|
this.slideOptions = options.slides ?? [];
|
|
4362
4331
|
this.corePropsOptions = options;
|
|
@@ -4444,8 +4413,8 @@ var File = class {
|
|
|
4444
4413
|
});
|
|
4445
4414
|
}
|
|
4446
4415
|
this.masterMap = masters;
|
|
4447
|
-
this.
|
|
4448
|
-
this.
|
|
4416
|
+
this._allLayouts = masters.flatMap((m) => m.layouts);
|
|
4417
|
+
this._allLayoutRels = masters.flatMap((m) => m.layoutRels);
|
|
4449
4418
|
return this.masterMap;
|
|
4450
4419
|
}
|
|
4451
4420
|
findLayoutForSlide(slideIndex) {
|
|
@@ -4455,30 +4424,30 @@ var File = class {
|
|
|
4455
4424
|
const layoutKey = opts.layout ?? "blank";
|
|
4456
4425
|
return master.layouts.find((l) => l.key === layoutKey) ?? master.layouts[0];
|
|
4457
4426
|
}
|
|
4458
|
-
get
|
|
4459
|
-
return this.
|
|
4427
|
+
get coreProperties() {
|
|
4428
|
+
return this._coreProperties ??= new CoreProperties(this.corePropsOptions);
|
|
4460
4429
|
}
|
|
4461
|
-
get
|
|
4462
|
-
return this.
|
|
4430
|
+
get appProperties() {
|
|
4431
|
+
return this._appProperties ??= new AppProperties();
|
|
4463
4432
|
}
|
|
4464
|
-
get
|
|
4465
|
-
if (!this.
|
|
4466
|
-
this.
|
|
4433
|
+
get contentTypes() {
|
|
4434
|
+
if (!this._contentTypes) {
|
|
4435
|
+
this._contentTypes = new ContentTypes();
|
|
4467
4436
|
let hasComments = false;
|
|
4468
4437
|
for (let i = 0; i < this.slideOptions.length; i++) {
|
|
4469
|
-
this.
|
|
4470
|
-
if (this.slideOptions[i].notes) this.
|
|
4438
|
+
this._contentTypes.addSlide(i + 1);
|
|
4439
|
+
if (this.slideOptions[i].notes) this._contentTypes.addNotesSlide(i + 1);
|
|
4471
4440
|
if (this.slideOptions[i].comments && this.slideOptions[i].comments.length > 0) {
|
|
4472
|
-
this.
|
|
4441
|
+
this._contentTypes.addComments(i + 1);
|
|
4473
4442
|
hasComments = true;
|
|
4474
4443
|
}
|
|
4475
4444
|
}
|
|
4476
|
-
if (hasComments) this.
|
|
4445
|
+
if (hasComments) this._contentTypes.addCommentAuthors();
|
|
4477
4446
|
}
|
|
4478
|
-
return this.
|
|
4447
|
+
return this._contentTypes;
|
|
4479
4448
|
}
|
|
4480
|
-
get
|
|
4481
|
-
if (!this.
|
|
4449
|
+
get fileRelationships() {
|
|
4450
|
+
if (!this._fileRels) this._fileRels = buildRelationships([
|
|
4482
4451
|
{
|
|
4483
4452
|
id: 1,
|
|
4484
4453
|
type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
@@ -4495,30 +4464,30 @@ var File = class {
|
|
|
4495
4464
|
target: "docProps/app.xml"
|
|
4496
4465
|
}
|
|
4497
4466
|
]);
|
|
4498
|
-
return this.
|
|
4467
|
+
return this._fileRels;
|
|
4499
4468
|
}
|
|
4500
|
-
get
|
|
4501
|
-
return this.
|
|
4469
|
+
get media() {
|
|
4470
|
+
return this._media ??= new Media();
|
|
4502
4471
|
}
|
|
4503
|
-
get
|
|
4504
|
-
return this.
|
|
4472
|
+
get charts() {
|
|
4473
|
+
return this._charts ??= new ChartCollection();
|
|
4505
4474
|
}
|
|
4506
|
-
get
|
|
4507
|
-
return this.
|
|
4475
|
+
get smartArts() {
|
|
4476
|
+
return this._smartArts ??= new SmartArtCollection();
|
|
4508
4477
|
}
|
|
4509
|
-
get
|
|
4510
|
-
return this.
|
|
4478
|
+
get hyperlinks() {
|
|
4479
|
+
return this._hyperlinks ??= new HyperlinkCollection();
|
|
4511
4480
|
}
|
|
4512
|
-
get
|
|
4513
|
-
if (!this.
|
|
4481
|
+
get presentationWrapper() {
|
|
4482
|
+
if (!this._presentationWrapper) {
|
|
4514
4483
|
const masters = this.getMasterMap();
|
|
4515
|
-
this.
|
|
4484
|
+
this._presentationWrapper = new PresentationWrapper({
|
|
4516
4485
|
slideWidth: this.slideWidthEmus,
|
|
4517
4486
|
slideHeight: this.slideHeightEmus,
|
|
4518
4487
|
slideIds: this.slideOptions.map((_, i) => 256 + i),
|
|
4519
4488
|
masterCount: masters.length
|
|
4520
4489
|
});
|
|
4521
|
-
const presRels = this.
|
|
4490
|
+
const presRels = this._presentationWrapper.relationships;
|
|
4522
4491
|
let rid = 1;
|
|
4523
4492
|
for (let mi = 0; mi < masters.length; mi++) presRels.addRelationship(rid++, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster", `slideMasters/slideMaster${mi + 1}.xml`);
|
|
4524
4493
|
for (let i = 0; i < this.slideOptions.length; i++) presRels.addRelationship(rid++, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide", `slides/slide${i + 1}.xml`);
|
|
@@ -4527,49 +4496,49 @@ var File = class {
|
|
|
4527
4496
|
for (let mi = 0; mi < masters.length; mi++) presRels.addRelationship(rid++, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", `theme/theme${mi + 1}.xml`);
|
|
4528
4497
|
presRels.addRelationship(rid, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles", "tableStyles.xml");
|
|
4529
4498
|
}
|
|
4530
|
-
return this.
|
|
4499
|
+
return this._presentationWrapper;
|
|
4531
4500
|
}
|
|
4532
|
-
get
|
|
4501
|
+
get themes() {
|
|
4533
4502
|
return this.getMasterMap().map((m) => m.theme);
|
|
4534
4503
|
}
|
|
4535
|
-
get
|
|
4536
|
-
return this.
|
|
4504
|
+
get tableStyles() {
|
|
4505
|
+
return this._tableStyles ??= new TableStyles();
|
|
4537
4506
|
}
|
|
4538
|
-
get
|
|
4539
|
-
return this.
|
|
4507
|
+
get presProps() {
|
|
4508
|
+
return this._presProps ??= new PresentationProperties(this.showOptions);
|
|
4540
4509
|
}
|
|
4541
|
-
get
|
|
4542
|
-
return this.
|
|
4510
|
+
get viewProps() {
|
|
4511
|
+
return this._viewProps ??= new ViewProperties();
|
|
4543
4512
|
}
|
|
4544
|
-
get
|
|
4513
|
+
get slideMasters() {
|
|
4545
4514
|
return this.getMasterMap().map((m) => m.master);
|
|
4546
4515
|
}
|
|
4547
|
-
get
|
|
4516
|
+
get slideMasterRelsArray() {
|
|
4548
4517
|
return this.getMasterMap().map((m) => m.masterRels);
|
|
4549
4518
|
}
|
|
4550
|
-
get
|
|
4519
|
+
get allLayouts() {
|
|
4551
4520
|
this.getMasterMap();
|
|
4552
|
-
return this.
|
|
4521
|
+
return this._allLayouts;
|
|
4553
4522
|
}
|
|
4554
|
-
get
|
|
4523
|
+
get allLayoutRelsArray() {
|
|
4555
4524
|
this.getMasterMap();
|
|
4556
|
-
return this.
|
|
4525
|
+
return this._allLayoutRels;
|
|
4557
4526
|
}
|
|
4558
|
-
get
|
|
4559
|
-
if (!this.
|
|
4560
|
-
this.
|
|
4561
|
-
for (const s of this.slideOptions) this.
|
|
4527
|
+
get slides() {
|
|
4528
|
+
if (!this._slides) {
|
|
4529
|
+
this._slides = [];
|
|
4530
|
+
for (const s of this.slideOptions) this._slides.push(new Slide(s.children ?? [], s.background ? new Background(s.background) : void 0, s.transition, s.headerFooter));
|
|
4562
4531
|
}
|
|
4563
|
-
return this.
|
|
4532
|
+
return this._slides;
|
|
4564
4533
|
}
|
|
4565
|
-
get
|
|
4566
|
-
if (!this.
|
|
4567
|
-
this.
|
|
4534
|
+
get slideWrappers() {
|
|
4535
|
+
if (!this._slideWrappers) {
|
|
4536
|
+
this._slideWrappers = [];
|
|
4568
4537
|
for (let i = 0; i < this.slideOptions.length; i++) {
|
|
4569
4538
|
const layout = this.findLayoutForSlide(i);
|
|
4570
|
-
this.
|
|
4571
|
-
|
|
4572
|
-
|
|
4539
|
+
this._slideWrappers.push({
|
|
4540
|
+
view: this.slides[i],
|
|
4541
|
+
relationships: buildRelationships([{
|
|
4573
4542
|
id: 1,
|
|
4574
4543
|
type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
|
|
4575
4544
|
target: `../slideLayouts/slideLayout${layout.index + 1}.xml`
|
|
@@ -4577,37 +4546,37 @@ var File = class {
|
|
|
4577
4546
|
});
|
|
4578
4547
|
}
|
|
4579
4548
|
}
|
|
4580
|
-
return this.
|
|
4549
|
+
return this._slideWrappers;
|
|
4581
4550
|
}
|
|
4582
|
-
get
|
|
4583
|
-
if (!this.
|
|
4584
|
-
this.
|
|
4585
|
-
for (let i = 0; i < this.slideOptions.length; i++) if (this.slideOptions[i].notes) this.
|
|
4551
|
+
get notesSlides() {
|
|
4552
|
+
if (!this._notesSlides) {
|
|
4553
|
+
this._notesSlides = [];
|
|
4554
|
+
for (let i = 0; i < this.slideOptions.length; i++) if (this.slideOptions[i].notes) this._notesSlides.push(new NotesSlide({ text: this.slideOptions[i].notes }));
|
|
4586
4555
|
}
|
|
4587
|
-
return this.
|
|
4556
|
+
return this._notesSlides;
|
|
4588
4557
|
}
|
|
4589
4558
|
/** Map from slide index → notesSlide index (0-based) for slides that have notes. */
|
|
4590
|
-
get
|
|
4559
|
+
get notesSlideIndexMap() {
|
|
4591
4560
|
const map = /* @__PURE__ */ new Map();
|
|
4592
4561
|
let notesIdx = 0;
|
|
4593
4562
|
for (let i = 0; i < this.slideOptions.length; i++) if (this.slideOptions[i].notes) map.set(i, notesIdx++);
|
|
4594
4563
|
return map;
|
|
4595
4564
|
}
|
|
4596
|
-
get
|
|
4597
|
-
return this.
|
|
4565
|
+
get notesMasterRelationships() {
|
|
4566
|
+
return this._notesMasterRels ??= new Relationships();
|
|
4598
4567
|
}
|
|
4599
|
-
get
|
|
4600
|
-
if (!this.
|
|
4601
|
-
return this.
|
|
4568
|
+
get commentAuthorList() {
|
|
4569
|
+
if (!this._commentAuthorList && !this._slideCommentLists) this.buildComments();
|
|
4570
|
+
return this._commentAuthorList;
|
|
4602
4571
|
}
|
|
4603
|
-
get
|
|
4604
|
-
if (!this.
|
|
4605
|
-
return this.
|
|
4572
|
+
get slideCommentLists() {
|
|
4573
|
+
if (!this._slideCommentLists) this.buildComments();
|
|
4574
|
+
return this._slideCommentLists;
|
|
4606
4575
|
}
|
|
4607
4576
|
buildComments() {
|
|
4608
4577
|
const authorMap = /* @__PURE__ */ new Map();
|
|
4609
4578
|
let nextAuthorId = 0;
|
|
4610
|
-
this.
|
|
4579
|
+
this._slideCommentLists = Array.from({ length: this.slideOptions.length });
|
|
4611
4580
|
for (let i = 0; i < this.slideOptions.length; i++) {
|
|
4612
4581
|
const slideComments = this.slideOptions[i].comments;
|
|
4613
4582
|
if (!slideComments || slideComments.length === 0) continue;
|
|
@@ -4635,7 +4604,7 @@ var File = class {
|
|
|
4635
4604
|
text: c.text
|
|
4636
4605
|
});
|
|
4637
4606
|
}
|
|
4638
|
-
this.
|
|
4607
|
+
this._slideCommentLists[i] = new SlideCommentList(commentEntries);
|
|
4639
4608
|
}
|
|
4640
4609
|
if (authorMap.size > 0) {
|
|
4641
4610
|
const authors = [...authorMap.values()].map((a) => ({
|
|
@@ -4645,7 +4614,7 @@ var File = class {
|
|
|
4645
4614
|
clrIdx: a.clrIdx,
|
|
4646
4615
|
lastIdx: a.commentCount
|
|
4647
4616
|
}));
|
|
4648
|
-
this.
|
|
4617
|
+
this._commentAuthorList = new CommentAuthorList(authors);
|
|
4649
4618
|
}
|
|
4650
4619
|
}
|
|
4651
4620
|
};
|
|
@@ -4898,40 +4867,40 @@ var Compiler = class {
|
|
|
4898
4867
|
};
|
|
4899
4868
|
const mapping = {
|
|
4900
4869
|
AppProperties: {
|
|
4901
|
-
data: xml(this.formatter.format(file.
|
|
4870
|
+
data: xml(this.formatter.format(file.appProperties, context), { declaration }),
|
|
4902
4871
|
path: "docProps/app.xml"
|
|
4903
4872
|
},
|
|
4904
4873
|
Properties: {
|
|
4905
|
-
data: xml(this.formatter.format(file.
|
|
4874
|
+
data: xml(this.formatter.format(file.coreProperties, context), {
|
|
4906
4875
|
declaration,
|
|
4907
4876
|
indent
|
|
4908
4877
|
}),
|
|
4909
4878
|
path: "docProps/core.xml"
|
|
4910
4879
|
},
|
|
4911
4880
|
FileRelationships: {
|
|
4912
|
-
data: xml(this.formatter.format(file.
|
|
4881
|
+
data: xml(this.formatter.format(file.fileRelationships, context), { declaration: false }),
|
|
4913
4882
|
path: "_rels/.rels"
|
|
4914
4883
|
}
|
|
4915
4884
|
};
|
|
4916
|
-
const themes = file.
|
|
4885
|
+
const themes = file.themes;
|
|
4917
4886
|
for (let ti = 0; ti < themes.length; ti++) mapping[`Theme${ti}`] = {
|
|
4918
4887
|
data: this.formatter.formatToXml(themes[ti], context, declaration),
|
|
4919
4888
|
path: `ppt/theme/theme${ti + 1}.xml`
|
|
4920
4889
|
};
|
|
4921
4890
|
mapping["TableStyles"] = {
|
|
4922
|
-
data: this.formatter.formatToXml(file.
|
|
4891
|
+
data: this.formatter.formatToXml(file.tableStyles, context, declaration),
|
|
4923
4892
|
path: "ppt/tableStyles.xml"
|
|
4924
4893
|
};
|
|
4925
4894
|
mapping["PresProps"] = {
|
|
4926
|
-
data: this.formatter.formatToXml(file.
|
|
4895
|
+
data: this.formatter.formatToXml(file.presProps, context, declaration),
|
|
4927
4896
|
path: "ppt/presProps.xml"
|
|
4928
4897
|
};
|
|
4929
4898
|
mapping["ViewProps"] = {
|
|
4930
|
-
data: this.formatter.formatToXml(file.
|
|
4899
|
+
data: this.formatter.formatToXml(file.viewProps, context, declaration),
|
|
4931
4900
|
path: "ppt/viewProps.xml"
|
|
4932
4901
|
};
|
|
4933
|
-
const masters = file.
|
|
4934
|
-
const masterRels = file.
|
|
4902
|
+
const masters = file.slideMasters;
|
|
4903
|
+
const masterRels = file.slideMasterRelsArray;
|
|
4935
4904
|
for (let mi = 0; mi < masters.length; mi++) {
|
|
4936
4905
|
mapping[`SlideMaster${mi}`] = {
|
|
4937
4906
|
data: this.formatter.formatToXml(masters[mi], context, declaration),
|
|
@@ -4942,8 +4911,8 @@ var Compiler = class {
|
|
|
4942
4911
|
path: `ppt/slideMasters/_rels/slideMaster${mi + 1}.xml.rels`
|
|
4943
4912
|
};
|
|
4944
4913
|
}
|
|
4945
|
-
const layouts = file.
|
|
4946
|
-
const layoutRels = file.
|
|
4914
|
+
const layouts = file.allLayouts;
|
|
4915
|
+
const layoutRels = file.allLayoutRelsArray;
|
|
4947
4916
|
for (let li = 0; li < layouts.length; li++) {
|
|
4948
4917
|
mapping[`SlideLayout${li}`] = {
|
|
4949
4918
|
data: this.formatter.formatToXml(layouts[li].layout, context, declaration),
|
|
@@ -4954,13 +4923,13 @@ var Compiler = class {
|
|
|
4954
4923
|
path: `ppt/slideLayouts/_rels/slideLayout${li + 1}.xml.rels`
|
|
4955
4924
|
};
|
|
4956
4925
|
}
|
|
4957
|
-
for (let i = 0; i < layouts.length; i++) file.
|
|
4926
|
+
for (let i = 0; i < layouts.length; i++) file.contentTypes.addSlideLayout(i + 1);
|
|
4958
4927
|
for (let mi = 0; mi < masters.length; mi++) {
|
|
4959
|
-
file.
|
|
4960
|
-
file.
|
|
4928
|
+
file.contentTypes.addSlideMaster(mi + 1);
|
|
4929
|
+
file.contentTypes.addTheme(mi + 1);
|
|
4961
4930
|
}
|
|
4962
|
-
if (file.
|
|
4963
|
-
file.
|
|
4931
|
+
if (file.notesSlides.length > 0) {
|
|
4932
|
+
file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster", "notesMasters/notesMaster1.xml");
|
|
4964
4933
|
mapping["NotesMaster"] = {
|
|
4965
4934
|
data: xml(this.formatter.format(new DefaultNotesMaster(), context), {
|
|
4966
4935
|
declaration,
|
|
@@ -4969,17 +4938,17 @@ var Compiler = class {
|
|
|
4969
4938
|
path: "ppt/notesMasters/notesMaster1.xml"
|
|
4970
4939
|
};
|
|
4971
4940
|
mapping["NotesMasterRelationships"] = {
|
|
4972
|
-
data: xml(this.formatter.format(file.
|
|
4941
|
+
data: xml(this.formatter.format(file.notesMasterRelationships, context), { declaration: false }),
|
|
4973
4942
|
path: "ppt/notesMasters/_rels/notesMaster1.xml.rels"
|
|
4974
4943
|
};
|
|
4975
4944
|
}
|
|
4976
|
-
if (file.
|
|
4977
|
-
const presentationXml = this.formatter.formatToXml(file.
|
|
4945
|
+
if (file.commentAuthorList) file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors", "commentAuthors.xml");
|
|
4946
|
+
const presentationXml = this.formatter.formatToXml(file.presentationWrapper.view, context, declaration);
|
|
4978
4947
|
let currentImageCount = 0;
|
|
4979
|
-
const mediaData = getReferencedMedia(presentationXml, file.
|
|
4980
|
-
const presImageOffset = file.
|
|
4948
|
+
const mediaData = getReferencedMedia(presentationXml, file.media.array);
|
|
4949
|
+
const presImageOffset = file.presentationWrapper.relationships.relationshipCount + 1;
|
|
4981
4950
|
mediaData.forEach((image, idx) => {
|
|
4982
|
-
file.
|
|
4951
|
+
file.presentationWrapper.relationships.addRelationship(presImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
|
|
4983
4952
|
});
|
|
4984
4953
|
const replacedPresentationXml = replaceImagePlaceholders(presentationXml, mediaData, presImageOffset);
|
|
4985
4954
|
currentImageCount += mediaData.length;
|
|
@@ -4988,38 +4957,38 @@ var Compiler = class {
|
|
|
4988
4957
|
path: "ppt/presentation.xml"
|
|
4989
4958
|
};
|
|
4990
4959
|
mapping["PresentationRelationships"] = {
|
|
4991
|
-
data: xml(this.formatter.format(file.
|
|
4960
|
+
data: xml(this.formatter.format(file.presentationWrapper.relationships, context), { declaration: false }),
|
|
4992
4961
|
path: "ppt/_rels/presentation.xml.rels"
|
|
4993
4962
|
};
|
|
4994
|
-
for (let i = 0; i < file.
|
|
4995
|
-
const slideWrapper = file.
|
|
4996
|
-
const slideXml = this.formatter.formatToXml(slideWrapper.
|
|
4997
|
-
const slideMediaData = getReferencedMedia(slideXml, file.
|
|
4998
|
-
const slideImageOffset = slideWrapper.
|
|
4963
|
+
for (let i = 0; i < file.slides.length; i++) {
|
|
4964
|
+
const slideWrapper = file.slideWrappers[i];
|
|
4965
|
+
const slideXml = this.formatter.formatToXml(slideWrapper.view, context, declaration);
|
|
4966
|
+
const slideMediaData = getReferencedMedia(slideXml, file.media.array);
|
|
4967
|
+
const slideImageOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
4999
4968
|
slideMediaData.forEach((image, idx) => {
|
|
5000
|
-
slideWrapper.
|
|
4969
|
+
slideWrapper.relationships.addRelationship(slideImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
|
|
5001
4970
|
});
|
|
5002
4971
|
let replacedSlideXml = replaceImagePlaceholders(slideXml, slideMediaData, slideImageOffset);
|
|
5003
4972
|
currentImageCount += slideMediaData.length;
|
|
5004
4973
|
if (hasPlaceholders(replacedSlideXml)) {
|
|
5005
4974
|
const slideChartKeys = collectPlaceholderKeys(replacedSlideXml, "chart:");
|
|
5006
4975
|
if (slideChartKeys.length > 0) {
|
|
5007
|
-
const slideChartOffset = slideWrapper.
|
|
5008
|
-
const slideCharts = file.
|
|
4976
|
+
const slideChartOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
4977
|
+
const slideCharts = file.charts.array.filter((c) => slideChartKeys.includes(c.key));
|
|
5009
4978
|
replacedSlideXml = replaceChartPlaceholders(replacedSlideXml, slideCharts.map((c) => c.key), slideChartOffset);
|
|
5010
4979
|
slideCharts.forEach((chartData, ci) => {
|
|
5011
|
-
const globalIndex = file.
|
|
5012
|
-
slideWrapper.
|
|
4980
|
+
const globalIndex = file.charts.array.indexOf(chartData);
|
|
4981
|
+
slideWrapper.relationships.addRelationship(slideChartOffset + ci, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", `../charts/chart${globalIndex + 1}.xml`);
|
|
5013
4982
|
});
|
|
5014
4983
|
}
|
|
5015
4984
|
const slideSmartArtKeys = collectPlaceholderKeys(replacedSlideXml, "smartart:");
|
|
5016
4985
|
if (slideSmartArtKeys.length > 0) {
|
|
5017
|
-
const slideSmartArts = file.
|
|
5018
|
-
const saOffset = slideWrapper.
|
|
4986
|
+
const slideSmartArts = file.smartArts.array.filter((s) => slideSmartArtKeys.includes(s.key));
|
|
4987
|
+
const saOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
5019
4988
|
replacedSlideXml = replaceSmartArtPlaceholders(replacedSlideXml, slideSmartArts.map((s) => s.key), saOffset);
|
|
5020
|
-
const saGlobalStart = file.
|
|
4989
|
+
const saGlobalStart = file.smartArts.array.indexOf(slideSmartArts[0]);
|
|
5021
4990
|
addSmartArtRelationships(slideSmartArts.map((s) => s.key), (id, type, target) => {
|
|
5022
|
-
slideWrapper.
|
|
4991
|
+
slideWrapper.relationships.addRelationship(id, type, target);
|
|
5023
4992
|
}, saOffset, saGlobalStart, {
|
|
5024
4993
|
pathPrefix: "../",
|
|
5025
4994
|
styleRelType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"
|
|
@@ -5027,25 +4996,25 @@ var Compiler = class {
|
|
|
5027
4996
|
}
|
|
5028
4997
|
const slideHlinkKeys = collectPlaceholderKeys(replacedSlideXml, "hlink:");
|
|
5029
4998
|
if (slideHlinkKeys.length > 0) {
|
|
5030
|
-
const slideHlinks = file.
|
|
5031
|
-
const hlinkOffset = slideWrapper.
|
|
4999
|
+
const slideHlinks = file.hyperlinks.array.filter((h) => slideHlinkKeys.includes(h.key));
|
|
5000
|
+
const hlinkOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
5032
5001
|
replacedSlideXml = replaceHyperlinkPlaceholders(replacedSlideXml, slideHlinks, hlinkOffset);
|
|
5033
5002
|
slideHlinks.forEach((hlink, hi) => {
|
|
5034
|
-
slideWrapper.
|
|
5003
|
+
slideWrapper.relationships.addRelationship(hlinkOffset + hi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hlink.url, "External");
|
|
5035
5004
|
});
|
|
5036
5005
|
}
|
|
5037
|
-
const slideMediaRefs = getMediaRefs(replacedSlideXml, file.
|
|
5038
|
-
const slideVideoRefs = getVideoRefs(replacedSlideXml, file.
|
|
5006
|
+
const slideMediaRefs = getMediaRefs(replacedSlideXml, file.media.array);
|
|
5007
|
+
const slideVideoRefs = getVideoRefs(replacedSlideXml, file.media.array);
|
|
5039
5008
|
if (slideMediaRefs.length > 0 || slideVideoRefs.length > 0) {
|
|
5040
|
-
const mediaOffset = slideWrapper.
|
|
5009
|
+
const mediaOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
5041
5010
|
const videoOffset = mediaOffset + slideMediaRefs.length;
|
|
5042
5011
|
replacedSlideXml = replaceMediaPlaceholders(replacedSlideXml, slideMediaRefs, mediaOffset);
|
|
5043
5012
|
replacedSlideXml = replaceVideoPlaceholders(replacedSlideXml, slideVideoRefs, videoOffset);
|
|
5044
5013
|
slideMediaRefs.forEach((media, mi) => {
|
|
5045
|
-
slideWrapper.
|
|
5014
|
+
slideWrapper.relationships.addRelationship(mediaOffset + mi, "http://schemas.microsoft.com/office/2007/relationships/media", `../media/${media.fileName}`);
|
|
5046
5015
|
});
|
|
5047
5016
|
slideVideoRefs.forEach((video, vi) => {
|
|
5048
|
-
slideWrapper.
|
|
5017
|
+
slideWrapper.relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${video.fileName}`);
|
|
5049
5018
|
});
|
|
5050
5019
|
}
|
|
5051
5020
|
}
|
|
@@ -5053,26 +5022,26 @@ var Compiler = class {
|
|
|
5053
5022
|
data: replacedSlideXml,
|
|
5054
5023
|
path: `ppt/slides/slide${i + 1}.xml`
|
|
5055
5024
|
};
|
|
5056
|
-
if (file.
|
|
5057
|
-
const notesSlideIndex = file.
|
|
5058
|
-
if (notesSlideIndex !== void 0) slideWrapper.
|
|
5025
|
+
if (file.slideCommentLists[i]) slideWrapper.relationships.addRelationship(slideWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments", `../comments/comment${i + 1}.xml`);
|
|
5026
|
+
const notesSlideIndex = file.notesSlideIndexMap.get(i);
|
|
5027
|
+
if (notesSlideIndex !== void 0) slideWrapper.relationships.addRelationship(slideWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide", `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`);
|
|
5059
5028
|
mapping[`SlideRelationships${i}`] = {
|
|
5060
|
-
data: xml(this.formatter.format(slideWrapper.
|
|
5029
|
+
data: xml(this.formatter.format(slideWrapper.relationships, context), { declaration: false }),
|
|
5061
5030
|
path: `ppt/slides/_rels/slide${i + 1}.xml.rels`
|
|
5062
5031
|
};
|
|
5063
5032
|
}
|
|
5064
|
-
file.
|
|
5065
|
-
file.
|
|
5033
|
+
file.charts.array.forEach((_, i) => {
|
|
5034
|
+
file.contentTypes.addChart(i + 1);
|
|
5066
5035
|
});
|
|
5067
|
-
file.
|
|
5068
|
-
file.
|
|
5069
|
-
file.
|
|
5070
|
-
file.
|
|
5071
|
-
file.
|
|
5072
|
-
file.
|
|
5036
|
+
file.smartArts.array.forEach((_, i) => {
|
|
5037
|
+
file.contentTypes.addDiagramData(i + 1);
|
|
5038
|
+
file.contentTypes.addDiagramLayout(i + 1);
|
|
5039
|
+
file.contentTypes.addDiagramStyle(i + 1);
|
|
5040
|
+
file.contentTypes.addDiagramColors(i + 1);
|
|
5041
|
+
file.contentTypes.addDiagramDrawing(i + 1);
|
|
5073
5042
|
});
|
|
5074
5043
|
mapping["ContentTypes"] = {
|
|
5075
|
-
data: xml(this.formatter.format(file.
|
|
5044
|
+
data: xml(this.formatter.format(file.contentTypes, context), { declaration: false }),
|
|
5076
5045
|
path: "[Content_Types].xml"
|
|
5077
5046
|
};
|
|
5078
5047
|
const files = {};
|
|
@@ -5081,8 +5050,8 @@ var Compiler = class {
|
|
|
5081
5050
|
files[entry.path] = textToUint8Array(entry.data);
|
|
5082
5051
|
}
|
|
5083
5052
|
for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array(override.data);
|
|
5084
|
-
for (let i = 0; i < file.
|
|
5085
|
-
const chartData = file.
|
|
5053
|
+
for (let i = 0; i < file.charts.array.length; i++) {
|
|
5054
|
+
const chartData = file.charts.array[i];
|
|
5086
5055
|
files[`ppt/charts/chart${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(chartData.chartSpace, context), {
|
|
5087
5056
|
declaration,
|
|
5088
5057
|
indent
|
|
@@ -5092,8 +5061,8 @@ var Compiler = class {
|
|
|
5092
5061
|
standalone: "yes"
|
|
5093
5062
|
} }));
|
|
5094
5063
|
}
|
|
5095
|
-
for (let i = 0; i < file.
|
|
5096
|
-
const smartArtData = file.
|
|
5064
|
+
for (let i = 0; i < file.smartArts.array.length; i++) {
|
|
5065
|
+
const smartArtData = file.smartArts.array[i];
|
|
5097
5066
|
files[`ppt/diagrams/data${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(smartArtData.dataModel, context), {
|
|
5098
5067
|
declaration,
|
|
5099
5068
|
indent
|
|
@@ -5103,8 +5072,8 @@ var Compiler = class {
|
|
|
5103
5072
|
files[`ppt/diagrams/colors${i + 1}.xml`] = textToUint8Array(getColorXml(smartArtData.color));
|
|
5104
5073
|
files[`ppt/diagrams/drawing${i + 1}.xml`] = textToUint8Array(DEFAULT_DRAWING_XML);
|
|
5105
5074
|
}
|
|
5106
|
-
for (let i = 0; i < file.
|
|
5107
|
-
const notesSlide = file.
|
|
5075
|
+
for (let i = 0; i < file.notesSlides.length; i++) {
|
|
5076
|
+
const notesSlide = file.notesSlides[i];
|
|
5108
5077
|
files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(notesSlide, context), {
|
|
5109
5078
|
declaration,
|
|
5110
5079
|
indent
|
|
@@ -5114,16 +5083,16 @@ var Compiler = class {
|
|
|
5114
5083
|
standalone: "yes"
|
|
5115
5084
|
} }));
|
|
5116
5085
|
}
|
|
5117
|
-
if (file.
|
|
5086
|
+
if (file.commentAuthorList) files["ppt/commentAuthors.xml"] = textToUint8Array(xml(this.formatter.format(file.commentAuthorList, context), {
|
|
5118
5087
|
declaration,
|
|
5119
5088
|
indent
|
|
5120
5089
|
}));
|
|
5121
|
-
const commentLists = file.
|
|
5090
|
+
const commentLists = file.slideCommentLists;
|
|
5122
5091
|
for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(commentLists[i], context), {
|
|
5123
5092
|
declaration,
|
|
5124
5093
|
indent
|
|
5125
5094
|
}));
|
|
5126
|
-
for (const image of file.
|
|
5095
|
+
for (const image of file.media.array) {
|
|
5127
5096
|
files[`ppt/media/${image.fileName}`] = [image.data, { level: ZIP_STORED_LEVEL }];
|
|
5128
5097
|
if (image.type === "svg" && "fallback" in image) {
|
|
5129
5098
|
const fallback = image.fallback;
|
|
@@ -5354,17 +5323,19 @@ function parseAnimationEffect(el) {
|
|
|
5354
5323
|
}
|
|
5355
5324
|
const childTnLst = findChild(cTn, "p:childTnLst");
|
|
5356
5325
|
if (childTnLst) for (const sub of childTnLst.elements ?? []) switch (sub.name) {
|
|
5357
|
-
case "p:animEffect":
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
const
|
|
5361
|
-
if (
|
|
5362
|
-
const
|
|
5363
|
-
if (
|
|
5326
|
+
case "p:animEffect":
|
|
5327
|
+
if (opts.duration === void 0) {
|
|
5328
|
+
const cBhvr = findChild(sub, "p:cBhvr");
|
|
5329
|
+
const subCTn = cBhvr ? findChild(cBhvr, "p:cTn") : void 0;
|
|
5330
|
+
if (subCTn) {
|
|
5331
|
+
const subDur = attr(subCTn, "dur");
|
|
5332
|
+
if (subDur) {
|
|
5333
|
+
const ms = parseDuration(subDur);
|
|
5334
|
+
if (ms !== void 0) opts.duration = ms;
|
|
5335
|
+
}
|
|
5364
5336
|
}
|
|
5365
5337
|
}
|
|
5366
5338
|
break;
|
|
5367
|
-
}
|
|
5368
5339
|
case "p:anim": {
|
|
5369
5340
|
const subCTn = findChild(sub, "p:cTn");
|
|
5370
5341
|
if (subCTn) {
|
|
@@ -5406,12 +5377,15 @@ function parseAnimationEffect(el) {
|
|
|
5406
5377
|
}
|
|
5407
5378
|
case "p:animScale":
|
|
5408
5379
|
opts.emphasisType = "growShrink";
|
|
5380
|
+
readSubDuration(sub, opts);
|
|
5409
5381
|
break;
|
|
5410
5382
|
case "p:animRot":
|
|
5411
5383
|
opts.emphasisType = "spin";
|
|
5384
|
+
readSubDuration(sub, opts);
|
|
5412
5385
|
break;
|
|
5413
5386
|
case "p:animClr":
|
|
5414
5387
|
opts.emphasisType = "colorChange";
|
|
5388
|
+
readSubDuration(sub, opts);
|
|
5415
5389
|
break;
|
|
5416
5390
|
case "p:cmd":
|
|
5417
5391
|
if (attr(sub, "type") === "call") opts.mediaType = "play";
|
|
@@ -5441,6 +5415,21 @@ function findDeep$1(parent, name) {
|
|
|
5441
5415
|
return results;
|
|
5442
5416
|
}
|
|
5443
5417
|
/**
|
|
5418
|
+
* Read duration from p:cBhvr > p:cTn inside a sub-effect element.
|
|
5419
|
+
*/
|
|
5420
|
+
function readSubDuration(sub, opts) {
|
|
5421
|
+
if (opts.duration !== void 0) return;
|
|
5422
|
+
const cBhvr = findChild(sub, "p:cBhvr");
|
|
5423
|
+
const subCTn = cBhvr ? findChild(cBhvr, "p:cTn") : void 0;
|
|
5424
|
+
if (subCTn) {
|
|
5425
|
+
const subDur = attr(subCTn, "dur");
|
|
5426
|
+
if (subDur) {
|
|
5427
|
+
const ms = parseDuration(subDur);
|
|
5428
|
+
if (ms !== void 0) opts.duration = ms;
|
|
5429
|
+
}
|
|
5430
|
+
}
|
|
5431
|
+
}
|
|
5432
|
+
/**
|
|
5444
5433
|
* Parse OOXML duration string to milliseconds.
|
|
5445
5434
|
* Format: "PT#H#M#S" or "###ms" or just a number string
|
|
5446
5435
|
*/
|
|
@@ -5616,7 +5605,7 @@ function parseTransition(el) {
|
|
|
5616
5605
|
}
|
|
5617
5606
|
return opts;
|
|
5618
5607
|
}
|
|
5619
|
-
function parseShape(el,
|
|
5608
|
+
function parseShape(el, ctx) {
|
|
5620
5609
|
const opts = {};
|
|
5621
5610
|
const nvSpPr = findChild(el, "p:nvSpPr");
|
|
5622
5611
|
if (nvSpPr) {
|
|
@@ -5650,7 +5639,7 @@ function parseShape(el, _ctx) {
|
|
|
5650
5639
|
if (effects) opts.effects = effects;
|
|
5651
5640
|
}
|
|
5652
5641
|
const txBody = findChild(el, "p:txBody");
|
|
5653
|
-
if (txBody) parseTextBody(txBody, opts);
|
|
5642
|
+
if (txBody) parseTextBody(txBody, opts, ctx.slideRels);
|
|
5654
5643
|
return opts;
|
|
5655
5644
|
}
|
|
5656
5645
|
function parseLineShape(el) {
|
|
@@ -5715,7 +5704,7 @@ function parsePicture(el, ctx) {
|
|
|
5715
5704
|
}
|
|
5716
5705
|
const nvPicPr = findChild(el, "p:nvPicPr");
|
|
5717
5706
|
if (nvPicPr) {
|
|
5718
|
-
const cNvPr = findChild(nvPicPr, "p:cNvPr");
|
|
5707
|
+
const cNvPr = findChild(nvPicPr, "a:cNvPr") ?? findChild(nvPicPr, "p:cNvPr");
|
|
5719
5708
|
if (cNvPr) {
|
|
5720
5709
|
const name = attr(cNvPr, "name");
|
|
5721
5710
|
if (name) opts.name = name;
|
|
@@ -5998,6 +5987,20 @@ function parseTableCell(tc) {
|
|
|
5998
5987
|
if (txBody) {
|
|
5999
5988
|
const paragraphs = parseParagraphsFromTxBody(txBody);
|
|
6000
5989
|
if (paragraphs.length > 0) opts.children = paragraphs;
|
|
5990
|
+
const bodyPr = findChild(txBody, "a:bodyPr");
|
|
5991
|
+
if (bodyPr) {
|
|
5992
|
+
const margins = {};
|
|
5993
|
+
for (const [attrName, key] of [
|
|
5994
|
+
["tIns", "top"],
|
|
5995
|
+
["bIns", "bottom"],
|
|
5996
|
+
["lIns", "left"],
|
|
5997
|
+
["rIns", "right"]
|
|
5998
|
+
]) {
|
|
5999
|
+
const val = attrNum(bodyPr, attrName);
|
|
6000
|
+
if (val !== void 0) margins[key] = val;
|
|
6001
|
+
}
|
|
6002
|
+
if (Object.keys(margins).length > 0) opts.margins = margins;
|
|
6003
|
+
}
|
|
6001
6004
|
}
|
|
6002
6005
|
const tcPr = findChild(tc, "a:tcPr");
|
|
6003
6006
|
if (tcPr) {
|
|
@@ -6006,9 +6009,9 @@ function parseTableCell(tc) {
|
|
|
6006
6009
|
const anchor = attr(tcPr, "anchor");
|
|
6007
6010
|
if (anchor) {
|
|
6008
6011
|
const anchorMap = {
|
|
6009
|
-
t: "
|
|
6010
|
-
ctr: "
|
|
6011
|
-
b: "
|
|
6012
|
+
t: "top",
|
|
6013
|
+
ctr: "center",
|
|
6014
|
+
b: "bottom"
|
|
6012
6015
|
};
|
|
6013
6016
|
if (anchor in anchorMap) opts.verticalAlign = anchorMap[anchor];
|
|
6014
6017
|
}
|
|
@@ -6035,7 +6038,7 @@ function parseTableCell(tc) {
|
|
|
6035
6038
|
const borderOpts = {};
|
|
6036
6039
|
if (w !== void 0) borderOpts.width = w;
|
|
6037
6040
|
const fill = parseFillFromElement(borderEl);
|
|
6038
|
-
if (fill) borderOpts.
|
|
6041
|
+
if (typeof fill === "string") borderOpts.color = fill;
|
|
6039
6042
|
if (Object.keys(borderOpts).length > 0) borders[key] = borderOpts;
|
|
6040
6043
|
}
|
|
6041
6044
|
}
|
|
@@ -6136,22 +6139,23 @@ function parseGroup(el, ctx) {
|
|
|
6136
6139
|
opts.children = groupChildren;
|
|
6137
6140
|
return opts;
|
|
6138
6141
|
}
|
|
6139
|
-
function parseTextBody(txBody, opts) {
|
|
6142
|
+
function parseTextBody(txBody, opts, rels) {
|
|
6143
|
+
const textBody = {};
|
|
6140
6144
|
const bodyPr = findChild(txBody, "a:bodyPr");
|
|
6141
6145
|
if (bodyPr) {
|
|
6142
6146
|
const vert = attr(bodyPr, "vert");
|
|
6143
|
-
if (vert)
|
|
6147
|
+
if (vert) textBody.vertical = vert;
|
|
6144
6148
|
const anchor = attr(bodyPr, "anchor");
|
|
6145
6149
|
if (anchor) {
|
|
6146
6150
|
const anchorMap = {
|
|
6147
|
-
t: "
|
|
6148
|
-
ctr: "
|
|
6149
|
-
b: "
|
|
6151
|
+
t: "top",
|
|
6152
|
+
ctr: "center",
|
|
6153
|
+
b: "bottom"
|
|
6150
6154
|
};
|
|
6151
|
-
if (anchor in anchorMap)
|
|
6155
|
+
if (anchor in anchorMap) textBody.anchor = anchorMap[anchor];
|
|
6152
6156
|
}
|
|
6153
6157
|
const wrap = attr(bodyPr, "wrap");
|
|
6154
|
-
if (wrap)
|
|
6158
|
+
if (wrap) textBody.wrap = wrap;
|
|
6155
6159
|
const tIns = attrNum(bodyPr, "tIns");
|
|
6156
6160
|
const bIns = attrNum(bodyPr, "bIns");
|
|
6157
6161
|
const lIns = attrNum(bodyPr, "lIns");
|
|
@@ -6161,34 +6165,36 @@ function parseTextBody(txBody, opts) {
|
|
|
6161
6165
|
if (bIns !== void 0) margins.bottom = bIns;
|
|
6162
6166
|
if (lIns !== void 0) margins.left = lIns;
|
|
6163
6167
|
if (rIns !== void 0) margins.right = rIns;
|
|
6164
|
-
if (Object.keys(margins).length > 0)
|
|
6168
|
+
if (Object.keys(margins).length > 0) textBody.margins = margins;
|
|
6165
6169
|
const numCol = attrNum(bodyPr, "numCol");
|
|
6166
|
-
if (numCol !== void 0)
|
|
6170
|
+
if (numCol !== void 0) textBody.columns = numCol;
|
|
6167
6171
|
const spcCol = attrNum(bodyPr, "spcCol");
|
|
6168
|
-
if (spcCol !== void 0)
|
|
6169
|
-
if (findChild(bodyPr, "a:normAutofit"))
|
|
6170
|
-
else if (findChild(bodyPr, "a:spAutoFit"))
|
|
6171
|
-
else if (findChild(bodyPr, "a:noAutofit"))
|
|
6172
|
+
if (spcCol !== void 0) textBody.columnSpacing = spcCol / 100;
|
|
6173
|
+
if (findChild(bodyPr, "a:normAutofit")) textBody.autoFit = "normal";
|
|
6174
|
+
else if (findChild(bodyPr, "a:spAutoFit")) textBody.autoFit = "shape";
|
|
6175
|
+
else if (findChild(bodyPr, "a:noAutofit")) textBody.autoFit = "none";
|
|
6172
6176
|
}
|
|
6173
|
-
const paragraphs = parseParagraphsFromTxBody(txBody);
|
|
6177
|
+
const paragraphs = parseParagraphsFromTxBody(txBody, rels);
|
|
6174
6178
|
if (paragraphs.length === 1) {
|
|
6175
6179
|
const p = paragraphs[0];
|
|
6176
6180
|
if (p.text && !p.children) {
|
|
6177
6181
|
const props = p.properties;
|
|
6178
6182
|
if (!(props && Object.keys(props).some((k) => k !== "bullet" || props[k]?.type !== "none"))) {
|
|
6179
|
-
|
|
6183
|
+
textBody.text = p.text;
|
|
6184
|
+
opts.textBody = textBody;
|
|
6180
6185
|
return;
|
|
6181
6186
|
}
|
|
6182
6187
|
}
|
|
6183
6188
|
}
|
|
6184
|
-
if (paragraphs.length > 0)
|
|
6189
|
+
if (paragraphs.length > 0) textBody.children = paragraphs;
|
|
6190
|
+
if (Object.keys(textBody).length > 0) opts.textBody = textBody;
|
|
6185
6191
|
}
|
|
6186
|
-
function parseParagraphsFromTxBody(txBody) {
|
|
6192
|
+
function parseParagraphsFromTxBody(txBody, rels) {
|
|
6187
6193
|
const paragraphs = [];
|
|
6188
|
-
for (const pEl of children(txBody, "a:p")) paragraphs.push(parseParagraph(pEl));
|
|
6194
|
+
for (const pEl of children(txBody, "a:p")) paragraphs.push(parseParagraph(pEl, rels));
|
|
6189
6195
|
return paragraphs;
|
|
6190
6196
|
}
|
|
6191
|
-
function parseParagraph(el) {
|
|
6197
|
+
function parseParagraph(el, rels) {
|
|
6192
6198
|
const opts = {};
|
|
6193
6199
|
const pPr = findChild(el, "a:pPr");
|
|
6194
6200
|
if (pPr) {
|
|
@@ -6196,10 +6202,10 @@ function parseParagraph(el) {
|
|
|
6196
6202
|
const algn = attr(pPr, "algn");
|
|
6197
6203
|
if (algn) {
|
|
6198
6204
|
const alignMap = {
|
|
6199
|
-
l: "
|
|
6200
|
-
ctr: "
|
|
6201
|
-
r: "
|
|
6202
|
-
just: "
|
|
6205
|
+
l: "left",
|
|
6206
|
+
ctr: "center",
|
|
6207
|
+
r: "right",
|
|
6208
|
+
just: "justify"
|
|
6203
6209
|
};
|
|
6204
6210
|
if (algn in alignMap) props.alignment = alignMap[algn];
|
|
6205
6211
|
}
|
|
@@ -6219,7 +6225,7 @@ function parseParagraph(el) {
|
|
|
6219
6225
|
if (buClr) {
|
|
6220
6226
|
const srgbClr = findChild(buClr, "a:srgbClr");
|
|
6221
6227
|
if (srgbClr) {
|
|
6222
|
-
const val =
|
|
6228
|
+
const val = colorAttr(srgbClr, "val");
|
|
6223
6229
|
if (val) bulletOpts.color = val;
|
|
6224
6230
|
}
|
|
6225
6231
|
}
|
|
@@ -6270,12 +6276,12 @@ function parseParagraph(el) {
|
|
|
6270
6276
|
if (Object.keys(props).length > 0) opts.properties = props;
|
|
6271
6277
|
}
|
|
6272
6278
|
const runs = [];
|
|
6273
|
-
for (const rEl of children(el, "a:r")) runs.push(parseRun(rEl));
|
|
6279
|
+
for (const rEl of children(el, "a:r")) runs.push(parseRun(rEl, rels));
|
|
6274
6280
|
if (runs.length === 1 && Object.keys(runs[0]).length === 1 && runs[0].text) opts.text = runs[0].text;
|
|
6275
6281
|
else if (runs.length > 0) opts.children = runs;
|
|
6276
6282
|
return opts;
|
|
6277
6283
|
}
|
|
6278
|
-
function parseRun(el) {
|
|
6284
|
+
function parseRun(el, rels) {
|
|
6279
6285
|
const opts = {};
|
|
6280
6286
|
const rPr = findChild(el, "a:rPr");
|
|
6281
6287
|
if (rPr) {
|
|
@@ -6288,9 +6294,9 @@ function parseRun(el) {
|
|
|
6288
6294
|
const u = attr(rPr, "u");
|
|
6289
6295
|
if (u) {
|
|
6290
6296
|
const underlineMap = {
|
|
6291
|
-
sng: "
|
|
6292
|
-
dbl: "
|
|
6293
|
-
none: "
|
|
6297
|
+
sng: "single",
|
|
6298
|
+
dbl: "double",
|
|
6299
|
+
none: "none"
|
|
6294
6300
|
};
|
|
6295
6301
|
if (u in underlineMap) opts.underline = underlineMap[u];
|
|
6296
6302
|
}
|
|
@@ -6299,9 +6305,9 @@ function parseRun(el) {
|
|
|
6299
6305
|
const strike = attr(rPr, "strike");
|
|
6300
6306
|
if (strike) {
|
|
6301
6307
|
const strikeMap = {
|
|
6302
|
-
sngStrike: "
|
|
6303
|
-
dblStrike: "
|
|
6304
|
-
noStrike: "
|
|
6308
|
+
sngStrike: "sngStrike",
|
|
6309
|
+
dblStrike: "dblStrike",
|
|
6310
|
+
noStrike: "noStrike"
|
|
6305
6311
|
};
|
|
6306
6312
|
if (strike in strikeMap) opts.strike = strikeMap[strike];
|
|
6307
6313
|
}
|
|
@@ -6310,9 +6316,9 @@ function parseRun(el) {
|
|
|
6310
6316
|
const cap = attr(rPr, "cap");
|
|
6311
6317
|
if (cap) {
|
|
6312
6318
|
const capMap = {
|
|
6313
|
-
none: "
|
|
6314
|
-
all: "
|
|
6315
|
-
small: "
|
|
6319
|
+
none: "none",
|
|
6320
|
+
all: "all",
|
|
6321
|
+
small: "small"
|
|
6316
6322
|
};
|
|
6317
6323
|
if (cap in capMap) opts.capitalization = capMap[cap];
|
|
6318
6324
|
}
|
|
@@ -6325,6 +6331,19 @@ function parseRun(el) {
|
|
|
6325
6331
|
}
|
|
6326
6332
|
const fill = parseFillFromElement(rPr);
|
|
6327
6333
|
if (fill) opts.fill = fill;
|
|
6334
|
+
const hlinkClick = findChild(rPr, "a:hlinkClick");
|
|
6335
|
+
if (hlinkClick && rels) {
|
|
6336
|
+
const rId = attr(hlinkClick, "r:id");
|
|
6337
|
+
if (rId) {
|
|
6338
|
+
const url = rels.get(rId);
|
|
6339
|
+
if (url) {
|
|
6340
|
+
const hyperlink = { url };
|
|
6341
|
+
const tooltip = attr(hlinkClick, "tooltip");
|
|
6342
|
+
if (tooltip) hyperlink.tooltip = tooltip;
|
|
6343
|
+
opts.hyperlink = hyperlink;
|
|
6344
|
+
}
|
|
6345
|
+
}
|
|
6346
|
+
}
|
|
6328
6347
|
}
|
|
6329
6348
|
const t = findChild(el, "a:t");
|
|
6330
6349
|
if (t) opts.text = textOf(t) ?? "";
|
|
@@ -6380,7 +6399,7 @@ function parseFillFromElement(parent) {
|
|
|
6380
6399
|
const solidFill = findChild(parent, "a:solidFill");
|
|
6381
6400
|
if (solidFill) {
|
|
6382
6401
|
const srgbClr = findChild(solidFill, "a:srgbClr");
|
|
6383
|
-
if (srgbClr) return
|
|
6402
|
+
if (srgbClr) return colorAttr(srgbClr, "val");
|
|
6384
6403
|
const schemeClr = findChild(solidFill, "a:schemeClr");
|
|
6385
6404
|
if (schemeClr) return {
|
|
6386
6405
|
type: "scheme",
|
|
@@ -6398,7 +6417,7 @@ function parseFillFromElement(parent) {
|
|
|
6398
6417
|
if (fgClr) {
|
|
6399
6418
|
const srgbClr = findChild(fgClr, "a:srgbClr");
|
|
6400
6419
|
if (srgbClr) {
|
|
6401
|
-
const val =
|
|
6420
|
+
const val = colorAttr(srgbClr, "val");
|
|
6402
6421
|
if (val) result.foregroundColor = val;
|
|
6403
6422
|
}
|
|
6404
6423
|
}
|
|
@@ -6406,7 +6425,7 @@ function parseFillFromElement(parent) {
|
|
|
6406
6425
|
if (bgClr) {
|
|
6407
6426
|
const srgbClr = findChild(bgClr, "a:srgbClr");
|
|
6408
6427
|
if (srgbClr) {
|
|
6409
|
-
const val =
|
|
6428
|
+
const val = colorAttr(srgbClr, "val");
|
|
6410
6429
|
if (val) result.backgroundColor = val;
|
|
6411
6430
|
}
|
|
6412
6431
|
}
|
|
@@ -6425,8 +6444,8 @@ function parseFillFromElement(parent) {
|
|
|
6425
6444
|
const pos = attrNum(gs, "pos");
|
|
6426
6445
|
const srgbClr = findChild(gs, "a:srgbClr");
|
|
6427
6446
|
if (pos !== void 0 && srgbClr) stops.push({
|
|
6428
|
-
position: pos /
|
|
6429
|
-
color:
|
|
6447
|
+
position: pos / 1e3,
|
|
6448
|
+
color: colorAttr(srgbClr, "val") ?? ""
|
|
6430
6449
|
});
|
|
6431
6450
|
}
|
|
6432
6451
|
if (stops.length > 0) {
|
|
@@ -6439,6 +6458,11 @@ function parseFillFromElement(parent) {
|
|
|
6439
6458
|
const ang = attrNum(lin, "ang");
|
|
6440
6459
|
if (ang !== void 0) result.angle = Math.round(ang / 6e4);
|
|
6441
6460
|
}
|
|
6461
|
+
const pathEl = findChild(gradFill, "a:path");
|
|
6462
|
+
if (pathEl) {
|
|
6463
|
+
const pathType = attr(pathEl, "path");
|
|
6464
|
+
if (pathType) result.path = pathType;
|
|
6465
|
+
}
|
|
6442
6466
|
return result;
|
|
6443
6467
|
}
|
|
6444
6468
|
}
|
|
@@ -6453,7 +6477,7 @@ function parseOutlineFromElement(parent) {
|
|
|
6453
6477
|
if (solidFill) {
|
|
6454
6478
|
const srgbClr = findChild(solidFill, "a:srgbClr");
|
|
6455
6479
|
if (srgbClr) {
|
|
6456
|
-
const val =
|
|
6480
|
+
const val = colorAttr(srgbClr, "val");
|
|
6457
6481
|
if (val) opts.color = val;
|
|
6458
6482
|
}
|
|
6459
6483
|
}
|
|
@@ -6465,10 +6489,10 @@ function parseOutlineFromElement(parent) {
|
|
|
6465
6489
|
return Object.keys(opts).length > 0 ? opts : void 0;
|
|
6466
6490
|
}
|
|
6467
6491
|
function parseEffectsFromElement(parent) {
|
|
6468
|
-
const
|
|
6469
|
-
if (!effectLst) return void 0;
|
|
6492
|
+
const spPr = findChild(parent, "p:spPr") ?? parent;
|
|
6470
6493
|
const opts = {};
|
|
6471
|
-
|
|
6494
|
+
const effectLst = findChild(spPr, "a:effectLst");
|
|
6495
|
+
if (effectLst) for (const child of effectLst.elements ?? []) {
|
|
6472
6496
|
if (!child.name) continue;
|
|
6473
6497
|
switch (child.name) {
|
|
6474
6498
|
case "a:outerShdw": {
|
|
@@ -6523,6 +6547,10 @@ function parseEffectsFromElement(parent) {
|
|
|
6523
6547
|
if (dist !== void 0) reflection.distance = dist;
|
|
6524
6548
|
const dir = attrNum(child, "dir");
|
|
6525
6549
|
if (dir !== void 0) reflection.direction = dir;
|
|
6550
|
+
const stA = attrNum(child, "stA");
|
|
6551
|
+
if (stA !== void 0) reflection.startAlpha = stA / 1e3;
|
|
6552
|
+
const endA = attrNum(child, "endA");
|
|
6553
|
+
if (endA !== void 0) reflection.endAlpha = endA / 1e3;
|
|
6526
6554
|
opts.reflection = reflection;
|
|
6527
6555
|
break;
|
|
6528
6556
|
}
|
|
@@ -6533,6 +6561,63 @@ function parseEffectsFromElement(parent) {
|
|
|
6533
6561
|
}
|
|
6534
6562
|
}
|
|
6535
6563
|
}
|
|
6564
|
+
const scene3d = findChild(spPr, "a:scene3d");
|
|
6565
|
+
if (scene3d) {
|
|
6566
|
+
const camera = findChild(scene3d, "a:camera");
|
|
6567
|
+
if (camera) {
|
|
6568
|
+
const rot = findChild(camera, "a:rot");
|
|
6569
|
+
if (rot) {
|
|
6570
|
+
const rotation3d = {};
|
|
6571
|
+
const lat = attrNum(rot, "lat");
|
|
6572
|
+
const lon = attrNum(rot, "lon");
|
|
6573
|
+
const rev = attrNum(rot, "rev");
|
|
6574
|
+
if (lat !== void 0) rotation3d.x = Math.round(lat / 6e4);
|
|
6575
|
+
if (lon !== void 0) rotation3d.y = Math.round(lon / 6e4);
|
|
6576
|
+
if (rev !== void 0) rotation3d.z = Math.round(rev / 6e4);
|
|
6577
|
+
const fov = attrNum(camera, "fov");
|
|
6578
|
+
if (fov !== void 0) rotation3d.perspective = fov;
|
|
6579
|
+
if (Object.keys(rotation3d).length > 0) opts.rotation3D = rotation3d;
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6582
|
+
const lightRig = findChild(scene3d, "a:lightRig");
|
|
6583
|
+
if (lightRig) {
|
|
6584
|
+
const rig = attr(lightRig, "rig");
|
|
6585
|
+
if (rig) opts.lighting = rig;
|
|
6586
|
+
}
|
|
6587
|
+
}
|
|
6588
|
+
const sp3d = findChild(spPr, "a:sp3d");
|
|
6589
|
+
if (sp3d) {
|
|
6590
|
+
const bevelT = findChild(sp3d, "a:bevelT");
|
|
6591
|
+
if (bevelT) {
|
|
6592
|
+
const bevel = {};
|
|
6593
|
+
const w = attrNum(bevelT, "w");
|
|
6594
|
+
const h = attrNum(bevelT, "h");
|
|
6595
|
+
if (w !== void 0) bevel.width = Math.round(w / 12700);
|
|
6596
|
+
if (h !== void 0) bevel.height = Math.round(h / 12700);
|
|
6597
|
+
const prst = attr(bevelT, "prst");
|
|
6598
|
+
if (prst) bevel.preset = prst;
|
|
6599
|
+
if (Object.keys(bevel).length > 0) opts.bevelTop = bevel;
|
|
6600
|
+
}
|
|
6601
|
+
const bevelB = findChild(sp3d, "a:bevelB");
|
|
6602
|
+
if (bevelB) {
|
|
6603
|
+
const bevel = {};
|
|
6604
|
+
const w = attrNum(bevelB, "w");
|
|
6605
|
+
const h = attrNum(bevelB, "h");
|
|
6606
|
+
if (w !== void 0) bevel.width = Math.round(w / 12700);
|
|
6607
|
+
if (h !== void 0) bevel.height = Math.round(h / 12700);
|
|
6608
|
+
const prst = attr(bevelB, "prst");
|
|
6609
|
+
if (prst) bevel.preset = prst;
|
|
6610
|
+
if (Object.keys(bevel).length > 0) opts.bevelBottom = bevel;
|
|
6611
|
+
}
|
|
6612
|
+
const z = attrNum(sp3d, "z");
|
|
6613
|
+
if (z !== void 0) opts.depth = z;
|
|
6614
|
+
const contourW = attrNum(sp3d, "contourW");
|
|
6615
|
+
if (contourW !== void 0) opts.contourWidth = contourW;
|
|
6616
|
+
const extrusionH = attrNum(sp3d, "extrusionH");
|
|
6617
|
+
if (extrusionH !== void 0) opts.extrusionH = extrusionH;
|
|
6618
|
+
const prstMaterial = attr(sp3d, "prstMaterial");
|
|
6619
|
+
if (prstMaterial) opts.material = prstMaterial;
|
|
6620
|
+
}
|
|
6536
6621
|
return Object.keys(opts).length > 0 ? opts : void 0;
|
|
6537
6622
|
}
|
|
6538
6623
|
/**
|
|
@@ -6541,7 +6626,7 @@ function parseEffectsFromElement(parent) {
|
|
|
6541
6626
|
*/
|
|
6542
6627
|
function extractColorFromElement(el) {
|
|
6543
6628
|
for (const child of el.elements ?? []) if (child.name === "a:srgbClr") {
|
|
6544
|
-
const color =
|
|
6629
|
+
const color = colorAttr(child, "val");
|
|
6545
6630
|
let alpha;
|
|
6546
6631
|
for (const transform of child.elements ?? []) if (transform.name === "a:alpha") {
|
|
6547
6632
|
const val = attrNum(transform, "val");
|
|
@@ -6629,23 +6714,24 @@ function parseMediaFrame(el, ctx, mediaKind) {
|
|
|
6629
6714
|
if (spPr) parseTransformFromSpPr(spPr, opts);
|
|
6630
6715
|
const nvPicPr = findChild(el, "p:nvPicPr");
|
|
6631
6716
|
if (nvPicPr) {
|
|
6632
|
-
const cNvPr = findChild(nvPicPr, "p:cNvPr");
|
|
6717
|
+
const cNvPr = findChild(nvPicPr, "a:cNvPr") ?? findChild(nvPicPr, "p:cNvPr");
|
|
6633
6718
|
if (cNvPr) {
|
|
6634
6719
|
const name = attr(cNvPr, "name");
|
|
6635
6720
|
if (name) opts.name = name;
|
|
6636
6721
|
}
|
|
6637
6722
|
}
|
|
6638
|
-
const
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6723
|
+
const mediaFileEl = findDeep(el, "a:videoFile")[0] ?? findDeep(el, "a:audioFile")[0];
|
|
6724
|
+
const rLink = mediaFileEl ? attr(mediaFileEl, "r:link") : void 0;
|
|
6725
|
+
const p14media = !mediaFileEl ? findDeep(el, "p14:media")[0] : void 0;
|
|
6726
|
+
const rEmbed = p14media ? attr(p14media, "r:embed") : void 0;
|
|
6727
|
+
const mediaRef = rLink ?? rEmbed;
|
|
6728
|
+
if (mediaRef) {
|
|
6729
|
+
const mediaPath = ctx.slideRels.get(mediaRef);
|
|
6730
|
+
if (mediaPath) {
|
|
6731
|
+
const data = ctx.pptx.doc.getRaw(mediaPath);
|
|
6732
|
+
if (data) {
|
|
6733
|
+
opts.data = data;
|
|
6734
|
+
opts.type = mediaTypeFromPath(mediaPath, mediaKind);
|
|
6649
6735
|
}
|
|
6650
6736
|
}
|
|
6651
6737
|
}
|
|
@@ -6739,7 +6825,7 @@ const COLOR_MAP = {
|
|
|
6739
6825
|
};
|
|
6740
6826
|
function extractColor(el) {
|
|
6741
6827
|
const srgb = findChild(el, "a:srgbClr");
|
|
6742
|
-
if (srgb) return
|
|
6828
|
+
if (srgb) return colorAttr(srgb, "val") ?? void 0;
|
|
6743
6829
|
const sysClr = findChild(el, "a:sysClr");
|
|
6744
6830
|
if (sysClr) return attr(sysClr, "lastClr") ?? void 0;
|
|
6745
6831
|
}
|
|
@@ -6921,7 +7007,8 @@ function parseSlideRelMap(doc, slidePath) {
|
|
|
6921
7007
|
const id = attr(child, "Id") ?? "";
|
|
6922
7008
|
const target = attr(child, "Target") ?? "";
|
|
6923
7009
|
if (!id || !target) continue;
|
|
6924
|
-
rels.set(id,
|
|
7010
|
+
if (attr(child, "TargetMode") === "External") rels.set(id, target);
|
|
7011
|
+
else rels.set(id, resolveRelsPath(target));
|
|
6925
7012
|
}
|
|
6926
7013
|
return rels;
|
|
6927
7014
|
}
|
|
@@ -7004,6 +7091,24 @@ function parsePresentation(data) {
|
|
|
7004
7091
|
const bg = cSld ? findChild(cSld, "p:bg") : void 0;
|
|
7005
7092
|
const masterBackground = bg ? parseBackground(bg) : void 0;
|
|
7006
7093
|
const hasBackground = masterBackground && Object.keys(masterBackground).length > 0;
|
|
7094
|
+
const spTree = cSld ? findChild(cSld, "p:spTree") : void 0;
|
|
7095
|
+
const masterChildren = [];
|
|
7096
|
+
if (spTree) {
|
|
7097
|
+
const emptyCtx = {
|
|
7098
|
+
pptx,
|
|
7099
|
+
slideRels: /* @__PURE__ */ new Map()
|
|
7100
|
+
};
|
|
7101
|
+
for (const child of spTree.elements ?? []) {
|
|
7102
|
+
if (child.name === "p:nvGrpSpPr" || child.name === "p:grpSpPr") continue;
|
|
7103
|
+
if (child.name === "p:sp") {
|
|
7104
|
+
const nvSpPr = findChild(child, "p:nvSpPr");
|
|
7105
|
+
const nvPr = nvSpPr ? findChild(nvSpPr, "p:nvPr") : void 0;
|
|
7106
|
+
if (nvPr && findChild(nvPr, "p:ph")) continue;
|
|
7107
|
+
}
|
|
7108
|
+
const parsed = parseSlideChild(child, emptyCtx);
|
|
7109
|
+
if (parsed !== void 0) masterChildren.push(parsed);
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7007
7112
|
const masterLayouts = [];
|
|
7008
7113
|
for (const layoutPath of pptx.slideLayouts) {
|
|
7009
7114
|
if (layoutMasterPaths.get(layoutPath) !== masterPath) continue;
|
|
@@ -7015,6 +7120,7 @@ function parsePresentation(data) {
|
|
|
7015
7120
|
masterDef.name = masterName;
|
|
7016
7121
|
if (themeOptions) masterDef.theme = themeOptions;
|
|
7017
7122
|
if (hasBackground) masterDef.background = masterBackground;
|
|
7123
|
+
if (masterChildren.length > 0) masterDef.children = masterChildren;
|
|
7018
7124
|
if (masterLayouts.length > 0) masterDef.layouts = masterLayouts;
|
|
7019
7125
|
masterDefs.push(masterDef);
|
|
7020
7126
|
}
|
|
@@ -7064,8 +7170,9 @@ function parsePresentation(data) {
|
|
|
7064
7170
|
const pos = findChild(cm, "p:pos");
|
|
7065
7171
|
const x = pos ? attrNum(pos, "x") : void 0;
|
|
7066
7172
|
const y = pos ? attrNum(pos, "y") : void 0;
|
|
7173
|
+
const textEl = findChild(cm, "p:text");
|
|
7067
7174
|
const txBody = findChild(cm, "p:txBody");
|
|
7068
|
-
const text = txBody ? extractCommentText(txBody) : "";
|
|
7175
|
+
const text = textEl ? textOf(textEl) ?? "" : txBody ? extractCommentText(txBody) : "";
|
|
7069
7176
|
const commentEntry = {};
|
|
7070
7177
|
if (authorId !== void 0) commentEntry.authorId = authorId;
|
|
7071
7178
|
if (author) commentEntry.author = author.name;
|