@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,1077 +0,0 @@
|
|
|
1
|
-
import { assertValidLang, schemeColorNameSchema } from "../../../core/dist/theme.js";
|
|
2
|
-
import { matchLayoutPlaceholderKey, matchMasterPlaceholderSpec, placeholderStyleSchema } from "../../../core/dist/placeholders.js";
|
|
3
|
-
import "../../../core/dist/capability.js";
|
|
4
|
-
import { A_NS, EMU_PER_PX, P_NS, XML_NS, emuToPx } from "../../../import/dist/namespaces.js";
|
|
5
|
-
import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
|
|
6
|
-
import "../../../import/dist/index.js";
|
|
7
|
-
import { readNonVisualCommonProperties } from "../shape/shape-import.js";
|
|
8
|
-
import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, hasPlaceholderElement } from "../shared/identity.js";
|
|
9
|
-
import { directElementChild, directPlaceholderElement, isPlaceholderSpElement, readNvPrPlaceholder } from "../shared/placeholder-import.js";
|
|
10
|
-
import { readSpPrAppearance, readSpPrVisuals } from "../shared/visual.js";
|
|
11
|
-
import { createParagraphNode, createSlideNumberNode, createSpanNode, createTextNode } from "./text-declaration.js";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
// ../capabilities/dist/text/text-import.js
|
|
14
|
-
const NonVisualSpPrFlagsSchema = z.object({ txBox: ooxmlBoolSchema.optional() });
|
|
15
|
-
const BodyPrFragmentSchema = z.object({
|
|
16
|
-
wrap: z.enum(["square", "none"]).optional(),
|
|
17
|
-
rtlCol: ooxmlBoolSchema.optional(),
|
|
18
|
-
lIns: ooxmlNonNegativeIntSchema.optional(),
|
|
19
|
-
tIns: ooxmlNonNegativeIntSchema.optional(),
|
|
20
|
-
rIns: ooxmlNonNegativeIntSchema.optional(),
|
|
21
|
-
bIns: ooxmlNonNegativeIntSchema.optional(),
|
|
22
|
-
anchor: z.enum([
|
|
23
|
-
"t",
|
|
24
|
-
"ctr",
|
|
25
|
-
"b"
|
|
26
|
-
]).optional(),
|
|
27
|
-
anchorCtr: ooxmlBoolSchema.optional(),
|
|
28
|
-
spcFirstLastPara: ooxmlBoolSchema.optional(),
|
|
29
|
-
numCol: z.string().optional(),
|
|
30
|
-
spcCol: z.string().optional()
|
|
31
|
-
});
|
|
32
|
-
const ParagraphPrFragmentSchema = z.object({
|
|
33
|
-
algn: z.enum([
|
|
34
|
-
"l",
|
|
35
|
-
"ctr",
|
|
36
|
-
"r",
|
|
37
|
-
"just"
|
|
38
|
-
]).optional(),
|
|
39
|
-
rtl: ooxmlBoolSchema.optional(),
|
|
40
|
-
lvl: ooxmlNonNegativeIntSchema.refine((value) => value <= 8).optional()
|
|
41
|
-
});
|
|
42
|
-
const SpacingPointsXmlSchema = z.object({ val: ooxmlNonNegativeIntSchema });
|
|
43
|
-
const SpacingPercentXmlSchema = z.object({ val: ooxmlPositiveIntSchema });
|
|
44
|
-
const BulletCharXmlSchema = z.object({ char: z.string().min(1) });
|
|
45
|
-
const AutoNumXmlSchema = z.object({
|
|
46
|
-
type: z.string().min(1),
|
|
47
|
-
startAt: ooxmlPositiveIntSchema.optional()
|
|
48
|
-
});
|
|
49
|
-
const RunPrFragmentSchema = z.object({
|
|
50
|
-
lang: z.string().min(1).optional(),
|
|
51
|
-
sz: ooxmlPositiveIntSchema.optional(),
|
|
52
|
-
b: ooxmlBoolSchema.optional(),
|
|
53
|
-
i: ooxmlBoolSchema.optional(),
|
|
54
|
-
u: z.enum(["none", "sng"]).optional(),
|
|
55
|
-
strike: z.enum(["noStrike", "sngStrike"]).optional(),
|
|
56
|
-
cap: z.enum(["none", "all"]).optional(),
|
|
57
|
-
spc: ooxmlIntSchema.optional(),
|
|
58
|
-
dirty: ooxmlBoolSchema.optional(),
|
|
59
|
-
smtClean: ooxmlBoolSchema.optional()
|
|
60
|
-
});
|
|
61
|
-
const TextFieldXmlSchema = z.object({
|
|
62
|
-
id: z.string().min(1),
|
|
63
|
-
type: z.string().min(1)
|
|
64
|
-
});
|
|
65
|
-
const OuterShadowXmlSchema = z.object({
|
|
66
|
-
blurRad: ooxmlNonNegativeIntSchema.optional(),
|
|
67
|
-
dist: ooxmlNonNegativeIntSchema.optional(),
|
|
68
|
-
dir: ooxmlIntSchema.optional(),
|
|
69
|
-
algn: z.string().optional(),
|
|
70
|
-
rotWithShape: ooxmlBoolSchema.optional()
|
|
71
|
-
});
|
|
72
|
-
const TypefaceFragmentSchema = z.object({
|
|
73
|
-
typeface: z.string().min(1),
|
|
74
|
-
pitchFamily: z.string().optional(),
|
|
75
|
-
charset: z.string().optional(),
|
|
76
|
-
panose: z.string().optional()
|
|
77
|
-
});
|
|
78
|
-
const PercentModifierSchema = z.object({ val: ooxmlNonNegativeIntSchema });
|
|
79
|
-
const SrgbColorSchema = z.object({ val: hexRgb6Schema });
|
|
80
|
-
const SchemeColorSchema = z.object({ val: schemeColorNameSchema });
|
|
81
|
-
const anchorToVerticalAlign = {
|
|
82
|
-
t: "top",
|
|
83
|
-
ctr: "middle",
|
|
84
|
-
b: "bottom"
|
|
85
|
-
};
|
|
86
|
-
const algnToTextAlign = {
|
|
87
|
-
l: "left",
|
|
88
|
-
ctr: "center",
|
|
89
|
-
r: "right",
|
|
90
|
-
just: "justify"
|
|
91
|
-
};
|
|
92
|
-
const textCompatiblePlaceholderRoles = /* @__PURE__ */ new Set([
|
|
93
|
-
"title",
|
|
94
|
-
"ctrTitle",
|
|
95
|
-
"subTitle",
|
|
96
|
-
"body",
|
|
97
|
-
"hdr",
|
|
98
|
-
"obj"
|
|
99
|
-
]);
|
|
100
|
-
/** Side-effect-free predicate distinguishing `<p:sp>` text boxes (`txBox="1"`) from shapes and placeholders. */
|
|
101
|
-
function isTextBoxSpElement(cursor) {
|
|
102
|
-
if (hasPlaceholderElement(cursor)) return false;
|
|
103
|
-
const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
|
|
104
|
-
if (nvSpPr === void 0) return false;
|
|
105
|
-
const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
|
|
106
|
-
if (cNvSpPr === void 0) return false;
|
|
107
|
-
const txBox = cNvSpPr.getAttribute("txBox");
|
|
108
|
-
return txBox === "1" || txBox === "true";
|
|
109
|
-
}
|
|
110
|
-
/** Side-effect-free predicate matching populated text-compatible `<p:sp>` placeholder elements. */
|
|
111
|
-
function isTextPlaceholderSpElement(cursor) {
|
|
112
|
-
const ph = directPlaceholderElement(cursor, "nvSpPr");
|
|
113
|
-
if (ph === void 0) return false;
|
|
114
|
-
if (directElementChild(cursor.element, "http://schemas.openxmlformats.org/presentationml/2006/main", "txBody") === void 0) return false;
|
|
115
|
-
const rawType = ph.getAttribute("type");
|
|
116
|
-
const role = rawType === null || rawType === "" ? "obj" : rawType;
|
|
117
|
-
return textCompatiblePlaceholderRoles.has(role);
|
|
118
|
-
}
|
|
119
|
-
function readColorModifier(colorCursor, localName) {
|
|
120
|
-
const mod = colorCursor.child(A_NS, localName);
|
|
121
|
-
if (mod === void 0) return void 0;
|
|
122
|
-
const parsed = PercentModifierSchema.safeParse(mod.attrsObject(["val"]));
|
|
123
|
-
return parsed.success ? parsed.data.val / 1e5 : void 0;
|
|
124
|
-
}
|
|
125
|
-
function readColorElement(containerCursor, part, slideIndex, diagnostics) {
|
|
126
|
-
const srgb = containerCursor.child(A_NS, "srgbClr");
|
|
127
|
-
const scheme = srgb === void 0 ? containerCursor.child(A_NS, "schemeClr") : void 0;
|
|
128
|
-
const colorCursor = srgb ?? scheme;
|
|
129
|
-
if (colorCursor === void 0) return void 0;
|
|
130
|
-
let baseString;
|
|
131
|
-
let schemeSlot;
|
|
132
|
-
if (srgb !== void 0) {
|
|
133
|
-
const raw = srgb.attrsObject(["val"]);
|
|
134
|
-
const parsed = SrgbColorSchema.safeParse(raw);
|
|
135
|
-
if (!parsed.success) {
|
|
136
|
-
diagnostics.push({
|
|
137
|
-
code: "invalid-xml-value",
|
|
138
|
-
category: "corrupt-input",
|
|
139
|
-
disposition: "omitted",
|
|
140
|
-
location: {
|
|
141
|
-
part,
|
|
142
|
-
xpath: srgb.xpath,
|
|
143
|
-
slideIndex
|
|
144
|
-
},
|
|
145
|
-
attributeOrElement: "a:srgbClr/@val",
|
|
146
|
-
rawValue: raw["val"] ?? ""
|
|
147
|
-
});
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
baseString = `#${parsed.data.val.toUpperCase()}`;
|
|
151
|
-
} else if (scheme !== void 0) {
|
|
152
|
-
const raw = scheme.attrsObject(["val"]);
|
|
153
|
-
const parsed = SchemeColorSchema.safeParse(raw);
|
|
154
|
-
if (!parsed.success) {
|
|
155
|
-
diagnostics.push({
|
|
156
|
-
code: "invalid-xml-value",
|
|
157
|
-
category: "corrupt-input",
|
|
158
|
-
disposition: "omitted",
|
|
159
|
-
location: {
|
|
160
|
-
part,
|
|
161
|
-
xpath: scheme.xpath,
|
|
162
|
-
slideIndex
|
|
163
|
-
},
|
|
164
|
-
attributeOrElement: "a:schemeClr/@val",
|
|
165
|
-
rawValue: raw["val"] ?? ""
|
|
166
|
-
});
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
schemeSlot = parsed.data.val;
|
|
170
|
-
}
|
|
171
|
-
const lumMod = readColorModifier(colorCursor, "lumMod");
|
|
172
|
-
const lumOff = readColorModifier(colorCursor, "lumOff");
|
|
173
|
-
const alpha = readColorModifier(colorCursor, "alpha");
|
|
174
|
-
const baseColor = schemeSlot !== void 0 && lumMod !== void 0 ? {
|
|
175
|
-
slot: schemeSlot,
|
|
176
|
-
lumMod: Math.min(1, lumMod),
|
|
177
|
-
...lumOff === void 0 ? {} : { lumOff: Math.min(1, lumOff) }
|
|
178
|
-
} : schemeSlot ?? baseString;
|
|
179
|
-
if (baseColor === void 0) return void 0;
|
|
180
|
-
if (alpha !== void 0) return {
|
|
181
|
-
color: baseColor,
|
|
182
|
-
alpha: Math.min(1, alpha)
|
|
183
|
-
};
|
|
184
|
-
return baseColor;
|
|
185
|
-
}
|
|
186
|
-
function readOuterShadow(rPrCursor, part, slideIndex, diagnostics) {
|
|
187
|
-
const effectLst = rPrCursor.child(A_NS, "effectLst");
|
|
188
|
-
if (effectLst === void 0) return void 0;
|
|
189
|
-
const outerShdw = effectLst.child(A_NS, "outerShdw");
|
|
190
|
-
if (outerShdw === void 0) return void 0;
|
|
191
|
-
const raw = outerShdw.attrsObject([
|
|
192
|
-
"blurRad",
|
|
193
|
-
"dist",
|
|
194
|
-
"dir",
|
|
195
|
-
"algn",
|
|
196
|
-
"rotWithShape"
|
|
197
|
-
]);
|
|
198
|
-
const parsed = OuterShadowXmlSchema.safeParse(raw);
|
|
199
|
-
if (!parsed.success) {
|
|
200
|
-
diagnostics.push({
|
|
201
|
-
code: "invalid-xml-value",
|
|
202
|
-
category: "corrupt-input",
|
|
203
|
-
disposition: "omitted",
|
|
204
|
-
location: {
|
|
205
|
-
part,
|
|
206
|
-
xpath: outerShdw.xpath,
|
|
207
|
-
slideIndex
|
|
208
|
-
},
|
|
209
|
-
attributeOrElement: "a:outerShdw",
|
|
210
|
-
rawValue: JSON.stringify(raw)
|
|
211
|
-
});
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const color = readColorElement(outerShdw, part, slideIndex, diagnostics);
|
|
215
|
-
const blur = parsed.data.blurRad === void 0 ? void 0 : emuToPx(parsed.data.blurRad);
|
|
216
|
-
const distance = parsed.data.dist === void 0 ? void 0 : emuToPx(parsed.data.dist);
|
|
217
|
-
const angle = parsed.data.dir === void 0 ? void 0 : parsed.data.dir / 6e4;
|
|
218
|
-
return {
|
|
219
|
-
...color === void 0 ? {} : { color },
|
|
220
|
-
...blur === void 0 ? {} : { blur },
|
|
221
|
-
...distance === void 0 ? {} : { distance },
|
|
222
|
-
...angle === void 0 ? {} : { angle }
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function resolveTypefaceToken(typeface) {
|
|
226
|
-
if (typeface === "+mn-lt" || typeface === "+mn-ea" || typeface === "+mn-cs") return "minor";
|
|
227
|
-
if (typeface === "+mj-lt" || typeface === "+mj-ea" || typeface === "+mj-cs") return "major";
|
|
228
|
-
return typeface;
|
|
229
|
-
}
|
|
230
|
-
function readRunProperties(rPrCursor, part, slideIndex, diagnostics) {
|
|
231
|
-
const raw = rPrCursor.attrsObject([
|
|
232
|
-
"lang",
|
|
233
|
-
"sz",
|
|
234
|
-
"b",
|
|
235
|
-
"i",
|
|
236
|
-
"u",
|
|
237
|
-
"strike",
|
|
238
|
-
"cap",
|
|
239
|
-
"spc",
|
|
240
|
-
"dirty",
|
|
241
|
-
"smtClean"
|
|
242
|
-
]);
|
|
243
|
-
const parsed = RunPrFragmentSchema.safeParse(raw);
|
|
244
|
-
let lang;
|
|
245
|
-
let fontSize;
|
|
246
|
-
let sizePt;
|
|
247
|
-
let fontWeight;
|
|
248
|
-
let fontStyle;
|
|
249
|
-
let textDecoration;
|
|
250
|
-
let textTransform;
|
|
251
|
-
let letterSpacing;
|
|
252
|
-
if (!parsed.success) diagnostics.push({
|
|
253
|
-
code: "invalid-xml-value",
|
|
254
|
-
category: "corrupt-input",
|
|
255
|
-
disposition: "recovered",
|
|
256
|
-
location: {
|
|
257
|
-
part,
|
|
258
|
-
xpath: rPrCursor.xpath,
|
|
259
|
-
slideIndex
|
|
260
|
-
},
|
|
261
|
-
attributeOrElement: "a:rPr",
|
|
262
|
-
rawValue: JSON.stringify(raw)
|
|
263
|
-
});
|
|
264
|
-
else {
|
|
265
|
-
const data = parsed.data;
|
|
266
|
-
if (data.lang !== void 0) try {
|
|
267
|
-
lang = assertValidLang(data.lang);
|
|
268
|
-
} catch {
|
|
269
|
-
diagnostics.push({
|
|
270
|
-
code: "invalid-xml-value",
|
|
271
|
-
category: "corrupt-input",
|
|
272
|
-
disposition: "omitted",
|
|
273
|
-
location: {
|
|
274
|
-
part,
|
|
275
|
-
xpath: `${rPrCursor.xpath}/@lang`,
|
|
276
|
-
slideIndex
|
|
277
|
-
},
|
|
278
|
-
attributeOrElement: "@lang",
|
|
279
|
-
rawValue: data.lang
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
if (data.sz !== void 0) {
|
|
283
|
-
sizePt = data.sz / 100;
|
|
284
|
-
fontSize = `${sizePt}pt`;
|
|
285
|
-
}
|
|
286
|
-
if (data.b !== void 0) fontWeight = data.b ? "bold" : "normal";
|
|
287
|
-
if (data.i !== void 0) fontStyle = data.i ? "italic" : "normal";
|
|
288
|
-
if (data.u === "sng") textDecoration = "underline";
|
|
289
|
-
else if (data.strike === "sngStrike") textDecoration = "line-through";
|
|
290
|
-
else if (data.u === "none" && data.strike === "noStrike") textDecoration = "none";
|
|
291
|
-
if (data.cap === "all") textTransform = "uppercase";
|
|
292
|
-
else if (data.cap === "none") textTransform = "none";
|
|
293
|
-
if (data.spc !== void 0) letterSpacing = data.spc / 75;
|
|
294
|
-
}
|
|
295
|
-
let color;
|
|
296
|
-
const solidFill = rPrCursor.child(A_NS, "solidFill");
|
|
297
|
-
if (solidFill !== void 0) color = readColorElement(solidFill, part, slideIndex, diagnostics);
|
|
298
|
-
const textShadow = readOuterShadow(rPrCursor, part, slideIndex, diagnostics);
|
|
299
|
-
let fontFamily;
|
|
300
|
-
const latin = rPrCursor.child(A_NS, "latin");
|
|
301
|
-
const ea = rPrCursor.child(A_NS, "ea");
|
|
302
|
-
const cs = rPrCursor.child(A_NS, "cs");
|
|
303
|
-
const fontCursor = latin ?? ea ?? cs;
|
|
304
|
-
if (fontCursor !== void 0) {
|
|
305
|
-
const rawFont = fontCursor.attrsObject([
|
|
306
|
-
"typeface",
|
|
307
|
-
"pitchFamily",
|
|
308
|
-
"charset",
|
|
309
|
-
"panose"
|
|
310
|
-
]);
|
|
311
|
-
const parsedFont = TypefaceFragmentSchema.safeParse(rawFont);
|
|
312
|
-
if (parsedFont.success) fontFamily = resolveTypefaceToken(parsedFont.data.typeface);
|
|
313
|
-
}
|
|
314
|
-
for (const extraSlot of [ea, cs]) if (extraSlot !== void 0 && extraSlot !== fontCursor) extraSlot.attrsObject([
|
|
315
|
-
"typeface",
|
|
316
|
-
"pitchFamily",
|
|
317
|
-
"charset",
|
|
318
|
-
"panose"
|
|
319
|
-
]);
|
|
320
|
-
return {
|
|
321
|
-
style: {
|
|
322
|
-
...fontFamily === void 0 ? {} : { fontFamily },
|
|
323
|
-
...fontSize === void 0 ? {} : { fontSize },
|
|
324
|
-
...fontWeight === void 0 ? {} : { fontWeight },
|
|
325
|
-
...fontStyle === void 0 ? {} : { fontStyle },
|
|
326
|
-
...color === void 0 ? {} : { color },
|
|
327
|
-
...letterSpacing === void 0 ? {} : { letterSpacing },
|
|
328
|
-
...textTransform === void 0 ? {} : { textTransform },
|
|
329
|
-
...textDecoration === void 0 ? {} : { textDecoration },
|
|
330
|
-
...textShadow === void 0 ? {} : { textShadow },
|
|
331
|
-
...lang === void 0 ? {} : { lang }
|
|
332
|
-
},
|
|
333
|
-
...sizePt === void 0 ? {} : { sizePt }
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Import handler for `<a:fld type="slidenum">` inline text fields (`text-field-slidenum`).
|
|
338
|
-
*/
|
|
339
|
-
const textFieldSlideNumImportHandler = {
|
|
340
|
-
target: "text-inline",
|
|
341
|
-
localName: "fld",
|
|
342
|
-
matches(cursor) {
|
|
343
|
-
return cursor.element.getAttribute("type") === "slidenum";
|
|
344
|
-
},
|
|
345
|
-
read(context) {
|
|
346
|
-
const { cursor, part, slideIndex } = context;
|
|
347
|
-
const diagnostics = [];
|
|
348
|
-
const rawField = cursor.attrsObject(["id", "type"]);
|
|
349
|
-
const parsedField = TextFieldXmlSchema.safeParse(rawField);
|
|
350
|
-
const rPrCursor = cursor.child(A_NS, "rPr");
|
|
351
|
-
cursor.ignoreEmptyChild(A_NS, "pPr");
|
|
352
|
-
const tCursor = cursor.child(A_NS, "t");
|
|
353
|
-
if (tCursor !== void 0) tCursor.consumeAttr("space", XML_NS);
|
|
354
|
-
const fallbackText = tCursor?.textContent ?? "";
|
|
355
|
-
if (!parsedField.success) {
|
|
356
|
-
diagnostics.push({
|
|
357
|
-
code: "invalid-xml-value",
|
|
358
|
-
category: "corrupt-input",
|
|
359
|
-
disposition: "omitted",
|
|
360
|
-
location: {
|
|
361
|
-
part,
|
|
362
|
-
xpath: cursor.xpath,
|
|
363
|
-
slideIndex
|
|
364
|
-
},
|
|
365
|
-
attributeOrElement: "a:fld",
|
|
366
|
-
rawValue: JSON.stringify(rawField)
|
|
367
|
-
});
|
|
368
|
-
return {
|
|
369
|
-
kind: "unsupported",
|
|
370
|
-
fieldType: rawField["type"] ?? "",
|
|
371
|
-
...rPrCursor === void 0 ? {} : { rPrCursor },
|
|
372
|
-
fallbackText,
|
|
373
|
-
diagnostics
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
if (parsedField.data.type !== "slidenum") {
|
|
377
|
-
diagnostics.push({
|
|
378
|
-
code: "unsupported-mechanism",
|
|
379
|
-
category: "unsupported",
|
|
380
|
-
disposition: "omitted",
|
|
381
|
-
location: {
|
|
382
|
-
part,
|
|
383
|
-
xpath: cursor.xpath,
|
|
384
|
-
slideIndex
|
|
385
|
-
},
|
|
386
|
-
namespaceUri: cursor.namespaceUri,
|
|
387
|
-
localName: cursor.localName,
|
|
388
|
-
mechanismHint: `text-field:${parsedField.data.type}`
|
|
389
|
-
});
|
|
390
|
-
return {
|
|
391
|
-
kind: "unsupported",
|
|
392
|
-
fieldType: parsedField.data.type,
|
|
393
|
-
...rPrCursor === void 0 ? {} : { rPrCursor },
|
|
394
|
-
fallbackText,
|
|
395
|
-
diagnostics
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
return {
|
|
399
|
-
kind: "slide-number",
|
|
400
|
-
fieldType: "slidenum",
|
|
401
|
-
...rPrCursor === void 0 ? {} : { rPrCursor },
|
|
402
|
-
fallbackText,
|
|
403
|
-
diagnostics
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
function readParagraph(pCursor, part, slideIndex, diagnostics) {
|
|
408
|
-
const pPr = pCursor.child(A_NS, "pPr");
|
|
409
|
-
let align;
|
|
410
|
-
let lvl;
|
|
411
|
-
let list;
|
|
412
|
-
let lnSpcNode;
|
|
413
|
-
let spcAftNode;
|
|
414
|
-
if (pPr !== void 0) {
|
|
415
|
-
const rawPPr = pPr.attrsObject([
|
|
416
|
-
"algn",
|
|
417
|
-
"rtl",
|
|
418
|
-
"lvl",
|
|
419
|
-
"marL",
|
|
420
|
-
"indent",
|
|
421
|
-
"fontAlgn",
|
|
422
|
-
"eaLnBrk",
|
|
423
|
-
"latinLnBrk",
|
|
424
|
-
"hangingPunct",
|
|
425
|
-
"defTabSz"
|
|
426
|
-
]);
|
|
427
|
-
const parsedPPr = ParagraphPrFragmentSchema.safeParse({
|
|
428
|
-
algn: rawPPr["algn"],
|
|
429
|
-
rtl: rawPPr["rtl"],
|
|
430
|
-
lvl: rawPPr["lvl"]
|
|
431
|
-
});
|
|
432
|
-
if (!parsedPPr.success) diagnostics.push({
|
|
433
|
-
code: "invalid-xml-value",
|
|
434
|
-
category: "corrupt-input",
|
|
435
|
-
disposition: "recovered",
|
|
436
|
-
location: {
|
|
437
|
-
part,
|
|
438
|
-
xpath: pPr.xpath,
|
|
439
|
-
slideIndex
|
|
440
|
-
},
|
|
441
|
-
attributeOrElement: "a:pPr",
|
|
442
|
-
rawValue: JSON.stringify(rawPPr)
|
|
443
|
-
});
|
|
444
|
-
else {
|
|
445
|
-
if (parsedPPr.data.algn !== void 0) align = algnToTextAlign[parsedPPr.data.algn];
|
|
446
|
-
lvl = parsedPPr.data.lvl;
|
|
447
|
-
}
|
|
448
|
-
const spcBefNode = pPr.child(A_NS, "spcBef");
|
|
449
|
-
if (spcBefNode !== void 0) {
|
|
450
|
-
spcBefNode.child(A_NS, "spcPts")?.consumeAttr("val");
|
|
451
|
-
spcBefNode.child(A_NS, "spcPct")?.consumeAttr("val");
|
|
452
|
-
}
|
|
453
|
-
lnSpcNode = pPr.child(A_NS, "lnSpc");
|
|
454
|
-
spcAftNode = pPr.child(A_NS, "spcAft");
|
|
455
|
-
pPr.ignoreEmptyChild(A_NS, "buNone");
|
|
456
|
-
pPr.child(A_NS, "buFont")?.attrsObject([
|
|
457
|
-
"typeface",
|
|
458
|
-
"pitchFamily",
|
|
459
|
-
"charset",
|
|
460
|
-
"panose"
|
|
461
|
-
]);
|
|
462
|
-
const buChar = pPr.child(A_NS, "buChar");
|
|
463
|
-
const buAutoNum = pPr.child(A_NS, "buAutoNum");
|
|
464
|
-
if (buChar !== void 0) {
|
|
465
|
-
const rawBu = buChar.attrsObject(["char"]);
|
|
466
|
-
const parsedBu = BulletCharXmlSchema.safeParse(rawBu);
|
|
467
|
-
if (!parsedBu.success) diagnostics.push({
|
|
468
|
-
code: "invalid-xml-value",
|
|
469
|
-
category: "corrupt-input",
|
|
470
|
-
disposition: "omitted",
|
|
471
|
-
location: {
|
|
472
|
-
part,
|
|
473
|
-
xpath: buChar.xpath,
|
|
474
|
-
slideIndex
|
|
475
|
-
},
|
|
476
|
-
attributeOrElement: "a:buChar/@char",
|
|
477
|
-
rawValue: rawBu["char"] ?? ""
|
|
478
|
-
});
|
|
479
|
-
else list = {
|
|
480
|
-
type: "bullet",
|
|
481
|
-
character: parsedBu.data.char,
|
|
482
|
-
...lvl === void 0 ? {} : { level: lvl }
|
|
483
|
-
};
|
|
484
|
-
} else if (buAutoNum !== void 0) {
|
|
485
|
-
const rawNum = buAutoNum.attrsObject(["type", "startAt"]);
|
|
486
|
-
const parsedNum = AutoNumXmlSchema.safeParse(rawNum);
|
|
487
|
-
if (!parsedNum.success) diagnostics.push({
|
|
488
|
-
code: "invalid-xml-value",
|
|
489
|
-
category: "corrupt-input",
|
|
490
|
-
disposition: "omitted",
|
|
491
|
-
location: {
|
|
492
|
-
part,
|
|
493
|
-
xpath: buAutoNum.xpath,
|
|
494
|
-
slideIndex
|
|
495
|
-
},
|
|
496
|
-
attributeOrElement: "a:buAutoNum",
|
|
497
|
-
rawValue: JSON.stringify(rawNum)
|
|
498
|
-
});
|
|
499
|
-
else {
|
|
500
|
-
if (parsedNum.data.type !== "arabicPeriod") diagnostics.push({
|
|
501
|
-
code: "invalid-xml-value",
|
|
502
|
-
category: "corrupt-input",
|
|
503
|
-
disposition: "recovered",
|
|
504
|
-
location: {
|
|
505
|
-
part,
|
|
506
|
-
xpath: `${buAutoNum.xpath}/@type`,
|
|
507
|
-
slideIndex
|
|
508
|
-
},
|
|
509
|
-
attributeOrElement: "a:buAutoNum/@type",
|
|
510
|
-
rawValue: parsedNum.data.type
|
|
511
|
-
});
|
|
512
|
-
list = {
|
|
513
|
-
type: "number",
|
|
514
|
-
style: "arabicPeriod",
|
|
515
|
-
...parsedNum.data.startAt === void 0 ? {} : { startAt: parsedNum.data.startAt },
|
|
516
|
-
...lvl === void 0 ? {} : { level: lvl }
|
|
517
|
-
};
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
const runs = [];
|
|
522
|
-
let endParaSizePt;
|
|
523
|
-
for (const child of pCursor.remainingElementChildren()) {
|
|
524
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
|
|
525
|
-
const rPr = child.child(A_NS, "rPr");
|
|
526
|
-
const parsedRPr = rPr === void 0 ? { style: {} } : readRunProperties(rPr, part, slideIndex, diagnostics);
|
|
527
|
-
const t = child.child(A_NS, "t");
|
|
528
|
-
if (t !== void 0) {
|
|
529
|
-
t.consumeAttr("space", XML_NS);
|
|
530
|
-
runs.push({
|
|
531
|
-
kind: "text",
|
|
532
|
-
text: t.textContent,
|
|
533
|
-
style: parsedRPr.style,
|
|
534
|
-
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "br") {
|
|
540
|
-
const rPr = child.child(A_NS, "rPr");
|
|
541
|
-
const parsedRPr = rPr === void 0 ? { style: {} } : readRunProperties(rPr, part, slideIndex, diagnostics);
|
|
542
|
-
runs.push({
|
|
543
|
-
kind: "text",
|
|
544
|
-
text: "\n",
|
|
545
|
-
style: parsedRPr.style,
|
|
546
|
-
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
547
|
-
});
|
|
548
|
-
continue;
|
|
549
|
-
}
|
|
550
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
|
|
551
|
-
const outcome = textFieldSlideNumImportHandler.read({
|
|
552
|
-
cursor: child,
|
|
553
|
-
part,
|
|
554
|
-
slideIndex
|
|
555
|
-
});
|
|
556
|
-
diagnostics.push(...outcome.diagnostics);
|
|
557
|
-
if (outcome.kind === "slide-number") {
|
|
558
|
-
const parsedRPr = outcome.rPrCursor === void 0 ? { style: {} } : readRunProperties(outcome.rPrCursor, part, slideIndex, diagnostics);
|
|
559
|
-
runs.push({
|
|
560
|
-
kind: "slide-number",
|
|
561
|
-
style: parsedRPr.style,
|
|
562
|
-
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
continue;
|
|
566
|
-
}
|
|
567
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
|
|
568
|
-
endParaSizePt = readRunProperties(child, part, slideIndex, diagnostics).sizePt;
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
diagnostics.push({
|
|
572
|
-
code: "unconsumed-xml",
|
|
573
|
-
category: "unsupported",
|
|
574
|
-
disposition: "omitted",
|
|
575
|
-
kind: "element",
|
|
576
|
-
location: {
|
|
577
|
-
part,
|
|
578
|
-
xpath: child.xpath,
|
|
579
|
-
slideIndex
|
|
580
|
-
},
|
|
581
|
-
namespaceUri: child.namespaceUri,
|
|
582
|
-
localName: child.localName
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
const baseFontPt = runs.find((run) => run.sizePt !== void 0)?.sizePt ?? endParaSizePt ?? 18;
|
|
586
|
-
let lineHeight;
|
|
587
|
-
if (lnSpcNode !== void 0) {
|
|
588
|
-
const spcPts = lnSpcNode.child(A_NS, "spcPts");
|
|
589
|
-
const spcPct = spcPts === void 0 ? lnSpcNode.child(A_NS, "spcPct") : void 0;
|
|
590
|
-
if (spcPts !== void 0) {
|
|
591
|
-
const raw = spcPts.attrsObject(["val"]);
|
|
592
|
-
const parsed = SpacingPointsXmlSchema.safeParse(raw);
|
|
593
|
-
if (!parsed.success || parsed.data.val === 0) diagnostics.push({
|
|
594
|
-
code: "invalid-xml-value",
|
|
595
|
-
category: "corrupt-input",
|
|
596
|
-
disposition: "omitted",
|
|
597
|
-
location: {
|
|
598
|
-
part,
|
|
599
|
-
xpath: spcPts.xpath,
|
|
600
|
-
slideIndex
|
|
601
|
-
},
|
|
602
|
-
attributeOrElement: "a:spcPts/@val",
|
|
603
|
-
rawValue: raw["val"] ?? ""
|
|
604
|
-
});
|
|
605
|
-
else lineHeight = `${parsed.data.val / 100}pt`;
|
|
606
|
-
} else if (spcPct !== void 0) {
|
|
607
|
-
const raw = spcPct.attrsObject(["val"]);
|
|
608
|
-
const parsed = SpacingPercentXmlSchema.safeParse(raw);
|
|
609
|
-
if (!parsed.success) diagnostics.push({
|
|
610
|
-
code: "invalid-xml-value",
|
|
611
|
-
category: "corrupt-input",
|
|
612
|
-
disposition: "omitted",
|
|
613
|
-
location: {
|
|
614
|
-
part,
|
|
615
|
-
xpath: spcPct.xpath,
|
|
616
|
-
slideIndex
|
|
617
|
-
},
|
|
618
|
-
attributeOrElement: "a:spcPct/@val",
|
|
619
|
-
rawValue: raw["val"] ?? ""
|
|
620
|
-
});
|
|
621
|
-
else {
|
|
622
|
-
const pt = Number((baseFontPt * parsed.data.val / 1e5).toFixed(2));
|
|
623
|
-
if (pt > 0) lineHeight = `${pt}pt`;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
let spacingAfter;
|
|
628
|
-
if (spcAftNode !== void 0) {
|
|
629
|
-
const spcPts = spcAftNode.child(A_NS, "spcPts");
|
|
630
|
-
const spcPct = spcPts === void 0 ? spcAftNode.child(A_NS, "spcPct") : void 0;
|
|
631
|
-
if (spcPts !== void 0) {
|
|
632
|
-
const raw = spcPts.attrsObject(["val"]);
|
|
633
|
-
const parsed = SpacingPointsXmlSchema.safeParse(raw);
|
|
634
|
-
if (!parsed.success) diagnostics.push({
|
|
635
|
-
code: "invalid-xml-value",
|
|
636
|
-
category: "corrupt-input",
|
|
637
|
-
disposition: "omitted",
|
|
638
|
-
location: {
|
|
639
|
-
part,
|
|
640
|
-
xpath: spcPts.xpath,
|
|
641
|
-
slideIndex
|
|
642
|
-
},
|
|
643
|
-
attributeOrElement: "a:spcPts/@val",
|
|
644
|
-
rawValue: raw["val"] ?? ""
|
|
645
|
-
});
|
|
646
|
-
else spacingAfter = parsed.data.val / 75;
|
|
647
|
-
} else if (spcPct !== void 0) {
|
|
648
|
-
const raw = spcPct.attrsObject(["val"]);
|
|
649
|
-
const parsed = SpacingPercentXmlSchema.safeParse(raw);
|
|
650
|
-
if (parsed.success) spacingAfter = baseFontPt * parsed.data.val / 1e5 * (4 / 3);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
return {
|
|
654
|
-
runs,
|
|
655
|
-
style: {
|
|
656
|
-
...align === void 0 ? {} : { align },
|
|
657
|
-
...lineHeight === void 0 ? {} : { lineHeight },
|
|
658
|
-
...spacingAfter === void 0 ? {} : { spacingAfter },
|
|
659
|
-
...list === void 0 ? {} : { list }
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
/**
|
|
664
|
-
* Shared rich-text body reader for text boxes, shapes, table cells, and speaker notes.
|
|
665
|
-
*/
|
|
666
|
-
function readRichTextBody(txBody, part, slideIndex, diagnostics, _clrMap) {
|
|
667
|
-
let paddingTop;
|
|
668
|
-
let paddingRight;
|
|
669
|
-
let paddingBottom;
|
|
670
|
-
let paddingLeft;
|
|
671
|
-
let verticalAlign;
|
|
672
|
-
let textWrap;
|
|
673
|
-
const bodyPr = txBody.child(A_NS, "bodyPr");
|
|
674
|
-
if (bodyPr !== void 0) {
|
|
675
|
-
const rawBodyPr = bodyPr.attrsObject([
|
|
676
|
-
"wrap",
|
|
677
|
-
"rtlCol",
|
|
678
|
-
"lIns",
|
|
679
|
-
"tIns",
|
|
680
|
-
"rIns",
|
|
681
|
-
"bIns",
|
|
682
|
-
"anchor",
|
|
683
|
-
"anchorCtr",
|
|
684
|
-
"spcFirstLastPara",
|
|
685
|
-
"numCol",
|
|
686
|
-
"spcCol"
|
|
687
|
-
]);
|
|
688
|
-
const parsedBodyPr = BodyPrFragmentSchema.safeParse(rawBodyPr);
|
|
689
|
-
if (!parsedBodyPr.success) diagnostics.push({
|
|
690
|
-
code: "invalid-xml-value",
|
|
691
|
-
category: "corrupt-input",
|
|
692
|
-
disposition: "recovered",
|
|
693
|
-
location: {
|
|
694
|
-
part,
|
|
695
|
-
xpath: bodyPr.xpath,
|
|
696
|
-
slideIndex
|
|
697
|
-
},
|
|
698
|
-
attributeOrElement: "a:bodyPr",
|
|
699
|
-
rawValue: JSON.stringify(rawBodyPr)
|
|
700
|
-
});
|
|
701
|
-
else {
|
|
702
|
-
const b = parsedBodyPr.data;
|
|
703
|
-
if (b.wrap === "none") textWrap = "nowrap";
|
|
704
|
-
else if (b.wrap === "square") textWrap = "normal";
|
|
705
|
-
if (b.anchor !== void 0) verticalAlign = anchorToVerticalAlign[b.anchor];
|
|
706
|
-
if (b.lIns !== void 0 && b.lIns !== 0) paddingLeft = emuToPx(b.lIns);
|
|
707
|
-
if (b.tIns !== void 0 && b.tIns !== 0) paddingTop = emuToPx(b.tIns);
|
|
708
|
-
if (b.rIns !== void 0 && b.rIns !== 0) paddingRight = emuToPx(b.rIns);
|
|
709
|
-
if (b.bIns !== void 0 && b.bIns !== 0) paddingBottom = emuToPx(b.bIns);
|
|
710
|
-
}
|
|
711
|
-
bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
|
|
712
|
-
bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
|
|
713
|
-
bodyPr.child(A_NS, "normAutofit")?.attrsObject(["fontScale", "lnSpcReduction"]);
|
|
714
|
-
}
|
|
715
|
-
txBody.ignoreEmptyChild(A_NS, "lstStyle");
|
|
716
|
-
const importedParagraphs = txBody.children(A_NS, "p").map((pCursor) => readParagraph(pCursor, part, slideIndex, diagnostics));
|
|
717
|
-
return {
|
|
718
|
-
boxStyle: {
|
|
719
|
-
...paddingTop === void 0 ? {} : { paddingTop },
|
|
720
|
-
...paddingRight === void 0 ? {} : { paddingRight },
|
|
721
|
-
...paddingBottom === void 0 ? {} : { paddingBottom },
|
|
722
|
-
...paddingLeft === void 0 ? {} : { paddingLeft },
|
|
723
|
-
...verticalAlign === void 0 ? {} : { verticalAlign },
|
|
724
|
-
...textWrap === void 0 ? {} : { textWrap }
|
|
725
|
-
},
|
|
726
|
-
importedParagraphs
|
|
727
|
-
};
|
|
728
|
-
}
|
|
729
|
-
/** Populates a `RichTextContainer` (`TextNode`, `ShapeNode`, `CellNode`, `NotesNode`) from imported paragraphs. */
|
|
730
|
-
function populateRichTextNode(target, importedParagraphs) {
|
|
731
|
-
const paragraphNodes = importedParagraphs.map((para) => {
|
|
732
|
-
const pNode = createParagraphNode(Object.keys(para.style).length === 0 ? {} : { style: para.style });
|
|
733
|
-
if (para.runs.length === 1 && para.runs[0].kind === "text" && Object.keys(para.runs[0].style).length === 0) pNode.content(para.runs[0].text);
|
|
734
|
-
else if (para.runs.length > 0) pNode.content(...para.runs.map((run) => {
|
|
735
|
-
if (run.kind === "slide-number") return createSlideNumberNode(Object.keys(run.style).length === 0 ? {} : { style: run.style });
|
|
736
|
-
return Object.keys(run.style).length === 0 ? run.text : createSpanNode({ style: run.style }).content(run.text);
|
|
737
|
-
}));
|
|
738
|
-
return pNode;
|
|
739
|
-
});
|
|
740
|
-
target.content(...paragraphNodes);
|
|
741
|
-
}
|
|
742
|
-
function textBoxVisualStyle(appearanceStyle, geometry, boxSize, rotate, location, diagnostics) {
|
|
743
|
-
const { startArrow, endArrow, ...supportedVisualStyle } = appearanceStyle;
|
|
744
|
-
if (startArrow !== void 0 || endArrow !== void 0) diagnostics.push({
|
|
745
|
-
code: "unsupported-mechanism",
|
|
746
|
-
category: "unsupported",
|
|
747
|
-
disposition: "omitted",
|
|
748
|
-
location,
|
|
749
|
-
namespaceUri: A_NS,
|
|
750
|
-
localName: startArrow !== void 0 ? "headEnd" : "tailEnd",
|
|
751
|
-
mechanismHint: "textbox-line-arrow"
|
|
752
|
-
});
|
|
753
|
-
let borderRadius;
|
|
754
|
-
if (geometry === "roundRect") {
|
|
755
|
-
if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
756
|
-
} else if (typeof geometry === "object" && geometry.type === "preset") {
|
|
757
|
-
if (geometry.name === "roundRect") {
|
|
758
|
-
if (boxSize !== void 0) {
|
|
759
|
-
const adj = geometry.adjust?.["adj"] ?? 16667;
|
|
760
|
-
if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
761
|
-
}
|
|
762
|
-
} else if (geometry.name !== "rect") diagnostics.push({
|
|
763
|
-
code: "unsupported-mechanism",
|
|
764
|
-
category: "unsupported",
|
|
765
|
-
disposition: "omitted",
|
|
766
|
-
location,
|
|
767
|
-
namespaceUri: A_NS,
|
|
768
|
-
localName: "prstGeom",
|
|
769
|
-
mechanismHint: `textbox-preset:${geometry.name}`
|
|
770
|
-
});
|
|
771
|
-
} else if (typeof geometry === "object" && geometry.type === "custom") diagnostics.push({
|
|
772
|
-
code: "unsupported-mechanism",
|
|
773
|
-
category: "unsupported",
|
|
774
|
-
disposition: "omitted",
|
|
775
|
-
location,
|
|
776
|
-
namespaceUri: A_NS,
|
|
777
|
-
localName: "custGeom",
|
|
778
|
-
mechanismHint: "textbox-custGeom"
|
|
779
|
-
});
|
|
780
|
-
return {
|
|
781
|
-
...supportedVisualStyle,
|
|
782
|
-
...borderRadius === void 0 ? {} : { borderRadius },
|
|
783
|
-
...rotate === void 0 ? {} : { rotate }
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
function flattenImportedTextBody(imported, visualStyle) {
|
|
787
|
-
const importedParagraphs = imported?.importedParagraphs ?? [];
|
|
788
|
-
const singleParagraph = importedParagraphs.length === 1 ? importedParagraphs[0] : void 0;
|
|
789
|
-
const singleTextRun = singleParagraph !== void 0 && singleParagraph.style.list === void 0 && singleParagraph.runs.length === 1 && singleParagraph.runs[0].kind === "text" ? singleParagraph.runs[0] : void 0;
|
|
790
|
-
const singleEmptyParagraph = singleParagraph !== void 0 && singleParagraph.style.list === void 0 && singleParagraph.runs.length === 0;
|
|
791
|
-
const flatParagraphStyle = singleTextRun === void 0 && !singleEmptyParagraph || singleParagraph === void 0 ? void 0 : (() => {
|
|
792
|
-
const { list: _list, ...rest } = singleParagraph.style;
|
|
793
|
-
return rest;
|
|
794
|
-
})();
|
|
795
|
-
const boxStyle = {
|
|
796
|
-
...imported?.boxStyle,
|
|
797
|
-
...visualStyle,
|
|
798
|
-
...flatParagraphStyle,
|
|
799
|
-
...singleTextRun === void 0 ? {} : singleTextRun.style
|
|
800
|
-
};
|
|
801
|
-
if (singleTextRun !== void 0) return {
|
|
802
|
-
boxStyle,
|
|
803
|
-
singleText: singleTextRun.text
|
|
804
|
-
};
|
|
805
|
-
if (!singleEmptyParagraph && importedParagraphs.length > 0) return {
|
|
806
|
-
boxStyle,
|
|
807
|
-
paragraphsToPopulate: importedParagraphs
|
|
808
|
-
};
|
|
809
|
-
return { boxStyle };
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* Reads a Transitional `<p:sp>` text box (`<p:cNvSpPr txBox="1"/>` without `<p:ph>`) into an editable `TextNode`.
|
|
813
|
-
*/
|
|
814
|
-
function readTextBoxSp(context) {
|
|
815
|
-
const { cursor, part, slideIndex, package: pkg } = context;
|
|
816
|
-
const diagnostics = [];
|
|
817
|
-
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
818
|
-
if (nvSpPr === void 0) {
|
|
819
|
-
diagnostics.push({
|
|
820
|
-
code: "corrupt-part",
|
|
821
|
-
category: "corrupt-input",
|
|
822
|
-
disposition: "omitted",
|
|
823
|
-
location: {
|
|
824
|
-
part,
|
|
825
|
-
xpath: cursor.xpath,
|
|
826
|
-
slideIndex
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
return { diagnostics };
|
|
830
|
-
}
|
|
831
|
-
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
832
|
-
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
833
|
-
cNvPr?.ignoreEmptyChild(A_NS, "extLst");
|
|
834
|
-
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
835
|
-
if (cNvSpPr !== void 0) {
|
|
836
|
-
const rawFlags = cNvSpPr.attrsObject(["txBox"]);
|
|
837
|
-
NonVisualSpPrFlagsSchema.safeParse(rawFlags);
|
|
838
|
-
cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
|
|
839
|
-
"noGrp",
|
|
840
|
-
"noRot",
|
|
841
|
-
"noChangeAspect",
|
|
842
|
-
"noMove",
|
|
843
|
-
"noResize",
|
|
844
|
-
"noSelect"
|
|
845
|
-
]);
|
|
846
|
-
}
|
|
847
|
-
consumeNonPlaceholderNvPr(nvSpPr);
|
|
848
|
-
const location = {
|
|
849
|
-
part,
|
|
850
|
-
slideIndex,
|
|
851
|
-
...objectId === void 0 ? {} : { objectId },
|
|
852
|
-
...objectName === void 0 ? {} : { objectName }
|
|
853
|
-
};
|
|
854
|
-
const spPr = cursor.child(P_NS, "spPr");
|
|
855
|
-
const txBody = cursor.child(P_NS, "txBody");
|
|
856
|
-
if (spPr === void 0 || txBody === void 0) {
|
|
857
|
-
diagnostics.push({
|
|
858
|
-
code: "corrupt-part",
|
|
859
|
-
category: "corrupt-input",
|
|
860
|
-
disposition: "omitted",
|
|
861
|
-
location: {
|
|
862
|
-
...location,
|
|
863
|
-
xpath: cursor.xpath
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
return { diagnostics };
|
|
867
|
-
}
|
|
868
|
-
const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
|
|
869
|
-
if (visuals === void 0) return { diagnostics };
|
|
870
|
-
const visualStyle = textBoxVisualStyle(visuals.style, visuals.geometry, {
|
|
871
|
-
width: visuals.transform.width,
|
|
872
|
-
height: visuals.transform.height
|
|
873
|
-
}, visuals.transform.rotate, location, diagnostics);
|
|
874
|
-
const { boxStyle, singleText, paragraphsToPopulate } = flattenImportedTextBody(readRichTextBody(txBody, part, slideIndex, diagnostics), visualStyle);
|
|
875
|
-
const props = {
|
|
876
|
-
...objectName === void 0 ? {} : { name: objectName },
|
|
877
|
-
...link === void 0 ? {} : { link },
|
|
878
|
-
x: visuals.transform.x,
|
|
879
|
-
y: visuals.transform.y,
|
|
880
|
-
width: visuals.transform.width,
|
|
881
|
-
height: visuals.transform.height,
|
|
882
|
-
...Object.keys(boxStyle).length === 0 ? {} : { style: boxStyle }
|
|
883
|
-
};
|
|
884
|
-
const node = createTextNode(props);
|
|
885
|
-
if (singleText !== void 0) node.content(singleText);
|
|
886
|
-
else if (paragraphsToPopulate !== void 0) populateRichTextNode(node, paragraphsToPopulate);
|
|
887
|
-
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
888
|
-
return {
|
|
889
|
-
node,
|
|
890
|
-
diagnostics
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* Reads a Transitional `<p:sp>` bound placeholder (`<p:nvPr><p:ph .../></p:nvPr>`)
|
|
895
|
-
* into a layout-bound `TextNode` preserving differential transforms and styles.
|
|
896
|
-
*/
|
|
897
|
-
function readTextPlaceholderSp(context) {
|
|
898
|
-
const { cursor, part, slideIndex, layoutPlaceholders, package: pkg } = context;
|
|
899
|
-
const diagnostics = [];
|
|
900
|
-
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
901
|
-
if (nvSpPr === void 0) {
|
|
902
|
-
diagnostics.push({
|
|
903
|
-
code: "corrupt-part",
|
|
904
|
-
category: "corrupt-input",
|
|
905
|
-
disposition: "omitted",
|
|
906
|
-
location: {
|
|
907
|
-
part,
|
|
908
|
-
xpath: cursor.xpath,
|
|
909
|
-
slideIndex
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
return { diagnostics };
|
|
913
|
-
}
|
|
914
|
-
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
915
|
-
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
916
|
-
cNvPr?.ignoreEmptyChild(A_NS, "extLst");
|
|
917
|
-
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
918
|
-
if (cNvSpPr !== void 0) {
|
|
919
|
-
cNvSpPr.consumeAttr("txBox");
|
|
920
|
-
cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
|
|
921
|
-
"noGrp",
|
|
922
|
-
"noRot",
|
|
923
|
-
"noChangeAspect",
|
|
924
|
-
"noMove",
|
|
925
|
-
"noResize",
|
|
926
|
-
"noSelect"
|
|
927
|
-
]);
|
|
928
|
-
}
|
|
929
|
-
const location = {
|
|
930
|
-
part,
|
|
931
|
-
slideIndex,
|
|
932
|
-
...objectId === void 0 ? {} : { objectId },
|
|
933
|
-
...objectName === void 0 ? {} : { objectName }
|
|
934
|
-
};
|
|
935
|
-
const nvPr = nvSpPr.child(P_NS, "nvPr");
|
|
936
|
-
const phResult = readNvPrPlaceholder(nvPr, {
|
|
937
|
-
...location,
|
|
938
|
-
xpath: cursor.xpath
|
|
939
|
-
}, diagnostics);
|
|
940
|
-
if (phResult.kind === "none") {
|
|
941
|
-
diagnostics.push({
|
|
942
|
-
code: "corrupt-part",
|
|
943
|
-
category: "corrupt-input",
|
|
944
|
-
disposition: "omitted",
|
|
945
|
-
location: {
|
|
946
|
-
...location,
|
|
947
|
-
xpath: cursor.xpath
|
|
948
|
-
}
|
|
949
|
-
});
|
|
950
|
-
return { diagnostics };
|
|
951
|
-
}
|
|
952
|
-
if (phResult.kind === "error") return { diagnostics };
|
|
953
|
-
const nativeRef = phResult.nativeRef;
|
|
954
|
-
const spPr = cursor.child(P_NS, "spPr");
|
|
955
|
-
if (spPr === void 0) {
|
|
956
|
-
diagnostics.push({
|
|
957
|
-
code: "corrupt-part",
|
|
958
|
-
category: "corrupt-input",
|
|
959
|
-
disposition: "omitted",
|
|
960
|
-
location: {
|
|
961
|
-
...location,
|
|
962
|
-
xpath: cursor.xpath
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
return { diagnostics };
|
|
966
|
-
}
|
|
967
|
-
let localBox;
|
|
968
|
-
let rotate;
|
|
969
|
-
let fallbackUnits = {
|
|
970
|
-
w: 0,
|
|
971
|
-
h: 0
|
|
972
|
-
};
|
|
973
|
-
const xfrm = spPr.child(A_NS, "xfrm");
|
|
974
|
-
if (xfrm !== void 0) {
|
|
975
|
-
const rawXfrm = xfrm.attrsObject([
|
|
976
|
-
"rot",
|
|
977
|
-
"flipH",
|
|
978
|
-
"flipV"
|
|
979
|
-
]);
|
|
980
|
-
const parsedXfrm = transformAttributesFragmentSchema.safeParse(rawXfrm);
|
|
981
|
-
if (parsedXfrm.success && parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0) rotate = parsedXfrm.data.rot / 6e4;
|
|
982
|
-
const off = xfrm.child(A_NS, "off");
|
|
983
|
-
const ext = xfrm.child(A_NS, "ext");
|
|
984
|
-
if (off !== void 0 && ext !== void 0) {
|
|
985
|
-
const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
|
|
986
|
-
const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
|
|
987
|
-
if (!parsedOff.success || !parsedExt.success) {
|
|
988
|
-
diagnostics.push({
|
|
989
|
-
code: "invalid-xml-value",
|
|
990
|
-
category: "corrupt-input",
|
|
991
|
-
disposition: "omitted",
|
|
992
|
-
location: {
|
|
993
|
-
...location,
|
|
994
|
-
xpath: xfrm.xpath
|
|
995
|
-
},
|
|
996
|
-
attributeOrElement: "a:xfrm"
|
|
997
|
-
});
|
|
998
|
-
return { diagnostics };
|
|
999
|
-
}
|
|
1000
|
-
fallbackUnits = {
|
|
1001
|
-
w: parsedExt.data.cx,
|
|
1002
|
-
h: parsedExt.data.cy
|
|
1003
|
-
};
|
|
1004
|
-
localBox = {
|
|
1005
|
-
x: emuToPx(parsedOff.data.x),
|
|
1006
|
-
y: emuToPx(parsedOff.data.y),
|
|
1007
|
-
width: emuToPx(parsedExt.data.cx),
|
|
1008
|
-
height: emuToPx(parsedExt.data.cy)
|
|
1009
|
-
};
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
const matchedKey = matchLayoutPlaceholderKey(layoutPlaceholders, {
|
|
1013
|
-
type: nativeRef.type,
|
|
1014
|
-
idx: nativeRef.idx
|
|
1015
|
-
});
|
|
1016
|
-
const layoutPlaceholder = matchedKey === void 0 ? void 0 : layoutPlaceholders?.[matchedKey];
|
|
1017
|
-
const masterPlaceholder = matchMasterPlaceholderSpec(context.masterPlaceholders, nativeRef.type);
|
|
1018
|
-
const inheritedWidth = layoutPlaceholder?.width ?? masterPlaceholder?.width;
|
|
1019
|
-
const inheritedHeight = layoutPlaceholder?.height ?? masterPlaceholder?.height;
|
|
1020
|
-
const inheritedPlaceholderBox = inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
|
|
1021
|
-
width: inheritedWidth,
|
|
1022
|
-
height: inheritedHeight
|
|
1023
|
-
} : void 0;
|
|
1024
|
-
const effectiveFallbackUnits = localBox === void 0 && inheritedPlaceholderBox !== void 0 ? {
|
|
1025
|
-
w: Math.round(inheritedPlaceholderBox.width * EMU_PER_PX),
|
|
1026
|
-
h: Math.round(inheritedPlaceholderBox.height * EMU_PER_PX)
|
|
1027
|
-
} : fallbackUnits;
|
|
1028
|
-
const appearance = readSpPrAppearance(spPr, pkg, effectiveFallbackUnits, location, diagnostics);
|
|
1029
|
-
const visualStyle = textBoxVisualStyle(appearance.style, appearance.geometry, localBox ?? inheritedPlaceholderBox, rotate, location, diagnostics);
|
|
1030
|
-
const txBody = cursor.child(P_NS, "txBody");
|
|
1031
|
-
const { boxStyle, singleText, paragraphsToPopulate } = flattenImportedTextBody(txBody === void 0 ? void 0 : readRichTextBody(txBody, part, slideIndex, diagnostics), visualStyle);
|
|
1032
|
-
let validatedStyle;
|
|
1033
|
-
if (Object.keys(boxStyle).length > 0) {
|
|
1034
|
-
const parsedStyle = placeholderStyleSchema.safeParse(boxStyle);
|
|
1035
|
-
if (parsedStyle.success) validatedStyle = parsedStyle.data;
|
|
1036
|
-
else diagnostics.push({
|
|
1037
|
-
code: "invalid-xml-value",
|
|
1038
|
-
category: "corrupt-input",
|
|
1039
|
-
disposition: "recovered",
|
|
1040
|
-
location: {
|
|
1041
|
-
...location,
|
|
1042
|
-
xpath: cursor.xpath
|
|
1043
|
-
},
|
|
1044
|
-
attributeOrElement: "p:sp",
|
|
1045
|
-
rawValue: parsedStyle.error.issues[0]?.message ?? "invalid style"
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
const props = {
|
|
1049
|
-
...objectName === void 0 ? {} : { name: objectName },
|
|
1050
|
-
...link === void 0 ? {} : { link },
|
|
1051
|
-
...matchedKey === void 0 ? {} : { placeholder: matchedKey },
|
|
1052
|
-
nativePlaceholder: nativeRef,
|
|
1053
|
-
...localBox,
|
|
1054
|
-
...validatedStyle === void 0 ? {} : { style: validatedStyle }
|
|
1055
|
-
};
|
|
1056
|
-
const node = createTextNode(props);
|
|
1057
|
-
if (singleText !== void 0) node.content(singleText);
|
|
1058
|
-
else if (paragraphsToPopulate !== void 0) populateRichTextNode(node, paragraphsToPopulate);
|
|
1059
|
-
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
1060
|
-
return {
|
|
1061
|
-
node,
|
|
1062
|
-
diagnostics
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
const textBoxImportHandler = {
|
|
1066
|
-
target: "shape-tree",
|
|
1067
|
-
localName: "sp",
|
|
1068
|
-
matches: (cursor) => isTextBoxSpElement(cursor) && !isPlaceholderSpElement(cursor),
|
|
1069
|
-
read: readTextBoxSp
|
|
1070
|
-
};
|
|
1071
|
-
const textPlaceholderImportHandler = {
|
|
1072
|
-
target: "shape-tree",
|
|
1073
|
-
localName: "sp",
|
|
1074
|
-
matches: isTextPlaceholderSpElement,
|
|
1075
|
-
read: readTextPlaceholderSp
|
|
1076
|
-
};
|
|
1077
|
-
export { isPlaceholderSpElement, isTextPlaceholderSpElement, populateRichTextNode, readRichTextBody, readTextBoxSp, readTextPlaceholderSp, textBoxImportHandler, textFieldSlideNumImportHandler, textPlaceholderImportHandler };
|