@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,9 @@
|
|
|
1
|
+
import { placeholderRefXml } from "../../../emit/dist/ooxml.js";
|
|
2
|
+
import "../../../emit/dist/index.js";
|
|
3
|
+
// ../capabilities/dist/text/text-xml.js
|
|
4
|
+
/** Internal PresentationML text box / text placeholder wrapper for the text capability. */
|
|
5
|
+
function textBoxXml(id, escapedName, _box, textBody, properties, linkXml, placeholder) {
|
|
6
|
+
if (placeholder !== void 0) return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${placeholderRefXml(placeholder.nativeRef)}</p:nvPr></p:nvSpPr>${placeholder.spPrXml ?? properties}${textBody}</p:sp>`;
|
|
7
|
+
return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr>${properties}${textBody}</p:sp>`;
|
|
8
|
+
}
|
|
9
|
+
export { placeholderRefXml, textBoxXml };
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import { textStyleKeys } from "../../../core/dist/theme.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, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
7
|
+
import "../../../emit/dist/index.js";
|
|
8
|
+
import "../../../import/dist/index.js";
|
|
9
|
+
import { defineCanvasMechanism, defineShowMechanism } from "../../../import/dist/mechanism.js";
|
|
10
|
+
import { fontPresentationContributions } from "../font/font-embedding.js";
|
|
11
|
+
import { embeddedFontImportHandler } from "../font/font-import.js";
|
|
12
|
+
import { motionAnnotations, motionParagraphAnnotations, pickMotionProps } from "../motion/motion-api.js";
|
|
13
|
+
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
|
|
14
|
+
import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
|
|
15
|
+
import { parseTextCoordinate, parseTextExtent, textBoxAllowedParamKeys, textBoxStyleKeys } from "../shared/text-schemas.js";
|
|
16
|
+
import { computeTextMetrics, emitSlideNumberRunXml, emitTextBody, measureTextLayoutFromParagraphs, parseTextContent, renderTextOutlinesSvg, resolveTextBody, textInsets } from "../shared/text-service.js";
|
|
17
|
+
import { emitPlaceholderVisualSpPr, emitVisualModel, paintVisualModel, resolveVisualModel, visualSvgTransform } from "../shared/visual.js";
|
|
18
|
+
import { textCodegen } from "./text-codegen.js";
|
|
19
|
+
import { textBoxImportHandler, textFieldSlideNumImportHandler, textPlaceholderImportHandler } from "./text-import.js";
|
|
20
|
+
import { textBoxXml } from "./text-xml.js";
|
|
21
|
+
import { font, fromFontCollection } from "../font/font.js";
|
|
22
|
+
// ../capabilities/dist/text/text.js
|
|
23
|
+
function record(value) {
|
|
24
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
|
+
}
|
|
26
|
+
function coordinate(value, label, path) {
|
|
27
|
+
return parseTextCoordinate(value, label, path);
|
|
28
|
+
}
|
|
29
|
+
function size(value, label, path) {
|
|
30
|
+
return parseTextExtent(value, label, path);
|
|
31
|
+
}
|
|
32
|
+
function textStyle(value) {
|
|
33
|
+
if (!record(value)) return value;
|
|
34
|
+
return Object.fromEntries(Object.entries(value).filter(([key]) => textStyleKeys.has(key)));
|
|
35
|
+
}
|
|
36
|
+
const textCompatiblePlaceholderRoles = /* @__PURE__ */ new Set([
|
|
37
|
+
"title",
|
|
38
|
+
"ctrTitle",
|
|
39
|
+
"subTitle",
|
|
40
|
+
"body",
|
|
41
|
+
"dt",
|
|
42
|
+
"ftr",
|
|
43
|
+
"hdr",
|
|
44
|
+
"obj",
|
|
45
|
+
"sldNum"
|
|
46
|
+
]);
|
|
47
|
+
function emitTextModel(model, emitContext) {
|
|
48
|
+
const embedFonts = emitContext.options.embedFonts;
|
|
49
|
+
const emittedBody = emitTextBody(model.text, emitContext.theme, {
|
|
50
|
+
createFieldId: emitContext.createTextFieldId,
|
|
51
|
+
...embedFonts === void 0 ? {} : { embedFonts }
|
|
52
|
+
});
|
|
53
|
+
let placeholderEmit;
|
|
54
|
+
let propertiesXml = "";
|
|
55
|
+
if (model.placeholder !== void 0) placeholderEmit = {
|
|
56
|
+
nativeRef: model.placeholder.nativeRef,
|
|
57
|
+
spPrXml: emitPlaceholderVisualSpPr(model.visual, model.placeholder.spPrFlags, (resource) => emitContext.registerResource(resource))
|
|
58
|
+
};
|
|
59
|
+
else propertiesXml = emitVisualModel(model.visual, (resource) => emitContext.registerResource(resource)).xml;
|
|
60
|
+
return {
|
|
61
|
+
xml: textBoxXml(emitContext.id, model.escapedName, model.box, emittedBody.xml, propertiesXml, nativeLinkXml(emitContext.nativeLink), placeholderEmit),
|
|
62
|
+
...emittedBody.presentationContributions.length === 0 ? {} : { presentationContributions: emittedBody.presentationContributions }
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function paintTextModel(model, paintContext) {
|
|
66
|
+
const paintBox = paintContext.box ?? model.box;
|
|
67
|
+
const visualPaint = model.visual.hasVisibleStyle ? paintVisualModel({
|
|
68
|
+
model: model.visual,
|
|
69
|
+
slideNumber: paintContext.slideNumber,
|
|
70
|
+
objectId: paintContext.objectId,
|
|
71
|
+
...paintContext.registerRasterResource === void 0 ? {} : { registerRasterResource: paintContext.registerRasterResource }
|
|
72
|
+
}) : void 0;
|
|
73
|
+
const backgroundSvg = visualPaint?.svg ?? "";
|
|
74
|
+
const glyphs = renderTextOutlinesSvg({
|
|
75
|
+
paragraphs: model.text.paragraphs,
|
|
76
|
+
box: paintBox,
|
|
77
|
+
insets: model.insets,
|
|
78
|
+
verticalAlign: model.text.verticalAlign,
|
|
79
|
+
theme: paintContext.theme,
|
|
80
|
+
measuredLayout: model.box.width === paintBox.width ? model.text.measuredLayout : void 0,
|
|
81
|
+
idPrefix: `obj-s${paintContext.slideNumber}-o${paintContext.objectId}`,
|
|
82
|
+
rotate: model.visual.rotate
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
svg: `${backgroundSvg}<g transform="${visualSvgTransform(model.visual)}">${glyphs}</g>`,
|
|
86
|
+
...visualPaint?.placeholders === void 0 ? {} : { placeholders: visualPaint.placeholders }
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/** Typed native canvas mechanism connecting emit, paint, and import for `text-box`. */
|
|
90
|
+
const textBoxMechanism = defineCanvasMechanism({
|
|
91
|
+
key: "text-box",
|
|
92
|
+
role: "canvas",
|
|
93
|
+
emit: emitTextModel,
|
|
94
|
+
paint: paintTextModel,
|
|
95
|
+
import: textBoxImportHandler
|
|
96
|
+
});
|
|
97
|
+
/** Typed native canvas mechanism connecting emit, paint, and import for `text-placeholder`. */
|
|
98
|
+
const textPlaceholderMechanism = defineCanvasMechanism({
|
|
99
|
+
key: "text-placeholder",
|
|
100
|
+
role: "canvas",
|
|
101
|
+
emit: emitTextModel,
|
|
102
|
+
paint: paintTextModel,
|
|
103
|
+
import: textPlaceholderImportHandler
|
|
104
|
+
});
|
|
105
|
+
/** Typed native canvas mechanism connecting emit, paint, and import for `text-field-slidenum`. */
|
|
106
|
+
const textFieldSlideNumMechanism = defineCanvasMechanism({
|
|
107
|
+
key: "text-field-slidenum",
|
|
108
|
+
role: "canvas",
|
|
109
|
+
emit(model, emitContext) {
|
|
110
|
+
return { xml: emitSlideNumberRunXml(model.run, emitContext.theme, emitContext.createTextFieldId) };
|
|
111
|
+
},
|
|
112
|
+
paint(model, paintContext) {
|
|
113
|
+
return { svg: renderTextOutlinesSvg({
|
|
114
|
+
paragraphs: [{
|
|
115
|
+
runs: [model.run],
|
|
116
|
+
style: {},
|
|
117
|
+
endStyle: model.run.style,
|
|
118
|
+
wrap: "normal"
|
|
119
|
+
}],
|
|
120
|
+
box: paintContext.box ?? model.box,
|
|
121
|
+
theme: paintContext.theme,
|
|
122
|
+
idPrefix: model.idPrefix
|
|
123
|
+
}) };
|
|
124
|
+
},
|
|
125
|
+
import: textFieldSlideNumImportHandler
|
|
126
|
+
});
|
|
127
|
+
/** Typed native show mechanism connecting emit and import for presentation `embedded-font`. */
|
|
128
|
+
const embeddedFontMechanism = defineShowMechanism({
|
|
129
|
+
key: "embedded-font",
|
|
130
|
+
role: "show",
|
|
131
|
+
emit(model) {
|
|
132
|
+
return {
|
|
133
|
+
xml: "",
|
|
134
|
+
presentationContributions: fontPresentationContributions(model.uses, model.mode)
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
import: embeddedFontImportHandler
|
|
138
|
+
});
|
|
139
|
+
/** Fixed-region and content-sized text box capability bound per formal build. */
|
|
140
|
+
const textCapability = {
|
|
141
|
+
declaration: "text",
|
|
142
|
+
codegen: textCodegen,
|
|
143
|
+
mechanisms: [
|
|
144
|
+
textBoxMechanism,
|
|
145
|
+
textPlaceholderMechanism,
|
|
146
|
+
textFieldSlideNumMechanism,
|
|
147
|
+
embeddedFontMechanism
|
|
148
|
+
],
|
|
149
|
+
bind(input, context) {
|
|
150
|
+
const unknown = Object.keys(input.props).find((key) => !textBoxAllowedParamKeys.has(key));
|
|
151
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Text contains unsupported parameter ${unknown}`);
|
|
152
|
+
const placeholder = context.placeholder;
|
|
153
|
+
if (placeholder !== void 0) {
|
|
154
|
+
const role = placeholder.layoutPlaceholder?.type ?? placeholder.nativeRef.type;
|
|
155
|
+
if (!textCompatiblePlaceholderRoles.has(role)) throw new CapabilityError("incompatible-placeholder-content", `Text cannot be bound to ${role} placeholder`);
|
|
156
|
+
}
|
|
157
|
+
const requestedName = parseOptionalName(input.props["name"]);
|
|
158
|
+
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
159
|
+
const link = parseLinkTarget(input.props["link"]);
|
|
160
|
+
const placeholderGeometry = placeholder === void 0 ? void 0 : resolvePlaceholderGeometry(placeholder, input.props);
|
|
161
|
+
const declaredX = placeholderGeometry?.x;
|
|
162
|
+
const declaredY = placeholderGeometry?.y;
|
|
163
|
+
const declaredWidth = placeholderGeometry?.width;
|
|
164
|
+
if (declaredX !== void 0) coordinate(declaredX, "x");
|
|
165
|
+
if (declaredY !== void 0) coordinate(declaredY, "y");
|
|
166
|
+
if (declaredWidth !== void 0 && typeof declaredWidth === "number") size(declaredWidth, "width");
|
|
167
|
+
const allowedStyleKeys = new Set(textBoxStyleKeys);
|
|
168
|
+
const contract = parseCapabilityLayoutContract({
|
|
169
|
+
nativeKind: "sp",
|
|
170
|
+
props: input.props,
|
|
171
|
+
allowedStyleKeys,
|
|
172
|
+
allowPadding: true,
|
|
173
|
+
path: context.path
|
|
174
|
+
});
|
|
175
|
+
const insets = textInsets(input.props["style"], placeholder);
|
|
176
|
+
const placeholderHeight = placeholderGeometry?.height;
|
|
177
|
+
const isContentSized = !(placeholderHeight !== void 0 && placeholderHeight !== "auto") && !(contract.fixedAxes?.height ?? false);
|
|
178
|
+
const declaredPixelHeight = typeof placeholderHeight === "number" ? size(placeholderHeight, "height") : contract.explicitPixelSize?.height;
|
|
179
|
+
const { paragraphs, paragraphMotions, style: parsedTextStyle, localBodyDeclared } = parseTextContent(input.children, textStyle(input.props["style"]), placeholder?.masterTheme ?? context.theme, { slideNumber: context.slideNumber }, "Text.style", placeholder, input.props["style"], { allowParagraphMotion: true });
|
|
180
|
+
const rawSlideStyle = record(input.props["style"]) ? input.props["style"] : void 0;
|
|
181
|
+
const inheritedPlaceholderGeometry = placeholder?.layoutPlaceholder?.geometry ?? placeholder?.masterPlaceholder?.geometry;
|
|
182
|
+
const visualStyle = placeholder !== void 0 ? resolvePlaceholderVisualStyle(placeholder, rawSlideStyle) : rawSlideStyle !== void 0 ? { ...rawSlideStyle } : {};
|
|
183
|
+
resolveVisualModel({
|
|
184
|
+
theme: placeholder?.masterTheme ?? context.theme,
|
|
185
|
+
style: visualStyle,
|
|
186
|
+
box: {
|
|
187
|
+
x: 0,
|
|
188
|
+
y: 0,
|
|
189
|
+
width: 100,
|
|
190
|
+
height: 100
|
|
191
|
+
},
|
|
192
|
+
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry }
|
|
193
|
+
});
|
|
194
|
+
const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
|
|
195
|
+
const motionProps = pickMotionProps(input.props);
|
|
196
|
+
const native = {
|
|
197
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
198
|
+
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
199
|
+
...link === void 0 ? {} : { link }
|
|
200
|
+
};
|
|
201
|
+
return {
|
|
202
|
+
contract,
|
|
203
|
+
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
204
|
+
measureLayout(request) {
|
|
205
|
+
const width = request.availableWidth ?? contract.explicitPixelSize?.width ?? declaredWidth;
|
|
206
|
+
const innerWidth = request.availableWidth !== void 0 ? request.availableWidth : typeof width === "number" ? Math.max(0, width - insets.left - insets.right) : void 0;
|
|
207
|
+
try {
|
|
208
|
+
const measured = measureTextLayoutFromParagraphs(paragraphs, parsedTextStyle, innerWidth);
|
|
209
|
+
return {
|
|
210
|
+
...measured,
|
|
211
|
+
baseline: measured.baseline ?? "unavailable"
|
|
212
|
+
};
|
|
213
|
+
} catch (error) {
|
|
214
|
+
if (!isContentSized && request.purpose !== "baseline" && error instanceof CapabilityError && (error.code === "font-measurement-unavailable" || error.code === "font-missing-glyph")) return { baseline: "unavailable" };
|
|
215
|
+
throw error;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
resolve(resolveContext) {
|
|
219
|
+
const dimensions = {
|
|
220
|
+
x: coordinate(resolveContext.layoutBox?.x ?? declaredX, "x"),
|
|
221
|
+
y: coordinate(resolveContext.layoutBox?.y ?? declaredY, "y"),
|
|
222
|
+
width: size(resolveContext.layoutBox?.width ?? declaredWidth ?? contract.explicitPixelSize?.width, "width")
|
|
223
|
+
};
|
|
224
|
+
const measuredHeight = isContentSized ? void 0 : declaredPixelHeight;
|
|
225
|
+
const outputHeight = resolveContext.layoutBox?.height ?? measuredHeight;
|
|
226
|
+
const innerWidth = Math.max(0, dimensions.width - insets.left - insets.right);
|
|
227
|
+
const innerHeight = outputHeight === void 0 ? void 0 : Math.max(0, outputHeight - insets.top - insets.bottom);
|
|
228
|
+
const resolvedText = resolveTextBody(paragraphs, parsedTextStyle, placeholder?.masterTheme ?? resolveContext.theme, parsedTextStyle.verticalAlign ?? "top", {
|
|
229
|
+
width: innerWidth,
|
|
230
|
+
...innerHeight === void 0 ? {} : { height: innerHeight },
|
|
231
|
+
contentSized: isContentSized,
|
|
232
|
+
insets
|
|
233
|
+
}, "text-box", placeholder === void 0 ? void 0 : {
|
|
234
|
+
isPlaceholder: true,
|
|
235
|
+
...localBodyDeclared === void 0 ? {} : { localBodyDeclared }
|
|
236
|
+
});
|
|
237
|
+
const box = {
|
|
238
|
+
...dimensions,
|
|
239
|
+
height: size(resolveContext.layoutBox?.height ?? (isContentSized ? resolvedText.measurement === void 0 ? void 0 : resolvedText.measurement.height + insets.top + insets.bottom : measuredHeight), "height")
|
|
240
|
+
};
|
|
241
|
+
const textMetrics = computeTextMetrics(resolvedText, Math.max(0, box.width - insets.left - insets.right), Math.max(0, box.height - insets.top - insets.bottom));
|
|
242
|
+
const visual = resolveVisualModel({
|
|
243
|
+
theme: placeholder?.masterTheme ?? resolveContext.theme,
|
|
244
|
+
style: visualStyle,
|
|
245
|
+
box,
|
|
246
|
+
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry }
|
|
247
|
+
});
|
|
248
|
+
const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `Text ${resolveContext.id - 1}`;
|
|
249
|
+
let escapedName;
|
|
250
|
+
try {
|
|
251
|
+
assertXml10Characters(name);
|
|
252
|
+
escapedName = xmlEscape(name);
|
|
253
|
+
} catch {
|
|
254
|
+
throw new CapabilityError("invalid-xml-character", "Text.name contains characters not allowed in XML 1.0");
|
|
255
|
+
}
|
|
256
|
+
const target = {
|
|
257
|
+
kind: "text",
|
|
258
|
+
name,
|
|
259
|
+
...authorId === void 0 ? {} : { authorId },
|
|
260
|
+
textBody: true,
|
|
261
|
+
filled: visual.fill.kind !== "none",
|
|
262
|
+
box,
|
|
263
|
+
rotationDegrees: visual.rotate,
|
|
264
|
+
hasBackground: visual.fill.kind !== "none" || visual.border !== void 0,
|
|
265
|
+
paragraphCount: resolvedText.paragraphCount
|
|
266
|
+
};
|
|
267
|
+
const annotations = [...motionAnnotations(motionProps, target), ...motionParagraphAnnotations(paragraphMotions, target, motionProps)];
|
|
268
|
+
const transform = {
|
|
269
|
+
box,
|
|
270
|
+
angle: visual.rotate,
|
|
271
|
+
flipH: visual.flipH,
|
|
272
|
+
flipV: visual.flipV
|
|
273
|
+
};
|
|
274
|
+
const model = {
|
|
275
|
+
escapedName,
|
|
276
|
+
box,
|
|
277
|
+
visual,
|
|
278
|
+
text: resolvedText,
|
|
279
|
+
insets,
|
|
280
|
+
...placeholder === void 0 ? {} : { placeholder: {
|
|
281
|
+
nativeRef: placeholder.nativeRef,
|
|
282
|
+
spPrFlags: {
|
|
283
|
+
hasBox: placeholderGeometry?.hasLocalBoxOverride === true,
|
|
284
|
+
hasRotate: hasLocalDeclaration(rawSlideStyle, "rotate"),
|
|
285
|
+
hasFlipH: hasLocalDeclaration(rawSlideStyle, "flipH"),
|
|
286
|
+
hasFlipV: hasLocalDeclaration(rawSlideStyle, "flipV"),
|
|
287
|
+
hasGeometryOrRadius: hasLocalDeclaration(rawSlideStyle, "borderRadius"),
|
|
288
|
+
hasFill: hasLocalDeclaration(rawSlideStyle, "background"),
|
|
289
|
+
hasBorder: hasLocalDeclaration(rawSlideStyle, "border"),
|
|
290
|
+
hasEffects: hasLocalDeclaration(rawSlideStyle, "boxShadow") || hasLocalDeclaration(rawSlideStyle, "softEdge"),
|
|
291
|
+
includeDefaultRectWhenHasBox: false
|
|
292
|
+
}
|
|
293
|
+
} }
|
|
294
|
+
};
|
|
295
|
+
return {
|
|
296
|
+
observation: {
|
|
297
|
+
id: resolveContext.id,
|
|
298
|
+
kind: "text",
|
|
299
|
+
name,
|
|
300
|
+
box,
|
|
301
|
+
text: resolvedText.text,
|
|
302
|
+
textMetrics
|
|
303
|
+
},
|
|
304
|
+
transform,
|
|
305
|
+
extensions: [],
|
|
306
|
+
...annotations.length === 0 ? {} : { annotations },
|
|
307
|
+
resourceClaims: resolvedText.resourceClaims,
|
|
308
|
+
fontUsages: resolvedText.fontUsages,
|
|
309
|
+
emit(emitContext) {
|
|
310
|
+
return placeholder !== void 0 ? textPlaceholderMechanism.emit(model, emitContext) : textBoxMechanism.emit(model, emitContext);
|
|
311
|
+
},
|
|
312
|
+
paint(paintContext) {
|
|
313
|
+
return placeholder !== void 0 ? textPlaceholderMechanism.paint(model, paintContext) : textBoxMechanism.paint(model, paintContext);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
export { embeddedFontMechanism, font, fromFontCollection, textBoxMechanism, textCapability, textFieldSlideNumMechanism, textPlaceholderMechanism };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ../capabilities/dist/transition/transition-api.js
|
|
3
|
+
/** Transition duration in milliseconds; rounded to the nearest integer millisecond when written to p14:dur. */
|
|
4
|
+
const transitionDurationSchema = z.number().finite().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
5
|
+
const advanceAfterSchema = z.number().finite().min(0).max(4294967295);
|
|
6
|
+
const rawTransitionDirectionSchema = z.enum([
|
|
7
|
+
"left",
|
|
8
|
+
"right",
|
|
9
|
+
"top",
|
|
10
|
+
"bottom"
|
|
11
|
+
]);
|
|
12
|
+
const rawStripsDirectionSchema = z.enum([
|
|
13
|
+
"leftUp",
|
|
14
|
+
"rightUp",
|
|
15
|
+
"leftDown",
|
|
16
|
+
"rightDown"
|
|
17
|
+
]);
|
|
18
|
+
const transitionSpeedSchema = z.enum([
|
|
19
|
+
"fast",
|
|
20
|
+
"med",
|
|
21
|
+
"slow"
|
|
22
|
+
]);
|
|
23
|
+
const flipDirectionSchema = z.enum(["left", "right"]);
|
|
24
|
+
const morphBySchema = z.enum([
|
|
25
|
+
"object",
|
|
26
|
+
"word",
|
|
27
|
+
"character"
|
|
28
|
+
]);
|
|
29
|
+
const transitionKindSchema = z.enum([
|
|
30
|
+
"fade",
|
|
31
|
+
"strips",
|
|
32
|
+
"push",
|
|
33
|
+
"flip",
|
|
34
|
+
"morph"
|
|
35
|
+
]);
|
|
36
|
+
const fadeTransitionObjectSchema = z.strictObject({
|
|
37
|
+
type: z.literal("transition"),
|
|
38
|
+
kind: z.literal("fade"),
|
|
39
|
+
duration: transitionDurationSchema.optional()
|
|
40
|
+
});
|
|
41
|
+
const fadeTransitionSchema = fadeTransitionObjectSchema.readonly();
|
|
42
|
+
const stripsTransitionObjectSchema = z.strictObject({
|
|
43
|
+
type: z.literal("transition"),
|
|
44
|
+
kind: z.literal("strips"),
|
|
45
|
+
duration: transitionDurationSchema.optional(),
|
|
46
|
+
direction: rawStripsDirectionSchema
|
|
47
|
+
});
|
|
48
|
+
const stripsTransitionSchema = stripsTransitionObjectSchema.readonly();
|
|
49
|
+
const pushTransitionObjectSchema = z.strictObject({
|
|
50
|
+
type: z.literal("transition"),
|
|
51
|
+
kind: z.literal("push"),
|
|
52
|
+
duration: transitionDurationSchema.optional(),
|
|
53
|
+
from: rawTransitionDirectionSchema
|
|
54
|
+
});
|
|
55
|
+
const pushTransitionSchema = pushTransitionObjectSchema.readonly();
|
|
56
|
+
const rawStandardTransitionSchema = z.discriminatedUnion("kind", [
|
|
57
|
+
fadeTransitionSchema,
|
|
58
|
+
stripsTransitionSchema,
|
|
59
|
+
pushTransitionSchema
|
|
60
|
+
]);
|
|
61
|
+
const flipTransitionObjectSchema = z.strictObject({
|
|
62
|
+
type: z.literal("transition"),
|
|
63
|
+
kind: z.literal("flip"),
|
|
64
|
+
duration: transitionDurationSchema.optional(),
|
|
65
|
+
direction: flipDirectionSchema,
|
|
66
|
+
fallback: rawStandardTransitionSchema
|
|
67
|
+
});
|
|
68
|
+
const rawFlipTransitionSchema = flipTransitionObjectSchema.readonly();
|
|
69
|
+
const morphTransitionObjectSchema = z.strictObject({
|
|
70
|
+
type: z.literal("transition"),
|
|
71
|
+
kind: z.literal("morph"),
|
|
72
|
+
duration: transitionDurationSchema.optional(),
|
|
73
|
+
by: morphBySchema,
|
|
74
|
+
fallback: rawStandardTransitionSchema
|
|
75
|
+
});
|
|
76
|
+
const rawMorphTransitionSchema = morphTransitionObjectSchema.readonly();
|
|
77
|
+
/** Slide, layout, or master transition declaration; build fails when target forbids required mechanisms. */
|
|
78
|
+
const transitionSchema = z.discriminatedUnion("kind", [
|
|
79
|
+
fadeTransitionSchema,
|
|
80
|
+
stripsTransitionSchema,
|
|
81
|
+
pushTransitionSchema,
|
|
82
|
+
rawFlipTransitionSchema,
|
|
83
|
+
rawMorphTransitionSchema
|
|
84
|
+
]);
|
|
85
|
+
fadeTransitionObjectSchema.pick({ duration: true }).readonly();
|
|
86
|
+
stripsTransitionObjectSchema.pick({
|
|
87
|
+
duration: true,
|
|
88
|
+
direction: true
|
|
89
|
+
}).partial({ direction: true }).readonly();
|
|
90
|
+
pushTransitionObjectSchema.pick({
|
|
91
|
+
duration: true,
|
|
92
|
+
from: true
|
|
93
|
+
}).partial({ from: true }).readonly();
|
|
94
|
+
flipTransitionObjectSchema.pick({
|
|
95
|
+
duration: true,
|
|
96
|
+
direction: true,
|
|
97
|
+
fallback: true
|
|
98
|
+
}).partial({ direction: true }).readonly();
|
|
99
|
+
morphTransitionObjectSchema.pick({
|
|
100
|
+
duration: true,
|
|
101
|
+
by: true,
|
|
102
|
+
fallback: true
|
|
103
|
+
}).partial({ by: true }).readonly();
|
|
104
|
+
function declaration(kind, options) {
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
...options,
|
|
107
|
+
type: "transition",
|
|
108
|
+
kind
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** Creates baseline and extended transition values used for slide, layout, and master transition declarations. */
|
|
112
|
+
const transitions = Object.freeze({
|
|
113
|
+
/** Uses baseline fade effect; defaults to slow speed. */
|
|
114
|
+
fade: (options = {}) => declaration("fade", options),
|
|
115
|
+
/** Uses baseline strips effect toward the specified diagonal direction. */
|
|
116
|
+
strips: (options = {}) => declaration("strips", {
|
|
117
|
+
...options,
|
|
118
|
+
direction: options.direction === void 0 ? "rightDown" : options.direction
|
|
119
|
+
}),
|
|
120
|
+
/** Uses baseline push effect entering from the slide edge. */
|
|
121
|
+
push: (options = {}) => declaration("push", {
|
|
122
|
+
...options,
|
|
123
|
+
from: options.from === void 0 ? "bottom" : options.from
|
|
124
|
+
}),
|
|
125
|
+
/** Uses p14 Flip with an explicit baseline fallback for targets that exclude extensions. */
|
|
126
|
+
flip: (options) => declaration("flip", {
|
|
127
|
+
...options,
|
|
128
|
+
direction: options.direction === void 0 ? "right" : options.direction
|
|
129
|
+
}),
|
|
130
|
+
/** Uses p159 Morph with an explicit baseline fallback for targets that exclude extensions. */
|
|
131
|
+
morph: (options) => declaration("morph", {
|
|
132
|
+
...options,
|
|
133
|
+
by: options.by === void 0 ? "object" : options.by
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
export { advanceAfterSchema, fadeTransitionSchema, flipDirectionSchema, morphBySchema, pushTransitionSchema, stripsTransitionSchema, transitionDurationSchema, transitionKindSchema, transitionSchema, transitionSpeedSchema, transitions };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineSlideCodegen, expr } from "../../../codegen/dist/types.js";
|
|
2
|
+
import "../../../codegen/dist/index.js";
|
|
3
|
+
import { advanceAfterSchema, transitionSchema } from "./transition-api.js";
|
|
4
|
+
// ../capabilities/dist/transition/transition-codegen.js
|
|
5
|
+
function serializeTransitionDeclaration(transition, ctx) {
|
|
6
|
+
const transitionsVar = ctx.useImport("transitions");
|
|
7
|
+
const optionEntries = [];
|
|
8
|
+
if (transition.duration !== void 0) optionEntries.push(["duration", transition.duration]);
|
|
9
|
+
switch (transition.kind) {
|
|
10
|
+
case "fade": break;
|
|
11
|
+
case "strips":
|
|
12
|
+
optionEntries.push(["direction", transition.direction]);
|
|
13
|
+
break;
|
|
14
|
+
case "push":
|
|
15
|
+
optionEntries.push(["from", transition.from]);
|
|
16
|
+
break;
|
|
17
|
+
case "flip":
|
|
18
|
+
optionEntries.push(["direction", transition.direction]);
|
|
19
|
+
optionEntries.push(["fallback", serializeTransitionDeclaration(transition.fallback, ctx)]);
|
|
20
|
+
break;
|
|
21
|
+
case "morph":
|
|
22
|
+
optionEntries.push(["by", transition.by]);
|
|
23
|
+
optionEntries.push(["fallback", serializeTransitionDeclaration(transition.fallback, ctx)]);
|
|
24
|
+
break;
|
|
25
|
+
default: return transition;
|
|
26
|
+
}
|
|
27
|
+
const args = optionEntries.length === 0 ? [] : [ctx.formatProps(optionEntries)];
|
|
28
|
+
return expr(ctx.formatVanillaCall(`${transitionsVar}.${transition.kind}`, args));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Source codegen contribution for `transition` and `advanceAfter` slide/layout/master properties.
|
|
32
|
+
*/
|
|
33
|
+
const transitionCodegen = defineSlideCodegen({ slideProps: {
|
|
34
|
+
transition: (value, ctx) => {
|
|
35
|
+
const parsed = transitionSchema.safeParse(value);
|
|
36
|
+
if (!parsed.success) return ctx.fail("unexpressible-value", parsed.error.issues[0]?.message ?? "Transition declaration is invalid");
|
|
37
|
+
return serializeTransitionDeclaration(parsed.data, ctx);
|
|
38
|
+
},
|
|
39
|
+
advanceAfter: (value, ctx) => {
|
|
40
|
+
const parsed = advanceAfterSchema.safeParse(value);
|
|
41
|
+
if (!parsed.success) return ctx.fail("unexpressible-value", parsed.error.issues[0]?.message ?? "Slide.advanceAfter must be a finite millisecond value between 0 and 4294967295");
|
|
42
|
+
return expr(ctx.emitValueExpr(parsed.data));
|
|
43
|
+
}
|
|
44
|
+
} });
|
|
45
|
+
export { transitionCodegen };
|