@office-open/pptx 0.3.1 → 0.3.3
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 +27 -8
- package/dist/index.d.mts +17 -34
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +382 -293
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as __reExport, r as __require, t as __exportAll } from "./_chunks/chunk-C8fdooHg.mjs";
|
|
2
|
-
import { AppProperties, BaseXmlComponent, BuilderElement, Formatter, ImportedXmlComponent, NextAttributeComponent, RawPassthrough, Relationships, StringContainer, XmlComponent, chartAttr, convertEmuToInches as emusToInches, convertEmuToPixels as emusToPixels, convertEmuToPoints as emusToPoints, convertInchesToEmu as inchesToEmus, convertPixelsToEmu as pixelsToEmus, convertPointsToEmu as pointsToEmus, getImageType, hashedId, isRaw, parseCoreProperties, parseRels, readAllXmlParts, readXmlFromZip, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, unzipToMap, wrapEl } from "@office-open/core";
|
|
2
|
+
import { AppProperties, BaseXmlComponent, BuilderElement, Formatter, ImportedXmlComponent, NextAttributeComponent, OoxmlMimeType, PrettifyType, RawPassthrough, Relationships, StringContainer, XmlComponent, addSmartArtRelationships, chartAttr, collectPlaceholderKeys, convertEmuToInches as emusToInches, convertEmuToPixels as emusToPixels, convertEmuToPoints as emusToPoints, convertInchesToEmu as inchesToEmus, convertOutput, convertPixelsToEmu as pixelsToEmus, convertPointsToEmu as pointsToEmus, convertPrettifyType, escapeRegex, formatId, getImageType, getReferencedMedia, hasPlaceholders, hashedId, isRaw, parseCoreProperties, parseRels, readAllXmlParts, readXmlFromZip, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, unzipToMap, wrapEl } from "@office-open/core";
|
|
3
3
|
import { ChartCollection, ChartTitle, createChartType } from "@office-open/core/chart";
|
|
4
|
+
import { attr, attrBool, attrNum, attrs, children, escapeXml, findChild, findDeep, textOf, xml } from "@office-open/xml";
|
|
4
5
|
import { BevelPresetType, CompoundLine, LineCap, LineJoin, PathShadeType, PenAlignment, PresetDash, PresetMaterialType, TileFlipMode, buildFill, createBevel, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createGradientFill, createGradientStop, createOutline, createOutline as createOutline$1, createScene3D, createShape3D, extractBlipFillMedia } from "@office-open/core/drawingml";
|
|
5
6
|
import { COLOR_CATEGORIES, LAYOUT_CATEGORIES, STYLE_CATEGORIES, SmartArtCollection, createDataModel } from "@office-open/core/smartart";
|
|
6
7
|
import { Readable } from "stream";
|
|
7
8
|
import { Zip, ZipDeflate, ZipPassThrough, zipSync } from "fflate";
|
|
8
|
-
import { attr, attrBool, attrNum, children, findChild, findDeep, textOf, xml } from "@office-open/xml";
|
|
9
9
|
export * from "@office-open/core/values";
|
|
10
10
|
//#region src/file/content-types/content-types.ts
|
|
11
11
|
/**
|
|
@@ -378,6 +378,9 @@ var GroupShapeNonVisualProperties = class extends BuilderElement {
|
|
|
378
378
|
function buildEndParagraphRunProperties(lang = "en-US") {
|
|
379
379
|
return { "a:endParaRPr": { _attr: { lang } } };
|
|
380
380
|
}
|
|
381
|
+
function buildEndParagraphRunPropertiesXml(lang = "en-US") {
|
|
382
|
+
return `<a:endParaRPr${attrs({ lang })}/>`;
|
|
383
|
+
}
|
|
381
384
|
/**
|
|
382
385
|
* a:endParaRPr — End paragraph run properties.
|
|
383
386
|
* Lazy: stores lang, builds XML object in prepForXml.
|
|
@@ -458,7 +461,48 @@ var ParagraphProperties = class extends XmlComponent {
|
|
|
458
461
|
prepForXml(_context) {
|
|
459
462
|
return buildParagraphProperties(this.options);
|
|
460
463
|
}
|
|
464
|
+
toXml() {
|
|
465
|
+
return buildParagraphPropertiesXml(this.options);
|
|
466
|
+
}
|
|
461
467
|
};
|
|
468
|
+
function buildBulletChildrenXml(options) {
|
|
469
|
+
if (options.type === "none") return "<a:buNone/>";
|
|
470
|
+
let s = "";
|
|
471
|
+
if (options.color) s += `<a:buClr><a:srgbClr${attrs({ val: options.color.replace("#", "") })}/></a:buClr>`;
|
|
472
|
+
if (options.size !== void 0) s += `<a:buSzPct${attrs({ val: `${options.size}%` })}/>`;
|
|
473
|
+
s += `<a:buFont${attrs({
|
|
474
|
+
typeface: "Arial",
|
|
475
|
+
panose: "020B0604020202020204",
|
|
476
|
+
pitchFamily: "34",
|
|
477
|
+
charset: "0"
|
|
478
|
+
})}/>`;
|
|
479
|
+
if (options.type === "char") s += `<a:buChar${attrs({ char: options.char ?? "•" })}/>`;
|
|
480
|
+
else if (options.type === "autoNum") {
|
|
481
|
+
const buAttrs = { type: options.format ?? "arabicPeriod" };
|
|
482
|
+
if (options.startAt !== void 0) buAttrs.startAt = options.startAt;
|
|
483
|
+
s += `<a:buAutoNum${attrs(buAttrs)}/>`;
|
|
484
|
+
}
|
|
485
|
+
return s;
|
|
486
|
+
}
|
|
487
|
+
function buildParagraphPropertiesXml(options) {
|
|
488
|
+
const attrStr = attrs({
|
|
489
|
+
algn: options.alignment ? TextAlignment[options.alignment] : void 0,
|
|
490
|
+
lvl: options.indentLevel,
|
|
491
|
+
marL: options.marginIndent,
|
|
492
|
+
marR: options.marginRight,
|
|
493
|
+
defTabSz: options.defTabSize
|
|
494
|
+
});
|
|
495
|
+
const body = [];
|
|
496
|
+
if (options.lineSpacing !== void 0) body.push(`<a:lnSpc><a:spcPct${attrs({ val: options.lineSpacing * 1e3 })}/></a:lnSpc>`);
|
|
497
|
+
if (options.lineSpacingPoints !== void 0) body.push(`<a:lnSpc><a:spcPts${attrs({ val: options.lineSpacingPoints * 100 })}/></a:lnSpc>`);
|
|
498
|
+
if (options.marginBottom !== void 0 || options.marginTop !== void 0) body.push(`<a:spcAft><a:spcPts${attrs({ val: options.marginBottom ?? 0 })}/></a:spcAft>`);
|
|
499
|
+
if (options.marginTop !== void 0) body.push(`<a:spcBef><a:spcPts${attrs({ val: options.marginTop })}/></a:spcBef>`);
|
|
500
|
+
if (options.bullet) body.push(buildBulletChildrenXml(options.bullet));
|
|
501
|
+
else if (options.bulletNone !== false) body.push("<a:buNone/>");
|
|
502
|
+
if (!attrStr && body.length === 0) return "";
|
|
503
|
+
if (body.length === 0) return `<a:pPr${attrStr}/>`;
|
|
504
|
+
return `<a:pPr${attrStr}>${body.join("")}</a:pPr>`;
|
|
505
|
+
}
|
|
462
506
|
//#endregion
|
|
463
507
|
//#region src/file/shape/paragraph/run-properties.ts
|
|
464
508
|
let nextHyperlinkId = 1;
|
|
@@ -535,7 +579,48 @@ var RunProperties = class extends XmlComponent {
|
|
|
535
579
|
if (opts.fill !== void 0) fillObj = buildFill(opts.fill).prepForXml(context) ?? void 0;
|
|
536
580
|
return buildRunProperties(opts, hyperlinkKey, fillObj);
|
|
537
581
|
}
|
|
582
|
+
toXml(context) {
|
|
583
|
+
const opts = this.options;
|
|
584
|
+
let hyperlinkKey;
|
|
585
|
+
if (opts.hyperlink) {
|
|
586
|
+
hyperlinkKey = `hlink_${nextHyperlinkId++}`;
|
|
587
|
+
context.fileData?.Hyperlinks?.addHyperlink(hyperlinkKey, opts.hyperlink.url, opts.hyperlink.tooltip);
|
|
588
|
+
}
|
|
589
|
+
let fillObj;
|
|
590
|
+
if (opts.fill !== void 0) fillObj = buildFill(opts.fill).prepForXml(context) ?? void 0;
|
|
591
|
+
return buildRunPropertiesXml(opts, hyperlinkKey, fillObj);
|
|
592
|
+
}
|
|
538
593
|
};
|
|
594
|
+
/**
|
|
595
|
+
* String version of buildRunProperties for zero-allocation serialization.
|
|
596
|
+
*/
|
|
597
|
+
function buildRunPropertiesXml(options, hyperlinkKey, fillObject) {
|
|
598
|
+
const a = {};
|
|
599
|
+
if (options.fontSize) a.sz = options.fontSize * 100;
|
|
600
|
+
if (options.bold !== void 0) a.b = options.bold;
|
|
601
|
+
if (options.italic !== void 0) a.i = options.italic;
|
|
602
|
+
if (options.underline) a.u = UnderlineStyle[options.underline];
|
|
603
|
+
if (options.lang) a.lang = options.lang;
|
|
604
|
+
if (options.strike) a.strike = StrikeStyle[options.strike];
|
|
605
|
+
if (options.baseline !== void 0) a.baseline = options.baseline;
|
|
606
|
+
if (options.capitalization) a.cap = TextCapitalization[options.capitalization] ?? options.capitalization;
|
|
607
|
+
if (options.spacing !== void 0) a.spc = options.spacing;
|
|
608
|
+
if (options.noProof !== void 0) a.noProof = options.noProof;
|
|
609
|
+
if (options.dirty !== void 0) a.dirty = options.dirty;
|
|
610
|
+
const attrStr = attrs(a);
|
|
611
|
+
const body = [];
|
|
612
|
+
if (options.font) body.push(`<a:latin${attrs({ typeface: options.font })}/><a:ea${attrs({ typeface: options.font })}/>`);
|
|
613
|
+
if (options.hyperlink && hyperlinkKey) {
|
|
614
|
+
const h = { "r:id": `{hlink:${hyperlinkKey}}` };
|
|
615
|
+
if (options.hyperlink.tooltip) h.tooltip = options.hyperlink.tooltip;
|
|
616
|
+
body.push(`<a:hlinkClick${attrs(h)}/>`);
|
|
617
|
+
}
|
|
618
|
+
if (options.rightToLeft !== void 0) body.push(`<a:rtl${attrs({ val: options.rightToLeft ? 1 : 0 })}/>`);
|
|
619
|
+
if (fillObject) body.push(xml(fillObject));
|
|
620
|
+
if (!attrStr && body.length === 0) return "";
|
|
621
|
+
if (body.length === 0) return `<a:rPr${attrStr}/>`;
|
|
622
|
+
return `<a:rPr${attrStr}>${body.join("")}</a:rPr>`;
|
|
623
|
+
}
|
|
539
624
|
//#endregion
|
|
540
625
|
//#region src/file/shape/paragraph/run.ts
|
|
541
626
|
/**
|
|
@@ -557,6 +642,16 @@ var Run = class extends XmlComponent {
|
|
|
557
642
|
if (this.options.text) children.push({ "a:t": [this.options.text] });
|
|
558
643
|
return { "a:r": children.length === 0 ? {} : children.length === 1 && "_attr" in children[0] ? children[0] : children };
|
|
559
644
|
}
|
|
645
|
+
toXml(context) {
|
|
646
|
+
let s = "<a:r>";
|
|
647
|
+
if (RunProperties.hasProperties(this.options)) {
|
|
648
|
+
const rp = new RunProperties(this.options);
|
|
649
|
+
s += rp.toXml(context);
|
|
650
|
+
}
|
|
651
|
+
if (this.options.text) s += `<a:t>${escapeXml(this.options.text)}</a:t>`;
|
|
652
|
+
s += "</a:r>";
|
|
653
|
+
return s;
|
|
654
|
+
}
|
|
560
655
|
};
|
|
561
656
|
//#endregion
|
|
562
657
|
//#region src/file/shape/paragraph/paragraph.ts
|
|
@@ -581,6 +676,15 @@ var Paragraph = class extends XmlComponent {
|
|
|
581
676
|
children.push(buildEndParagraphRunProperties());
|
|
582
677
|
return { "a:p": children };
|
|
583
678
|
}
|
|
679
|
+
toXml(context) {
|
|
680
|
+
let s = "<a:p>";
|
|
681
|
+
const pPr = buildParagraphPropertiesXml(this.options.properties ?? {});
|
|
682
|
+
if (pPr) s += pPr;
|
|
683
|
+
if (this.options.children) for (const child of this.options.children) s += child.toXml(context);
|
|
684
|
+
s += buildEndParagraphRunPropertiesXml();
|
|
685
|
+
s += "</a:p>";
|
|
686
|
+
return s;
|
|
687
|
+
}
|
|
584
688
|
};
|
|
585
689
|
//#endregion
|
|
586
690
|
//#region src/file/table/table-cell-properties.ts
|
|
@@ -697,6 +801,25 @@ function buildBodyPr(options) {
|
|
|
697
801
|
bodyPrContent.push(...bodyPrChildren);
|
|
698
802
|
return { "a:bodyPr": bodyPrContent.length === 1 && "_attr" in bodyPrContent[0] ? bodyPrContent[0] : bodyPrContent.length > 0 ? bodyPrContent : {} };
|
|
699
803
|
}
|
|
804
|
+
function buildBodyPrXml(options) {
|
|
805
|
+
let s = "<a:bodyPr";
|
|
806
|
+
const a = {};
|
|
807
|
+
if (options.vertical) a.vert = options.vertical;
|
|
808
|
+
if (options.anchor) a.anchor = VerticalAlignment[options.anchor];
|
|
809
|
+
if (options.wrap) a.wrap = options.wrap;
|
|
810
|
+
if (options.margins?.top !== void 0) a.tIns = options.margins.top;
|
|
811
|
+
if (options.margins?.bottom !== void 0) a.bIns = options.margins.bottom;
|
|
812
|
+
if (options.margins?.left !== void 0) a.lIns = options.margins.left;
|
|
813
|
+
if (options.margins?.right !== void 0) a.rIns = options.margins.right;
|
|
814
|
+
if (options.columns !== void 0) a.numCol = options.columns;
|
|
815
|
+
if (options.columnSpacing !== void 0) a.spcCol = options.columnSpacing * 100;
|
|
816
|
+
s += attrs(a);
|
|
817
|
+
let inner = "";
|
|
818
|
+
if (options.autoFit === "normal") inner += "<a:normAutofit/>";
|
|
819
|
+
else if (options.autoFit === "shape") inner += "<a:spAutoFit/>";
|
|
820
|
+
else if (options.autoFit === "none") inner += "<a:noAutofit/>";
|
|
821
|
+
return inner ? `${s}>${inner}</a:bodyPr>` : `${s}/>`;
|
|
822
|
+
}
|
|
700
823
|
/**
|
|
701
824
|
* p:txBody — Text body within a shape.
|
|
702
825
|
* Lazy: stores options, builds XML object in prepForXml.
|
|
@@ -721,6 +844,18 @@ var TextBody = class extends XmlComponent {
|
|
|
721
844
|
}
|
|
722
845
|
return { "p:txBody": children };
|
|
723
846
|
}
|
|
847
|
+
toXml(context) {
|
|
848
|
+
let s = "<p:txBody>";
|
|
849
|
+
s += buildBodyPrXml(this.options);
|
|
850
|
+
s += "<a:lstStyle/>";
|
|
851
|
+
if (this.options.paragraphs) for (const p of this.options.paragraphs) {
|
|
852
|
+
const para = typeof p === "string" ? new Paragraph({ children: [new Run({ text: p })] }) : p;
|
|
853
|
+
s += para.toXml(context);
|
|
854
|
+
}
|
|
855
|
+
else s += new Paragraph().toXml(context);
|
|
856
|
+
s += "</p:txBody>";
|
|
857
|
+
return s;
|
|
858
|
+
}
|
|
724
859
|
};
|
|
725
860
|
//#endregion
|
|
726
861
|
//#region src/file/notes/notes-slide.ts
|
|
@@ -931,7 +1066,7 @@ var PresentationProperties = class PresentationProperties extends ImportedXmlCom
|
|
|
931
1066
|
};
|
|
932
1067
|
//#endregion
|
|
933
1068
|
//#region src/file/presentation/presentation.ts
|
|
934
|
-
const
|
|
1069
|
+
const DEFAULT_TEXT_STYLE_XML = `<p:defaultTextStyle xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
|
|
935
1070
|
<a:defPPr><a:defRPr/></a:defPPr>
|
|
936
1071
|
<a:lvl1pPr marL="0" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
|
|
937
1072
|
<a:defRPr sz="1800" kern="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/></a:defRPr>
|
|
@@ -960,7 +1095,8 @@ const DEFAULT_TEXT_STYLE_OBJ = ImportedXmlComponent.fromXmlString(`<p:defaultTex
|
|
|
960
1095
|
<a:lvl9pPr marL="3657600" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
|
|
961
1096
|
<a:defRPr sz="1800" kern="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/></a:defRPr>
|
|
962
1097
|
</a:lvl9pPr>
|
|
963
|
-
</p:defaultTextStyle
|
|
1098
|
+
</p:defaultTextStyle>`;
|
|
1099
|
+
const DEFAULT_TEXT_STYLE_OBJ = ImportedXmlComponent.fromXmlString(DEFAULT_TEXT_STYLE_XML).prepForXml({ stack: [] });
|
|
964
1100
|
/**
|
|
965
1101
|
* p:presentation — Root element of a PPTX file.
|
|
966
1102
|
* Lazy: stores options, builds XML object directly in prepForXml.
|
|
@@ -1002,6 +1138,22 @@ var Presentation = class extends BaseXmlComponent {
|
|
|
1002
1138
|
children.push(DEFAULT_TEXT_STYLE_OBJ);
|
|
1003
1139
|
return { "p:presentation": children };
|
|
1004
1140
|
}
|
|
1141
|
+
toXml(_context) {
|
|
1142
|
+
const opts = this.options;
|
|
1143
|
+
const cx = opts.slideWidth ?? 9144e3;
|
|
1144
|
+
const cy = opts.slideHeight ?? 6858e3;
|
|
1145
|
+
const typeAttr = cx === 914400 && cy === 6858e3 ? " type=\"screen4x3\"" : "";
|
|
1146
|
+
let s = `<p:presentation 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">`;
|
|
1147
|
+
s += "<p:sldMasterIdLst><p:sldMasterId id=\"2147483648\" r:id=\"rId1\"/></p:sldMasterIdLst>";
|
|
1148
|
+
s += "<p:sldIdLst>";
|
|
1149
|
+
for (let i = 0; i < opts.slideIds.length; i++) s += `<p:sldId id="${opts.slideIds[i]}" r:id="rId${i + 2}"/>`;
|
|
1150
|
+
s += "</p:sldIdLst>";
|
|
1151
|
+
s += `<p:sldSz cx="${cx}" cy="${cy}"${typeAttr}/>`;
|
|
1152
|
+
s += "<p:notesSz cx=\"6858000\" cy=\"9144000\"/>";
|
|
1153
|
+
s += DEFAULT_TEXT_STYLE_XML;
|
|
1154
|
+
s += "</p:presentation>";
|
|
1155
|
+
return s;
|
|
1156
|
+
}
|
|
1005
1157
|
};
|
|
1006
1158
|
//#endregion
|
|
1007
1159
|
//#region src/file/presentation/presentation-wrapper.ts
|
|
@@ -2238,6 +2390,49 @@ var Shape = class Shape extends XmlComponent {
|
|
|
2238
2390
|
if (txBodyObj) children.push(txBodyObj);
|
|
2239
2391
|
return { "p:sp": children };
|
|
2240
2392
|
}
|
|
2393
|
+
toXml(context) {
|
|
2394
|
+
const opts = this.options;
|
|
2395
|
+
const id = this.shapeId;
|
|
2396
|
+
const name = escapeXml(opts.name ?? `Shape ${id}`);
|
|
2397
|
+
let s = "<p:sp><p:nvSpPr>";
|
|
2398
|
+
s += `<p:cNvPr${attrs({
|
|
2399
|
+
id,
|
|
2400
|
+
name
|
|
2401
|
+
})}/>`;
|
|
2402
|
+
s += "<p:cNvSpPr/>";
|
|
2403
|
+
if (opts.placeholder) {
|
|
2404
|
+
const phAttrs = { type: opts.placeholder };
|
|
2405
|
+
if (opts.placeholderIndex !== void 0) phAttrs.idx = opts.placeholderIndex;
|
|
2406
|
+
s += `<p:nvPr><p:ph${attrs(phAttrs)}/></p:nvPr>`;
|
|
2407
|
+
} else s += "<p:nvPr/>";
|
|
2408
|
+
s += "</p:nvSpPr>";
|
|
2409
|
+
const spPrObj = new ShapeProperties({
|
|
2410
|
+
x: opts.x !== void 0 ? pixelsToEmus(opts.x) : void 0,
|
|
2411
|
+
y: opts.y !== void 0 ? pixelsToEmus(opts.y) : void 0,
|
|
2412
|
+
width: opts.width !== void 0 ? pixelsToEmus(opts.width) : void 0,
|
|
2413
|
+
height: opts.height !== void 0 ? pixelsToEmus(opts.height) : void 0,
|
|
2414
|
+
geometry: opts.geometry,
|
|
2415
|
+
fill: opts.fill,
|
|
2416
|
+
outline: opts.outline,
|
|
2417
|
+
effects: opts.effects,
|
|
2418
|
+
flipH: opts.flipH,
|
|
2419
|
+
rotation: opts.rotation
|
|
2420
|
+
}).prepForXml(context);
|
|
2421
|
+
if (spPrObj) s += xml(spPrObj);
|
|
2422
|
+
const txBodyOpts = {
|
|
2423
|
+
paragraphs: opts.paragraphs ?? (opts.text ? [new Paragraph({ children: [new Run({ text: opts.text })] })] : void 0),
|
|
2424
|
+
vertical: opts.textVertical,
|
|
2425
|
+
anchor: opts.textAnchor,
|
|
2426
|
+
autoFit: opts.textAutoFit,
|
|
2427
|
+
wrap: opts.textWrap,
|
|
2428
|
+
margins: opts.textMargins,
|
|
2429
|
+
columns: opts.textColumns,
|
|
2430
|
+
columnSpacing: opts.textColumnSpacing
|
|
2431
|
+
};
|
|
2432
|
+
s += new TextBody(txBodyOpts).toXml(context);
|
|
2433
|
+
s += "</p:sp>";
|
|
2434
|
+
return s;
|
|
2435
|
+
}
|
|
2241
2436
|
};
|
|
2242
2437
|
//#endregion
|
|
2243
2438
|
//#region src/file/transition/transition.ts
|
|
@@ -2289,47 +2484,10 @@ var Transition = class extends BaseXmlComponent {
|
|
|
2289
2484
|
};
|
|
2290
2485
|
//#endregion
|
|
2291
2486
|
//#region src/file/slide/slide.ts
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
const
|
|
2296
|
-
{ "p:cNvPr": { _attr: {
|
|
2297
|
-
id: 1,
|
|
2298
|
-
name: ""
|
|
2299
|
-
} } },
|
|
2300
|
-
{ "p:cNvGrpSpPr": {} },
|
|
2301
|
-
{ "p:nvPr": {} }
|
|
2302
|
-
] };
|
|
2303
|
-
/**
|
|
2304
|
-
* p:grpSpPr singleton — group shape properties with default transform.
|
|
2305
|
-
*/
|
|
2306
|
-
const GRP_SP_PR = { "p:grpSpPr": { "a:xfrm": [
|
|
2307
|
-
{ "a:off": { _attr: {
|
|
2308
|
-
x: 0,
|
|
2309
|
-
y: 0
|
|
2310
|
-
} } },
|
|
2311
|
-
{ "a:ext": { _attr: {
|
|
2312
|
-
cx: 0,
|
|
2313
|
-
cy: 0
|
|
2314
|
-
} } },
|
|
2315
|
-
{ "a:chOff": { _attr: {
|
|
2316
|
-
x: 0,
|
|
2317
|
-
y: 0
|
|
2318
|
-
} } },
|
|
2319
|
-
{ "a:chExt": { _attr: {
|
|
2320
|
-
cx: 0,
|
|
2321
|
-
cy: 0
|
|
2322
|
-
} } }
|
|
2323
|
-
] } };
|
|
2324
|
-
/**
|
|
2325
|
-
* p:clrMapOvr singleton — color map override.
|
|
2326
|
-
*/
|
|
2327
|
-
const CLR_MAP_OVR = { "p:clrMapOvr": [{ "a:masterClrMapping": {} }] };
|
|
2328
|
-
const XMLNS_ATTRS = { _attr: {
|
|
2329
|
-
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
2330
|
-
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
2331
|
-
"xmlns:p": "http://schemas.openxmlformats.org/presentationml/2006/main"
|
|
2332
|
-
} };
|
|
2487
|
+
const NV_GRP_SP_PR = "<p:nvGrpSpPr><p:cNvPr id=\"1\" name=\"\"/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr>";
|
|
2488
|
+
const GRP_SP_PR = "<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>";
|
|
2489
|
+
const CLR_MAP_OVR = "<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>";
|
|
2490
|
+
const XMLNS = " 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\"";
|
|
2333
2491
|
function collectAnimations(children) {
|
|
2334
2492
|
const entries = [];
|
|
2335
2493
|
for (const child of children) if (child instanceof Shape) {
|
|
@@ -2359,20 +2517,48 @@ var Slide = class extends BaseXmlComponent {
|
|
|
2359
2517
|
}
|
|
2360
2518
|
prepForXml(context) {
|
|
2361
2519
|
const children = [];
|
|
2362
|
-
children.push(
|
|
2520
|
+
children.push({ _attr: {
|
|
2521
|
+
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
2522
|
+
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
2523
|
+
"xmlns:p": "http://schemas.openxmlformats.org/presentationml/2006/main"
|
|
2524
|
+
} });
|
|
2363
2525
|
const cSldChildren = [];
|
|
2364
2526
|
if (this.background) {
|
|
2365
2527
|
const bgObj = this.background.prepForXml(context);
|
|
2366
2528
|
if (bgObj) cSldChildren.push(bgObj);
|
|
2367
2529
|
}
|
|
2368
|
-
const spTreeChildren = [
|
|
2530
|
+
const spTreeChildren = [{ "p:nvGrpSpPr": [
|
|
2531
|
+
{ "p:cNvPr": { _attr: {
|
|
2532
|
+
id: 1,
|
|
2533
|
+
name: ""
|
|
2534
|
+
} } },
|
|
2535
|
+
{ "p:cNvGrpSpPr": {} },
|
|
2536
|
+
{ "p:nvPr": {} }
|
|
2537
|
+
] }, { "p:grpSpPr": { "a:xfrm": [
|
|
2538
|
+
{ "a:off": { _attr: {
|
|
2539
|
+
x: 0,
|
|
2540
|
+
y: 0
|
|
2541
|
+
} } },
|
|
2542
|
+
{ "a:ext": { _attr: {
|
|
2543
|
+
cx: 0,
|
|
2544
|
+
cy: 0
|
|
2545
|
+
} } },
|
|
2546
|
+
{ "a:chOff": { _attr: {
|
|
2547
|
+
x: 0,
|
|
2548
|
+
y: 0
|
|
2549
|
+
} } },
|
|
2550
|
+
{ "a:chExt": { _attr: {
|
|
2551
|
+
cx: 0,
|
|
2552
|
+
cy: 0
|
|
2553
|
+
} } }
|
|
2554
|
+
] } }];
|
|
2369
2555
|
for (const child of this.children) {
|
|
2370
2556
|
const obj = child.prepForXml(context);
|
|
2371
2557
|
if (obj) spTreeChildren.push(obj);
|
|
2372
2558
|
}
|
|
2373
2559
|
cSldChildren.push({ "p:spTree": spTreeChildren });
|
|
2374
2560
|
children.push({ "p:cSld": cSldChildren });
|
|
2375
|
-
children.push(
|
|
2561
|
+
children.push({ "p:clrMapOvr": [{ "a:masterClrMapping": {} }] });
|
|
2376
2562
|
if (this.transition) {
|
|
2377
2563
|
const transObj = buildTransition(this.transition);
|
|
2378
2564
|
if (transObj) children.push(transObj);
|
|
@@ -2384,6 +2570,35 @@ var Slide = class extends BaseXmlComponent {
|
|
|
2384
2570
|
}
|
|
2385
2571
|
return { "p:sld": children };
|
|
2386
2572
|
}
|
|
2573
|
+
toXml(context) {
|
|
2574
|
+
let s = `<p:sld${XMLNS}>`;
|
|
2575
|
+
s += "<p:cSld>";
|
|
2576
|
+
if (this.background) {
|
|
2577
|
+
const bgObj = this.background.prepForXml(context);
|
|
2578
|
+
if (bgObj) s += xml(bgObj);
|
|
2579
|
+
}
|
|
2580
|
+
s += "<p:spTree>";
|
|
2581
|
+
s += NV_GRP_SP_PR;
|
|
2582
|
+
s += GRP_SP_PR;
|
|
2583
|
+
for (const child of this.children) if (typeof child.toXml === "function") s += child.toXml(context);
|
|
2584
|
+
else {
|
|
2585
|
+
const obj = child.prepForXml(context);
|
|
2586
|
+
if (obj) s += xml(obj);
|
|
2587
|
+
}
|
|
2588
|
+
s += "</p:spTree></p:cSld>";
|
|
2589
|
+
s += CLR_MAP_OVR;
|
|
2590
|
+
if (this.transition) {
|
|
2591
|
+
const transObj = buildTransition(this.transition);
|
|
2592
|
+
if (transObj) s += xml(transObj);
|
|
2593
|
+
}
|
|
2594
|
+
const animations = collectAnimations(this.children);
|
|
2595
|
+
if (animations.length > 0) {
|
|
2596
|
+
const timingObj = new SlideTiming(animations).prepForXml(context);
|
|
2597
|
+
if (timingObj) s += xml(timingObj);
|
|
2598
|
+
}
|
|
2599
|
+
s += "</p:sld>";
|
|
2600
|
+
return s;
|
|
2601
|
+
}
|
|
2387
2602
|
};
|
|
2388
2603
|
//#endregion
|
|
2389
2604
|
//#region src/file/table-styles.ts
|
|
@@ -4274,116 +4489,46 @@ function getColorXml(colorId) {
|
|
|
4274
4489
|
/** Minimal drawing cache for PPTX SmartArt (PowerPoint auto-regenerates this on open) */
|
|
4275
4490
|
const DEFAULT_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><dsp:drawing xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:dsp=\"http://schemas.microsoft.com/office/drawing/2008/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><dsp:spTree><dsp:nvGrpSpPr><dsp:cNvPr id=\"0\" name=\"\"/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr><dsp:grpSpPr/></dsp:spTree></dsp:drawing>";
|
|
4276
4491
|
//#endregion
|
|
4277
|
-
//#region src/export/packer/
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
}
|
|
4286
|
-
};
|
|
4287
|
-
//#endregion
|
|
4288
|
-
//#region src/export/packer/hyperlink-replacer.ts
|
|
4289
|
-
var HyperlinkReplacer = class {
|
|
4290
|
-
replace(xmlData, hyperlinks, offset) {
|
|
4291
|
-
let currentXml = xmlData;
|
|
4292
|
-
hyperlinks.forEach((hyperlink, i) => {
|
|
4293
|
-
currentXml = currentXml.replace(new RegExp(`\\{hlink:${hyperlink.key}\\}`, "g"), `rId${offset + i}`);
|
|
4294
|
-
});
|
|
4295
|
-
return currentXml;
|
|
4296
|
-
}
|
|
4297
|
-
};
|
|
4298
|
-
//#endregion
|
|
4299
|
-
//#region src/export/packer/image-replacer.ts
|
|
4300
|
-
var ImageReplacer = class {
|
|
4301
|
-
replace(xmlData, mediaData, offset) {
|
|
4302
|
-
let currentXmlData = xmlData;
|
|
4303
|
-
mediaData.forEach((image, i) => {
|
|
4304
|
-
currentXmlData = currentXmlData.replace(new RegExp(`{${image.fileName}}`, "g"), `rId${offset + i}`);
|
|
4305
|
-
});
|
|
4306
|
-
return currentXmlData;
|
|
4307
|
-
}
|
|
4308
|
-
getMediaData(xmlData, media) {
|
|
4309
|
-
return media.Array.filter((image) => xmlData.search(`{${image.fileName}}`) > 0);
|
|
4310
|
-
}
|
|
4311
|
-
};
|
|
4312
|
-
//#endregion
|
|
4313
|
-
//#region src/export/packer/media-replacer.ts
|
|
4314
|
-
var MediaReplacer = class {
|
|
4315
|
-
replaceMedia(xmlData, mediaData, offset) {
|
|
4316
|
-
let currentXmlData = xmlData;
|
|
4317
|
-
mediaData.forEach((media, i) => {
|
|
4318
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{media:${this.escapeRegex(media.fileName)}\\}`, "g"), `rId${offset + i}`);
|
|
4319
|
-
});
|
|
4320
|
-
return currentXmlData;
|
|
4321
|
-
}
|
|
4322
|
-
replaceVideo(xmlData, mediaData, offset) {
|
|
4323
|
-
let currentXmlData = xmlData;
|
|
4324
|
-
mediaData.forEach((media, i) => {
|
|
4325
|
-
currentXmlData = currentXmlData.replace(new RegExp(`\\{video:${this.escapeRegex(media.fileName)}\\}`, "g"), `rId${offset + i}`);
|
|
4326
|
-
});
|
|
4327
|
-
return currentXmlData;
|
|
4328
|
-
}
|
|
4329
|
-
getMediaRefs(xmlData, media) {
|
|
4330
|
-
const mediaPlaceholders = xmlData.matchAll(/\{media:([^}]+)\}/g);
|
|
4331
|
-
const keys = /* @__PURE__ */ new Set();
|
|
4332
|
-
for (const match of mediaPlaceholders) keys.add(match[1]);
|
|
4333
|
-
return media.Array.filter((m) => keys.has(m.fileName));
|
|
4334
|
-
}
|
|
4335
|
-
getVideoRefs(xmlData, media) {
|
|
4336
|
-
const videoPlaceholders = xmlData.matchAll(/\{video:([^}]+)\}/g);
|
|
4337
|
-
const keys = /* @__PURE__ */ new Set();
|
|
4338
|
-
for (const match of videoPlaceholders) keys.add(match[1]);
|
|
4339
|
-
return media.Array.filter((m) => keys.has(m.fileName));
|
|
4340
|
-
}
|
|
4341
|
-
escapeRegex(str) {
|
|
4342
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4343
|
-
}
|
|
4344
|
-
};
|
|
4492
|
+
//#region src/export/packer/hyperlink-placeholders.ts
|
|
4493
|
+
function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
|
|
4494
|
+
let result = xml;
|
|
4495
|
+
hyperlinks.forEach((h, i) => {
|
|
4496
|
+
result = result.replace(new RegExp(`\\{hlink:${escapeRegex(h.key)}\\}`, "g"), formatId(offset, i, "rId"));
|
|
4497
|
+
});
|
|
4498
|
+
return result;
|
|
4499
|
+
}
|
|
4345
4500
|
//#endregion
|
|
4346
|
-
//#region src/export/packer/
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
addRelationship(csOffset + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors", `../diagrams/colors${gi + 1}.xml`);
|
|
4374
|
-
addRelationship(csOffset + smartArtCount + i, "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing", `../diagrams/drawing${gi + 1}.xml`);
|
|
4375
|
-
});
|
|
4376
|
-
}
|
|
4377
|
-
};
|
|
4501
|
+
//#region src/export/packer/media-placeholders.ts
|
|
4502
|
+
function replaceMediaPlaceholders(xml, mediaData, offset) {
|
|
4503
|
+
let result = xml;
|
|
4504
|
+
mediaData.forEach((m, i) => {
|
|
4505
|
+
result = result.replace(new RegExp(`\\{media:${escapeRegex(m.fileName)}\\}`, "g"), formatId(offset, i, "rId"));
|
|
4506
|
+
});
|
|
4507
|
+
return result;
|
|
4508
|
+
}
|
|
4509
|
+
function replaceVideoPlaceholders(xml, mediaData, offset) {
|
|
4510
|
+
let result = xml;
|
|
4511
|
+
mediaData.forEach((m, i) => {
|
|
4512
|
+
result = result.replace(new RegExp(`\\{video:${escapeRegex(m.fileName)}\\}`, "g"), formatId(offset, i, "rId"));
|
|
4513
|
+
});
|
|
4514
|
+
return result;
|
|
4515
|
+
}
|
|
4516
|
+
function getMediaRefs(xml, mediaArray) {
|
|
4517
|
+
return collectRefs(xml, "media:", mediaArray);
|
|
4518
|
+
}
|
|
4519
|
+
function getVideoRefs(xml, mediaArray) {
|
|
4520
|
+
return collectRefs(xml, "video:", mediaArray);
|
|
4521
|
+
}
|
|
4522
|
+
function collectRefs(xml, prefix, mediaArray) {
|
|
4523
|
+
const pattern = new RegExp(`\\{${escapeRegex(prefix)}([^}]+)\\}`, "g");
|
|
4524
|
+
const keys = /* @__PURE__ */ new Set();
|
|
4525
|
+
for (const match of xml.matchAll(pattern)) keys.add(match[1]);
|
|
4526
|
+
return mediaArray.filter((m) => keys.has(m.fileName));
|
|
4527
|
+
}
|
|
4378
4528
|
//#endregion
|
|
4379
4529
|
//#region src/export/packer/next-compiler.ts
|
|
4380
4530
|
var Compiler = class {
|
|
4381
4531
|
formatter = new Formatter();
|
|
4382
|
-
imageReplacer = new ImageReplacer();
|
|
4383
|
-
chartReplacer = new ChartReplacer();
|
|
4384
|
-
hyperlinkReplacer = new HyperlinkReplacer();
|
|
4385
|
-
mediaReplacer = new MediaReplacer();
|
|
4386
|
-
smartArtReplacer = new SmartArtReplacer();
|
|
4387
4532
|
compile(file, prettifyXml, overrides = []) {
|
|
4388
4533
|
const declaration = true;
|
|
4389
4534
|
const indent = prettifyXml;
|
|
@@ -4393,10 +4538,7 @@ var Compiler = class {
|
|
|
4393
4538
|
};
|
|
4394
4539
|
const mapping = {
|
|
4395
4540
|
AppProperties: {
|
|
4396
|
-
data: xml(this.formatter.format(file.AppProperties, context), {
|
|
4397
|
-
declaration,
|
|
4398
|
-
indent
|
|
4399
|
-
}),
|
|
4541
|
+
data: xml(this.formatter.format(file.AppProperties, context), { declaration }),
|
|
4400
4542
|
path: "docProps/app.xml"
|
|
4401
4543
|
},
|
|
4402
4544
|
Properties: {
|
|
@@ -4412,38 +4554,23 @@ var Compiler = class {
|
|
|
4412
4554
|
}
|
|
4413
4555
|
};
|
|
4414
4556
|
mapping["Theme"] = {
|
|
4415
|
-
data:
|
|
4416
|
-
declaration,
|
|
4417
|
-
indent
|
|
4418
|
-
}),
|
|
4557
|
+
data: this.formatter.formatToXml(file.Theme, context, declaration),
|
|
4419
4558
|
path: "ppt/theme/theme1.xml"
|
|
4420
4559
|
};
|
|
4421
4560
|
mapping["TableStyles"] = {
|
|
4422
|
-
data:
|
|
4423
|
-
declaration,
|
|
4424
|
-
indent
|
|
4425
|
-
}),
|
|
4561
|
+
data: this.formatter.formatToXml(file.TableStyles, context, declaration),
|
|
4426
4562
|
path: "ppt/tableStyles.xml"
|
|
4427
4563
|
};
|
|
4428
4564
|
mapping["PresProps"] = {
|
|
4429
|
-
data:
|
|
4430
|
-
declaration,
|
|
4431
|
-
indent
|
|
4432
|
-
}),
|
|
4565
|
+
data: this.formatter.formatToXml(file.PresProps, context, declaration),
|
|
4433
4566
|
path: "ppt/presProps.xml"
|
|
4434
4567
|
};
|
|
4435
4568
|
mapping["ViewProps"] = {
|
|
4436
|
-
data:
|
|
4437
|
-
declaration,
|
|
4438
|
-
indent
|
|
4439
|
-
}),
|
|
4569
|
+
data: this.formatter.formatToXml(file.ViewProps, context, declaration),
|
|
4440
4570
|
path: "ppt/viewProps.xml"
|
|
4441
4571
|
};
|
|
4442
4572
|
mapping["SlideMaster"] = {
|
|
4443
|
-
data:
|
|
4444
|
-
declaration,
|
|
4445
|
-
indent
|
|
4446
|
-
}),
|
|
4573
|
+
data: this.formatter.formatToXml(file.SlideMaster, context, declaration),
|
|
4447
4574
|
path: "ppt/slideMasters/slideMaster1.xml"
|
|
4448
4575
|
};
|
|
4449
4576
|
mapping["SlideMasterRelationships"] = {
|
|
@@ -4451,10 +4578,7 @@ var Compiler = class {
|
|
|
4451
4578
|
path: "ppt/slideMasters/_rels/slideMaster1.xml.rels"
|
|
4452
4579
|
};
|
|
4453
4580
|
mapping["SlideLayout"] = {
|
|
4454
|
-
data:
|
|
4455
|
-
declaration,
|
|
4456
|
-
indent
|
|
4457
|
-
}),
|
|
4581
|
+
data: this.formatter.formatToXml(file.SlideLayout, context, declaration),
|
|
4458
4582
|
path: "ppt/slideLayouts/slideLayout1.xml"
|
|
4459
4583
|
};
|
|
4460
4584
|
mapping["SlideLayoutRelationships"] = {
|
|
@@ -4475,17 +4599,14 @@ var Compiler = class {
|
|
|
4475
4599
|
path: "ppt/notesMasters/_rels/notesMaster1.xml.rels"
|
|
4476
4600
|
};
|
|
4477
4601
|
}
|
|
4478
|
-
const presentationXml =
|
|
4479
|
-
declaration,
|
|
4480
|
-
indent
|
|
4481
|
-
});
|
|
4602
|
+
const presentationXml = this.formatter.formatToXml(file.PresentationWrapper.View, context, declaration);
|
|
4482
4603
|
let currentImageCount = 0;
|
|
4483
|
-
const mediaData =
|
|
4604
|
+
const mediaData = getReferencedMedia(presentationXml, file.Media.Array);
|
|
4484
4605
|
const presImageOffset = file.PresentationWrapper.Relationships.RelationshipCount + 1;
|
|
4485
4606
|
mediaData.forEach((image, idx) => {
|
|
4486
4607
|
file.PresentationWrapper.Relationships.addRelationship(presImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
|
|
4487
4608
|
});
|
|
4488
|
-
const replacedPresentationXml =
|
|
4609
|
+
const replacedPresentationXml = replaceImagePlaceholders(presentationXml, mediaData, presImageOffset);
|
|
4489
4610
|
currentImageCount += mediaData.length;
|
|
4490
4611
|
mapping["Presentation"] = {
|
|
4491
4612
|
data: replacedPresentationXml,
|
|
@@ -4497,69 +4618,61 @@ var Compiler = class {
|
|
|
4497
4618
|
};
|
|
4498
4619
|
for (let i = 0; i < file.Slides.length; i++) {
|
|
4499
4620
|
const slideWrapper = file.SlideWrappers[i];
|
|
4500
|
-
const slideXml =
|
|
4501
|
-
|
|
4502
|
-
indent
|
|
4503
|
-
});
|
|
4504
|
-
const slideMediaData = this.imageReplacer.getMediaData(slideXml, file.Media);
|
|
4621
|
+
const slideXml = this.formatter.formatToXml(slideWrapper.View, context, declaration);
|
|
4622
|
+
const slideMediaData = getReferencedMedia(slideXml, file.Media.Array);
|
|
4505
4623
|
const slideImageOffset = slideWrapper.Relationships.RelationshipCount + 1;
|
|
4506
4624
|
slideMediaData.forEach((image, idx) => {
|
|
4507
4625
|
slideWrapper.Relationships.addRelationship(slideImageOffset + idx, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `../media/${image.fileName}`);
|
|
4508
4626
|
});
|
|
4509
|
-
let replacedSlideXml =
|
|
4627
|
+
let replacedSlideXml = replaceImagePlaceholders(slideXml, slideMediaData, slideImageOffset);
|
|
4510
4628
|
currentImageCount += slideMediaData.length;
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
const
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
slideWrapper.Relationships.
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
slideWrapper.Relationships.addRelationship(mediaOffset + mi, "http://schemas.microsoft.com/office/2007/relationships/media", `../media/${media.fileName}`);
|
|
4559
|
-
});
|
|
4560
|
-
slideVideoRefs.forEach((video, vi) => {
|
|
4561
|
-
slideWrapper.Relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${video.fileName}`);
|
|
4562
|
-
});
|
|
4629
|
+
if (hasPlaceholders(replacedSlideXml)) {
|
|
4630
|
+
const slideChartKeys = collectPlaceholderKeys(replacedSlideXml, "chart:");
|
|
4631
|
+
if (slideChartKeys.length > 0) {
|
|
4632
|
+
const slideChartOffset = slideWrapper.Relationships.RelationshipCount + 1;
|
|
4633
|
+
const slideCharts = file.Charts.Array.filter((c) => slideChartKeys.includes(c.key));
|
|
4634
|
+
replacedSlideXml = replaceChartPlaceholders(replacedSlideXml, slideCharts.map((c) => c.key), slideChartOffset);
|
|
4635
|
+
slideCharts.forEach((chartData, ci) => {
|
|
4636
|
+
const globalIndex = file.Charts.Array.indexOf(chartData);
|
|
4637
|
+
slideWrapper.Relationships.addRelationship(slideChartOffset + ci, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", `../charts/chart${globalIndex + 1}.xml`);
|
|
4638
|
+
});
|
|
4639
|
+
}
|
|
4640
|
+
const slideSmartArtKeys = collectPlaceholderKeys(replacedSlideXml, "smartart:");
|
|
4641
|
+
if (slideSmartArtKeys.length > 0) {
|
|
4642
|
+
const slideSmartArts = file.SmartArts.Array.filter((s) => slideSmartArtKeys.includes(s.key));
|
|
4643
|
+
const saOffset = slideWrapper.Relationships.RelationshipCount + 1;
|
|
4644
|
+
replacedSlideXml = replaceSmartArtPlaceholders(replacedSlideXml, slideSmartArts.map((s) => s.key), saOffset);
|
|
4645
|
+
const saGlobalStart = file.SmartArts.Array.indexOf(slideSmartArts[0]);
|
|
4646
|
+
addSmartArtRelationships(slideSmartArts.map((s) => s.key), (id, type, target) => {
|
|
4647
|
+
slideWrapper.Relationships.addRelationship(id, type, target);
|
|
4648
|
+
}, saOffset, saGlobalStart, {
|
|
4649
|
+
pathPrefix: "../",
|
|
4650
|
+
styleRelType: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle"
|
|
4651
|
+
});
|
|
4652
|
+
}
|
|
4653
|
+
const slideHlinkKeys = collectPlaceholderKeys(replacedSlideXml, "hlink:");
|
|
4654
|
+
if (slideHlinkKeys.length > 0) {
|
|
4655
|
+
const slideHlinks = file.Hyperlinks.Array.filter((h) => slideHlinkKeys.includes(h.key));
|
|
4656
|
+
const hlinkOffset = slideWrapper.Relationships.RelationshipCount + 1;
|
|
4657
|
+
replacedSlideXml = replaceHyperlinkPlaceholders(replacedSlideXml, slideHlinks, hlinkOffset);
|
|
4658
|
+
slideHlinks.forEach((hlink, hi) => {
|
|
4659
|
+
slideWrapper.Relationships.addRelationship(hlinkOffset + hi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hlink.url, "External");
|
|
4660
|
+
});
|
|
4661
|
+
}
|
|
4662
|
+
const slideMediaRefs = getMediaRefs(replacedSlideXml, file.Media.Array);
|
|
4663
|
+
const slideVideoRefs = getVideoRefs(replacedSlideXml, file.Media.Array);
|
|
4664
|
+
if (slideMediaRefs.length > 0 || slideVideoRefs.length > 0) {
|
|
4665
|
+
const mediaOffset = slideWrapper.Relationships.RelationshipCount + 1;
|
|
4666
|
+
const videoOffset = mediaOffset + slideMediaRefs.length;
|
|
4667
|
+
replacedSlideXml = replaceMediaPlaceholders(replacedSlideXml, slideMediaRefs, mediaOffset);
|
|
4668
|
+
replacedSlideXml = replaceVideoPlaceholders(replacedSlideXml, slideVideoRefs, videoOffset);
|
|
4669
|
+
slideMediaRefs.forEach((media, mi) => {
|
|
4670
|
+
slideWrapper.Relationships.addRelationship(mediaOffset + mi, "http://schemas.microsoft.com/office/2007/relationships/media", `../media/${media.fileName}`);
|
|
4671
|
+
});
|
|
4672
|
+
slideVideoRefs.forEach((video, vi) => {
|
|
4673
|
+
slideWrapper.Relationships.addRelationship(videoOffset + vi, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video", `../media/${video.fileName}`);
|
|
4674
|
+
});
|
|
4675
|
+
}
|
|
4563
4676
|
}
|
|
4564
4677
|
mapping[`Slide${i}`] = {
|
|
4565
4678
|
data: replacedSlideXml,
|
|
@@ -4587,41 +4700,41 @@ var Compiler = class {
|
|
|
4587
4700
|
const files = {};
|
|
4588
4701
|
for (const key of Object.keys(mapping)) {
|
|
4589
4702
|
const entry = mapping[key];
|
|
4590
|
-
files[entry.path] = textToUint8Array(entry.data);
|
|
4703
|
+
files[entry.path] = [textToUint8Array(entry.data), { level: 0 }];
|
|
4591
4704
|
}
|
|
4592
4705
|
for (const override of overrides) files[override.path] = override.data instanceof Uint8Array ? override.data : textToUint8Array(override.data);
|
|
4593
4706
|
for (let i = 0; i < file.Charts.Array.length; i++) {
|
|
4594
4707
|
const chartData = file.Charts.Array[i];
|
|
4595
|
-
files[`ppt/charts/chart${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(chartData.chartSpace, context), {
|
|
4708
|
+
files[`ppt/charts/chart${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(chartData.chartSpace, context), {
|
|
4596
4709
|
declaration,
|
|
4597
4710
|
indent
|
|
4598
|
-
}));
|
|
4599
|
-
files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
4711
|
+
})), { level: 0 }];
|
|
4712
|
+
files[`ppt/charts/_rels/chart${i + 1}.xml.rels`] = [textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
4600
4713
|
encoding: "UTF-8",
|
|
4601
4714
|
standalone: "yes"
|
|
4602
|
-
} }));
|
|
4715
|
+
} })), { level: 0 }];
|
|
4603
4716
|
}
|
|
4604
4717
|
for (let i = 0; i < file.SmartArts.Array.length; i++) {
|
|
4605
4718
|
const smartArtData = file.SmartArts.Array[i];
|
|
4606
|
-
files[`ppt/diagrams/data${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(smartArtData.dataModel, context), {
|
|
4719
|
+
files[`ppt/diagrams/data${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(smartArtData.dataModel, context), {
|
|
4607
4720
|
declaration,
|
|
4608
4721
|
indent
|
|
4609
|
-
}));
|
|
4610
|
-
files[`ppt/diagrams/layout${i + 1}.xml`] = textToUint8Array(getLayoutXml(smartArtData.layout));
|
|
4611
|
-
files[`ppt/diagrams/quickStyle${i + 1}.xml`] = textToUint8Array(getStyleXml(smartArtData.style));
|
|
4612
|
-
files[`ppt/diagrams/colors${i + 1}.xml`] = textToUint8Array(getColorXml(smartArtData.color));
|
|
4613
|
-
files[`ppt/diagrams/drawing${i + 1}.xml`] = textToUint8Array(DEFAULT_DRAWING_XML);
|
|
4722
|
+
})), { level: 0 }];
|
|
4723
|
+
files[`ppt/diagrams/layout${i + 1}.xml`] = [textToUint8Array(getLayoutXml(smartArtData.layout)), { level: 0 }];
|
|
4724
|
+
files[`ppt/diagrams/quickStyle${i + 1}.xml`] = [textToUint8Array(getStyleXml(smartArtData.style)), { level: 0 }];
|
|
4725
|
+
files[`ppt/diagrams/colors${i + 1}.xml`] = [textToUint8Array(getColorXml(smartArtData.color)), { level: 0 }];
|
|
4726
|
+
files[`ppt/diagrams/drawing${i + 1}.xml`] = [textToUint8Array(DEFAULT_DRAWING_XML), { level: 0 }];
|
|
4614
4727
|
}
|
|
4615
4728
|
for (let i = 0; i < file.NotesSlides.length; i++) {
|
|
4616
4729
|
const notesSlide = file.NotesSlides[i];
|
|
4617
|
-
files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = textToUint8Array(xml(this.formatter.format(notesSlide, context), {
|
|
4730
|
+
files[`ppt/notesSlides/notesSlide${i + 1}.xml`] = [textToUint8Array(xml(this.formatter.format(notesSlide, context), {
|
|
4618
4731
|
declaration,
|
|
4619
4732
|
indent
|
|
4620
|
-
}));
|
|
4621
|
-
files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
4733
|
+
})), { level: 0 }];
|
|
4734
|
+
files[`ppt/notesSlides/_rels/notesSlide${i + 1}.xml.rels`] = [textToUint8Array(xml({ Relationships: { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } } }, { declaration: {
|
|
4622
4735
|
encoding: "UTF-8",
|
|
4623
4736
|
standalone: "yes"
|
|
4624
|
-
} }));
|
|
4737
|
+
} })), { level: 0 }];
|
|
4625
4738
|
}
|
|
4626
4739
|
for (const image of file.Media.Array) {
|
|
4627
4740
|
files[`ppt/media/${image.fileName}`] = [image.data, { level: 0 }];
|
|
@@ -4639,30 +4752,9 @@ function textToUint8Array(data) {
|
|
|
4639
4752
|
}
|
|
4640
4753
|
//#endregion
|
|
4641
4754
|
//#region src/export/packer/packer.ts
|
|
4642
|
-
const convertOutput = (data, type) => {
|
|
4643
|
-
switch (type) {
|
|
4644
|
-
case "nodebuffer": return Buffer.from(data);
|
|
4645
|
-
case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.presentationml.presentation" });
|
|
4646
|
-
case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
4647
|
-
case "uint8array": return data;
|
|
4648
|
-
case "base64": return btoa(Array.from(data, (b) => String.fromCharCode(b)).join(""));
|
|
4649
|
-
case "string":
|
|
4650
|
-
case "text":
|
|
4651
|
-
case "binarystring": return new TextDecoder().decode(data);
|
|
4652
|
-
case "array": return [...data];
|
|
4653
|
-
default: return data;
|
|
4654
|
-
}
|
|
4655
|
-
};
|
|
4656
|
-
const PrettifyType = {
|
|
4657
|
-
NONE: "",
|
|
4658
|
-
WITH_2_BLANKS: " ",
|
|
4659
|
-
WITH_4_BLANKS: " ",
|
|
4660
|
-
WITH_TAB: " "
|
|
4661
|
-
};
|
|
4662
|
-
const convertPrettifyType = (prettify) => prettify === true ? PrettifyType.WITH_2_BLANKS : prettify === false ? void 0 : prettify;
|
|
4663
4755
|
var Packer = class Packer {
|
|
4664
4756
|
static async pack(file, type, prettify, overrides = []) {
|
|
4665
|
-
return convertOutput(zipSync(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
|
|
4757
|
+
return convertOutput(zipSync(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type, OoxmlMimeType.PPTX);
|
|
4666
4758
|
}
|
|
4667
4759
|
static toBuffer(file, prettify, overrides = []) {
|
|
4668
4760
|
return Packer.pack(file, "nodebuffer", prettify, overrides);
|
|
@@ -5515,16 +5607,14 @@ function parseGroupShape(grpSp, ctx, slideRels) {
|
|
|
5515
5607
|
if (flipV === "1") result.flipV = true;
|
|
5516
5608
|
}
|
|
5517
5609
|
}
|
|
5518
|
-
const
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
if (parsed) children.push(parsed);
|
|
5525
|
-
}
|
|
5526
|
-
if (children.length > 0) result.children = children;
|
|
5610
|
+
const childSource = findChild(grpSp, "p:spTree") ?? grpSp;
|
|
5611
|
+
const children = [];
|
|
5612
|
+
for (const child of childSource.elements ?? []) {
|
|
5613
|
+
if (child.name === "p:nvGrpSpPr" || child.name === "p:grpSpPr") continue;
|
|
5614
|
+
const parsed = parseShapeTreeElement(child, ctx, slideRels);
|
|
5615
|
+
if (parsed) children.push(parsed);
|
|
5527
5616
|
}
|
|
5617
|
+
if (children.length > 0) result.children = children;
|
|
5528
5618
|
return result;
|
|
5529
5619
|
}
|
|
5530
5620
|
/** Parse slide notes content */
|
|
@@ -5888,7 +5978,6 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
5888
5978
|
VerticalAlignment: () => VerticalAlignment,
|
|
5889
5979
|
VideoFrame: () => VideoFrame,
|
|
5890
5980
|
buildFill: () => buildFill,
|
|
5891
|
-
convertOutput: () => convertOutput,
|
|
5892
5981
|
createBevel: () => createBevel,
|
|
5893
5982
|
createBottomBevel: () => createBottomBevel,
|
|
5894
5983
|
createColorElement: () => createColorElement,
|
|
@@ -5918,6 +6007,6 @@ __reExport(/* @__PURE__ */ __exportAll({
|
|
|
5918
6007
|
uniqueUuid: () => uniqueUuid
|
|
5919
6008
|
}), util_exports);
|
|
5920
6009
|
//#endregion
|
|
5921
|
-
export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill, ChartCollection, ChartFrame, ChartSpace, CompoundLine, ConnectorShape, ContentTypes, CoreProperties, DateTimeField, DefaultNotesMaster, DefaultSlideLayout, DefaultSlideMaster, DefaultTheme, EffectList, EndParagraphRunProperties, Field, File, File as Presentation, GroupShape, GroupShapeProperties, GroupTransform2D, HeaderFooter, LineCap, LineJoin, LineShape, Media, NonVisualDrawingProperties, NonVisualPictureProperties, NonVisualShapeProperties, NotesSlide, Packer, Paragraph, ParagraphProperties, PathShadeType, PenAlignment, Picture, PresentationWrapper, PresetDash, PresetGeometry, PresetMaterialType, PrettifyType, ReflectionAlignment, Relationships, Run, RunProperties, Shape, ShapeProperties, ShapeTree, Slide, SlideNumberField, SlideSizePreset, SmartArtFrame, StrikeStyle, Table, TableCell, TableCellProperties, TableFrame, TableProperties, TableRow, Text, TextAlignment, TextBody, TextCapitalization, TileFlipMode, Transform2D, Transition, UnderlineStyle, VerticalAlignment, VideoFrame, buildFill,
|
|
6010
|
+
export { AppProperties, AudioFrame, Background, BevelPresetType, BlipFill, ChartCollection, ChartFrame, ChartSpace, CompoundLine, ConnectorShape, ContentTypes, CoreProperties, DateTimeField, DefaultNotesMaster, DefaultSlideLayout, DefaultSlideMaster, DefaultTheme, EffectList, EndParagraphRunProperties, Field, File, File as Presentation, GroupShape, GroupShapeProperties, GroupTransform2D, HeaderFooter, LineCap, LineJoin, LineShape, Media, NonVisualDrawingProperties, NonVisualPictureProperties, NonVisualShapeProperties, NotesSlide, Packer, Paragraph, ParagraphProperties, PathShadeType, PenAlignment, Picture, PresentationWrapper, PresetDash, PresetGeometry, PresetMaterialType, PrettifyType, ReflectionAlignment, Relationships, Run, RunProperties, Shape, ShapeProperties, ShapeTree, Slide, SlideNumberField, SlideSizePreset, SmartArtFrame, StrikeStyle, Table, TableCell, TableCellProperties, TableFrame, TableProperties, TableRow, Text, TextAlignment, TextBody, TextCapitalization, TileFlipMode, Transform2D, Transition, UnderlineStyle, VerticalAlignment, VideoFrame, buildFill, createBevel, createBottomBevel, createColorElement, createColorTransforms, createEffectList, createGradientFill, createGradientStop, createOutline, createOutlineCompat, createScene3D, createShape3D, createTransformation, emusToInches, emusToPixels, emusToPoints, extractBlipFillMedia, hashedId, inchesToEmus, isRaw, parsePptx, percentToTHousandths, pixelsToEmus, pointsToEmus, toSlideChildren, uniqueId, uniqueNumericIdCreator, uniqueUuid };
|
|
5922
6011
|
|
|
5923
6012
|
//# sourceMappingURL=index.mjs.map
|