documents.js 1.33.2 → 1.33.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/dist/index.cjs +191 -18
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +191 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1304,9 +1304,21 @@ function appendBlock(body, block) {
|
|
|
1304
1304
|
const CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
1305
1305
|
const RELS_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
1306
1306
|
const PML_NS = "http://schemas.openxmlformats.org/presentationml/2006/main";
|
|
1307
|
+
const DML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
1307
1308
|
const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
1308
1309
|
const DEFAULT_SLIDE_WIDTH_EMU = "12192000";
|
|
1309
1310
|
const DEFAULT_SLIDE_HEIGHT_EMU = "6858000";
|
|
1311
|
+
const SLIDE_MASTER_PART_PATH = "ppt/slideMasters/slideMaster1.xml";
|
|
1312
|
+
const SLIDE_LAYOUT_PART_PATH = "ppt/slideLayouts/slideLayout1.xml";
|
|
1313
|
+
const THEME_PART_PATH = "ppt/theme/theme1.xml";
|
|
1314
|
+
const PRESENTATION_PART_PATH$1 = "ppt/presentation.xml";
|
|
1315
|
+
const SLIDE_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
|
|
1316
|
+
const SLIDE_LAYOUT_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
|
|
1317
|
+
const THEME_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
1318
|
+
const SLIDE_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
|
1319
|
+
const SLIDE_LAYOUT_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
|
1320
|
+
const THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
1321
|
+
const MIN_MASTER_OR_LAYOUT_ID = 2147483648;
|
|
1310
1322
|
function declaration() {
|
|
1311
1323
|
return {
|
|
1312
1324
|
type: "declaration",
|
|
@@ -1326,6 +1338,122 @@ function declaration() {
|
|
|
1326
1338
|
]
|
|
1327
1339
|
};
|
|
1328
1340
|
}
|
|
1341
|
+
function buildEmptyGroupSpTree() {
|
|
1342
|
+
return el("p:spTree", {}, [el("p:nvGrpSpPr", {}, [
|
|
1343
|
+
el("p:cNvPr", {
|
|
1344
|
+
id: "1",
|
|
1345
|
+
name: ""
|
|
1346
|
+
}),
|
|
1347
|
+
el("p:cNvGrpSpPr"),
|
|
1348
|
+
el("p:nvPr")
|
|
1349
|
+
]), el("p:grpSpPr")]);
|
|
1350
|
+
}
|
|
1351
|
+
function buildFormatScheme() {
|
|
1352
|
+
const solidPhClr = () => el("a:solidFill", {}, [el("a:schemeClr", { val: "phClr" })]);
|
|
1353
|
+
return el("a:fmtScheme", { name: "Office" }, [
|
|
1354
|
+
el("a:fillStyleLst", {}, [
|
|
1355
|
+
solidPhClr(),
|
|
1356
|
+
solidPhClr(),
|
|
1357
|
+
solidPhClr()
|
|
1358
|
+
]),
|
|
1359
|
+
el("a:lnStyleLst", {}, [
|
|
1360
|
+
el("a:ln", {}, [solidPhClr()]),
|
|
1361
|
+
el("a:ln", {}, [solidPhClr()]),
|
|
1362
|
+
el("a:ln", {}, [solidPhClr()])
|
|
1363
|
+
]),
|
|
1364
|
+
el("a:effectStyleLst", {}, [
|
|
1365
|
+
el("a:effectStyle", {}, [el("a:effectLst")]),
|
|
1366
|
+
el("a:effectStyle", {}, [el("a:effectLst")]),
|
|
1367
|
+
el("a:effectStyle", {}, [el("a:effectLst")])
|
|
1368
|
+
]),
|
|
1369
|
+
el("a:bgFillStyleLst", {}, [
|
|
1370
|
+
solidPhClr(),
|
|
1371
|
+
solidPhClr(),
|
|
1372
|
+
solidPhClr()
|
|
1373
|
+
])
|
|
1374
|
+
]);
|
|
1375
|
+
}
|
|
1376
|
+
function buildTheme() {
|
|
1377
|
+
const clrScheme = el("a:clrScheme", { name: "Office" }, [
|
|
1378
|
+
el("a:dk1", {}, [el("a:sysClr", {
|
|
1379
|
+
val: "windowText",
|
|
1380
|
+
lastClr: "000000"
|
|
1381
|
+
})]),
|
|
1382
|
+
el("a:lt1", {}, [el("a:sysClr", {
|
|
1383
|
+
val: "window",
|
|
1384
|
+
lastClr: "FFFFFF"
|
|
1385
|
+
})]),
|
|
1386
|
+
el("a:dk2", {}, [el("a:srgbClr", { val: "1F497D" })]),
|
|
1387
|
+
el("a:lt2", {}, [el("a:srgbClr", { val: "EEECE1" })]),
|
|
1388
|
+
el("a:accent1", {}, [el("a:srgbClr", { val: "4F81BD" })]),
|
|
1389
|
+
el("a:accent2", {}, [el("a:srgbClr", { val: "C0504D" })]),
|
|
1390
|
+
el("a:accent3", {}, [el("a:srgbClr", { val: "9BBB59" })]),
|
|
1391
|
+
el("a:accent4", {}, [el("a:srgbClr", { val: "8064A2" })]),
|
|
1392
|
+
el("a:accent5", {}, [el("a:srgbClr", { val: "4BACC6" })]),
|
|
1393
|
+
el("a:accent6", {}, [el("a:srgbClr", { val: "F79646" })]),
|
|
1394
|
+
el("a:hlink", {}, [el("a:srgbClr", { val: "0000FF" })]),
|
|
1395
|
+
el("a:folHlink", {}, [el("a:srgbClr", { val: "800080" })])
|
|
1396
|
+
]);
|
|
1397
|
+
const fontScheme = el("a:fontScheme", { name: "Office" }, [el("a:majorFont", {}, [
|
|
1398
|
+
el("a:latin", { typeface: "Calibri Light" }),
|
|
1399
|
+
el("a:ea", { typeface: "" }),
|
|
1400
|
+
el("a:cs", { typeface: "" })
|
|
1401
|
+
]), el("a:minorFont", {}, [
|
|
1402
|
+
el("a:latin", { typeface: "Calibri" }),
|
|
1403
|
+
el("a:ea", { typeface: "" }),
|
|
1404
|
+
el("a:cs", { typeface: "" })
|
|
1405
|
+
])]);
|
|
1406
|
+
return el("a:theme", {
|
|
1407
|
+
"xmlns:a": DML_NS,
|
|
1408
|
+
name: "Office Theme"
|
|
1409
|
+
}, [el("a:themeElements", {}, [
|
|
1410
|
+
clrScheme,
|
|
1411
|
+
fontScheme,
|
|
1412
|
+
buildFormatScheme()
|
|
1413
|
+
])]);
|
|
1414
|
+
}
|
|
1415
|
+
function buildIdentityColorMap() {
|
|
1416
|
+
return el("p:clrMap", {
|
|
1417
|
+
bg1: "lt1",
|
|
1418
|
+
tx1: "dk1",
|
|
1419
|
+
bg2: "lt2",
|
|
1420
|
+
tx2: "dk2",
|
|
1421
|
+
accent1: "accent1",
|
|
1422
|
+
accent2: "accent2",
|
|
1423
|
+
accent3: "accent3",
|
|
1424
|
+
accent4: "accent4",
|
|
1425
|
+
accent5: "accent5",
|
|
1426
|
+
accent6: "accent6",
|
|
1427
|
+
hlink: "hlink",
|
|
1428
|
+
folHlink: "folHlink"
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
function buildWhiteBackground() {
|
|
1432
|
+
return el("p:bg", {}, [el("p:bgPr", {}, [el("a:solidFill", {}, [el("a:srgbClr", { val: "FFFFFF" })]), el("a:effectLst")])]);
|
|
1433
|
+
}
|
|
1434
|
+
function buildSlideMaster(layoutRelationshipId) {
|
|
1435
|
+
return el("p:sldMaster", {
|
|
1436
|
+
"xmlns:p": PML_NS,
|
|
1437
|
+
"xmlns:a": DML_NS,
|
|
1438
|
+
"xmlns:r": R_NS
|
|
1439
|
+
}, [
|
|
1440
|
+
el("p:cSld", {}, [buildWhiteBackground(), buildEmptyGroupSpTree()]),
|
|
1441
|
+
buildIdentityColorMap(),
|
|
1442
|
+
el("p:sldLayoutIdLst", {}, [el("p:sldLayoutId", {
|
|
1443
|
+
id: String(MIN_MASTER_OR_LAYOUT_ID),
|
|
1444
|
+
"r:id": layoutRelationshipId
|
|
1445
|
+
})])
|
|
1446
|
+
]);
|
|
1447
|
+
}
|
|
1448
|
+
function buildSlideLayout() {
|
|
1449
|
+
return el("p:sldLayout", {
|
|
1450
|
+
"xmlns:p": PML_NS,
|
|
1451
|
+
"xmlns:a": DML_NS,
|
|
1452
|
+
"xmlns:r": R_NS,
|
|
1453
|
+
type: "blank",
|
|
1454
|
+
preserve: "1"
|
|
1455
|
+
}, [el("p:cSld", { name: "Blank" }, [buildEmptyGroupSpTree()]), el("p:clrMapOvr", {}, [el("a:masterClrMapping")])]);
|
|
1456
|
+
}
|
|
1329
1457
|
function createEmptyPptxPackage() {
|
|
1330
1458
|
const contentTypes = el("Types", { xmlns: CONTENT_TYPES_NS }, [
|
|
1331
1459
|
el("Default", {
|
|
@@ -1337,24 +1465,16 @@ function createEmptyPptxPackage() {
|
|
|
1337
1465
|
ContentType: "application/xml"
|
|
1338
1466
|
}),
|
|
1339
1467
|
el("Override", {
|
|
1340
|
-
PartName:
|
|
1468
|
+
PartName: `/${PRESENTATION_PART_PATH$1}`,
|
|
1341
1469
|
ContentType: "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"
|
|
1342
1470
|
})
|
|
1343
1471
|
]);
|
|
1344
1472
|
const rootRels = el("Relationships", { xmlns: RELS_NS }, [el("Relationship", {
|
|
1345
1473
|
Id: "rId1",
|
|
1346
1474
|
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
1347
|
-
Target:
|
|
1475
|
+
Target: PRESENTATION_PART_PATH$1
|
|
1348
1476
|
})]);
|
|
1349
|
-
const
|
|
1350
|
-
"xmlns:p": PML_NS,
|
|
1351
|
-
"xmlns:r": R_NS
|
|
1352
|
-
}, [el("p:sldIdLst"), el("p:sldSz", {
|
|
1353
|
-
cx: DEFAULT_SLIDE_WIDTH_EMU,
|
|
1354
|
-
cy: DEFAULT_SLIDE_HEIGHT_EMU
|
|
1355
|
-
})]);
|
|
1356
|
-
const presentationRels = el("Relationships", { xmlns: RELS_NS }, []);
|
|
1357
|
-
return { parts: {
|
|
1477
|
+
const pkg = { parts: {
|
|
1358
1478
|
"[Content_Types].xml": {
|
|
1359
1479
|
kind: "xml",
|
|
1360
1480
|
nodes: [declaration(), contentTypes]
|
|
@@ -1363,15 +1483,60 @@ function createEmptyPptxPackage() {
|
|
|
1363
1483
|
kind: "xml",
|
|
1364
1484
|
nodes: [declaration(), rootRels]
|
|
1365
1485
|
},
|
|
1366
|
-
|
|
1486
|
+
[PRESENTATION_PART_PATH$1]: {
|
|
1367
1487
|
kind: "xml",
|
|
1368
|
-
nodes: [declaration(), presentation
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
nodes: [declaration(), presentationRels]
|
|
1488
|
+
nodes: [declaration(), el("p:presentation", {
|
|
1489
|
+
"xmlns:p": PML_NS,
|
|
1490
|
+
"xmlns:r": R_NS
|
|
1491
|
+
})]
|
|
1373
1492
|
}
|
|
1374
1493
|
} };
|
|
1494
|
+
const layoutToMasterTarget = buildRelativeTarget(SLIDE_LAYOUT_PART_PATH, SLIDE_MASTER_PART_PATH);
|
|
1495
|
+
addRelationship(pkg, SLIDE_LAYOUT_PART_PATH, {
|
|
1496
|
+
type: SLIDE_MASTER_REL_TYPE,
|
|
1497
|
+
target: layoutToMasterTarget
|
|
1498
|
+
});
|
|
1499
|
+
pkg.parts[SLIDE_LAYOUT_PART_PATH] = {
|
|
1500
|
+
kind: "xml",
|
|
1501
|
+
nodes: [declaration(), buildSlideLayout()]
|
|
1502
|
+
};
|
|
1503
|
+
ensureContentTypeOverride(pkg, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_CONTENT_TYPE);
|
|
1504
|
+
const masterToLayoutTarget = buildRelativeTarget(SLIDE_MASTER_PART_PATH, SLIDE_LAYOUT_PART_PATH);
|
|
1505
|
+
const masterToLayoutRelId = addRelationship(pkg, SLIDE_MASTER_PART_PATH, {
|
|
1506
|
+
type: SLIDE_LAYOUT_REL_TYPE,
|
|
1507
|
+
target: masterToLayoutTarget
|
|
1508
|
+
});
|
|
1509
|
+
const masterToThemeTarget = buildRelativeTarget(SLIDE_MASTER_PART_PATH, THEME_PART_PATH);
|
|
1510
|
+
addRelationship(pkg, SLIDE_MASTER_PART_PATH, {
|
|
1511
|
+
type: THEME_REL_TYPE,
|
|
1512
|
+
target: masterToThemeTarget
|
|
1513
|
+
});
|
|
1514
|
+
pkg.parts[SLIDE_MASTER_PART_PATH] = {
|
|
1515
|
+
kind: "xml",
|
|
1516
|
+
nodes: [declaration(), buildSlideMaster(masterToLayoutRelId)]
|
|
1517
|
+
};
|
|
1518
|
+
ensureContentTypeOverride(pkg, SLIDE_MASTER_PART_PATH, SLIDE_MASTER_CONTENT_TYPE);
|
|
1519
|
+
pkg.parts[THEME_PART_PATH] = {
|
|
1520
|
+
kind: "xml",
|
|
1521
|
+
nodes: [declaration(), buildTheme()]
|
|
1522
|
+
};
|
|
1523
|
+
ensureContentTypeOverride(pkg, THEME_PART_PATH, THEME_CONTENT_TYPE);
|
|
1524
|
+
const presentationToMasterTarget = buildRelativeTarget(PRESENTATION_PART_PATH$1, SLIDE_MASTER_PART_PATH);
|
|
1525
|
+
const presentationToMasterRelId = addRelationship(pkg, PRESENTATION_PART_PATH$1, {
|
|
1526
|
+
type: SLIDE_MASTER_REL_TYPE,
|
|
1527
|
+
target: presentationToMasterTarget
|
|
1528
|
+
});
|
|
1529
|
+
const presentationPart = pkg.parts[PRESENTATION_PART_PATH$1];
|
|
1530
|
+
const presentationElement = presentationPart?.kind === "xml" ? presentationPart.nodes.find((n) => n.type === "element") : void 0;
|
|
1531
|
+
if (presentationElement === void 0) throw new Error("createEmptyPptxPackage: failed to build ppt/presentation.xml");
|
|
1532
|
+
presentationElement.children.push(el("p:sldMasterIdLst", {}, [el("p:sldMasterId", {
|
|
1533
|
+
id: String(MIN_MASTER_OR_LAYOUT_ID),
|
|
1534
|
+
"r:id": presentationToMasterRelId
|
|
1535
|
+
})]), el("p:sldIdLst"), el("p:sldSz", {
|
|
1536
|
+
cx: DEFAULT_SLIDE_WIDTH_EMU,
|
|
1537
|
+
cy: DEFAULT_SLIDE_HEIGHT_EMU
|
|
1538
|
+
}));
|
|
1539
|
+
return pkg;
|
|
1375
1540
|
}
|
|
1376
1541
|
//#endregion
|
|
1377
1542
|
//#region src/edit/pptx/shape.ts
|
|
@@ -1730,7 +1895,11 @@ function nextSlidePartIndex(pkg) {
|
|
|
1730
1895
|
return max + 1;
|
|
1731
1896
|
}
|
|
1732
1897
|
function buildEmptySlideRoot() {
|
|
1733
|
-
return el("p:sld", {
|
|
1898
|
+
return el("p:sld", {
|
|
1899
|
+
"xmlns:p": PML_NS,
|
|
1900
|
+
"xmlns:a": DML_NS,
|
|
1901
|
+
"xmlns:r": R_NS
|
|
1902
|
+
}, [el("p:cSld", {}, [buildEmptyGroupSpTree()])]);
|
|
1734
1903
|
}
|
|
1735
1904
|
var PptxEditor = class {
|
|
1736
1905
|
pkg;
|
|
@@ -1772,6 +1941,10 @@ var PptxEditor = class {
|
|
|
1772
1941
|
type: SLIDE_RELATIONSHIP_TYPE,
|
|
1773
1942
|
target: `slides/slide${partIndex}.xml`
|
|
1774
1943
|
});
|
|
1944
|
+
addRelationship(this.pkg, slidePartPath, {
|
|
1945
|
+
type: SLIDE_LAYOUT_REL_TYPE,
|
|
1946
|
+
target: buildRelativeTarget(slidePartPath, SLIDE_LAYOUT_PART_PATH)
|
|
1947
|
+
});
|
|
1775
1948
|
const slideId = nextSlideId(sldIdLst);
|
|
1776
1949
|
sldIdLst.children.push(el("p:sldId", {
|
|
1777
1950
|
id: String(slideId),
|
package/dist/index.d.cts
CHANGED
|
@@ -265,12 +265,12 @@ declare const LayoutTextSchema: z.ZodObject<{
|
|
|
265
265
|
font: z.ZodObject<{
|
|
266
266
|
family: z.ZodString;
|
|
267
267
|
weight: z.ZodEnum<{
|
|
268
|
-
normal: "normal";
|
|
269
268
|
bold: "bold";
|
|
269
|
+
normal: "normal";
|
|
270
270
|
}>;
|
|
271
271
|
style: z.ZodEnum<{
|
|
272
|
-
normal: "normal";
|
|
273
272
|
italic: "italic";
|
|
273
|
+
normal: "normal";
|
|
274
274
|
}>;
|
|
275
275
|
}, z.core.$strip>;
|
|
276
276
|
sizePt: z.ZodNumber;
|
|
@@ -367,12 +367,12 @@ declare const LayoutItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
367
367
|
font: z.ZodObject<{
|
|
368
368
|
family: z.ZodString;
|
|
369
369
|
weight: z.ZodEnum<{
|
|
370
|
-
normal: "normal";
|
|
371
370
|
bold: "bold";
|
|
371
|
+
normal: "normal";
|
|
372
372
|
}>;
|
|
373
373
|
style: z.ZodEnum<{
|
|
374
|
-
normal: "normal";
|
|
375
374
|
italic: "italic";
|
|
375
|
+
normal: "normal";
|
|
376
376
|
}>;
|
|
377
377
|
}, z.core.$strip>;
|
|
378
378
|
sizePt: z.ZodNumber;
|
|
@@ -462,12 +462,12 @@ declare const LayoutPageSchema: z.ZodObject<{
|
|
|
462
462
|
font: z.ZodObject<{
|
|
463
463
|
family: z.ZodString;
|
|
464
464
|
weight: z.ZodEnum<{
|
|
465
|
-
normal: "normal";
|
|
466
465
|
bold: "bold";
|
|
466
|
+
normal: "normal";
|
|
467
467
|
}>;
|
|
468
468
|
style: z.ZodEnum<{
|
|
469
|
-
normal: "normal";
|
|
470
469
|
italic: "italic";
|
|
470
|
+
normal: "normal";
|
|
471
471
|
}>;
|
|
472
472
|
}, z.core.$strip>;
|
|
473
473
|
sizePt: z.ZodNumber;
|
|
@@ -591,12 +591,12 @@ declare const LayoutDocumentSchema: z.ZodObject<{
|
|
|
591
591
|
font: z.ZodObject<{
|
|
592
592
|
family: z.ZodString;
|
|
593
593
|
weight: z.ZodEnum<{
|
|
594
|
-
normal: "normal";
|
|
595
594
|
bold: "bold";
|
|
595
|
+
normal: "normal";
|
|
596
596
|
}>;
|
|
597
597
|
style: z.ZodEnum<{
|
|
598
|
-
normal: "normal";
|
|
599
598
|
italic: "italic";
|
|
599
|
+
normal: "normal";
|
|
600
600
|
}>;
|
|
601
601
|
}, z.core.$strip>;
|
|
602
602
|
sizePt: z.ZodNumber;
|
|
@@ -694,12 +694,12 @@ declare function flipY(box: Box$1, containerHeightPt: number): Box$1;
|
|
|
694
694
|
declare const LayoutFontSchema: z.ZodObject<{
|
|
695
695
|
family: z.ZodString;
|
|
696
696
|
weight: z.ZodEnum<{
|
|
697
|
-
normal: "normal";
|
|
698
697
|
bold: "bold";
|
|
698
|
+
normal: "normal";
|
|
699
699
|
}>;
|
|
700
700
|
style: z.ZodEnum<{
|
|
701
|
-
normal: "normal";
|
|
702
701
|
italic: "italic";
|
|
702
|
+
normal: "normal";
|
|
703
703
|
}>;
|
|
704
704
|
}, z.core.$strip>;
|
|
705
705
|
type LayoutFont = z.infer<typeof LayoutFontSchema>;
|
|
@@ -991,12 +991,12 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
991
991
|
font: z.ZodObject<{
|
|
992
992
|
family: z.ZodString;
|
|
993
993
|
weight: z.ZodEnum<{
|
|
994
|
-
normal: "normal";
|
|
995
994
|
bold: "bold";
|
|
995
|
+
normal: "normal";
|
|
996
996
|
}>;
|
|
997
997
|
style: z.ZodEnum<{
|
|
998
|
-
normal: "normal";
|
|
999
998
|
italic: "italic";
|
|
999
|
+
normal: "normal";
|
|
1000
1000
|
}>;
|
|
1001
1001
|
}, z.core.$strip>;
|
|
1002
1002
|
sizePt: z.ZodNumber;
|
package/dist/index.d.ts
CHANGED
|
@@ -265,12 +265,12 @@ declare const LayoutTextSchema: z.ZodObject<{
|
|
|
265
265
|
font: z.ZodObject<{
|
|
266
266
|
family: z.ZodString;
|
|
267
267
|
weight: z.ZodEnum<{
|
|
268
|
-
normal: "normal";
|
|
269
268
|
bold: "bold";
|
|
269
|
+
normal: "normal";
|
|
270
270
|
}>;
|
|
271
271
|
style: z.ZodEnum<{
|
|
272
|
-
normal: "normal";
|
|
273
272
|
italic: "italic";
|
|
273
|
+
normal: "normal";
|
|
274
274
|
}>;
|
|
275
275
|
}, z.core.$strip>;
|
|
276
276
|
sizePt: z.ZodNumber;
|
|
@@ -367,12 +367,12 @@ declare const LayoutItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
367
367
|
font: z.ZodObject<{
|
|
368
368
|
family: z.ZodString;
|
|
369
369
|
weight: z.ZodEnum<{
|
|
370
|
-
normal: "normal";
|
|
371
370
|
bold: "bold";
|
|
371
|
+
normal: "normal";
|
|
372
372
|
}>;
|
|
373
373
|
style: z.ZodEnum<{
|
|
374
|
-
normal: "normal";
|
|
375
374
|
italic: "italic";
|
|
375
|
+
normal: "normal";
|
|
376
376
|
}>;
|
|
377
377
|
}, z.core.$strip>;
|
|
378
378
|
sizePt: z.ZodNumber;
|
|
@@ -462,12 +462,12 @@ declare const LayoutPageSchema: z.ZodObject<{
|
|
|
462
462
|
font: z.ZodObject<{
|
|
463
463
|
family: z.ZodString;
|
|
464
464
|
weight: z.ZodEnum<{
|
|
465
|
-
normal: "normal";
|
|
466
465
|
bold: "bold";
|
|
466
|
+
normal: "normal";
|
|
467
467
|
}>;
|
|
468
468
|
style: z.ZodEnum<{
|
|
469
|
-
normal: "normal";
|
|
470
469
|
italic: "italic";
|
|
470
|
+
normal: "normal";
|
|
471
471
|
}>;
|
|
472
472
|
}, z.core.$strip>;
|
|
473
473
|
sizePt: z.ZodNumber;
|
|
@@ -591,12 +591,12 @@ declare const LayoutDocumentSchema: z.ZodObject<{
|
|
|
591
591
|
font: z.ZodObject<{
|
|
592
592
|
family: z.ZodString;
|
|
593
593
|
weight: z.ZodEnum<{
|
|
594
|
-
normal: "normal";
|
|
595
594
|
bold: "bold";
|
|
595
|
+
normal: "normal";
|
|
596
596
|
}>;
|
|
597
597
|
style: z.ZodEnum<{
|
|
598
|
-
normal: "normal";
|
|
599
598
|
italic: "italic";
|
|
599
|
+
normal: "normal";
|
|
600
600
|
}>;
|
|
601
601
|
}, z.core.$strip>;
|
|
602
602
|
sizePt: z.ZodNumber;
|
|
@@ -694,12 +694,12 @@ declare function flipY(box: Box$1, containerHeightPt: number): Box$1;
|
|
|
694
694
|
declare const LayoutFontSchema: z.ZodObject<{
|
|
695
695
|
family: z.ZodString;
|
|
696
696
|
weight: z.ZodEnum<{
|
|
697
|
-
normal: "normal";
|
|
698
697
|
bold: "bold";
|
|
698
|
+
normal: "normal";
|
|
699
699
|
}>;
|
|
700
700
|
style: z.ZodEnum<{
|
|
701
|
-
normal: "normal";
|
|
702
701
|
italic: "italic";
|
|
702
|
+
normal: "normal";
|
|
703
703
|
}>;
|
|
704
704
|
}, z.core.$strip>;
|
|
705
705
|
type LayoutFont = z.infer<typeof LayoutFontSchema>;
|
|
@@ -991,12 +991,12 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
991
991
|
font: z.ZodObject<{
|
|
992
992
|
family: z.ZodString;
|
|
993
993
|
weight: z.ZodEnum<{
|
|
994
|
-
normal: "normal";
|
|
995
994
|
bold: "bold";
|
|
995
|
+
normal: "normal";
|
|
996
996
|
}>;
|
|
997
997
|
style: z.ZodEnum<{
|
|
998
|
-
normal: "normal";
|
|
999
998
|
italic: "italic";
|
|
999
|
+
normal: "normal";
|
|
1000
1000
|
}>;
|
|
1001
1001
|
}, z.core.$strip>;
|
|
1002
1002
|
sizePt: z.ZodNumber;
|
package/dist/index.js
CHANGED
|
@@ -1303,9 +1303,21 @@ function appendBlock(body, block) {
|
|
|
1303
1303
|
const CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
1304
1304
|
const RELS_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
1305
1305
|
const PML_NS = "http://schemas.openxmlformats.org/presentationml/2006/main";
|
|
1306
|
+
const DML_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
1306
1307
|
const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
1307
1308
|
const DEFAULT_SLIDE_WIDTH_EMU = "12192000";
|
|
1308
1309
|
const DEFAULT_SLIDE_HEIGHT_EMU = "6858000";
|
|
1310
|
+
const SLIDE_MASTER_PART_PATH = "ppt/slideMasters/slideMaster1.xml";
|
|
1311
|
+
const SLIDE_LAYOUT_PART_PATH = "ppt/slideLayouts/slideLayout1.xml";
|
|
1312
|
+
const THEME_PART_PATH = "ppt/theme/theme1.xml";
|
|
1313
|
+
const PRESENTATION_PART_PATH$1 = "ppt/presentation.xml";
|
|
1314
|
+
const SLIDE_MASTER_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
|
|
1315
|
+
const SLIDE_LAYOUT_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
|
|
1316
|
+
const THEME_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
1317
|
+
const SLIDE_MASTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
|
|
1318
|
+
const SLIDE_LAYOUT_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
|
1319
|
+
const THEME_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
|
|
1320
|
+
const MIN_MASTER_OR_LAYOUT_ID = 2147483648;
|
|
1309
1321
|
function declaration() {
|
|
1310
1322
|
return {
|
|
1311
1323
|
type: "declaration",
|
|
@@ -1325,6 +1337,122 @@ function declaration() {
|
|
|
1325
1337
|
]
|
|
1326
1338
|
};
|
|
1327
1339
|
}
|
|
1340
|
+
function buildEmptyGroupSpTree() {
|
|
1341
|
+
return el("p:spTree", {}, [el("p:nvGrpSpPr", {}, [
|
|
1342
|
+
el("p:cNvPr", {
|
|
1343
|
+
id: "1",
|
|
1344
|
+
name: ""
|
|
1345
|
+
}),
|
|
1346
|
+
el("p:cNvGrpSpPr"),
|
|
1347
|
+
el("p:nvPr")
|
|
1348
|
+
]), el("p:grpSpPr")]);
|
|
1349
|
+
}
|
|
1350
|
+
function buildFormatScheme() {
|
|
1351
|
+
const solidPhClr = () => el("a:solidFill", {}, [el("a:schemeClr", { val: "phClr" })]);
|
|
1352
|
+
return el("a:fmtScheme", { name: "Office" }, [
|
|
1353
|
+
el("a:fillStyleLst", {}, [
|
|
1354
|
+
solidPhClr(),
|
|
1355
|
+
solidPhClr(),
|
|
1356
|
+
solidPhClr()
|
|
1357
|
+
]),
|
|
1358
|
+
el("a:lnStyleLst", {}, [
|
|
1359
|
+
el("a:ln", {}, [solidPhClr()]),
|
|
1360
|
+
el("a:ln", {}, [solidPhClr()]),
|
|
1361
|
+
el("a:ln", {}, [solidPhClr()])
|
|
1362
|
+
]),
|
|
1363
|
+
el("a:effectStyleLst", {}, [
|
|
1364
|
+
el("a:effectStyle", {}, [el("a:effectLst")]),
|
|
1365
|
+
el("a:effectStyle", {}, [el("a:effectLst")]),
|
|
1366
|
+
el("a:effectStyle", {}, [el("a:effectLst")])
|
|
1367
|
+
]),
|
|
1368
|
+
el("a:bgFillStyleLst", {}, [
|
|
1369
|
+
solidPhClr(),
|
|
1370
|
+
solidPhClr(),
|
|
1371
|
+
solidPhClr()
|
|
1372
|
+
])
|
|
1373
|
+
]);
|
|
1374
|
+
}
|
|
1375
|
+
function buildTheme() {
|
|
1376
|
+
const clrScheme = el("a:clrScheme", { name: "Office" }, [
|
|
1377
|
+
el("a:dk1", {}, [el("a:sysClr", {
|
|
1378
|
+
val: "windowText",
|
|
1379
|
+
lastClr: "000000"
|
|
1380
|
+
})]),
|
|
1381
|
+
el("a:lt1", {}, [el("a:sysClr", {
|
|
1382
|
+
val: "window",
|
|
1383
|
+
lastClr: "FFFFFF"
|
|
1384
|
+
})]),
|
|
1385
|
+
el("a:dk2", {}, [el("a:srgbClr", { val: "1F497D" })]),
|
|
1386
|
+
el("a:lt2", {}, [el("a:srgbClr", { val: "EEECE1" })]),
|
|
1387
|
+
el("a:accent1", {}, [el("a:srgbClr", { val: "4F81BD" })]),
|
|
1388
|
+
el("a:accent2", {}, [el("a:srgbClr", { val: "C0504D" })]),
|
|
1389
|
+
el("a:accent3", {}, [el("a:srgbClr", { val: "9BBB59" })]),
|
|
1390
|
+
el("a:accent4", {}, [el("a:srgbClr", { val: "8064A2" })]),
|
|
1391
|
+
el("a:accent5", {}, [el("a:srgbClr", { val: "4BACC6" })]),
|
|
1392
|
+
el("a:accent6", {}, [el("a:srgbClr", { val: "F79646" })]),
|
|
1393
|
+
el("a:hlink", {}, [el("a:srgbClr", { val: "0000FF" })]),
|
|
1394
|
+
el("a:folHlink", {}, [el("a:srgbClr", { val: "800080" })])
|
|
1395
|
+
]);
|
|
1396
|
+
const fontScheme = el("a:fontScheme", { name: "Office" }, [el("a:majorFont", {}, [
|
|
1397
|
+
el("a:latin", { typeface: "Calibri Light" }),
|
|
1398
|
+
el("a:ea", { typeface: "" }),
|
|
1399
|
+
el("a:cs", { typeface: "" })
|
|
1400
|
+
]), el("a:minorFont", {}, [
|
|
1401
|
+
el("a:latin", { typeface: "Calibri" }),
|
|
1402
|
+
el("a:ea", { typeface: "" }),
|
|
1403
|
+
el("a:cs", { typeface: "" })
|
|
1404
|
+
])]);
|
|
1405
|
+
return el("a:theme", {
|
|
1406
|
+
"xmlns:a": DML_NS,
|
|
1407
|
+
name: "Office Theme"
|
|
1408
|
+
}, [el("a:themeElements", {}, [
|
|
1409
|
+
clrScheme,
|
|
1410
|
+
fontScheme,
|
|
1411
|
+
buildFormatScheme()
|
|
1412
|
+
])]);
|
|
1413
|
+
}
|
|
1414
|
+
function buildIdentityColorMap() {
|
|
1415
|
+
return el("p:clrMap", {
|
|
1416
|
+
bg1: "lt1",
|
|
1417
|
+
tx1: "dk1",
|
|
1418
|
+
bg2: "lt2",
|
|
1419
|
+
tx2: "dk2",
|
|
1420
|
+
accent1: "accent1",
|
|
1421
|
+
accent2: "accent2",
|
|
1422
|
+
accent3: "accent3",
|
|
1423
|
+
accent4: "accent4",
|
|
1424
|
+
accent5: "accent5",
|
|
1425
|
+
accent6: "accent6",
|
|
1426
|
+
hlink: "hlink",
|
|
1427
|
+
folHlink: "folHlink"
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
function buildWhiteBackground() {
|
|
1431
|
+
return el("p:bg", {}, [el("p:bgPr", {}, [el("a:solidFill", {}, [el("a:srgbClr", { val: "FFFFFF" })]), el("a:effectLst")])]);
|
|
1432
|
+
}
|
|
1433
|
+
function buildSlideMaster(layoutRelationshipId) {
|
|
1434
|
+
return el("p:sldMaster", {
|
|
1435
|
+
"xmlns:p": PML_NS,
|
|
1436
|
+
"xmlns:a": DML_NS,
|
|
1437
|
+
"xmlns:r": R_NS
|
|
1438
|
+
}, [
|
|
1439
|
+
el("p:cSld", {}, [buildWhiteBackground(), buildEmptyGroupSpTree()]),
|
|
1440
|
+
buildIdentityColorMap(),
|
|
1441
|
+
el("p:sldLayoutIdLst", {}, [el("p:sldLayoutId", {
|
|
1442
|
+
id: String(MIN_MASTER_OR_LAYOUT_ID),
|
|
1443
|
+
"r:id": layoutRelationshipId
|
|
1444
|
+
})])
|
|
1445
|
+
]);
|
|
1446
|
+
}
|
|
1447
|
+
function buildSlideLayout() {
|
|
1448
|
+
return el("p:sldLayout", {
|
|
1449
|
+
"xmlns:p": PML_NS,
|
|
1450
|
+
"xmlns:a": DML_NS,
|
|
1451
|
+
"xmlns:r": R_NS,
|
|
1452
|
+
type: "blank",
|
|
1453
|
+
preserve: "1"
|
|
1454
|
+
}, [el("p:cSld", { name: "Blank" }, [buildEmptyGroupSpTree()]), el("p:clrMapOvr", {}, [el("a:masterClrMapping")])]);
|
|
1455
|
+
}
|
|
1328
1456
|
function createEmptyPptxPackage() {
|
|
1329
1457
|
const contentTypes = el("Types", { xmlns: CONTENT_TYPES_NS }, [
|
|
1330
1458
|
el("Default", {
|
|
@@ -1336,24 +1464,16 @@ function createEmptyPptxPackage() {
|
|
|
1336
1464
|
ContentType: "application/xml"
|
|
1337
1465
|
}),
|
|
1338
1466
|
el("Override", {
|
|
1339
|
-
PartName:
|
|
1467
|
+
PartName: `/${PRESENTATION_PART_PATH$1}`,
|
|
1340
1468
|
ContentType: "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"
|
|
1341
1469
|
})
|
|
1342
1470
|
]);
|
|
1343
1471
|
const rootRels = el("Relationships", { xmlns: RELS_NS }, [el("Relationship", {
|
|
1344
1472
|
Id: "rId1",
|
|
1345
1473
|
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
1346
|
-
Target:
|
|
1474
|
+
Target: PRESENTATION_PART_PATH$1
|
|
1347
1475
|
})]);
|
|
1348
|
-
const
|
|
1349
|
-
"xmlns:p": PML_NS,
|
|
1350
|
-
"xmlns:r": R_NS
|
|
1351
|
-
}, [el("p:sldIdLst"), el("p:sldSz", {
|
|
1352
|
-
cx: DEFAULT_SLIDE_WIDTH_EMU,
|
|
1353
|
-
cy: DEFAULT_SLIDE_HEIGHT_EMU
|
|
1354
|
-
})]);
|
|
1355
|
-
const presentationRels = el("Relationships", { xmlns: RELS_NS }, []);
|
|
1356
|
-
return { parts: {
|
|
1476
|
+
const pkg = { parts: {
|
|
1357
1477
|
"[Content_Types].xml": {
|
|
1358
1478
|
kind: "xml",
|
|
1359
1479
|
nodes: [declaration(), contentTypes]
|
|
@@ -1362,15 +1482,60 @@ function createEmptyPptxPackage() {
|
|
|
1362
1482
|
kind: "xml",
|
|
1363
1483
|
nodes: [declaration(), rootRels]
|
|
1364
1484
|
},
|
|
1365
|
-
|
|
1485
|
+
[PRESENTATION_PART_PATH$1]: {
|
|
1366
1486
|
kind: "xml",
|
|
1367
|
-
nodes: [declaration(), presentation
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
nodes: [declaration(), presentationRels]
|
|
1487
|
+
nodes: [declaration(), el("p:presentation", {
|
|
1488
|
+
"xmlns:p": PML_NS,
|
|
1489
|
+
"xmlns:r": R_NS
|
|
1490
|
+
})]
|
|
1372
1491
|
}
|
|
1373
1492
|
} };
|
|
1493
|
+
const layoutToMasterTarget = buildRelativeTarget(SLIDE_LAYOUT_PART_PATH, SLIDE_MASTER_PART_PATH);
|
|
1494
|
+
addRelationship(pkg, SLIDE_LAYOUT_PART_PATH, {
|
|
1495
|
+
type: SLIDE_MASTER_REL_TYPE,
|
|
1496
|
+
target: layoutToMasterTarget
|
|
1497
|
+
});
|
|
1498
|
+
pkg.parts[SLIDE_LAYOUT_PART_PATH] = {
|
|
1499
|
+
kind: "xml",
|
|
1500
|
+
nodes: [declaration(), buildSlideLayout()]
|
|
1501
|
+
};
|
|
1502
|
+
ensureContentTypeOverride(pkg, SLIDE_LAYOUT_PART_PATH, SLIDE_LAYOUT_CONTENT_TYPE);
|
|
1503
|
+
const masterToLayoutTarget = buildRelativeTarget(SLIDE_MASTER_PART_PATH, SLIDE_LAYOUT_PART_PATH);
|
|
1504
|
+
const masterToLayoutRelId = addRelationship(pkg, SLIDE_MASTER_PART_PATH, {
|
|
1505
|
+
type: SLIDE_LAYOUT_REL_TYPE,
|
|
1506
|
+
target: masterToLayoutTarget
|
|
1507
|
+
});
|
|
1508
|
+
const masterToThemeTarget = buildRelativeTarget(SLIDE_MASTER_PART_PATH, THEME_PART_PATH);
|
|
1509
|
+
addRelationship(pkg, SLIDE_MASTER_PART_PATH, {
|
|
1510
|
+
type: THEME_REL_TYPE,
|
|
1511
|
+
target: masterToThemeTarget
|
|
1512
|
+
});
|
|
1513
|
+
pkg.parts[SLIDE_MASTER_PART_PATH] = {
|
|
1514
|
+
kind: "xml",
|
|
1515
|
+
nodes: [declaration(), buildSlideMaster(masterToLayoutRelId)]
|
|
1516
|
+
};
|
|
1517
|
+
ensureContentTypeOverride(pkg, SLIDE_MASTER_PART_PATH, SLIDE_MASTER_CONTENT_TYPE);
|
|
1518
|
+
pkg.parts[THEME_PART_PATH] = {
|
|
1519
|
+
kind: "xml",
|
|
1520
|
+
nodes: [declaration(), buildTheme()]
|
|
1521
|
+
};
|
|
1522
|
+
ensureContentTypeOverride(pkg, THEME_PART_PATH, THEME_CONTENT_TYPE);
|
|
1523
|
+
const presentationToMasterTarget = buildRelativeTarget(PRESENTATION_PART_PATH$1, SLIDE_MASTER_PART_PATH);
|
|
1524
|
+
const presentationToMasterRelId = addRelationship(pkg, PRESENTATION_PART_PATH$1, {
|
|
1525
|
+
type: SLIDE_MASTER_REL_TYPE,
|
|
1526
|
+
target: presentationToMasterTarget
|
|
1527
|
+
});
|
|
1528
|
+
const presentationPart = pkg.parts[PRESENTATION_PART_PATH$1];
|
|
1529
|
+
const presentationElement = presentationPart?.kind === "xml" ? presentationPart.nodes.find((n) => n.type === "element") : void 0;
|
|
1530
|
+
if (presentationElement === void 0) throw new Error("createEmptyPptxPackage: failed to build ppt/presentation.xml");
|
|
1531
|
+
presentationElement.children.push(el("p:sldMasterIdLst", {}, [el("p:sldMasterId", {
|
|
1532
|
+
id: String(MIN_MASTER_OR_LAYOUT_ID),
|
|
1533
|
+
"r:id": presentationToMasterRelId
|
|
1534
|
+
})]), el("p:sldIdLst"), el("p:sldSz", {
|
|
1535
|
+
cx: DEFAULT_SLIDE_WIDTH_EMU,
|
|
1536
|
+
cy: DEFAULT_SLIDE_HEIGHT_EMU
|
|
1537
|
+
}));
|
|
1538
|
+
return pkg;
|
|
1374
1539
|
}
|
|
1375
1540
|
//#endregion
|
|
1376
1541
|
//#region src/edit/pptx/shape.ts
|
|
@@ -1729,7 +1894,11 @@ function nextSlidePartIndex(pkg) {
|
|
|
1729
1894
|
return max + 1;
|
|
1730
1895
|
}
|
|
1731
1896
|
function buildEmptySlideRoot() {
|
|
1732
|
-
return el("p:sld", {
|
|
1897
|
+
return el("p:sld", {
|
|
1898
|
+
"xmlns:p": PML_NS,
|
|
1899
|
+
"xmlns:a": DML_NS,
|
|
1900
|
+
"xmlns:r": R_NS
|
|
1901
|
+
}, [el("p:cSld", {}, [buildEmptyGroupSpTree()])]);
|
|
1733
1902
|
}
|
|
1734
1903
|
var PptxEditor = class {
|
|
1735
1904
|
pkg;
|
|
@@ -1771,6 +1940,10 @@ var PptxEditor = class {
|
|
|
1771
1940
|
type: SLIDE_RELATIONSHIP_TYPE,
|
|
1772
1941
|
target: `slides/slide${partIndex}.xml`
|
|
1773
1942
|
});
|
|
1943
|
+
addRelationship(this.pkg, slidePartPath, {
|
|
1944
|
+
type: SLIDE_LAYOUT_REL_TYPE,
|
|
1945
|
+
target: buildRelativeTarget(slidePartPath, SLIDE_LAYOUT_PART_PATH)
|
|
1946
|
+
});
|
|
1774
1947
|
const slideId = nextSlideId(sldIdLst);
|
|
1775
1948
|
sldIdLst.children.push(el("p:sldId", {
|
|
1776
1949
|
id: String(slideId),
|
package/package.json
CHANGED