@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,19 @@
|
|
|
1
|
+
import { defineObjectCodegen } from "../../../codegen/dist/types.js";
|
|
2
|
+
import "../../../codegen/dist/index.js";
|
|
3
|
+
import { blockRichTextChildKinds, createRichTextCodegenHandler } from "../text/text-codegen.js";
|
|
4
|
+
import { notesAllowedPropKeys } from "./notes-schemas.js";
|
|
5
|
+
// ../capabilities/dist/notes/notes-codegen.js
|
|
6
|
+
/**
|
|
7
|
+
* Source codegen contribution for page-affiliated `notes` (`notes()` / `<Notes>`) declarations.
|
|
8
|
+
*
|
|
9
|
+
* Registered via `declarations.notes` so `@pptxdk/codegen` resolves `Notes` child nodes inside
|
|
10
|
+
* `Slide` while preserving all rich-text children and speaker-note styles.
|
|
11
|
+
*/
|
|
12
|
+
const notesCodegen = defineObjectCodegen({ declarations: { notes: createRichTextCodegenHandler({
|
|
13
|
+
vanillaFactory: "notes",
|
|
14
|
+
reactComponent: "Notes",
|
|
15
|
+
allowedPropKeys: notesAllowedPropKeys,
|
|
16
|
+
allowedChildKinds: blockRichTextChildKinds,
|
|
17
|
+
supportObjectExtras: false
|
|
18
|
+
}) } });
|
|
19
|
+
export { notesCodegen };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RichTextContainer } from "../../../core/dist/document.js";
|
|
2
|
+
import "./notes-schemas.js";
|
|
3
|
+
// ../capabilities/dist/notes/notes-declaration.js
|
|
4
|
+
/** Creates the editable notes container shared by the command factory and Notes JSX. */
|
|
5
|
+
function createNotesNode(props) {
|
|
6
|
+
return new RichTextContainer("notes", "notes", props, { pageAffiliated: true });
|
|
7
|
+
}
|
|
8
|
+
export { createNotesNode };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hostNodeCreator } from "../../../core/dist/host.js";
|
|
2
|
+
import { createNotesNode } from "./notes-declaration.js";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
// ../capabilities/dist/notes/notes-elements.js
|
|
5
|
+
/** Declares one page's rich-text speaker notes; repeated declarations on a page are a build error. */
|
|
6
|
+
function Notes(props) {
|
|
7
|
+
return createElement("notes", {
|
|
8
|
+
...props,
|
|
9
|
+
[hostNodeCreator]: createNotesNode
|
|
10
|
+
}, props.children);
|
|
11
|
+
}
|
|
12
|
+
export { Notes };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { textStyleKeys } from "../../../core/dist/theme.js";
|
|
2
|
+
import "../../../core/dist/capability.js";
|
|
3
|
+
import { CommonContainer, CommonNode } from "../../../core/dist/document.js";
|
|
4
|
+
import { A_NS, P_NS, REL_NOTES_SLIDE } from "../../../import/dist/namespaces.js";
|
|
5
|
+
import { XmlElementCursor, parseXmlPart } from "../../../import/dist/xml-reader.js";
|
|
6
|
+
import { resolvePartPath } from "../../../import/dist/opc.js";
|
|
7
|
+
import { peekShapeTreeObjectIdentity } from "../../../import/dist/resources.js";
|
|
8
|
+
import { appendUnconsumedDiagnostics, consumeIdentityShapeTreeBoilerplate } from "../../../import/dist/masters.js";
|
|
9
|
+
import { importPresentationSections } from "../../../import/dist/sections.js";
|
|
10
|
+
import "../../../import/dist/index.js";
|
|
11
|
+
import { populateRichTextNode, readRichTextBody } from "../text/text-import.js";
|
|
12
|
+
import { createNotesNode } from "./notes-declaration.js";
|
|
13
|
+
import { notesPlaceholderXmlSchema, notesRootAttrsXmlSchema, notesShapeIdentityXmlSchema } from "./notes-schemas.js";
|
|
14
|
+
// ../capabilities/dist/notes/notes-import.js
|
|
15
|
+
const baselineNotesSlidePlaceholders = /* @__PURE__ */ new Set([
|
|
16
|
+
"sldImg",
|
|
17
|
+
"hdr",
|
|
18
|
+
"ftr",
|
|
19
|
+
"dt",
|
|
20
|
+
"sldNum"
|
|
21
|
+
]);
|
|
22
|
+
function consumeNotesCreationIdExtLst(cSld) {
|
|
23
|
+
const extLst = cSld.child(P_NS, "extLst");
|
|
24
|
+
if (extLst === void 0) return;
|
|
25
|
+
for (const ext of extLst.children(P_NS, "ext")) {
|
|
26
|
+
if (ext.element.getAttribute("uri") !== "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}") continue;
|
|
27
|
+
ext.consumeAttr("uri");
|
|
28
|
+
ext.suppressUnconsumed();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function readNotesPlaceholderInfo(spCursor, part, slideIndex, diagnostics) {
|
|
32
|
+
const nvSpPr = spCursor.child(P_NS, "nvSpPr");
|
|
33
|
+
if (nvSpPr === void 0) return {};
|
|
34
|
+
let objectId;
|
|
35
|
+
let objectName;
|
|
36
|
+
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
37
|
+
if (cNvPr !== void 0) {
|
|
38
|
+
const rawCNvPr = cNvPr.attrsObject(["id", "name"]);
|
|
39
|
+
const parsedCNvPr = notesShapeIdentityXmlSchema.safeParse(rawCNvPr);
|
|
40
|
+
if (parsedCNvPr.success) {
|
|
41
|
+
objectId = parsedCNvPr.data.id;
|
|
42
|
+
if (parsedCNvPr.data.name !== void 0 && parsedCNvPr.data.name.trim() !== "") objectName = parsedCNvPr.data.name;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
46
|
+
if (cNvSpPr !== void 0) cNvSpPr.suppressUnconsumed();
|
|
47
|
+
const nvPr = nvSpPr.child(P_NS, "nvPr");
|
|
48
|
+
if (nvPr === void 0) return {
|
|
49
|
+
...objectId === void 0 ? {} : { objectId },
|
|
50
|
+
...objectName === void 0 ? {} : { objectName }
|
|
51
|
+
};
|
|
52
|
+
const ph = nvPr.child(P_NS, "ph");
|
|
53
|
+
if (ph === void 0) return {
|
|
54
|
+
...objectId === void 0 ? {} : { objectId },
|
|
55
|
+
...objectName === void 0 ? {} : { objectName }
|
|
56
|
+
};
|
|
57
|
+
const rawPh = ph.attrsObject([
|
|
58
|
+
"type",
|
|
59
|
+
"idx",
|
|
60
|
+
"sz",
|
|
61
|
+
"orient",
|
|
62
|
+
"hasCustomPrompt"
|
|
63
|
+
]);
|
|
64
|
+
const parsedPh = notesPlaceholderXmlSchema.safeParse(rawPh);
|
|
65
|
+
if (!parsedPh.success) {
|
|
66
|
+
diagnostics.push({
|
|
67
|
+
code: "invalid-xml-value",
|
|
68
|
+
category: "corrupt-input",
|
|
69
|
+
disposition: "recovered",
|
|
70
|
+
location: {
|
|
71
|
+
part,
|
|
72
|
+
xpath: ph.xpath,
|
|
73
|
+
slideIndex
|
|
74
|
+
},
|
|
75
|
+
attributeOrElement: "p:ph",
|
|
76
|
+
rawValue: JSON.stringify(rawPh)
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
...rawPh["type"] === void 0 ? {} : { phType: rawPh["type"] },
|
|
80
|
+
...objectId === void 0 ? {} : { objectId },
|
|
81
|
+
...objectName === void 0 ? {} : { objectName }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
...parsedPh.data.type === void 0 ? {} : { phType: parsedPh.data.type },
|
|
86
|
+
...objectId === void 0 ? {} : { objectId },
|
|
87
|
+
...objectName === void 0 ? {} : { objectName }
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function consumeNotesBodyShapeProperties(spPr) {
|
|
91
|
+
spPr.suppressUnconsumed();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Slide-level import handler for `speaker-notes`, reading `ppt/notesSlides/notesSlide{n}.xml`
|
|
95
|
+
* body rich text into a page-affiliated `NotesNode` on the owning `SlideNode`.
|
|
96
|
+
*/
|
|
97
|
+
const speakerNotesImportHandler = {
|
|
98
|
+
target: "slide",
|
|
99
|
+
slot: "notes",
|
|
100
|
+
read(context) {
|
|
101
|
+
const { slideNode, part, slideIndex, package: pkg } = context;
|
|
102
|
+
if (slideIndex === void 0) return {};
|
|
103
|
+
const diagnostics = [];
|
|
104
|
+
const notesRel = pkg.readRelationships(part).entries.find((entry) => entry.Type === REL_NOTES_SLIDE);
|
|
105
|
+
if (notesRel === void 0) return {};
|
|
106
|
+
const notesPartPath = notesRel.TargetMode === "External" ? void 0 : resolvePartPath(part, notesRel.Target);
|
|
107
|
+
if (notesPartPath === void 0) {
|
|
108
|
+
diagnostics.push({
|
|
109
|
+
code: "broken-relationship",
|
|
110
|
+
category: "corrupt-input",
|
|
111
|
+
disposition: "omitted",
|
|
112
|
+
location: {
|
|
113
|
+
part,
|
|
114
|
+
xpath: notesRel.xpath,
|
|
115
|
+
slideIndex
|
|
116
|
+
},
|
|
117
|
+
relationshipId: notesRel.Id
|
|
118
|
+
});
|
|
119
|
+
return { diagnostics };
|
|
120
|
+
}
|
|
121
|
+
if (!pkg.hasPart(notesPartPath)) {
|
|
122
|
+
diagnostics.push({
|
|
123
|
+
code: "missing-target-part",
|
|
124
|
+
category: "corrupt-input",
|
|
125
|
+
disposition: "omitted",
|
|
126
|
+
location: {
|
|
127
|
+
part,
|
|
128
|
+
xpath: notesRel.xpath,
|
|
129
|
+
slideIndex
|
|
130
|
+
},
|
|
131
|
+
relationshipId: notesRel.Id,
|
|
132
|
+
targetPart: notesPartPath
|
|
133
|
+
});
|
|
134
|
+
return { diagnostics };
|
|
135
|
+
}
|
|
136
|
+
const xmlText = pkg.readTextPart(notesPartPath);
|
|
137
|
+
if (xmlText === void 0) return { diagnostics };
|
|
138
|
+
let notesEl;
|
|
139
|
+
try {
|
|
140
|
+
notesEl = parseXmlPart(notesPartPath, xmlText);
|
|
141
|
+
} catch {
|
|
142
|
+
diagnostics.push({
|
|
143
|
+
code: "corrupt-part",
|
|
144
|
+
category: "corrupt-input",
|
|
145
|
+
disposition: "omitted",
|
|
146
|
+
location: {
|
|
147
|
+
part: notesPartPath,
|
|
148
|
+
slideIndex
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return { diagnostics };
|
|
152
|
+
}
|
|
153
|
+
if ((notesEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main" || (notesEl.localName ?? notesEl.tagName) !== "notes") {
|
|
154
|
+
diagnostics.push({
|
|
155
|
+
code: "corrupt-part",
|
|
156
|
+
category: "corrupt-input",
|
|
157
|
+
disposition: "omitted",
|
|
158
|
+
location: {
|
|
159
|
+
part: notesPartPath,
|
|
160
|
+
slideIndex
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return { diagnostics };
|
|
164
|
+
}
|
|
165
|
+
const notesRels = pkg.readRelationships(notesPartPath);
|
|
166
|
+
diagnostics.push(...notesRels.diagnostics);
|
|
167
|
+
const notesCursor = XmlElementCursor.createRoot(notesEl, notesPartPath, "/p:notes");
|
|
168
|
+
const rawRootAttrs = notesCursor.attrsObject(["showMasterSp", "showMasterPhAnim"]);
|
|
169
|
+
if (!notesRootAttrsXmlSchema.safeParse(rawRootAttrs).success) diagnostics.push({
|
|
170
|
+
code: "invalid-xml-value",
|
|
171
|
+
category: "corrupt-input",
|
|
172
|
+
disposition: "recovered",
|
|
173
|
+
location: {
|
|
174
|
+
part: notesPartPath,
|
|
175
|
+
xpath: notesCursor.xpath,
|
|
176
|
+
slideIndex
|
|
177
|
+
},
|
|
178
|
+
attributeOrElement: "p:notes",
|
|
179
|
+
rawValue: JSON.stringify(rawRootAttrs)
|
|
180
|
+
});
|
|
181
|
+
const clrMapOvr = notesCursor.child(P_NS, "clrMapOvr");
|
|
182
|
+
if (clrMapOvr !== void 0) clrMapOvr.ignoreEmptyChild(A_NS, "masterClrMapping");
|
|
183
|
+
const cSld = notesCursor.child(P_NS, "cSld");
|
|
184
|
+
if (cSld === void 0) {
|
|
185
|
+
diagnostics.push({
|
|
186
|
+
code: "corrupt-part",
|
|
187
|
+
category: "corrupt-input",
|
|
188
|
+
disposition: "omitted",
|
|
189
|
+
location: {
|
|
190
|
+
part: notesPartPath,
|
|
191
|
+
xpath: notesCursor.xpath,
|
|
192
|
+
slideIndex
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return { diagnostics };
|
|
196
|
+
}
|
|
197
|
+
cSld.consumeAttr("name");
|
|
198
|
+
consumeNotesCreationIdExtLst(cSld);
|
|
199
|
+
const spTree = cSld.child(P_NS, "spTree");
|
|
200
|
+
if (spTree !== void 0) {
|
|
201
|
+
consumeIdentityShapeTreeBoilerplate(spTree);
|
|
202
|
+
let importedNotesBody = false;
|
|
203
|
+
for (const item of spTree.remainingElementChildren()) {
|
|
204
|
+
if (item.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && item.localName === "sp") {
|
|
205
|
+
const info = readNotesPlaceholderInfo(item, notesPartPath, slideIndex, diagnostics);
|
|
206
|
+
if (info.phType === "body" && !importedNotesBody) {
|
|
207
|
+
importedNotesBody = true;
|
|
208
|
+
const spPr = item.child(P_NS, "spPr");
|
|
209
|
+
if (spPr !== void 0) consumeNotesBodyShapeProperties(spPr);
|
|
210
|
+
const txBody = item.child(P_NS, "txBody");
|
|
211
|
+
if (txBody !== void 0) {
|
|
212
|
+
const { boxStyle, importedParagraphs } = readRichTextBody(txBody, notesPartPath, slideIndex, diagnostics);
|
|
213
|
+
const notesStyle = {};
|
|
214
|
+
const boxRecord = boxStyle;
|
|
215
|
+
for (const key of textStyleKeys) if (Object.hasOwn(boxRecord, key) && boxRecord[key] !== void 0) notesStyle[key] = boxRecord[key];
|
|
216
|
+
const hasNotesStyle = Object.keys(notesStyle).length > 0;
|
|
217
|
+
if (!(!hasNotesStyle && (importedParagraphs.length === 0 || importedParagraphs.length === 1 && importedParagraphs[0].runs.length === 0 && Object.keys(importedParagraphs[0].style).length === 0))) {
|
|
218
|
+
const notesNode = createNotesNode(hasNotesStyle ? { style: notesStyle } : {});
|
|
219
|
+
populateRichTextNode(notesNode, importedParagraphs);
|
|
220
|
+
if (slideNode instanceof CommonContainer) slideNode.append(notesNode);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (info.phType !== void 0 && baselineNotesSlidePlaceholders.has(info.phType)) {
|
|
226
|
+
item.suppressUnconsumed();
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
const identity = peekShapeTreeObjectIdentity(item.element);
|
|
231
|
+
diagnostics.push({
|
|
232
|
+
code: "unsupported-mechanism",
|
|
233
|
+
category: "unsupported",
|
|
234
|
+
disposition: "omitted",
|
|
235
|
+
location: {
|
|
236
|
+
part: notesPartPath,
|
|
237
|
+
xpath: item.xpath,
|
|
238
|
+
slideIndex,
|
|
239
|
+
...identity
|
|
240
|
+
},
|
|
241
|
+
namespaceUri: item.namespaceUri,
|
|
242
|
+
localName: item.localName,
|
|
243
|
+
mechanismHint: "notes-slide-custom-object",
|
|
244
|
+
loss: {
|
|
245
|
+
lost: "custom-print-layout",
|
|
246
|
+
retainedAs: "notes-body-only"
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
item.suppressUnconsumed();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
appendUnconsumedDiagnostics(notesCursor, slideIndex, diagnostics);
|
|
253
|
+
return diagnostics.length === 0 ? {} : { diagnostics };
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Deck-level import handler for `presentation-sections` (`<p14:sectionLst>`).
|
|
258
|
+
*
|
|
259
|
+
* When invoked inside `createImporter`, `importPresentationSections` has already grouped
|
|
260
|
+
* slides into `SectionNode`s; this handler remains idempotent and also supports standalone
|
|
261
|
+
* mechanism calls against an ungrouped `DeckContainer`.
|
|
262
|
+
*/
|
|
263
|
+
const presentationSectionsImportHandler = {
|
|
264
|
+
target: "deck",
|
|
265
|
+
stage: "post-slides",
|
|
266
|
+
read(context) {
|
|
267
|
+
const { presentationCursor, deckNode, package: pkg, slideNodeByPresentationSldId } = context;
|
|
268
|
+
if (deckNode.children.some((child) => child instanceof CommonNode && child.type === "section")) return {};
|
|
269
|
+
let slideNodeBySldId = slideNodeByPresentationSldId;
|
|
270
|
+
if (slideNodeBySldId === void 0) {
|
|
271
|
+
const fallbackMap = /* @__PURE__ */ new Map();
|
|
272
|
+
const slideNodes = deckNode.children.filter((child) => child instanceof CommonNode && child.type === "slide");
|
|
273
|
+
const sldIdLst = presentationCursor.child(P_NS, "sldIdLst");
|
|
274
|
+
if (sldIdLst !== void 0) {
|
|
275
|
+
const sldIds = sldIdLst.children(P_NS, "sldId");
|
|
276
|
+
for (let index = 0; index < sldIds.length; index += 1) {
|
|
277
|
+
const rawId = sldIds[index]?.attr("id");
|
|
278
|
+
const slideNode = slideNodes[index];
|
|
279
|
+
if (rawId !== void 0 && slideNode !== void 0) {
|
|
280
|
+
const parsedId = Number(rawId);
|
|
281
|
+
if (Number.isInteger(parsedId)) fallbackMap.set(parsedId, slideNode);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
slideNodeBySldId = fallbackMap;
|
|
286
|
+
}
|
|
287
|
+
const diagnostics = [];
|
|
288
|
+
importPresentationSections(presentationCursor, deckNode, slideNodeBySldId, pkg.presentationPath, diagnostics);
|
|
289
|
+
return diagnostics.length === 0 ? {} : { diagnostics };
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
export { presentationSectionsImportHandler, speakerNotesImportHandler };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../../core/dist/author-ids.js";
|
|
2
|
+
import { textStyleSchema } from "../../../core/dist/theme.js";
|
|
3
|
+
import "../../../core/dist/capability.js";
|
|
4
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../../import/dist/xml-fragments.js";
|
|
5
|
+
import "../../../import/dist/index.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// ../capabilities/dist/notes/notes-schemas.js
|
|
8
|
+
const rawNotesDeclarationPropsSchema = z.strictObject({
|
|
9
|
+
id: authorIdSchema.optional(),
|
|
10
|
+
style: textStyleSchema.optional()
|
|
11
|
+
}).readonly();
|
|
12
|
+
/** Allowed declaration prop keys for `Notes` / `notes()`, derived from `rawNotesDeclarationPropsSchema`. */
|
|
13
|
+
const notesAllowedPropKeys = new Set(Object.keys(rawNotesDeclarationPropsSchema.unwrap().shape));
|
|
14
|
+
/** Pure-data Zod v4 contract for page-affiliated speaker notes declarations (`Notes` / `notes()`). */
|
|
15
|
+
const notesDeclarationPropsSchema = rawNotesDeclarationPropsSchema;
|
|
16
|
+
/** Validates `<p:notes>` root attributes in Transitional OOXML. */
|
|
17
|
+
const notesRootAttrsXmlSchema = z.object({
|
|
18
|
+
showMasterSp: ooxmlBoolSchema.optional(),
|
|
19
|
+
showMasterPhAnim: ooxmlBoolSchema.optional()
|
|
20
|
+
});
|
|
21
|
+
/** Validates `<p:cNvPr>` attributes inside notes slide shapes. */
|
|
22
|
+
const notesShapeIdentityXmlSchema = z.object({
|
|
23
|
+
id: ooxmlNonNegativeIntSchema,
|
|
24
|
+
name: z.string().optional()
|
|
25
|
+
});
|
|
26
|
+
/** Validates `<p:ph>` placeholder attributes inside notes slides. */
|
|
27
|
+
const notesPlaceholderXmlSchema = z.object({
|
|
28
|
+
type: z.string().optional(),
|
|
29
|
+
idx: ooxmlNonNegativeIntSchema.optional(),
|
|
30
|
+
sz: z.enum([
|
|
31
|
+
"full",
|
|
32
|
+
"half",
|
|
33
|
+
"quarter"
|
|
34
|
+
]).optional(),
|
|
35
|
+
orient: z.enum(["horz", "vert"]).optional(),
|
|
36
|
+
hasCustomPrompt: ooxmlBoolSchema.optional()
|
|
37
|
+
});
|
|
38
|
+
export { notesAllowedPropKeys, notesDeclarationPropsSchema, notesPlaceholderXmlSchema, notesRootAttrsXmlSchema, notesShapeIdentityXmlSchema };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { xmlDocument } from "../../../emit/dist/ooxml.js";
|
|
2
|
+
import "../../../emit/dist/index.js";
|
|
3
|
+
// ../capabilities/dist/notes/notes-xml.js
|
|
4
|
+
const drawingNamespace = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
5
|
+
const presentationNamespace = "http://schemas.openxmlformats.org/presentationml/2006/main";
|
|
6
|
+
const relationshipNamespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
7
|
+
const notesMasterContentType = "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
|
|
8
|
+
const notesSlideContentType = "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
|
|
9
|
+
const themeContentType = "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
10
|
+
const notesMasterRelationshipType = `${relationshipNamespace}/notesMaster`;
|
|
11
|
+
const notesSlideRelationshipType = `${relationshipNamespace}/notesSlide`;
|
|
12
|
+
const themeRelationshipType = `${relationshipNamespace}/theme`;
|
|
13
|
+
const slideRelationshipType = `${relationshipNamespace}/slide`;
|
|
14
|
+
const notesMasterPathTemplate = "ppt/notesMasters/notesMaster{n}.xml";
|
|
15
|
+
const notesSlidePathTemplate = "ppt/notesSlides/notesSlide{n}.xml";
|
|
16
|
+
const themePathTemplate = "ppt/theme/theme{n}.xml";
|
|
17
|
+
const colorMap = "<p:clrMap bg1=\"lt1\" tx1=\"dk1\" bg2=\"lt2\" tx2=\"dk2\" accent1=\"accent1\" accent2=\"accent2\" accent3=\"accent3\" accent4=\"accent4\" accent5=\"accent5\" accent6=\"accent6\" hlink=\"hlink\" folHlink=\"folHlink\"/>";
|
|
18
|
+
function groupShapeTree(shapes) {
|
|
19
|
+
return `<p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr>${shapes}`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Shared notes master for one deck.
|
|
23
|
+
*
|
|
24
|
+
* The master is intentionally fixed rather than author-composed: it supplies the slide-image and
|
|
25
|
+
* body placeholders plus the notes text defaults, while the page's notes body carries the actual
|
|
26
|
+
* rich-text content. Its theme relationship targets a notes-owned theme part with the deck theme
|
|
27
|
+
* values, so the notes master never shares the slide master's theme part.
|
|
28
|
+
*/
|
|
29
|
+
function notesMasterXml() {
|
|
30
|
+
return xmlDocument(`<p:notesMaster xmlns:a="${drawingNamespace}" xmlns:r="${relationshipNamespace}" xmlns:p="${presentationNamespace}"><p:cSld><p:bg><p:bgRef idx="1001"><a:schemeClr val="bg1"/></p:bgRef></p:bg><p:spTree>${groupShapeTree("<p:sp><p:nvSpPr><p:cNvPr id=\"2\" name=\"Slide Image Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\" noRot=\"1\" noChangeAspect=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldImg\" idx=\"2\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"685800\" y=\"1143000\"/><a:ext cx=\"5486400\" cy=\"3086100\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom><a:noFill/><a:ln><a:noFill/></a:ln></p:spPr></p:sp><p:sp><p:nvSpPr><p:cNvPr id=\"3\" name=\"Notes Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"body\" idx=\"1\"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x=\"685800\" y=\"4400550\"/><a:ext cx=\"5486400\" cy=\"3600450\"/></a:xfrm><a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom></p:spPr><p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang=\"en-US\" sz=\"1200\"/></a:p></p:txBody></p:sp>")}</p:spTree></p:cSld>${colorMap}<p:notesStyle><a:lvl1pPr><a:defRPr sz="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/></a:defRPr></a:lvl1pPr></p:notesStyle></p:notesMaster>`);
|
|
31
|
+
}
|
|
32
|
+
/** One notes slide body placeholder containing the parsed notes rich text. */
|
|
33
|
+
function notesSlideXml(textBody) {
|
|
34
|
+
const slideImage = "<p:sp><p:nvSpPr><p:cNvPr id=\"2\" name=\"Slide Image Placeholder 1\"/><p:cNvSpPr><a:spLocks noGrp=\"1\" noRot=\"1\" noChangeAspect=\"1\"/></p:cNvSpPr><p:nvPr><p:ph type=\"sldImg\"/></p:nvPr></p:nvSpPr><p:spPr/></p:sp>";
|
|
35
|
+
const body = `<p:sp><p:nvSpPr><p:cNvPr id="3" name="Notes Placeholder 2"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="body" idx="1"/></p:nvPr></p:nvSpPr><p:spPr/>${textBody}</p:sp>`;
|
|
36
|
+
return xmlDocument(`<p:notes xmlns:a="${drawingNamespace}" xmlns:r="${relationshipNamespace}" xmlns:p="${presentationNamespace}"><p:cSld><p:spTree>${groupShapeTree(slideImage + body)}</p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:notes>`);
|
|
37
|
+
}
|
|
38
|
+
export { notesMasterContentType, notesMasterPathTemplate, notesMasterRelationshipType, notesMasterXml, notesSlideContentType, notesSlidePathTemplate, notesSlideRelationshipType, notesSlideXml, slideRelationshipType, themeContentType, themePathTemplate, themeRelationshipType };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import "../../../core/dist/capability.js";
|
|
3
|
+
import { sectionListXml, themeXml, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
4
|
+
import "../../../emit/dist/index.js";
|
|
5
|
+
import { defineShowMechanism } from "../../../import/dist/mechanism.js";
|
|
6
|
+
import "../../../import/dist/index.js";
|
|
7
|
+
import { emitTextBody, parseTextContent, resolveTextBody } from "../shared/text-service.js";
|
|
8
|
+
import { notesCodegen } from "./notes-codegen.js";
|
|
9
|
+
import { presentationSectionsImportHandler, speakerNotesImportHandler } from "./notes-import.js";
|
|
10
|
+
import { notesDeclarationPropsSchema } from "./notes-schemas.js";
|
|
11
|
+
import { notesMasterContentType, notesMasterPathTemplate, notesMasterRelationshipType, notesMasterXml, notesSlideContentType, notesSlidePathTemplate, notesSlideRelationshipType, notesSlideXml, slideRelationshipType, themeContentType, themePathTemplate, themeRelationshipType } from "./notes-xml.js";
|
|
12
|
+
// ../capabilities/dist/notes/notes.js
|
|
13
|
+
/**
|
|
14
|
+
* Notes text defaults are independent of slide projection styles.
|
|
15
|
+
*
|
|
16
|
+
* Colors and font tokens still resolve through the owning page theme; the inherited projection
|
|
17
|
+
* text defaults are replaced instead of being overridden property by property.
|
|
18
|
+
*/
|
|
19
|
+
const notesDefaultTextStyle = Object.freeze({
|
|
20
|
+
fontFamily: "minor",
|
|
21
|
+
fontSize: "12pt",
|
|
22
|
+
fontWeight: "normal",
|
|
23
|
+
fontStyle: "normal",
|
|
24
|
+
color: "dk1",
|
|
25
|
+
verticalAlign: "top",
|
|
26
|
+
align: "left",
|
|
27
|
+
spacingAfter: 0,
|
|
28
|
+
letterSpacing: 0,
|
|
29
|
+
textTransform: "none",
|
|
30
|
+
textDecoration: "none",
|
|
31
|
+
textShadow: "none",
|
|
32
|
+
textWrap: "normal"
|
|
33
|
+
});
|
|
34
|
+
const boundNotesEntries = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
function parseNotes(input, pageTheme, slideNumber) {
|
|
36
|
+
const parsedProps = notesDeclarationPropsSchema.safeParse(input.props);
|
|
37
|
+
if (!parsedProps.success) {
|
|
38
|
+
const issue = parsedProps.error.issues[0];
|
|
39
|
+
if (issue?.code === "unrecognized_keys" && issue.path.length === 0) throw new CapabilityError("unknown-parameter", `Notes contains unsupported parameter ${issue.keys[0]}`);
|
|
40
|
+
if (issue?.path[0] === "id") throw new CapabilityError("invalid-notes", "Notes.id must be a string");
|
|
41
|
+
}
|
|
42
|
+
const theme = pageTheme.withTextStyle(notesDefaultTextStyle);
|
|
43
|
+
return {
|
|
44
|
+
...parseTextContent(input.children, input.props["style"], theme, { slideNumber }, "Notes.style"),
|
|
45
|
+
theme
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function emitSpeakerNotes(model, emitContext) {
|
|
49
|
+
const embedFonts = emitContext.options.embedFonts;
|
|
50
|
+
const body = emitTextBody(model.resolvedBody, model.entryTheme, {
|
|
51
|
+
createFieldId: emitContext.createTextFieldId,
|
|
52
|
+
...embedFonts === void 0 ? {} : { embedFonts }
|
|
53
|
+
});
|
|
54
|
+
emitContext.registerSharedPart("notes-theme", {
|
|
55
|
+
part: {
|
|
56
|
+
pathTemplate: themePathTemplate,
|
|
57
|
+
contentType: themeContentType
|
|
58
|
+
},
|
|
59
|
+
content: () => themeXml(emitContext.theme.theme)
|
|
60
|
+
});
|
|
61
|
+
emitContext.registerSharedPart("notes-master", {
|
|
62
|
+
part: {
|
|
63
|
+
pathTemplate: notesMasterPathTemplate,
|
|
64
|
+
contentType: notesMasterContentType
|
|
65
|
+
},
|
|
66
|
+
presentationRelationshipType: notesMasterRelationshipType,
|
|
67
|
+
relationships: [{
|
|
68
|
+
relationshipType: themeRelationshipType,
|
|
69
|
+
target: {
|
|
70
|
+
kind: "part",
|
|
71
|
+
key: "notes-theme"
|
|
72
|
+
}
|
|
73
|
+
}],
|
|
74
|
+
presentationElement: {
|
|
75
|
+
position: "before-slides",
|
|
76
|
+
content: (relationshipId) => `<p:notesMasterIdLst><p:notesMasterId r:id="${xmlEscape(relationshipId)}"/></p:notesMasterIdLst>`
|
|
77
|
+
},
|
|
78
|
+
content: () => notesMasterXml()
|
|
79
|
+
});
|
|
80
|
+
emitContext.registerPackagePart({
|
|
81
|
+
part: {
|
|
82
|
+
pathTemplate: notesSlidePathTemplate,
|
|
83
|
+
contentType: notesSlideContentType
|
|
84
|
+
},
|
|
85
|
+
slideRelationshipType: notesSlideRelationshipType,
|
|
86
|
+
relationships: [{
|
|
87
|
+
relationshipType: slideRelationshipType,
|
|
88
|
+
target: { kind: "slide" }
|
|
89
|
+
}, {
|
|
90
|
+
relationshipType: notesMasterRelationshipType,
|
|
91
|
+
target: {
|
|
92
|
+
kind: "part",
|
|
93
|
+
key: "notes-master"
|
|
94
|
+
}
|
|
95
|
+
}],
|
|
96
|
+
content: () => notesSlideXml(body.xml)
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
xml: "",
|
|
100
|
+
...body.presentationContributions.length === 0 ? {} : { presentationContributions: body.presentationContributions }
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** Typed native show mechanism connecting emit and import for `speaker-notes`. */
|
|
104
|
+
const speakerNotesMechanism = defineShowMechanism({
|
|
105
|
+
key: "speaker-notes",
|
|
106
|
+
role: "show",
|
|
107
|
+
emit: emitSpeakerNotes,
|
|
108
|
+
import: speakerNotesImportHandler
|
|
109
|
+
});
|
|
110
|
+
/** Typed native show mechanism connecting emit and import for `presentation-sections`. */
|
|
111
|
+
const presentationSectionsMechanism = defineShowMechanism({
|
|
112
|
+
key: "presentation-sections",
|
|
113
|
+
role: "show",
|
|
114
|
+
emit: (model) => ({ xml: sectionListXml(model.sections) }),
|
|
115
|
+
import: presentationSectionsImportHandler
|
|
116
|
+
});
|
|
117
|
+
function notesObservation(text, paragraphs) {
|
|
118
|
+
return {
|
|
119
|
+
text,
|
|
120
|
+
paragraphCount: paragraphs.length
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Page-affiliated rich-text notes capability.
|
|
125
|
+
*
|
|
126
|
+
* The visible slide tree never contains the notes body: core treats the declaration subtree as
|
|
127
|
+
* owned by this module, while this module parses the shared P/Span content once into an opaque
|
|
128
|
+
* per-build binding, resolves text metrics and resource claims during resolve, and emits the notes
|
|
129
|
+
* part, body placeholder, notes master, relationships, and font resources during emit. Notes has
|
|
130
|
+
* no canvas geometry or static slide preview layer.
|
|
131
|
+
*/
|
|
132
|
+
const notesCapability = Object.freeze({
|
|
133
|
+
declaration: "notes",
|
|
134
|
+
slideProp: "notes",
|
|
135
|
+
slideProps: [],
|
|
136
|
+
slot: "timing",
|
|
137
|
+
always: true,
|
|
138
|
+
codegen: notesCodegen,
|
|
139
|
+
mechanisms: [speakerNotesMechanism, presentationSectionsMechanism],
|
|
140
|
+
bindSections(sections) {
|
|
141
|
+
return {
|
|
142
|
+
extensions: ["p14"],
|
|
143
|
+
emit: () => presentationSectionsMechanism.emit({ sections })
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
transparentDeclarations: [{
|
|
147
|
+
declaration: "notes",
|
|
148
|
+
children: "owned",
|
|
149
|
+
compileDeclaration(input, context) {
|
|
150
|
+
if (context.theme === void 0 || context.slideNumber === void 0) throw new CapabilityError("invalid-notes", "Notes declaration requires slide theme and number context");
|
|
151
|
+
const entry = parseNotes(input, context.theme, context.slideNumber);
|
|
152
|
+
const token = Object.freeze({});
|
|
153
|
+
boundNotesEntries.set(token, entry);
|
|
154
|
+
return [{
|
|
155
|
+
capability: "notes",
|
|
156
|
+
value: token
|
|
157
|
+
}];
|
|
158
|
+
}
|
|
159
|
+
}],
|
|
160
|
+
bindSlide(_input, parseContext) {
|
|
161
|
+
const contributions = parseContext.contributions.filter((contribution) => contribution.capability === "notes");
|
|
162
|
+
if (contributions.length === 0) return { resolveSlide() {
|
|
163
|
+
return {
|
|
164
|
+
extensions: [],
|
|
165
|
+
emit() {
|
|
166
|
+
return { xml: "" };
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
} };
|
|
170
|
+
if (contributions.length > 1) throw new CapabilityError("duplicate-notes", "A slide can declare at most one Notes", contributions[1].path);
|
|
171
|
+
const contribution = contributions[0];
|
|
172
|
+
const entry = typeof contribution.value === "object" && contribution.value !== null ? boundNotesEntries.get(contribution.value) : void 0;
|
|
173
|
+
if (entry === void 0) throw new CapabilityError("invalid-notes", "Notes declaration is missing its bound content", contribution.path);
|
|
174
|
+
return { resolveSlide() {
|
|
175
|
+
const resolvedBody = resolveTextBody(entry.paragraphs, entry.style, entry.theme, "top", void 0, "text-box");
|
|
176
|
+
return {
|
|
177
|
+
observation: notesObservation(resolvedBody.text, entry.paragraphs),
|
|
178
|
+
extensions: [],
|
|
179
|
+
resourceClaims: resolvedBody.resourceClaims,
|
|
180
|
+
fontUsages: resolvedBody.fontUsages.map((usage) => ({
|
|
181
|
+
...usage,
|
|
182
|
+
path: contribution.path
|
|
183
|
+
})),
|
|
184
|
+
emit(emitContext) {
|
|
185
|
+
return speakerNotesMechanism.emit({
|
|
186
|
+
resolvedBody,
|
|
187
|
+
entryTheme: entry.theme
|
|
188
|
+
}, emitContext);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
} };
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
export { notesCapability, presentationSectionsMechanism, speakerNotesMechanism };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../../core/dist/document-internals.js";
|
|
2
|
+
import { nativePlaceholderRefSchema } from "../../../core/dist/placeholders.js";
|
|
3
|
+
import "../../../codegen/dist/index.js";
|
|
4
|
+
import { defineObjectCodegen } from "../../../codegen/dist/types.js";
|
|
5
|
+
import "../../../core/dist/capability.js";
|
|
6
|
+
import { placeholderAllowedPropKeys, placeholderObjectStyleSchema } from "./placeholder-schemas.js";
|
|
7
|
+
// ../capabilities/dist/placeholder/placeholder-codegen.js
|
|
8
|
+
function isPlainRecord(value) {
|
|
9
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
10
|
+
const proto = Object.getPrototypeOf(value);
|
|
11
|
+
return proto === Object.prototype || proto === null;
|
|
12
|
+
}
|
|
13
|
+
function validatePlaceholderNativeRef(value, ctx) {
|
|
14
|
+
const parsed = nativePlaceholderRefSchema.safeParse(value);
|
|
15
|
+
if (!parsed.success) {
|
|
16
|
+
const issue = parsed.error.issues[0];
|
|
17
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Placeholder.nativePlaceholder cannot be expressed", "@nativePlaceholder");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function validatePlaceholderStyle(value, ctx) {
|
|
21
|
+
if (!isPlainRecord(value)) ctx.fail("unexpressible-value", "Placeholder.style must be a plain object", "@style");
|
|
22
|
+
const parsed = placeholderObjectStyleSchema.safeParse(value);
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
const issue = parsed.error.issues[0];
|
|
25
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
26
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Placeholder.style cannot be expressed", issuePath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function collectPlaceholderProps(node, ctx) {
|
|
30
|
+
if (node.children.length > 0) return ctx.fail("unexpressible-value", "Unpopulated placeholder cannot contain children");
|
|
31
|
+
const entries = [];
|
|
32
|
+
for (const [key, value] of Object.entries(readInternalDeclarationProps(node))) {
|
|
33
|
+
if (value === void 0) continue;
|
|
34
|
+
if (!placeholderAllowedPropKeys.has(key)) ctx.fail("invalid-document", `placeholder declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
35
|
+
if (key === "nativePlaceholder") validatePlaceholderNativeRef(value, ctx);
|
|
36
|
+
else if (key === "style") validatePlaceholderStyle(value, ctx);
|
|
37
|
+
entries.push([key, value]);
|
|
38
|
+
}
|
|
39
|
+
return entries;
|
|
40
|
+
}
|
|
41
|
+
/** Source codegen contribution for unpopulated `placeholder` declarations. */
|
|
42
|
+
const placeholderCodegen = defineObjectCodegen({ declarations: { placeholder: {
|
|
43
|
+
emitVanilla: (node, ctx) => {
|
|
44
|
+
const callee = ctx.useImport("placeholder");
|
|
45
|
+
const propsEntries = collectPlaceholderProps(node, ctx);
|
|
46
|
+
return propsEntries.length === 0 ? ctx.formatVanillaCall(callee, []) : ctx.formatVanillaCall(callee, [ctx.formatProps(propsEntries)]);
|
|
47
|
+
},
|
|
48
|
+
emitReact: (node, ctx) => {
|
|
49
|
+
const tag = ctx.useImport("Placeholder");
|
|
50
|
+
const propsEntries = collectPlaceholderProps(node, ctx);
|
|
51
|
+
return ctx.formatJsxElement(tag, propsEntries);
|
|
52
|
+
}
|
|
53
|
+
} } });
|
|
54
|
+
export { placeholderCodegen };
|