@officedk/pptxdk 0.2.0 → 0.2.2
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 +8 -7
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
import { EMU_PER_PX } from "../../kernel/drawing-units.js";
|
|
2
|
+
import { placeholderStyleSchema } from "../../kernel/placeholders.js";
|
|
3
|
+
import { populateRichTextNode, promoteSingleParagraph, readRichTextBody, textFieldDateTimeImportHandler, textFieldSlideNumImportHandler } from "../shared/rich-text-import.js";
|
|
4
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
5
|
+
import { ooxmlBoolSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
6
|
+
import { readPlaceholderTransform } from "../../kernel/pptx-read/visual.js";
|
|
7
|
+
import { attachDeferredSlideLink, consumeNonPlaceholderNvPr, readNonVisualCommonProperties } from "../shared/identity.js";
|
|
8
|
+
import { directElementChild, directPlaceholderElement, emitPlaceholderUnbindDiagnostic, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, stripPlaceholderClearSentinels } from "../shared/placeholder-import.js";
|
|
9
|
+
import { resolvePlaceholderBaseTextStyle, resolvePlaceholderLevelTextStyle } from "../shared/style-inheritance.js";
|
|
10
|
+
import { createTextNode } from "../shared/text-declaration.js";
|
|
11
|
+
import { isInlineTextFieldNodeType, textBoxStyleSchema } from "../shared/text-schemas.js";
|
|
12
|
+
import { hasVisibleBoxStyle, readSpPrAppearance, readSpPrVisuals } from "../shared/visual.js";
|
|
13
|
+
import "../../kernel/capability.js";
|
|
14
|
+
import "../../kernel/pptx-read/index.js";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
// ../core/dist/capabilities/text/text-import.js
|
|
17
|
+
const NonVisualSpPrFlagsSchema = z.object({ txBox: ooxmlBoolSchema.optional() });
|
|
18
|
+
const footerPlaceholderRoles = /* @__PURE__ */ new Set([
|
|
19
|
+
"dt",
|
|
20
|
+
"ftr",
|
|
21
|
+
"sldNum"
|
|
22
|
+
]);
|
|
23
|
+
/** Side-effect-free predicate distinguishing `<p:sp>` text boxes (`txBox="1"`) from shapes and placeholders. */
|
|
24
|
+
function isTextBoxSpElement(cursor) {
|
|
25
|
+
const nvSpPr = directElementChild(cursor.element, P_NS, "nvSpPr");
|
|
26
|
+
if (nvSpPr === void 0) return false;
|
|
27
|
+
const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
|
|
28
|
+
if (cNvSpPr === void 0) return false;
|
|
29
|
+
const txBox = cNvSpPr.getAttribute("txBox");
|
|
30
|
+
return txBox === "1" || txBox === "true";
|
|
31
|
+
}
|
|
32
|
+
/** Side-effect-free predicate matching non-footer populated `<p:sp>` placeholder elements. */
|
|
33
|
+
function isTextPlaceholderSpElement(cursor) {
|
|
34
|
+
const ph = directPlaceholderElement(cursor, "nvSpPr");
|
|
35
|
+
if (ph === void 0) return false;
|
|
36
|
+
if (directElementChild(cursor.element, "http://schemas.openxmlformats.org/presentationml/2006/main", "txBody") === void 0) return false;
|
|
37
|
+
const rawType = ph.getAttribute("type");
|
|
38
|
+
const role = rawType === null || rawType === "" ? "obj" : rawType;
|
|
39
|
+
return !footerPlaceholderRoles.has(role) || role === "dt" && isTextBoxSpElement(cursor);
|
|
40
|
+
}
|
|
41
|
+
function textBoxVisualStyle(appearanceStyle, borderArrows, geometry, boxSize, rotate, location, diagnostics) {
|
|
42
|
+
const { border: rawBorder, ...restVisualStyle } = appearanceStyle;
|
|
43
|
+
const border = rawBorder;
|
|
44
|
+
const hasHeadArrow = borderArrows?.startArrow !== void 0;
|
|
45
|
+
const hasTailArrow = borderArrows?.endArrow !== void 0;
|
|
46
|
+
if (hasHeadArrow || hasTailArrow) diagnostics.push({
|
|
47
|
+
code: "unsupported-mechanism",
|
|
48
|
+
category: "unsupported",
|
|
49
|
+
disposition: "omitted",
|
|
50
|
+
location,
|
|
51
|
+
namespaceUri: A_NS,
|
|
52
|
+
localName: hasHeadArrow ? "headEnd" : "tailEnd",
|
|
53
|
+
mechanismHint: "textbox-line-arrow"
|
|
54
|
+
});
|
|
55
|
+
let borderRadius;
|
|
56
|
+
if (geometry === "roundRect") {
|
|
57
|
+
if (boxSize !== void 0) borderRadius = 16667 / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
58
|
+
} else if (typeof geometry === "object" && geometry.type === "preset") {
|
|
59
|
+
if (geometry.name === "roundRect") {
|
|
60
|
+
if (boxSize !== void 0) {
|
|
61
|
+
const adj = geometry.adjust?.["adj"] ?? 16667;
|
|
62
|
+
if (adj > 0) borderRadius = adj / 1e5 * Math.min(boxSize.width, boxSize.height);
|
|
63
|
+
}
|
|
64
|
+
} else if (geometry.name !== "rect") diagnostics.push({
|
|
65
|
+
code: "unsupported-mechanism",
|
|
66
|
+
category: "unsupported",
|
|
67
|
+
disposition: "omitted",
|
|
68
|
+
location,
|
|
69
|
+
namespaceUri: A_NS,
|
|
70
|
+
localName: "prstGeom",
|
|
71
|
+
mechanismHint: `textbox-preset:${geometry.name}`
|
|
72
|
+
});
|
|
73
|
+
} else if (typeof geometry === "object" && geometry.type === "custom") diagnostics.push({
|
|
74
|
+
code: "unsupported-mechanism",
|
|
75
|
+
category: "unsupported",
|
|
76
|
+
disposition: "omitted",
|
|
77
|
+
location,
|
|
78
|
+
namespaceUri: A_NS,
|
|
79
|
+
localName: "custGeom",
|
|
80
|
+
mechanismHint: "textbox-custGeom"
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
...restVisualStyle,
|
|
84
|
+
...border === void 0 ? {} : { border },
|
|
85
|
+
...borderRadius === void 0 ? {} : { borderRadius },
|
|
86
|
+
...rotate === void 0 ? {} : { rotate }
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function flattenImportedTextBody(imported, visualStyle) {
|
|
90
|
+
const importedParagraphs = imported?.importedParagraphs ?? [];
|
|
91
|
+
const promoted = promoteSingleParagraph(importedParagraphs);
|
|
92
|
+
const boxStyle = {
|
|
93
|
+
...imported?.boxStyle,
|
|
94
|
+
...visualStyle,
|
|
95
|
+
...promoted?.style
|
|
96
|
+
};
|
|
97
|
+
if (promoted?.text !== void 0) return {
|
|
98
|
+
boxStyle,
|
|
99
|
+
singleText: promoted.text
|
|
100
|
+
};
|
|
101
|
+
if (promoted === void 0 && importedParagraphs.length > 0) return {
|
|
102
|
+
boxStyle,
|
|
103
|
+
paragraphsToPopulate: importedParagraphs
|
|
104
|
+
};
|
|
105
|
+
return { boxStyle };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Reads a Transitional `<p:sp>` text box (`<p:cNvSpPr txBox="1"/>` without `<p:ph>`) into an editable `TextNode`.
|
|
109
|
+
*/
|
|
110
|
+
function readTextBoxSp(context) {
|
|
111
|
+
const { cursor, part, slideIndex, package: pkg } = context;
|
|
112
|
+
const diagnostics = [];
|
|
113
|
+
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
114
|
+
if (nvSpPr === void 0) {
|
|
115
|
+
diagnostics.push({
|
|
116
|
+
code: "corrupt-part",
|
|
117
|
+
category: "corrupt-input",
|
|
118
|
+
disposition: "omitted",
|
|
119
|
+
location: {
|
|
120
|
+
part,
|
|
121
|
+
xpath: cursor.xpath,
|
|
122
|
+
slideIndex
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return { diagnostics };
|
|
126
|
+
}
|
|
127
|
+
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
128
|
+
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
129
|
+
cNvPr?.ignoreEmptyChild(A_NS, "extLst");
|
|
130
|
+
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
131
|
+
if (cNvSpPr !== void 0) {
|
|
132
|
+
const rawFlags = cNvSpPr.attrsObject(["txBox"]);
|
|
133
|
+
NonVisualSpPrFlagsSchema.safeParse(rawFlags);
|
|
134
|
+
cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
|
|
135
|
+
"noGrp",
|
|
136
|
+
"noRot",
|
|
137
|
+
"noChangeAspect",
|
|
138
|
+
"noMove",
|
|
139
|
+
"noResize",
|
|
140
|
+
"noSelect"
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
consumeNonPlaceholderNvPr(nvSpPr);
|
|
144
|
+
const location = {
|
|
145
|
+
part,
|
|
146
|
+
slideIndex,
|
|
147
|
+
...objectId === void 0 ? {} : { objectId },
|
|
148
|
+
...objectName === void 0 ? {} : { objectName }
|
|
149
|
+
};
|
|
150
|
+
const spPr = cursor.child(P_NS, "spPr");
|
|
151
|
+
const txBody = cursor.child(P_NS, "txBody");
|
|
152
|
+
if (spPr === void 0 || txBody === void 0) {
|
|
153
|
+
diagnostics.push({
|
|
154
|
+
code: "corrupt-part",
|
|
155
|
+
category: "corrupt-input",
|
|
156
|
+
disposition: "omitted",
|
|
157
|
+
location: {
|
|
158
|
+
...location,
|
|
159
|
+
xpath: cursor.xpath
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return { diagnostics };
|
|
163
|
+
}
|
|
164
|
+
const visuals = readSpPrVisuals(spPr, pkg, location, diagnostics);
|
|
165
|
+
if (visuals === void 0) return { diagnostics };
|
|
166
|
+
const { background: rawBg, border: rawBorder, ...restFreeVisuals } = textBoxVisualStyle(visuals.style, visuals.borderArrows, visuals.geometry, {
|
|
167
|
+
width: visuals.transform.width,
|
|
168
|
+
height: visuals.transform.height
|
|
169
|
+
}, visuals.transform.rotate, location, diagnostics);
|
|
170
|
+
const visualStyle = {
|
|
171
|
+
...restFreeVisuals,
|
|
172
|
+
...rawBg === void 0 || rawBg === "none" ? {} : { background: rawBg },
|
|
173
|
+
...rawBorder === void 0 || rawBorder === "none" ? {} : { border: rawBorder }
|
|
174
|
+
};
|
|
175
|
+
const { boxStyle, singleText, paragraphsToPopulate } = flattenImportedTextBody(readRichTextBody(txBody, location, diagnostics), visualStyle);
|
|
176
|
+
const props = {
|
|
177
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
178
|
+
...link === void 0 ? {} : { link },
|
|
179
|
+
style: {
|
|
180
|
+
position: "absolute",
|
|
181
|
+
left: visuals.transform.x,
|
|
182
|
+
top: visuals.transform.y,
|
|
183
|
+
width: visuals.transform.width,
|
|
184
|
+
height: visuals.transform.height,
|
|
185
|
+
...boxStyle
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const node = createTextNode(props);
|
|
189
|
+
if (singleText !== void 0) node.content(singleText);
|
|
190
|
+
else if (paragraphsToPopulate !== void 0) populateRichTextNode(node, paragraphsToPopulate);
|
|
191
|
+
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
192
|
+
return {
|
|
193
|
+
node,
|
|
194
|
+
diagnostics
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Reads a Transitional `<p:sp>` bound placeholder (`<p:nvPr><p:ph .../></p:nvPr>`)
|
|
199
|
+
* into a layout-bound `TextNode` preserving differential transforms and styles.
|
|
200
|
+
*/
|
|
201
|
+
function readTextPlaceholderSp(context) {
|
|
202
|
+
const { cursor, part, slideIndex, package: pkg } = context;
|
|
203
|
+
const diagnostics = [];
|
|
204
|
+
const nvSpPr = cursor.child(P_NS, "nvSpPr");
|
|
205
|
+
if (nvSpPr === void 0) {
|
|
206
|
+
diagnostics.push({
|
|
207
|
+
code: "corrupt-part",
|
|
208
|
+
category: "corrupt-input",
|
|
209
|
+
disposition: "omitted",
|
|
210
|
+
location: {
|
|
211
|
+
part,
|
|
212
|
+
xpath: cursor.xpath,
|
|
213
|
+
slideIndex
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
return { diagnostics };
|
|
217
|
+
}
|
|
218
|
+
const cNvPr = nvSpPr.child(P_NS, "cNvPr");
|
|
219
|
+
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
220
|
+
cNvPr?.ignoreEmptyChild(A_NS, "extLst");
|
|
221
|
+
const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
|
|
222
|
+
if (cNvSpPr !== void 0) {
|
|
223
|
+
cNvSpPr.consumeAttr("txBox");
|
|
224
|
+
cNvSpPr.child(A_NS, "spLocks")?.attrsObject([
|
|
225
|
+
"noGrp",
|
|
226
|
+
"noRot",
|
|
227
|
+
"noChangeAspect",
|
|
228
|
+
"noMove",
|
|
229
|
+
"noResize",
|
|
230
|
+
"noSelect"
|
|
231
|
+
]);
|
|
232
|
+
}
|
|
233
|
+
const location = {
|
|
234
|
+
part,
|
|
235
|
+
slideIndex,
|
|
236
|
+
...objectId === void 0 ? {} : { objectId },
|
|
237
|
+
...objectName === void 0 ? {} : { objectName }
|
|
238
|
+
};
|
|
239
|
+
const nvPr = nvSpPr.child(P_NS, "nvPr");
|
|
240
|
+
const phResult = readNvPrPlaceholder(nvPr, {
|
|
241
|
+
...location,
|
|
242
|
+
xpath: cursor.xpath
|
|
243
|
+
}, diagnostics);
|
|
244
|
+
if (phResult.kind === "none") {
|
|
245
|
+
diagnostics.push({
|
|
246
|
+
code: "corrupt-part",
|
|
247
|
+
category: "corrupt-input",
|
|
248
|
+
disposition: "omitted",
|
|
249
|
+
location: {
|
|
250
|
+
...location,
|
|
251
|
+
xpath: cursor.xpath
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
return { diagnostics };
|
|
255
|
+
}
|
|
256
|
+
if (phResult.kind === "error") return { diagnostics };
|
|
257
|
+
const nativeRef = phResult.nativeRef;
|
|
258
|
+
const spPr = cursor.child(P_NS, "spPr");
|
|
259
|
+
if (spPr === void 0) {
|
|
260
|
+
diagnostics.push({
|
|
261
|
+
code: "corrupt-part",
|
|
262
|
+
category: "corrupt-input",
|
|
263
|
+
disposition: "omitted",
|
|
264
|
+
location: {
|
|
265
|
+
...location,
|
|
266
|
+
xpath: cursor.xpath
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
return { diagnostics };
|
|
270
|
+
}
|
|
271
|
+
const { offset, extent, rotate, flipH, flipV } = readPlaceholderTransform(spPr.child(A_NS, "xfrm"), location, diagnostics);
|
|
272
|
+
const claim = resolvePlaceholderImportClaim({
|
|
273
|
+
context,
|
|
274
|
+
nativeRef,
|
|
275
|
+
objectKind: "text"
|
|
276
|
+
});
|
|
277
|
+
const layoutPlaceholder = claim.layoutPlaceholder;
|
|
278
|
+
const masterPlaceholder = claim.masterPlaceholder;
|
|
279
|
+
const layoutPhWidth = typeof layoutPlaceholder?.style?.width === "number" ? layoutPlaceholder.style.width : void 0;
|
|
280
|
+
const layoutPhHeight = typeof layoutPlaceholder?.style?.height === "number" ? layoutPlaceholder.style.height : void 0;
|
|
281
|
+
const masterPhWidth = typeof masterPlaceholder?.style?.width === "number" ? masterPlaceholder.style.width : void 0;
|
|
282
|
+
const masterPhHeight = typeof masterPlaceholder?.style?.height === "number" ? masterPlaceholder.style.height : void 0;
|
|
283
|
+
const inheritedWidth = layoutPhWidth ?? masterPhWidth;
|
|
284
|
+
const inheritedHeight = layoutPhHeight ?? masterPhHeight;
|
|
285
|
+
const boxSize = extent ?? (inheritedWidth !== void 0 && inheritedHeight !== void 0 ? {
|
|
286
|
+
width: inheritedWidth,
|
|
287
|
+
height: inheritedHeight
|
|
288
|
+
} : void 0);
|
|
289
|
+
const effectiveFallbackUnits = boxSize === void 0 ? {
|
|
290
|
+
w: 0,
|
|
291
|
+
h: 0
|
|
292
|
+
} : {
|
|
293
|
+
w: Math.round(boxSize.width * EMU_PER_PX),
|
|
294
|
+
h: Math.round(boxSize.height * EMU_PER_PX)
|
|
295
|
+
};
|
|
296
|
+
const appearance = readSpPrAppearance(spPr, pkg, effectiveFallbackUnits, location, diagnostics, { preservePlaceholderClears: true });
|
|
297
|
+
const visualStyle = textBoxVisualStyle(appearance.style, appearance.borderArrows, appearance.geometry, boxSize, rotate, location, diagnostics);
|
|
298
|
+
const txBody = cursor.child(P_NS, "txBody");
|
|
299
|
+
const textLevels = context.placeholderTextLevels?.(nativeRef);
|
|
300
|
+
const imported = txBody === void 0 ? void 0 : readRichTextBody(txBody, location, diagnostics, claim.bound ? "placeholder" : "unbound-placeholder", textLevels?.map((level) => level.decoration));
|
|
301
|
+
if (!claim.bound) {
|
|
302
|
+
const resolvedBox = resolveUnboundPlaceholderBox({
|
|
303
|
+
inheritanceContext: claim.inheritanceContext,
|
|
304
|
+
localBox: {
|
|
305
|
+
...offset,
|
|
306
|
+
...extent
|
|
307
|
+
},
|
|
308
|
+
requireHeight: false
|
|
309
|
+
});
|
|
310
|
+
if (resolvedBox === void 0) {
|
|
311
|
+
emitPlaceholderUnbindDiagnostic({
|
|
312
|
+
diagnostics,
|
|
313
|
+
location: {
|
|
314
|
+
...location,
|
|
315
|
+
xpath: cursor.xpath
|
|
316
|
+
},
|
|
317
|
+
retainedAs: "omitted"
|
|
318
|
+
});
|
|
319
|
+
return { diagnostics };
|
|
320
|
+
}
|
|
321
|
+
const freeVisualStyle = materializeUnboundVisualStyle({
|
|
322
|
+
inheritanceContext: claim.inheritanceContext,
|
|
323
|
+
localVisualStyle: {
|
|
324
|
+
...visualStyle,
|
|
325
|
+
...flipH === void 0 ? {} : { flipH },
|
|
326
|
+
...flipV === void 0 ? {} : { flipV }
|
|
327
|
+
},
|
|
328
|
+
...appearance.geometry === void 0 ? {} : { localGeometry: appearance.geometry },
|
|
329
|
+
boxSize: {
|
|
330
|
+
width: resolvedBox.width,
|
|
331
|
+
height: resolvedBox.height ?? 100
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
if (!imported?.importedParagraphs.some(({ runs }) => runs.some((run) => isInlineTextFieldNodeType(run.kind) || "text" in run && run.text.length > 0)) && !hasVisibleBoxStyle(freeVisualStyle)) {
|
|
335
|
+
emitPlaceholderUnbindDiagnostic({
|
|
336
|
+
diagnostics,
|
|
337
|
+
location: {
|
|
338
|
+
...location,
|
|
339
|
+
xpath: cursor.xpath
|
|
340
|
+
},
|
|
341
|
+
retainedAs: "omitted"
|
|
342
|
+
});
|
|
343
|
+
return { diagnostics };
|
|
344
|
+
}
|
|
345
|
+
const baseTextStyle = resolvePlaceholderBaseTextStyle(claim.inheritanceContext, imported?.boxStyle);
|
|
346
|
+
const freeParagraphs = (imported?.importedParagraphs ?? []).map((para) => {
|
|
347
|
+
const { list, ...inherited } = resolvePlaceholderLevelTextStyle(claim.inheritanceContext, para.level0 ?? 0, void 0);
|
|
348
|
+
return {
|
|
349
|
+
...para,
|
|
350
|
+
style: {
|
|
351
|
+
...inherited,
|
|
352
|
+
...list === void 0 || para.buNone || textLevels?.[para.level0 ?? 0]?.buNone ? {} : { list },
|
|
353
|
+
...para.style
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
});
|
|
357
|
+
const promoted = promoteSingleParagraph(freeParagraphs);
|
|
358
|
+
const combinedFreeStyle = stripPlaceholderClearSentinels({
|
|
359
|
+
...baseTextStyle,
|
|
360
|
+
...promoted?.style,
|
|
361
|
+
...freeVisualStyle,
|
|
362
|
+
position: "absolute",
|
|
363
|
+
left: resolvedBox.x,
|
|
364
|
+
top: resolvedBox.y,
|
|
365
|
+
width: resolvedBox.width,
|
|
366
|
+
...resolvedBox.height === void 0 ? {} : { height: resolvedBox.height }
|
|
367
|
+
});
|
|
368
|
+
const parsedFreeStyle = textBoxStyleSchema.safeParse(combinedFreeStyle);
|
|
369
|
+
let validatedFreeStyle;
|
|
370
|
+
if (parsedFreeStyle.success) validatedFreeStyle = parsedFreeStyle.data;
|
|
371
|
+
else {
|
|
372
|
+
diagnostics.push({
|
|
373
|
+
code: "invalid-xml-value",
|
|
374
|
+
category: "corrupt-input",
|
|
375
|
+
disposition: "recovered",
|
|
376
|
+
location: {
|
|
377
|
+
...location,
|
|
378
|
+
xpath: cursor.xpath
|
|
379
|
+
},
|
|
380
|
+
attributeOrElement: "p:sp",
|
|
381
|
+
rawValue: parsedFreeStyle.error.issues[0]?.message ?? "invalid style"
|
|
382
|
+
});
|
|
383
|
+
validatedFreeStyle = {
|
|
384
|
+
position: "absolute",
|
|
385
|
+
left: resolvedBox.x,
|
|
386
|
+
top: resolvedBox.y,
|
|
387
|
+
width: resolvedBox.width,
|
|
388
|
+
...resolvedBox.height === void 0 ? {} : { height: resolvedBox.height }
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const freeNode = createTextNode({
|
|
392
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
393
|
+
...link === void 0 ? {} : { link },
|
|
394
|
+
style: validatedFreeStyle
|
|
395
|
+
});
|
|
396
|
+
if (promoted?.text !== void 0) freeNode.content(promoted.text);
|
|
397
|
+
else if (promoted === void 0) populateRichTextNode(freeNode, freeParagraphs);
|
|
398
|
+
attachDeferredSlideLink(freeNode, deferredSlideLink, context);
|
|
399
|
+
emitPlaceholderUnbindDiagnostic({
|
|
400
|
+
diagnostics,
|
|
401
|
+
location: {
|
|
402
|
+
...location,
|
|
403
|
+
xpath: cursor.xpath
|
|
404
|
+
},
|
|
405
|
+
retainedAs: "text"
|
|
406
|
+
});
|
|
407
|
+
return {
|
|
408
|
+
node: freeNode,
|
|
409
|
+
diagnostics
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
const { boxStyle, singleText, paragraphsToPopulate } = flattenImportedTextBody(imported, visualStyle);
|
|
413
|
+
const combinedStyle = {
|
|
414
|
+
...offset === void 0 ? {} : {
|
|
415
|
+
position: "absolute",
|
|
416
|
+
left: offset.x,
|
|
417
|
+
top: offset.y
|
|
418
|
+
},
|
|
419
|
+
...extent,
|
|
420
|
+
...flipH === void 0 ? {} : { flipH },
|
|
421
|
+
...flipV === void 0 ? {} : { flipV },
|
|
422
|
+
...boxStyle
|
|
423
|
+
};
|
|
424
|
+
let validatedStyle;
|
|
425
|
+
if (Object.keys(combinedStyle).length > 0) {
|
|
426
|
+
const parsedStyle = placeholderStyleSchema.safeParse(combinedStyle);
|
|
427
|
+
if (parsedStyle.success) validatedStyle = parsedStyle.data;
|
|
428
|
+
else diagnostics.push({
|
|
429
|
+
code: "invalid-xml-value",
|
|
430
|
+
category: "corrupt-input",
|
|
431
|
+
disposition: "recovered",
|
|
432
|
+
location: {
|
|
433
|
+
...location,
|
|
434
|
+
xpath: cursor.xpath
|
|
435
|
+
},
|
|
436
|
+
attributeOrElement: "p:sp",
|
|
437
|
+
rawValue: parsedStyle.error.issues[0]?.message ?? "invalid style"
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
const props = {
|
|
441
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
442
|
+
...link === void 0 ? {} : { link },
|
|
443
|
+
placeholder: claim.key,
|
|
444
|
+
...validatedStyle === void 0 ? {} : { style: validatedStyle }
|
|
445
|
+
};
|
|
446
|
+
const node = createTextNode(props);
|
|
447
|
+
if (singleText !== void 0) node.content(singleText);
|
|
448
|
+
else if (paragraphsToPopulate !== void 0) populateRichTextNode(node, paragraphsToPopulate);
|
|
449
|
+
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
450
|
+
return {
|
|
451
|
+
node,
|
|
452
|
+
diagnostics
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const textBoxImportHandler = {
|
|
456
|
+
target: "shape-tree",
|
|
457
|
+
localName: "sp",
|
|
458
|
+
matches: (cursor) => isTextBoxSpElement(cursor) && !isPlaceholderSpElement(cursor),
|
|
459
|
+
read: readTextBoxSp,
|
|
460
|
+
groupMember: true
|
|
461
|
+
};
|
|
462
|
+
const textPlaceholderImportHandler = {
|
|
463
|
+
target: "shape-tree",
|
|
464
|
+
localName: "sp",
|
|
465
|
+
matches: isTextPlaceholderSpElement,
|
|
466
|
+
read: readTextPlaceholderSp
|
|
467
|
+
};
|
|
468
|
+
export { isPlaceholderSpElement, isTextPlaceholderSpElement, readTextBoxSp, readTextPlaceholderSp, textBoxImportHandler, textFieldDateTimeImportHandler, textFieldSlideNumImportHandler, textPlaceholderImportHandler };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { placeholderRefXml } from "
|
|
2
|
-
|
|
3
|
-
// ../capabilities/dist/text/text-xml.js
|
|
1
|
+
import { placeholderRefXml } from "../../kernel/pptx-write/xml.js";
|
|
2
|
+
// ../core/dist/capabilities/text/text-xml.js
|
|
4
3
|
/** Internal PresentationML text box / text placeholder wrapper for the text capability. */
|
|
5
4
|
function textBoxXml(id, escapedName, _box, textBody, properties, linkXml, placeholder) {
|
|
6
|
-
if (placeholder !== void 0) return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${placeholderRefXml(placeholder.nativeRef)}</p:nvPr></p:nvSpPr>${placeholder.spPrXml ?? properties}${textBody}</p:sp>`;
|
|
5
|
+
if (placeholder !== void 0) return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr${placeholder.nativeRef.type === "dt" ? " txBox=\"1\"" : ""}><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr>${placeholderRefXml(placeholder.nativeRef)}</p:nvPr></p:nvSpPr>${placeholder.spPrXml ?? properties}${textBody}</p:sp>`;
|
|
7
6
|
return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr txBox="1"/><p:nvPr/></p:nvSpPr>${properties}${textBody}</p:sp>`;
|
|
8
7
|
}
|
|
9
8
|
export { placeholderRefXml, textBoxXml };
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import { textStyleKeys } from "
|
|
3
|
-
import { parseLinkTarget } from "
|
|
4
|
-
import { parseCapabilityLayoutContract } from "
|
|
5
|
-
import "
|
|
6
|
-
import {
|
|
7
|
-
import "
|
|
8
|
-
import "../../../import/dist/index.js";
|
|
9
|
-
import { defineCanvasMechanism, defineShowMechanism } from "../../../import/dist/mechanism.js";
|
|
10
|
-
import { fontPresentationContributions } from "../font/font-embedding.js";
|
|
11
|
-
import { embeddedFontImportHandler } from "../font/font-import.js";
|
|
12
|
-
import { motionAnnotations, motionParagraphAnnotations, pickMotionProps } from "../motion/motion-api.js";
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { textStyleKeys } from "../../kernel/theme.js";
|
|
3
|
+
import { parseLinkTarget } from "../../kernel/author-schemas.js";
|
|
4
|
+
import { parseCapabilityLayoutContract } from "../../kernel/layout.js";
|
|
5
|
+
import { fontPresentationContributions } from "../shared/font/font-embedding.js";
|
|
6
|
+
import { embeddedFontImportHandler } from "../shared/font/font-import.js";
|
|
7
|
+
import { defineCanvasMechanism, defineShowMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
13
8
|
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
|
|
9
|
+
import { motionAnnotations, motionParagraphAnnotations, pickMotionProps } from "../shared/motion-api.js";
|
|
10
|
+
import { compatiblePlaceholderRoles } from "../shared/placeholder-roles.js";
|
|
14
11
|
import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "../shared/style-inheritance.js";
|
|
15
12
|
import { parseTextCoordinate, parseTextExtent, textBoxAllowedParamKeys, textBoxStyleKeys } from "../shared/text-schemas.js";
|
|
16
|
-
import {
|
|
17
|
-
import { emitPlaceholderVisualSpPr, emitVisualModel, paintVisualModel, resolveVisualModel, visualSvgTransform } from "../shared/visual.js";
|
|
13
|
+
import { alignMeasuredTextWidthsForOuterEmu, computeTextMetrics, emitTextBody, emitTextFieldRunXml, measureTextLayoutFromParagraphs, parseTextContent, renderTextOutlinesSvg, resolveTextBody, textInsets } from "../shared/text-service.js";
|
|
14
|
+
import { bindVisualModel, emitPlaceholderVisualSpPr, emitVisualModel, paintVisualModel, resolveVisualModel, visualSvgTransform } from "../shared/visual.js";
|
|
15
|
+
import "../../kernel/capability.js";
|
|
16
|
+
import "../../kernel/pptx-read/index.js";
|
|
17
|
+
import { assertXml10Characters, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
18
|
+
import { textFieldDateTimeImportHandler, textFieldSlideNumImportHandler } from "../shared/rich-text-import.js";
|
|
18
19
|
import { textCodegen } from "./text-codegen.js";
|
|
19
|
-
import { textBoxImportHandler,
|
|
20
|
+
import { textBoxImportHandler, textPlaceholderImportHandler } from "./text-import.js";
|
|
20
21
|
import { textBoxXml } from "./text-xml.js";
|
|
21
|
-
import { font, fromFontCollection } from "../font/font.js";
|
|
22
|
-
// ../
|
|
22
|
+
import { font, fromFontCollection } from "../shared/font/font.js";
|
|
23
|
+
// ../core/dist/capabilities/text/text.js
|
|
23
24
|
function record(value) {
|
|
24
25
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25
26
|
}
|
|
@@ -33,17 +34,6 @@ function textStyle(value) {
|
|
|
33
34
|
if (!record(value)) return value;
|
|
34
35
|
return Object.fromEntries(Object.entries(value).filter(([key]) => textStyleKeys.has(key)));
|
|
35
36
|
}
|
|
36
|
-
const textCompatiblePlaceholderRoles = /* @__PURE__ */ new Set([
|
|
37
|
-
"title",
|
|
38
|
-
"ctrTitle",
|
|
39
|
-
"subTitle",
|
|
40
|
-
"body",
|
|
41
|
-
"dt",
|
|
42
|
-
"ftr",
|
|
43
|
-
"hdr",
|
|
44
|
-
"obj",
|
|
45
|
-
"sldNum"
|
|
46
|
-
]);
|
|
47
37
|
function emitTextModel(model, emitContext) {
|
|
48
38
|
const embedFonts = emitContext.options.embedFonts;
|
|
49
39
|
const emittedBody = emitTextBody(model.text, emitContext.theme, {
|
|
@@ -68,7 +58,7 @@ function paintTextModel(model, paintContext) {
|
|
|
68
58
|
model: model.visual,
|
|
69
59
|
slideNumber: paintContext.slideNumber,
|
|
70
60
|
objectId: paintContext.objectId,
|
|
71
|
-
|
|
61
|
+
registerRasterResource: paintContext.registerRasterResource
|
|
72
62
|
}) : void 0;
|
|
73
63
|
const backgroundSvg = visualPaint?.svg ?? "";
|
|
74
64
|
const glyphs = renderTextOutlinesSvg({
|
|
@@ -102,28 +92,38 @@ const textPlaceholderMechanism = defineCanvasMechanism({
|
|
|
102
92
|
paint: paintTextModel,
|
|
103
93
|
import: textPlaceholderImportHandler
|
|
104
94
|
});
|
|
105
|
-
|
|
95
|
+
function emitTextField(model, context) {
|
|
96
|
+
return { xml: emitTextFieldRunXml(model.run, context.theme, context.createTextFieldId) };
|
|
97
|
+
}
|
|
98
|
+
function paintTextField(model, context) {
|
|
99
|
+
return { svg: renderTextOutlinesSvg({
|
|
100
|
+
paragraphs: [{
|
|
101
|
+
runs: [model.run],
|
|
102
|
+
style: {},
|
|
103
|
+
endStyle: model.run.style,
|
|
104
|
+
wrap: "normal"
|
|
105
|
+
}],
|
|
106
|
+
box: context.box ?? model.box,
|
|
107
|
+
theme: context.theme,
|
|
108
|
+
idPrefix: model.idPrefix
|
|
109
|
+
}) };
|
|
110
|
+
}
|
|
111
|
+
/** Native inline slide number field. */
|
|
106
112
|
const textFieldSlideNumMechanism = defineCanvasMechanism({
|
|
107
113
|
key: "text-field-slidenum",
|
|
108
114
|
role: "canvas",
|
|
109
|
-
emit
|
|
110
|
-
|
|
111
|
-
},
|
|
112
|
-
paint(model, paintContext) {
|
|
113
|
-
return { svg: renderTextOutlinesSvg({
|
|
114
|
-
paragraphs: [{
|
|
115
|
-
runs: [model.run],
|
|
116
|
-
style: {},
|
|
117
|
-
endStyle: model.run.style,
|
|
118
|
-
wrap: "normal"
|
|
119
|
-
}],
|
|
120
|
-
box: paintContext.box ?? model.box,
|
|
121
|
-
theme: paintContext.theme,
|
|
122
|
-
idPrefix: model.idPrefix
|
|
123
|
-
}) };
|
|
124
|
-
},
|
|
115
|
+
emit: emitTextField,
|
|
116
|
+
paint: paintTextField,
|
|
125
117
|
import: textFieldSlideNumImportHandler
|
|
126
118
|
});
|
|
119
|
+
/** Native inline date/time field. */
|
|
120
|
+
const textFieldDateTimeMechanism = defineCanvasMechanism({
|
|
121
|
+
key: "text-field-datetime",
|
|
122
|
+
role: "canvas",
|
|
123
|
+
emit: emitTextField,
|
|
124
|
+
paint: paintTextField,
|
|
125
|
+
import: textFieldDateTimeImportHandler
|
|
126
|
+
});
|
|
127
127
|
/** Typed native show mechanism connecting emit and import for presentation `embedded-font`. */
|
|
128
128
|
const embeddedFontMechanism = defineShowMechanism({
|
|
129
129
|
key: "embedded-font",
|
|
@@ -144,15 +144,16 @@ const textCapability = {
|
|
|
144
144
|
textBoxMechanism,
|
|
145
145
|
textPlaceholderMechanism,
|
|
146
146
|
textFieldSlideNumMechanism,
|
|
147
|
+
textFieldDateTimeMechanism,
|
|
147
148
|
embeddedFontMechanism
|
|
148
149
|
],
|
|
149
|
-
bind(input, context) {
|
|
150
|
+
*bind(input, context) {
|
|
150
151
|
const unknown = Object.keys(input.props).find((key) => !textBoxAllowedParamKeys.has(key));
|
|
151
152
|
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Text contains unsupported parameter ${unknown}`);
|
|
152
153
|
const placeholder = context.placeholder;
|
|
153
154
|
if (placeholder !== void 0) {
|
|
154
|
-
const role = placeholder.
|
|
155
|
-
if (!
|
|
155
|
+
const role = placeholder.nativeRef.type;
|
|
156
|
+
if (!compatiblePlaceholderRoles.text.has(role)) throw new CapabilityError("incompatible-placeholder-content", `Text cannot be bound to ${role} placeholder`);
|
|
156
157
|
}
|
|
157
158
|
const requestedName = parseOptionalName(input.props["name"]);
|
|
158
159
|
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
@@ -176,11 +177,14 @@ const textCapability = {
|
|
|
176
177
|
const placeholderHeight = placeholderGeometry?.height;
|
|
177
178
|
const isContentSized = !(placeholderHeight !== void 0 && placeholderHeight !== "auto") && !(contract.fixedAxes?.height ?? false);
|
|
178
179
|
const declaredPixelHeight = typeof placeholderHeight === "number" ? size(placeholderHeight, "height") : contract.explicitPixelSize?.height;
|
|
179
|
-
const { paragraphs, paragraphMotions, style: parsedTextStyle, localBodyDeclared } = parseTextContent(input.children, textStyle(input.props["style"]), placeholder?.masterTheme ?? context.theme, {
|
|
180
|
+
const { paragraphs, paragraphMotions, style: parsedTextStyle, localBodyDeclared } = parseTextContent(input.children, textStyle(input.props["style"]), placeholder?.masterTheme ?? context.theme, {
|
|
181
|
+
slideNumber: context.slideNumber,
|
|
182
|
+
referenceDate: context.options.referenceDate
|
|
183
|
+
}, "Text.style", placeholder, input.props["style"], { allowParagraphMotion: true });
|
|
180
184
|
const rawSlideStyle = record(input.props["style"]) ? input.props["style"] : void 0;
|
|
181
185
|
const inheritedPlaceholderGeometry = placeholder?.layoutPlaceholder?.geometry ?? placeholder?.masterPlaceholder?.geometry;
|
|
182
186
|
const visualStyle = placeholder !== void 0 ? resolvePlaceholderVisualStyle(placeholder, rawSlideStyle) : rawSlideStyle !== void 0 ? { ...rawSlideStyle } : {};
|
|
183
|
-
|
|
187
|
+
const initialVisual = yield* bindVisualModel({
|
|
184
188
|
theme: placeholder?.masterTheme ?? context.theme,
|
|
185
189
|
style: visualStyle,
|
|
186
190
|
box: {
|
|
@@ -206,8 +210,11 @@ const textCapability = {
|
|
|
206
210
|
const innerWidth = request.availableWidth !== void 0 ? request.availableWidth : typeof width === "number" ? Math.max(0, width - insets.left - insets.right) : void 0;
|
|
207
211
|
try {
|
|
208
212
|
const measured = measureTextLayoutFromParagraphs(paragraphs, parsedTextStyle, innerWidth);
|
|
213
|
+
const { width: widthResult, minContentWidth: minContentWidthResult } = alignMeasuredTextWidthsForOuterEmu(measured, insets, request);
|
|
209
214
|
return {
|
|
210
215
|
...measured,
|
|
216
|
+
width: widthResult,
|
|
217
|
+
minContentWidth: minContentWidthResult,
|
|
211
218
|
baseline: measured.baseline ?? "unavailable"
|
|
212
219
|
};
|
|
213
220
|
} catch (error) {
|
|
@@ -244,14 +251,14 @@ const textCapability = {
|
|
|
244
251
|
style: visualStyle,
|
|
245
252
|
box,
|
|
246
253
|
...inheritedPlaceholderGeometry === void 0 ? {} : { geometry: inheritedPlaceholderGeometry }
|
|
247
|
-
});
|
|
254
|
+
}, initialVisual.fill);
|
|
248
255
|
const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `Text ${resolveContext.id - 1}`;
|
|
249
256
|
let escapedName;
|
|
250
257
|
try {
|
|
251
258
|
assertXml10Characters(name);
|
|
252
259
|
escapedName = xmlEscape(name);
|
|
253
260
|
} catch {
|
|
254
|
-
throw new CapabilityError("invalid-xml-character", "Text.name contains characters not allowed in XML 1.0");
|
|
261
|
+
throw new CapabilityError("invalid-xml-character", "Text.name contains characters not allowed in XML 1.0", void 0, { field: "name" });
|
|
255
262
|
}
|
|
256
263
|
const target = {
|
|
257
264
|
kind: "text",
|
|
@@ -317,4 +324,4 @@ const textCapability = {
|
|
|
317
324
|
};
|
|
318
325
|
}
|
|
319
326
|
};
|
|
320
|
-
export { embeddedFontMechanism, font, fromFontCollection, textBoxMechanism, textCapability, textFieldSlideNumMechanism, textPlaceholderMechanism };
|
|
327
|
+
export { embeddedFontMechanism, font, fromFontCollection, textBoxMechanism, textCapability, textFieldDateTimeMechanism, textFieldSlideNumMechanism, textPlaceholderMechanism };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { transitions } from "./transition-api.js";
|
|
2
|
+
import { transitionCapability, transitionFadeMechanism, transitionFlipMechanism, transitionMorphMechanism, transitionPushMechanism, transitionStripsMechanism } from "./transition.js";
|
|
3
|
+
export { transitionCapability, transitionFadeMechanism, transitionFlipMechanism, transitionMorphMechanism, transitionPushMechanism, transitionStripsMechanism, transitions };
|