@officedk/pptxdk 0.2.0 → 0.2.1
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/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -1,552 +0,0 @@
|
|
|
1
|
-
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
-
import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
|
|
3
|
-
import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
|
|
4
|
-
import "../../../core/dist/capability.js";
|
|
5
|
-
import { assertXml10Characters, pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
6
|
-
import "../../../emit/dist/index.js";
|
|
7
|
-
import "../../../import/dist/index.js";
|
|
8
|
-
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
9
|
-
import { motionAnnotations, pickMotionProps } from "../motion/motion-api.js";
|
|
10
|
-
import { evaluateGeometry } from "../shared/geometry.js";
|
|
11
|
-
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
|
|
12
|
-
import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
|
|
13
|
-
import { emitVisualModel, gradientDefSvg, paintImageFillSvg, resolveVisualModel, visualSvgTransform } from "../shared/visual.js";
|
|
14
|
-
import { imageCodegen } from "./image-codegen.js";
|
|
15
|
-
import "./image-declaration.js";
|
|
16
|
-
import { decodeImageToPngBytes, readImage } from "./image-decode.js";
|
|
17
|
-
import { imageImportHandler, picturePlaceholderImportHandler } from "./image-import.js";
|
|
18
|
-
import { externalImageSourceSchema, imageAllowedParameters, imageAltSchema, imageCoordinateValueSchema, imageCropInputSchema, imageExtentValueSchema, imageFitSchema, imageSourceSchema, imageStyleKeys, imageVisualStyleKeys } from "./image-schemas.js";
|
|
19
|
-
import { imageXml } from "./image-xml.js";
|
|
20
|
-
// ../capabilities/dist/image/image.js
|
|
21
|
-
function roundSvgNumber(value) {
|
|
22
|
-
const rounded = Math.round(value * 1e6) / 1e6;
|
|
23
|
-
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
24
|
-
}
|
|
25
|
-
function borderStrokeAttributes(border) {
|
|
26
|
-
const w = Math.max(1, border.width);
|
|
27
|
-
let dashAttr = "";
|
|
28
|
-
switch (border.style) {
|
|
29
|
-
case "solid":
|
|
30
|
-
dashAttr = "";
|
|
31
|
-
break;
|
|
32
|
-
case "dashed":
|
|
33
|
-
dashAttr = ` stroke-dasharray="${roundSvgNumber(w * 4)} ${roundSvgNumber(w * 3)}"`;
|
|
34
|
-
break;
|
|
35
|
-
case "dotted":
|
|
36
|
-
dashAttr = ` stroke-dasharray="${roundSvgNumber(w)} ${roundSvgNumber(w * 2)}"`;
|
|
37
|
-
break;
|
|
38
|
-
default: return border.style;
|
|
39
|
-
}
|
|
40
|
-
return `stroke="#${border.color.hex}" stroke-opacity="${roundSvgNumber(border.color.alpha ?? 1)}" stroke-width="${roundSvgNumber(border.width)}"${dashAttr}`;
|
|
41
|
-
}
|
|
42
|
-
const imageRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
43
|
-
function emitImageModel(model, emitContext) {
|
|
44
|
-
const omitFill = model.visual.fill.kind === "none" && model.placeholder?.hasLocalFill !== true;
|
|
45
|
-
const properties = emitVisualModel(model.visual, (resource) => emitContext.registerResource(resource), { omitFill });
|
|
46
|
-
const escapedName = xmlEscape(model.name);
|
|
47
|
-
const escapedAlt = model.alt === void 0 ? void 0 : xmlEscape(model.alt);
|
|
48
|
-
let relationshipId;
|
|
49
|
-
try {
|
|
50
|
-
relationshipId = model.image.kind === "external" ? emitContext.registerResource({
|
|
51
|
-
externalTarget: model.image.externalUrl,
|
|
52
|
-
relationshipType: imageRelationshipType
|
|
53
|
-
}) : emitContext.registerResource({
|
|
54
|
-
bytes: model.image.bytes,
|
|
55
|
-
extension: model.image.extension,
|
|
56
|
-
contentType: model.image.contentType,
|
|
57
|
-
relationshipType: imageRelationshipType
|
|
58
|
-
});
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (error instanceof CapabilityError) throw error;
|
|
61
|
-
throw new CapabilityError("image-resource-failure", error instanceof Error ? error.message : String(error));
|
|
62
|
-
}
|
|
63
|
-
const { sourceCrop } = model.placement;
|
|
64
|
-
const serializedCrop = Object.fromEntries([
|
|
65
|
-
["l", sourceCrop.l],
|
|
66
|
-
["t", sourceCrop.t],
|
|
67
|
-
["r", sourceCrop.r],
|
|
68
|
-
["b", sourceCrop.b]
|
|
69
|
-
].filter(([, fraction]) => fraction !== 0));
|
|
70
|
-
return { xml: imageXml(emitContext.id, escapedName, escapedAlt, {
|
|
71
|
-
kind: model.image.kind === "external" ? "link" : "embed",
|
|
72
|
-
relationshipId
|
|
73
|
-
}, model.placement.box, serializedCrop, properties.xml, properties.opacity, nativeLinkXml(emitContext.nativeLink), model.placeholder === void 0 ? void 0 : {
|
|
74
|
-
nativeRef: model.placeholder.nativeRef,
|
|
75
|
-
...model.placeholder.omitSpPrTransform ? { spPrXml: "<p:spPr/>" } : {}
|
|
76
|
-
}) };
|
|
77
|
-
}
|
|
78
|
-
function roundCropFraction(fraction) {
|
|
79
|
-
return Math.round(fraction * 1e5) / 1e5;
|
|
80
|
-
}
|
|
81
|
-
function paintImageModel(model, paintContext) {
|
|
82
|
-
const { image, placement, visual } = model;
|
|
83
|
-
const { box, sourceCrop } = placement;
|
|
84
|
-
const hasFinitePositiveBox = Number.isFinite(box.x) && Number.isFinite(box.y) && Number.isFinite(box.width) && Number.isFinite(box.height) && box.width > 1e-6 && box.height > 1e-6;
|
|
85
|
-
const externalPlaceholders = [...image.kind === "external" ? [{
|
|
86
|
-
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
87
|
-
path: paintContext.path,
|
|
88
|
-
url: image.externalUrl
|
|
89
|
-
}] : [], ...visual.fill.kind === "image" && visual.fill.source.kind === "external" ? [{
|
|
90
|
-
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
91
|
-
path: paintContext.path,
|
|
92
|
-
url: visual.fill.source.externalUrl
|
|
93
|
-
}] : []];
|
|
94
|
-
if (!hasFinitePositiveBox) return {
|
|
95
|
-
svg: "",
|
|
96
|
-
...externalPlaceholders.length === 0 ? {} : { placeholders: externalPlaceholders }
|
|
97
|
-
};
|
|
98
|
-
if (image.kind === "external") {
|
|
99
|
-
const evaluated = evaluateGeometry(visual.geometry, box);
|
|
100
|
-
const placeholderShapes = evaluated.paths.filter((pathItem) => pathItem.fillMode !== "none" && pathItem.d !== "").map((pathItem) => `<path d="${pathItem.d}" fill="#F1F5F9" stroke="#94A3B8" stroke-width="1" stroke-dasharray="4 4"/>`).join("");
|
|
101
|
-
const borderElements = visual.border !== void 0 ? evaluated.paths.filter((pathItem) => pathItem.stroke && pathItem.d !== "").map((pathItem) => `<path d="${pathItem.d}" fill="none" ${borderStrokeAttributes(visual.border)}/>`).join("") : "";
|
|
102
|
-
return {
|
|
103
|
-
svg: `<g transform="${visualSvgTransform(visual)}">${placeholderShapes}${borderElements}</g>`,
|
|
104
|
-
placeholders: [{
|
|
105
|
-
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
106
|
-
path: paintContext.path,
|
|
107
|
-
url: image.externalUrl
|
|
108
|
-
}, ...visual.fill.kind === "image" && visual.fill.source.kind === "external" ? [{
|
|
109
|
-
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
110
|
-
path: paintContext.path,
|
|
111
|
-
url: visual.fill.source.externalUrl
|
|
112
|
-
}] : []]
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
let pngBytes;
|
|
116
|
-
try {
|
|
117
|
-
pngBytes = decodeImageToPngBytes(image);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, error.path, {
|
|
120
|
-
...error.details,
|
|
121
|
-
field: "src"
|
|
122
|
-
});
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
const leftCrop = roundCropFraction(sourceCrop.l);
|
|
126
|
-
const topCrop = roundCropFraction(sourceCrop.t);
|
|
127
|
-
const rightCrop = roundCropFraction(sourceCrop.r);
|
|
128
|
-
const bottomCrop = roundCropFraction(sourceCrop.b);
|
|
129
|
-
const widthFactor = 1 - leftCrop - rightCrop;
|
|
130
|
-
const heightFactor = 1 - topCrop - bottomCrop;
|
|
131
|
-
const prefix = `img-s${paintContext.slideNumber}-o${paintContext.objectId}`;
|
|
132
|
-
const defs = [];
|
|
133
|
-
const evaluated = evaluateGeometry(visual.geometry, box);
|
|
134
|
-
const fillablePaths = evaluated.paths.filter((pathItem) => pathItem.fillMode !== "none" && pathItem.d !== "");
|
|
135
|
-
let backgroundElements = "";
|
|
136
|
-
if (visual.fill.kind !== "none" && fillablePaths.length > 0) {
|
|
137
|
-
let fillAttr = "fill=\"none\"";
|
|
138
|
-
if (visual.fill.kind === "solid") fillAttr = `fill="#${visual.fill.color.hex}" fill-opacity="${roundSvgNumber(visual.fill.color.alpha ?? 1)}"`;
|
|
139
|
-
else if (visual.fill.kind === "linear-gradient" || visual.fill.kind === "radial-gradient") {
|
|
140
|
-
const bgDefId = `${prefix}-bg`;
|
|
141
|
-
defs.push(gradientDefSvg(bgDefId, visual.fill));
|
|
142
|
-
fillAttr = `fill="url(#${bgDefId})"`;
|
|
143
|
-
} else if (visual.fill.kind === "image") {
|
|
144
|
-
const bgDefId = `${prefix}-bg`;
|
|
145
|
-
const patternSvg = paintImageFillSvg(visual.fill, bgDefId, box, paintContext.registerRasterResource);
|
|
146
|
-
if (patternSvg !== "") {
|
|
147
|
-
defs.push(patternSvg);
|
|
148
|
-
fillAttr = `fill="url(#${bgDefId})"`;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
backgroundElements = fillablePaths.map((pathItem) => `<path d="${pathItem.d}" ${fillAttr} stroke="none" stroke-width="0"/>`).join("");
|
|
152
|
-
}
|
|
153
|
-
const opacity = visual.opacity ?? 1;
|
|
154
|
-
let imageElement = "";
|
|
155
|
-
if (widthFactor > 1e-6 && heightFactor > 1e-6 && fillablePaths.length > 0) {
|
|
156
|
-
const imgWidth = box.width / widthFactor;
|
|
157
|
-
const imgHeight = box.height / heightFactor;
|
|
158
|
-
const imgX = box.x - leftCrop * imgWidth;
|
|
159
|
-
const imgY = box.y - topCrop * imgHeight;
|
|
160
|
-
if (Number.isFinite(imgX) && Number.isFinite(imgY) && Number.isFinite(imgWidth) && Number.isFinite(imgHeight) && imgWidth > 1e-6 && imgHeight > 1e-6) {
|
|
161
|
-
const clipId = `${prefix}-clip`;
|
|
162
|
-
const clipMarkup = fillablePaths.map((pathItem) => `<path d="${pathItem.d}"/>`).join("");
|
|
163
|
-
defs.push(`<clipPath id="${clipId}" clipPathUnits="userSpaceOnUse">${clipMarkup}</clipPath>`);
|
|
164
|
-
const opacityAttr = opacity === 1 ? "" : ` opacity="${roundSvgNumber(opacity)}"`;
|
|
165
|
-
const href = paintContext.registerRasterResource !== void 0 ? paintContext.registerRasterResource({
|
|
166
|
-
contentType: "image/png",
|
|
167
|
-
bytes: pngBytes
|
|
168
|
-
}) : `data:image/png;base64,${Buffer.from(pngBytes).toString("base64")}`;
|
|
169
|
-
imageElement = `<image clip-path="url(#${clipId})" x="${roundSvgNumber(imgX)}" y="${roundSvgNumber(imgY)}" width="${roundSvgNumber(imgWidth)}" height="${roundSvgNumber(imgHeight)}" preserveAspectRatio="none"${opacityAttr} href="${href}"/>`;
|
|
170
|
-
if (visual.softEdge !== void 0 && visual.softEdge > 0) {
|
|
171
|
-
const r = visual.softEdge;
|
|
172
|
-
const minSide = Math.min(box.width, box.height);
|
|
173
|
-
const borderPad = visual.border === void 0 ? 0 : visual.border.width;
|
|
174
|
-
const pad = Math.ceil(r * 2 + borderPad + 8);
|
|
175
|
-
const maskX = roundSvgNumber(box.x - pad);
|
|
176
|
-
const maskY = roundSvgNumber(box.y - pad);
|
|
177
|
-
const maskW = roundSvgNumber(box.width + pad * 2);
|
|
178
|
-
const maskH = roundSvgNumber(box.height + pad * 2);
|
|
179
|
-
const blurId = `${prefix}-soft-blur`;
|
|
180
|
-
const maskId = `${prefix}-soft-mask`;
|
|
181
|
-
const innerStrokeWidth = r >= minSide / 2 ? 0 : Math.min(r, minSide * .45);
|
|
182
|
-
const maskAttrs = innerStrokeWidth > 0 ? `fill="white" stroke="black" stroke-width="${roundSvgNumber(innerStrokeWidth)}" filter="url(#${blurId})"` : `fill="white" stroke="none" filter="url(#${blurId})"`;
|
|
183
|
-
const maskShapes = fillablePaths.map((pathItem) => `<path d="${pathItem.d}" ${maskAttrs}/>`).join("");
|
|
184
|
-
defs.push(`<filter id="${blurId}" filterUnits="userSpaceOnUse" x="${maskX}" y="${maskY}" width="${maskW}" height="${maskH}"><feGaussianBlur stdDeviation="${roundSvgNumber(r / 2)}"/></filter>`);
|
|
185
|
-
defs.push(`<mask id="${maskId}" maskUnits="userSpaceOnUse" x="${maskX}" y="${maskY}" width="${maskW}" height="${maskH}">${maskShapes}</mask>`);
|
|
186
|
-
imageElement = `<g mask="url(#${maskId})">${imageElement}</g>`;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
let borderElements = "";
|
|
191
|
-
if (visual.border !== void 0) {
|
|
192
|
-
const strokeAttr = borderStrokeAttributes(visual.border);
|
|
193
|
-
borderElements = evaluated.paths.filter((pathItem) => pathItem.stroke && pathItem.d !== "").map((pathItem) => `<path d="${pathItem.d}" fill="none" ${strokeAttr}/>`).join("");
|
|
194
|
-
}
|
|
195
|
-
let layer = `<g transform="${visualSvgTransform(visual)}">${backgroundElements}${imageElement}${borderElements}</g>`;
|
|
196
|
-
if (visual.boxShadow !== void 0) {
|
|
197
|
-
const shadow = visual.boxShadow;
|
|
198
|
-
const cx = box.x + box.width / 2;
|
|
199
|
-
const cy = box.y + box.height / 2;
|
|
200
|
-
const halfDiag = Math.hypot(box.width, box.height) / 2;
|
|
201
|
-
const rad = shadow.angle * Math.PI / 180;
|
|
202
|
-
const dx = shadow.distance * Math.cos(rad);
|
|
203
|
-
const dy = shadow.distance * Math.sin(rad);
|
|
204
|
-
const sigma = shadow.blur / 2;
|
|
205
|
-
const borderPad = visual.border === void 0 ? 0 : visual.border.width;
|
|
206
|
-
const pad = shadow.blur * 3 + Math.abs(dx) + Math.abs(dy) + borderPad + 16;
|
|
207
|
-
const minX = roundSvgNumber(cx - halfDiag - pad);
|
|
208
|
-
const minY = roundSvgNumber(cy - halfDiag - pad);
|
|
209
|
-
const filterSize = roundSvgNumber((halfDiag + pad) * 2);
|
|
210
|
-
const shadowId = `${prefix}-shadow`;
|
|
211
|
-
defs.push(`<filter id="${shadowId}" filterUnits="userSpaceOnUse" x="${minX}" y="${minY}" width="${filterSize}" height="${filterSize}"><feDropShadow dx="${roundSvgNumber(dx)}" dy="${roundSvgNumber(dy)}" stdDeviation="${roundSvgNumber(sigma)}" flood-color="#${shadow.color.hex}" flood-opacity="${roundSvgNumber(shadow.color.alpha ?? 1)}"/></filter>`);
|
|
212
|
-
layer = `<g filter="url(#${shadowId})">${layer}</g>`;
|
|
213
|
-
}
|
|
214
|
-
return {
|
|
215
|
-
svg: `${defs.length > 0 ? `<defs>${defs.join("")}</defs>` : ""}${layer}`,
|
|
216
|
-
...visual.fill.kind === "image" && visual.fill.source.kind === "external" ? { placeholders: [{
|
|
217
|
-
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
218
|
-
path: paintContext.path,
|
|
219
|
-
url: visual.fill.source.externalUrl
|
|
220
|
-
}] } : {}
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
/** Shared image placement calculation for native OOXML output and static preview. */
|
|
224
|
-
function imagePlacement(image, fit, crop, allocated) {
|
|
225
|
-
const { width, height } = allocated;
|
|
226
|
-
const box = { ...allocated };
|
|
227
|
-
let l = crop?.l ?? 0;
|
|
228
|
-
let t = crop?.t ?? 0;
|
|
229
|
-
let r = crop?.r ?? 0;
|
|
230
|
-
let b = crop?.b ?? 0;
|
|
231
|
-
if (crop === void 0 && image.width !== void 0 && image.height !== void 0) {
|
|
232
|
-
if (fit === "cover") {
|
|
233
|
-
const imageRatio = image.width / image.height;
|
|
234
|
-
const boxRatio = width / height;
|
|
235
|
-
if (imageRatio > boxRatio) {
|
|
236
|
-
const excess = (1 - boxRatio / imageRatio) / 2;
|
|
237
|
-
l = excess;
|
|
238
|
-
r = excess;
|
|
239
|
-
} else if (imageRatio < boxRatio) {
|
|
240
|
-
const excess = (1 - imageRatio / boxRatio) / 2;
|
|
241
|
-
t = excess;
|
|
242
|
-
b = excess;
|
|
243
|
-
}
|
|
244
|
-
} else if (fit === "contain") {
|
|
245
|
-
const imageRatio = image.width / image.height;
|
|
246
|
-
const boxRatio = width / height;
|
|
247
|
-
if (imageRatio > boxRatio) {
|
|
248
|
-
const fittedHeight = width / imageRatio;
|
|
249
|
-
box.y += (height - fittedHeight) / 2;
|
|
250
|
-
box.height = fittedHeight;
|
|
251
|
-
} else if (imageRatio < boxRatio) {
|
|
252
|
-
const fittedWidth = height * imageRatio;
|
|
253
|
-
box.x += (width - fittedWidth) / 2;
|
|
254
|
-
box.width = fittedWidth;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
box.width = dimension(box.width, "width");
|
|
259
|
-
box.height = dimension(box.height, "height");
|
|
260
|
-
return {
|
|
261
|
-
box,
|
|
262
|
-
sourceCrop: {
|
|
263
|
-
l,
|
|
264
|
-
t,
|
|
265
|
-
r,
|
|
266
|
-
b
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
const imageCompatiblePlaceholderRoles = /* @__PURE__ */ new Set([
|
|
271
|
-
"pic",
|
|
272
|
-
"clipArt",
|
|
273
|
-
"obj"
|
|
274
|
-
]);
|
|
275
|
-
const maximumShapeExtentEmu = 2147483647;
|
|
276
|
-
function isRecord(value) {
|
|
277
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
278
|
-
}
|
|
279
|
-
function dimension(value, name, fallback) {
|
|
280
|
-
const actual = value === void 0 ? fallback : value;
|
|
281
|
-
const isExtent = name === "width" || name === "height";
|
|
282
|
-
if (isExtent && typeof actual === "number" && Number.isFinite(actual)) {
|
|
283
|
-
if (actual === 0 || pxToEmu(actual) === 0) throw new CapabilityError("invalid-coordinate", `Computed ${name} is 0px; ${name} must be greater than 0px`);
|
|
284
|
-
if (actual < 0 || pxToEmu(actual) < 1) throw new CapabilityError("invalid-coordinate", `Computed ${name} is ${actual}px; ${name} must be greater than 0px`);
|
|
285
|
-
}
|
|
286
|
-
const parsed = isExtent ? imageExtentValueSchema.safeParse(actual) : imageCoordinateValueSchema.safeParse(actual);
|
|
287
|
-
if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${name} must be a finite pixel number, width and height must be greater than 0, and coordinates must be between -1000000 and 1000000`);
|
|
288
|
-
if (isExtent) {
|
|
289
|
-
const extentEmu = pxToEmu(parsed.data);
|
|
290
|
-
if (extentEmu < 1 || extentEmu > maximumShapeExtentEmu) throw new CapabilityError("invalid-coordinate", `${name} must convert to an EMU value between 1 and ${maximumShapeExtentEmu} inclusive`);
|
|
291
|
-
}
|
|
292
|
-
return parsed.data;
|
|
293
|
-
}
|
|
294
|
-
function parseCropValues(value, path) {
|
|
295
|
-
if (value === void 0) return void 0;
|
|
296
|
-
const parsed = imageCropInputSchema.safeParse(value);
|
|
297
|
-
if (!parsed.success) {
|
|
298
|
-
const issue = parsed.error.issues[0];
|
|
299
|
-
if (issue?.code === "unrecognized_keys") throw new CapabilityError("unknown-parameter", `crop contains unknown parameter ${issue.keys[0]}`, path);
|
|
300
|
-
throw new CapabilityError("invalid-crop", issue?.message ?? "crop must be a four-sided fraction object", path);
|
|
301
|
-
}
|
|
302
|
-
const { left, top, right, bottom } = parsed.data;
|
|
303
|
-
return {
|
|
304
|
-
...left === void 0 ? {} : { l: left },
|
|
305
|
-
...top === void 0 ? {} : { t: top },
|
|
306
|
-
...right === void 0 ? {} : { r: right },
|
|
307
|
-
...bottom === void 0 ? {} : { b: bottom }
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
function readImageSource(source) {
|
|
311
|
-
const parsed = imageSourceSchema.safeParse(source);
|
|
312
|
-
if (!parsed.success) throw new CapabilityError("invalid-image-source", "Image.src must be a file path, file URL, image bytes, or externalUrl descriptor");
|
|
313
|
-
if (typeof parsed.data === "object" && parsed.data !== null && !(parsed.data instanceof Uint8Array) && !(parsed.data instanceof URL)) {
|
|
314
|
-
const externalParsed = externalImageSourceSchema.safeParse(parsed.data);
|
|
315
|
-
if (externalParsed.success) return {
|
|
316
|
-
kind: "external",
|
|
317
|
-
externalUrl: externalParsed.data.externalUrl
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
kind: "embedded",
|
|
322
|
-
...readImage(parsed.data)
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
/** Typed native canvas mechanism connecting emit, paint, and import for `image`. */
|
|
326
|
-
const imageMechanism = defineCanvasMechanism({
|
|
327
|
-
key: "image",
|
|
328
|
-
role: "canvas",
|
|
329
|
-
emit: emitImageModel,
|
|
330
|
-
paint: paintImageModel,
|
|
331
|
-
import: imageImportHandler
|
|
332
|
-
});
|
|
333
|
-
/** Typed native canvas mechanism connecting emit, paint, and import for `picture-placeholder`. */
|
|
334
|
-
const picturePlaceholderMechanism = defineCanvasMechanism({
|
|
335
|
-
key: "picture-placeholder",
|
|
336
|
-
role: "canvas",
|
|
337
|
-
emit: emitImageModel,
|
|
338
|
-
paint: paintImageModel,
|
|
339
|
-
import: picturePlaceholderImportHandler
|
|
340
|
-
});
|
|
341
|
-
/** Image module reads and validates formal resources, encapsulates bound state, and emits native picture objects. */
|
|
342
|
-
const imageCapability = {
|
|
343
|
-
declaration: "image",
|
|
344
|
-
codegen: imageCodegen,
|
|
345
|
-
mechanisms: [imageMechanism, picturePlaceholderMechanism],
|
|
346
|
-
bind(input, context) {
|
|
347
|
-
const placeholder = context.placeholder;
|
|
348
|
-
if (placeholder !== void 0) {
|
|
349
|
-
const role = placeholder.layoutPlaceholder?.type ?? placeholder.nativeRef.type;
|
|
350
|
-
if (!imageCompatiblePlaceholderRoles.has(role)) throw new CapabilityError("incompatible-placeholder-content", `Image cannot be bound to ${role} placeholder`);
|
|
351
|
-
}
|
|
352
|
-
const unknown = Object.keys(input.props).find((key) => !imageAllowedParameters.includes(key));
|
|
353
|
-
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Image contains unsupported parameter ${unknown}`);
|
|
354
|
-
if (input.children.some((child) => "props" in child || child.text.trim() !== "")) throw new CapabilityError("unsupported-children", "Image does not accept children");
|
|
355
|
-
const requestedName = parseOptionalName(input.props["name"]);
|
|
356
|
-
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
357
|
-
const link = parseLinkTarget(input.props["link"]);
|
|
358
|
-
const altParsed = imageAltSchema.safeParse(input.props["alt"]);
|
|
359
|
-
if (!altParsed.success) throw new CapabilityError("invalid-parameter", "alt must be a string");
|
|
360
|
-
const altValue = altParsed.data;
|
|
361
|
-
const allowedStyleKeys = new Set(imageStyleKeys);
|
|
362
|
-
const contract = parseCapabilityLayoutContract({
|
|
363
|
-
nativeKind: "pic",
|
|
364
|
-
props: input.props,
|
|
365
|
-
allowedStyleKeys,
|
|
366
|
-
allowPadding: false,
|
|
367
|
-
path: context.path
|
|
368
|
-
});
|
|
369
|
-
const rawSlideStyle = isRecord(input.props["style"]) ? input.props["style"] : void 0;
|
|
370
|
-
const imageStyle = placeholder !== void 0 ? resolvePlaceholderVisualStyle(placeholder, rawSlideStyle) : rawSlideStyle !== void 0 ? { ...rawSlideStyle } : {};
|
|
371
|
-
const hasLocalFill = hasLocalDeclaration(rawSlideStyle, "background");
|
|
372
|
-
const requestedFit = input.props["fit"];
|
|
373
|
-
let fit = "fill";
|
|
374
|
-
if (requestedFit !== void 0) {
|
|
375
|
-
const parsedFit = imageFitSchema.safeParse(requestedFit);
|
|
376
|
-
if (!parsedFit.success) throw new CapabilityError("unsupported-fit", "fit must be fill, cover, or contain");
|
|
377
|
-
fit = parsedFit.data;
|
|
378
|
-
}
|
|
379
|
-
const crop = parseCropValues(input.props["crop"]);
|
|
380
|
-
const image = readImageSource(input.props["src"]);
|
|
381
|
-
const geometry = input.props["geometry"];
|
|
382
|
-
resolveVisualModel({
|
|
383
|
-
theme: context.theme,
|
|
384
|
-
style: imageStyle,
|
|
385
|
-
box: {
|
|
386
|
-
x: 0,
|
|
387
|
-
y: 0,
|
|
388
|
-
width: 100,
|
|
389
|
-
height: 100
|
|
390
|
-
},
|
|
391
|
-
...geometry !== void 0 ? { geometry } : {},
|
|
392
|
-
image: true
|
|
393
|
-
});
|
|
394
|
-
const placeholderGeometry = placeholder === void 0 ? void 0 : resolvePlaceholderGeometry(placeholder, input.props);
|
|
395
|
-
const hasLocalVisualOverride = geometry !== void 0 || [...imageVisualStyleKeys].some((key) => key !== "opacity" && hasLocalDeclaration(rawSlideStyle, key));
|
|
396
|
-
const declaredX = placeholderGeometry?.x;
|
|
397
|
-
const declaredY = placeholderGeometry?.y;
|
|
398
|
-
const requestedWidth = placeholderGeometry?.width ?? contract.explicitPixelSize?.width;
|
|
399
|
-
const requestedHeight = placeholderGeometry?.height ?? contract.explicitPixelSize?.height;
|
|
400
|
-
const hasFixedWidth = placeholderGeometry?.width !== void 0 && placeholderGeometry.width !== "auto" || (contract.fixedAxes?.width ?? false);
|
|
401
|
-
const hasFixedHeight = placeholderGeometry?.height !== void 0 && placeholderGeometry.height !== "auto" || (contract.fixedAxes?.height ?? false);
|
|
402
|
-
const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
|
|
403
|
-
const motionProps = pickMotionProps(input.props);
|
|
404
|
-
const native = {
|
|
405
|
-
...morphKey === void 0 ? {} : { morphKey },
|
|
406
|
-
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
407
|
-
...link === void 0 ? {} : { link }
|
|
408
|
-
};
|
|
409
|
-
return {
|
|
410
|
-
contract,
|
|
411
|
-
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
412
|
-
measureLayout(request) {
|
|
413
|
-
const declaredWidth = typeof requestedWidth === "number" ? requestedWidth : void 0;
|
|
414
|
-
const declaredHeight = typeof requestedHeight === "number" ? requestedHeight : void 0;
|
|
415
|
-
if (image.kind === "external") {
|
|
416
|
-
if (declaredWidth !== void 0 && declaredHeight !== void 0) return {
|
|
417
|
-
width: declaredWidth,
|
|
418
|
-
height: declaredHeight,
|
|
419
|
-
minContentWidth: hasFixedWidth ? 0 : declaredWidth,
|
|
420
|
-
minContentHeight: hasFixedHeight ? 0 : declaredHeight
|
|
421
|
-
};
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
const width = declaredWidth ?? (declaredHeight !== void 0 ? declaredHeight * image.width / image.height : request.widthMode === "exactly" && request.availableWidth !== void 0 ? request.availableWidth : Math.min(image.width, request.availableWidth ?? image.width));
|
|
425
|
-
const height = declaredHeight ?? width * image.height / image.width;
|
|
426
|
-
const intrinsicMinWidth = declaredHeight !== void 0 ? declaredHeight * image.width / image.height : image.width;
|
|
427
|
-
const intrinsicMinHeight = declaredWidth !== void 0 ? declaredWidth * image.height / image.width : image.height;
|
|
428
|
-
return {
|
|
429
|
-
width,
|
|
430
|
-
height,
|
|
431
|
-
minContentWidth: hasFixedWidth ? 0 : intrinsicMinWidth,
|
|
432
|
-
minContentHeight: hasFixedHeight ? 0 : intrinsicMinHeight
|
|
433
|
-
};
|
|
434
|
-
},
|
|
435
|
-
resolve(resolveContext) {
|
|
436
|
-
const x = dimension(resolveContext.layoutBox?.x ?? declaredX, "x", 0);
|
|
437
|
-
const y = dimension(resolveContext.layoutBox?.y ?? declaredY, "y", 0);
|
|
438
|
-
let width;
|
|
439
|
-
let height;
|
|
440
|
-
if (resolveContext.layoutBox !== void 0) {
|
|
441
|
-
width = dimension(resolveContext.layoutBox.width, "width");
|
|
442
|
-
height = dimension(resolveContext.layoutBox.height, "height");
|
|
443
|
-
} else if (image.kind === "external") {
|
|
444
|
-
width = dimension(requestedWidth, "width");
|
|
445
|
-
height = dimension(requestedHeight, "height");
|
|
446
|
-
} else if (requestedWidth === void 0 && requestedHeight === void 0) {
|
|
447
|
-
width = image.width;
|
|
448
|
-
height = image.height;
|
|
449
|
-
} else if (requestedWidth === void 0) {
|
|
450
|
-
height = dimension(requestedHeight, "height");
|
|
451
|
-
width = height * image.width / image.height;
|
|
452
|
-
} else if (requestedHeight === void 0) {
|
|
453
|
-
width = dimension(requestedWidth, "width");
|
|
454
|
-
height = width * image.height / image.width;
|
|
455
|
-
} else {
|
|
456
|
-
width = dimension(requestedWidth, "width");
|
|
457
|
-
height = dimension(requestedHeight, "height");
|
|
458
|
-
}
|
|
459
|
-
width = dimension(width, "width");
|
|
460
|
-
height = dimension(height, "height");
|
|
461
|
-
const placement = imagePlacement(image.kind === "external" ? {} : image, fit, crop, {
|
|
462
|
-
x,
|
|
463
|
-
y,
|
|
464
|
-
width,
|
|
465
|
-
height
|
|
466
|
-
});
|
|
467
|
-
const { box } = placement;
|
|
468
|
-
const boxChangedByFit = Math.abs(box.x - x) > .01 || Math.abs(box.y - y) > .01 || Math.abs(box.width - width) > .01 || Math.abs(box.height - height) > .01;
|
|
469
|
-
const resolvedVisual = resolveVisualModel({
|
|
470
|
-
theme: resolveContext.theme,
|
|
471
|
-
style: imageStyle,
|
|
472
|
-
box,
|
|
473
|
-
...geometry === void 0 ? {} : { geometry },
|
|
474
|
-
image: true
|
|
475
|
-
});
|
|
476
|
-
const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `Image ${resolveContext.id - 1}`;
|
|
477
|
-
try {
|
|
478
|
-
assertXml10Characters(name);
|
|
479
|
-
if (altValue !== void 0) assertXml10Characters(altValue);
|
|
480
|
-
} catch {
|
|
481
|
-
throw new CapabilityError("invalid-xml-character", "Image.name or alt contains characters not allowed in XML 1.0");
|
|
482
|
-
}
|
|
483
|
-
const angle = resolvedVisual.rotate;
|
|
484
|
-
const annotations = motionAnnotations(motionProps, {
|
|
485
|
-
kind: "image",
|
|
486
|
-
name,
|
|
487
|
-
...authorId === void 0 ? {} : { authorId },
|
|
488
|
-
textBody: false,
|
|
489
|
-
filled: resolvedVisual.fill.kind !== "none",
|
|
490
|
-
box,
|
|
491
|
-
rotationDegrees: angle,
|
|
492
|
-
hasBackground: resolvedVisual.fill.kind !== "none" || resolvedVisual.border !== void 0
|
|
493
|
-
});
|
|
494
|
-
const omitSpPrTransform = placeholder !== void 0 && placeholderGeometry?.hasLocalBoxOverride !== true && !hasLocalVisualOverride && !boxChangedByFit;
|
|
495
|
-
const model = {
|
|
496
|
-
image,
|
|
497
|
-
placement,
|
|
498
|
-
visual: resolvedVisual,
|
|
499
|
-
name,
|
|
500
|
-
...authorId === void 0 ? {} : { authorId },
|
|
501
|
-
...altValue === void 0 ? {} : { alt: altValue },
|
|
502
|
-
...placeholder === void 0 ? {} : { placeholder: {
|
|
503
|
-
nativeRef: placeholder.nativeRef,
|
|
504
|
-
omitSpPrTransform,
|
|
505
|
-
hasLocalFill
|
|
506
|
-
} }
|
|
507
|
-
};
|
|
508
|
-
const mechanism = placeholder === void 0 ? imageMechanism : picturePlaceholderMechanism;
|
|
509
|
-
const imageObservation = image.kind === "external" ? Object.freeze({
|
|
510
|
-
kind: "external",
|
|
511
|
-
...authorId === void 0 ? {} : { id: authorId },
|
|
512
|
-
path: resolveContext.path,
|
|
513
|
-
url: image.externalUrl,
|
|
514
|
-
placeholder: Object.freeze({
|
|
515
|
-
...authorId === void 0 ? {} : { id: authorId },
|
|
516
|
-
path: resolveContext.path,
|
|
517
|
-
url: image.externalUrl
|
|
518
|
-
})
|
|
519
|
-
}) : Object.freeze({
|
|
520
|
-
kind: "embedded",
|
|
521
|
-
contentType: image.contentType,
|
|
522
|
-
width: image.width,
|
|
523
|
-
height: image.height
|
|
524
|
-
});
|
|
525
|
-
return {
|
|
526
|
-
observation: {
|
|
527
|
-
id: resolveContext.id,
|
|
528
|
-
kind: "image",
|
|
529
|
-
name,
|
|
530
|
-
box,
|
|
531
|
-
image: imageObservation
|
|
532
|
-
},
|
|
533
|
-
transform: {
|
|
534
|
-
box,
|
|
535
|
-
angle,
|
|
536
|
-
flipH: resolvedVisual.flipH,
|
|
537
|
-
flipV: resolvedVisual.flipV
|
|
538
|
-
},
|
|
539
|
-
extensions: [],
|
|
540
|
-
...annotations.length === 0 ? {} : { annotations },
|
|
541
|
-
emit(emitContext) {
|
|
542
|
-
return mechanism.emit(model, emitContext);
|
|
543
|
-
},
|
|
544
|
-
paint(paintContext) {
|
|
545
|
-
return mechanism.paint(model, paintContext);
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
export { imageCapability, imageMechanism, picturePlaceholderMechanism };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { hostNodeCreator } from "../../../core/dist/host.js";
|
|
2
|
-
import { motionElement } from "../motion/motion-elements.js";
|
|
3
|
-
import { createLineNode } from "./line-declaration.js";
|
|
4
|
-
// ../capabilities/dist/line/line-elements.js
|
|
5
|
-
/** Declares a native `<p:cxnSp>` line or connector within the React tree. */
|
|
6
|
-
function Line(props) {
|
|
7
|
-
return motionElement("line", {
|
|
8
|
-
...props,
|
|
9
|
-
[hostNodeCreator]: createLineNode
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
export { Line };
|
|
@@ -1,12 +0,0 @@
|
|
|
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 };
|
|
@@ -1,38 +0,0 @@
|
|
|
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 };
|
|
@@ -1,13 +0,0 @@
|
|
|
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 };
|