@officedk/pptxdk 0.1.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 +14 -76
- package/dist/build.js +69 -97
- package/dist/cli.js +1 -1
- 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/core/dist/capabilities/box/box-codegen.js +83 -0
- package/dist/core/dist/capabilities/box/box-declaration.js +32 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +32 -29
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +17 -22
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +1025 -471
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +3 -3
- 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 +216 -212
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +228 -171
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +23 -10
- 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 +30 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +160 -89
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +4 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +4 -4
- 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 +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +15 -3
- 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 +5 -5
- 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 +194 -133
- 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/core/dist/capabilities/group/group-codegen.js +73 -0
- package/dist/core/dist/capabilities/group/group-declaration.js +41 -0
- package/dist/core/dist/capabilities/group/group-import.js +608 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +4 -3
- package/dist/core/dist/capabilities/group/group.js +260 -0
- 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/core/dist/capabilities/line/line-codegen.js +88 -0
- package/dist/core/dist/capabilities/line/line-declaration.js +78 -0
- package/dist/core/dist/capabilities/line/line-import.js +424 -0
- package/dist/core/dist/capabilities/line/line-xml.js +9 -0
- package/dist/core/dist/capabilities/line/line.js +329 -0
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/core/dist/capabilities/masters/masters-codegen.js +50 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +35 -47
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +97 -51
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +653 -102
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +317 -163
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +9 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +357 -108
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +5 -7
- 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 +12 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +20 -42
- 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/core/dist/capabilities/placeholder/placeholder-codegen.js +44 -0
- package/dist/core/dist/capabilities/placeholder/placeholder-schemas.js +31 -0
- package/dist/core/dist/capabilities/placeholder/placeholder.js +394 -0
- 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 +100 -103
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/core/dist/capabilities/shared/font/font-embedding.js +118 -0
- package/dist/core/dist/capabilities/shared/font/font-engine.js +855 -0
- package/dist/core/dist/capabilities/shared/font/font-import.js +805 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/core/dist/capabilities/shared/font/font.js +72 -0
- package/dist/{capabilities/dist/shape/shape-codegen.js → core/dist/capabilities/shared/geometry-codegen.js} +4 -69
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +384 -123
- 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 -56
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +49 -61
- 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/core/dist/capabilities/shared/motion-api.js +770 -0
- package/dist/core/dist/capabilities/shared/motion-schemas.js +353 -0
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +313 -168
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/core/dist/capabilities/shared/placeholder-import.js +268 -0
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1221 -188
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/core/dist/capabilities/shared/rich-text-codegen.js +119 -0
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/core/dist/capabilities/shared/shape-declaration.js +45 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +26 -24
- package/dist/core/dist/capabilities/shared/text-declaration.js +31 -0
- package/dist/core/dist/capabilities/shared/text-schemas.js +241 -0
- package/dist/core/dist/capabilities/shared/text-service.js +2563 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +441 -137
- 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 +12 -7
- package/dist/core/dist/capabilities/slide-background/slide-background-xml.js +33 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +61 -50
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/core/dist/capabilities/table/table-codegen.js +118 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +116 -84
- package/dist/core/dist/capabilities/table/table-schemas.js +337 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +13 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +284 -192
- 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 +103 -111
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +13 -16
- 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 +16 -10
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +152 -140
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +27 -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 +173 -90
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/core/dist/import/import.js +547 -0
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +404 -328
- 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} +9 -6
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +105 -127
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +225 -142
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/core/dist/kernel/codegen.js +97 -0
- 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} +3 -2
- package/dist/core/dist/kernel/diagnostics.js +370 -0
- package/dist/core/dist/kernel/document-internals.js +26 -0
- package/dist/core/dist/{document.js → kernel/document.js} +23 -13
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/kernel/font-seal.js +204 -0
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +21 -18
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +177 -72
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/kernel/input-values.js +62 -0
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +5 -10
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +33 -44
- package/dist/core/dist/kernel/layout.js +339 -0
- package/dist/core/dist/kernel/masters.js +171 -0
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/kernel/placeholders.js +289 -0
- 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 +33 -29
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +71 -12
- 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 +6 -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 +182 -41
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +175 -88
- package/dist/core/dist/kernel/pptx-read/xml-fragments.js +320 -0
- 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} +133 -290
- package/dist/core/dist/{query.js → kernel/query.js} +76 -37
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +2 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +797 -409
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/kernel/stage-options.js +312 -0
- package/dist/core/dist/{theme.js → kernel/theme.js} +399 -289
- package/dist/core/dist/kernel/transform-geometry.js +72 -0
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/document-C0lPlH-L.d.ts +1442 -0
- package/dist/index-B9_OUeA-.d.ts +2238 -0
- package/dist/index-BJEzQxWV.d.ts +75 -0
- package/dist/index-DA9flrlR.d.ts +146 -0
- package/dist/index-GSt0t9VO.d.ts +54 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +75 -61
- package/dist/node.d.ts +37 -35
- package/dist/node.js +125 -51
- package/dist/pptxdk/src/cli-commands.js +79 -81
- package/dist/pptxdk/src/compose.js +32 -24
- 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 +229 -77
- package/dist/preview/dist/options.js +17 -26
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +1090 -0
- package/dist/preview.d.ts +6 -3
- package/dist/preview.js +8 -24
- 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/react/dist/author/text-elements.js +64 -0
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +376 -37
- package/dist/react/dist/elements.js +30 -4
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +47 -12
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +26 -26
- package/dist/react.d.ts +174 -50
- package/dist/react.js +31 -27
- package/dist/stages-DYHSHKt4.d.ts +80 -0
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -14
- package/package.json +6 -8
- package/README.md +0 -49
- package/dist/capabilities/dist/all.js +0 -32
- package/dist/capabilities/dist/box/box-codegen.js +0 -51
- package/dist/capabilities/dist/box/box-declaration.js +0 -31
- 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 -148
- package/dist/capabilities/dist/font/font-embedding.js +0 -289
- package/dist/capabilities/dist/font/font-family.js +0 -10
- package/dist/capabilities/dist/font/font-import.js +0 -302
- package/dist/capabilities/dist/font/font.js +0 -25
- package/dist/capabilities/dist/group/group-codegen.js +0 -51
- package/dist/capabilities/dist/group/group-declaration.js +0 -42
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/group/group-import.js +0 -319
- package/dist/capabilities/dist/group/group.js +0 -211
- package/dist/capabilities/dist/image/image-codegen.js +0 -94
- 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 -472
- package/dist/capabilities/dist/masters/masters-codegen.js +0 -21
- package/dist/capabilities/dist/motion/motion-api.js +0 -527
- package/dist/capabilities/dist/motion/motion-schemas.js +0 -216
- 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-codegen.js +0 -23
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -12
- package/dist/capabilities/dist/placeholder/placeholder.js +0 -292
- package/dist/capabilities/dist/shape/shape-declaration.js +0 -57
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -579
- package/dist/capabilities/dist/shared/placeholder-import.js +0 -113
- package/dist/capabilities/dist/shared/style-parse.js +0 -11
- package/dist/capabilities/dist/shared/text-schemas.js +0 -216
- package/dist/capabilities/dist/shared/text-service.js +0 -1883
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +0 -21
- package/dist/capabilities/dist/table/table-codegen.js +0 -81
- package/dist/capabilities/dist/table/table-schemas.js +0 -279
- package/dist/capabilities/dist/text/text-codegen.js +0 -129
- package/dist/capabilities/dist/text/text-declaration.js +0 -19
- package/dist/capabilities/dist/text/text-elements.js +0 -38
- package/dist/capabilities/dist/text/text-import.js +0 -1077
- package/dist/capability-D_xeNVIw.d.ts +0 -29496
- package/dist/codegen/dist/types.js +0 -49
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -13
- package/dist/core/dist/diagnostics.js +0 -21
- package/dist/core/dist/document-internals.js +0 -13
- package/dist/core/dist/input-values.js +0 -45
- package/dist/core/dist/layout.js +0 -299
- package/dist/core/dist/masters.js +0 -169
- package/dist/core/dist/placeholders.js +0 -213
- package/dist/core/dist/stage-options.js +0 -67
- package/dist/document-BHPUODPP.d.ts +0 -27759
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/import.js +0 -504
- package/dist/import/dist/index.js +0 -16
- package/dist/import/dist/xml-fragments.js +0 -36
- package/dist/index-B5m3hqjC.d.ts +0 -7
- package/dist/index-CCy-Yo8G.d.ts +0 -1208
- package/dist/index-DpxcZ4Gs.d.ts +0 -725
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/preview-Cfw0QdMM.d.ts +0 -86
- package/dist/transition-Cips9wma.d.ts +0 -82
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../../core/dist/capability.js";
|
|
3
|
-
import { A_NS, P_NS, TABLE_NS_URI, emuToPx } from "../../../import/dist/namespaces.js";
|
|
4
|
-
import { readDrawingColor, readLineBorder, readTransformXml } from "../../../import/dist/visual.js";
|
|
5
|
-
import "../../../import/dist/index.js";
|
|
1
|
+
import { emuToPx } from "../../kernel/drawing-units.js";
|
|
6
2
|
import { readClickLink } from "../shared/identity.js";
|
|
7
|
-
import {
|
|
3
|
+
import { A_NS, P_NS, TABLE_NS_URI } from "../../kernel/pptx-read/namespaces.js";
|
|
4
|
+
import { readOoxmlBoxInsets } from "../../kernel/pptx-read/xml-fragments.js";
|
|
5
|
+
import { readDrawingColor, readLineBorder } from "../../kernel/pptx-read/visual.js";
|
|
6
|
+
import { emitPlaceholderUnbindDiagnostic, isPlaceholderGraphicFrameElement, readNvPrPlaceholder, readPlaceholderFrameBox, resolvePlaceholderImportClaim } from "../shared/placeholder-import.js";
|
|
7
|
+
import { populateRichTextNode, promoteSingleParagraph, readRichTextBody } from "../shared/rich-text-import.js";
|
|
8
8
|
import "../shared/visual.js";
|
|
9
|
-
import
|
|
9
|
+
import "../../kernel/capability.js";
|
|
10
|
+
import "../../kernel/pptx-read/index.js";
|
|
10
11
|
import { createCellNode, createRowNode, createTableNode } from "./table-declaration.js";
|
|
11
|
-
import { graphicFrameLocksXmlSchema, nonVisualGraphicFrameIdSchema, tblCellPrXmlSchema, tblCellXmlSchema, tblGridColXmlSchema, tblPrXmlSchema, tblRowXmlSchema } from "./table-schemas.js";
|
|
12
|
-
// ../
|
|
12
|
+
import { graphicFrameLocksXmlSchema, nonVisualGraphicFrameIdSchema, tableTextStyleSchema, tblCellPrXmlSchema, tblCellXmlSchema, tblGridColXmlSchema, tblPrXmlSchema, tblRowXmlSchema } from "./table-schemas.js";
|
|
13
|
+
// ../core/dist/capabilities/table/table-import.js
|
|
13
14
|
const anchorToVerticalAlign = {
|
|
14
15
|
t: "top",
|
|
15
16
|
ctr: "middle",
|
|
@@ -49,6 +50,17 @@ function consumeContinuationCell(tcCursor) {
|
|
|
49
50
|
tcCursor.ignoreEmptyChild(A_NS, "tcPr");
|
|
50
51
|
tcCursor.suppressUnconsumed();
|
|
51
52
|
}
|
|
53
|
+
function readCellBorderSide(tcPr, side, cellLocation, diagnostics) {
|
|
54
|
+
const ln = tcPr.child(A_NS, side);
|
|
55
|
+
if (ln === void 0) return void 0;
|
|
56
|
+
const parsed = readLineBorder(ln, cellLocation, diagnostics);
|
|
57
|
+
if (parsed.noFill === true) return "none";
|
|
58
|
+
if (parsed.borderColor !== void 0) return {
|
|
59
|
+
color: parsed.borderColor,
|
|
60
|
+
...parsed.borderWidth === void 0 ? {} : { width: parsed.borderWidth },
|
|
61
|
+
...parsed.borderStyle === void 0 ? {} : { style: parsed.borderStyle }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
52
64
|
function readCellProperties(tcPr, cellLocation, diagnostics) {
|
|
53
65
|
if (tcPr === void 0) return {};
|
|
54
66
|
const rawAttrs = tcPr.attrsObject([
|
|
@@ -62,10 +74,6 @@ function readCellProperties(tcPr, cellLocation, diagnostics) {
|
|
|
62
74
|
"anchorCtr"
|
|
63
75
|
]);
|
|
64
76
|
const parsedAttrs = tblCellPrXmlSchema.safeParse(rawAttrs);
|
|
65
|
-
let paddingTop;
|
|
66
|
-
let paddingRight;
|
|
67
|
-
let paddingBottom;
|
|
68
|
-
let paddingLeft;
|
|
69
77
|
let verticalAlign;
|
|
70
78
|
if (!parsedAttrs.success) diagnostics.push({
|
|
71
79
|
code: "invalid-xml-value",
|
|
@@ -80,10 +88,6 @@ function readCellProperties(tcPr, cellLocation, diagnostics) {
|
|
|
80
88
|
});
|
|
81
89
|
else {
|
|
82
90
|
const attrs = parsedAttrs.data;
|
|
83
|
-
if (attrs.marT !== void 0 && attrs.marT !== 0) paddingTop = emuToPx(attrs.marT);
|
|
84
|
-
if (attrs.marR !== void 0 && attrs.marR !== 0) paddingRight = emuToPx(attrs.marR);
|
|
85
|
-
if (attrs.marB !== void 0 && attrs.marB !== 0) paddingBottom = emuToPx(attrs.marB);
|
|
86
|
-
if (attrs.marL !== void 0 && attrs.marL !== 0) paddingLeft = emuToPx(attrs.marL);
|
|
87
91
|
if (attrs.anchor !== void 0) verticalAlign = anchorToVerticalAlign[attrs.anchor];
|
|
88
92
|
if (attrs.vert !== void 0 && attrs.vert !== "horz") diagnostics.push({
|
|
89
93
|
code: "unsupported-mechanism",
|
|
@@ -98,27 +102,41 @@ function readCellProperties(tcPr, cellLocation, diagnostics) {
|
|
|
98
102
|
mechanismHint: `table-cell-vert:${attrs.vert}`
|
|
99
103
|
});
|
|
100
104
|
}
|
|
105
|
+
const { paddingTop, paddingRight, paddingBottom, paddingLeft } = readOoxmlBoxInsets({
|
|
106
|
+
rawAttrs,
|
|
107
|
+
attrNames: {
|
|
108
|
+
left: "marL",
|
|
109
|
+
top: "marT",
|
|
110
|
+
right: "marR",
|
|
111
|
+
bottom: "marB"
|
|
112
|
+
},
|
|
113
|
+
elementXpath: tcPr.xpath,
|
|
114
|
+
location: cellLocation,
|
|
115
|
+
diagnostics
|
|
116
|
+
});
|
|
117
|
+
const borderLeft = readCellBorderSide(tcPr, "lnL", cellLocation, diagnostics);
|
|
118
|
+
const borderRight = readCellBorderSide(tcPr, "lnR", cellLocation, diagnostics);
|
|
119
|
+
const borderTop = readCellBorderSide(tcPr, "lnT", cellLocation, diagnostics);
|
|
120
|
+
const borderBottom = readCellBorderSide(tcPr, "lnB", cellLocation, diagnostics);
|
|
101
121
|
let border;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const ln = tcPr.child(A_NS, side);
|
|
109
|
-
if (ln === void 0) continue;
|
|
110
|
-
const parsedBorder = readLineBorder(ln, cellLocation, diagnostics);
|
|
111
|
-
if (border === void 0 && parsedBorder.borderColor !== void 0) border = parsedBorder;
|
|
112
|
-
}
|
|
122
|
+
let individualBorders = false;
|
|
123
|
+
if (borderLeft !== void 0 && borderRight !== void 0 && borderTop !== void 0 && borderBottom !== void 0) {
|
|
124
|
+
const leftKey = JSON.stringify(borderLeft);
|
|
125
|
+
if (JSON.stringify(borderRight) === leftKey && JSON.stringify(borderTop) === leftKey && JSON.stringify(borderBottom) === leftKey) border = borderLeft;
|
|
126
|
+
else individualBorders = true;
|
|
127
|
+
} else individualBorders = true;
|
|
113
128
|
tcPr.ignoreEmptyChild(A_NS, "noFill");
|
|
114
|
-
let
|
|
129
|
+
let background;
|
|
115
130
|
const solidFill = tcPr.child(A_NS, "solidFill");
|
|
116
|
-
if (solidFill !== void 0)
|
|
131
|
+
if (solidFill !== void 0) background = readDrawingColor(solidFill, cellLocation, diagnostics);
|
|
117
132
|
return {
|
|
118
|
-
...
|
|
119
|
-
...border
|
|
120
|
-
|
|
121
|
-
|
|
133
|
+
...background === void 0 ? {} : { background },
|
|
134
|
+
...border !== void 0 ? { border } : individualBorders ? {
|
|
135
|
+
...borderLeft === void 0 ? {} : { borderLeft },
|
|
136
|
+
...borderRight === void 0 ? {} : { borderRight },
|
|
137
|
+
...borderTop === void 0 ? {} : { borderTop },
|
|
138
|
+
...borderBottom === void 0 ? {} : { borderBottom }
|
|
139
|
+
} : {},
|
|
122
140
|
...paddingTop === void 0 ? {} : { paddingTop },
|
|
123
141
|
...paddingRight === void 0 ? {} : { paddingRight },
|
|
124
142
|
...paddingBottom === void 0 ? {} : { paddingBottom },
|
|
@@ -126,38 +144,15 @@ function readCellProperties(tcPr, cellLocation, diagnostics) {
|
|
|
126
144
|
...verticalAlign === void 0 ? {} : { verticalAlign }
|
|
127
145
|
};
|
|
128
146
|
}
|
|
129
|
-
function readAnchorCell(tcCursor, colSpan, rowSpan, cellLocation,
|
|
147
|
+
function readAnchorCell(tcCursor, colSpan, rowSpan, cellLocation, diagnostics) {
|
|
130
148
|
const txBody = tcCursor.child(A_NS, "txBody");
|
|
131
149
|
const cellPropsStyle = readCellProperties(tcCursor.child(A_NS, "tcPr"), cellLocation, diagnostics);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (txBody !== void 0) {
|
|
136
|
-
const { importedParagraphs } = readRichTextBody(txBody, part, slideIndex, diagnostics);
|
|
137
|
-
const singleParagraph = importedParagraphs.length === 1 ? importedParagraphs[0] : void 0;
|
|
138
|
-
const hasParagraphLevelStyle = singleParagraph !== void 0 && Object.keys(singleParagraph.style).length > 0;
|
|
139
|
-
const singleTextRun = singleParagraph !== void 0 && !hasParagraphLevelStyle && singleParagraph.runs.length === 1 && singleParagraph.runs[0].kind === "text" ? singleParagraph.runs[0] : void 0;
|
|
140
|
-
const isSingleEmptyParagraph = singleParagraph !== void 0 && !hasParagraphLevelStyle && singleParagraph.runs.length === 0;
|
|
141
|
-
if (singleTextRun !== void 0) {
|
|
142
|
-
const { fontFamily, fontSize, fontWeight, fontStyle, color, letterSpacing, textTransform, textDecoration, textShadow, lang } = singleTextRun.style;
|
|
143
|
-
hoistedRunStyle = {
|
|
144
|
-
...fontFamily === void 0 ? {} : { fontFamily },
|
|
145
|
-
...fontSize === void 0 ? {} : { fontSize },
|
|
146
|
-
...fontWeight === void 0 ? {} : { fontWeight },
|
|
147
|
-
...fontStyle === void 0 ? {} : { fontStyle },
|
|
148
|
-
...color === void 0 ? {} : { color },
|
|
149
|
-
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
150
|
-
...textTransform === void 0 ? {} : { textTransform },
|
|
151
|
-
...textDecoration === void 0 ? {} : { textDecoration },
|
|
152
|
-
...textShadow === void 0 ? {} : { textShadow },
|
|
153
|
-
...lang === void 0 ? {} : { lang }
|
|
154
|
-
};
|
|
155
|
-
singleTextContent = singleTextRun.text;
|
|
156
|
-
} else if (!isSingleEmptyParagraph && importedParagraphs.length > 0) richParagraphs = importedParagraphs;
|
|
157
|
-
}
|
|
150
|
+
const paragraphs = txBody === void 0 ? [] : readRichTextBody(txBody, cellLocation, diagnostics).importedParagraphs;
|
|
151
|
+
const promoted = promoteSingleParagraph(paragraphs);
|
|
152
|
+
const cellTextStyle = promoted === void 0 ? void 0 : tableTextStyleSchema.safeParse(promoted.style);
|
|
158
153
|
const mergedStyle = {
|
|
159
154
|
...cellPropsStyle,
|
|
160
|
-
...
|
|
155
|
+
...cellTextStyle?.success ? cellTextStyle.data : {}
|
|
161
156
|
};
|
|
162
157
|
const cellProps = {
|
|
163
158
|
...colSpan > 1 ? { colSpan } : {},
|
|
@@ -165,8 +160,9 @@ function readAnchorCell(tcCursor, colSpan, rowSpan, cellLocation, part, slideInd
|
|
|
165
160
|
...Object.keys(mergedStyle).length === 0 ? {} : { style: mergedStyle }
|
|
166
161
|
};
|
|
167
162
|
const cellNode = createCellNode(cellProps);
|
|
168
|
-
if (
|
|
169
|
-
|
|
163
|
+
if (cellTextStyle?.success) {
|
|
164
|
+
if (promoted?.text !== void 0) cellNode.content(promoted.text);
|
|
165
|
+
} else if (paragraphs.length > 0) populateRichTextNode(cellNode, paragraphs);
|
|
170
166
|
return cellNode;
|
|
171
167
|
}
|
|
172
168
|
/**
|
|
@@ -174,7 +170,7 @@ function readAnchorCell(tcCursor, colSpan, rowSpan, cellLocation, part, slideInd
|
|
|
174
170
|
* preserving solved column widths, row heights, 2D merge ranges, cell borders/fills/padding, and rich text.
|
|
175
171
|
*/
|
|
176
172
|
function readTableGraphicFrame(context) {
|
|
177
|
-
const { cursor, part, slideIndex
|
|
173
|
+
const { cursor, part, slideIndex } = context;
|
|
178
174
|
const diagnostics = [];
|
|
179
175
|
const nvGraphicFramePr = cursor.child(P_NS, "nvGraphicFramePr");
|
|
180
176
|
if (nvGraphicFramePr === void 0) {
|
|
@@ -249,21 +245,14 @@ function readTableGraphicFrame(context) {
|
|
|
249
245
|
const phResult = readNvPrPlaceholder(nvPr, tableLocation, diagnostics);
|
|
250
246
|
if (phResult.kind === "error") return { diagnostics };
|
|
251
247
|
const nativeRef = phResult.kind === "ok" ? phResult.nativeRef : void 0;
|
|
252
|
-
const
|
|
253
|
-
|
|
254
|
-
|
|
248
|
+
const claim = nativeRef === void 0 ? void 0 : resolvePlaceholderImportClaim({
|
|
249
|
+
context,
|
|
250
|
+
nativeRef,
|
|
251
|
+
objectKind: "table"
|
|
255
252
|
});
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
code: "corrupt-part",
|
|
260
|
-
category: "corrupt-input",
|
|
261
|
-
disposition: "omitted",
|
|
262
|
-
location: tableLocation
|
|
263
|
-
});
|
|
264
|
-
return { diagnostics };
|
|
265
|
-
}
|
|
266
|
-
const transform = readTransformXml(xfrmCursor, tableLocation, diagnostics);
|
|
253
|
+
const matchedKey = claim?.bound === true ? claim.key : void 0;
|
|
254
|
+
const unboundPlaceholder = claim !== void 0 && !claim.bound;
|
|
255
|
+
const transform = readPlaceholderFrameBox(cursor.child("http://schemas.openxmlformats.org/presentationml/2006/main", "xfrm") ?? cursor.child("http://schemas.openxmlformats.org/drawingml/2006/main", "xfrm"), claim, tableLocation, diagnostics);
|
|
267
256
|
if (transform === void 0) return { diagnostics };
|
|
268
257
|
const graphicData = cursor.child(A_NS, "graphic")?.child(A_NS, "graphicData");
|
|
269
258
|
if (graphicData !== void 0) graphicData.consumeAttr("uri");
|
|
@@ -345,6 +334,7 @@ function readTableGraphicFrame(context) {
|
|
|
345
334
|
return { diagnostics };
|
|
346
335
|
}
|
|
347
336
|
const columnWidths = [];
|
|
337
|
+
let totalWidthEmu = 0;
|
|
348
338
|
for (const gridCol of gridCols) {
|
|
349
339
|
const rawCol = gridCol.attrsObject(["w"]);
|
|
350
340
|
const parsedCol = tblGridColXmlSchema.safeParse(rawCol);
|
|
@@ -362,8 +352,23 @@ function readTableGraphicFrame(context) {
|
|
|
362
352
|
});
|
|
363
353
|
return { diagnostics };
|
|
364
354
|
}
|
|
355
|
+
totalWidthEmu += parsedCol.data.w;
|
|
365
356
|
columnWidths.push(emuToPx(parsedCol.data.w));
|
|
366
357
|
}
|
|
358
|
+
if (totalWidthEmu > 2147483647) {
|
|
359
|
+
diagnostics.push({
|
|
360
|
+
code: "invalid-xml-value",
|
|
361
|
+
category: "corrupt-input",
|
|
362
|
+
disposition: "omitted",
|
|
363
|
+
location: {
|
|
364
|
+
...tableLocation,
|
|
365
|
+
xpath: tblGrid.xpath
|
|
366
|
+
},
|
|
367
|
+
attributeOrElement: "a:tblGrid",
|
|
368
|
+
rawValue: String(totalWidthEmu)
|
|
369
|
+
});
|
|
370
|
+
return { diagnostics };
|
|
371
|
+
}
|
|
367
372
|
const trCursors = tbl.children(A_NS, "tr");
|
|
368
373
|
if (trCursors.length === 0) {
|
|
369
374
|
diagnostics.push({
|
|
@@ -378,6 +383,7 @@ function readTableGraphicFrame(context) {
|
|
|
378
383
|
return { diagnostics };
|
|
379
384
|
}
|
|
380
385
|
const rowHeights = [];
|
|
386
|
+
let totalHeightEmu = 0;
|
|
381
387
|
const rawGrid = [];
|
|
382
388
|
for (const trCursor of trCursors) {
|
|
383
389
|
const rawRow = trCursor.attrsObject(["h"]);
|
|
@@ -396,7 +402,22 @@ function readTableGraphicFrame(context) {
|
|
|
396
402
|
});
|
|
397
403
|
return { diagnostics };
|
|
398
404
|
}
|
|
405
|
+
totalHeightEmu += parsedRow.data.h;
|
|
399
406
|
rowHeights.push(emuToPx(parsedRow.data.h));
|
|
407
|
+
if (totalHeightEmu > 2147483647) {
|
|
408
|
+
diagnostics.push({
|
|
409
|
+
code: "invalid-xml-value",
|
|
410
|
+
category: "corrupt-input",
|
|
411
|
+
disposition: "omitted",
|
|
412
|
+
location: {
|
|
413
|
+
...tableLocation,
|
|
414
|
+
xpath: tbl.xpath
|
|
415
|
+
},
|
|
416
|
+
attributeOrElement: "a:tbl",
|
|
417
|
+
rawValue: String(totalHeightEmu)
|
|
418
|
+
});
|
|
419
|
+
return { diagnostics };
|
|
420
|
+
}
|
|
400
421
|
const tcCursors = trCursor.children(A_NS, "tc");
|
|
401
422
|
if (tcCursors.length !== columnWidths.length) {
|
|
402
423
|
diagnostics.push({
|
|
@@ -490,22 +511,33 @@ function readTableGraphicFrame(context) {
|
|
|
490
511
|
for (let rr = r; rr < r + rowSpan; rr += 1) for (let cc = c; cc < c + colSpan; cc += 1) occupied[rr][cc] = true;
|
|
491
512
|
const cellNode = readAnchorCell(rawCell.cursor, colSpan, rowSpan, {
|
|
492
513
|
...tableLocation,
|
|
514
|
+
slideIndex,
|
|
493
515
|
xpath: rawCell.cursor.xpath
|
|
494
|
-
},
|
|
516
|
+
}, diagnostics);
|
|
495
517
|
rowNode.append(cellNode);
|
|
496
518
|
}
|
|
497
519
|
rowNodes.push(rowNode);
|
|
498
520
|
}
|
|
499
521
|
const columns = columnWidths;
|
|
522
|
+
const tableStyle = {
|
|
523
|
+
position: "absolute",
|
|
524
|
+
left: transform.x,
|
|
525
|
+
top: transform.y,
|
|
526
|
+
width: transform.width,
|
|
527
|
+
height: transform.height
|
|
528
|
+
};
|
|
500
529
|
const tableProps = {
|
|
501
530
|
...objectName === void 0 ? {} : { name: objectName },
|
|
502
531
|
...matchedKey === void 0 ? {} : { placeholder: matchedKey },
|
|
503
|
-
...nativeRef === void 0 ? {} : { nativePlaceholder: nativeRef },
|
|
504
532
|
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
columns
|
|
533
|
+
columns,
|
|
534
|
+
style: tableStyle
|
|
508
535
|
};
|
|
536
|
+
if (unboundPlaceholder) emitPlaceholderUnbindDiagnostic({
|
|
537
|
+
diagnostics,
|
|
538
|
+
location: tableLocation,
|
|
539
|
+
retainedAs: "table"
|
|
540
|
+
});
|
|
509
541
|
const tableNode = createTableNode(tableProps);
|
|
510
542
|
tableNode.append(...rowNodes);
|
|
511
543
|
if (clickResult?.deferredSlideLink !== void 0 && context.registerDeferredSlideLink !== void 0) {
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
4
|
+
import { backgroundValueSchema, borderValueSchema, textStyleShape, validateTextStyle } from "../../kernel/theme.js";
|
|
5
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
6
|
+
import { optionalNameSchema } from "../shared/identity.js";
|
|
7
|
+
import { morphKeySchema } from "../shared/morph-api.js";
|
|
8
|
+
import { motionPropsShape } from "../shared/motion-schemas.js";
|
|
9
|
+
import { parseTextInsets, textCoordinateSchema, textPaddingValueSchema, textPositiveSizeSchema } from "../shared/text-schemas.js";
|
|
10
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema, ooxmlWritablePositiveExtentEmuSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
11
|
+
import "../../kernel/capability.js";
|
|
12
|
+
import "../../kernel/pptx-read/index.js";
|
|
13
|
+
import "../../kernel/pptx-write/xml.js";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
// ../core/dist/capabilities/table/table-schemas.js
|
|
16
|
+
const frColumnPattern = /^\d+(?:\.\d+)?fr$/u;
|
|
17
|
+
const maximumExtentEmu = 2147483647;
|
|
18
|
+
const tableVerticalAlignSchema = z.enum([
|
|
19
|
+
"top",
|
|
20
|
+
"middle",
|
|
21
|
+
"bottom"
|
|
22
|
+
]);
|
|
23
|
+
const tableColumnPxSchema = z.number().finite().positive();
|
|
24
|
+
const tableColumnFrSchema = z.string().regex(frColumnPattern).refine((value) => Number(value.slice(0, -2)) > 0);
|
|
25
|
+
const rawTableColumnSchema = z.union([
|
|
26
|
+
tableColumnPxSchema,
|
|
27
|
+
tableColumnFrSchema,
|
|
28
|
+
z.literal("auto")
|
|
29
|
+
]);
|
|
30
|
+
/** Column width in px; Nfr allocates from remaining width, auto uses shared font measurement. */
|
|
31
|
+
const tableColumnSchema = rawTableColumnSchema;
|
|
32
|
+
const tableTextStyleObjectSchema = z.strictObject({
|
|
33
|
+
fontFamily: textStyleShape.fontFamily,
|
|
34
|
+
eastAsianFontFamily: textStyleShape.eastAsianFontFamily,
|
|
35
|
+
fontSize: textStyleShape.fontSize,
|
|
36
|
+
fontWeight: textStyleShape.fontWeight,
|
|
37
|
+
fontStyle: textStyleShape.fontStyle,
|
|
38
|
+
color: textStyleShape.color,
|
|
39
|
+
lineHeight: textStyleShape.lineHeight,
|
|
40
|
+
align: textStyleShape.align,
|
|
41
|
+
verticalAlign: textStyleShape.verticalAlign,
|
|
42
|
+
letterSpacing: textStyleShape.letterSpacing,
|
|
43
|
+
textTransform: textStyleShape.textTransform,
|
|
44
|
+
textDecoration: textStyleShape.textDecoration,
|
|
45
|
+
textShadow: textStyleShape.textShadow,
|
|
46
|
+
textStroke: textStyleShape.textStroke,
|
|
47
|
+
lang: textStyleShape.lang
|
|
48
|
+
});
|
|
49
|
+
const tableTextStyleSchema = tableTextStyleObjectSchema.readonly();
|
|
50
|
+
const tableStyleObjectSchema = z.strictObject({
|
|
51
|
+
...tableTextStyleObjectSchema.shape,
|
|
52
|
+
...layoutStyleShape,
|
|
53
|
+
background: backgroundValueSchema.optional(),
|
|
54
|
+
border: borderValueSchema.optional(),
|
|
55
|
+
borderTop: borderValueSchema.optional(),
|
|
56
|
+
borderRight: borderValueSchema.optional(),
|
|
57
|
+
borderBottom: borderValueSchema.optional(),
|
|
58
|
+
borderLeft: borderValueSchema.optional()
|
|
59
|
+
});
|
|
60
|
+
const rawTableStyleSchema = tableStyleObjectSchema.readonly();
|
|
61
|
+
const tableStyleSchema = rawTableStyleSchema;
|
|
62
|
+
const tableRowOwnStyleObjectSchema = z.strictObject({
|
|
63
|
+
/** When unspecified, row height is determined from text measurement of unmerged cells in this row. */
|
|
64
|
+
height: textPositiveSizeSchema.optional(),
|
|
65
|
+
background: backgroundValueSchema.optional(),
|
|
66
|
+
border: borderValueSchema.optional(),
|
|
67
|
+
borderTop: borderValueSchema.optional(),
|
|
68
|
+
borderRight: borderValueSchema.optional(),
|
|
69
|
+
borderBottom: borderValueSchema.optional(),
|
|
70
|
+
borderLeft: borderValueSchema.optional()
|
|
71
|
+
});
|
|
72
|
+
const rawTableRowStyleSchema = z.strictObject({
|
|
73
|
+
...tableTextStyleObjectSchema.shape,
|
|
74
|
+
...tableRowOwnStyleObjectSchema.shape
|
|
75
|
+
}).readonly();
|
|
76
|
+
const tableRowStyleSchema = rawTableRowStyleSchema;
|
|
77
|
+
const tableCellOwnStyleObjectSchema = z.strictObject({
|
|
78
|
+
background: backgroundValueSchema.optional(),
|
|
79
|
+
border: borderValueSchema.optional(),
|
|
80
|
+
borderTop: borderValueSchema.optional(),
|
|
81
|
+
borderRight: borderValueSchema.optional(),
|
|
82
|
+
borderBottom: borderValueSchema.optional(),
|
|
83
|
+
borderLeft: borderValueSchema.optional(),
|
|
84
|
+
padding: textPaddingValueSchema.optional(),
|
|
85
|
+
paddingTop: z.number().finite().nonnegative().optional(),
|
|
86
|
+
paddingRight: z.number().finite().nonnegative().optional(),
|
|
87
|
+
paddingBottom: z.number().finite().nonnegative().optional(),
|
|
88
|
+
paddingLeft: z.number().finite().nonnegative().optional()
|
|
89
|
+
});
|
|
90
|
+
const tableCellStyleObjectSchema = z.strictObject({
|
|
91
|
+
...tableTextStyleObjectSchema.shape,
|
|
92
|
+
...tableCellOwnStyleObjectSchema.shape
|
|
93
|
+
});
|
|
94
|
+
const rawTableCellStyleSchema = tableCellStyleObjectSchema.readonly();
|
|
95
|
+
const tableCellStyleSchema = rawTableCellStyleSchema;
|
|
96
|
+
const tableMergeSpanSchema = z.number().int().min(1);
|
|
97
|
+
const tableDeclarationPropsObjectSchema = z.strictObject({
|
|
98
|
+
id: optionalNameSchema.optional(),
|
|
99
|
+
name: optionalNameSchema.optional(),
|
|
100
|
+
placeholder: z.string().optional(),
|
|
101
|
+
morphKey: morphKeySchema.optional(),
|
|
102
|
+
link: linkTargetSchema.optional(),
|
|
103
|
+
columns: z.array(rawTableColumnSchema).nonempty().readonly(),
|
|
104
|
+
style: rawTableStyleSchema.optional(),
|
|
105
|
+
...motionPropsShape
|
|
106
|
+
});
|
|
107
|
+
tableDeclarationPropsObjectSchema.readonly();
|
|
108
|
+
const rowDeclarationPropsObjectSchema = z.strictObject({
|
|
109
|
+
id: optionalNameSchema.optional(),
|
|
110
|
+
style: rawTableRowStyleSchema.optional()
|
|
111
|
+
});
|
|
112
|
+
rowDeclarationPropsObjectSchema.readonly();
|
|
113
|
+
const cellDeclarationPropsObjectSchema = z.strictObject({
|
|
114
|
+
id: optionalNameSchema.optional(),
|
|
115
|
+
colSpan: tableMergeSpanSchema.optional(),
|
|
116
|
+
rowSpan: tableMergeSpanSchema.optional(),
|
|
117
|
+
style: rawTableCellStyleSchema.optional()
|
|
118
|
+
});
|
|
119
|
+
cellDeclarationPropsObjectSchema.readonly();
|
|
120
|
+
const tableDeclarationAllowedPropKeys = Object.keys(tableDeclarationPropsObjectSchema.shape);
|
|
121
|
+
const tableAllowedParameters = [...tableDeclarationAllowedPropKeys, "children"];
|
|
122
|
+
const rowAllowedParameters = Object.keys(rowDeclarationPropsObjectSchema.shape);
|
|
123
|
+
const cellAllowedParameters = Object.keys(cellDeclarationPropsObjectSchema.shape);
|
|
124
|
+
const tableTextStyleKeys = Object.keys(tableTextStyleObjectSchema.shape);
|
|
125
|
+
const tableStyleKeys = Object.keys(tableStyleObjectSchema.shape);
|
|
126
|
+
const rowStyleKeys = Object.keys(tableRowOwnStyleObjectSchema.shape);
|
|
127
|
+
const cellStyleKeys = Object.keys(tableCellOwnStyleObjectSchema.shape);
|
|
128
|
+
const tableCellAllStyleKeys = Object.keys(tableCellStyleObjectSchema.shape);
|
|
129
|
+
/** OOXML `<p:cNvPr>` attribute fragment schema inside `<p:graphicFrame>`. */
|
|
130
|
+
const nonVisualGraphicFrameIdSchema = z.object({
|
|
131
|
+
id: ooxmlNonNegativeIntSchema,
|
|
132
|
+
name: z.string().optional()
|
|
133
|
+
});
|
|
134
|
+
/** OOXML `<a:graphicFrameLocks>` attribute fragment schema. */
|
|
135
|
+
const graphicFrameLocksXmlSchema = z.object({
|
|
136
|
+
noGrp: ooxmlBoolSchema.optional(),
|
|
137
|
+
noDrilldown: ooxmlBoolSchema.optional(),
|
|
138
|
+
noSelect: ooxmlBoolSchema.optional(),
|
|
139
|
+
noChangeAspect: ooxmlBoolSchema.optional(),
|
|
140
|
+
noMove: ooxmlBoolSchema.optional(),
|
|
141
|
+
noResize: ooxmlBoolSchema.optional()
|
|
142
|
+
});
|
|
143
|
+
/** OOXML `<a:tblPr>` attribute fragment schema. */
|
|
144
|
+
const tblPrXmlSchema = z.object({
|
|
145
|
+
firstRow: ooxmlBoolSchema.optional(),
|
|
146
|
+
firstCol: ooxmlBoolSchema.optional(),
|
|
147
|
+
lastRow: ooxmlBoolSchema.optional(),
|
|
148
|
+
lastCol: ooxmlBoolSchema.optional(),
|
|
149
|
+
bandRow: ooxmlBoolSchema.optional(),
|
|
150
|
+
bandCol: ooxmlBoolSchema.optional(),
|
|
151
|
+
rtl: ooxmlBoolSchema.optional()
|
|
152
|
+
});
|
|
153
|
+
/** OOXML `<a:gridCol w="..."/>` fragment schema bounded to `1 .. 2_147_483_647` EMU. */
|
|
154
|
+
const tblGridColXmlSchema = z.object({ w: ooxmlWritablePositiveExtentEmuSchema });
|
|
155
|
+
/** OOXML `<a:tr h="..."/>` fragment schema bounded to `1 .. 2_147_483_647` EMU. */
|
|
156
|
+
const tblRowXmlSchema = z.object({ h: ooxmlWritablePositiveExtentEmuSchema });
|
|
157
|
+
/** OOXML `<a:tc gridSpan="..." rowSpan="..." hMerge="..." vMerge="..."/>` fragment schema. */
|
|
158
|
+
const tblCellXmlSchema = z.object({
|
|
159
|
+
gridSpan: ooxmlPositiveIntSchema.optional(),
|
|
160
|
+
rowSpan: ooxmlPositiveIntSchema.optional(),
|
|
161
|
+
hMerge: ooxmlBoolSchema.optional(),
|
|
162
|
+
vMerge: ooxmlBoolSchema.optional()
|
|
163
|
+
});
|
|
164
|
+
/** OOXML `<a:tcPr .../>` non-margin attribute fragment schema. */
|
|
165
|
+
const tblCellPrXmlSchema = z.object({
|
|
166
|
+
anchor: z.enum([
|
|
167
|
+
"t",
|
|
168
|
+
"ctr",
|
|
169
|
+
"b"
|
|
170
|
+
]).optional(),
|
|
171
|
+
vert: z.string().optional(),
|
|
172
|
+
horzOverflow: z.string().optional(),
|
|
173
|
+
anchorCtr: ooxmlBoolSchema.optional()
|
|
174
|
+
});
|
|
175
|
+
/** Validates a plain object parameter map against allowed parameter keys. */
|
|
176
|
+
function assertAllowedTableKeys(value, allowed, label, path) {
|
|
177
|
+
const unknown = Object.keys(value).find((key) => !allowed.includes(key));
|
|
178
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `${label} contains unsupported parameter ${unknown}`, path);
|
|
179
|
+
}
|
|
180
|
+
/** Validates an optional non-empty author ID on Row or Cell. */
|
|
181
|
+
function parseOptionalTableId(value, path) {
|
|
182
|
+
if (value === void 0) return void 0;
|
|
183
|
+
const parsed = optionalNameSchema.safeParse(value);
|
|
184
|
+
if (!parsed.success) throw new CapabilityError("invalid-parameter", "id must be a non-empty string", path, { field: "id" });
|
|
185
|
+
return parsed.data;
|
|
186
|
+
}
|
|
187
|
+
/** Validates table coordinate (`x` or `y`) via shared coordinate schema, defaulting omitted to `0`. */
|
|
188
|
+
function parseTableCoordinate(value, label) {
|
|
189
|
+
if (value === void 0) return 0;
|
|
190
|
+
const parsed = textCoordinateSchema.safeParse(value);
|
|
191
|
+
if (!parsed.success) throw new CapabilityError("invalid-table-geometry", `${label} must be a finite pixel number between -1000000 and 1000000`, void 0, { field: label === "x" ? "style.left" : "style.top" });
|
|
192
|
+
return parsed.data;
|
|
193
|
+
}
|
|
194
|
+
/** Validates positive pixel extent (`width` or `Row.style.height`) via shared positive size schema. */
|
|
195
|
+
function parseTablePositiveSize(value, label, path) {
|
|
196
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
197
|
+
if (value === 0 || pxToEmu(value) === 0) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is 0px; ${label} must be greater than 0px`, path, { field: label });
|
|
198
|
+
if (value < 0 || pxToEmu(value) < 1) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, path, { field: label });
|
|
199
|
+
} else throw new CapabilityError("invalid-table-geometry", `${label} must be a finite positive pixel number`, path, { field: label });
|
|
200
|
+
const parsed = textPositiveSizeSchema.safeParse(value);
|
|
201
|
+
if (!parsed.success) throw new CapabilityError("invalid-table-geometry", `${label} exceeds writable table dimension range after conversion`, path, { field: label });
|
|
202
|
+
return parsed.data;
|
|
203
|
+
}
|
|
204
|
+
/** Validates EMU extent bounds for resolved table tracks and borders. */
|
|
205
|
+
function assertTableEmuExtent(value, label, path) {
|
|
206
|
+
const emu = pxToEmu(value);
|
|
207
|
+
if (Number.isFinite(value) && (value === 0 || emu === 0)) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is 0px; ${label} must be greater than 0px`, path, { field: label });
|
|
208
|
+
if (Number.isFinite(value) && (value < 0 || emu < 1)) throw new CapabilityError("invalid-table-geometry", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, path, { field: label });
|
|
209
|
+
if (!Number.isSafeInteger(emu) || emu > maximumExtentEmu) throw new CapabilityError("invalid-table-geometry", `${label} exceeds writable table dimension range after conversion`, path, { field: label });
|
|
210
|
+
return emu;
|
|
211
|
+
}
|
|
212
|
+
/** Validates vertical alignment via Zod schema. */
|
|
213
|
+
function parseTableVerticalAlign(value, path) {
|
|
214
|
+
if (value === void 0) return void 0;
|
|
215
|
+
const parsed = tableVerticalAlignSchema.safeParse(value);
|
|
216
|
+
if (!parsed.success) throw new CapabilityError("invalid-vertical-align", "verticalAlign must be top, middle, or bottom", path);
|
|
217
|
+
return parsed.data;
|
|
218
|
+
}
|
|
219
|
+
/** Validates non-empty `Table.columns` tracks via Zod schema. */
|
|
220
|
+
function parseTableColumns(value) {
|
|
221
|
+
if (!Array.isArray(value) || value.length === 0) throw new CapabilityError("invalid-table-column", "Table.columns must be a non-empty array", void 0, { field: "columns" });
|
|
222
|
+
return value.map((column, index) => {
|
|
223
|
+
const parsed = tableColumnSchema.safeParse(column);
|
|
224
|
+
if (!parsed.success) {
|
|
225
|
+
if (typeof column === "number" && (!Number.isFinite(column) || column <= 0) || typeof column === "string" && frColumnPattern.test(column) && Number(column.slice(0, -2)) <= 0) {
|
|
226
|
+
const kindLabel = typeof column === "number" ? "width" : "fraction";
|
|
227
|
+
throw new CapabilityError("invalid-table-column", `column ${index + 1} ${kindLabel} must be greater than 0`, void 0, { field: `columns.${index}` });
|
|
228
|
+
}
|
|
229
|
+
throw new CapabilityError("invalid-table-column", `Invalid width for column ${index + 1}; use positive px number, positive "Nfr", or "auto"`, void 0, { field: `columns.${index}` });
|
|
230
|
+
}
|
|
231
|
+
if (typeof parsed.data === "number") return {
|
|
232
|
+
kind: "px",
|
|
233
|
+
value: parsed.data
|
|
234
|
+
};
|
|
235
|
+
if (parsed.data === "auto") return { kind: "auto" };
|
|
236
|
+
return {
|
|
237
|
+
kind: "fr",
|
|
238
|
+
value: Number(parsed.data.slice(0, -2))
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
/** Validates `colSpan` or `rowSpan` via Zod schema. */
|
|
243
|
+
function parseTableMergeSpan(value, label, path) {
|
|
244
|
+
if (value === void 0) return 1;
|
|
245
|
+
const parsed = tableMergeSpanSchema.safeParse(value);
|
|
246
|
+
if (!parsed.success) throw new CapabilityError("invalid-table-merge", `${label} must be a positive integer`, path, { field: label });
|
|
247
|
+
return parsed.data;
|
|
248
|
+
}
|
|
249
|
+
/** Validates cell padding declarations by reusing shared `parseTextInsets`. */
|
|
250
|
+
function parseTableCellPadding(style, path) {
|
|
251
|
+
try {
|
|
252
|
+
return parseTextInsets(style);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
if (error instanceof CapabilityError && error.code === "invalid-text-insets") throw new CapabilityError("invalid-table-padding", error.message, path, error.details);
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/** Validates a single unified `BorderValue` (`"none"` or `{ color, width?, style? }`) on Table, Row, or Cell. */
|
|
259
|
+
function parseTableBorderValue(value, label, theme, path) {
|
|
260
|
+
if (value === "none") return void 0;
|
|
261
|
+
const parsed = borderValueSchema.safeParse(value);
|
|
262
|
+
if (!parsed.success || parsed.data === "none") {
|
|
263
|
+
const issue = parsed.success ? void 0 : parsed.error.issues[0];
|
|
264
|
+
throw new CapabilityError("invalid-table-border", issue?.message ?? `${label} must be "none" or { color, width?, style? }`, path, { field: zodIssueField(issue, label) });
|
|
265
|
+
}
|
|
266
|
+
const width = parsed.data.width ?? 1;
|
|
267
|
+
if (width === 0) return void 0;
|
|
268
|
+
assertTableEmuExtent(width, `${label}.width`, path);
|
|
269
|
+
let resolvedColor;
|
|
270
|
+
try {
|
|
271
|
+
resolvedColor = theme.resolveColor(parsed.data.color);
|
|
272
|
+
} catch (error) {
|
|
273
|
+
if (error instanceof CapabilityError) throw new CapabilityError(error.code, `${label}.color: ${error.message}`, path, { field: `${label}.color` });
|
|
274
|
+
throw error;
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
color: resolvedColor,
|
|
278
|
+
width,
|
|
279
|
+
dash: {
|
|
280
|
+
solid: "solid",
|
|
281
|
+
dashed: "dash",
|
|
282
|
+
dotted: "dot"
|
|
283
|
+
}[parsed.data.style ?? "solid"]
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/** Validates optional `align` on Table, Row, or Cell using shared core text style validation. */
|
|
287
|
+
function assertTableTextAlignment(align, path) {
|
|
288
|
+
if (align === void 0) return;
|
|
289
|
+
try {
|
|
290
|
+
validateTextStyle({ align });
|
|
291
|
+
} catch (error) {
|
|
292
|
+
if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, path, error.details);
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const tableBorderSideEntries = [
|
|
297
|
+
["borderTop", "top"],
|
|
298
|
+
["borderRight", "right"],
|
|
299
|
+
["borderBottom", "bottom"],
|
|
300
|
+
["borderLeft", "left"]
|
|
301
|
+
];
|
|
302
|
+
/**
|
|
303
|
+
* Resolves 4-side borders for a Table, Row, or Cell layer by applying `border` shorthand
|
|
304
|
+
* then individual `borderTop`/`borderRight`/`borderBottom`/`borderLeft` overrides over inherited borders.
|
|
305
|
+
*/
|
|
306
|
+
function resolveTableLayerBorders(style, inherited, theme, path) {
|
|
307
|
+
let top = inherited.top;
|
|
308
|
+
let right = inherited.right;
|
|
309
|
+
let bottom = inherited.bottom;
|
|
310
|
+
let left = inherited.left;
|
|
311
|
+
if (Object.hasOwn(style, "border") && style["border"] !== void 0) {
|
|
312
|
+
const baseBorder = parseTableBorderValue(style["border"], "style.border", theme, path);
|
|
313
|
+
top = baseBorder;
|
|
314
|
+
right = baseBorder;
|
|
315
|
+
bottom = baseBorder;
|
|
316
|
+
left = baseBorder;
|
|
317
|
+
}
|
|
318
|
+
for (const [sideKey, sideName] of tableBorderSideEntries) {
|
|
319
|
+
if (!Object.hasOwn(style, sideKey) || style[sideKey] === void 0) continue;
|
|
320
|
+
const sideValue = parseTableBorderValue(style[sideKey], `style.${sideKey}`, theme, path);
|
|
321
|
+
if (sideName === "top") top = sideValue;
|
|
322
|
+
else if (sideName === "right") right = sideValue;
|
|
323
|
+
else if (sideName === "bottom") bottom = sideValue;
|
|
324
|
+
else left = sideValue;
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
...top === void 0 ? {} : { top },
|
|
328
|
+
...right === void 0 ? {} : { right },
|
|
329
|
+
...bottom === void 0 ? {} : { bottom },
|
|
330
|
+
...left === void 0 ? {} : { left }
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** Resolves final 4-side borders for a Cell by cascading Table -> Row -> Cell.border -> Cell.border{Side}. */
|
|
334
|
+
function resolveTableCellBorders(style, inheritedBorders, theme, path) {
|
|
335
|
+
return resolveTableLayerBorders(style, inheritedBorders, theme, path);
|
|
336
|
+
}
|
|
337
|
+
export { assertAllowedTableKeys, assertTableEmuExtent, assertTableTextAlignment, cellAllowedParameters, cellStyleKeys, graphicFrameLocksXmlSchema, nonVisualGraphicFrameIdSchema, parseOptionalTableId, parseTableBorderValue, parseTableCellPadding, parseTableColumns, parseTableCoordinate, parseTableMergeSpan, parseTablePositiveSize, parseTableVerticalAlign, resolveTableCellBorders, resolveTableLayerBorders, rowAllowedParameters, rowStyleKeys, tableAllowedParameters, tableCellAllStyleKeys, tableCellStyleSchema, tableColumnSchema, tableDeclarationAllowedPropKeys, tableMergeSpanSchema, tableRowStyleSchema, tableStyleKeys, tableStyleSchema, tableTextStyleKeys, tableTextStyleSchema, tableVerticalAlignSchema, tblCellPrXmlSchema, tblCellXmlSchema, tblGridColXmlSchema, tblPrXmlSchema, tblRowXmlSchema };
|