@officedk/pptxdk 0.0.0-stage → 0.2.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/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -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 +2403 -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 +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -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 +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -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 +60 -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 +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -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 +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -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 +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -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 +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -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-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -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 +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -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 +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createPlaceholderNode } from "./placeholder-schemas.js";
|
|
2
|
+
import { hostNodeCreator } from "../../../core/dist/host.js";
|
|
3
|
+
import "./placeholder.js";
|
|
4
|
+
import { createElement } from "react";
|
|
5
|
+
// ../capabilities/dist/placeholder/placeholder-elements.js
|
|
6
|
+
/** Declares an unpopulated native content placeholder bound to a layout placeholder slot. */
|
|
7
|
+
function Placeholder(props) {
|
|
8
|
+
return createElement("placeholder", {
|
|
9
|
+
...props,
|
|
10
|
+
[hostNodeCreator]: createPlaceholderNode
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export { Placeholder };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../../core/dist/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../../core/dist/layout-schemas.js";
|
|
3
|
+
import { visualStyleShape } from "../../../core/dist/theme.js";
|
|
4
|
+
import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
|
|
5
|
+
import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
|
|
6
|
+
import "../../../core/dist/capability.js";
|
|
7
|
+
import { CommonNode } from "../../../core/dist/document.js";
|
|
8
|
+
import { optionalNameSchema } from "../shared/identity.js";
|
|
9
|
+
import { morphKeySchema } from "../shared/morph-api.js";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
// ../capabilities/dist/placeholder/placeholder-schemas.js
|
|
12
|
+
const placeholderObjectStyleObjectSchema = z.strictObject({
|
|
13
|
+
...layoutStyleShape,
|
|
14
|
+
...visualStyleShape
|
|
15
|
+
});
|
|
16
|
+
const placeholderStyleKeys = Object.keys(placeholderObjectStyleObjectSchema.shape);
|
|
17
|
+
const placeholderObjectStyleSchema = placeholderObjectStyleObjectSchema.readonly();
|
|
18
|
+
const placeholderDeclarationPropsObjectSchema = z.strictObject({
|
|
19
|
+
id: authorIdSchema.optional(),
|
|
20
|
+
name: optionalNameSchema.optional(),
|
|
21
|
+
morphKey: morphKeySchema.optional(),
|
|
22
|
+
placeholder: z.string().min(1).optional(),
|
|
23
|
+
nativePlaceholder: nativePlaceholderRefSchema.optional(),
|
|
24
|
+
link: linkTargetSchema.optional(),
|
|
25
|
+
style: placeholderObjectStyleSchema.optional()
|
|
26
|
+
});
|
|
27
|
+
placeholderDeclarationPropsObjectSchema.readonly();
|
|
28
|
+
const placeholderAllowedPropKeys = new Set(Object.keys(placeholderDeclarationPropsObjectSchema.shape));
|
|
29
|
+
/** Creates an editable AST node representing an unpopulated native content placeholder (`<p:sp><p:ph .../></p:sp>` without `<p:txBody>`). */
|
|
30
|
+
function createPlaceholderNode(props) {
|
|
31
|
+
return new CommonNode("placeholder", "placeholder", props);
|
|
32
|
+
}
|
|
33
|
+
export { createPlaceholderNode, placeholderAllowedPropKeys, placeholderObjectStyleSchema, placeholderStyleKeys };
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
|
|
3
|
+
import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
|
|
4
|
+
import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
|
|
5
|
+
import "../../../core/dist/capability.js";
|
|
6
|
+
import { assertXml10Characters, placeholderRefXml, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
7
|
+
import "../../../emit/dist/index.js";
|
|
8
|
+
import { A_NS, EMU_PER_PX, P_NS, emuToPx } from "../../../import/dist/namespaces.js";
|
|
9
|
+
import { extentEmuFragmentSchema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
|
|
10
|
+
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
11
|
+
import "../../../import/dist/index.js";
|
|
12
|
+
import { createShapeNode, shapeStyleSchema } from "../shape/shape-declaration.js";
|
|
13
|
+
import { nativeLinkXml, parseMorphKey, parseOptionalName, readClickLink } from "../shared/identity.js";
|
|
14
|
+
import { directElementChild, emitPlaceholderUnbindDiagnostic, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, stripPlaceholderClearSentinels } from "../shared/placeholder-import.js";
|
|
15
|
+
import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
|
|
16
|
+
import { assertVisualBoxExtent, emitPlaceholderVisualSpPr, readSpPrAppearance, resolveVisualModel } from "../shared/visual.js";
|
|
17
|
+
import { placeholderCodegen } from "./placeholder-codegen.js";
|
|
18
|
+
import { createPlaceholderNode, placeholderAllowedPropKeys, placeholderObjectStyleSchema, placeholderStyleKeys } from "./placeholder-schemas.js";
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
// ../capabilities/dist/placeholder/placeholder.js
|
|
21
|
+
const NonVisualSpIdSchema = z.object({
|
|
22
|
+
id: ooxmlNonNegativeIntSchema,
|
|
23
|
+
name: z.string().optional()
|
|
24
|
+
});
|
|
25
|
+
const NonVisualSpPrFlagsSchema = z.object({ txBox: ooxmlBoolSchema.optional() });
|
|
26
|
+
const placeholderAllowedStyleKeys = new Set(placeholderStyleKeys);
|
|
27
|
+
function emitPlaceholderModel(model, emitContext) {
|
|
28
|
+
const escapedName = xmlEscape(model.name);
|
|
29
|
+
const spPrXml = emitPlaceholderVisualSpPr(model.visual, model.spPrFlags, (resource) => emitContext.registerResource(resource));
|
|
30
|
+
return { xml: `<p:sp><p:nvSpPr><p:cNvPr id="${emitContext.id}" name="${escapedName}">${nativeLinkXml(emitContext.nativeLink)}</p:cNvPr><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${placeholderRefXml(model.nativeRef)}</p:nvPr></p:nvSpPr>${spPrXml}</p:sp>` };
|
|
31
|
+
}
|
|
32
|
+
function paintPlaceholderModel() {
|
|
33
|
+
return { svg: "" };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reads an unpopulated `<p:sp>` content/object placeholder (no `<p:txBody>`)
|
|
37
|
+
* into a layout-bound `PlaceholderNode` while preserving `<p:ph>` binding.
|
|
38
|
+
*/
|
|
39
|
+
function readContentPlaceholderSp(context) {
|
|
40
|
+
const { cursor, part, slideIndex } = context;
|
|
41
|
+
const diagnostics = [];
|
|
42
|
+
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
43
|
+
if (nvSpPr === void 0) {
|
|
44
|
+
diagnostics.push({
|
|
45
|
+
code: "corrupt-part",
|
|
46
|
+
category: "corrupt-input",
|
|
47
|
+
disposition: "omitted",
|
|
48
|
+
location: {
|
|
49
|
+
part,
|
|
50
|
+
xpath: cursor.xpath,
|
|
51
|
+
slideIndex
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return { diagnostics };
|
|
55
|
+
}
|
|
56
|
+
let objectId;
|
|
57
|
+
let objectName;
|
|
58
|
+
let clickResult;
|
|
59
|
+
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
60
|
+
if (cNvPr !== void 0) {
|
|
61
|
+
const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
|
|
62
|
+
const parsedCNvPr = NonVisualSpIdSchema.safeParse(rawCNvPr);
|
|
63
|
+
if (!parsedCNvPr.success) diagnostics.push({
|
|
64
|
+
code: "invalid-xml-value",
|
|
65
|
+
category: "corrupt-input",
|
|
66
|
+
disposition: "recovered",
|
|
67
|
+
location: {
|
|
68
|
+
part,
|
|
69
|
+
xpath: cNvPr.xpath,
|
|
70
|
+
slideIndex
|
|
71
|
+
},
|
|
72
|
+
attributeOrElement: "p:cNvPr",
|
|
73
|
+
rawValue: JSON.stringify(rawCNvPr)
|
|
74
|
+
});
|
|
75
|
+
else {
|
|
76
|
+
objectId = parsedCNvPr.data.id;
|
|
77
|
+
if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
|
|
78
|
+
}
|
|
79
|
+
const hlinkClick = cNvPr.child(A_NS, "hlinkClick");
|
|
80
|
+
if (hlinkClick !== void 0) {
|
|
81
|
+
clickResult = readClickLink(hlinkClick, context, {
|
|
82
|
+
...objectId === void 0 ? {} : { objectId },
|
|
83
|
+
...objectName === void 0 ? {} : { objectName }
|
|
84
|
+
});
|
|
85
|
+
diagnostics.push(...clickResult.diagnostics);
|
|
86
|
+
}
|
|
87
|
+
cNvPr.ignoreEmptyChild(A_NS, "extLst");
|
|
88
|
+
}
|
|
89
|
+
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
90
|
+
if (cNvSpPr !== void 0) {
|
|
91
|
+
NonVisualSpPrFlagsSchema.safeParse(cNvSpPr.attrsObject(["txBox"]));
|
|
92
|
+
cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
|
|
93
|
+
"noGrp",
|
|
94
|
+
"noRot",
|
|
95
|
+
"noChangeAspect",
|
|
96
|
+
"noMove",
|
|
97
|
+
"noResize",
|
|
98
|
+
"noSelect"
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
const phLocation = {
|
|
102
|
+
part,
|
|
103
|
+
xpath: cursor.xpath,
|
|
104
|
+
slideIndex,
|
|
105
|
+
...objectId === void 0 ? {} : { objectId },
|
|
106
|
+
...objectName === void 0 ? {} : { objectName }
|
|
107
|
+
};
|
|
108
|
+
const nvPr = nvSpPr.child(P_NS, "nvPr");
|
|
109
|
+
const phResult = readNvPrPlaceholder(nvPr, phLocation, diagnostics);
|
|
110
|
+
if (phResult.kind === "none") {
|
|
111
|
+
diagnostics.push({
|
|
112
|
+
code: "corrupt-part",
|
|
113
|
+
category: "corrupt-input",
|
|
114
|
+
disposition: "omitted",
|
|
115
|
+
location: phLocation
|
|
116
|
+
});
|
|
117
|
+
return { diagnostics };
|
|
118
|
+
}
|
|
119
|
+
if (phResult.kind === "error") return { diagnostics };
|
|
120
|
+
const nativeRef = phResult.nativeRef;
|
|
121
|
+
const spPr = cursor.child(P_NS, "spPr");
|
|
122
|
+
if (spPr === void 0) {
|
|
123
|
+
diagnostics.push({
|
|
124
|
+
code: "corrupt-part",
|
|
125
|
+
category: "corrupt-input",
|
|
126
|
+
disposition: "omitted",
|
|
127
|
+
location: phLocation
|
|
128
|
+
});
|
|
129
|
+
return { diagnostics };
|
|
130
|
+
}
|
|
131
|
+
let localBox;
|
|
132
|
+
let rotate;
|
|
133
|
+
let flipH;
|
|
134
|
+
let flipV;
|
|
135
|
+
let fallbackUnits = {
|
|
136
|
+
w: 0,
|
|
137
|
+
h: 0
|
|
138
|
+
};
|
|
139
|
+
const xfrm = spPr.child(A_NS, "xfrm");
|
|
140
|
+
if (xfrm !== void 0) {
|
|
141
|
+
const hasExplicitFlipH = xfrm.element.hasAttribute("flipH");
|
|
142
|
+
const hasExplicitFlipV = xfrm.element.hasAttribute("flipV");
|
|
143
|
+
const rawXfrm = xfrm.attrsObject([
|
|
144
|
+
"rot",
|
|
145
|
+
"flipH",
|
|
146
|
+
"flipV"
|
|
147
|
+
]);
|
|
148
|
+
const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
|
|
149
|
+
if (parsedXfrm.success) {
|
|
150
|
+
if (parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0) rotate = parsedXfrm.data.rot / 6e4;
|
|
151
|
+
if (hasExplicitFlipH && parsedXfrm.data.flipH !== void 0) flipH = parsedXfrm.data.flipH;
|
|
152
|
+
if (hasExplicitFlipV && parsedXfrm.data.flipV !== void 0) flipV = parsedXfrm.data.flipV;
|
|
153
|
+
}
|
|
154
|
+
const off = xfrm.child(A_NS, "off");
|
|
155
|
+
const ext = xfrm.child(A_NS, "ext");
|
|
156
|
+
if (off !== void 0 && ext !== void 0) {
|
|
157
|
+
const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
|
|
158
|
+
const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
|
|
159
|
+
if (parsedOff.success && parsedExt.success) {
|
|
160
|
+
fallbackUnits = {
|
|
161
|
+
w: parsedExt.data.cx,
|
|
162
|
+
h: parsedExt.data.cy
|
|
163
|
+
};
|
|
164
|
+
localBox = {
|
|
165
|
+
x: emuToPx(parsedOff.data.x),
|
|
166
|
+
y: emuToPx(parsedOff.data.y),
|
|
167
|
+
width: emuToPx(parsedExt.data.cx),
|
|
168
|
+
height: emuToPx(parsedExt.data.cy)
|
|
169
|
+
};
|
|
170
|
+
} else diagnostics.push({
|
|
171
|
+
code: "invalid-xml-value",
|
|
172
|
+
category: "corrupt-input",
|
|
173
|
+
disposition: "recovered",
|
|
174
|
+
location: {
|
|
175
|
+
...phLocation,
|
|
176
|
+
xpath: xfrm.xpath
|
|
177
|
+
},
|
|
178
|
+
attributeOrElement: "a:xfrm"
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const claim = resolvePlaceholderImportClaim({
|
|
183
|
+
context,
|
|
184
|
+
nativeRef
|
|
185
|
+
});
|
|
186
|
+
const layoutPlaceholder = claim.layoutPlaceholder;
|
|
187
|
+
const masterPlaceholder = claim.masterPlaceholder;
|
|
188
|
+
const inheritedWidth = (typeof layoutPlaceholder?.style?.width === "number" ? layoutPlaceholder.style.width : void 0) ?? (typeof masterPlaceholder?.style?.width === "number" ? masterPlaceholder.style.width : void 0);
|
|
189
|
+
const inheritedHeight = (typeof layoutPlaceholder?.style?.height === "number" ? layoutPlaceholder.style.height : void 0) ?? (typeof masterPlaceholder?.style?.height === "number" ? masterPlaceholder.style.height : void 0);
|
|
190
|
+
const inheritedBox = inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
|
|
191
|
+
width: inheritedWidth,
|
|
192
|
+
height: inheritedHeight
|
|
193
|
+
} : void 0;
|
|
194
|
+
const effectiveFallbackUnits = localBox === void 0 && inheritedBox !== void 0 ? {
|
|
195
|
+
w: Math.round(inheritedBox.width * EMU_PER_PX),
|
|
196
|
+
h: Math.round(inheritedBox.height * EMU_PER_PX)
|
|
197
|
+
} : fallbackUnits;
|
|
198
|
+
const appearance = readSpPrAppearance(spPr, context.package, effectiveFallbackUnits, phLocation, diagnostics, { preservePlaceholderClears: true });
|
|
199
|
+
const { border: rawBorder, ...restVisualStyle } = appearance.style;
|
|
200
|
+
const border = rawBorder;
|
|
201
|
+
const boxSize = localBox ?? inheritedBox;
|
|
202
|
+
let borderRadius;
|
|
203
|
+
if (appearance.geometry === "roundRect") {
|
|
204
|
+
if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
205
|
+
} else if (typeof appearance.geometry === "object" && appearance.geometry.type === "preset" && appearance.geometry.name === "roundRect" && boxSize !== void 0) {
|
|
206
|
+
const adj = appearance.geometry.adjust?.["adj"] ?? 16667;
|
|
207
|
+
if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
208
|
+
}
|
|
209
|
+
const combinedStyle = {
|
|
210
|
+
...localBox === void 0 ? {} : {
|
|
211
|
+
position: "absolute",
|
|
212
|
+
left: localBox.x,
|
|
213
|
+
top: localBox.y,
|
|
214
|
+
width: localBox.width,
|
|
215
|
+
height: localBox.height
|
|
216
|
+
},
|
|
217
|
+
...restVisualStyle,
|
|
218
|
+
...border === void 0 ? {} : { border },
|
|
219
|
+
...borderRadius === void 0 ? {} : { borderRadius },
|
|
220
|
+
...rotate === void 0 ? {} : { rotate },
|
|
221
|
+
...flipH === void 0 ? {} : { flipH },
|
|
222
|
+
...flipV === void 0 ? {} : { flipV }
|
|
223
|
+
};
|
|
224
|
+
if (!claim.bound) {
|
|
225
|
+
const resolvedBox = resolveUnboundPlaceholderBox({
|
|
226
|
+
inheritanceContext: claim.inheritanceContext,
|
|
227
|
+
...localBox === void 0 ? {} : { localBox },
|
|
228
|
+
requireHeight: true
|
|
229
|
+
});
|
|
230
|
+
if (resolvedBox === void 0 || resolvedBox.height === void 0) {
|
|
231
|
+
diagnostics.push({
|
|
232
|
+
code: "unsupported-mechanism",
|
|
233
|
+
category: "unsupported",
|
|
234
|
+
disposition: "omitted",
|
|
235
|
+
location: phLocation,
|
|
236
|
+
namespaceUri: P_NS,
|
|
237
|
+
localName: "ph",
|
|
238
|
+
mechanismHint: "orphan-placeholder-without-box"
|
|
239
|
+
});
|
|
240
|
+
return { diagnostics };
|
|
241
|
+
}
|
|
242
|
+
const freeVisual = materializeUnboundVisualStyle({
|
|
243
|
+
inheritanceContext: claim.inheritanceContext,
|
|
244
|
+
localVisualStyle: {
|
|
245
|
+
...restVisualStyle,
|
|
246
|
+
...border === void 0 ? {} : { border },
|
|
247
|
+
...borderRadius === void 0 ? {} : { borderRadius },
|
|
248
|
+
...rotate === void 0 ? {} : { rotate },
|
|
249
|
+
...flipH === void 0 ? {} : { flipH },
|
|
250
|
+
...flipV === void 0 ? {} : { flipV }
|
|
251
|
+
},
|
|
252
|
+
...appearance.geometry === void 0 ? {} : { localGeometry: appearance.geometry },
|
|
253
|
+
boxSize: {
|
|
254
|
+
width: resolvedBox.width,
|
|
255
|
+
height: resolvedBox.height
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
const rawFreeStyle = stripPlaceholderClearSentinels({
|
|
259
|
+
...freeVisual,
|
|
260
|
+
position: "absolute",
|
|
261
|
+
left: resolvedBox.x,
|
|
262
|
+
top: resolvedBox.y,
|
|
263
|
+
width: resolvedBox.width,
|
|
264
|
+
height: resolvedBox.height
|
|
265
|
+
});
|
|
266
|
+
const parsedFreeStyle = shapeStyleSchema.safeParse(rawFreeStyle);
|
|
267
|
+
const effectiveGeom = appearance.geometry ?? layoutPlaceholder?.geometry ?? masterPlaceholder?.geometry;
|
|
268
|
+
const freeShape = createShapeNode({
|
|
269
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
270
|
+
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
271
|
+
...effectiveGeom === void 0 ? {} : { geometry: effectiveGeom },
|
|
272
|
+
style: parsedFreeStyle.success ? parsedFreeStyle.data : {
|
|
273
|
+
position: "absolute",
|
|
274
|
+
left: resolvedBox.x,
|
|
275
|
+
top: resolvedBox.y,
|
|
276
|
+
width: resolvedBox.width,
|
|
277
|
+
height: resolvedBox.height
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
|
|
281
|
+
const deferred = clickResult.deferredSlideLink;
|
|
282
|
+
context.registerDeferredSlideLink({
|
|
283
|
+
...deferred,
|
|
284
|
+
apply(targetSlideId) {
|
|
285
|
+
freeShape.set({ link: { id: targetSlideId } });
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
emitPlaceholderUnbindDiagnostic({
|
|
290
|
+
diagnostics,
|
|
291
|
+
location: phLocation,
|
|
292
|
+
retainedAs: "shape"
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
node: freeShape,
|
|
296
|
+
diagnostics
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const matchedKey = claim.key;
|
|
300
|
+
let validatedStyle;
|
|
301
|
+
if (Object.keys(combinedStyle).length > 0) {
|
|
302
|
+
const parsedStyle = placeholderObjectStyleSchema.safeParse(combinedStyle);
|
|
303
|
+
if (parsedStyle.success) validatedStyle = parsedStyle.data;
|
|
304
|
+
}
|
|
305
|
+
const node = createPlaceholderNode({
|
|
306
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
307
|
+
placeholder: matchedKey,
|
|
308
|
+
nativePlaceholder: nativeRef,
|
|
309
|
+
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
310
|
+
...validatedStyle === void 0 ? {} : { style: validatedStyle }
|
|
311
|
+
});
|
|
312
|
+
if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
|
|
313
|
+
const deferred = clickResult.deferredSlideLink;
|
|
314
|
+
context.registerDeferredSlideLink({
|
|
315
|
+
...deferred,
|
|
316
|
+
apply(targetSlideId) {
|
|
317
|
+
node.set({ link: { id: targetSlideId } });
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return {
|
|
322
|
+
node,
|
|
323
|
+
diagnostics
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/** Shape-tree import handler wired into `contentPlaceholderMechanism` for unpopulated `<p:sp><p:ph .../></p:sp>` placeholders without `<p:txBody>`. */
|
|
327
|
+
const contentPlaceholderImportHandler = {
|
|
328
|
+
target: "shape-tree",
|
|
329
|
+
localName: "sp",
|
|
330
|
+
matches: (cursor) => isPlaceholderSpElement(cursor) && directElementChild(cursor.element, "http://schemas.openxmlformats.org/presentationml/2006/main", "txBody") === void 0,
|
|
331
|
+
read: readContentPlaceholderSp
|
|
332
|
+
};
|
|
333
|
+
/** Typed native canvas mechanism connecting emit, paint, and import for unpopulated `content-placeholder`. */
|
|
334
|
+
const contentPlaceholderMechanism = defineCanvasMechanism({
|
|
335
|
+
key: "content-placeholder",
|
|
336
|
+
role: "canvas",
|
|
337
|
+
emit: emitPlaceholderModel,
|
|
338
|
+
paint: paintPlaceholderModel,
|
|
339
|
+
import: contentPlaceholderImportHandler
|
|
340
|
+
});
|
|
341
|
+
/** Capability preserving unpopulated non-text content placeholder slots across import/emit without synthesizing empty text bodies. */
|
|
342
|
+
const placeholderCapability = {
|
|
343
|
+
declaration: "placeholder",
|
|
344
|
+
mechanisms: [contentPlaceholderMechanism],
|
|
345
|
+
codegen: placeholderCodegen,
|
|
346
|
+
bind(input, context) {
|
|
347
|
+
const unknown = Object.keys(input.props).find((key) => !placeholderAllowedPropKeys.has(key));
|
|
348
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Placeholder contains unsupported parameter ${unknown}`);
|
|
349
|
+
if (input.children.length > 0) throw new CapabilityError("unsupported-children", "Unpopulated content placeholder does not accept children");
|
|
350
|
+
const placeholder = context.placeholder;
|
|
351
|
+
const rawNative = nativePlaceholderRefSchema.safeParse(input.props["nativePlaceholder"]);
|
|
352
|
+
const nativeRef = placeholder?.nativeRef ?? (rawNative.success ? rawNative.data : void 0);
|
|
353
|
+
if (nativeRef === void 0) throw new CapabilityError("missing-placeholder-binding", "Content placeholder requires a bound layout placeholder or nativePlaceholder descriptor");
|
|
354
|
+
const requestedName = parseOptionalName(input.props["name"]);
|
|
355
|
+
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
356
|
+
const link = parseLinkTarget(input.props["link"]);
|
|
357
|
+
const contract = parseCapabilityLayoutContract({
|
|
358
|
+
nativeKind: "sp",
|
|
359
|
+
props: input.props,
|
|
360
|
+
allowedStyleKeys: placeholderAllowedStyleKeys,
|
|
361
|
+
allowPadding: false,
|
|
362
|
+
path: context.path
|
|
363
|
+
});
|
|
364
|
+
const rawSlideStyle = typeof input.props["style"] === "object" && input.props["style"] !== null && !Array.isArray(input.props["style"]) ? input.props["style"] : void 0;
|
|
365
|
+
const inheritedPlaceholderGeometry = placeholder?.layoutPlaceholder?.geometry ?? placeholder?.masterPlaceholder?.geometry;
|
|
366
|
+
const visualStyle = placeholder !== void 0 ? resolvePlaceholderVisualStyle(placeholder, rawSlideStyle) : rawSlideStyle !== void 0 ? { ...rawSlideStyle } : {};
|
|
367
|
+
resolveVisualModel({
|
|
368
|
+
theme: placeholder?.masterTheme ?? context.theme,
|
|
369
|
+
style: visualStyle,
|
|
370
|
+
box: {
|
|
371
|
+
x: 0,
|
|
372
|
+
y: 0,
|
|
373
|
+
width: 100,
|
|
374
|
+
height: 100
|
|
375
|
+
},
|
|
376
|
+
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
|
|
377
|
+
layoutOnlyWhenInvisible: true
|
|
378
|
+
});
|
|
379
|
+
const placeholderGeometry = placeholder === void 0 ? void 0 : resolvePlaceholderGeometry(placeholder, input.props);
|
|
380
|
+
const rawX = placeholderGeometry?.x;
|
|
381
|
+
const rawY = placeholderGeometry?.y;
|
|
382
|
+
const rawWidth = placeholderGeometry?.width;
|
|
383
|
+
const rawHeight = placeholderGeometry?.height;
|
|
384
|
+
const native = {
|
|
385
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
386
|
+
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
387
|
+
...link === void 0 ? {} : { link }
|
|
388
|
+
};
|
|
389
|
+
return {
|
|
390
|
+
contract,
|
|
391
|
+
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
392
|
+
resolve(resolveContext) {
|
|
393
|
+
const box = {
|
|
394
|
+
x: resolveContext.layoutBox?.x ?? (typeof rawX === "number" ? rawX : 0),
|
|
395
|
+
y: resolveContext.layoutBox?.y ?? (typeof rawY === "number" ? rawY : 0),
|
|
396
|
+
width: resolveContext.layoutBox?.width ?? (typeof rawWidth === "number" ? rawWidth : 100),
|
|
397
|
+
height: resolveContext.layoutBox?.height ?? (typeof rawHeight === "number" ? rawHeight : 100)
|
|
398
|
+
};
|
|
399
|
+
const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `Placeholder ${resolveContext.id - 1}`;
|
|
400
|
+
try {
|
|
401
|
+
assertXml10Characters(name);
|
|
402
|
+
} catch {
|
|
403
|
+
throw new CapabilityError("invalid-xml-character", "Placeholder.name contains characters not allowed in XML 1.0");
|
|
404
|
+
}
|
|
405
|
+
const hasBox = placeholder === void 0 || placeholderGeometry?.hasLocalBoxOverride === true;
|
|
406
|
+
if (hasBox) assertVisualBoxExtent(box);
|
|
407
|
+
const visual = resolveVisualModel({
|
|
408
|
+
theme: placeholder?.masterTheme ?? resolveContext.theme,
|
|
409
|
+
style: visualStyle,
|
|
410
|
+
box,
|
|
411
|
+
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
|
|
412
|
+
layoutOnlyWhenInvisible: !hasBox
|
|
413
|
+
});
|
|
414
|
+
const spPrFlags = {
|
|
415
|
+
hasBox,
|
|
416
|
+
hasRotate: hasLocalDeclaration(rawSlideStyle, "rotate"),
|
|
417
|
+
hasFlipH: hasLocalDeclaration(rawSlideStyle, "flipH"),
|
|
418
|
+
hasFlipV: hasLocalDeclaration(rawSlideStyle, "flipV"),
|
|
419
|
+
hasGeometryOrRadius: hasLocalDeclaration(rawSlideStyle, "borderRadius"),
|
|
420
|
+
hasFill: hasLocalDeclaration(rawSlideStyle, "background"),
|
|
421
|
+
hasBorder: hasLocalDeclaration(rawSlideStyle, "border"),
|
|
422
|
+
hasEffects: hasLocalDeclaration(rawSlideStyle, "boxShadow") || hasLocalDeclaration(rawSlideStyle, "softEdge"),
|
|
423
|
+
includeDefaultRectWhenHasBox: true
|
|
424
|
+
};
|
|
425
|
+
const model = {
|
|
426
|
+
box,
|
|
427
|
+
name,
|
|
428
|
+
nativeRef,
|
|
429
|
+
visual,
|
|
430
|
+
spPrFlags
|
|
431
|
+
};
|
|
432
|
+
return {
|
|
433
|
+
observation: {
|
|
434
|
+
id: resolveContext.id,
|
|
435
|
+
kind: "placeholder",
|
|
436
|
+
name,
|
|
437
|
+
box
|
|
438
|
+
},
|
|
439
|
+
extensions: [],
|
|
440
|
+
emit(emitContext) {
|
|
441
|
+
return contentPlaceholderMechanism.emit(model, emitContext);
|
|
442
|
+
},
|
|
443
|
+
paint() {
|
|
444
|
+
return contentPlaceholderMechanism.paint(model, void 0);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
export { contentPlaceholderImportHandler, contentPlaceholderMechanism, createPlaceholderNode, placeholderCapability, placeholderObjectStyleSchema, readContentPlaceholderSp };
|