@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,205 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import { isMorphKey } from "../../../core/dist/morph.js";
|
|
3
|
+
import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
|
|
4
|
+
import "../../../core/dist/capability.js";
|
|
5
|
+
import { xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
6
|
+
import "../../../emit/dist/index.js";
|
|
7
|
+
import { P_NS, REL_HYPERLINK, R_NS } from "../../../import/dist/namespaces.js";
|
|
8
|
+
import { resolvePartPath } from "../../../import/dist/opc.js";
|
|
9
|
+
import { ooxmlBoolSchema } from "../../../import/dist/xml-fragments.js";
|
|
10
|
+
import { resolveExternalRelationshipTarget } from "../../../import/dist/resources.js";
|
|
11
|
+
import "../../../import/dist/index.js";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
// ../capabilities/dist/shared/identity.js
|
|
14
|
+
const NvPrUserDrawnSchema = z.object({ userDrawn: ooxmlBoolSchema.optional() });
|
|
15
|
+
function directChildDom(parent, namespaceUri, localName) {
|
|
16
|
+
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
17
|
+
if (child.nodeType !== 1) continue;
|
|
18
|
+
const el = child;
|
|
19
|
+
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Side-effect-free check for `<p:ph>` inside an object's `<p:nvPr>`. */
|
|
23
|
+
function hasPlaceholderElement(cursor) {
|
|
24
|
+
for (const wrapperName of [
|
|
25
|
+
"nvSpPr",
|
|
26
|
+
"nvPicPr",
|
|
27
|
+
"nvGrpSpPr",
|
|
28
|
+
"nvGraphicFramePr",
|
|
29
|
+
"nvCxnSpPr"
|
|
30
|
+
]) {
|
|
31
|
+
const wrapper = directChildDom(cursor.element, P_NS, wrapperName);
|
|
32
|
+
if (wrapper === void 0) continue;
|
|
33
|
+
const nvPr = directChildDom(wrapper, P_NS, "nvPr");
|
|
34
|
+
if (nvPr === void 0) continue;
|
|
35
|
+
if (directChildDom(nvPr, "http://schemas.openxmlformats.org/presentationml/2006/main", "ph") !== void 0) return true;
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
/** Consumes `<p:nvPr>` (and optional `userDrawn` flag) for non-placeholder objects. */
|
|
40
|
+
function consumeNonPlaceholderNvPr(nvParentCursor) {
|
|
41
|
+
const nvPr = nvParentCursor.child(P_NS, "nvPr");
|
|
42
|
+
if (nvPr === void 0) return;
|
|
43
|
+
const raw = nvPr.attrsObject(["userDrawn"]);
|
|
44
|
+
NvPrUserDrawnSchema.safeParse(raw);
|
|
45
|
+
}
|
|
46
|
+
const optionalNameSchema = z.string().refine((value) => value.trim() !== "", { message: "name must be a non-empty string" });
|
|
47
|
+
const HlinkClickFragmentSchema = z.object({
|
|
48
|
+
id: z.string().optional(),
|
|
49
|
+
action: z.string().optional()
|
|
50
|
+
});
|
|
51
|
+
/** Validates an optional non-empty object name parameter. */
|
|
52
|
+
function parseOptionalName(value, path) {
|
|
53
|
+
if (value === void 0) return void 0;
|
|
54
|
+
const parsed = optionalNameSchema.safeParse(value);
|
|
55
|
+
if (!parsed.success) throw new CapabilityError("invalid-parameter", "name must be a non-empty string", path);
|
|
56
|
+
return parsed.data;
|
|
57
|
+
}
|
|
58
|
+
/** Validates an optional Morph handle created by createMorphScope().handle(name). */
|
|
59
|
+
function parseMorphKey(value, path) {
|
|
60
|
+
if (value === void 0) return void 0;
|
|
61
|
+
if (!isMorphKey(value)) throw new CapabilityError("invalid-morph-key", "morphKey must be created by createMorphScope().handle(name)", path);
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
/** Native object capabilities share the same click link representation, with relationships and actions pre-resolved by core. */
|
|
65
|
+
function nativeLinkXml(link) {
|
|
66
|
+
if (link === void 0) return "";
|
|
67
|
+
return `<a:hlinkClick ${[...link.relationshipId === void 0 ? [] : [`r:id="${xmlEscape(link.relationshipId)}"`], ...link.action === void 0 ? [] : [`action="${xmlEscape(link.action)}"`]].join(" ")}/>`;
|
|
68
|
+
}
|
|
69
|
+
const homeAction = "ppaction://hlinkshowjump?jump=firstslide";
|
|
70
|
+
const slideJumpAction = "ppaction://hlinksldjump";
|
|
71
|
+
/**
|
|
72
|
+
* Reads an `<a:hlinkClick>` child under `<p:cNvPr>` into a `LinkTarget` or deferred internal slide jump,
|
|
73
|
+
* keeping external URLs offline and diagnosing broken relationships without dropping the host object.
|
|
74
|
+
*/
|
|
75
|
+
function readClickLink(hlinkCursor, context, objectIdentity) {
|
|
76
|
+
const clickLocation = {
|
|
77
|
+
part: context.part,
|
|
78
|
+
xpath: hlinkCursor.xpath,
|
|
79
|
+
slideIndex: context.slideIndex,
|
|
80
|
+
...objectIdentity?.objectId === void 0 ? {} : { objectId: objectIdentity.objectId },
|
|
81
|
+
...objectIdentity?.objectName === void 0 ? {} : { objectName: objectIdentity.objectName }
|
|
82
|
+
};
|
|
83
|
+
const rawId = hlinkCursor.attr("id", R_NS);
|
|
84
|
+
const rawAction = hlinkCursor.attr("action");
|
|
85
|
+
const parsed = HlinkClickFragmentSchema.safeParse({
|
|
86
|
+
...rawId === void 0 ? {} : { id: rawId },
|
|
87
|
+
...rawAction === void 0 ? {} : { action: rawAction }
|
|
88
|
+
});
|
|
89
|
+
if (!parsed.success) return {
|
|
90
|
+
clickLocation,
|
|
91
|
+
diagnostics: [{
|
|
92
|
+
code: "invalid-xml-value",
|
|
93
|
+
category: "corrupt-input",
|
|
94
|
+
disposition: "omitted",
|
|
95
|
+
location: clickLocation,
|
|
96
|
+
attributeOrElement: "a:hlinkClick"
|
|
97
|
+
}]
|
|
98
|
+
};
|
|
99
|
+
const rId = parsed.data.id ?? "";
|
|
100
|
+
const action = parsed.data.action ?? "";
|
|
101
|
+
if (rId === "" && action === homeAction) return {
|
|
102
|
+
link: { action: "home" },
|
|
103
|
+
clickLocation,
|
|
104
|
+
diagnostics: []
|
|
105
|
+
};
|
|
106
|
+
if (rId === "") return {
|
|
107
|
+
clickLocation,
|
|
108
|
+
diagnostics: [{
|
|
109
|
+
code: "broken-relationship",
|
|
110
|
+
category: "corrupt-input",
|
|
111
|
+
disposition: "omitted",
|
|
112
|
+
location: clickLocation,
|
|
113
|
+
relationshipId: ""
|
|
114
|
+
}]
|
|
115
|
+
};
|
|
116
|
+
const relationships = context.relationships ?? /* @__PURE__ */ new Map();
|
|
117
|
+
if (action === slideJumpAction) {
|
|
118
|
+
const rel = relationships.get(rId);
|
|
119
|
+
if (rel === void 0 || rel.Type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" || rel.TargetMode === "External") return {
|
|
120
|
+
relationshipId: rId,
|
|
121
|
+
clickLocation,
|
|
122
|
+
diagnostics: [{
|
|
123
|
+
code: "broken-relationship",
|
|
124
|
+
category: "corrupt-input",
|
|
125
|
+
disposition: "omitted",
|
|
126
|
+
location: clickLocation,
|
|
127
|
+
relationshipId: rId
|
|
128
|
+
}]
|
|
129
|
+
};
|
|
130
|
+
const targetPart = resolvePartPath(context.part, rel.Target);
|
|
131
|
+
if (targetPart === void 0 || !context.package.hasPart(targetPart)) return {
|
|
132
|
+
relationshipId: rId,
|
|
133
|
+
clickLocation,
|
|
134
|
+
diagnostics: [{
|
|
135
|
+
code: "missing-target-part",
|
|
136
|
+
category: "corrupt-input",
|
|
137
|
+
disposition: "omitted",
|
|
138
|
+
location: clickLocation,
|
|
139
|
+
relationshipId: rId,
|
|
140
|
+
targetPart: targetPart ?? rel.Target
|
|
141
|
+
}]
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
deferredSlideLink: {
|
|
145
|
+
targetPart,
|
|
146
|
+
relationshipId: rId,
|
|
147
|
+
location: clickLocation
|
|
148
|
+
},
|
|
149
|
+
relationshipId: rId,
|
|
150
|
+
clickLocation,
|
|
151
|
+
diagnostics: []
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (action !== "") return {
|
|
155
|
+
relationshipId: rId,
|
|
156
|
+
clickLocation,
|
|
157
|
+
diagnostics: [{
|
|
158
|
+
code: "unsupported-mechanism",
|
|
159
|
+
category: "unsupported",
|
|
160
|
+
disposition: "omitted",
|
|
161
|
+
location: clickLocation,
|
|
162
|
+
namespaceUri: hlinkCursor.namespaceUri,
|
|
163
|
+
localName: hlinkCursor.localName,
|
|
164
|
+
mechanismHint: action
|
|
165
|
+
}]
|
|
166
|
+
};
|
|
167
|
+
const resolvedExternal = resolveExternalRelationshipTarget(relationships, rId, clickLocation, REL_HYPERLINK);
|
|
168
|
+
if (!resolvedExternal.ok) return {
|
|
169
|
+
relationshipId: rId,
|
|
170
|
+
clickLocation,
|
|
171
|
+
diagnostics: [resolvedExternal.diagnostic]
|
|
172
|
+
};
|
|
173
|
+
try {
|
|
174
|
+
new URL(resolvedExternal.target);
|
|
175
|
+
} catch {
|
|
176
|
+
return {
|
|
177
|
+
relationshipId: rId,
|
|
178
|
+
clickLocation,
|
|
179
|
+
diagnostics: [{
|
|
180
|
+
code: "invalid-xml-value",
|
|
181
|
+
category: "corrupt-input",
|
|
182
|
+
disposition: "omitted",
|
|
183
|
+
location: clickLocation,
|
|
184
|
+
attributeOrElement: "Relationship/@Target",
|
|
185
|
+
rawValue: resolvedExternal.target
|
|
186
|
+
}]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
link: { url: resolvedExternal.target },
|
|
191
|
+
relationshipId: rId,
|
|
192
|
+
clickLocation,
|
|
193
|
+
diagnostics: []
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/** Registers a deferred internal slide-jump callback so links resolve via slidePartPath -> allocated Slide.id. */
|
|
197
|
+
function attachDeferredSlideLink(node, deferredSlideLink, context) {
|
|
198
|
+
if (deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) context.registerDeferredSlideLink({
|
|
199
|
+
...deferredSlideLink,
|
|
200
|
+
apply(targetSlideId) {
|
|
201
|
+
node.set({ link: { id: targetSlideId } });
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
export { attachDeferredSlideLink, consumeNonPlaceholderNvPr, hasPlaceholderElement, nativeLinkXml, optionalNameSchema, parseLinkTarget, parseMorphKey, parseOptionalName, readClickLink };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isMorphKey } from "../../../core/dist/morph.js";
|
|
2
|
+
import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
|
|
3
|
+
import "../../../core/dist/capability.js";
|
|
4
|
+
import "../../../core/dist/index.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
// ../capabilities/dist/shared/morph-api.js
|
|
7
|
+
/** Runtime-identity-preserving Zod schema for handles created by `createMorphScope().handle(name)`. */
|
|
8
|
+
const morphKeySchema = z.custom(isMorphKey, "morphKey must be created by createMorphScope().handle(name)");
|
|
9
|
+
z.strictObject({ morphKey: morphKeySchema.optional() }).readonly();
|
|
10
|
+
z.strictObject({ link: linkTargetSchema.optional() }).readonly();
|
|
11
|
+
export { morphKeySchema };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { nativePlaceholderRefSchema, placeholderRoleSchema } from "../../../core/dist/placeholders.js";
|
|
2
|
+
import "../../../core/dist/capability.js";
|
|
3
|
+
import { P_NS } from "../../../import/dist/namespaces.js";
|
|
4
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../../import/dist/xml-fragments.js";
|
|
5
|
+
import "../../../import/dist/index.js";
|
|
6
|
+
// ../capabilities/dist/shared/placeholder-import.js
|
|
7
|
+
const P14_MOD_ID_EXT_URI = "{D42A27DB-BD31-4B8C-83A1-F6EECF244321}";
|
|
8
|
+
/** Finds a direct child XML element matching namespace URI and local name without mutating cursor tracking. */
|
|
9
|
+
function directElementChild(parent, namespaceUri, localName) {
|
|
10
|
+
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
11
|
+
if (child.nodeType !== 1) continue;
|
|
12
|
+
const el = child;
|
|
13
|
+
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Side-effect-free lookup of `<p:ph>` inside `<p:{nvContainer}>/<p:nvPr>`. */
|
|
17
|
+
function directPlaceholderElement(cursor, nvContainerLocalName) {
|
|
18
|
+
const nvContainer = directElementChild(cursor.element, P_NS, nvContainerLocalName);
|
|
19
|
+
if (nvContainer === void 0) return void 0;
|
|
20
|
+
const nvPr = directElementChild(nvContainer, P_NS, "nvPr");
|
|
21
|
+
if (nvPr === void 0) return void 0;
|
|
22
|
+
return directElementChild(nvPr, P_NS, "ph");
|
|
23
|
+
}
|
|
24
|
+
/** Side-effect-free predicate identifying `<p:sp>` elements bound to a placeholder (`<p:ph>`). */
|
|
25
|
+
function isPlaceholderSpElement(cursor) {
|
|
26
|
+
return directPlaceholderElement(cursor, "nvSpPr") !== void 0;
|
|
27
|
+
}
|
|
28
|
+
/** Side-effect-free predicate identifying `<p:pic>` elements bound to a placeholder (`<p:ph>`). */
|
|
29
|
+
function isPlaceholderPicElement(cursor) {
|
|
30
|
+
return directPlaceholderElement(cursor, "nvPicPr") !== void 0;
|
|
31
|
+
}
|
|
32
|
+
/** Side-effect-free predicate identifying `<p:graphicFrame>` elements bound to a placeholder (`<p:ph>`). */
|
|
33
|
+
function isPlaceholderGraphicFrameElement(cursor) {
|
|
34
|
+
return directPlaceholderElement(cursor, "nvGraphicFramePr") !== void 0;
|
|
35
|
+
}
|
|
36
|
+
function consumeSubtree(cursor) {
|
|
37
|
+
const attrs = cursor.element.attributes;
|
|
38
|
+
for (let i = 0; i < attrs.length; i += 1) {
|
|
39
|
+
const attr = attrs.item(i);
|
|
40
|
+
if (attr === null) continue;
|
|
41
|
+
const ns = attr.namespaceURI ?? "";
|
|
42
|
+
const local = attr.localName ?? attr.name;
|
|
43
|
+
if (ns === "http://www.w3.org/2000/xmlns/" || attr.name === "xmlns" || attr.prefix === "xmlns") continue;
|
|
44
|
+
cursor.consumeAttr(local, ns);
|
|
45
|
+
}
|
|
46
|
+
for (const child of cursor.remainingElementChildren()) consumeSubtree(child);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Reads optional `<p:ph>` and benign `p14:modId` extensions inside `<p:nvPr>`.
|
|
50
|
+
* Shared across text, image, table, chart, and unpopulated placeholder importers.
|
|
51
|
+
*/
|
|
52
|
+
function readNvPrPlaceholder(nvPr, location, diagnostics) {
|
|
53
|
+
if (nvPr === void 0) return { kind: "none" };
|
|
54
|
+
const extLst = nvPr.child(P_NS, "extLst");
|
|
55
|
+
if (extLst !== void 0) {
|
|
56
|
+
for (const ext of extLst.children(P_NS, "ext")) if (ext.attr("uri") === P14_MOD_ID_EXT_URI) consumeSubtree(ext);
|
|
57
|
+
}
|
|
58
|
+
const ph = nvPr.child(P_NS, "ph");
|
|
59
|
+
if (ph === void 0) return { kind: "none" };
|
|
60
|
+
const rawPh = ph.attrsObject([
|
|
61
|
+
"type",
|
|
62
|
+
"idx",
|
|
63
|
+
"sz",
|
|
64
|
+
"orient",
|
|
65
|
+
"hasCustomPrompt"
|
|
66
|
+
]);
|
|
67
|
+
const explicitType = rawPh["type"] !== void 0;
|
|
68
|
+
const parsedRole = placeholderRoleSchema.safeParse(rawPh["type"] ?? "obj");
|
|
69
|
+
if (!parsedRole.success) {
|
|
70
|
+
diagnostics.push({
|
|
71
|
+
code: "unsupported-mechanism",
|
|
72
|
+
category: "unsupported",
|
|
73
|
+
disposition: "omitted",
|
|
74
|
+
location: {
|
|
75
|
+
...location,
|
|
76
|
+
xpath: ph.xpath
|
|
77
|
+
},
|
|
78
|
+
namespaceUri: P_NS,
|
|
79
|
+
localName: "ph",
|
|
80
|
+
mechanismHint: `ph:${rawPh["type"] ?? ""}`
|
|
81
|
+
});
|
|
82
|
+
return { kind: "error" };
|
|
83
|
+
}
|
|
84
|
+
const idxParsed = ooxmlNonNegativeIntSchema.safeParse(rawPh["idx"]);
|
|
85
|
+
const hasPromptParsed = ooxmlBoolSchema.safeParse(rawPh["hasCustomPrompt"]);
|
|
86
|
+
const parsedNativeRef = nativePlaceholderRefSchema.safeParse({
|
|
87
|
+
type: parsedRole.data,
|
|
88
|
+
explicitType,
|
|
89
|
+
...idxParsed.success ? { idx: idxParsed.data } : {},
|
|
90
|
+
...rawPh["sz"] !== void 0 ? { sz: rawPh["sz"] } : {},
|
|
91
|
+
...rawPh["orient"] !== void 0 ? { orient: rawPh["orient"] } : {},
|
|
92
|
+
...hasPromptParsed.success && hasPromptParsed.data ? { hasCustomPrompt: true } : {}
|
|
93
|
+
});
|
|
94
|
+
if (!parsedNativeRef.success) {
|
|
95
|
+
diagnostics.push({
|
|
96
|
+
code: "invalid-xml-value",
|
|
97
|
+
category: "corrupt-input",
|
|
98
|
+
disposition: "omitted",
|
|
99
|
+
location: {
|
|
100
|
+
...location,
|
|
101
|
+
xpath: ph.xpath
|
|
102
|
+
},
|
|
103
|
+
attributeOrElement: "p:ph",
|
|
104
|
+
rawValue: JSON.stringify(rawPh)
|
|
105
|
+
});
|
|
106
|
+
return { kind: "error" };
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
kind: "ok",
|
|
110
|
+
nativeRef: parsedNativeRef.data
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export { directElementChild, directPlaceholderElement, isPlaceholderGraphicFrameElement, isPlaceholderPicElement, isPlaceholderSpElement, readNvPrPlaceholder };
|