@office-open/pptx 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -46
- package/dist/index.d.mts +55 -21
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +437 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, Formatter as Formatter$1, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PPTX_NS,
|
|
2
|
+
import { AppProperties, BaseXmlComponent, BuilderElement, EmptyElement, Formatter, Formatter as Formatter$1, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PPTX_NS, Relationships, XmlComponent, ZIP_STORED_LEVEL, addSmartArtRelationships, appendContentType, buildCorePropertiesXml, buildCorePropertiesXmlString, collectPlaceholderKeys, compileMapping, convertEmuToInches, convertEmuToPixels, convertEmuToPixels as convertEmuToPixels$1, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPixelsToEmu as convertPixelsToEmu$1, convertPointsToEmu, createPacker, createReplacer, formatId, getReferencedMedia, hasPlaceholders, hashedId, parseArchive, parseCorePropsElement, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, strFromU8, stringContainerObj, toJson, uniqueId, uniqueNumericIdCreator, uniqueUuid, unzipSync, xsdLineEndSize, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, zipAndConvert } 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
|
+
import { attr, attrBool, attrNum, children, colorAttr, escapeXml, findChild, findDeep, js2xml, textOf, xml, xml2js } from "@office-open/xml";
|
|
5
6
|
import { DEFAULT_DRAWING_XML, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml } from "@office-open/core/smartart";
|
|
6
|
-
import {
|
|
7
|
-
import { textToUint8Array, toUint8Array } from "undio";
|
|
7
|
+
import { toUint8Array } from "undio";
|
|
8
8
|
export * from "@office-open/core/values";
|
|
9
9
|
//#region src/file/drawingml/effects.ts
|
|
10
10
|
/** Convert PPTX simple color to core SolidFillOptions. */
|
|
@@ -480,6 +480,9 @@ var CoreProperties = class extends BaseXmlComponent {
|
|
|
480
480
|
prepForXml(_context) {
|
|
481
481
|
return buildCorePropertiesXml(this.options);
|
|
482
482
|
}
|
|
483
|
+
toXml(_context) {
|
|
484
|
+
return buildCorePropertiesXmlString(this.options);
|
|
485
|
+
}
|
|
483
486
|
};
|
|
484
487
|
//#endregion
|
|
485
488
|
//#region src/file/hyperlink-collection.ts
|
|
@@ -547,6 +550,9 @@ var GroupTransform2D = class extends XmlComponent {
|
|
|
547
550
|
prepForXml(context) {
|
|
548
551
|
return this.core["prepForXml"]?.(context);
|
|
549
552
|
}
|
|
553
|
+
toXml(context) {
|
|
554
|
+
return this.core.toXml(context);
|
|
555
|
+
}
|
|
550
556
|
};
|
|
551
557
|
//#endregion
|
|
552
558
|
//#region src/file/drawingml/group-shape-properties.ts
|
|
@@ -612,6 +618,9 @@ var EndParagraphRunProperties = class extends BuilderElement {
|
|
|
612
618
|
prepForXml(_context) {
|
|
613
619
|
return buildEndParagraphRunProperties(this.lang);
|
|
614
620
|
}
|
|
621
|
+
toXml(_context) {
|
|
622
|
+
return `<a:endParaRPr lang="${this.lang}"/>`;
|
|
623
|
+
}
|
|
615
624
|
};
|
|
616
625
|
//#endregion
|
|
617
626
|
//#region src/file/shape/paragraph/paragraph-properties.ts
|
|
@@ -679,6 +688,10 @@ var ParagraphProperties = class extends XmlComponent {
|
|
|
679
688
|
prepForXml(_context) {
|
|
680
689
|
return buildParagraphProperties(this.options);
|
|
681
690
|
}
|
|
691
|
+
toXml(_context) {
|
|
692
|
+
const obj = buildParagraphProperties(this.options);
|
|
693
|
+
return obj ? xml(obj) : "";
|
|
694
|
+
}
|
|
682
695
|
};
|
|
683
696
|
//#endregion
|
|
684
697
|
//#region src/file/shape/paragraph/run-properties.ts
|
|
@@ -776,6 +789,34 @@ var RunProperties = class extends XmlComponent {
|
|
|
776
789
|
} }).prepForXml(context) ?? void 0;
|
|
777
790
|
return buildRunProperties(opts, hyperlinkKey, fillObj, effectListObj, outlineObj);
|
|
778
791
|
}
|
|
792
|
+
toXml(context) {
|
|
793
|
+
const opts = this.options;
|
|
794
|
+
let hyperlinkKey;
|
|
795
|
+
if (opts.hyperlink) {
|
|
796
|
+
hyperlinkKey = `hlink_${nextHyperlinkId++}`;
|
|
797
|
+
context.fileData?.hyperlinks?.addHyperlink(hyperlinkKey, opts.hyperlink.url, opts.hyperlink.tooltip);
|
|
798
|
+
}
|
|
799
|
+
let fillObj;
|
|
800
|
+
if (opts.fill !== void 0) fillObj = buildFill(opts.fill).prepForXml(context) ?? void 0;
|
|
801
|
+
let outlineObj;
|
|
802
|
+
if (opts.outline) outlineObj = createOutline$1({
|
|
803
|
+
width: 12700,
|
|
804
|
+
type: "solidFill",
|
|
805
|
+
color: { value: "000000" }
|
|
806
|
+
}).prepForXml(context) ?? void 0;
|
|
807
|
+
let effectListObj;
|
|
808
|
+
if (opts.shadow) effectListObj = createEffectList$1({ outerShadow: {
|
|
809
|
+
blurRadius: 50800,
|
|
810
|
+
distance: 38100,
|
|
811
|
+
direction: 27e5,
|
|
812
|
+
color: {
|
|
813
|
+
value: "000000",
|
|
814
|
+
transforms: { alpha: 4e4 }
|
|
815
|
+
}
|
|
816
|
+
} }).prepForXml(context) ?? void 0;
|
|
817
|
+
const obj = buildRunProperties(opts, hyperlinkKey, fillObj, effectListObj, outlineObj);
|
|
818
|
+
return obj ? xml(obj) : "";
|
|
819
|
+
}
|
|
779
820
|
};
|
|
780
821
|
//#endregion
|
|
781
822
|
//#region src/file/shape/paragraph/run.ts
|
|
@@ -799,6 +840,27 @@ var TextRun = class extends XmlComponent {
|
|
|
799
840
|
if (this.options.text) children.push({ "a:t": [this.options.text] });
|
|
800
841
|
return { "a:r": children.length === 0 ? {} : children.length === 1 && "_attr" in children[0] ? children[0] : children };
|
|
801
842
|
}
|
|
843
|
+
/**
|
|
844
|
+
* Fast path: simple properties (no hyperlink/fill/shadow/outline) skip
|
|
845
|
+
* RunProperties side effects and serialize directly.
|
|
846
|
+
* Complex path uses RunProperties.toXml() + direct text serialization.
|
|
847
|
+
*/
|
|
848
|
+
toXml(context) {
|
|
849
|
+
const opts = this.options;
|
|
850
|
+
const hasRPr = RunProperties.hasProperties(opts);
|
|
851
|
+
if (!hasRPr || !opts.hyperlink && !opts.fill && !opts.shadow && !opts.outline) {
|
|
852
|
+
let body = "";
|
|
853
|
+
if (hasRPr) {
|
|
854
|
+
const rPrObj = buildRunProperties(opts);
|
|
855
|
+
if (rPrObj) body += xml(rPrObj);
|
|
856
|
+
}
|
|
857
|
+
if (opts.text) body += `<a:t>${escapeXml(opts.text)}</a:t>`;
|
|
858
|
+
return body.length === 0 ? "<a:r/>" : `<a:r>${body}</a:r>`;
|
|
859
|
+
}
|
|
860
|
+
let body = new RunProperties(opts).toXml(context);
|
|
861
|
+
if (opts.text) body += `<a:t>${escapeXml(opts.text)}</a:t>`;
|
|
862
|
+
return body ? `<a:r>${body}</a:r>` : "<a:r/>";
|
|
863
|
+
}
|
|
802
864
|
};
|
|
803
865
|
//#endregion
|
|
804
866
|
//#region src/file/shape/paragraph/paragraph.ts
|
|
@@ -828,6 +890,19 @@ var Paragraph = class extends XmlComponent {
|
|
|
828
890
|
children.push(buildEndParagraphRunProperties());
|
|
829
891
|
return { "a:p": children };
|
|
830
892
|
}
|
|
893
|
+
toXml(context) {
|
|
894
|
+
const parts = [];
|
|
895
|
+
const pPr = buildParagraphProperties(this.options.properties ?? {});
|
|
896
|
+
if (pPr) parts.push(xml(pPr));
|
|
897
|
+
if (this.options.text) parts.push(new TextRun(this.options.text).toXml(context));
|
|
898
|
+
if (this.options.children) for (const rawChild of this.options.children) {
|
|
899
|
+
const child = rawChild instanceof TextRun || rawChild instanceof XmlComponent ? rawChild : new TextRun(rawChild);
|
|
900
|
+
parts.push(child.toXml(context));
|
|
901
|
+
}
|
|
902
|
+
parts.push("<a:endParaRPr lang=\"en-US\"/>");
|
|
903
|
+
const body = parts.join("");
|
|
904
|
+
return body ? `<a:p>${body}</a:p>` : "<a:p/>";
|
|
905
|
+
}
|
|
831
906
|
};
|
|
832
907
|
//#endregion
|
|
833
908
|
//#region src/file/table/table-cell-properties.ts
|
|
@@ -867,6 +942,10 @@ var TableCellProperties = class extends BaseXmlComponent {
|
|
|
867
942
|
}
|
|
868
943
|
return { "a:tcPr": children.length === 0 ? {} : children.length === 1 && "_attr" in children[0] ? children[0] : children };
|
|
869
944
|
}
|
|
945
|
+
toXml(context) {
|
|
946
|
+
const obj = this.prepForXml(context);
|
|
947
|
+
return obj ? xml(obj) : "<a:tcPr/>";
|
|
948
|
+
}
|
|
870
949
|
};
|
|
871
950
|
//#endregion
|
|
872
951
|
//#region src/file/table/table-cell.ts
|
|
@@ -921,6 +1000,34 @@ var TableCell = class extends BaseXmlComponent {
|
|
|
921
1000
|
if (tcPrObj) children.push(tcPrObj);
|
|
922
1001
|
return { "a:tc": children };
|
|
923
1002
|
}
|
|
1003
|
+
toXml(context) {
|
|
1004
|
+
const opts = this.options;
|
|
1005
|
+
const parts = [];
|
|
1006
|
+
const tcAttrs = [];
|
|
1007
|
+
if (opts.columnSpan !== void 0 && opts.columnSpan > 1) tcAttrs.push(`gridSpan="${opts.columnSpan}"`);
|
|
1008
|
+
if (opts.rowSpan !== void 0 && opts.rowSpan > 1) tcAttrs.push(`rowSpan="${opts.rowSpan}"`);
|
|
1009
|
+
const tcAttrStr = tcAttrs.length > 0 ? ` ${tcAttrs.join(" ")}` : "";
|
|
1010
|
+
const txParts = [];
|
|
1011
|
+
const margins = opts.margins;
|
|
1012
|
+
const bodyPrAttrs = [];
|
|
1013
|
+
if (margins?.top !== void 0) bodyPrAttrs.push(`tIns="${margins.top}"`);
|
|
1014
|
+
if (margins?.bottom !== void 0) bodyPrAttrs.push(`bIns="${margins.bottom}"`);
|
|
1015
|
+
if (margins?.left !== void 0) bodyPrAttrs.push(`lIns="${margins.left}"`);
|
|
1016
|
+
if (margins?.right !== void 0) bodyPrAttrs.push(`rIns="${margins.right}"`);
|
|
1017
|
+
const bodyPrStr = bodyPrAttrs.length > 0 ? ` ${bodyPrAttrs.join(" ")}` : "";
|
|
1018
|
+
txParts.push(`<a:bodyPr${bodyPrStr}/>`);
|
|
1019
|
+
txParts.push("<a:lstStyle/>");
|
|
1020
|
+
if (this.paragraphs) for (const p of this.paragraphs) txParts.push(p.toXml(context));
|
|
1021
|
+
else txParts.push("<a:p/>");
|
|
1022
|
+
parts.push(`<a:txBody>${txParts.join("")}</a:txBody>`);
|
|
1023
|
+
const tcPr = new TableCellProperties({
|
|
1024
|
+
fill: opts.fill,
|
|
1025
|
+
borders: opts.borders,
|
|
1026
|
+
verticalAlign: opts.verticalAlign ? xsdTextAnchor.to(opts.verticalAlign) : void 0
|
|
1027
|
+
});
|
|
1028
|
+
parts.push(tcPr.toXml(context));
|
|
1029
|
+
return `<a:tc${tcAttrStr}>${parts.join("")}</a:tc>`;
|
|
1030
|
+
}
|
|
924
1031
|
};
|
|
925
1032
|
//#endregion
|
|
926
1033
|
//#region src/file/shape/text-body.ts
|
|
@@ -975,6 +1082,18 @@ var TextBody = class extends XmlComponent {
|
|
|
975
1082
|
}
|
|
976
1083
|
return { "p:txBody": children };
|
|
977
1084
|
}
|
|
1085
|
+
toXml(context) {
|
|
1086
|
+
const parts = [];
|
|
1087
|
+
parts.push(xml(buildBodyPr(this.options)));
|
|
1088
|
+
parts.push("<a:lstStyle/>");
|
|
1089
|
+
if (this.options.children) for (const p of this.options.children) {
|
|
1090
|
+
const para = typeof p === "string" ? new Paragraph({ children: [new TextRun({ text: p })] }) : p instanceof Paragraph ? p : new Paragraph(p);
|
|
1091
|
+
parts.push(para.toXml(context));
|
|
1092
|
+
}
|
|
1093
|
+
else if (this.options.text !== void 0) parts.push(new Paragraph({ children: [new TextRun({ text: this.options.text })] }).toXml(context));
|
|
1094
|
+
else parts.push(new Paragraph().toXml(context));
|
|
1095
|
+
return `<p:txBody>${parts.join("")}</p:txBody>`;
|
|
1096
|
+
}
|
|
978
1097
|
};
|
|
979
1098
|
//#endregion
|
|
980
1099
|
//#region src/file/notes/notes-slide.ts
|
|
@@ -1178,13 +1297,19 @@ var PresentationProperties = class PresentationProperties extends ImportedXmlCom
|
|
|
1178
1297
|
key;
|
|
1179
1298
|
constructor(showOptions) {
|
|
1180
1299
|
super("p:presentationPr");
|
|
1181
|
-
this.key = showOptions ?
|
|
1300
|
+
this.key = showOptions ? presPropsKey(showOptions) : "";
|
|
1182
1301
|
if (!PresentationProperties.cache.has(this.key)) PresentationProperties.cache.set(this.key, ImportedXmlComponent.fromXmlString(buildPresPropsXml(showOptions)));
|
|
1183
1302
|
}
|
|
1184
1303
|
prepForXml() {
|
|
1185
1304
|
return PresentationProperties.cache.get(this.key).prepForXml({ stack: [] });
|
|
1186
1305
|
}
|
|
1306
|
+
toXml(context) {
|
|
1307
|
+
return PresentationProperties.cache.get(this.key).toXml(context);
|
|
1308
|
+
}
|
|
1187
1309
|
};
|
|
1310
|
+
function presPropsKey(o) {
|
|
1311
|
+
return `l${o.loop ? 1 : 0}k${o.kiosk ? 1 : 0}n${o.showNarration ? 1 : 0}t${o.useTimings ? 1 : 0}`;
|
|
1312
|
+
}
|
|
1188
1313
|
//#endregion
|
|
1189
1314
|
//#region src/file/presentation/presentation.ts
|
|
1190
1315
|
init_xml_components();
|
|
@@ -1309,6 +1434,9 @@ var Transform2D = class extends XmlComponent {
|
|
|
1309
1434
|
prepForXml(context) {
|
|
1310
1435
|
return this.core["prepForXml"]?.(context);
|
|
1311
1436
|
}
|
|
1437
|
+
toXml(context) {
|
|
1438
|
+
return this.core.toXml(context);
|
|
1439
|
+
}
|
|
1312
1440
|
};
|
|
1313
1441
|
//#endregion
|
|
1314
1442
|
//#region src/util/position.ts
|
|
@@ -1319,8 +1447,8 @@ var Transform2D = class extends XmlComponent {
|
|
|
1319
1447
|
/**
|
|
1320
1448
|
* Converts pixel position/size values to EMU, defaulting missing values to 0.
|
|
1321
1449
|
*
|
|
1322
|
-
* Used by components that always need a transform (
|
|
1323
|
-
*
|
|
1450
|
+
* Used by components that always need a transform (Chart, Picture,
|
|
1451
|
+
* Table, SmartArt, MediaFrameBase, etc.).
|
|
1324
1452
|
*/
|
|
1325
1453
|
function emuPosition(opts) {
|
|
1326
1454
|
return {
|
|
@@ -1346,33 +1474,41 @@ function emuPositionOptional(opts) {
|
|
|
1346
1474
|
//#endregion
|
|
1347
1475
|
//#region src/file/chart/chart-frame.ts
|
|
1348
1476
|
init_xml_components();
|
|
1349
|
-
let
|
|
1477
|
+
let nextChartId = 2048;
|
|
1350
1478
|
/**
|
|
1351
1479
|
* p:graphicFrame — Slide-level graphic frame wrapping a chart.
|
|
1352
1480
|
*
|
|
1353
1481
|
* The chart is stored as a separate part (ppt/charts/chart{n}.xml)
|
|
1354
1482
|
* and referenced via a relationship ID placeholder {chart:key}.
|
|
1355
1483
|
*/
|
|
1356
|
-
var
|
|
1484
|
+
var Chart = class extends XmlComponent {
|
|
1357
1485
|
chartOptions;
|
|
1358
1486
|
chartKey;
|
|
1359
1487
|
constructor(options) {
|
|
1360
1488
|
super("p:graphicFrame");
|
|
1361
1489
|
this.chartOptions = options;
|
|
1362
|
-
this.chartKey = `chart_${
|
|
1363
|
-
const id =
|
|
1490
|
+
this.chartKey = `chart_${nextChartId++}`;
|
|
1491
|
+
const id = nextChartId++;
|
|
1364
1492
|
this.root.push(new GraphicFrameNonVisual$2(id));
|
|
1365
1493
|
this.root.push(new Transform2D({ ...emuPosition(options) }, "p"));
|
|
1366
1494
|
this.root.push(new ChartGraphic(this.chartKey));
|
|
1367
1495
|
}
|
|
1368
|
-
|
|
1496
|
+
/** Register chart data with the File's Chart collection. */
|
|
1497
|
+
registerChart(context) {
|
|
1369
1498
|
const file = context.fileData;
|
|
1370
1499
|
if (file?.charts) file.charts.addChart(this.chartKey, {
|
|
1371
1500
|
chartSpace: new ChartSpace(this.chartOptions),
|
|
1372
1501
|
key: this.chartKey
|
|
1373
1502
|
});
|
|
1503
|
+
}
|
|
1504
|
+
prepForXml(context) {
|
|
1505
|
+
this.registerChart(context);
|
|
1374
1506
|
return super.prepForXml(context);
|
|
1375
1507
|
}
|
|
1508
|
+
toXml(context) {
|
|
1509
|
+
this.registerChart(context);
|
|
1510
|
+
return super.toXml(context);
|
|
1511
|
+
}
|
|
1376
1512
|
};
|
|
1377
1513
|
var GraphicFrameNonVisual$2 = class extends XmlComponent {
|
|
1378
1514
|
constructor(id) {
|
|
@@ -1572,12 +1708,20 @@ var MediaFrameBase = class extends XmlComponent {
|
|
|
1572
1708
|
children: [new Transform2D({ ...emuPosition(options) }), new PresetGeometry({ preset: "rect" })]
|
|
1573
1709
|
}));
|
|
1574
1710
|
}
|
|
1575
|
-
|
|
1711
|
+
/** Register media data with the File's Media collection. */
|
|
1712
|
+
registerMedia(context) {
|
|
1576
1713
|
const file = context.fileData;
|
|
1577
1714
|
if (this.posterData) file?.media.addImage(this.posterData.fileName, this.posterData);
|
|
1578
1715
|
file?.media.addMedia(this.mediaData.fileName, this.mediaData);
|
|
1716
|
+
}
|
|
1717
|
+
prepForXml(context) {
|
|
1718
|
+
this.registerMedia(context);
|
|
1579
1719
|
return super.prepForXml(context);
|
|
1580
1720
|
}
|
|
1721
|
+
toXml(context) {
|
|
1722
|
+
this.registerMedia(context);
|
|
1723
|
+
return super.toXml(context);
|
|
1724
|
+
}
|
|
1581
1725
|
};
|
|
1582
1726
|
//#endregion
|
|
1583
1727
|
//#region src/file/media/audio-frame.ts
|
|
@@ -1768,7 +1912,7 @@ init_xml_components();
|
|
|
1768
1912
|
/**
|
|
1769
1913
|
* p:pic — A picture on a slide.
|
|
1770
1914
|
*
|
|
1771
|
-
* Registers image with Media collection via prepForXml.
|
|
1915
|
+
* Registers image with Media collection via prepForXml/toXml.
|
|
1772
1916
|
* The ImageReplacer replaces `{fileName}` placeholder with actual rId.
|
|
1773
1917
|
*/
|
|
1774
1918
|
var Picture = class Picture extends XmlComponent {
|
|
@@ -1801,10 +1945,18 @@ var Picture = class Picture extends XmlComponent {
|
|
|
1801
1945
|
children: [new Transform2D({ ...emuPosition(options) }), new PresetGeometry({ preset: "rect" })]
|
|
1802
1946
|
}));
|
|
1803
1947
|
}
|
|
1804
|
-
|
|
1948
|
+
/** Register image with the File's Media collection. */
|
|
1949
|
+
registerMedia(context) {
|
|
1805
1950
|
context.fileData?.media.addImage(this.imageData.fileName, this.imageData);
|
|
1951
|
+
}
|
|
1952
|
+
prepForXml(context) {
|
|
1953
|
+
this.registerMedia(context);
|
|
1806
1954
|
return super.prepForXml(context);
|
|
1807
1955
|
}
|
|
1956
|
+
toXml(context) {
|
|
1957
|
+
this.registerMedia(context);
|
|
1958
|
+
return super.toXml(context);
|
|
1959
|
+
}
|
|
1808
1960
|
};
|
|
1809
1961
|
//#endregion
|
|
1810
1962
|
//#region src/file/shape/group-shape.ts
|
|
@@ -1863,6 +2015,22 @@ var GroupShape = class GroupShape extends BaseXmlComponent {
|
|
|
1863
2015
|
}
|
|
1864
2016
|
return { "p:grpSp": children };
|
|
1865
2017
|
}
|
|
2018
|
+
toXml(context) {
|
|
2019
|
+
const opts = this.options;
|
|
2020
|
+
const id = this.id;
|
|
2021
|
+
const parts = [];
|
|
2022
|
+
parts.push(`<p:nvGrpSpPr><p:cNvPr id="${id}" name="Group ${id}"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>`);
|
|
2023
|
+
const xfrmAttrs = [];
|
|
2024
|
+
if (opts.flipHorizontal !== void 0) xfrmAttrs.push(`flipH="${opts.flipHorizontal ? 1 : 0}"`);
|
|
2025
|
+
if (opts.rotation !== void 0) xfrmAttrs.push(`rot="${opts.rotation}"`);
|
|
2026
|
+
const xfrmAttrStr = xfrmAttrs.length > 0 ? ` ${xfrmAttrs.join(" ")}` : "";
|
|
2027
|
+
parts.push(`<p:grpSpPr><a:xfrm${xfrmAttrStr}><a:off x="${convertPixelsToEmu$1(opts.x ?? 0)}" y="${convertPixelsToEmu$1(opts.y ?? 0)}"/><a:ext cx="${convertPixelsToEmu$1(opts.width ?? 0)}" cy="${convertPixelsToEmu$1(opts.height ?? 0)}"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>`);
|
|
2028
|
+
for (const rawChild of opts.children) {
|
|
2029
|
+
const s = coerceChild(rawChild).toXml(context);
|
|
2030
|
+
if (s) parts.push(s);
|
|
2031
|
+
}
|
|
2032
|
+
return `<p:grpSp>${parts.join("")}</p:grpSp>`;
|
|
2033
|
+
}
|
|
1866
2034
|
};
|
|
1867
2035
|
//#endregion
|
|
1868
2036
|
//#region src/file/drawingml/non-visual-shape-props.ts
|
|
@@ -1893,16 +2061,11 @@ const ARROWHEAD_MAP = {
|
|
|
1893
2061
|
oval: "oval",
|
|
1894
2062
|
open: "arrow"
|
|
1895
2063
|
};
|
|
1896
|
-
const ARROWHEAD_SIZE_MAP = {
|
|
1897
|
-
sm: "small",
|
|
1898
|
-
med: "medium",
|
|
1899
|
-
lg: "large"
|
|
1900
|
-
};
|
|
1901
2064
|
function toCoreLineEnd(type, width, length) {
|
|
1902
2065
|
return {
|
|
1903
2066
|
type: ARROWHEAD_MAP[type] ?? "triangle",
|
|
1904
|
-
...width ? { width
|
|
1905
|
-
...length ? { length
|
|
2067
|
+
...width ? { width } : {},
|
|
2068
|
+
...length ? { length } : {}
|
|
1906
2069
|
};
|
|
1907
2070
|
}
|
|
1908
2071
|
/**
|
|
@@ -2188,6 +2351,10 @@ var ShapeProperties = class extends BaseXmlComponent {
|
|
|
2188
2351
|
}
|
|
2189
2352
|
return { "p:spPr": children };
|
|
2190
2353
|
}
|
|
2354
|
+
toXml(context) {
|
|
2355
|
+
const obj = this.prepForXml(context);
|
|
2356
|
+
return obj ? xml(obj) : "";
|
|
2357
|
+
}
|
|
2191
2358
|
};
|
|
2192
2359
|
//#endregion
|
|
2193
2360
|
//#region src/file/shape/shape.ts
|
|
@@ -2250,15 +2417,41 @@ var Shape = class Shape extends XmlComponent {
|
|
|
2250
2417
|
if (txBodyObj) children.push(txBodyObj);
|
|
2251
2418
|
return { "p:sp": children };
|
|
2252
2419
|
}
|
|
2420
|
+
toXml(context) {
|
|
2421
|
+
const opts = this.options;
|
|
2422
|
+
const id = this.shapeId;
|
|
2423
|
+
const name = opts.name ?? `Shape ${id}`;
|
|
2424
|
+
const parts = [];
|
|
2425
|
+
let nvPrContent = "<p:nvPr/>";
|
|
2426
|
+
if (opts.placeholder) {
|
|
2427
|
+
const phAttrs = [`type="${opts.placeholder}"`];
|
|
2428
|
+
if (opts.placeholderIndex !== void 0) phAttrs.push(`idx="${opts.placeholderIndex}"`);
|
|
2429
|
+
nvPrContent = `<p:nvPr><p:ph ${phAttrs.join(" ")}/></p:nvPr>`;
|
|
2430
|
+
}
|
|
2431
|
+
parts.push(`<p:nvSpPr><p:cNvPr id="${id}" name="${escapeXml(name)}"/><p:cNvSpPr/>${nvPrContent}</p:nvSpPr>`);
|
|
2432
|
+
const spPrXml = new ShapeProperties({
|
|
2433
|
+
...emuPositionOptional(opts),
|
|
2434
|
+
geometry: opts.geometry,
|
|
2435
|
+
fill: opts.fill,
|
|
2436
|
+
outline: opts.outline,
|
|
2437
|
+
effects: opts.effects,
|
|
2438
|
+
flipHorizontal: opts.flipHorizontal,
|
|
2439
|
+
rotation: opts.rotation
|
|
2440
|
+
}).toXml(context);
|
|
2441
|
+
if (spPrXml) parts.push(spPrXml);
|
|
2442
|
+
const txBody = new TextBody(opts.textBody ?? {});
|
|
2443
|
+
parts.push(txBody.toXml(context));
|
|
2444
|
+
return `<p:sp>${parts.join("")}</p:sp>`;
|
|
2445
|
+
}
|
|
2253
2446
|
};
|
|
2254
2447
|
//#endregion
|
|
2255
2448
|
//#region src/file/smartart/smartart-frame.ts
|
|
2256
2449
|
init_xml_components();
|
|
2257
|
-
let
|
|
2450
|
+
let nextSmartArtId = 1024;
|
|
2258
2451
|
/**
|
|
2259
2452
|
* p:graphicFrame — Slide-level graphic frame wrapping a SmartArt diagram.
|
|
2260
2453
|
*/
|
|
2261
|
-
var
|
|
2454
|
+
var SmartArt = class extends XmlComponent {
|
|
2262
2455
|
smartArtKey;
|
|
2263
2456
|
dataModel;
|
|
2264
2457
|
layoutId;
|
|
@@ -2266,18 +2459,19 @@ var SmartArtFrame = class extends XmlComponent {
|
|
|
2266
2459
|
colorId;
|
|
2267
2460
|
constructor(options) {
|
|
2268
2461
|
super("p:graphicFrame");
|
|
2269
|
-
this.smartArtKey = `smartart_${
|
|
2462
|
+
this.smartArtKey = `smartart_${nextSmartArtId++}`;
|
|
2270
2463
|
this.layoutId = options.layout ?? "default";
|
|
2271
2464
|
this.styleId = options.style ?? "simple1";
|
|
2272
2465
|
this.colorId = options.color ?? "accent1_2";
|
|
2273
2466
|
this.dataModel = createDataModel(options.nodes, this.layoutId, this.styleId, this.colorId);
|
|
2274
|
-
const id =
|
|
2467
|
+
const id = nextSmartArtId++;
|
|
2275
2468
|
const name = options.name ?? `Diagram ${id}`;
|
|
2276
2469
|
this.root.push(new GraphicFrameNonVisual$1(id, name));
|
|
2277
2470
|
this.root.push(new Transform2D({ ...emuPosition(options) }, "p"));
|
|
2278
2471
|
this.root.push(new SmartArtGraphic(this.smartArtKey));
|
|
2279
2472
|
}
|
|
2280
|
-
|
|
2473
|
+
/** Register SmartArt data with the File's SmartArt collection. */
|
|
2474
|
+
registerSmartArt(context) {
|
|
2281
2475
|
const file = context.fileData;
|
|
2282
2476
|
if (file?.smartArts) file.smartArts.addSmartArt(this.smartArtKey, {
|
|
2283
2477
|
key: this.smartArtKey,
|
|
@@ -2286,8 +2480,15 @@ var SmartArtFrame = class extends XmlComponent {
|
|
|
2286
2480
|
style: this.styleId,
|
|
2287
2481
|
color: this.colorId
|
|
2288
2482
|
});
|
|
2483
|
+
}
|
|
2484
|
+
prepForXml(context) {
|
|
2485
|
+
this.registerSmartArt(context);
|
|
2289
2486
|
return super.prepForXml(context);
|
|
2290
2487
|
}
|
|
2488
|
+
toXml(context) {
|
|
2489
|
+
this.registerSmartArt(context);
|
|
2490
|
+
return super.toXml(context);
|
|
2491
|
+
}
|
|
2291
2492
|
};
|
|
2292
2493
|
var GraphicFrameNonVisual$1 = class extends XmlComponent {
|
|
2293
2494
|
constructor(id, name) {
|
|
@@ -2384,6 +2585,9 @@ var Graphic = class extends BaseXmlComponent {
|
|
|
2384
2585
|
if (tableObj) graphicDataChildren.push(tableObj);
|
|
2385
2586
|
return { "a:graphic": [{ "a:graphicData": graphicDataChildren }] };
|
|
2386
2587
|
}
|
|
2588
|
+
toXml(context) {
|
|
2589
|
+
return `<a:graphic><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">${this.table.toXml(context)}</a:graphicData></a:graphic>`;
|
|
2590
|
+
}
|
|
2387
2591
|
};
|
|
2388
2592
|
//#endregion
|
|
2389
2593
|
//#region src/file/table/graphic-frame-non-visual.ts
|
|
@@ -2438,6 +2642,9 @@ var TableGrid = class extends BaseXmlComponent {
|
|
|
2438
2642
|
prepForXml(_context) {
|
|
2439
2643
|
return { "a:tblGrid": this.columnWidths.map((w) => ({ "a:gridCol": { _attr: { w } } })) };
|
|
2440
2644
|
}
|
|
2645
|
+
toXml(_context) {
|
|
2646
|
+
return `<a:tblGrid>${this.columnWidths.map((w) => `<a:gridCol w="${w}"/>`).join("")}</a:tblGrid>`;
|
|
2647
|
+
}
|
|
2441
2648
|
};
|
|
2442
2649
|
//#endregion
|
|
2443
2650
|
//#region src/file/table/table-properties.ts
|
|
@@ -2464,6 +2671,18 @@ var TableProperties = class extends BaseXmlComponent {
|
|
|
2464
2671
|
if (opts.bandCol !== void 0) attrs.bandCol = opts.bandCol ? 1 : 0;
|
|
2465
2672
|
return { "a:tblPr": Object.keys(attrs).length > 0 ? { _attr: attrs } : {} };
|
|
2466
2673
|
}
|
|
2674
|
+
toXml(_context) {
|
|
2675
|
+
if (!this.options) return "<a:tblPr/>";
|
|
2676
|
+
const opts = this.options;
|
|
2677
|
+
const attrs = [];
|
|
2678
|
+
if (opts.firstRow !== void 0) attrs.push(`firstRow="${opts.firstRow ? 1 : 0}"`);
|
|
2679
|
+
if (opts.lastRow !== void 0) attrs.push(`lastRow="${opts.lastRow ? 1 : 0}"`);
|
|
2680
|
+
if (opts.bandRow !== void 0) attrs.push(`bandRow="${opts.bandRow ? 1 : 0}"`);
|
|
2681
|
+
if (opts.firstCol !== void 0) attrs.push(`firstCol="${opts.firstCol ? 1 : 0}"`);
|
|
2682
|
+
if (opts.lastCol !== void 0) attrs.push(`lastCol="${opts.lastCol ? 1 : 0}"`);
|
|
2683
|
+
if (opts.bandCol !== void 0) attrs.push(`bandCol="${opts.bandCol ? 1 : 0}"`);
|
|
2684
|
+
return attrs.length === 0 ? "<a:tblPr/>" : `<a:tblPr ${attrs.join(" ")}/>`;
|
|
2685
|
+
}
|
|
2467
2686
|
};
|
|
2468
2687
|
//#endregion
|
|
2469
2688
|
//#region src/file/table/table-row.ts
|
|
@@ -2487,6 +2706,12 @@ var TableRow = class extends BaseXmlComponent {
|
|
|
2487
2706
|
}
|
|
2488
2707
|
return { "a:tr": children };
|
|
2489
2708
|
}
|
|
2709
|
+
toXml(context) {
|
|
2710
|
+
const h = this.options.height ?? 0;
|
|
2711
|
+
const parts = [];
|
|
2712
|
+
for (const cell of this.options.cells) parts.push(new TableCell(cell).toXml(context));
|
|
2713
|
+
return `<a:tr h="${h}">${parts.join("")}</a:tr>`;
|
|
2714
|
+
}
|
|
2490
2715
|
};
|
|
2491
2716
|
//#endregion
|
|
2492
2717
|
//#region src/file/table/table.ts
|
|
@@ -2495,7 +2720,7 @@ init_xml_components();
|
|
|
2495
2720
|
* a:tbl — DrawingML table element.
|
|
2496
2721
|
* Lazy: stores options, builds IXmlableObject in prepForXml.
|
|
2497
2722
|
*/
|
|
2498
|
-
var
|
|
2723
|
+
var DrawingTable = class extends BaseXmlComponent {
|
|
2499
2724
|
options;
|
|
2500
2725
|
constructor(options) {
|
|
2501
2726
|
super("a:tbl");
|
|
@@ -2513,24 +2738,12 @@ var Table = class extends BaseXmlComponent {
|
|
|
2513
2738
|
bandCol: opts.bandCol
|
|
2514
2739
|
}).prepForXml(context);
|
|
2515
2740
|
if (tblPrObj) children.push(tblPrObj);
|
|
2516
|
-
const gridObj = new TableGrid(opts.columnWidths && opts.columnWidths.length > 0 ?
|
|
2741
|
+
const gridObj = new TableGrid(opts.columnWidths && opts.columnWidths.length > 0 ? opts.columnWidths : Array.from({ length: opts.rows[0]?.cells.length ?? 1 }, () => 0)).prepForXml(context);
|
|
2517
2742
|
if (gridObj) children.push(gridObj);
|
|
2518
|
-
const tb = opts.borders;
|
|
2519
2743
|
const rowCount = opts.rows.length;
|
|
2520
2744
|
for (let ri = 0; ri < rowCount; ri++) {
|
|
2521
2745
|
const row = opts.rows[ri];
|
|
2522
|
-
const
|
|
2523
|
-
const cells = tb ? row.cells.map((cell, ci) => {
|
|
2524
|
-
const b = { ...cell.borders };
|
|
2525
|
-
if (ri === 0 && tb.top && !b.top) b.top = tb.top;
|
|
2526
|
-
if (ri === rowCount - 1 && tb.bottom && !b.bottom) b.bottom = tb.bottom;
|
|
2527
|
-
if (ci === 0 && tb.left && !b.left) b.left = tb.left;
|
|
2528
|
-
if (ci === colCount - 1 && tb.right && !b.right) b.right = tb.right;
|
|
2529
|
-
return Object.keys(b).length === 0 ? cell : {
|
|
2530
|
-
...cell,
|
|
2531
|
-
borders: b
|
|
2532
|
-
};
|
|
2533
|
-
}) : row.cells;
|
|
2746
|
+
const cells = this.distributeBorders(row, ri, rowCount, opts.borders);
|
|
2534
2747
|
const trObj = new TableRow({
|
|
2535
2748
|
...row,
|
|
2536
2749
|
cells
|
|
@@ -2539,6 +2752,54 @@ var Table = class extends BaseXmlComponent {
|
|
|
2539
2752
|
}
|
|
2540
2753
|
return { "a:tbl": children };
|
|
2541
2754
|
}
|
|
2755
|
+
toXml(context) {
|
|
2756
|
+
const opts = this.options;
|
|
2757
|
+
const parts = [];
|
|
2758
|
+
const tblPr = new TableProperties({
|
|
2759
|
+
firstRow: opts.firstRow,
|
|
2760
|
+
lastRow: opts.lastRow,
|
|
2761
|
+
bandRow: opts.bandRow,
|
|
2762
|
+
firstCol: opts.firstCol,
|
|
2763
|
+
lastCol: opts.lastCol,
|
|
2764
|
+
bandCol: opts.bandCol
|
|
2765
|
+
});
|
|
2766
|
+
parts.push(tblPr.toXml(context));
|
|
2767
|
+
const colWidths = opts.columnWidths && opts.columnWidths.length > 0 ? opts.columnWidths : Array.from({ length: opts.rows[0]?.cells.length ?? 1 }, () => 0);
|
|
2768
|
+
parts.push(new TableGrid(colWidths).toXml(context));
|
|
2769
|
+
const rowCount = opts.rows.length;
|
|
2770
|
+
for (let ri = 0; ri < rowCount; ri++) {
|
|
2771
|
+
const row = opts.rows[ri];
|
|
2772
|
+
const cells = this.distributeBorders(row, ri, rowCount, opts.borders);
|
|
2773
|
+
parts.push(new TableRow({
|
|
2774
|
+
...row,
|
|
2775
|
+
cells
|
|
2776
|
+
}).toXml(context));
|
|
2777
|
+
}
|
|
2778
|
+
return `<a:tbl>${parts.join("")}</a:tbl>`;
|
|
2779
|
+
}
|
|
2780
|
+
/** Distribute table-level borders to edge cells only when needed. */
|
|
2781
|
+
distributeBorders(row, ri, rowCount, tb) {
|
|
2782
|
+
if (!tb) return row.cells;
|
|
2783
|
+
const colCount = row.cells.length;
|
|
2784
|
+
return row.cells.map((cell, ci) => {
|
|
2785
|
+
const needTop = ri === 0 && !!tb.top && !cell.borders?.top;
|
|
2786
|
+
const needBottom = ri === rowCount - 1 && !!tb.bottom && !cell.borders?.bottom;
|
|
2787
|
+
const needLeft = ci === 0 && !!tb.left && !cell.borders?.left;
|
|
2788
|
+
const needRight = ci === colCount - 1 && !!tb.right && !cell.borders?.right;
|
|
2789
|
+
if (!needTop && !needBottom && !needLeft && !needRight) return cell;
|
|
2790
|
+
const borders = {
|
|
2791
|
+
...cell.borders,
|
|
2792
|
+
...needTop && { top: tb.top },
|
|
2793
|
+
...needBottom && { bottom: tb.bottom },
|
|
2794
|
+
...needLeft && { left: tb.left },
|
|
2795
|
+
...needRight && { right: tb.right }
|
|
2796
|
+
};
|
|
2797
|
+
return {
|
|
2798
|
+
...cell,
|
|
2799
|
+
borders
|
|
2800
|
+
};
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2542
2803
|
};
|
|
2543
2804
|
//#endregion
|
|
2544
2805
|
//#region src/file/table/table-frame.ts
|
|
@@ -2548,12 +2809,12 @@ init_xml_components();
|
|
|
2548
2809
|
*
|
|
2549
2810
|
* x/y/width/height accept pixel values, converted to EMUs internally.
|
|
2550
2811
|
*/
|
|
2551
|
-
var
|
|
2812
|
+
var Table = class extends XmlComponent {
|
|
2552
2813
|
constructor(options) {
|
|
2553
2814
|
super("p:graphicFrame");
|
|
2554
2815
|
this.root.push(new GraphicFrameNonVisual());
|
|
2555
2816
|
this.root.push(new Transform2D({ ...emuPosition(options) }, "p"));
|
|
2556
|
-
const table = new
|
|
2817
|
+
const table = new DrawingTable(options);
|
|
2557
2818
|
this.root.push(new Graphic(table));
|
|
2558
2819
|
}
|
|
2559
2820
|
};
|
|
@@ -2564,14 +2825,14 @@ function coerceChild(child) {
|
|
|
2564
2825
|
if (child instanceof BaseXmlComponent) return child;
|
|
2565
2826
|
if ("shape" in child) return new Shape(child.shape);
|
|
2566
2827
|
if ("picture" in child) return new Picture(child.picture);
|
|
2567
|
-
if ("table" in child) return new
|
|
2568
|
-
if ("chart" in child) return new
|
|
2828
|
+
if ("table" in child) return new Table(child.table);
|
|
2829
|
+
if ("chart" in child) return new Chart(child.chart);
|
|
2569
2830
|
if ("line" in child) return new LineShape(child.line);
|
|
2570
2831
|
if ("connector" in child) return new ConnectorShape(child.connector);
|
|
2571
2832
|
if ("video" in child) return new VideoFrame(child.video);
|
|
2572
2833
|
if ("audio" in child) return new AudioFrame(child.audio);
|
|
2573
2834
|
if ("group" in child) return new GroupShape(child.group);
|
|
2574
|
-
if ("smartart" in child) return new
|
|
2835
|
+
if ("smartart" in child) return new SmartArt(child.smartart);
|
|
2575
2836
|
throw new Error("Unknown slide child type");
|
|
2576
2837
|
}
|
|
2577
2838
|
function coerceMasterChild(child) {
|
|
@@ -2799,6 +3060,9 @@ var SlideLayout = class SlideLayout extends ImportedXmlComponent {
|
|
|
2799
3060
|
prepForXml() {
|
|
2800
3061
|
return SlideLayout.cache.get(this.cacheKey).prepForXml({ stack: [] });
|
|
2801
3062
|
}
|
|
3063
|
+
toXml(context) {
|
|
3064
|
+
return SlideLayout.cache.get(this.cacheKey).toXml(context);
|
|
3065
|
+
}
|
|
2802
3066
|
};
|
|
2803
3067
|
var DefaultSlideLayout = class extends SlideLayout {
|
|
2804
3068
|
constructor() {
|
|
@@ -2919,6 +3183,9 @@ var DefaultSlideMaster = class DefaultSlideMaster extends ImportedXmlComponent {
|
|
|
2919
3183
|
prepForXml() {
|
|
2920
3184
|
return DefaultSlideMaster.cache.get(this.cacheKey).prepForXml({ stack: [] });
|
|
2921
3185
|
}
|
|
3186
|
+
toXml(context) {
|
|
3187
|
+
return DefaultSlideMaster.cache.get(this.cacheKey).toXml(context);
|
|
3188
|
+
}
|
|
2922
3189
|
};
|
|
2923
3190
|
//#endregion
|
|
2924
3191
|
//#region src/file/animation/timing.ts
|
|
@@ -4129,6 +4396,37 @@ var Slide = class extends XmlComponent {
|
|
|
4129
4396
|
}
|
|
4130
4397
|
return { "p:sld": children };
|
|
4131
4398
|
}
|
|
4399
|
+
toXml(context) {
|
|
4400
|
+
const parts = [];
|
|
4401
|
+
parts.push("<p:sld xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:p=\"http://schemas.openxmlformats.org/presentationml/2006/main\">");
|
|
4402
|
+
parts.push("<p:cSld>");
|
|
4403
|
+
if (this.background) {
|
|
4404
|
+
const bgObj = this.background.prepForXml(context);
|
|
4405
|
+
if (bgObj) parts.push(xml(bgObj));
|
|
4406
|
+
}
|
|
4407
|
+
parts.push("<p:spTree>");
|
|
4408
|
+
parts.push("<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>");
|
|
4409
|
+
parts.push("<p:grpSpPr><a:xfrm><a:off x=\"0\" y=\"0\"/><a:ext cx=\"0\" cy=\"0\"/><a:chOff x=\"0\" y=\"0\"/><a:chExt cx=\"0\" cy=\"0\"/></a:xfrm></p:grpSpPr>");
|
|
4410
|
+
const coercedChildren = this.children.map(coerceChild);
|
|
4411
|
+
for (const child of coercedChildren) {
|
|
4412
|
+
const s = child.toXml(context);
|
|
4413
|
+
if (s) parts.push(s);
|
|
4414
|
+
}
|
|
4415
|
+
parts.push("</p:spTree>");
|
|
4416
|
+
parts.push("</p:cSld>");
|
|
4417
|
+
parts.push("<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>");
|
|
4418
|
+
if (this.transition) {
|
|
4419
|
+
const transObj = buildTransition(this.transition);
|
|
4420
|
+
if (transObj) parts.push(xml(transObj));
|
|
4421
|
+
}
|
|
4422
|
+
const animations = collectAnimations(coercedChildren);
|
|
4423
|
+
if (animations.length > 0) {
|
|
4424
|
+
const timingObj = new SlideTiming(animations).prepForXml(context);
|
|
4425
|
+
if (timingObj) parts.push(xml(timingObj));
|
|
4426
|
+
}
|
|
4427
|
+
parts.push("</p:sld>");
|
|
4428
|
+
return parts.join("");
|
|
4429
|
+
}
|
|
4132
4430
|
};
|
|
4133
4431
|
//#endregion
|
|
4134
4432
|
//#region src/file/table-styles.ts
|
|
@@ -4142,6 +4440,9 @@ var TableStyles = class TableStyles extends ImportedXmlComponent {
|
|
|
4142
4440
|
prepForXml() {
|
|
4143
4441
|
return TableStyles.instance.prepForXml({ stack: [] });
|
|
4144
4442
|
}
|
|
4443
|
+
toXml(context) {
|
|
4444
|
+
return TableStyles.instance.toXml(context);
|
|
4445
|
+
}
|
|
4145
4446
|
};
|
|
4146
4447
|
//#endregion
|
|
4147
4448
|
//#region src/file/theme/theme.ts
|
|
@@ -4231,13 +4532,21 @@ var DefaultTheme = class DefaultTheme extends ImportedXmlComponent {
|
|
|
4231
4532
|
cacheKey;
|
|
4232
4533
|
constructor(options) {
|
|
4233
4534
|
super("a:theme");
|
|
4234
|
-
this.cacheKey = options ?
|
|
4535
|
+
this.cacheKey = options ? themeKey(options) : "";
|
|
4235
4536
|
if (!DefaultTheme.cache.has(this.cacheKey)) DefaultTheme.cache.set(this.cacheKey, ImportedXmlComponent.fromXmlString(buildThemeXml(options)));
|
|
4236
4537
|
}
|
|
4237
4538
|
prepForXml() {
|
|
4238
4539
|
return DefaultTheme.cache.get(this.cacheKey).prepForXml({ stack: [] });
|
|
4239
4540
|
}
|
|
4541
|
+
toXml(context) {
|
|
4542
|
+
return DefaultTheme.cache.get(this.cacheKey).toXml(context);
|
|
4543
|
+
}
|
|
4240
4544
|
};
|
|
4545
|
+
function themeKey(o) {
|
|
4546
|
+
const c = o.colors;
|
|
4547
|
+
const f = o.fonts;
|
|
4548
|
+
return `n${o.name ?? ""}c${c?.dark1 ?? ""}${c?.light1 ?? ""}${c?.dark2 ?? ""}${c?.light2 ?? ""}${c?.accent1 ?? ""}${c?.accent2 ?? ""}${c?.accent3 ?? ""}${c?.accent4 ?? ""}${c?.accent5 ?? ""}${c?.accent6 ?? ""}${c?.hyperlink ?? ""}${c?.followedHyperlink ?? ""}f${f?.majorFont ?? ""}${f?.minorFont ?? ""}${f?.majorFontAsian ?? ""}${f?.minorFontAsian ?? ""}`;
|
|
4549
|
+
}
|
|
4241
4550
|
//#endregion
|
|
4242
4551
|
//#region src/file/view-properties.ts
|
|
4243
4552
|
init_xml_components();
|
|
@@ -4271,6 +4580,9 @@ var ViewProperties = class ViewProperties extends ImportedXmlComponent {
|
|
|
4271
4580
|
prepForXml() {
|
|
4272
4581
|
return ViewProperties.instance.prepForXml({ stack: [] });
|
|
4273
4582
|
}
|
|
4583
|
+
toXml(context) {
|
|
4584
|
+
return ViewProperties.instance.toXml(context);
|
|
4585
|
+
}
|
|
4274
4586
|
};
|
|
4275
4587
|
//#endregion
|
|
4276
4588
|
//#region src/file/file.ts
|
|
@@ -4755,6 +5067,9 @@ var DefaultNotesMaster = class DefaultNotesMaster extends ImportedXmlComponent {
|
|
|
4755
5067
|
prepForXml() {
|
|
4756
5068
|
return DefaultNotesMaster.instance.prepForXml({ stack: [] });
|
|
4757
5069
|
}
|
|
5070
|
+
toXml(context) {
|
|
5071
|
+
return DefaultNotesMaster.instance.toXml(context);
|
|
5072
|
+
}
|
|
4758
5073
|
};
|
|
4759
5074
|
//#endregion
|
|
4760
5075
|
//#region src/file/header-footer/header-footer.ts
|
|
@@ -4821,7 +5136,7 @@ init_background();
|
|
|
4821
5136
|
function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
|
|
4822
5137
|
let result = xml;
|
|
4823
5138
|
hyperlinks.forEach((h, i) => {
|
|
4824
|
-
result = result.
|
|
5139
|
+
result = result.replaceAll(`{hlink:${h.key}}`, formatId(offset, i, "rId"));
|
|
4825
5140
|
});
|
|
4826
5141
|
return result;
|
|
4827
5142
|
}
|
|
@@ -4830,83 +5145,86 @@ function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
|
|
|
4830
5145
|
function replaceMediaPlaceholders(xml, mediaData, offset) {
|
|
4831
5146
|
let result = xml;
|
|
4832
5147
|
mediaData.forEach((m, i) => {
|
|
4833
|
-
result = result.
|
|
5148
|
+
result = result.replaceAll(`{media:${m.fileName}}`, formatId(offset, i, "rId"));
|
|
4834
5149
|
});
|
|
4835
5150
|
return result;
|
|
4836
5151
|
}
|
|
4837
5152
|
function replaceVideoPlaceholders(xml, mediaData, offset) {
|
|
4838
5153
|
let result = xml;
|
|
4839
5154
|
mediaData.forEach((m, i) => {
|
|
4840
|
-
result = result.
|
|
5155
|
+
result = result.replaceAll(`{video:${m.fileName}}`, formatId(offset, i, "rId"));
|
|
4841
5156
|
});
|
|
4842
5157
|
return result;
|
|
4843
5158
|
}
|
|
4844
5159
|
function getMediaRefs(xml, mediaArray) {
|
|
4845
|
-
return collectRefs(xml, "media:", mediaArray);
|
|
5160
|
+
return collectRefs(xml, "{media:", mediaArray);
|
|
4846
5161
|
}
|
|
4847
5162
|
function getVideoRefs(xml, mediaArray) {
|
|
4848
|
-
return collectRefs(xml, "video:", mediaArray);
|
|
5163
|
+
return collectRefs(xml, "{video:", mediaArray);
|
|
4849
5164
|
}
|
|
4850
|
-
function collectRefs(xml,
|
|
4851
|
-
const pattern = new RegExp(`\\{${escapeRegex(prefix)}([^}]+)\\}`, "g");
|
|
5165
|
+
function collectRefs(xml, search, mediaArray) {
|
|
4852
5166
|
const keys = /* @__PURE__ */ new Set();
|
|
4853
|
-
|
|
5167
|
+
let pos = 0;
|
|
5168
|
+
while ((pos = xml.indexOf(search, pos)) !== -1) {
|
|
5169
|
+
const keyStart = pos + search.length;
|
|
5170
|
+
const keyEnd = xml.indexOf("}", keyStart);
|
|
5171
|
+
if (keyEnd === -1) break;
|
|
5172
|
+
keys.add(xml.substring(keyStart, keyEnd));
|
|
5173
|
+
pos = keyEnd + 1;
|
|
5174
|
+
}
|
|
4854
5175
|
return mediaArray.filter((m) => keys.has(m.fileName));
|
|
4855
5176
|
}
|
|
4856
5177
|
//#endregion
|
|
4857
5178
|
//#region src/export/packer/next-compiler.ts
|
|
5179
|
+
/** Reusable TextEncoder (stateless, safe to share). */
|
|
5180
|
+
const encoder$1 = new TextEncoder();
|
|
4858
5181
|
var Compiler = class {
|
|
4859
5182
|
formatter = new Formatter$1();
|
|
4860
|
-
compile(file,
|
|
4861
|
-
const declaration = true;
|
|
4862
|
-
const indent = prettifyXml;
|
|
5183
|
+
compile(file, overrides = []) {
|
|
4863
5184
|
const context = {
|
|
4864
5185
|
fileData: file,
|
|
4865
5186
|
stack: []
|
|
4866
5187
|
};
|
|
4867
5188
|
const mapping = {
|
|
4868
5189
|
AppProperties: {
|
|
4869
|
-
data:
|
|
5190
|
+
data: this.formatter.formatToXml(file.appProperties, context),
|
|
4870
5191
|
path: "docProps/app.xml"
|
|
4871
5192
|
},
|
|
4872
5193
|
Properties: {
|
|
4873
|
-
data:
|
|
4874
|
-
declaration,
|
|
4875
|
-
indent
|
|
4876
|
-
}),
|
|
5194
|
+
data: this.formatter.formatToXml(file.coreProperties, context),
|
|
4877
5195
|
path: "docProps/core.xml"
|
|
4878
5196
|
},
|
|
4879
5197
|
FileRelationships: {
|
|
4880
|
-
data:
|
|
5198
|
+
data: this.formatter.formatToXml(file.fileRelationships, context),
|
|
4881
5199
|
path: "_rels/.rels"
|
|
4882
5200
|
}
|
|
4883
5201
|
};
|
|
4884
5202
|
const themes = file.themes;
|
|
4885
5203
|
for (let ti = 0; ti < themes.length; ti++) mapping[`Theme${ti}`] = {
|
|
4886
|
-
data: this.formatter.formatToXml(themes[ti], context
|
|
5204
|
+
data: this.formatter.formatToXml(themes[ti], context),
|
|
4887
5205
|
path: `ppt/theme/theme${ti + 1}.xml`
|
|
4888
5206
|
};
|
|
4889
5207
|
mapping["TableStyles"] = {
|
|
4890
|
-
data: this.formatter.formatToXml(file.tableStyles, context
|
|
5208
|
+
data: this.formatter.formatToXml(file.tableStyles, context),
|
|
4891
5209
|
path: "ppt/tableStyles.xml"
|
|
4892
5210
|
};
|
|
4893
5211
|
mapping["PresProps"] = {
|
|
4894
|
-
data: this.formatter.formatToXml(file.presProps, context
|
|
5212
|
+
data: this.formatter.formatToXml(file.presProps, context),
|
|
4895
5213
|
path: "ppt/presProps.xml"
|
|
4896
5214
|
};
|
|
4897
5215
|
mapping["ViewProps"] = {
|
|
4898
|
-
data: this.formatter.formatToXml(file.viewProps, context
|
|
5216
|
+
data: this.formatter.formatToXml(file.viewProps, context),
|
|
4899
5217
|
path: "ppt/viewProps.xml"
|
|
4900
5218
|
};
|
|
4901
5219
|
const masters = file.slideMasters;
|
|
4902
5220
|
const masterRels = file.slideMasterRelsArray;
|
|
4903
5221
|
for (let mi = 0; mi < masters.length; mi++) {
|
|
4904
5222
|
mapping[`SlideMaster${mi}`] = {
|
|
4905
|
-
data: this.formatter.formatToXml(masters[mi], context
|
|
5223
|
+
data: this.formatter.formatToXml(masters[mi], context),
|
|
4906
5224
|
path: `ppt/slideMasters/slideMaster${mi + 1}.xml`
|
|
4907
5225
|
};
|
|
4908
5226
|
mapping[`SlideMasterRels${mi}`] = {
|
|
4909
|
-
data:
|
|
5227
|
+
data: this.formatter.formatToXml(masterRels[mi], context),
|
|
4910
5228
|
path: `ppt/slideMasters/_rels/slideMaster${mi + 1}.xml.rels`
|
|
4911
5229
|
};
|
|
4912
5230
|
}
|
|
@@ -4914,11 +5232,11 @@ var Compiler = class {
|
|
|
4914
5232
|
const layoutRels = file.allLayoutRelsArray;
|
|
4915
5233
|
for (let li = 0; li < layouts.length; li++) {
|
|
4916
5234
|
mapping[`SlideLayout${li}`] = {
|
|
4917
|
-
data: this.formatter.formatToXml(layouts[li].layout, context
|
|
5235
|
+
data: this.formatter.formatToXml(layouts[li].layout, context),
|
|
4918
5236
|
path: `ppt/slideLayouts/slideLayout${li + 1}.xml`
|
|
4919
5237
|
};
|
|
4920
5238
|
mapping[`SlideLayoutRels${li}`] = {
|
|
4921
|
-
data:
|
|
5239
|
+
data: this.formatter.formatToXml(layoutRels[li], context),
|
|
4922
5240
|
path: `ppt/slideLayouts/_rels/slideLayout${li + 1}.xml.rels`
|
|
4923
5241
|
};
|
|
4924
5242
|
}
|
|
@@ -4930,25 +5248,20 @@ var Compiler = class {
|
|
|
4930
5248
|
if (file.notesSlides.length > 0) {
|
|
4931
5249
|
file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster", "notesMasters/notesMaster1.xml");
|
|
4932
5250
|
mapping["NotesMaster"] = {
|
|
4933
|
-
data:
|
|
4934
|
-
declaration,
|
|
4935
|
-
indent
|
|
4936
|
-
}),
|
|
5251
|
+
data: this.formatter.formatToXml(new DefaultNotesMaster(), context),
|
|
4937
5252
|
path: "ppt/notesMasters/notesMaster1.xml"
|
|
4938
5253
|
};
|
|
4939
5254
|
mapping["NotesMasterRelationships"] = {
|
|
4940
|
-
data:
|
|
5255
|
+
data: this.formatter.formatToXml(file.notesMasterRelationships, context),
|
|
4941
5256
|
path: "ppt/notesMasters/_rels/notesMaster1.xml.rels"
|
|
4942
5257
|
};
|
|
4943
5258
|
}
|
|
4944
5259
|
if (file.commentAuthorList) file.presentationWrapper.relationships.addRelationship(file.presentationWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors", "commentAuthors.xml");
|
|
4945
|
-
const presentationXml = this.formatter.formatToXml(file.presentationWrapper.view, context
|
|
5260
|
+
const presentationXml = this.formatter.formatToXml(file.presentationWrapper.view, context);
|
|
4946
5261
|
let currentImageCount = 0;
|
|
4947
5262
|
const mediaData = getReferencedMedia(presentationXml, file.media.array);
|
|
4948
5263
|
const presImageOffset = file.presentationWrapper.relationships.relationshipCount + 1;
|
|
4949
|
-
mediaData.
|
|
4950
|
-
file.presentationWrapper.relationships.addRelationship(presImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
|
|
4951
|
-
});
|
|
5264
|
+
for (let idx = 0; idx < mediaData.length; idx++) file.presentationWrapper.relationships.addRelationship(presImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${mediaData[idx].fileName}`);
|
|
4952
5265
|
const replacedPresentationXml = replaceImagePlaceholders(presentationXml, mediaData, presImageOffset);
|
|
4953
5266
|
currentImageCount += mediaData.length;
|
|
4954
5267
|
mapping["Presentation"] = {
|
|
@@ -4956,33 +5269,34 @@ var Compiler = class {
|
|
|
4956
5269
|
path: "ppt/presentation.xml"
|
|
4957
5270
|
};
|
|
4958
5271
|
mapping["PresentationRelationships"] = {
|
|
4959
|
-
data:
|
|
5272
|
+
data: this.formatter.formatToXml(file.presentationWrapper.relationships, context),
|
|
4960
5273
|
path: "ppt/_rels/presentation.xml.rels"
|
|
4961
5274
|
};
|
|
4962
5275
|
for (let i = 0; i < file.slides.length; i++) {
|
|
4963
5276
|
const slideWrapper = file.slideWrappers[i];
|
|
4964
|
-
const slideXml = this.formatter.formatToXml(slideWrapper.view, context
|
|
5277
|
+
const slideXml = this.formatter.formatToXml(slideWrapper.view, context);
|
|
4965
5278
|
const slideMediaData = getReferencedMedia(slideXml, file.media.array);
|
|
4966
5279
|
const slideImageOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
4967
|
-
slideMediaData.
|
|
4968
|
-
slideWrapper.relationships.addRelationship(slideImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
|
|
4969
|
-
});
|
|
5280
|
+
for (let idx = 0; idx < slideMediaData.length; idx++) slideWrapper.relationships.addRelationship(slideImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${slideMediaData[idx].fileName}`);
|
|
4970
5281
|
let replacedSlideXml = replaceImagePlaceholders(slideXml, slideMediaData, slideImageOffset);
|
|
4971
5282
|
currentImageCount += slideMediaData.length;
|
|
4972
5283
|
if (hasPlaceholders(replacedSlideXml)) {
|
|
4973
5284
|
const slideChartKeys = collectPlaceholderKeys(replacedSlideXml, "chart:");
|
|
4974
5285
|
if (slideChartKeys.length > 0) {
|
|
4975
5286
|
const slideChartOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
4976
|
-
const
|
|
5287
|
+
const slideChartKeySet = new Set(slideChartKeys);
|
|
5288
|
+
const slideCharts = file.charts.array.filter((c) => slideChartKeySet.has(c.key));
|
|
4977
5289
|
replacedSlideXml = replaceChartPlaceholders(replacedSlideXml, slideCharts.map((c) => c.key), slideChartOffset);
|
|
4978
|
-
slideCharts.
|
|
5290
|
+
for (let ci = 0; ci < slideCharts.length; ci++) {
|
|
5291
|
+
const chartData = slideCharts[ci];
|
|
4979
5292
|
const globalIndex = file.charts.array.indexOf(chartData);
|
|
4980
5293
|
slideWrapper.relationships.addRelationship(slideChartOffset + ci, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", `../charts/chart${globalIndex + 1}.xml`);
|
|
4981
|
-
}
|
|
5294
|
+
}
|
|
4982
5295
|
}
|
|
4983
5296
|
const slideSmartArtKeys = collectPlaceholderKeys(replacedSlideXml, "smartart:");
|
|
4984
5297
|
if (slideSmartArtKeys.length > 0) {
|
|
4985
|
-
const
|
|
5298
|
+
const slideSmartArtKeySet = new Set(slideSmartArtKeys);
|
|
5299
|
+
const slideSmartArts = file.smartArts.array.filter((s) => slideSmartArtKeySet.has(s.key));
|
|
4986
5300
|
const saOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
4987
5301
|
replacedSlideXml = replaceSmartArtPlaceholders(replacedSlideXml, slideSmartArts.map((s) => s.key), saOffset);
|
|
4988
5302
|
const saGlobalStart = file.smartArts.array.indexOf(slideSmartArts[0]);
|
|
@@ -4995,12 +5309,11 @@ var Compiler = class {
|
|
|
4995
5309
|
}
|
|
4996
5310
|
const slideHlinkKeys = collectPlaceholderKeys(replacedSlideXml, "hlink:");
|
|
4997
5311
|
if (slideHlinkKeys.length > 0) {
|
|
4998
|
-
const
|
|
5312
|
+
const slideHlinkKeySet = new Set(slideHlinkKeys);
|
|
5313
|
+
const slideHlinks = file.hyperlinks.array.filter((h) => slideHlinkKeySet.has(h.key));
|
|
4999
5314
|
const hlinkOffset = slideWrapper.relationships.relationshipCount + 1;
|
|
5000
5315
|
replacedSlideXml = replaceHyperlinkPlaceholders(replacedSlideXml, slideHlinks, hlinkOffset);
|
|
5001
|
-
slideHlinks.
|
|
5002
|
-
slideWrapper.relationships.addRelationship(hlinkOffset + hi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hlink.url, "External");
|
|
5003
|
-
});
|
|
5316
|
+
for (let hi = 0; hi < slideHlinks.length; hi++) slideWrapper.relationships.addRelationship(hlinkOffset + hi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", slideHlinks[hi].url, "External");
|
|
5004
5317
|
}
|
|
5005
5318
|
const slideMediaRefs = getMediaRefs(replacedSlideXml, file.media.array);
|
|
5006
5319
|
const slideVideoRefs = getVideoRefs(replacedSlideXml, file.media.array);
|
|
@@ -5009,12 +5322,8 @@ var Compiler = class {
|
|
|
5009
5322
|
const videoOffset = mediaOffset + slideMediaRefs.length;
|
|
5010
5323
|
replacedSlideXml = replaceMediaPlaceholders(replacedSlideXml, slideMediaRefs, mediaOffset);
|
|
5011
5324
|
replacedSlideXml = replaceVideoPlaceholders(replacedSlideXml, slideVideoRefs, videoOffset);
|
|
5012
|
-
slideMediaRefs.
|
|
5013
|
-
|
|
5014
|
-
});
|
|
5015
|
-
slideVideoRefs.forEach((video, vi) => {
|
|
5016
|
-
slideWrapper.relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${video.fileName}`);
|
|
5017
|
-
});
|
|
5325
|
+
for (let mi = 0; mi < slideMediaRefs.length; mi++) slideWrapper.relationships.addRelationship(mediaOffset + mi, "http://schemas.microsoft.com/office/2007/relationships/media", `../media/${slideMediaRefs[mi].fileName}`);
|
|
5326
|
+
for (let vi = 0; vi < slideVideoRefs.length; vi++) slideWrapper.relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${slideVideoRefs[vi].fileName}`);
|
|
5018
5327
|
}
|
|
5019
5328
|
}
|
|
5020
5329
|
mapping[`Slide${i}`] = {
|
|
@@ -5025,72 +5334,50 @@ var Compiler = class {
|
|
|
5025
5334
|
const notesSlideIndex = file.notesSlideIndexMap.get(i);
|
|
5026
5335
|
if (notesSlideIndex !== void 0) slideWrapper.relationships.addRelationship(slideWrapper.relationships.relationshipCount + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide", `../notesSlides/notesSlide${notesSlideIndex + 1}.xml`);
|
|
5027
5336
|
mapping[`SlideRelationships${i}`] = {
|
|
5028
|
-
data:
|
|
5337
|
+
data: this.formatter.formatToXml(slideWrapper.relationships, context),
|
|
5029
5338
|
path: `ppt/slides/_rels/slide${i + 1}.xml.rels`
|
|
5030
5339
|
};
|
|
5031
5340
|
}
|
|
5032
|
-
file.charts.array.
|
|
5033
|
-
|
|
5034
|
-
});
|
|
5035
|
-
file.smartArts.array.forEach((_, i) => {
|
|
5341
|
+
for (let i = 0; i < file.charts.array.length; i++) file.contentTypes.addChart(i + 1);
|
|
5342
|
+
for (let i = 0; i < file.smartArts.array.length; i++) {
|
|
5036
5343
|
file.contentTypes.addDiagramData(i + 1);
|
|
5037
5344
|
file.contentTypes.addDiagramLayout(i + 1);
|
|
5038
5345
|
file.contentTypes.addDiagramStyle(i + 1);
|
|
5039
5346
|
file.contentTypes.addDiagramColors(i + 1);
|
|
5040
5347
|
file.contentTypes.addDiagramDrawing(i + 1);
|
|
5041
|
-
}
|
|
5348
|
+
}
|
|
5042
5349
|
mapping["ContentTypes"] = {
|
|
5043
|
-
data:
|
|
5350
|
+
data: this.formatter.formatToXml(file.contentTypes, context),
|
|
5044
5351
|
path: "[Content_Types].xml"
|
|
5045
5352
|
};
|
|
5046
|
-
const files =
|
|
5047
|
-
for (const key of Object.keys(mapping)) {
|
|
5048
|
-
const entry = mapping[key];
|
|
5049
|
-
files[entry.path] = textToUint8Array$1(entry.data);
|
|
5050
|
-
}
|
|
5051
|
-
for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array$1(override.data);
|
|
5353
|
+
const files = compileMapping(mapping, overrides);
|
|
5052
5354
|
for (let i = 0; i < file.charts.array.length; i++) {
|
|
5053
5355
|
const chartData = file.charts.array[i];
|
|
5054
|
-
files[`ppt/charts/chart${i + 1}.xml`] =
|
|
5055
|
-
|
|
5056
|
-
indent
|
|
5057
|
-
}));
|
|
5058
|
-
files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = textToUint8Array$1(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
5356
|
+
files[`ppt/charts/chart${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(chartData.chartSpace, context));
|
|
5357
|
+
files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = encoder$1.encode(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
5059
5358
|
encoding: "UTF-8",
|
|
5060
5359
|
standalone: "yes"
|
|
5061
5360
|
} }));
|
|
5062
5361
|
}
|
|
5063
5362
|
for (let i = 0; i < file.smartArts.array.length; i++) {
|
|
5064
5363
|
const smartArtData = file.smartArts.array[i];
|
|
5065
|
-
files[`ppt/diagrams/data${i + 1}.xml`] =
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
}));
|
|
5069
|
-
files[`ppt/diagrams/
|
|
5070
|
-
files[`ppt/diagrams/quickStyle${i + 1}.xml`] = textToUint8Array$1(getStyleXml(smartArtData.style));
|
|
5071
|
-
files[`ppt/diagrams/colors${i + 1}.xml`] = textToUint8Array$1(getColorXml(smartArtData.color));
|
|
5072
|
-
files[`ppt/diagrams/drawing${i + 1}.xml`] = textToUint8Array$1(DEFAULT_DRAWING_XML);
|
|
5364
|
+
files[`ppt/diagrams/data${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(smartArtData.dataModel, context));
|
|
5365
|
+
files[`ppt/diagrams/layout${i + 1}.xml`] = encoder$1.encode(getLayoutXml(smartArtData.layout));
|
|
5366
|
+
files[`ppt/diagrams/quickStyle${i + 1}.xml`] = encoder$1.encode(getStyleXml(smartArtData.style));
|
|
5367
|
+
files[`ppt/diagrams/colors${i + 1}.xml`] = encoder$1.encode(getColorXml(smartArtData.color));
|
|
5368
|
+
files[`ppt/diagrams/drawing${i + 1}.xml`] = encoder$1.encode(DEFAULT_DRAWING_XML);
|
|
5073
5369
|
}
|
|
5074
5370
|
for (let i = 0; i < file.notesSlides.length; i++) {
|
|
5075
5371
|
const notesSlide = file.notesSlides[i];
|
|
5076
|
-
files[`ppt/notesSlides/notesSlide${i + 1}.xml`] =
|
|
5077
|
-
|
|
5078
|
-
indent
|
|
5079
|
-
}));
|
|
5080
|
-
files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = textToUint8Array$1(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
5372
|
+
files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(notesSlide, context));
|
|
5373
|
+
files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = encoder$1.encode(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
5081
5374
|
encoding: "UTF-8",
|
|
5082
5375
|
standalone: "yes"
|
|
5083
5376
|
} }));
|
|
5084
5377
|
}
|
|
5085
|
-
if (file.commentAuthorList) files["ppt/commentAuthors.xml"] =
|
|
5086
|
-
declaration,
|
|
5087
|
-
indent
|
|
5088
|
-
}));
|
|
5378
|
+
if (file.commentAuthorList) files["ppt/commentAuthors.xml"] = encoder$1.encode(this.formatter.formatToXml(file.commentAuthorList, context));
|
|
5089
5379
|
const commentLists = file.slideCommentLists;
|
|
5090
|
-
for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] =
|
|
5091
|
-
declaration,
|
|
5092
|
-
indent
|
|
5093
|
-
}));
|
|
5380
|
+
for (let i = 0; i < commentLists.length; i++) if (commentLists[i]) files[`ppt/comments/comment${i + 1}.xml`] = encoder$1.encode(this.formatter.formatToXml(commentLists[i], context));
|
|
5094
5381
|
for (const image of file.media.array) {
|
|
5095
5382
|
files[`ppt/media/${image.fileName}`] = [image.data, { level: ZIP_STORED_LEVEL }];
|
|
5096
5383
|
if (image.type === "svg" && "fallback" in image) {
|
|
@@ -5101,15 +5388,11 @@ var Compiler = class {
|
|
|
5101
5388
|
return files;
|
|
5102
5389
|
}
|
|
5103
5390
|
};
|
|
5104
|
-
function textToUint8Array$1(data) {
|
|
5105
|
-
if (data instanceof Uint8Array) return data;
|
|
5106
|
-
return new TextEncoder().encode(data);
|
|
5107
|
-
}
|
|
5108
5391
|
//#endregion
|
|
5109
5392
|
//#region src/export/packer/packer.ts
|
|
5110
5393
|
const compiler = new Compiler();
|
|
5111
5394
|
const Packer = createPacker({
|
|
5112
|
-
compile: (file,
|
|
5395
|
+
compile: (file, overrides) => compiler.compile(file, overrides),
|
|
5113
5396
|
mimeType: OoxmlMimeType.PPTX
|
|
5114
5397
|
});
|
|
5115
5398
|
//#endregion
|
|
@@ -6091,9 +6374,9 @@ function parseConnector(el) {
|
|
|
6091
6374
|
const type = attr(headEnd, "type");
|
|
6092
6375
|
if (type) opts.endArrowhead = type;
|
|
6093
6376
|
const len = attr(headEnd, "len");
|
|
6094
|
-
if (len) opts.arrowheadLength = len;
|
|
6377
|
+
if (len) opts.arrowheadLength = xsdLineEndSize.from(len);
|
|
6095
6378
|
const w = attr(headEnd, "w");
|
|
6096
|
-
if (w) opts.arrowheadWidth = w;
|
|
6379
|
+
if (w) opts.arrowheadWidth = xsdLineEndSize.from(w);
|
|
6097
6380
|
}
|
|
6098
6381
|
const tailEnd = findChild(ln, "a:tailEnd");
|
|
6099
6382
|
if (tailEnd) {
|
|
@@ -7209,12 +7492,14 @@ function extractCommentText(txBody) {
|
|
|
7209
7492
|
}
|
|
7210
7493
|
//#endregion
|
|
7211
7494
|
//#region src/patcher/from-pptx.ts
|
|
7495
|
+
/** Reusable TextEncoder (stateless, safe to share). */
|
|
7496
|
+
const encoder = new TextEncoder();
|
|
7212
7497
|
const PatchType = { PARAGRAPH: "paragraph" };
|
|
7213
7498
|
const formatter = new Formatter();
|
|
7214
7499
|
const pptxReplacer = createReplacer({
|
|
7215
7500
|
ns: PPTX_NS,
|
|
7216
7501
|
formatChild: (child, context) => {
|
|
7217
|
-
return [
|
|
7502
|
+
return [xml2js(formatter.formatToXml(child, context), { captureSpacesBetweenElements: true }).elements[0]];
|
|
7218
7503
|
},
|
|
7219
7504
|
preserveSpace: false
|
|
7220
7505
|
});
|
|
@@ -7275,7 +7560,7 @@ const patchPresentation = async ({ outputType, data, patches, keepOriginalStyles
|
|
|
7275
7560
|
if (contentTypes) for (const [contentType, extension] of IMAGE_CONTENT_TYPES) appendContentType(contentTypes, contentType, extension);
|
|
7276
7561
|
}
|
|
7277
7562
|
const files = {};
|
|
7278
|
-
for (const [key, value] of xmlMap) files[key] =
|
|
7563
|
+
for (const [key, value] of xmlMap) files[key] = encoder.encode(js2xml(value));
|
|
7279
7564
|
for (const [key, value] of binaryMap) files[key] = value;
|
|
7280
7565
|
return await zipAndConvert(files, outputType, OoxmlMimeType.PPTX);
|
|
7281
7566
|
};
|
|
@@ -7285,8 +7570,8 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
7285
7570
|
Background: () => Background,
|
|
7286
7571
|
BevelPresetType: () => BevelPresetType,
|
|
7287
7572
|
BlipFill: () => BlipFill,
|
|
7573
|
+
Chart: () => Chart,
|
|
7288
7574
|
ChartCollection: () => ChartCollection,
|
|
7289
|
-
ChartFrame: () => ChartFrame,
|
|
7290
7575
|
ChartSpace: () => ChartSpace,
|
|
7291
7576
|
CompoundLine: () => CompoundLine,
|
|
7292
7577
|
ConnectorShape: () => ConnectorShape,
|
|
@@ -7297,6 +7582,7 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
7297
7582
|
DefaultSlideLayout: () => DefaultSlideLayout,
|
|
7298
7583
|
DefaultSlideMaster: () => DefaultSlideMaster,
|
|
7299
7584
|
DefaultTheme: () => DefaultTheme,
|
|
7585
|
+
DrawingTable: () => DrawingTable,
|
|
7300
7586
|
EndParagraphRunProperties: () => EndParagraphRunProperties,
|
|
7301
7587
|
Field: () => Field,
|
|
7302
7588
|
File: () => File,
|
|
@@ -7324,7 +7610,6 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
7324
7610
|
PresetDash: () => PresetDash,
|
|
7325
7611
|
PresetGeometry: () => PresetGeometry,
|
|
7326
7612
|
PresetMaterialType: () => PresetMaterialType,
|
|
7327
|
-
PrettifyType: () => PrettifyType,
|
|
7328
7613
|
ReflectionAlignment: () => ReflectionAlignment,
|
|
7329
7614
|
Relationships: () => Relationships,
|
|
7330
7615
|
RunProperties: () => RunProperties,
|
|
@@ -7335,12 +7620,11 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
7335
7620
|
SlideLayout: () => SlideLayout,
|
|
7336
7621
|
SlideNumberField: () => SlideNumberField,
|
|
7337
7622
|
SlideSizePreset: () => SlideSizePreset,
|
|
7338
|
-
|
|
7623
|
+
SmartArt: () => SmartArt,
|
|
7339
7624
|
StrikeStyle: () => StrikeStyle,
|
|
7340
7625
|
Table: () => Table,
|
|
7341
7626
|
TableCell: () => TableCell,
|
|
7342
7627
|
TableCellProperties: () => TableCellProperties,
|
|
7343
|
-
TableFrame: () => TableFrame,
|
|
7344
7628
|
TableProperties: () => TableProperties,
|
|
7345
7629
|
TableRow: () => TableRow,
|
|
7346
7630
|
Text: () => Text,
|
|
@@ -7387,6 +7671,6 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
7387
7671
|
uniqueUuid: () => uniqueUuid
|
|
7388
7672
|
}), util_exports);
|
|
7389
7673
|
//#endregion
|
|
7390
|
-
export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill,
|
|
7674
|
+
export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill, Chart, ChartCollection, ChartSpace, CompoundLine, ConnectorShape, ContentTypes, CoreProperties, DateTimeField, DefaultNotesMaster, DefaultSlideLayout, DefaultSlideMaster, DefaultTheme, DrawingTable, EndParagraphRunProperties, Field, File, File as Presentation, GroupShape, GroupShapeProperties, GroupTransform2D, HeaderFooter, LineCap, LineJoin, LineShape, Media, NonVisualDrawingProperties, NonVisualPictureProperties, NonVisualShapeProperties, NotesSlide, Packer, Paragraph, ParagraphProperties, PatchType, PathShadeType, PenAlignment, Picture, PresentationWrapper, PresetDash, PresetGeometry, PresetMaterialType, ReflectionAlignment, Relationships, RunProperties, Shape, ShapeProperties, ShapeTree, Slide, SlideLayout, SlideNumberField, SlideSizePreset, SmartArt, StrikeStyle, Table, TableCell, TableCellProperties, TableProperties, TableRow, Text, TextAlignment, TextBody, TextCapitalization, TextRun, TileFlipMode, Transform2D, Transition, UnderlineStyle, VerticalAlignment, VideoFrame, buildFill, coerceChild, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertPixelsToEmu, convertPointsToEmu, createBevel, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createGradientFill, createGradientStop, createOutline, createOutlineCompat, createPptxEffectList, createScene3D, createShape3D, createTransformation, extractBlipFillMedia, hashedId, parseArchive, parsePptx, parsePresentation, patchPresentation, percentToTHousandths, uniqueId, uniqueNumericIdCreator, uniqueUuid };
|
|
7391
7675
|
|
|
7392
7676
|
//# sourceMappingURL=index.mjs.map
|