@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
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createPlaceholderNode, placeholderObjectStyleSchema } from "./placeholder-schemas.js";
|
|
2
|
+
import { contentPlaceholderImportHandler, contentPlaceholderMechanism, placeholderCapability, readContentPlaceholderSp } from "./placeholder.js";
|
|
3
|
+
export { contentPlaceholderImportHandler, contentPlaceholderMechanism, createPlaceholderNode, placeholderCapability, placeholderObjectStyleSchema, readContentPlaceholderSp };
|
package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js
RENAMED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { readInternalDeclarationProps } from "
|
|
2
|
-
import
|
|
3
|
-
import "
|
|
4
|
-
import { defineObjectCodegen } from "../../../codegen/dist/types.js";
|
|
5
|
-
import "../../../core/dist/capability.js";
|
|
1
|
+
import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
|
|
2
|
+
import "../../kernel/capability.js";
|
|
3
|
+
import { defineObjectCodegen } from "../../kernel/codegen.js";
|
|
6
4
|
import { placeholderAllowedPropKeys, placeholderObjectStyleSchema } from "./placeholder-schemas.js";
|
|
7
|
-
// ../
|
|
5
|
+
// ../core/dist/capabilities/placeholder/placeholder-codegen.js
|
|
8
6
|
function isPlainRecord(value) {
|
|
9
7
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
10
8
|
const proto = Object.getPrototypeOf(value);
|
|
11
9
|
return proto === Object.prototype || proto === null;
|
|
12
10
|
}
|
|
13
|
-
function validatePlaceholderNativeRef(value, ctx) {
|
|
14
|
-
const parsed = nativePlaceholderRefSchema.safeParse(value);
|
|
15
|
-
if (!parsed.success) {
|
|
16
|
-
const issue = parsed.error.issues[0];
|
|
17
|
-
ctx.fail("unexpressible-value", issue?.message ?? "Placeholder.nativePlaceholder cannot be expressed", "@nativePlaceholder");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
11
|
function validatePlaceholderStyle(value, ctx) {
|
|
21
12
|
if (!isPlainRecord(value)) ctx.fail("unexpressible-value", "Placeholder.style must be a plain object", "@style");
|
|
22
13
|
const parsed = placeholderObjectStyleSchema.safeParse(value);
|
|
@@ -32,8 +23,7 @@ function collectPlaceholderProps(node, ctx) {
|
|
|
32
23
|
for (const [key, value] of Object.entries(readInternalDeclarationProps(node))) {
|
|
33
24
|
if (value === void 0) continue;
|
|
34
25
|
if (!placeholderAllowedPropKeys.has(key)) ctx.fail("invalid-document", `placeholder declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
35
|
-
if (key === "
|
|
36
|
-
else if (key === "style") validatePlaceholderStyle(value, ctx);
|
|
26
|
+
if (key === "style") validatePlaceholderStyle(value, ctx);
|
|
37
27
|
entries.push([key, value]);
|
|
38
28
|
}
|
|
39
29
|
return entries;
|
package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js
RENAMED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { authorIdSchema } from "
|
|
2
|
-
import { layoutStyleShape } from "
|
|
3
|
-
import { visualStyleShape } from "
|
|
4
|
-
import {
|
|
5
|
-
import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
|
|
6
|
-
import "../../../core/dist/capability.js";
|
|
7
|
-
import { CommonNode } from "../../../core/dist/document.js";
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { visualStyleShape } from "../../kernel/theme.js";
|
|
4
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
8
5
|
import { optionalNameSchema } from "../shared/identity.js";
|
|
9
6
|
import { morphKeySchema } from "../shared/morph-api.js";
|
|
7
|
+
import "../../kernel/capability.js";
|
|
8
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
10
9
|
import { z } from "zod";
|
|
11
|
-
// ../
|
|
10
|
+
// ../core/dist/capabilities/placeholder/placeholder-schemas.js
|
|
12
11
|
const placeholderObjectStyleObjectSchema = z.strictObject({
|
|
13
12
|
...layoutStyleShape,
|
|
14
13
|
...visualStyleShape
|
|
@@ -20,7 +19,6 @@ const placeholderDeclarationPropsObjectSchema = z.strictObject({
|
|
|
20
19
|
name: optionalNameSchema.optional(),
|
|
21
20
|
morphKey: morphKeySchema.optional(),
|
|
22
21
|
placeholder: z.string().min(1).optional(),
|
|
23
|
-
nativePlaceholder: nativePlaceholderRefSchema.optional(),
|
|
24
22
|
link: linkTargetSchema.optional(),
|
|
25
23
|
style: placeholderObjectStyleSchema.optional()
|
|
26
24
|
});
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import {
|
|
3
|
-
import { parseLinkTarget } from "
|
|
4
|
-
import { parseCapabilityLayoutContract } from "
|
|
5
|
-
import "../../../core/dist/capability.js";
|
|
6
|
-
import { assertXml10Characters, placeholderRefXml, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
7
|
-
import "../../../emit/dist/index.js";
|
|
8
|
-
import { A_NS, EMU_PER_PX, P_NS, emuToPx } from "../../../import/dist/namespaces.js";
|
|
9
|
-
import { extentEmuFragmentSchema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
|
|
10
|
-
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
11
|
-
import "../../../import/dist/index.js";
|
|
12
|
-
import { createShapeNode, shapeStyleSchema } from "../shape/shape-declaration.js";
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { EMU_PER_PX } from "../../kernel/drawing-units.js";
|
|
3
|
+
import { parseLinkTarget } from "../../kernel/author-schemas.js";
|
|
4
|
+
import { parseCapabilityLayoutContract } from "../../kernel/layout.js";
|
|
13
5
|
import { nativeLinkXml, parseMorphKey, parseOptionalName, readClickLink } from "../shared/identity.js";
|
|
14
6
|
import { directElementChild, emitPlaceholderUnbindDiagnostic, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, stripPlaceholderClearSentinels } from "../shared/placeholder-import.js";
|
|
7
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
8
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
9
|
+
import { readPlaceholderTransform } from "../../kernel/pptx-read/visual.js";
|
|
10
|
+
import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
11
|
+
import { createShapeNode, shapeStyleSchema } from "../shared/shape-declaration.js";
|
|
15
12
|
import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
|
|
16
|
-
import { assertVisualBoxExtent, emitPlaceholderVisualSpPr, readSpPrAppearance, resolveVisualModel } from "../shared/visual.js";
|
|
13
|
+
import { assertVisualBoxExtent, bindVisualModel, emitPlaceholderVisualSpPr, readSpPrAppearance, resolveVisualModel } from "../shared/visual.js";
|
|
14
|
+
import "../../kernel/capability.js";
|
|
15
|
+
import "../../kernel/pptx-read/index.js";
|
|
16
|
+
import { assertXml10Characters, placeholderRefXml, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
17
17
|
import { placeholderCodegen } from "./placeholder-codegen.js";
|
|
18
18
|
import { createPlaceholderNode, placeholderAllowedPropKeys, placeholderObjectStyleSchema, placeholderStyleKeys } from "./placeholder-schemas.js";
|
|
19
19
|
import { z } from "zod";
|
|
20
|
-
// ../
|
|
20
|
+
// ../core/dist/capabilities/placeholder/placeholder.js
|
|
21
21
|
const NonVisualSpIdSchema = z.object({
|
|
22
22
|
id: ooxmlNonNegativeIntSchema,
|
|
23
23
|
name: z.string().optional()
|
|
@@ -128,57 +128,7 @@ function readContentPlaceholderSp(context) {
|
|
|
128
128
|
});
|
|
129
129
|
return { diagnostics };
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
let rotate;
|
|
133
|
-
let flipH;
|
|
134
|
-
let flipV;
|
|
135
|
-
let fallbackUnits = {
|
|
136
|
-
w: 0,
|
|
137
|
-
h: 0
|
|
138
|
-
};
|
|
139
|
-
const xfrm = spPr.child(A_NS, "xfrm");
|
|
140
|
-
if (xfrm !== void 0) {
|
|
141
|
-
const hasExplicitFlipH = xfrm.element.hasAttribute("flipH");
|
|
142
|
-
const hasExplicitFlipV = xfrm.element.hasAttribute("flipV");
|
|
143
|
-
const rawXfrm = xfrm.attrsObject([
|
|
144
|
-
"rot",
|
|
145
|
-
"flipH",
|
|
146
|
-
"flipV"
|
|
147
|
-
]);
|
|
148
|
-
const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
|
|
149
|
-
if (parsedXfrm.success) {
|
|
150
|
-
if (parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0) rotate = parsedXfrm.data.rot / 6e4;
|
|
151
|
-
if (hasExplicitFlipH && parsedXfrm.data.flipH !== void 0) flipH = parsedXfrm.data.flipH;
|
|
152
|
-
if (hasExplicitFlipV && parsedXfrm.data.flipV !== void 0) flipV = parsedXfrm.data.flipV;
|
|
153
|
-
}
|
|
154
|
-
const off = xfrm.child(A_NS, "off");
|
|
155
|
-
const ext = xfrm.child(A_NS, "ext");
|
|
156
|
-
if (off !== void 0 && ext !== void 0) {
|
|
157
|
-
const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
|
|
158
|
-
const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
|
|
159
|
-
if (parsedOff.success && parsedExt.success) {
|
|
160
|
-
fallbackUnits = {
|
|
161
|
-
w: parsedExt.data.cx,
|
|
162
|
-
h: parsedExt.data.cy
|
|
163
|
-
};
|
|
164
|
-
localBox = {
|
|
165
|
-
x: emuToPx(parsedOff.data.x),
|
|
166
|
-
y: emuToPx(parsedOff.data.y),
|
|
167
|
-
width: emuToPx(parsedExt.data.cx),
|
|
168
|
-
height: emuToPx(parsedExt.data.cy)
|
|
169
|
-
};
|
|
170
|
-
} else diagnostics.push({
|
|
171
|
-
code: "invalid-xml-value",
|
|
172
|
-
category: "corrupt-input",
|
|
173
|
-
disposition: "recovered",
|
|
174
|
-
location: {
|
|
175
|
-
...phLocation,
|
|
176
|
-
xpath: xfrm.xpath
|
|
177
|
-
},
|
|
178
|
-
attributeOrElement: "a:xfrm"
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
131
|
+
const { offset, extent, rotate, flipH, flipV } = readPlaceholderTransform(spPr.child(A_NS, "xfrm"), phLocation, diagnostics);
|
|
182
132
|
const claim = resolvePlaceholderImportClaim({
|
|
183
133
|
context,
|
|
184
134
|
nativeRef
|
|
@@ -187,18 +137,20 @@ function readContentPlaceholderSp(context) {
|
|
|
187
137
|
const masterPlaceholder = claim.masterPlaceholder;
|
|
188
138
|
const inheritedWidth = (typeof layoutPlaceholder?.style?.width === "number" ? layoutPlaceholder.style.width : void 0) ?? (typeof masterPlaceholder?.style?.width === "number" ? masterPlaceholder.style.width : void 0);
|
|
189
139
|
const inheritedHeight = (typeof layoutPlaceholder?.style?.height === "number" ? layoutPlaceholder.style.height : void 0) ?? (typeof masterPlaceholder?.style?.height === "number" ? masterPlaceholder.style.height : void 0);
|
|
190
|
-
const
|
|
140
|
+
const boxSize = extent ?? (inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
|
|
191
141
|
width: inheritedWidth,
|
|
192
142
|
height: inheritedHeight
|
|
193
|
-
} : void 0;
|
|
194
|
-
const effectiveFallbackUnits =
|
|
195
|
-
w:
|
|
196
|
-
h:
|
|
197
|
-
} :
|
|
143
|
+
} : void 0);
|
|
144
|
+
const effectiveFallbackUnits = boxSize === void 0 ? {
|
|
145
|
+
w: 0,
|
|
146
|
+
h: 0
|
|
147
|
+
} : {
|
|
148
|
+
w: Math.round(boxSize.width * EMU_PER_PX),
|
|
149
|
+
h: Math.round(boxSize.height * EMU_PER_PX)
|
|
150
|
+
};
|
|
198
151
|
const appearance = readSpPrAppearance(spPr, context.package, effectiveFallbackUnits, phLocation, diagnostics, { preservePlaceholderClears: true });
|
|
199
152
|
const { border: rawBorder, ...restVisualStyle } = appearance.style;
|
|
200
153
|
const border = rawBorder;
|
|
201
|
-
const boxSize = localBox ?? inheritedBox;
|
|
202
154
|
let borderRadius;
|
|
203
155
|
if (appearance.geometry === "roundRect") {
|
|
204
156
|
if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
@@ -207,13 +159,12 @@ function readContentPlaceholderSp(context) {
|
|
|
207
159
|
if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
208
160
|
}
|
|
209
161
|
const combinedStyle = {
|
|
210
|
-
...
|
|
162
|
+
...offset === void 0 ? {} : {
|
|
211
163
|
position: "absolute",
|
|
212
|
-
left:
|
|
213
|
-
top:
|
|
214
|
-
width: localBox.width,
|
|
215
|
-
height: localBox.height
|
|
164
|
+
left: offset.x,
|
|
165
|
+
top: offset.y
|
|
216
166
|
},
|
|
167
|
+
...extent,
|
|
217
168
|
...restVisualStyle,
|
|
218
169
|
...border === void 0 ? {} : { border },
|
|
219
170
|
...borderRadius === void 0 ? {} : { borderRadius },
|
|
@@ -224,18 +175,17 @@ function readContentPlaceholderSp(context) {
|
|
|
224
175
|
if (!claim.bound) {
|
|
225
176
|
const resolvedBox = resolveUnboundPlaceholderBox({
|
|
226
177
|
inheritanceContext: claim.inheritanceContext,
|
|
227
|
-
|
|
178
|
+
localBox: {
|
|
179
|
+
...offset,
|
|
180
|
+
...extent
|
|
181
|
+
},
|
|
228
182
|
requireHeight: true
|
|
229
183
|
});
|
|
230
184
|
if (resolvedBox === void 0 || resolvedBox.height === void 0) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
category: "unsupported",
|
|
234
|
-
disposition: "omitted",
|
|
185
|
+
emitPlaceholderUnbindDiagnostic({
|
|
186
|
+
diagnostics,
|
|
235
187
|
location: phLocation,
|
|
236
|
-
|
|
237
|
-
localName: "ph",
|
|
238
|
-
mechanismHint: "orphan-placeholder-without-box"
|
|
188
|
+
retainedAs: "omitted"
|
|
239
189
|
});
|
|
240
190
|
return { diagnostics };
|
|
241
191
|
}
|
|
@@ -296,7 +246,6 @@ function readContentPlaceholderSp(context) {
|
|
|
296
246
|
diagnostics
|
|
297
247
|
};
|
|
298
248
|
}
|
|
299
|
-
const matchedKey = claim.key;
|
|
300
249
|
let validatedStyle;
|
|
301
250
|
if (Object.keys(combinedStyle).length > 0) {
|
|
302
251
|
const parsedStyle = placeholderObjectStyleSchema.safeParse(combinedStyle);
|
|
@@ -304,8 +253,7 @@ function readContentPlaceholderSp(context) {
|
|
|
304
253
|
}
|
|
305
254
|
const node = createPlaceholderNode({
|
|
306
255
|
...objectName === void 0 ? {} : { name: objectName },
|
|
307
|
-
placeholder:
|
|
308
|
-
nativePlaceholder: nativeRef,
|
|
256
|
+
placeholder: claim.key,
|
|
309
257
|
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
310
258
|
...validatedStyle === void 0 ? {} : { style: validatedStyle }
|
|
311
259
|
});
|
|
@@ -343,14 +291,12 @@ const placeholderCapability = {
|
|
|
343
291
|
declaration: "placeholder",
|
|
344
292
|
mechanisms: [contentPlaceholderMechanism],
|
|
345
293
|
codegen: placeholderCodegen,
|
|
346
|
-
bind(input, context) {
|
|
294
|
+
*bind(input, context) {
|
|
347
295
|
const unknown = Object.keys(input.props).find((key) => !placeholderAllowedPropKeys.has(key));
|
|
348
296
|
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Placeholder contains unsupported parameter ${unknown}`);
|
|
349
297
|
if (input.children.length > 0) throw new CapabilityError("unsupported-children", "Unpopulated content placeholder does not accept children");
|
|
350
298
|
const placeholder = context.placeholder;
|
|
351
|
-
|
|
352
|
-
const nativeRef = placeholder?.nativeRef ?? (rawNative.success ? rawNative.data : void 0);
|
|
353
|
-
if (nativeRef === void 0) throw new CapabilityError("missing-placeholder-binding", "Content placeholder requires a bound layout placeholder or nativePlaceholder descriptor");
|
|
299
|
+
if (placeholder === void 0) throw new CapabilityError("missing-placeholder-binding", "Content placeholder requires a bound layout placeholder");
|
|
354
300
|
const requestedName = parseOptionalName(input.props["name"]);
|
|
355
301
|
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
356
302
|
const link = parseLinkTarget(input.props["link"]);
|
|
@@ -362,10 +308,10 @@ const placeholderCapability = {
|
|
|
362
308
|
path: context.path
|
|
363
309
|
});
|
|
364
310
|
const rawSlideStyle = typeof input.props["style"] === "object" && input.props["style"] !== null && !Array.isArray(input.props["style"]) ? input.props["style"] : void 0;
|
|
365
|
-
const inheritedPlaceholderGeometry = placeholder
|
|
366
|
-
const visualStyle =
|
|
367
|
-
|
|
368
|
-
theme: placeholder
|
|
311
|
+
const inheritedPlaceholderGeometry = placeholder.layoutPlaceholder?.geometry ?? placeholder.masterPlaceholder?.geometry;
|
|
312
|
+
const visualStyle = resolvePlaceholderVisualStyle(placeholder, rawSlideStyle);
|
|
313
|
+
const initialVisual = yield* bindVisualModel({
|
|
314
|
+
theme: placeholder.masterTheme,
|
|
369
315
|
style: visualStyle,
|
|
370
316
|
box: {
|
|
371
317
|
x: 0,
|
|
@@ -376,11 +322,8 @@ const placeholderCapability = {
|
|
|
376
322
|
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
|
|
377
323
|
layoutOnlyWhenInvisible: true
|
|
378
324
|
});
|
|
379
|
-
const placeholderGeometry =
|
|
380
|
-
const rawX = placeholderGeometry
|
|
381
|
-
const rawY = placeholderGeometry?.y;
|
|
382
|
-
const rawWidth = placeholderGeometry?.width;
|
|
383
|
-
const rawHeight = placeholderGeometry?.height;
|
|
325
|
+
const placeholderGeometry = resolvePlaceholderGeometry(placeholder, input.props);
|
|
326
|
+
const { x: rawX, y: rawY, width: rawWidth, height: rawHeight } = placeholderGeometry;
|
|
384
327
|
const native = {
|
|
385
328
|
...morphKey === void 0 ? {} : { morphKey },
|
|
386
329
|
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
@@ -396,21 +339,21 @@ const placeholderCapability = {
|
|
|
396
339
|
width: resolveContext.layoutBox?.width ?? (typeof rawWidth === "number" ? rawWidth : 100),
|
|
397
340
|
height: resolveContext.layoutBox?.height ?? (typeof rawHeight === "number" ? rawHeight : 100)
|
|
398
341
|
};
|
|
399
|
-
const name = resolveContext.morphName ?? requestedName ?? placeholder
|
|
342
|
+
const name = resolveContext.morphName ?? requestedName ?? placeholder.layoutPlaceholder?.name ?? `Placeholder ${resolveContext.id - 1}`;
|
|
400
343
|
try {
|
|
401
344
|
assertXml10Characters(name);
|
|
402
345
|
} catch {
|
|
403
|
-
throw new CapabilityError("invalid-xml-character", "Placeholder.name contains characters not allowed in XML 1.0");
|
|
346
|
+
throw new CapabilityError("invalid-xml-character", "Placeholder.name contains characters not allowed in XML 1.0", void 0, { field: "name" });
|
|
404
347
|
}
|
|
405
|
-
const hasBox =
|
|
348
|
+
const hasBox = placeholderGeometry.hasLocalBoxOverride;
|
|
406
349
|
if (hasBox) assertVisualBoxExtent(box);
|
|
407
350
|
const visual = resolveVisualModel({
|
|
408
|
-
theme: placeholder
|
|
351
|
+
theme: placeholder.masterTheme,
|
|
409
352
|
style: visualStyle,
|
|
410
353
|
box,
|
|
411
354
|
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry },
|
|
412
355
|
layoutOnlyWhenInvisible: !hasBox
|
|
413
|
-
});
|
|
356
|
+
}, initialVisual.fill);
|
|
414
357
|
const spPrFlags = {
|
|
415
358
|
hasBox,
|
|
416
359
|
hasRotate: hasLocalDeclaration(rawSlideStyle, "rotate"),
|
|
@@ -425,7 +368,7 @@ const placeholderCapability = {
|
|
|
425
368
|
const model = {
|
|
426
369
|
box,
|
|
427
370
|
name,
|
|
428
|
-
nativeRef,
|
|
371
|
+
nativeRef: placeholder.nativeRef,
|
|
429
372
|
visual,
|
|
430
373
|
spPrFlags
|
|
431
374
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import "../../kernel/geometry-schemas.js";
|
|
2
|
+
import { blockArc, path, preset } from "../shared/geometry.js";
|
|
3
|
+
import { linearGradient, radialGradient } from "../shared/visual.js";
|
|
4
|
+
import "../shared/shape-declaration.js";
|
|
5
|
+
import { customGeometryShapeMechanism, presetShapeMechanism, shapeCapability, shapeStyleKeys } from "./shape.js";
|
|
6
|
+
export { blockArc, customGeometryShapeMechanism, linearGradient, path, preset, presetShapeMechanism, radialGradient, shapeCapability, shapeStyleKeys };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
|
|
2
|
+
import { serializeGeometryProp } from "../shared/geometry-codegen.js";
|
|
3
|
+
import { serializeImageDescriptorValue } from "../shared/image-codegen.js";
|
|
4
|
+
import { motionPropKeySet } from "../shared/motion-schemas.js";
|
|
5
|
+
import { steppableRichTextChildKinds } from "../shared/rich-text-codegen.js";
|
|
6
|
+
import { shapeAllowedPropKeyList, shapeStyleSchema } from "../shared/shape-declaration.js";
|
|
7
|
+
import "../../kernel/capability.js";
|
|
8
|
+
import { defineObjectCodegen, expr } from "../../kernel/codegen.js";
|
|
9
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
10
|
+
// ../core/dist/capabilities/shape/shape-codegen.js
|
|
11
|
+
const objectMotionPropKeys = motionPropKeySet;
|
|
12
|
+
const shapeAllowedPropKeys = new Set(shapeAllowedPropKeyList);
|
|
13
|
+
const shapeAllowedChildKinds = /* @__PURE__ */ new Set([...steppableRichTextChildKinds, "br"]);
|
|
14
|
+
function isRecord(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
function isPlainRecord(value) {
|
|
18
|
+
if (!isRecord(value)) return false;
|
|
19
|
+
const proto = Object.getPrototypeOf(value);
|
|
20
|
+
return proto === Object.prototype || proto === null;
|
|
21
|
+
}
|
|
22
|
+
function singleTextLeaf(node) {
|
|
23
|
+
if (node.children.length !== 1) return void 0;
|
|
24
|
+
const only = node.children[0];
|
|
25
|
+
if (only === void 0 || only instanceof CommonNode) return void 0;
|
|
26
|
+
const leaf = only;
|
|
27
|
+
return leaf.type === "#text" ? leaf.text : void 0;
|
|
28
|
+
}
|
|
29
|
+
function assertAllowedShapeChildren(node, ctx) {
|
|
30
|
+
let childIndex = 0;
|
|
31
|
+
for (const child of node.children) {
|
|
32
|
+
if (!(child instanceof CommonNode)) continue;
|
|
33
|
+
const label = child.id === void 0 ? `${child.type}[${childIndex + 1}]` : `${child.type}[${child.id}]`;
|
|
34
|
+
if (!shapeAllowedChildKinds.has(child.type)) ctx.fail("invalid-document", `shape declaration cannot contain ${JSON.stringify(child.type)} child`, `${ctx.path}/${label}`);
|
|
35
|
+
childIndex += 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function serializeShapeStyleProp(style, ctx) {
|
|
39
|
+
if (!isPlainRecord(style)) ctx.fail("unexpressible-value", "Shape.style must be a plain object", "@style");
|
|
40
|
+
const parsed = shapeStyleSchema.safeParse(style);
|
|
41
|
+
if (!parsed.success) {
|
|
42
|
+
const issue = parsed.error.issues[0];
|
|
43
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
44
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Shape.style cannot be expressed", issuePath);
|
|
45
|
+
}
|
|
46
|
+
const entries = [];
|
|
47
|
+
for (const [key, entryValue] of Object.entries(style)) {
|
|
48
|
+
if (entryValue === void 0) continue;
|
|
49
|
+
if (key === "background") {
|
|
50
|
+
const serializedImage = serializeImageDescriptorValue(entryValue, ctx);
|
|
51
|
+
entries.push([key, serializedImage ?? entryValue]);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
entries.push([key, entryValue]);
|
|
55
|
+
}
|
|
56
|
+
return expr(ctx.formatProps(entries));
|
|
57
|
+
}
|
|
58
|
+
function collectShapeProps(node, ctx) {
|
|
59
|
+
const props = readInternalDeclarationProps(node);
|
|
60
|
+
const extra = ctx.emitObjectExtraProps(props);
|
|
61
|
+
const entries = [];
|
|
62
|
+
for (const [key, value] of Object.entries(props)) {
|
|
63
|
+
if (value === void 0) continue;
|
|
64
|
+
if (!shapeAllowedPropKeys.has(key)) ctx.fail("invalid-document", `shape declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
65
|
+
if (objectMotionPropKeys.has(key)) {
|
|
66
|
+
if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
|
|
67
|
+
else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (key === "geometry") {
|
|
71
|
+
entries.push([key, serializeGeometryProp(value, ctx)]);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (key === "style") {
|
|
75
|
+
entries.push([key, serializeShapeStyleProp(value, ctx)]);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
entries.push([key, value]);
|
|
79
|
+
}
|
|
80
|
+
return entries;
|
|
81
|
+
}
|
|
82
|
+
function emitShapeVanilla(node, ctx) {
|
|
83
|
+
assertAllowedShapeChildren(node, ctx);
|
|
84
|
+
const callee = ctx.useImport("shape");
|
|
85
|
+
const propsEntries = collectShapeProps(node, ctx);
|
|
86
|
+
const leafText = singleTextLeaf(node);
|
|
87
|
+
if (leafText !== void 0) {
|
|
88
|
+
const args = propsEntries.length === 0 ? [JSON.stringify(leafText)] : [JSON.stringify(leafText), ctx.formatProps(propsEntries)];
|
|
89
|
+
return ctx.formatVanillaCall(callee, args);
|
|
90
|
+
}
|
|
91
|
+
if (node.children.length === 0) {
|
|
92
|
+
const args = propsEntries.length === 0 ? [] : [ctx.formatProps(propsEntries)];
|
|
93
|
+
return ctx.formatVanillaCall(callee, args);
|
|
94
|
+
}
|
|
95
|
+
const children = ctx.emitRichTextChildren(node.children);
|
|
96
|
+
const contentArg = ctx.emitValueExpr(children.map((code) => expr(code)));
|
|
97
|
+
const args = propsEntries.length === 0 ? [contentArg] : [contentArg, ctx.formatProps(propsEntries)];
|
|
98
|
+
return ctx.formatVanillaCall(callee, args);
|
|
99
|
+
}
|
|
100
|
+
function emitShapeReact(node, ctx) {
|
|
101
|
+
assertAllowedShapeChildren(node, ctx);
|
|
102
|
+
const tag = ctx.useImport("Shape");
|
|
103
|
+
const propsEntries = collectShapeProps(node, ctx);
|
|
104
|
+
const children = node.children.length === 0 ? [] : ctx.emitRichTextChildren(node.children);
|
|
105
|
+
return ctx.formatJsxElement(tag, propsEntries, children);
|
|
106
|
+
}
|
|
107
|
+
/** Source codegen contribution for `shape` declarations and DrawingML gradient values. */
|
|
108
|
+
const shapeCodegen = defineObjectCodegen({ declarations: { shape: {
|
|
109
|
+
emitVanilla: emitShapeVanilla,
|
|
110
|
+
emitReact: emitShapeReact
|
|
111
|
+
} } });
|
|
112
|
+
export { shapeCodegen };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
2
|
+
import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, readNonVisualCommonProperties } from "../shared/identity.js";
|
|
3
|
+
import { isLineNormalizedSpElement } from "../shared/line-match.js";
|
|
4
|
+
import { isPlaceholderSpElement } from "../shared/placeholder-import.js";
|
|
5
|
+
import { populateRichTextNode, promoteSingleParagraph, readRichTextBody } from "../shared/rich-text-import.js";
|
|
6
|
+
import { createShapeNode } from "../shared/shape-declaration.js";
|
|
7
|
+
import { readSpPrVisuals } from "../shared/visual.js";
|
|
8
|
+
import "../../kernel/pptx-read/index.js";
|
|
9
|
+
// ../core/dist/capabilities/shape/shape-import.js
|
|
10
|
+
function directElementChild(parent, namespaceUri, localName) {
|
|
11
|
+
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
12
|
+
if (child.nodeType !== 1) continue;
|
|
13
|
+
const el = child;
|
|
14
|
+
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isTextBoxSpElement(cursor) {
|
|
18
|
+
const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
|
|
19
|
+
if (nvSpPr === void 0) return false;
|
|
20
|
+
const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
|
|
21
|
+
if (cNvSpPr === void 0) return false;
|
|
22
|
+
const txBox = cNvSpPr.getAttribute("txBox");
|
|
23
|
+
return txBox === "1" || txBox === "true";
|
|
24
|
+
}
|
|
25
|
+
function isCustomGeomSpElement(cursor) {
|
|
26
|
+
const spPr = directElementChild(cursor.element, P_NS, "spPr");
|
|
27
|
+
if (spPr === void 0) return false;
|
|
28
|
+
return directElementChild(spPr, A_NS, "custGeom") !== void 0;
|
|
29
|
+
}
|
|
30
|
+
/** Side-effect-free predicate matching non-textbox preset shapes (`<p:sp>` without `txBox="1"`, `<p:ph>`, `<a:custGeom>`, or normalized 1D lines). */
|
|
31
|
+
function isPresetShapeSpElement(cursor) {
|
|
32
|
+
return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && !isCustomGeomSpElement(cursor) && !isLineNormalizedSpElement(cursor);
|
|
33
|
+
}
|
|
34
|
+
/** Side-effect-free predicate matching non-textbox custom-geometry shapes (`<p:sp>` without `<p:ph>` and with `<a:custGeom>`). */
|
|
35
|
+
function isCustomGeometryShapeSpElement(cursor) {
|
|
36
|
+
return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && isCustomGeomSpElement(cursor);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reads a Transitional `<p:sp>` native shape (preset or custom geometry, fills, borders, effects,
|
|
40
|
+
* transforms, hyperlink, and optional rich text body) into an editable `ShapeNode`.
|
|
41
|
+
*/
|
|
42
|
+
function readShapeSp(context, mapBox) {
|
|
43
|
+
const { cursor, part, slideIndex, package: pkg } = context;
|
|
44
|
+
const diagnostics = [];
|
|
45
|
+
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
46
|
+
if (nvSpPr === void 0) {
|
|
47
|
+
diagnostics.push({
|
|
48
|
+
code: "corrupt-part",
|
|
49
|
+
category: "corrupt-input",
|
|
50
|
+
disposition: "omitted",
|
|
51
|
+
location: {
|
|
52
|
+
part,
|
|
53
|
+
xpath: cursor.xpath,
|
|
54
|
+
slideIndex
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return { diagnostics };
|
|
58
|
+
}
|
|
59
|
+
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
60
|
+
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
61
|
+
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
62
|
+
if (cNvSpPr !== void 0) cNvSpPr.consumeAttr("txBox");
|
|
63
|
+
consumeNonPlaceholderNvPr(nvSpPr);
|
|
64
|
+
const location = {
|
|
65
|
+
part,
|
|
66
|
+
slideIndex,
|
|
67
|
+
...objectId === void 0 ? {} : { objectId },
|
|
68
|
+
...objectName === void 0 ? {} : { objectName }
|
|
69
|
+
};
|
|
70
|
+
const spPr = cursor.child(P_NS, "spPr");
|
|
71
|
+
if (spPr === void 0) {
|
|
72
|
+
diagnostics.push({
|
|
73
|
+
code: "corrupt-part",
|
|
74
|
+
category: "corrupt-input",
|
|
75
|
+
disposition: "omitted",
|
|
76
|
+
location: {
|
|
77
|
+
...location,
|
|
78
|
+
xpath: cursor.xpath
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return { diagnostics };
|
|
82
|
+
}
|
|
83
|
+
const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
|
|
84
|
+
if (visuals === void 0) return { diagnostics };
|
|
85
|
+
const mappedBox = mapBox ? mapBox({
|
|
86
|
+
x: visuals.transform.x,
|
|
87
|
+
y: visuals.transform.y,
|
|
88
|
+
width: visuals.transform.width,
|
|
89
|
+
height: visuals.transform.height
|
|
90
|
+
}) : {
|
|
91
|
+
x: visuals.transform.x,
|
|
92
|
+
y: visuals.transform.y,
|
|
93
|
+
width: visuals.transform.width,
|
|
94
|
+
height: visuals.transform.height
|
|
95
|
+
};
|
|
96
|
+
const txBody = cursor.child(P_NS, "txBody");
|
|
97
|
+
const importedText = txBody === void 0 ? void 0 : readRichTextBody(txBody, location, diagnostics, "shape");
|
|
98
|
+
const paragraphs = importedText?.importedParagraphs ?? [];
|
|
99
|
+
const promoted = promoteSingleParagraph(paragraphs);
|
|
100
|
+
const hasTextBody = promoted === void 0 ? paragraphs.length > 0 : promoted.text === void 0 ? paragraphs[0]?.hasTextDefaults === true : promoted.text !== "";
|
|
101
|
+
const { border: rawBorder, ...restVisualStyle } = visuals.style;
|
|
102
|
+
if (visuals.borderArrows !== void 0) diagnostics.push({
|
|
103
|
+
code: "unsupported-mechanism",
|
|
104
|
+
category: "unsupported",
|
|
105
|
+
disposition: "omitted",
|
|
106
|
+
location,
|
|
107
|
+
namespaceUri: A_NS,
|
|
108
|
+
localName: visuals.borderArrows.startArrow !== void 0 ? "headEnd" : "tailEnd",
|
|
109
|
+
mechanismHint: "shape-line-arrow"
|
|
110
|
+
});
|
|
111
|
+
const effectiveVisualStyle = rawBorder === "none" ? restVisualStyle : visuals.style;
|
|
112
|
+
const shapeStyle = {
|
|
113
|
+
position: "absolute",
|
|
114
|
+
left: mappedBox.x,
|
|
115
|
+
top: mappedBox.y,
|
|
116
|
+
width: mappedBox.width,
|
|
117
|
+
height: mappedBox.height,
|
|
118
|
+
...effectiveVisualStyle,
|
|
119
|
+
...hasTextBody ? importedText?.boxStyle : {},
|
|
120
|
+
...hasTextBody ? promoted?.style : {}
|
|
121
|
+
};
|
|
122
|
+
const props = {
|
|
123
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
124
|
+
...link === void 0 ? {} : { link },
|
|
125
|
+
...visuals.geometry === void 0 ? {} : { geometry: visuals.geometry },
|
|
126
|
+
style: shapeStyle
|
|
127
|
+
};
|
|
128
|
+
const node = createShapeNode(props);
|
|
129
|
+
if (hasTextBody) {
|
|
130
|
+
if (promoted === void 0) populateRichTextNode(node, paragraphs);
|
|
131
|
+
else node.content(promoted.text ?? "");
|
|
132
|
+
}
|
|
133
|
+
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
134
|
+
return {
|
|
135
|
+
node,
|
|
136
|
+
diagnostics
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const presetShapeImportHandler = {
|
|
140
|
+
target: "shape-tree",
|
|
141
|
+
localName: "sp",
|
|
142
|
+
matches: isPresetShapeSpElement,
|
|
143
|
+
read: (context) => readShapeSp(context, context.mapBox),
|
|
144
|
+
groupMember: (cursor) => !(isTextBoxSpElement(cursor) && !isPlaceholderSpElement(cursor)) && !isLineNormalizedSpElement(cursor)
|
|
145
|
+
};
|
|
146
|
+
const customGeometryShapeImportHandler = {
|
|
147
|
+
target: "shape-tree",
|
|
148
|
+
localName: "sp",
|
|
149
|
+
matches: isCustomGeometryShapeSpElement,
|
|
150
|
+
read: (context) => readShapeSp(context, context.mapBox)
|
|
151
|
+
};
|
|
152
|
+
export { customGeometryShapeImportHandler, isCustomGeometryShapeSpElement, isPresetShapeSpElement, presetShapeImportHandler, readShapeSp };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../
|
|
1
|
+
// ../core/dist/capabilities/shape/shape-xml.js
|
|
2
2
|
/** Internal PresentationML wrapper for native shape objects. */
|
|
3
3
|
function shapeXml(id, escapedName, properties, textBody, linkXml) {
|
|
4
4
|
return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr/><p:nvPr/></p:nvSpPr>${properties}${textBody}</p:sp>`;
|