@officedk/pptxdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -1,628 +0,0 @@
|
|
|
1
|
-
import "../../../core/dist/capability.js";
|
|
2
|
-
import { A_NS, P_NS, XML_NS } from "../../../import/dist/namespaces.js";
|
|
3
|
-
import { normalizeBulletCharacter, ooxmlAutoNumStartAtSchema, ooxmlBoolSchema, ooxmlLineSpacingPercentSchema, ooxmlLineSpacingPointsSchema, ooxmlListLevelSchema, ooxmlNonNegativeIntSchema, ooxmlParagraphSpacingPointsSchema, readOoxmlBoxInsets, readOoxmlRunAttrStyles } from "../../../import/dist/xml-fragments.js";
|
|
4
|
-
import { readDrawingColor, readEffectList } from "../../../import/dist/visual.js";
|
|
5
|
-
import { readRunFontSlots } from "../../../import/dist/fonts.js";
|
|
6
|
-
import "../../../import/dist/index.js";
|
|
7
|
-
import { isLineNormalizedSpElement } from "../line/line-import.js";
|
|
8
|
-
import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, readClickLink } from "../shared/identity.js";
|
|
9
|
-
import { isPlaceholderSpElement } from "../shared/placeholder-import.js";
|
|
10
|
-
import { readSpPrVisuals } from "../shared/visual.js";
|
|
11
|
-
import { createParagraphNode, createSlideNumberNode, createSpanNode, createSubNode, createSupNode } from "../text/text-declaration.js";
|
|
12
|
-
import { createShapeNode } from "./shape-declaration.js";
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
// ../capabilities/dist/shape/shape-import.js
|
|
15
|
-
const NonVisualIdAttrSchema = z.object({
|
|
16
|
-
id: ooxmlNonNegativeIntSchema,
|
|
17
|
-
name: z.string().optional()
|
|
18
|
-
});
|
|
19
|
-
const BodyPrAttrSchema = z.object({
|
|
20
|
-
wrap: z.enum(["square", "none"]).optional(),
|
|
21
|
-
rtlCol: ooxmlBoolSchema.optional(),
|
|
22
|
-
anchor: z.enum([
|
|
23
|
-
"t",
|
|
24
|
-
"ctr",
|
|
25
|
-
"b"
|
|
26
|
-
]).optional()
|
|
27
|
-
});
|
|
28
|
-
const ParagraphAlignAttrSchema = z.enum([
|
|
29
|
-
"l",
|
|
30
|
-
"ctr",
|
|
31
|
-
"r",
|
|
32
|
-
"just"
|
|
33
|
-
]);
|
|
34
|
-
const SpacingValAttrSchema = z.object({ val: ooxmlParagraphSpacingPointsSchema });
|
|
35
|
-
const LineSpacingPtsAttrSchema = z.object({ val: ooxmlLineSpacingPointsSchema });
|
|
36
|
-
const LineSpacingPctAttrSchema = z.object({ val: ooxmlLineSpacingPercentSchema });
|
|
37
|
-
const anchorToVerticalAlign = {
|
|
38
|
-
t: "top",
|
|
39
|
-
ctr: "middle",
|
|
40
|
-
b: "bottom"
|
|
41
|
-
};
|
|
42
|
-
const algnToTextAlign = {
|
|
43
|
-
l: "left",
|
|
44
|
-
ctr: "center",
|
|
45
|
-
r: "right",
|
|
46
|
-
just: "justify"
|
|
47
|
-
};
|
|
48
|
-
function directElementChild(parent, namespaceUri, localName) {
|
|
49
|
-
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
50
|
-
if (child.nodeType !== 1) continue;
|
|
51
|
-
const el = child;
|
|
52
|
-
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function isTextBoxSpElement(cursor) {
|
|
56
|
-
const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
|
|
57
|
-
if (nvSpPr === void 0) return false;
|
|
58
|
-
const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
|
|
59
|
-
if (cNvSpPr === void 0) return false;
|
|
60
|
-
const txBox = cNvSpPr.getAttribute("txBox");
|
|
61
|
-
return txBox === "1" || txBox === "true";
|
|
62
|
-
}
|
|
63
|
-
function isCustomGeomSpElement(cursor) {
|
|
64
|
-
const spPr = directElementChild(cursor.element, P_NS, "spPr");
|
|
65
|
-
if (spPr === void 0) return false;
|
|
66
|
-
return directElementChild(spPr, A_NS, "custGeom") !== void 0;
|
|
67
|
-
}
|
|
68
|
-
/** Side-effect-free predicate matching non-textbox preset shapes (`<p:sp>` without `txBox="1"`, `<p:ph>`, `<a:custGeom>`, or normalized 1D lines). */
|
|
69
|
-
function isPresetShapeSpElement(cursor) {
|
|
70
|
-
return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && !isCustomGeomSpElement(cursor) && !isLineNormalizedSpElement(cursor);
|
|
71
|
-
}
|
|
72
|
-
/** Side-effect-free predicate matching non-textbox custom-geometry shapes (`<p:sp>` without `<p:ph>` and with `<a:custGeom>`). */
|
|
73
|
-
function isCustomGeometryShapeSpElement(cursor) {
|
|
74
|
-
return !isPlaceholderSpElement(cursor) && !isTextBoxSpElement(cursor) && isCustomGeomSpElement(cursor);
|
|
75
|
-
}
|
|
76
|
-
/** Reads `<p:cNvPr>` id, name, and hyperlink without assuming shape vs group wrapper tag. */
|
|
77
|
-
function readNonVisualCommonProperties(cNvPrCursor, context, diagnostics) {
|
|
78
|
-
if (cNvPrCursor === void 0) return {};
|
|
79
|
-
const raw = cNvPrCursor.attrsObject(["id", "name"]);
|
|
80
|
-
const parsed = NonVisualIdAttrSchema.safeParse(raw);
|
|
81
|
-
let objectId;
|
|
82
|
-
let objectName;
|
|
83
|
-
if (!parsed.success) diagnostics.push({
|
|
84
|
-
code: "invalid-xml-value",
|
|
85
|
-
category: "corrupt-input",
|
|
86
|
-
disposition: "recovered",
|
|
87
|
-
location: {
|
|
88
|
-
part: context.part,
|
|
89
|
-
xpath: cNvPrCursor.xpath,
|
|
90
|
-
slideIndex: context.slideIndex
|
|
91
|
-
},
|
|
92
|
-
attributeOrElement: "p:cNvPr",
|
|
93
|
-
rawValue: JSON.stringify(raw)
|
|
94
|
-
});
|
|
95
|
-
else {
|
|
96
|
-
objectId = parsed.data.id;
|
|
97
|
-
if (parsed.data.name !== void 0 && parsed.data.name.trim() !== "") objectName = parsed.data.name;
|
|
98
|
-
}
|
|
99
|
-
const hlinkClick = cNvPrCursor.child(A_NS, "hlinkClick");
|
|
100
|
-
let clickResult;
|
|
101
|
-
if (hlinkClick !== void 0) {
|
|
102
|
-
clickResult = readClickLink(hlinkClick, context, {
|
|
103
|
-
...objectId === void 0 ? {} : { objectId },
|
|
104
|
-
...objectName === void 0 ? {} : { objectName }
|
|
105
|
-
});
|
|
106
|
-
diagnostics.push(...clickResult.diagnostics);
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
...objectId === void 0 ? {} : { objectId },
|
|
110
|
-
...objectName === void 0 ? {} : { objectName },
|
|
111
|
-
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
112
|
-
...clickResult?.deferredSlideLink === void 0 ? {} : { deferredSlideLink: clickResult.deferredSlideLink }
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function readShapeRunProperties(rPrCursor, location, diagnostics) {
|
|
116
|
-
const attrStyles = readOoxmlRunAttrStyles({
|
|
117
|
-
rPrCursor,
|
|
118
|
-
location,
|
|
119
|
-
diagnostics,
|
|
120
|
-
allowBaseline: true,
|
|
121
|
-
allowNoneTextDecoration: false,
|
|
122
|
-
diagnoseUnsupportedEnums: true
|
|
123
|
-
});
|
|
124
|
-
const solidFill = rPrCursor.child(A_NS, "solidFill");
|
|
125
|
-
const color = solidFill === void 0 ? void 0 : readDrawingColor(solidFill, location, diagnostics);
|
|
126
|
-
const effectLst = rPrCursor.child(A_NS, "effectLst");
|
|
127
|
-
const effects = effectLst === void 0 ? {} : readEffectList(effectLst, location, diagnostics);
|
|
128
|
-
const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPrCursor);
|
|
129
|
-
return {
|
|
130
|
-
style: {
|
|
131
|
-
...fontFamily === void 0 ? {} : { fontFamily },
|
|
132
|
-
...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily },
|
|
133
|
-
...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
|
|
134
|
-
...attrStyles.fontWeight === void 0 ? {} : { fontWeight: attrStyles.fontWeight },
|
|
135
|
-
...attrStyles.fontStyle === void 0 ? {} : { fontStyle: attrStyles.fontStyle },
|
|
136
|
-
...color === void 0 ? {} : { color },
|
|
137
|
-
...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
|
|
138
|
-
...attrStyles.textTransform === void 0 ? {} : { textTransform: attrStyles.textTransform },
|
|
139
|
-
...attrStyles.textDecoration === void 0 ? {} : { textDecoration: attrStyles.textDecoration },
|
|
140
|
-
...effects.boxShadow === void 0 ? {} : { textShadow: effects.boxShadow },
|
|
141
|
-
...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang },
|
|
142
|
-
...attrStyles.baselineShift === void 0 ? {} : { baselineShift: attrStyles.baselineShift }
|
|
143
|
-
},
|
|
144
|
-
...attrStyles.inlineKind === void 0 ? {} : { inlineKind: attrStyles.inlineKind }
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
function readLineSpacing(lnSpcCursor, location, diagnostics) {
|
|
148
|
-
const spcPts = lnSpcCursor.child(A_NS, "spcPts");
|
|
149
|
-
if (spcPts !== void 0) {
|
|
150
|
-
const raw = spcPts.attrsObject(["val"]);
|
|
151
|
-
const parsed = LineSpacingPtsAttrSchema.safeParse(raw);
|
|
152
|
-
if (!parsed.success) diagnostics.push({
|
|
153
|
-
code: "invalid-xml-value",
|
|
154
|
-
category: "corrupt-input",
|
|
155
|
-
disposition: "omitted",
|
|
156
|
-
location: {
|
|
157
|
-
...location,
|
|
158
|
-
xpath: spcPts.xpath
|
|
159
|
-
},
|
|
160
|
-
attributeOrElement: "a:spcPts/@val",
|
|
161
|
-
rawValue: raw["val"] ?? ""
|
|
162
|
-
});
|
|
163
|
-
else return parsed.data.val / 75;
|
|
164
|
-
}
|
|
165
|
-
const spcPct = lnSpcCursor.child(A_NS, "spcPct");
|
|
166
|
-
if (spcPct !== void 0) {
|
|
167
|
-
const raw = spcPct.attrsObject(["val"]);
|
|
168
|
-
const parsed = LineSpacingPctAttrSchema.safeParse(raw);
|
|
169
|
-
if (!parsed.success) diagnostics.push({
|
|
170
|
-
code: "invalid-xml-value",
|
|
171
|
-
category: "corrupt-input",
|
|
172
|
-
disposition: "omitted",
|
|
173
|
-
location: {
|
|
174
|
-
...location,
|
|
175
|
-
xpath: spcPct.xpath
|
|
176
|
-
},
|
|
177
|
-
attributeOrElement: "a:spcPct/@val",
|
|
178
|
-
rawValue: raw["val"] ?? ""
|
|
179
|
-
});
|
|
180
|
-
else return `${parsed.data.val / 1e3}%`;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
function readShapeParagraph(pCursor, location, diagnostics) {
|
|
184
|
-
let align;
|
|
185
|
-
let lineHeight;
|
|
186
|
-
let spacingAfter;
|
|
187
|
-
let list;
|
|
188
|
-
let defRunStyle;
|
|
189
|
-
let level = 0;
|
|
190
|
-
const pPr = pCursor.child(A_NS, "pPr");
|
|
191
|
-
if (pPr !== void 0) {
|
|
192
|
-
const rawPPr = pPr.attrsObject([
|
|
193
|
-
"algn",
|
|
194
|
-
"rtl",
|
|
195
|
-
"lvl",
|
|
196
|
-
"marL",
|
|
197
|
-
"indent"
|
|
198
|
-
]);
|
|
199
|
-
if (rawPPr["algn"] !== void 0) {
|
|
200
|
-
const parsedAlgn = ParagraphAlignAttrSchema.safeParse(rawPPr["algn"]);
|
|
201
|
-
if (parsedAlgn.success) align = algnToTextAlign[parsedAlgn.data];
|
|
202
|
-
else diagnostics.push({
|
|
203
|
-
code: "invalid-xml-value",
|
|
204
|
-
category: "corrupt-input",
|
|
205
|
-
disposition: "recovered",
|
|
206
|
-
location: {
|
|
207
|
-
...location,
|
|
208
|
-
xpath: `${pPr.xpath}/@algn`
|
|
209
|
-
},
|
|
210
|
-
attributeOrElement: "@algn",
|
|
211
|
-
rawValue: rawPPr["algn"]
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
if (rawPPr["lvl"] !== void 0) {
|
|
215
|
-
const parsedLvl = ooxmlListLevelSchema.safeParse(rawPPr["lvl"]);
|
|
216
|
-
if (parsedLvl.success) level = parsedLvl.data;
|
|
217
|
-
else diagnostics.push({
|
|
218
|
-
code: "invalid-xml-value",
|
|
219
|
-
category: "corrupt-input",
|
|
220
|
-
disposition: "recovered",
|
|
221
|
-
location: {
|
|
222
|
-
...location,
|
|
223
|
-
xpath: `${pPr.xpath}/@lvl`
|
|
224
|
-
},
|
|
225
|
-
attributeOrElement: "@lvl",
|
|
226
|
-
rawValue: rawPPr["lvl"]
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
const lnSpc = pPr.child(A_NS, "lnSpc");
|
|
230
|
-
if (lnSpc !== void 0) lineHeight = readLineSpacing(lnSpc, location, diagnostics);
|
|
231
|
-
const spcAft = pPr.child(A_NS, "spcAft");
|
|
232
|
-
if (spcAft !== void 0) {
|
|
233
|
-
const spcPts = spcAft.child(A_NS, "spcPts");
|
|
234
|
-
if (spcPts !== void 0) {
|
|
235
|
-
const raw = spcPts.attrsObject(["val"]);
|
|
236
|
-
const parsed = SpacingValAttrSchema.safeParse(raw);
|
|
237
|
-
if (parsed.success) spacingAfter = parsed.data.val / 75;
|
|
238
|
-
else diagnostics.push({
|
|
239
|
-
code: "invalid-xml-value",
|
|
240
|
-
category: "corrupt-input",
|
|
241
|
-
disposition: "omitted",
|
|
242
|
-
location: {
|
|
243
|
-
...location,
|
|
244
|
-
xpath: spcPts.xpath
|
|
245
|
-
},
|
|
246
|
-
attributeOrElement: "a:spcPts/@val",
|
|
247
|
-
rawValue: raw["val"] ?? ""
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
pPr.ignoreEmptyChild(A_NS, "buNone");
|
|
252
|
-
const buChar = pPr.child(A_NS, "buChar");
|
|
253
|
-
if (buChar !== void 0) {
|
|
254
|
-
const rawBu = buChar.attrsObject(["char"]);
|
|
255
|
-
const normalized = normalizeBulletCharacter(rawBu["char"]);
|
|
256
|
-
if (normalized.recovered) diagnostics.push({
|
|
257
|
-
code: "invalid-xml-value",
|
|
258
|
-
category: "corrupt-input",
|
|
259
|
-
disposition: "recovered",
|
|
260
|
-
location: {
|
|
261
|
-
...location,
|
|
262
|
-
xpath: buChar.xpath
|
|
263
|
-
},
|
|
264
|
-
attributeOrElement: "a:buChar/@char",
|
|
265
|
-
rawValue: rawBu["char"] ?? ""
|
|
266
|
-
});
|
|
267
|
-
list = {
|
|
268
|
-
type: "bullet",
|
|
269
|
-
character: normalized.character,
|
|
270
|
-
...level > 0 ? { level } : {}
|
|
271
|
-
};
|
|
272
|
-
} else {
|
|
273
|
-
const buAutoNum = pPr.child(A_NS, "buAutoNum");
|
|
274
|
-
if (buAutoNum !== void 0) {
|
|
275
|
-
const rawAuto = buAutoNum.attrsObject(["type", "startAt"]);
|
|
276
|
-
const rawType = rawAuto["type"];
|
|
277
|
-
if (rawType === void 0 || rawType.length === 0) diagnostics.push({
|
|
278
|
-
code: "invalid-xml-value",
|
|
279
|
-
category: "corrupt-input",
|
|
280
|
-
disposition: "omitted",
|
|
281
|
-
location: {
|
|
282
|
-
...location,
|
|
283
|
-
xpath: buAutoNum.xpath
|
|
284
|
-
},
|
|
285
|
-
attributeOrElement: "a:buAutoNum",
|
|
286
|
-
rawValue: JSON.stringify(rawAuto)
|
|
287
|
-
});
|
|
288
|
-
else {
|
|
289
|
-
let startAt;
|
|
290
|
-
if (rawAuto["startAt"] !== void 0) {
|
|
291
|
-
const parsedStart = ooxmlAutoNumStartAtSchema.safeParse(rawAuto["startAt"]);
|
|
292
|
-
if (parsedStart.success) startAt = parsedStart.data;
|
|
293
|
-
else diagnostics.push({
|
|
294
|
-
code: "invalid-xml-value",
|
|
295
|
-
category: "corrupt-input",
|
|
296
|
-
disposition: "omitted",
|
|
297
|
-
location: {
|
|
298
|
-
...location,
|
|
299
|
-
xpath: `${buAutoNum.xpath}/@startAt`
|
|
300
|
-
},
|
|
301
|
-
attributeOrElement: "a:buAutoNum/@startAt",
|
|
302
|
-
rawValue: rawAuto["startAt"]
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
list = {
|
|
306
|
-
type: "number",
|
|
307
|
-
style: "arabicPeriod",
|
|
308
|
-
...startAt === void 0 ? {} : { startAt },
|
|
309
|
-
...level > 0 ? { level } : {}
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
const defRPr = pPr.child(A_NS, "defRPr");
|
|
315
|
-
if (defRPr !== void 0) {
|
|
316
|
-
const { baselineShift: _baselineShift, ...restDefRunStyle } = readShapeRunProperties(defRPr, location, diagnostics).style;
|
|
317
|
-
defRunStyle = restDefRunStyle;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
const runs = [];
|
|
321
|
-
for (const child of pCursor.remainingElementChildren()) {
|
|
322
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
|
|
323
|
-
const rPr = child.child(A_NS, "rPr");
|
|
324
|
-
const parsedRPr = rPr === void 0 ? { style: {} } : readShapeRunProperties(rPr, location, diagnostics);
|
|
325
|
-
const t = child.child(A_NS, "t");
|
|
326
|
-
if (t !== void 0) {
|
|
327
|
-
t.consumeAttr("space", XML_NS);
|
|
328
|
-
runs.push({
|
|
329
|
-
kind: parsedRPr.inlineKind ?? "text",
|
|
330
|
-
text: t.textContent,
|
|
331
|
-
style: parsedRPr.style
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
continue;
|
|
335
|
-
}
|
|
336
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
|
|
337
|
-
child.consumeAttr("id");
|
|
338
|
-
const fieldType = child.attr("type");
|
|
339
|
-
const rPr = child.child(A_NS, "rPr");
|
|
340
|
-
const parsedRPr = rPr === void 0 ? { style: {} } : readShapeRunProperties(rPr, location, diagnostics);
|
|
341
|
-
const t = child.child(A_NS, "t");
|
|
342
|
-
if (t !== void 0) t.consumeAttr("space", XML_NS);
|
|
343
|
-
if (fieldType === "slidenum") {
|
|
344
|
-
const fieldStyle = parsedRPr.inlineKind === void 0 ? parsedRPr.style : {
|
|
345
|
-
...parsedRPr.style,
|
|
346
|
-
baselineShift: parsedRPr.inlineKind === "sup" ? "30%" : "-25%"
|
|
347
|
-
};
|
|
348
|
-
runs.push({
|
|
349
|
-
kind: "slidenum",
|
|
350
|
-
style: fieldStyle
|
|
351
|
-
});
|
|
352
|
-
} else {
|
|
353
|
-
diagnostics.push({
|
|
354
|
-
code: "unsupported-mechanism",
|
|
355
|
-
category: "unsupported",
|
|
356
|
-
disposition: "omitted",
|
|
357
|
-
location: {
|
|
358
|
-
...location,
|
|
359
|
-
xpath: child.xpath
|
|
360
|
-
},
|
|
361
|
-
namespaceUri: A_NS,
|
|
362
|
-
localName: "fld",
|
|
363
|
-
mechanismHint: `field:${fieldType ?? "unknown"}`
|
|
364
|
-
});
|
|
365
|
-
if (t !== void 0) runs.push({
|
|
366
|
-
kind: parsedRPr.inlineKind ?? "text",
|
|
367
|
-
text: t.textContent,
|
|
368
|
-
style: parsedRPr.style
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "br") {
|
|
374
|
-
const rPr = child.child(A_NS, "rPr");
|
|
375
|
-
const parsedRPr = rPr === void 0 ? { style: {} } : readShapeRunProperties(rPr, location, diagnostics);
|
|
376
|
-
runs.push({
|
|
377
|
-
kind: parsedRPr.inlineKind ?? "text",
|
|
378
|
-
text: "\n",
|
|
379
|
-
style: parsedRPr.style
|
|
380
|
-
});
|
|
381
|
-
continue;
|
|
382
|
-
}
|
|
383
|
-
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
|
|
384
|
-
readShapeRunProperties(child, location, diagnostics);
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
diagnostics.push({
|
|
388
|
-
code: "unconsumed-xml",
|
|
389
|
-
category: "unsupported",
|
|
390
|
-
disposition: "omitted",
|
|
391
|
-
kind: "element",
|
|
392
|
-
location: {
|
|
393
|
-
...location,
|
|
394
|
-
xpath: child.xpath
|
|
395
|
-
},
|
|
396
|
-
namespaceUri: child.namespaceUri,
|
|
397
|
-
localName: child.localName
|
|
398
|
-
});
|
|
399
|
-
}
|
|
400
|
-
return {
|
|
401
|
-
runs,
|
|
402
|
-
style: {
|
|
403
|
-
...align === void 0 ? {} : { align },
|
|
404
|
-
...lineHeight === void 0 ? {} : { lineHeight },
|
|
405
|
-
...spacingAfter === void 0 ? {} : { spacingAfter },
|
|
406
|
-
...list === void 0 ? {} : { list }
|
|
407
|
-
},
|
|
408
|
-
...defRunStyle === void 0 ? {} : { defRunStyle }
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
function readShapeTxBody(txBodyCursor, location, diagnostics) {
|
|
412
|
-
let paddingTop;
|
|
413
|
-
let paddingRight;
|
|
414
|
-
let paddingBottom;
|
|
415
|
-
let paddingLeft;
|
|
416
|
-
let verticalAlign;
|
|
417
|
-
let textWrap;
|
|
418
|
-
const bodyPr = txBodyCursor.child(A_NS, "bodyPr");
|
|
419
|
-
if (bodyPr !== void 0) {
|
|
420
|
-
const rawBodyPr = bodyPr.attrsObject([
|
|
421
|
-
"wrap",
|
|
422
|
-
"rtlCol",
|
|
423
|
-
"lIns",
|
|
424
|
-
"tIns",
|
|
425
|
-
"rIns",
|
|
426
|
-
"bIns",
|
|
427
|
-
"anchor"
|
|
428
|
-
]);
|
|
429
|
-
const parsedBodyPr = BodyPrAttrSchema.safeParse(rawBodyPr);
|
|
430
|
-
if (!parsedBodyPr.success) diagnostics.push({
|
|
431
|
-
code: "invalid-xml-value",
|
|
432
|
-
category: "corrupt-input",
|
|
433
|
-
disposition: "recovered",
|
|
434
|
-
location: {
|
|
435
|
-
...location,
|
|
436
|
-
xpath: bodyPr.xpath
|
|
437
|
-
},
|
|
438
|
-
attributeOrElement: "a:bodyPr",
|
|
439
|
-
rawValue: JSON.stringify(rawBodyPr)
|
|
440
|
-
});
|
|
441
|
-
else {
|
|
442
|
-
const b = parsedBodyPr.data;
|
|
443
|
-
if (b.wrap === "none") textWrap = "nowrap";
|
|
444
|
-
else if (b.wrap === "square") textWrap = "normal";
|
|
445
|
-
if (b.anchor !== void 0) verticalAlign = anchorToVerticalAlign[b.anchor];
|
|
446
|
-
}
|
|
447
|
-
const insets = readOoxmlBoxInsets({
|
|
448
|
-
rawAttrs: rawBodyPr,
|
|
449
|
-
attrNames: {
|
|
450
|
-
left: "lIns",
|
|
451
|
-
top: "tIns",
|
|
452
|
-
right: "rIns",
|
|
453
|
-
bottom: "bIns"
|
|
454
|
-
},
|
|
455
|
-
elementXpath: bodyPr.xpath,
|
|
456
|
-
location,
|
|
457
|
-
diagnostics
|
|
458
|
-
});
|
|
459
|
-
paddingLeft = insets.paddingLeft;
|
|
460
|
-
paddingTop = insets.paddingTop;
|
|
461
|
-
paddingRight = insets.paddingRight;
|
|
462
|
-
paddingBottom = insets.paddingBottom;
|
|
463
|
-
bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
|
|
464
|
-
bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
|
|
465
|
-
}
|
|
466
|
-
txBodyCursor.ignoreEmptyChild(A_NS, "lstStyle");
|
|
467
|
-
const paragraphs = txBodyCursor.children(A_NS, "p").map((pCursor) => readShapeParagraph(pCursor, location, diagnostics));
|
|
468
|
-
return {
|
|
469
|
-
...paddingTop === void 0 ? {} : { paddingTop },
|
|
470
|
-
...paddingRight === void 0 ? {} : { paddingRight },
|
|
471
|
-
...paddingBottom === void 0 ? {} : { paddingBottom },
|
|
472
|
-
...paddingLeft === void 0 ? {} : { paddingLeft },
|
|
473
|
-
...verticalAlign === void 0 ? {} : { verticalAlign },
|
|
474
|
-
...textWrap === void 0 ? {} : { textWrap },
|
|
475
|
-
paragraphs
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Reads a Transitional `<p:sp>` native shape (preset or custom geometry, fills, borders, effects,
|
|
480
|
-
* transforms, hyperlink, and optional rich text body) into an editable `ShapeNode`.
|
|
481
|
-
*/
|
|
482
|
-
function readShapeSp(context, mapBox) {
|
|
483
|
-
const { cursor, part, slideIndex, package: pkg } = context;
|
|
484
|
-
const diagnostics = [];
|
|
485
|
-
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
486
|
-
if (nvSpPr === void 0) {
|
|
487
|
-
diagnostics.push({
|
|
488
|
-
code: "corrupt-part",
|
|
489
|
-
category: "corrupt-input",
|
|
490
|
-
disposition: "omitted",
|
|
491
|
-
location: {
|
|
492
|
-
part,
|
|
493
|
-
xpath: cursor.xpath,
|
|
494
|
-
slideIndex
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
return { diagnostics };
|
|
498
|
-
}
|
|
499
|
-
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(nvSpPr.child(P_NS, "cNvPr"), context, diagnostics);
|
|
500
|
-
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
501
|
-
if (cNvSpPr !== void 0) cNvSpPr.consumeAttr("txBox");
|
|
502
|
-
consumeNonPlaceholderNvPr(nvSpPr);
|
|
503
|
-
const location = {
|
|
504
|
-
part,
|
|
505
|
-
slideIndex,
|
|
506
|
-
...objectId === void 0 ? {} : { objectId },
|
|
507
|
-
...objectName === void 0 ? {} : { objectName }
|
|
508
|
-
};
|
|
509
|
-
const spPr = cursor.child(P_NS, "spPr");
|
|
510
|
-
if (spPr === void 0) {
|
|
511
|
-
diagnostics.push({
|
|
512
|
-
code: "corrupt-part",
|
|
513
|
-
category: "corrupt-input",
|
|
514
|
-
disposition: "omitted",
|
|
515
|
-
location: {
|
|
516
|
-
...location,
|
|
517
|
-
xpath: cursor.xpath
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
return { diagnostics };
|
|
521
|
-
}
|
|
522
|
-
const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
|
|
523
|
-
if (visuals === void 0) return { diagnostics };
|
|
524
|
-
const mappedBox = mapBox ? mapBox({
|
|
525
|
-
x: visuals.transform.x,
|
|
526
|
-
y: visuals.transform.y,
|
|
527
|
-
width: visuals.transform.width,
|
|
528
|
-
height: visuals.transform.height
|
|
529
|
-
}) : {
|
|
530
|
-
x: visuals.transform.x,
|
|
531
|
-
y: visuals.transform.y,
|
|
532
|
-
width: visuals.transform.width,
|
|
533
|
-
height: visuals.transform.height
|
|
534
|
-
};
|
|
535
|
-
const txBody = cursor.child(P_NS, "txBody");
|
|
536
|
-
const importedText = txBody === void 0 ? void 0 : readShapeTxBody(txBody, location, diagnostics);
|
|
537
|
-
const singleParagraph = importedText !== void 0 && importedText.paragraphs.length === 1 ? importedText.paragraphs[0] : void 0;
|
|
538
|
-
const isSingleEmptyParagraph = singleParagraph !== void 0 && singleParagraph.runs.length === 0 && singleParagraph.style.list === void 0;
|
|
539
|
-
const singlePlainRun = singleParagraph !== void 0 && singleParagraph.style.list === void 0 && singleParagraph.runs.length === 1 && singleParagraph.runs[0].kind === "text" && singleParagraph.runs[0].style.baselineShift === void 0 ? singleParagraph.runs[0] : void 0;
|
|
540
|
-
const hasStyledEmptyParagraph = isSingleEmptyParagraph && singleParagraph.defRunStyle !== void 0;
|
|
541
|
-
const hasEffectiveText = singlePlainRun !== void 0 && singlePlainRun.text !== "" || importedText !== void 0 && singlePlainRun === void 0 && !isSingleEmptyParagraph && importedText.paragraphs.length > 0;
|
|
542
|
-
const hasEffectiveTextBody = hasEffectiveText || hasStyledEmptyParagraph;
|
|
543
|
-
const emptyParagraphTextStyle = hasStyledEmptyParagraph && singleParagraph !== void 0 ? (() => {
|
|
544
|
-
const { list: _list, ...restPStyle } = singleParagraph.style;
|
|
545
|
-
return {
|
|
546
|
-
...restPStyle,
|
|
547
|
-
...singleParagraph.defRunStyle
|
|
548
|
-
};
|
|
549
|
-
})() : void 0;
|
|
550
|
-
const { border: rawBorder, ...restVisualStyle } = visuals.style;
|
|
551
|
-
if (visuals.borderArrows !== void 0) diagnostics.push({
|
|
552
|
-
code: "unsupported-mechanism",
|
|
553
|
-
category: "unsupported",
|
|
554
|
-
disposition: "omitted",
|
|
555
|
-
location,
|
|
556
|
-
namespaceUri: A_NS,
|
|
557
|
-
localName: visuals.borderArrows.startArrow !== void 0 ? "headEnd" : "tailEnd",
|
|
558
|
-
mechanismHint: "shape-line-arrow"
|
|
559
|
-
});
|
|
560
|
-
const effectiveVisualStyle = rawBorder === "none" ? restVisualStyle : visuals.style;
|
|
561
|
-
const singlePlainTextStyle = hasEffectiveText && singlePlainRun !== void 0 && singleParagraph !== void 0 ? (() => {
|
|
562
|
-
const { list: _list, ...restPStyle } = singleParagraph.style;
|
|
563
|
-
const { baselineShift: _baselineShift, ...restRunStyle } = singlePlainRun.style;
|
|
564
|
-
return {
|
|
565
|
-
...restPStyle,
|
|
566
|
-
...restRunStyle
|
|
567
|
-
};
|
|
568
|
-
})() : void 0;
|
|
569
|
-
const shapeStyle = {
|
|
570
|
-
position: "absolute",
|
|
571
|
-
left: mappedBox.x,
|
|
572
|
-
top: mappedBox.y,
|
|
573
|
-
width: mappedBox.width,
|
|
574
|
-
height: mappedBox.height,
|
|
575
|
-
...effectiveVisualStyle,
|
|
576
|
-
...hasEffectiveTextBody && importedText?.paddingTop !== void 0 ? { paddingTop: importedText.paddingTop } : {},
|
|
577
|
-
...hasEffectiveTextBody && importedText?.paddingRight !== void 0 ? { paddingRight: importedText.paddingRight } : {},
|
|
578
|
-
...hasEffectiveTextBody && importedText?.paddingBottom !== void 0 ? { paddingBottom: importedText.paddingBottom } : {},
|
|
579
|
-
...hasEffectiveTextBody && importedText?.paddingLeft !== void 0 ? { paddingLeft: importedText.paddingLeft } : {},
|
|
580
|
-
...hasEffectiveTextBody && importedText?.verticalAlign !== void 0 ? { verticalAlign: importedText.verticalAlign } : {},
|
|
581
|
-
...hasEffectiveTextBody && importedText?.textWrap !== void 0 ? { textWrap: importedText.textWrap } : {},
|
|
582
|
-
...singlePlainTextStyle,
|
|
583
|
-
...emptyParagraphTextStyle
|
|
584
|
-
};
|
|
585
|
-
const props = {
|
|
586
|
-
...objectName === void 0 ? {} : { name: objectName },
|
|
587
|
-
...link === void 0 ? {} : { link },
|
|
588
|
-
...visuals.geometry === void 0 ? {} : { geometry: visuals.geometry },
|
|
589
|
-
style: shapeStyle
|
|
590
|
-
};
|
|
591
|
-
const node = createShapeNode(props);
|
|
592
|
-
if (hasStyledEmptyParagraph) node.content("");
|
|
593
|
-
else if (hasEffectiveText && singlePlainRun !== void 0) node.content(singlePlainRun.text);
|
|
594
|
-
else if (hasEffectiveText && importedText !== void 0 && singlePlainRun === void 0 && importedText.paragraphs.length > 0) {
|
|
595
|
-
const paragraphNodes = importedText.paragraphs.map((para) => {
|
|
596
|
-
const pProps = Object.keys(para.style).length === 0 ? {} : { style: para.style };
|
|
597
|
-
const pNode = createParagraphNode(pProps);
|
|
598
|
-
if (para.runs.length === 1 && para.runs[0].kind === "text" && Object.keys(para.runs[0].style).length === 0) pNode.content(para.runs[0].text);
|
|
599
|
-
else pNode.content(...para.runs.map((run) => {
|
|
600
|
-
if (run.kind === "slidenum") return createSlideNumberNode(Object.keys(run.style).length === 0 ? {} : { style: run.style });
|
|
601
|
-
const runProps = Object.keys(run.style).length === 0 ? {} : { style: run.style };
|
|
602
|
-
if (run.kind === "sup") return createSupNode(runProps).content(run.text);
|
|
603
|
-
if (run.kind === "sub") return createSubNode(runProps).content(run.text);
|
|
604
|
-
return Object.keys(run.style).length === 0 ? run.text : createSpanNode({ style: run.style }).content(run.text);
|
|
605
|
-
}));
|
|
606
|
-
return pNode;
|
|
607
|
-
});
|
|
608
|
-
node.content(...paragraphNodes);
|
|
609
|
-
}
|
|
610
|
-
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
611
|
-
return {
|
|
612
|
-
node,
|
|
613
|
-
diagnostics
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
const presetShapeImportHandler = {
|
|
617
|
-
target: "shape-tree",
|
|
618
|
-
localName: "sp",
|
|
619
|
-
matches: isPresetShapeSpElement,
|
|
620
|
-
read: (context) => readShapeSp(context)
|
|
621
|
-
};
|
|
622
|
-
const customGeometryShapeImportHandler = {
|
|
623
|
-
target: "shape-tree",
|
|
624
|
-
localName: "sp",
|
|
625
|
-
matches: isCustomGeometryShapeSpElement,
|
|
626
|
-
read: (context) => readShapeSp(context)
|
|
627
|
-
};
|
|
628
|
-
export { customGeometryShapeImportHandler, isCustomGeometryShapeSpElement, isPresetShapeSpElement, presetShapeImportHandler, readNonVisualCommonProperties, readShapeSp };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { slideBackgroundSchema } from "../../../core/dist/author-schemas.js";
|
|
2
|
-
import "../../../codegen/dist/index.js";
|
|
3
|
-
import { defineSlideCodegen, expr } from "../../../codegen/dist/types.js";
|
|
4
|
-
import "../../../core/dist/capability.js";
|
|
5
|
-
import { serializeImageDescriptorValue } from "../image/image-codegen.js";
|
|
6
|
-
// ../capabilities/dist/slide-background/slide-background-codegen.js
|
|
7
|
-
function isPlainObject(value) {
|
|
8
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
9
|
-
const proto = Object.getPrototypeOf(value);
|
|
10
|
-
return proto === Object.prototype || proto === null;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Serializes `LinearGradient` and `RadialGradient` author values back into `linearGradient(...)`
|
|
14
|
-
* and `radialGradient(...)` calls so gradients in `Slide.background` and `VisualStyle.background`
|
|
15
|
-
* round-trip idiomatically.
|
|
16
|
-
*/
|
|
17
|
-
function serializeGradientValue(value, ctx) {
|
|
18
|
-
if (!isPlainObject(value)) return void 0;
|
|
19
|
-
const type = value["type"];
|
|
20
|
-
if (type !== "linear-gradient" && type !== "radial-gradient") return;
|
|
21
|
-
const definedKeys = Object.keys(value).filter((key) => value[key] !== void 0);
|
|
22
|
-
const subPath = ctx.path.includes("@") ? void 0 : "@style.background";
|
|
23
|
-
if (type === "linear-gradient") {
|
|
24
|
-
if (!definedKeys.every((key) => key === "type" || key === "angle" || key === "stops") || typeof value["angle"] !== "number" || !Array.isArray(value["stops"])) return;
|
|
25
|
-
const fn = ctx.useImport("linearGradient");
|
|
26
|
-
const angleExpr = ctx.emitValueExpr(value["angle"], subPath);
|
|
27
|
-
const stopExprs = value["stops"].map((stop) => ctx.emitValueExpr(stop, subPath));
|
|
28
|
-
return expr(ctx.formatVanillaCall(fn, [angleExpr, ...stopExprs]));
|
|
29
|
-
}
|
|
30
|
-
if (!definedKeys.every((key) => key === "type" || key === "stops") || !Array.isArray(value["stops"])) return;
|
|
31
|
-
const fn = ctx.useImport("radialGradient");
|
|
32
|
-
const stopExprs = value["stops"].map((stop) => ctx.emitValueExpr(stop, subPath));
|
|
33
|
-
return expr(ctx.formatVanillaCall(fn, stopExprs));
|
|
34
|
-
}
|
|
35
|
-
/** Source codegen contribution for `Slide.background` / `SlideMaster.background` / `SlideLayout.background` and gradients. */
|
|
36
|
-
const slideBackgroundCodegen = defineSlideCodegen({
|
|
37
|
-
slideProps: { background: (value, ctx) => {
|
|
38
|
-
const parsed = slideBackgroundSchema.safeParse(value);
|
|
39
|
-
if (!parsed.success) ctx.fail("unexpressible-value", parsed.error.issues[0]?.message ?? "Slide.background declaration is invalid");
|
|
40
|
-
return expr(ctx.emitValueExpr(parsed.data));
|
|
41
|
-
} },
|
|
42
|
-
valueSerializers: [serializeGradientValue, serializeImageDescriptorValue]
|
|
43
|
-
});
|
|
44
|
-
export { serializeGradientValue, slideBackgroundCodegen };
|