@officedk/pptxdk 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/build.d.ts +94 -0
- package/dist/build.js +148 -0
- package/dist/capabilities/dist/all.js +32 -0
- package/dist/capabilities/dist/box/box-codegen.js +51 -0
- package/dist/capabilities/dist/box/box-declaration.js +31 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +138 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +77 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2272 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1078 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1124 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +190 -0
- package/dist/capabilities/dist/chart/preview/layout.js +519 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +48 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +148 -0
- package/dist/capabilities/dist/font/font-embedding.js +289 -0
- package/dist/capabilities/dist/font/font-family.js +10 -0
- package/dist/capabilities/dist/font/font-import.js +302 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +25 -0
- package/dist/capabilities/dist/group/group-codegen.js +51 -0
- package/dist/capabilities/dist/group/group-declaration.js +42 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +319 -0
- package/dist/capabilities/dist/group/group-xml.js +7 -0
- package/dist/capabilities/dist/group/group.js +211 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +94 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +221 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +778 -0
- package/dist/capabilities/dist/image/image-schemas.js +149 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +472 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +527 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1033 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
- package/dist/capabilities/dist/motion/motion-query.js +420 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
- package/dist/capabilities/dist/motion/motion.js +1372 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +191 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +579 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +337 -0
- package/dist/capabilities/dist/shared/geometry.js +1423 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
- package/dist/capabilities/dist/shared/style-parse.js +11 -0
- package/dist/capabilities/dist/shared/text-schemas.js +216 -0
- package/dist/capabilities/dist/shared/text-service.js +1883 -0
- package/dist/capabilities/dist/shared/visual.js +918 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
- package/dist/capabilities/dist/table/table-codegen.js +81 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +539 -0
- package/dist/capabilities/dist/table/table-schemas.js +279 -0
- package/dist/capabilities/dist/table/table-xml.js +37 -0
- package/dist/capabilities/dist/table/table.js +662 -0
- package/dist/capabilities/dist/text/text-codegen.js +129 -0
- package/dist/capabilities/dist/text/text-declaration.js +19 -0
- package/dist/capabilities/dist/text/text-elements.js +38 -0
- package/dist/capabilities/dist/text/text-import.js +1077 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +335 -0
- package/dist/capabilities/dist/transition/transition-api.js +139 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-D_xeNVIw.d.ts +29496 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +78 -0
- package/dist/codegen/dist/codegen.js +611 -0
- package/dist/codegen/dist/identifiers.js +193 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +49 -0
- package/dist/core/dist/author-ids.js +48 -0
- package/dist/core/dist/author-schemas.js +313 -0
- package/dist/core/dist/block-flex-layout.js +749 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +13 -0
- package/dist/core/dist/declaration.js +15 -0
- package/dist/core/dist/diagnostics.js +21 -0
- package/dist/core/dist/document-internals.js +13 -0
- package/dist/core/dist/document.js +408 -0
- package/dist/core/dist/geometry-schemas.js +249 -0
- package/dist/core/dist/grid-layout.js +445 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +45 -0
- package/dist/core/dist/layout-protocol.js +66 -0
- package/dist/core/dist/layout-schemas.js +208 -0
- package/dist/core/dist/layout.js +299 -0
- package/dist/core/dist/masters.js +169 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +213 -0
- package/dist/core/dist/query.js +155 -0
- package/dist/core/dist/resolution.js +11 -0
- package/dist/core/dist/resolve.js +1827 -0
- package/dist/core/dist/stage-options.js +67 -0
- package/dist/core/dist/theme.js +931 -0
- package/dist/document-BHPUODPP.d.ts +27759 -0
- package/dist/emit/dist/emit.js +936 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +606 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +153 -0
- package/dist/import/dist/fonts.js +250 -0
- package/dist/import/dist/import.js +504 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1153 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +60 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +671 -0
- package/dist/import/dist/visual.js +761 -0
- package/dist/import/dist/xml-fragments.js +36 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-B5m3hqjC.d.ts +7 -0
- package/dist/index-CCy-Yo8G.d.ts +1208 -0
- package/dist/index-DpxcZ4Gs.d.ts +725 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +70 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +194 -0
- package/dist/pptxdk/src/cli-commands.js +913 -0
- package/dist/pptxdk/src/compose.js +44 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +240 -0
- package/dist/preview/dist/options.js +53 -0
- package/dist/preview-Cfw0QdMM.d.ts +86 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +27 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +65 -0
- package/dist/react/dist/elements.js +59 -0
- package/dist/react/dist/index.js +68 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +145 -0
- package/dist/react.js +27 -0
- package/dist/transition-Cips9wma.d.ts +82 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +14 -0
- package/package.json +78 -3
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { A_NS, DIAGRAM_NS, P_NS, REL_DIAGRAM_COLORS, REL_DIAGRAM_DATA, REL_DIAGRAM_LAYOUT, REL_DIAGRAM_QUICK_STYLE, R_NS } from "./namespaces.js";
|
|
2
|
+
import { resolvePartPath } from "./opc.js";
|
|
3
|
+
// ../import/dist/resources.js
|
|
4
|
+
/** Reads and indexes all OPC relationships owned by `sourcePartPath`. */
|
|
5
|
+
function buildRelationshipIndex(pkg, sourcePartPath) {
|
|
6
|
+
const { entries, diagnostics } = pkg.readRelationships(sourcePartPath);
|
|
7
|
+
const byId = /* @__PURE__ */ new Map();
|
|
8
|
+
for (const entry of entries) byId.set(entry.Id, entry);
|
|
9
|
+
return {
|
|
10
|
+
byId,
|
|
11
|
+
entries,
|
|
12
|
+
diagnostics
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves an internal OPC relationship ID to detached target part bytes without touching external URLs.
|
|
17
|
+
*/
|
|
18
|
+
function resolveInternalRelationshipTarget(pkg, relationships, sourcePartPath, relationshipId, location, expectedType) {
|
|
19
|
+
const rel = relationships.get(relationshipId);
|
|
20
|
+
if (rel === void 0 || rel.TargetMode === "External" || expectedType !== void 0 && rel.Type !== expectedType) return {
|
|
21
|
+
ok: false,
|
|
22
|
+
diagnostic: {
|
|
23
|
+
code: "broken-relationship",
|
|
24
|
+
category: "corrupt-input",
|
|
25
|
+
disposition: "omitted",
|
|
26
|
+
location,
|
|
27
|
+
relationshipId
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const targetPart = resolvePartPath(sourcePartPath, rel.Target);
|
|
31
|
+
if (targetPart === void 0) return {
|
|
32
|
+
ok: false,
|
|
33
|
+
diagnostic: {
|
|
34
|
+
code: "broken-relationship",
|
|
35
|
+
category: "corrupt-input",
|
|
36
|
+
disposition: "omitted",
|
|
37
|
+
location,
|
|
38
|
+
relationshipId
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const bytes = pkg.readDetachedBytes(targetPart);
|
|
42
|
+
if (bytes === void 0) return {
|
|
43
|
+
ok: false,
|
|
44
|
+
diagnostic: {
|
|
45
|
+
code: "missing-target-part",
|
|
46
|
+
category: "corrupt-input",
|
|
47
|
+
disposition: "omitted",
|
|
48
|
+
location,
|
|
49
|
+
relationshipId,
|
|
50
|
+
targetPart
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
return {
|
|
54
|
+
ok: true,
|
|
55
|
+
targetPart,
|
|
56
|
+
relationship: rel,
|
|
57
|
+
bytes
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Resolves an external OPC relationship (`TargetMode="External"`) without performing any network access. */
|
|
61
|
+
function resolveExternalRelationshipTarget(relationships, relationshipId, location, expectedType) {
|
|
62
|
+
const rel = relationships.get(relationshipId);
|
|
63
|
+
if (rel === void 0 || rel.TargetMode !== "External" || expectedType !== void 0 && rel.Type !== expectedType) return {
|
|
64
|
+
ok: false,
|
|
65
|
+
diagnostic: {
|
|
66
|
+
code: "broken-relationship",
|
|
67
|
+
category: "corrupt-input",
|
|
68
|
+
disposition: "omitted",
|
|
69
|
+
location,
|
|
70
|
+
relationshipId
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
ok: true,
|
|
75
|
+
target: rel.Target,
|
|
76
|
+
relationship: rel
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const diagramRelRoleByAttr = [
|
|
80
|
+
[
|
|
81
|
+
"dm",
|
|
82
|
+
"diagram-data",
|
|
83
|
+
REL_DIAGRAM_DATA
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
"lo",
|
|
87
|
+
"diagram-layout",
|
|
88
|
+
REL_DIAGRAM_LAYOUT
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
"qs",
|
|
92
|
+
"diagram-quick-style",
|
|
93
|
+
REL_DIAGRAM_QUICK_STYLE
|
|
94
|
+
],
|
|
95
|
+
[
|
|
96
|
+
"cs",
|
|
97
|
+
"diagram-colors",
|
|
98
|
+
REL_DIAGRAM_COLORS
|
|
99
|
+
]
|
|
100
|
+
];
|
|
101
|
+
function firstDirectChild(parent, namespaceUri, localName) {
|
|
102
|
+
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
103
|
+
if (child.nodeType !== 1) continue;
|
|
104
|
+
const el = child;
|
|
105
|
+
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Extracts non-visual `cNvPr` id and name from any shape-tree element without mutating cursor tracking. */
|
|
109
|
+
function peekShapeTreeObjectIdentity(element) {
|
|
110
|
+
for (let child = element.firstChild; child !== null; child = child.nextSibling) {
|
|
111
|
+
if (child.nodeType !== 1) continue;
|
|
112
|
+
const el = child;
|
|
113
|
+
if ((el.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main") continue;
|
|
114
|
+
const local = el.localName ?? el.tagName;
|
|
115
|
+
if (local !== "nvSpPr" && local !== "nvPicPr" && local !== "nvGraphicFramePr" && local !== "nvGrpSpPr" && local !== "nvCxnSpPr") continue;
|
|
116
|
+
const cNvPr = firstDirectChild(el, P_NS, "cNvPr");
|
|
117
|
+
if (cNvPr === void 0) return {};
|
|
118
|
+
const rawId = cNvPr.getAttribute("id");
|
|
119
|
+
const parsedId = rawId !== null && /^\d+$/u.test(rawId) ? Number(rawId) : void 0;
|
|
120
|
+
const rawName = cNvPr.getAttribute("name");
|
|
121
|
+
return {
|
|
122
|
+
...parsedId !== void 0 && Number.isSafeInteger(parsedId) ? { objectId: parsedId } : {},
|
|
123
|
+
...rawName !== null && rawName.trim() !== "" ? { objectName: rawName } : {}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
/** Inspects an omitted `<p:graphicFrame>` for `graphicData/@uri` and cascaded diagram relationships. */
|
|
129
|
+
function inspectUnsupportedGraphicFrame(cursor, sourcePartPath, relationships, relationshipEntries) {
|
|
130
|
+
const graphic = firstDirectChild(cursor.element, A_NS, "graphic");
|
|
131
|
+
const graphicData = graphic === void 0 ? void 0 : firstDirectChild(graphic, A_NS, "graphicData");
|
|
132
|
+
const uri = graphicData?.getAttribute("uri") ?? void 0;
|
|
133
|
+
const cascaded = [];
|
|
134
|
+
const seenParts = /* @__PURE__ */ new Set();
|
|
135
|
+
if (graphicData !== void 0 && uri === "http://schemas.openxmlformats.org/drawingml/2006/diagram") {
|
|
136
|
+
const relIds = firstDirectChild(graphicData, DIAGRAM_NS, "relIds");
|
|
137
|
+
if (relIds !== void 0) for (const [attrName, role] of diagramRelRoleByAttr) {
|
|
138
|
+
const rId = relIds.getAttributeNS(R_NS, attrName);
|
|
139
|
+
if (!rId) continue;
|
|
140
|
+
const rel = relationships.get(rId);
|
|
141
|
+
if (rel === void 0 || rel.TargetMode === "External") continue;
|
|
142
|
+
const targetPart = resolvePartPath(sourcePartPath, rel.Target);
|
|
143
|
+
if (targetPart === void 0) continue;
|
|
144
|
+
seenParts.add(targetPart);
|
|
145
|
+
cascaded.push({
|
|
146
|
+
location: { part: targetPart },
|
|
147
|
+
role
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
for (const rel of relationshipEntries) if (rel.Type === "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing" && rel.TargetMode !== "External") {
|
|
151
|
+
const targetPart = resolvePartPath(sourcePartPath, rel.Target);
|
|
152
|
+
if (targetPart !== void 0 && !seenParts.has(targetPart)) {
|
|
153
|
+
seenParts.add(targetPart);
|
|
154
|
+
cascaded.push({
|
|
155
|
+
location: { part: targetPart },
|
|
156
|
+
role: "diagram-drawing"
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
...uri !== void 0 && uri !== "" ? { mechanismHint: uri } : {},
|
|
163
|
+
cascaded
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export { buildRelationshipIndex, inspectUnsupportedGraphicFrame, peekShapeTreeObjectIdentity, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { CommonNode, createSectionNode } from "../../core/dist/document.js";
|
|
2
|
+
import { allocateScopedAuthorId } from "./masters.js";
|
|
3
|
+
import { P14_NS, P_NS } from "./namespaces.js";
|
|
4
|
+
import { ooxmlNonNegativeIntSchema } from "./xml-fragments.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
// ../import/dist/sections.js
|
|
7
|
+
const sectionAttrsXmlSchema = z.object({
|
|
8
|
+
name: z.string().refine((value) => value.trim() !== ""),
|
|
9
|
+
id: z.string().optional()
|
|
10
|
+
});
|
|
11
|
+
const sectionSlideIdXmlSchema = z.object({ id: ooxmlNonNegativeIntSchema });
|
|
12
|
+
function hasMatchingSectionExtension(extLst) {
|
|
13
|
+
for (let child = extLst.element.firstChild; child !== null; child = child.nextSibling) {
|
|
14
|
+
if (child.nodeType !== 1) continue;
|
|
15
|
+
const el = child;
|
|
16
|
+
if ((el.namespaceURI ?? "") === "http://schemas.openxmlformats.org/presentationml/2006/main" && (el.localName ?? el.tagName) === "ext" && el.getAttribute("uri") === "{521415D9-36F7-43E2-AB2F-B90AF26B5E84}") return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads PowerPoint `<p14:sectionLst>` from `ppt/presentation.xml` and groups imported
|
|
22
|
+
* `SlideNode` children into editable `SectionNode` containers while preserving slide order.
|
|
23
|
+
*/
|
|
24
|
+
function importPresentationSections(presCursor, deckNode, slideNodeBySldId, presentationPath, diagnostics) {
|
|
25
|
+
if (deckNode.children.some((child) => child instanceof CommonNode && child.type === "section")) return;
|
|
26
|
+
if ((() => {
|
|
27
|
+
for (let child = presCursor.element.firstChild; child !== null; child = child.nextSibling) {
|
|
28
|
+
if (child.nodeType !== 1) continue;
|
|
29
|
+
const el = child;
|
|
30
|
+
if ((el.namespaceURI ?? "") === "http://schemas.openxmlformats.org/presentationml/2006/main" && (el.localName ?? el.tagName) === "extLst") return el;
|
|
31
|
+
}
|
|
32
|
+
})() === void 0) return;
|
|
33
|
+
const extLst = presCursor.child(P_NS, "extLst");
|
|
34
|
+
if (extLst === void 0) return;
|
|
35
|
+
if (!hasMatchingSectionExtension(extLst)) return;
|
|
36
|
+
const parsedSections = [];
|
|
37
|
+
const assignedSlides = /* @__PURE__ */ new Set();
|
|
38
|
+
const usedSectionNames = /* @__PURE__ */ new Set();
|
|
39
|
+
for (const ext of extLst.children(P_NS, "ext")) {
|
|
40
|
+
if (ext.element.getAttribute("uri") !== "{521415D9-36F7-43E2-AB2F-B90AF26B5E84}") continue;
|
|
41
|
+
ext.consumeAttr("uri");
|
|
42
|
+
const sectionLst = ext.child(P14_NS, "sectionLst");
|
|
43
|
+
if (sectionLst === void 0) continue;
|
|
44
|
+
const sectionCursors = sectionLst.children(P14_NS, "section");
|
|
45
|
+
for (let index = 0; index < sectionCursors.length; index += 1) {
|
|
46
|
+
const sectionCursor = sectionCursors[index];
|
|
47
|
+
const rawAttrs = sectionCursor.attrsObject(["name", "id"]);
|
|
48
|
+
const parsedAttrs = sectionAttrsXmlSchema.safeParse(rawAttrs);
|
|
49
|
+
let sectionName;
|
|
50
|
+
if (!parsedAttrs.success) {
|
|
51
|
+
diagnostics.push({
|
|
52
|
+
code: "invalid-xml-value",
|
|
53
|
+
category: "corrupt-input",
|
|
54
|
+
disposition: "recovered",
|
|
55
|
+
location: {
|
|
56
|
+
part: presentationPath,
|
|
57
|
+
xpath: `${sectionCursor.xpath}/@name`
|
|
58
|
+
},
|
|
59
|
+
attributeOrElement: "p14:section/@name",
|
|
60
|
+
rawValue: rawAttrs["name"] ?? ""
|
|
61
|
+
});
|
|
62
|
+
sectionName = allocateScopedAuthorId(void 0, usedSectionNames, `Section ${index + 1}`);
|
|
63
|
+
} else {
|
|
64
|
+
sectionName = parsedAttrs.data.name;
|
|
65
|
+
usedSectionNames.add(sectionName);
|
|
66
|
+
}
|
|
67
|
+
const sectionSlides = [];
|
|
68
|
+
const sldIdLst = sectionCursor.child(P14_NS, "sldIdLst");
|
|
69
|
+
if (sldIdLst !== void 0) for (const sldIdCursor of sldIdLst.children(P14_NS, "sldId")) {
|
|
70
|
+
const rawSlideId = sldIdCursor.attrsObject(["id"]);
|
|
71
|
+
const parsedSlideId = sectionSlideIdXmlSchema.safeParse(rawSlideId);
|
|
72
|
+
if (!parsedSlideId.success) {
|
|
73
|
+
diagnostics.push({
|
|
74
|
+
code: "invalid-xml-value",
|
|
75
|
+
category: "corrupt-input",
|
|
76
|
+
disposition: "omitted",
|
|
77
|
+
location: {
|
|
78
|
+
part: presentationPath,
|
|
79
|
+
xpath: `${sldIdCursor.xpath}/@id`
|
|
80
|
+
},
|
|
81
|
+
attributeOrElement: "p14:sldId/@id",
|
|
82
|
+
rawValue: rawSlideId["id"] ?? ""
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const targetSlide = slideNodeBySldId.get(parsedSlideId.data.id);
|
|
87
|
+
if (targetSlide === void 0) {
|
|
88
|
+
diagnostics.push({
|
|
89
|
+
code: "broken-relationship",
|
|
90
|
+
category: "corrupt-input",
|
|
91
|
+
disposition: "omitted",
|
|
92
|
+
location: {
|
|
93
|
+
part: presentationPath,
|
|
94
|
+
xpath: sldIdCursor.xpath
|
|
95
|
+
},
|
|
96
|
+
relationshipId: String(parsedSlideId.data.id)
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (assignedSlides.has(targetSlide)) {
|
|
101
|
+
diagnostics.push({
|
|
102
|
+
code: "invalid-xml-value",
|
|
103
|
+
category: "corrupt-input",
|
|
104
|
+
disposition: "omitted",
|
|
105
|
+
location: {
|
|
106
|
+
part: presentationPath,
|
|
107
|
+
xpath: sldIdCursor.xpath
|
|
108
|
+
},
|
|
109
|
+
attributeOrElement: "p14:sldId/@id",
|
|
110
|
+
rawValue: String(parsedSlideId.data.id)
|
|
111
|
+
});
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
assignedSlides.add(targetSlide);
|
|
115
|
+
sectionSlides.push(targetSlide);
|
|
116
|
+
}
|
|
117
|
+
parsedSections.push({
|
|
118
|
+
name: sectionName,
|
|
119
|
+
slides: sectionSlides
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (parsedSections.length === 0) return;
|
|
124
|
+
const directSlides = deckNode.children.filter((child) => child instanceof CommonNode && child.type === "slide");
|
|
125
|
+
const unassignedSlides = directSlides.filter((slide) => !assignedSlides.has(slide));
|
|
126
|
+
for (const slide of directSlides) slide.remove();
|
|
127
|
+
if (unassignedSlides.length > 0) {
|
|
128
|
+
const fallbackName = allocateScopedAuthorId(void 0, usedSectionNames, "Default Section");
|
|
129
|
+
const defaultSection = createSectionNode({ name: fallbackName });
|
|
130
|
+
for (const slide of unassignedSlides) defaultSection.append(slide);
|
|
131
|
+
deckNode.append(defaultSection);
|
|
132
|
+
}
|
|
133
|
+
for (const entry of parsedSections) {
|
|
134
|
+
const sectionNode = createSectionNode({ name: entry.name });
|
|
135
|
+
for (const slide of entry.slides) sectionNode.append(slide);
|
|
136
|
+
deckNode.append(sectionNode);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export { importPresentationSections };
|