ooxml.js 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +192 -213
- package/dist/index.d.cts +5 -235
- package/dist/index.d.ts +5 -235
- package/dist/index.js +42 -188
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let zod = require("zod");
|
|
3
3
|
let fast_xml_parser = require("fast-xml-parser");
|
|
4
4
|
let fflate = require("fflate");
|
|
5
|
+
let document_content_model = require("document-content-model");
|
|
5
6
|
//#region src/model/node.ts
|
|
6
7
|
const AttributeSchema = zod.z.object({
|
|
7
8
|
name: zod.z.string(),
|
|
@@ -28,14 +29,14 @@ const XmlPiSchema = zod.z.object({
|
|
|
28
29
|
target: zod.z.string(),
|
|
29
30
|
content: zod.z.string()
|
|
30
31
|
});
|
|
31
|
-
function isRecord$
|
|
32
|
+
function isRecord$1(value) {
|
|
32
33
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
33
34
|
}
|
|
34
35
|
function isAttribute(value) {
|
|
35
|
-
return isRecord$
|
|
36
|
+
return isRecord$1(value) && typeof value.name === "string" && typeof value.value === "string";
|
|
36
37
|
}
|
|
37
38
|
function isXmlNode(value) {
|
|
38
|
-
if (!isRecord$
|
|
39
|
+
if (!isRecord$1(value)) return false;
|
|
39
40
|
const t = value.type;
|
|
40
41
|
if (t === "text" || t === "cdata" || t === "comment") return typeof value.value === "string";
|
|
41
42
|
if (t === "declaration") return Array.isArray(value.attributes) && value.attributes.every(isAttribute);
|
|
@@ -130,7 +131,7 @@ const PARSER = new fast_xml_parser.XMLParser({
|
|
|
130
131
|
function parseXml(xml) {
|
|
131
132
|
return parseNodes(PARSER.parse(xml));
|
|
132
133
|
}
|
|
133
|
-
function isRecord
|
|
134
|
+
function isRecord(value) {
|
|
134
135
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
135
136
|
}
|
|
136
137
|
function isUnknownArray$1(value) {
|
|
@@ -145,7 +146,7 @@ function parseNodes(raw) {
|
|
|
145
146
|
return raw.map(parseNode);
|
|
146
147
|
}
|
|
147
148
|
function parseNode(raw) {
|
|
148
|
-
if (!isRecord
|
|
149
|
+
if (!isRecord(raw)) throw new Error("fast-xml-parser node was not an object");
|
|
149
150
|
let tagKey;
|
|
150
151
|
for (const key of Object.keys(raw)) if (key !== ":@") {
|
|
151
152
|
if (tagKey !== void 0) throw new Error("XML node had multiple tag keys");
|
|
@@ -183,7 +184,7 @@ function parseNode(raw) {
|
|
|
183
184
|
}
|
|
184
185
|
function parseAttributes(raw) {
|
|
185
186
|
if (raw === void 0) return [];
|
|
186
|
-
if (!isRecord
|
|
187
|
+
if (!isRecord(raw)) throw new Error("XML attributes were not an object");
|
|
187
188
|
const attrs = [];
|
|
188
189
|
for (const key of Object.keys(raw)) {
|
|
189
190
|
if (!key.startsWith("@_")) throw new Error(`unexpected attribute key without @_ prefix: ${key}`);
|
|
@@ -197,7 +198,7 @@ function parseAttributes(raw) {
|
|
|
197
198
|
function scalarText(raw) {
|
|
198
199
|
if (!isUnknownArray$1(raw) || raw.length === 0) throw new Error("expected a scalar-text wrapper array");
|
|
199
200
|
const first = raw[0];
|
|
200
|
-
if (!isRecord
|
|
201
|
+
if (!isRecord(first)) throw new Error("scalar-text wrapper was not an object");
|
|
201
202
|
return asString(first["#text"]);
|
|
202
203
|
}
|
|
203
204
|
//#endregion
|
|
@@ -534,73 +535,7 @@ function encodeCompactPackage(cpkg) {
|
|
|
534
535
|
return zod.z.encode(compactPackageCodec, cpkg);
|
|
535
536
|
}
|
|
536
537
|
//#endregion
|
|
537
|
-
//#region src/typed/shared/geometry.ts
|
|
538
|
-
const BoxSchema = zod.z.object({
|
|
539
|
-
xPt: zod.z.number(),
|
|
540
|
-
yPt: zod.z.number(),
|
|
541
|
-
widthPt: zod.z.number().nonnegative(),
|
|
542
|
-
heightPt: zod.z.number().nonnegative()
|
|
543
|
-
});
|
|
544
|
-
const PageSizeSchema = zod.z.object({
|
|
545
|
-
widthPt: zod.z.number().positive(),
|
|
546
|
-
heightPt: zod.z.number().positive()
|
|
547
|
-
});
|
|
548
|
-
const MarginsSchema = zod.z.object({
|
|
549
|
-
topPt: zod.z.number().nonnegative(),
|
|
550
|
-
rightPt: zod.z.number().nonnegative(),
|
|
551
|
-
bottomPt: zod.z.number().nonnegative(),
|
|
552
|
-
leftPt: zod.z.number().nonnegative()
|
|
553
|
-
});
|
|
554
|
-
const PAGE_SIZE_LETTER = {
|
|
555
|
-
widthPt: 612,
|
|
556
|
-
heightPt: 792
|
|
557
|
-
};
|
|
558
|
-
const PAGE_SIZE_A4 = {
|
|
559
|
-
widthPt: 595.28,
|
|
560
|
-
heightPt: 841.89
|
|
561
|
-
};
|
|
562
|
-
const SLIDE_SIZE_WIDESCREEN = {
|
|
563
|
-
widthPt: 960,
|
|
564
|
-
heightPt: 540
|
|
565
|
-
};
|
|
566
|
-
const SLIDE_SIZE_STANDARD = {
|
|
567
|
-
widthPt: 720,
|
|
568
|
-
heightPt: 540
|
|
569
|
-
};
|
|
570
|
-
//#endregion
|
|
571
538
|
//#region src/typed/shared/color.ts
|
|
572
|
-
const ColorSchema = zod.z.object({
|
|
573
|
-
r: zod.z.number().min(0).max(1),
|
|
574
|
-
g: zod.z.number().min(0).max(1),
|
|
575
|
-
b: zod.z.number().min(0).max(1)
|
|
576
|
-
});
|
|
577
|
-
const COLOR_BLACK = {
|
|
578
|
-
r: 0,
|
|
579
|
-
g: 0,
|
|
580
|
-
b: 0
|
|
581
|
-
};
|
|
582
|
-
const HEX_COLOR_PATTERN = /^#?([0-9a-fA-F]{6})$/;
|
|
583
|
-
const HEX_BYTE_MAX = 255;
|
|
584
|
-
function rgbHexToColor(hex) {
|
|
585
|
-
const match = HEX_COLOR_PATTERN.exec(hex);
|
|
586
|
-
if (match === null) throw new Error(`not a 6-digit hex colour: ${hex}`);
|
|
587
|
-
const digits = match[1];
|
|
588
|
-
if (digits === void 0) throw new Error(`not a 6-digit hex colour: ${hex}`);
|
|
589
|
-
const r = Number.parseInt(digits.slice(0, 2), 16);
|
|
590
|
-
const g = Number.parseInt(digits.slice(2, 4), 16);
|
|
591
|
-
const b = Number.parseInt(digits.slice(4, 6), 16);
|
|
592
|
-
return {
|
|
593
|
-
r: r / HEX_BYTE_MAX,
|
|
594
|
-
g: g / HEX_BYTE_MAX,
|
|
595
|
-
b: b / HEX_BYTE_MAX
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
function toHexByte(component) {
|
|
599
|
-
return Math.round(component * HEX_BYTE_MAX).toString(16).padStart(2, "0");
|
|
600
|
-
}
|
|
601
|
-
function colorToRgbHex(color) {
|
|
602
|
-
return `${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
|
|
603
|
-
}
|
|
604
539
|
const OOXML_PERCENT_SCALE = 1e5;
|
|
605
540
|
function clamp01(x) {
|
|
606
541
|
return Math.max(0, Math.min(1, x));
|
|
@@ -683,14 +618,6 @@ function applyColorTransforms(base, transforms) {
|
|
|
683
618
|
return color;
|
|
684
619
|
}
|
|
685
620
|
//#endregion
|
|
686
|
-
//#region src/typed/shared/style.ts
|
|
687
|
-
const AlignmentSchema = zod.z.enum([
|
|
688
|
-
"left",
|
|
689
|
-
"center",
|
|
690
|
-
"right",
|
|
691
|
-
"justify"
|
|
692
|
-
]);
|
|
693
|
-
//#endregion
|
|
694
621
|
//#region src/typed/shared/metadata.ts
|
|
695
622
|
const DocumentMetadataSchema = zod.z.object({
|
|
696
623
|
title: zod.z.string().optional(),
|
|
@@ -730,103 +657,6 @@ function readCoreProperties(pkg) {
|
|
|
730
657
|
};
|
|
731
658
|
}
|
|
732
659
|
//#endregion
|
|
733
|
-
//#region src/typed/shared/content.ts
|
|
734
|
-
const ContentRunSchema = zod.z.object({
|
|
735
|
-
text: zod.z.string(),
|
|
736
|
-
bold: zod.z.boolean().optional(),
|
|
737
|
-
italic: zod.z.boolean().optional(),
|
|
738
|
-
underline: zod.z.boolean().optional(),
|
|
739
|
-
strike: zod.z.boolean().optional(),
|
|
740
|
-
fontFamily: zod.z.string().optional(),
|
|
741
|
-
sizePt: zod.z.number().positive().optional(),
|
|
742
|
-
color: ColorSchema.optional(),
|
|
743
|
-
hyperlink: zod.z.string().optional()
|
|
744
|
-
});
|
|
745
|
-
const ContentListMembershipSchema = zod.z.object({
|
|
746
|
-
numId: zod.z.string(),
|
|
747
|
-
level: zod.z.number().int().nonnegative()
|
|
748
|
-
});
|
|
749
|
-
const ContentParagraphSchema = zod.z.object({
|
|
750
|
-
kind: zod.z.literal("paragraph"),
|
|
751
|
-
runs: zod.z.array(ContentRunSchema),
|
|
752
|
-
styleId: zod.z.string().optional(),
|
|
753
|
-
alignment: AlignmentSchema.optional(),
|
|
754
|
-
list: ContentListMembershipSchema.optional(),
|
|
755
|
-
spacingBeforePt: zod.z.number().optional(),
|
|
756
|
-
spacingAfterPt: zod.z.number().optional(),
|
|
757
|
-
lineSpacing: zod.z.number().positive().optional(),
|
|
758
|
-
indentLeftPt: zod.z.number().optional(),
|
|
759
|
-
indentFirstLinePt: zod.z.number().optional()
|
|
760
|
-
});
|
|
761
|
-
const ContentImageBlockSchema = zod.z.object({
|
|
762
|
-
kind: zod.z.literal("image"),
|
|
763
|
-
format: zod.z.enum(["png", "jpeg"]),
|
|
764
|
-
base64: zod.z.string(),
|
|
765
|
-
widthPt: zod.z.number().positive(),
|
|
766
|
-
heightPt: zod.z.number().positive(),
|
|
767
|
-
altText: zod.z.string().optional()
|
|
768
|
-
});
|
|
769
|
-
const ContentPageBreakSchema = zod.z.object({ kind: zod.z.literal("pageBreak") });
|
|
770
|
-
function isRecord(value) {
|
|
771
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
772
|
-
}
|
|
773
|
-
function isContentRun(value) {
|
|
774
|
-
return isRecord(value) && typeof value.text === "string";
|
|
775
|
-
}
|
|
776
|
-
function isContentTableCell(value) {
|
|
777
|
-
return isRecord(value) && Array.isArray(value.blocks) && value.blocks.every(isContentBlock);
|
|
778
|
-
}
|
|
779
|
-
function isContentTableRow(value) {
|
|
780
|
-
return isRecord(value) && Array.isArray(value.cells) && value.cells.every(isContentTableCell) && (value.heightPt === void 0 || typeof value.heightPt === "number");
|
|
781
|
-
}
|
|
782
|
-
function isContentBlock(value) {
|
|
783
|
-
if (!isRecord(value)) return false;
|
|
784
|
-
const kind = value.kind;
|
|
785
|
-
if (kind === "paragraph") return Array.isArray(value.runs) && value.runs.every(isContentRun);
|
|
786
|
-
if (kind === "image") return (value.format === "png" || value.format === "jpeg") && typeof value.base64 === "string" && typeof value.widthPt === "number" && typeof value.heightPt === "number";
|
|
787
|
-
if (kind === "pageBreak") return true;
|
|
788
|
-
if (kind === "table") return Array.isArray(value.rows) && value.rows.every(isContentTableRow) && Array.isArray(value.columnWidthsPt) && value.columnWidthsPt.every((w) => typeof w === "number");
|
|
789
|
-
return false;
|
|
790
|
-
}
|
|
791
|
-
const ContentBlockSchema = zod.z.custom(isContentBlock);
|
|
792
|
-
const ContentTableCellSchema = zod.z.object({
|
|
793
|
-
blocks: zod.z.array(ContentBlockSchema),
|
|
794
|
-
colSpan: zod.z.number().int().positive().optional(),
|
|
795
|
-
rowSpan: zod.z.number().int().positive().optional(),
|
|
796
|
-
background: ColorSchema.optional()
|
|
797
|
-
});
|
|
798
|
-
const ContentTableRowSchema = zod.z.object({
|
|
799
|
-
cells: zod.z.array(ContentTableCellSchema),
|
|
800
|
-
heightPt: zod.z.number().positive().optional()
|
|
801
|
-
});
|
|
802
|
-
const ContentTableSchema = zod.z.object({
|
|
803
|
-
kind: zod.z.literal("table"),
|
|
804
|
-
rows: zod.z.array(ContentTableRowSchema),
|
|
805
|
-
columnWidthsPt: zod.z.array(zod.z.number().positive())
|
|
806
|
-
});
|
|
807
|
-
const ContentSectionSchema = zod.z.object({
|
|
808
|
-
pageSize: PageSizeSchema,
|
|
809
|
-
margins: MarginsSchema,
|
|
810
|
-
blocks: zod.z.array(ContentBlockSchema)
|
|
811
|
-
});
|
|
812
|
-
const ContentShapeSchema = zod.z.object({
|
|
813
|
-
name: zod.z.string().optional(),
|
|
814
|
-
frame: BoxSchema,
|
|
815
|
-
rotationDeg: zod.z.number().optional(),
|
|
816
|
-
insetLeftPt: zod.z.number().nonnegative(),
|
|
817
|
-
insetTopPt: zod.z.number().nonnegative(),
|
|
818
|
-
insetRightPt: zod.z.number().nonnegative(),
|
|
819
|
-
insetBottomPt: zod.z.number().nonnegative(),
|
|
820
|
-
fontScale: zod.z.number().positive().optional(),
|
|
821
|
-
lineSpacingReduction: zod.z.number().nonnegative().optional(),
|
|
822
|
-
blocks: zod.z.array(ContentBlockSchema)
|
|
823
|
-
});
|
|
824
|
-
const ContentSlideSchema = zod.z.object({
|
|
825
|
-
size: PageSizeSchema,
|
|
826
|
-
shapes: zod.z.array(ContentShapeSchema),
|
|
827
|
-
notes: zod.z.string()
|
|
828
|
-
});
|
|
829
|
-
//#endregion
|
|
830
660
|
//#region src/image/sniff.ts
|
|
831
661
|
const PNG_SIGNATURE = [
|
|
832
662
|
137,
|
|
@@ -909,11 +739,11 @@ const CLR_SCHEME_SLOTS = [
|
|
|
909
739
|
function readThemeSlotColor(colorEl) {
|
|
910
740
|
if (colorEl.tag === "a:srgbClr") {
|
|
911
741
|
const val = attr(colorEl, "val");
|
|
912
|
-
return val === void 0 ? void 0 : rgbHexToColor(val);
|
|
742
|
+
return val === void 0 ? void 0 : (0, document_content_model.rgbHexToColor)(val);
|
|
913
743
|
}
|
|
914
744
|
if (colorEl.tag === "a:sysClr") {
|
|
915
745
|
const lastClr = attr(colorEl, "lastClr");
|
|
916
|
-
if (lastClr !== void 0) return rgbHexToColor(lastClr);
|
|
746
|
+
if (lastClr !== void 0) return (0, document_content_model.rgbHexToColor)(lastClr);
|
|
917
747
|
return attr(colorEl, "val") === "window" ? {
|
|
918
748
|
r: 1,
|
|
919
749
|
g: 1,
|
|
@@ -1002,7 +832,7 @@ function readSchemeColor(schemeClrEl, colorMap, theme) {
|
|
|
1002
832
|
}
|
|
1003
833
|
function readSrgbColor(srgbClrEl) {
|
|
1004
834
|
const val = attr(srgbClrEl, "val");
|
|
1005
|
-
return val === void 0 ? void 0 : applyColorTransforms(rgbHexToColor(val), readColorTransforms(srgbClrEl));
|
|
835
|
+
return val === void 0 ? void 0 : applyColorTransforms((0, document_content_model.rgbHexToColor)(val), readColorTransforms(srgbClrEl));
|
|
1006
836
|
}
|
|
1007
837
|
function readSolidFillColor(solidFillEl, colorMap, theme) {
|
|
1008
838
|
if (solidFillEl === void 0) return;
|
|
@@ -1044,6 +874,22 @@ function applyGroupTransform(group, childFrame) {
|
|
|
1044
874
|
};
|
|
1045
875
|
}
|
|
1046
876
|
//#endregion
|
|
877
|
+
//#region src/typed/shared/source-path.ts
|
|
878
|
+
function assignSourcePaths(blocks, prefix) {
|
|
879
|
+
blocks.forEach((block, blockIndex) => {
|
|
880
|
+
const blockPath = `${prefix}.blocks[${blockIndex}]`;
|
|
881
|
+
block.sourcePath = blockPath;
|
|
882
|
+
if (block.kind === "paragraph") block.runs.forEach((run, runIndex) => {
|
|
883
|
+
run.sourcePath = `${blockPath}.runs[${runIndex}]`;
|
|
884
|
+
});
|
|
885
|
+
else if (block.kind === "table") block.rows.forEach((row, rowIndex) => {
|
|
886
|
+
row.cells.forEach((cell, cellIndex) => {
|
|
887
|
+
assignSourcePaths(cell.blocks, `${blockPath}.rows[${rowIndex}].cells[${cellIndex}]`);
|
|
888
|
+
});
|
|
889
|
+
});
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
//#endregion
|
|
1047
893
|
//#region src/typed/docx/styles.ts
|
|
1048
894
|
function mergeParagraphLayer(base, layer) {
|
|
1049
895
|
return {
|
|
@@ -1079,7 +925,7 @@ function readUnderline(u) {
|
|
|
1079
925
|
function readRunColor(colorEl) {
|
|
1080
926
|
if (colorEl === void 0) return;
|
|
1081
927
|
const val = attr(colorEl, "w:val");
|
|
1082
|
-
return val === void 0 || val === "auto" ? void 0 : rgbHexToColor(val);
|
|
928
|
+
return val === void 0 || val === "auto" ? void 0 : (0, document_content_model.rgbHexToColor)(val);
|
|
1083
929
|
}
|
|
1084
930
|
function readRunFontFamily(rFonts, theme) {
|
|
1085
931
|
if (rFonts === void 0) return;
|
|
@@ -1197,7 +1043,7 @@ const FootnoteSchema = zod.z.object({
|
|
|
1197
1043
|
});
|
|
1198
1044
|
const DocxDocumentSchema = zod.z.object({
|
|
1199
1045
|
metadata: DocumentMetadataSchema,
|
|
1200
|
-
sections: zod.z.array(ContentSectionSchema),
|
|
1046
|
+
sections: zod.z.array(document_content_model.ContentSectionSchema),
|
|
1201
1047
|
comments: zod.z.array(CommentSchema),
|
|
1202
1048
|
footnotes: zod.z.array(FootnoteSchema),
|
|
1203
1049
|
headers: zod.z.array(zod.z.string()),
|
|
@@ -1217,7 +1063,7 @@ function readPageSize(sectPr) {
|
|
|
1217
1063
|
const pgSz = childrenWithTag(sectPr, "w:pgSz")[0];
|
|
1218
1064
|
const w = pgSz === void 0 ? void 0 : attr(pgSz, "w:w");
|
|
1219
1065
|
const h = pgSz === void 0 ? void 0 : attr(pgSz, "w:h");
|
|
1220
|
-
return w === void 0 || h === void 0 ? PAGE_SIZE_LETTER : {
|
|
1066
|
+
return w === void 0 || h === void 0 ? document_content_model.PAGE_SIZE_LETTER : {
|
|
1221
1067
|
widthPt: twipsToPt(Number(w)),
|
|
1222
1068
|
heightPt: twipsToPt(Number(h))
|
|
1223
1069
|
};
|
|
@@ -1333,7 +1179,7 @@ function readParagraph$1(paragraph, context, rels) {
|
|
|
1333
1179
|
function readCellShading(tcPr) {
|
|
1334
1180
|
const shd = tcPr === void 0 ? void 0 : childrenWithTag(tcPr, "w:shd")[0];
|
|
1335
1181
|
const fill = shd === void 0 ? void 0 : attr(shd, "w:fill");
|
|
1336
|
-
return fill === void 0 || fill === "auto" || fill === "none" ? void 0 : rgbHexToColor(fill);
|
|
1182
|
+
return fill === void 0 || fill === "auto" || fill === "none" ? void 0 : (0, document_content_model.rgbHexToColor)(fill);
|
|
1337
1183
|
}
|
|
1338
1184
|
function readRawCell(tc, context, rels) {
|
|
1339
1185
|
const tcPr = childrenWithTag(tc, "w:tcPr")[0];
|
|
@@ -1433,10 +1279,11 @@ function readSections(body, context, rels) {
|
|
|
1433
1279
|
currentBlocks.push(...readBodyBlocks([node], context, rels));
|
|
1434
1280
|
}
|
|
1435
1281
|
if (currentBlocks.length > 0 || sections.length === 0) sections.push({
|
|
1436
|
-
pageSize: PAGE_SIZE_LETTER,
|
|
1282
|
+
pageSize: document_content_model.PAGE_SIZE_LETTER,
|
|
1437
1283
|
margins: DEFAULT_MARGINS,
|
|
1438
1284
|
blocks: currentBlocks
|
|
1439
1285
|
});
|
|
1286
|
+
sections.forEach((section, sectionIndex) => assignSourcePaths(section.blocks, `sections[${sectionIndex}]`));
|
|
1440
1287
|
return sections;
|
|
1441
1288
|
}
|
|
1442
1289
|
function readDocumentTheme(pkg, docRels) {
|
|
@@ -1593,7 +1440,7 @@ function resolveDefaultRunProperties(placeholderType, level, context) {
|
|
|
1593
1440
|
//#region src/typed/pptx/read.ts
|
|
1594
1441
|
const PptxDocumentSchema = zod.z.object({
|
|
1595
1442
|
metadata: DocumentMetadataSchema,
|
|
1596
|
-
slides: zod.z.array(ContentSlideSchema)
|
|
1443
|
+
slides: zod.z.array(document_content_model.ContentSlideSchema)
|
|
1597
1444
|
});
|
|
1598
1445
|
const PRESENTATION_PATH = "ppt/presentation.xml";
|
|
1599
1446
|
const TABLE_GRAPHIC_URI = "http://schemas.openxmlformats.org/drawingml/2006/table";
|
|
@@ -1601,7 +1448,7 @@ function readSlideSize(presentationRoot) {
|
|
|
1601
1448
|
const sldSz = presentationRoot === void 0 ? void 0 : childrenWithTag(presentationRoot, "p:sldSz")[0];
|
|
1602
1449
|
const cx = sldSz === void 0 ? void 0 : attr(sldSz, "cx");
|
|
1603
1450
|
const cy = sldSz === void 0 ? void 0 : attr(sldSz, "cy");
|
|
1604
|
-
return cx === void 0 || cy === void 0 ? SLIDE_SIZE_WIDESCREEN : {
|
|
1451
|
+
return cx === void 0 || cy === void 0 ? document_content_model.SLIDE_SIZE_WIDESCREEN : {
|
|
1605
1452
|
widthPt: emuToPt(Number(cx)),
|
|
1606
1453
|
heightPt: emuToPt(Number(cy))
|
|
1607
1454
|
};
|
|
@@ -1928,6 +1775,13 @@ function readPptx(pkg) {
|
|
|
1928
1775
|
const presentationRoot = rootElement(pkg.parts[PRESENTATION_PATH]);
|
|
1929
1776
|
const size = readSlideSize(presentationRoot);
|
|
1930
1777
|
const slides = readSlidePathsInOrder(pkg, presentationRoot).map((slidePath) => readSlide(pkg, slidePath, size));
|
|
1778
|
+
slides.forEach((slide, slideIndex) => {
|
|
1779
|
+
slide.shapes.forEach((shape, shapeIndex) => {
|
|
1780
|
+
const shapePath = `slides[${slideIndex}].shapes[${shapeIndex}]`;
|
|
1781
|
+
shape.sourcePath = shapePath;
|
|
1782
|
+
assignSourcePaths(shape.blocks, shapePath);
|
|
1783
|
+
});
|
|
1784
|
+
});
|
|
1931
1785
|
return {
|
|
1932
1786
|
metadata: readCoreProperties(pkg),
|
|
1933
1787
|
slides
|
|
@@ -2076,41 +1930,151 @@ function readXlsx(pkg) {
|
|
|
2076
1930
|
};
|
|
2077
1931
|
}
|
|
2078
1932
|
//#endregion
|
|
2079
|
-
exports
|
|
1933
|
+
Object.defineProperty(exports, "AlignmentSchema", {
|
|
1934
|
+
enumerable: true,
|
|
1935
|
+
get: function() {
|
|
1936
|
+
return document_content_model.AlignmentSchema;
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
2080
1939
|
exports.AttributeSchema = AttributeSchema;
|
|
2081
1940
|
exports.BinaryPartSchema = BinaryPartSchema;
|
|
2082
|
-
exports
|
|
2083
|
-
|
|
2084
|
-
|
|
1941
|
+
Object.defineProperty(exports, "BoxSchema", {
|
|
1942
|
+
enumerable: true,
|
|
1943
|
+
get: function() {
|
|
1944
|
+
return document_content_model.BoxSchema;
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
Object.defineProperty(exports, "COLOR_BLACK", {
|
|
1948
|
+
enumerable: true,
|
|
1949
|
+
get: function() {
|
|
1950
|
+
return document_content_model.COLOR_BLACK;
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
Object.defineProperty(exports, "ColorSchema", {
|
|
1954
|
+
enumerable: true,
|
|
1955
|
+
get: function() {
|
|
1956
|
+
return document_content_model.ColorSchema;
|
|
1957
|
+
}
|
|
1958
|
+
});
|
|
2085
1959
|
exports.CommentSchema = CommentSchema;
|
|
2086
1960
|
exports.CompactPackageSchema = CompactPackageSchema;
|
|
2087
1961
|
exports.CompactPartSchema = CompactPartSchema;
|
|
2088
1962
|
exports.CompactXmlNodeSchema = CompactXmlNodeSchema;
|
|
2089
|
-
exports
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
exports
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
1963
|
+
Object.defineProperty(exports, "ContentBlockSchema", {
|
|
1964
|
+
enumerable: true,
|
|
1965
|
+
get: function() {
|
|
1966
|
+
return document_content_model.ContentBlockSchema;
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
Object.defineProperty(exports, "ContentImageBlockSchema", {
|
|
1970
|
+
enumerable: true,
|
|
1971
|
+
get: function() {
|
|
1972
|
+
return document_content_model.ContentImageBlockSchema;
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
Object.defineProperty(exports, "ContentListMembershipSchema", {
|
|
1976
|
+
enumerable: true,
|
|
1977
|
+
get: function() {
|
|
1978
|
+
return document_content_model.ContentListMembershipSchema;
|
|
1979
|
+
}
|
|
1980
|
+
});
|
|
1981
|
+
Object.defineProperty(exports, "ContentPageBreakSchema", {
|
|
1982
|
+
enumerable: true,
|
|
1983
|
+
get: function() {
|
|
1984
|
+
return document_content_model.ContentPageBreakSchema;
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
Object.defineProperty(exports, "ContentParagraphSchema", {
|
|
1988
|
+
enumerable: true,
|
|
1989
|
+
get: function() {
|
|
1990
|
+
return document_content_model.ContentParagraphSchema;
|
|
1991
|
+
}
|
|
1992
|
+
});
|
|
1993
|
+
Object.defineProperty(exports, "ContentRunSchema", {
|
|
1994
|
+
enumerable: true,
|
|
1995
|
+
get: function() {
|
|
1996
|
+
return document_content_model.ContentRunSchema;
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
Object.defineProperty(exports, "ContentSectionSchema", {
|
|
2000
|
+
enumerable: true,
|
|
2001
|
+
get: function() {
|
|
2002
|
+
return document_content_model.ContentSectionSchema;
|
|
2003
|
+
}
|
|
2004
|
+
});
|
|
2005
|
+
Object.defineProperty(exports, "ContentShapeSchema", {
|
|
2006
|
+
enumerable: true,
|
|
2007
|
+
get: function() {
|
|
2008
|
+
return document_content_model.ContentShapeSchema;
|
|
2009
|
+
}
|
|
2010
|
+
});
|
|
2011
|
+
Object.defineProperty(exports, "ContentSlideSchema", {
|
|
2012
|
+
enumerable: true,
|
|
2013
|
+
get: function() {
|
|
2014
|
+
return document_content_model.ContentSlideSchema;
|
|
2015
|
+
}
|
|
2016
|
+
});
|
|
2017
|
+
Object.defineProperty(exports, "ContentTableCellSchema", {
|
|
2018
|
+
enumerable: true,
|
|
2019
|
+
get: function() {
|
|
2020
|
+
return document_content_model.ContentTableCellSchema;
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
Object.defineProperty(exports, "ContentTableRowSchema", {
|
|
2024
|
+
enumerable: true,
|
|
2025
|
+
get: function() {
|
|
2026
|
+
return document_content_model.ContentTableRowSchema;
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
Object.defineProperty(exports, "ContentTableSchema", {
|
|
2030
|
+
enumerable: true,
|
|
2031
|
+
get: function() {
|
|
2032
|
+
return document_content_model.ContentTableSchema;
|
|
2033
|
+
}
|
|
2034
|
+
});
|
|
2101
2035
|
exports.DefinedNameSchema = DefinedNameSchema;
|
|
2102
2036
|
exports.DocumentMetadataSchema = DocumentMetadataSchema;
|
|
2103
2037
|
exports.DocxDocumentSchema = DocxDocumentSchema;
|
|
2104
2038
|
exports.FootnoteSchema = FootnoteSchema;
|
|
2105
|
-
exports
|
|
2106
|
-
|
|
2107
|
-
|
|
2039
|
+
Object.defineProperty(exports, "MarginsSchema", {
|
|
2040
|
+
enumerable: true,
|
|
2041
|
+
get: function() {
|
|
2042
|
+
return document_content_model.MarginsSchema;
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
Object.defineProperty(exports, "PAGE_SIZE_A4", {
|
|
2046
|
+
enumerable: true,
|
|
2047
|
+
get: function() {
|
|
2048
|
+
return document_content_model.PAGE_SIZE_A4;
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
Object.defineProperty(exports, "PAGE_SIZE_LETTER", {
|
|
2052
|
+
enumerable: true,
|
|
2053
|
+
get: function() {
|
|
2054
|
+
return document_content_model.PAGE_SIZE_LETTER;
|
|
2055
|
+
}
|
|
2056
|
+
});
|
|
2108
2057
|
exports.PackageSchema = PackageSchema;
|
|
2109
|
-
exports
|
|
2058
|
+
Object.defineProperty(exports, "PageSizeSchema", {
|
|
2059
|
+
enumerable: true,
|
|
2060
|
+
get: function() {
|
|
2061
|
+
return document_content_model.PageSizeSchema;
|
|
2062
|
+
}
|
|
2063
|
+
});
|
|
2110
2064
|
exports.PartSchema = PartSchema;
|
|
2111
2065
|
exports.PptxDocumentSchema = PptxDocumentSchema;
|
|
2112
|
-
exports
|
|
2113
|
-
|
|
2066
|
+
Object.defineProperty(exports, "SLIDE_SIZE_STANDARD", {
|
|
2067
|
+
enumerable: true,
|
|
2068
|
+
get: function() {
|
|
2069
|
+
return document_content_model.SLIDE_SIZE_STANDARD;
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
2072
|
+
Object.defineProperty(exports, "SLIDE_SIZE_WIDESCREEN", {
|
|
2073
|
+
enumerable: true,
|
|
2074
|
+
get: function() {
|
|
2075
|
+
return document_content_model.SLIDE_SIZE_WIDESCREEN;
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2114
2078
|
exports.XlsxCellSchema = XlsxCellSchema;
|
|
2115
2079
|
exports.XlsxSheetSchema = XlsxSheetSchema;
|
|
2116
2080
|
exports.XlsxWorkbookSchema = XlsxWorkbookSchema;
|
|
@@ -2128,7 +2092,12 @@ exports.base64ToBytes = base64ToBytes;
|
|
|
2128
2092
|
exports.buildXml = buildXml;
|
|
2129
2093
|
exports.bytesToBase64 = bytesToBase64;
|
|
2130
2094
|
exports.childrenWithTag = childrenWithTag;
|
|
2131
|
-
exports
|
|
2095
|
+
Object.defineProperty(exports, "colorToRgbHex", {
|
|
2096
|
+
enumerable: true,
|
|
2097
|
+
get: function() {
|
|
2098
|
+
return document_content_model.colorToRgbHex;
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2132
2101
|
exports.compactCodec = compactCodec;
|
|
2133
2102
|
exports.compactPackageCodec = compactPackageCodec;
|
|
2134
2103
|
exports.decodeCompactPackage = decodeCompactPackage;
|
|
@@ -2139,7 +2108,12 @@ exports.encodeCompactPackage = encodeCompactPackage;
|
|
|
2139
2108
|
exports.encodePackage = encodePackage;
|
|
2140
2109
|
exports.fromCompact = fromCompact;
|
|
2141
2110
|
exports.isCompactXmlNode = isCompactXmlNode;
|
|
2142
|
-
exports
|
|
2111
|
+
Object.defineProperty(exports, "isContentBlock", {
|
|
2112
|
+
enumerable: true,
|
|
2113
|
+
get: function() {
|
|
2114
|
+
return document_content_model.isContentBlock;
|
|
2115
|
+
}
|
|
2116
|
+
});
|
|
2143
2117
|
exports.isXmlNode = isXmlNode;
|
|
2144
2118
|
exports.packageCodec = packageCodec;
|
|
2145
2119
|
exports.parsePackage = parsePackage;
|
|
@@ -2148,7 +2122,12 @@ exports.readDocx = readDocx;
|
|
|
2148
2122
|
exports.readPptx = readPptx;
|
|
2149
2123
|
exports.readXlsx = readXlsx;
|
|
2150
2124
|
exports.resolveRelationships = resolveRelationships;
|
|
2151
|
-
exports
|
|
2125
|
+
Object.defineProperty(exports, "rgbHexToColor", {
|
|
2126
|
+
enumerable: true,
|
|
2127
|
+
get: function() {
|
|
2128
|
+
return document_content_model.rgbHexToColor;
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2152
2131
|
exports.rootElement = rootElement;
|
|
2153
2132
|
exports.serializePackage = serializePackage;
|
|
2154
2133
|
exports.sniffImageFormat = sniffImageFormat;
|