@officedk/pptxdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import { dateTimeFormatSchema } from "../../kernel/date-time-format.js";
|
|
2
|
+
import "./date-time.js";
|
|
3
|
+
import "./text-schemas.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import { A_NS, XML_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
6
|
+
import { cascadeOoxmlTextDecoration, ooxmlBoolSchema, projectOoxmlTextDecoration, readOoxmlBoxInsets, readOoxmlRunAttrStyles, readOoxmlTextDecoration, reportOoxmlTextDecorationLoss } from "../../kernel/pptx-read/xml-fragments.js";
|
|
7
|
+
import { readEffectList, readRunFillAndStroke } from "../../kernel/pptx-read/visual.js";
|
|
8
|
+
import { readRunFontSlots } from "../../kernel/pptx-read/fonts.js";
|
|
9
|
+
import { cascadeDrawingParagraphProperties, readDrawingListStyles, readDrawingParagraphProperties } from "../../kernel/pptx-read/drawing-list-import.js";
|
|
10
|
+
import "../../kernel/pptx-read/index.js";
|
|
11
|
+
import { isTextGradient, textStyleKeys } from "../../kernel/theme.js";
|
|
12
|
+
import { createDateTimeNode, createParagraphNode, createSlideNumberNode, createSpanNode, createSubNode, createSupNode } from "./text-declaration.js";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
// ../core/dist/capabilities/shared/rich-text-import.js
|
|
15
|
+
const BodyPrFragmentSchema = z.object({
|
|
16
|
+
wrap: z.enum(["square", "none"]).optional(),
|
|
17
|
+
rtlCol: ooxmlBoolSchema.optional(),
|
|
18
|
+
anchor: z.enum([
|
|
19
|
+
"t",
|
|
20
|
+
"ctr",
|
|
21
|
+
"b"
|
|
22
|
+
]).optional(),
|
|
23
|
+
anchorCtr: ooxmlBoolSchema.optional(),
|
|
24
|
+
spcFirstLastPara: ooxmlBoolSchema.optional(),
|
|
25
|
+
numCol: z.string().optional(),
|
|
26
|
+
spcCol: z.string().optional()
|
|
27
|
+
});
|
|
28
|
+
const TextFieldXmlSchema = z.object({
|
|
29
|
+
id: z.string().min(1),
|
|
30
|
+
type: z.string().min(1)
|
|
31
|
+
});
|
|
32
|
+
const shapeFieldXmlSchema = TextFieldXmlSchema.omit({ id: true });
|
|
33
|
+
const anchorToVerticalAlign = {
|
|
34
|
+
t: "top",
|
|
35
|
+
ctr: "middle",
|
|
36
|
+
b: "bottom"
|
|
37
|
+
};
|
|
38
|
+
/** A bound slide keeps its native placeholder defaults. Consume the body-local overrides we can represent. */
|
|
39
|
+
function readPlaceholderListOverrides(body, location, diagnostics) {
|
|
40
|
+
if (body.ignoreEmptyChild("http://schemas.openxmlformats.org/drawingml/2006/main", "lstStyle")) return void 0;
|
|
41
|
+
const list = body.child(A_NS, "lstStyle");
|
|
42
|
+
if (list === void 0) return void 0;
|
|
43
|
+
const read = (name) => {
|
|
44
|
+
const properties = list.child(A_NS, name)?.child(A_NS, "defRPr");
|
|
45
|
+
if (properties === void 0) return void 0;
|
|
46
|
+
const decoration = readOoxmlTextDecoration(properties, location, diagnostics, true);
|
|
47
|
+
return {
|
|
48
|
+
style: readRunFillAndStroke(properties, location, diagnostics),
|
|
49
|
+
...decoration === void 0 ? {} : { decoration }
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const defaults = read("defPPr");
|
|
53
|
+
return Array.from({ length: 9 }, (_, level) => cascadeDrawingParagraphProperties(defaults, read(`lvl${level + 1}pPr`), level));
|
|
54
|
+
}
|
|
55
|
+
/** Folds inherited text effects into paragraph style while leaving each run's override intact. */
|
|
56
|
+
function resolveParagraphTextEffects(inherited, local, runs) {
|
|
57
|
+
const color = local?.color ?? inherited?.color;
|
|
58
|
+
const textStroke = local?.textStroke ?? inherited?.textStroke;
|
|
59
|
+
return {
|
|
60
|
+
...color !== void 0 && (isTextGradient(color) || runs.some((run) => run.style.color === void 0)) ? { color } : {},
|
|
61
|
+
...textStroke === void 0 ? {} : { textStroke }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function readRunProperties(rPrCursor, location, diagnostics, allowShadowNone = false) {
|
|
65
|
+
const attrStyles = readOoxmlRunAttrStyles({
|
|
66
|
+
rPrCursor,
|
|
67
|
+
location,
|
|
68
|
+
diagnostics,
|
|
69
|
+
allowBaseline: true,
|
|
70
|
+
diagnoseUnsupportedEnums: true
|
|
71
|
+
});
|
|
72
|
+
const { color, textStroke } = readRunFillAndStroke(rPrCursor, location, diagnostics);
|
|
73
|
+
const effects = rPrCursor.child(A_NS, "effectLst");
|
|
74
|
+
const textShadow = effects === void 0 ? void 0 : readEffectList(effects, location, diagnostics, "text").boxShadow ?? (allowShadowNone && effects.element.children.length === 0 ? "none" : void 0);
|
|
75
|
+
const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPrCursor);
|
|
76
|
+
return {
|
|
77
|
+
style: {
|
|
78
|
+
...fontFamily === void 0 ? {} : { fontFamily },
|
|
79
|
+
...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily },
|
|
80
|
+
...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
|
|
81
|
+
...attrStyles.fontWeight === void 0 ? {} : { fontWeight: attrStyles.fontWeight },
|
|
82
|
+
...attrStyles.fontStyle === void 0 ? {} : { fontStyle: attrStyles.fontStyle },
|
|
83
|
+
...color === void 0 ? {} : { color },
|
|
84
|
+
...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
|
|
85
|
+
...attrStyles.textTransform === void 0 ? {} : { textTransform: attrStyles.textTransform },
|
|
86
|
+
...textShadow === void 0 ? {} : { textShadow },
|
|
87
|
+
...textStroke === void 0 ? {} : { textStroke },
|
|
88
|
+
...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang },
|
|
89
|
+
...attrStyles.baselineShift === void 0 ? {} : { baselineShift: attrStyles.baselineShift }
|
|
90
|
+
},
|
|
91
|
+
...attrStyles.decoration === void 0 ? {} : { decoration: attrStyles.decoration },
|
|
92
|
+
...attrStyles.sizePt === void 0 ? {} : { sizePt: attrStyles.sizePt },
|
|
93
|
+
...attrStyles.inlineKind === void 0 ? {} : { inlineKind: attrStyles.inlineKind }
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function readInlineField(cursor, location, shape) {
|
|
97
|
+
const diagnostics = [];
|
|
98
|
+
const rawField = cursor.attrsObject(["id", "type"]);
|
|
99
|
+
const parsedField = (shape ? shapeFieldXmlSchema : TextFieldXmlSchema).safeParse(rawField);
|
|
100
|
+
const rPrCursor = cursor.child(A_NS, "rPr");
|
|
101
|
+
cursor.ignoreEmptyChild(A_NS, "pPr");
|
|
102
|
+
const tCursor = cursor.child(A_NS, "t");
|
|
103
|
+
if (tCursor !== void 0) tCursor.consumeAttr("space", XML_NS);
|
|
104
|
+
const fallbackText = tCursor?.textContent ?? "";
|
|
105
|
+
if (!parsedField.success) {
|
|
106
|
+
diagnostics.push({
|
|
107
|
+
code: "invalid-xml-value",
|
|
108
|
+
category: "corrupt-input",
|
|
109
|
+
disposition: "omitted",
|
|
110
|
+
location: {
|
|
111
|
+
...location,
|
|
112
|
+
xpath: cursor.xpath
|
|
113
|
+
},
|
|
114
|
+
attributeOrElement: "a:fld",
|
|
115
|
+
rawValue: JSON.stringify(rawField)
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
kind: "unsupported",
|
|
119
|
+
fieldType: rawField["type"] ?? "",
|
|
120
|
+
...rPrCursor === void 0 ? {} : { rPrCursor },
|
|
121
|
+
fallbackText,
|
|
122
|
+
diagnostics
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const dateTime = dateTimeFormatSchema.safeParse(parsedField.data.type);
|
|
126
|
+
if (parsedField.data.type !== "slidenum" && !dateTime.success) {
|
|
127
|
+
diagnostics.push({
|
|
128
|
+
code: "unsupported-mechanism",
|
|
129
|
+
category: "unsupported",
|
|
130
|
+
disposition: "omitted",
|
|
131
|
+
location: {
|
|
132
|
+
...location,
|
|
133
|
+
xpath: cursor.xpath
|
|
134
|
+
},
|
|
135
|
+
namespaceUri: cursor.namespaceUri,
|
|
136
|
+
localName: cursor.localName,
|
|
137
|
+
mechanismHint: `${shape ? "field" : "text-field"}:${parsedField.data.type}`
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
kind: "unsupported",
|
|
141
|
+
fieldType: parsedField.data.type,
|
|
142
|
+
...rPrCursor === void 0 ? {} : { rPrCursor },
|
|
143
|
+
fallbackText,
|
|
144
|
+
diagnostics
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
...dateTime.success ? {
|
|
149
|
+
kind: "date-time",
|
|
150
|
+
fieldType: dateTime.data
|
|
151
|
+
} : {
|
|
152
|
+
kind: "slide-number",
|
|
153
|
+
fieldType: "slidenum"
|
|
154
|
+
},
|
|
155
|
+
...rPrCursor === void 0 ? {} : { rPrCursor },
|
|
156
|
+
fallbackText,
|
|
157
|
+
diagnostics
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Import handler for `<a:fld type="slidenum">` inline text fields (`text-field-slidenum`).
|
|
162
|
+
*/
|
|
163
|
+
const textFieldSlideNumImportHandler = {
|
|
164
|
+
target: "text-inline",
|
|
165
|
+
localName: "fld",
|
|
166
|
+
matches(cursor) {
|
|
167
|
+
return cursor.element.getAttribute("type") === "slidenum";
|
|
168
|
+
},
|
|
169
|
+
read({ cursor, part, slideIndex }) {
|
|
170
|
+
return readInlineField(cursor, {
|
|
171
|
+
part,
|
|
172
|
+
slideIndex
|
|
173
|
+
}, false);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
/** Import handler for the native date/time field mechanism. */
|
|
177
|
+
const textFieldDateTimeImportHandler = {
|
|
178
|
+
...textFieldSlideNumImportHandler,
|
|
179
|
+
matches(cursor) {
|
|
180
|
+
return dateTimeFormatSchema.safeParse(cursor.element.getAttribute("type")).success;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
function readParagraph(pCursor, location, diagnostics, listStyles, ancestorDecorations, host) {
|
|
184
|
+
const pPr = pCursor.child(A_NS, "pPr");
|
|
185
|
+
const allowInheritedShadowClear = host === "placeholder" || host === "unbound-placeholder" || listStyles !== void 0;
|
|
186
|
+
let hasDefaultRun = false;
|
|
187
|
+
const readDefaultRun = (cursor) => {
|
|
188
|
+
hasDefaultRun = true;
|
|
189
|
+
const { style: { baselineShift: _baselineShift, ...style }, decoration } = readRunProperties(cursor, location, diagnostics, allowInheritedShadowClear);
|
|
190
|
+
return {
|
|
191
|
+
style,
|
|
192
|
+
...decoration === void 0 ? {} : { decoration }
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
const local = pPr === void 0 ? void 0 : readDrawingParagraphProperties(pPr, location, diagnostics, readDefaultRun);
|
|
196
|
+
const readShadowClear = allowInheritedShadowClear || local?.style.textShadow !== void 0;
|
|
197
|
+
const lvl = local?.level;
|
|
198
|
+
const inherited = listStyles?.[lvl ?? 0];
|
|
199
|
+
const effective = cascadeDrawingParagraphProperties(host === "placeholder" ? void 0 : inherited, local, lvl ?? 0);
|
|
200
|
+
const materializeListStyle = inherited !== void 0 && (Object.keys(inherited.style).length > 0 || inherited.decoration !== void 0 || inherited.buNone || inherited.spacingAfterPercent !== void 0);
|
|
201
|
+
const localDecoration = cascadeOoxmlTextDecoration(inherited?.decoration, local?.decoration);
|
|
202
|
+
const decoration = cascadeOoxmlTextDecoration(ancestorDecorations?.[lvl ?? 0], localDecoration);
|
|
203
|
+
const hasLocalDecoration = inherited?.decoration !== void 0 || local?.decoration !== void 0;
|
|
204
|
+
const needsLevelOverride = lvl !== void 0 && lvl > 0 && effective.style.list === void 0 && projectOoxmlTextDecoration(ancestorDecorations?.[lvl]) !== projectOoxmlTextDecoration(ancestorDecorations?.[0]);
|
|
205
|
+
const paragraphDecoration = hasLocalDecoration || needsLevelOverride ? projectOoxmlTextDecoration(decoration) ?? "none" : void 0;
|
|
206
|
+
const readInline = (properties, position) => {
|
|
207
|
+
const parsed = properties === void 0 ? { style: {} } : readRunProperties(properties, location, diagnostics, readShadowClear);
|
|
208
|
+
const state = cascadeOoxmlTextDecoration(decoration, parsed.decoration);
|
|
209
|
+
reportOoxmlTextDecorationLoss(state, {
|
|
210
|
+
...location,
|
|
211
|
+
xpath: position.xpath
|
|
212
|
+
}, diagnostics);
|
|
213
|
+
const textDecoration = projectOoxmlTextDecoration(state);
|
|
214
|
+
return {
|
|
215
|
+
...parsed,
|
|
216
|
+
style: {
|
|
217
|
+
...parsed.style,
|
|
218
|
+
...parsed.decoration === void 0 || textDecoration === void 0 ? {} : { textDecoration }
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
const runs = [];
|
|
223
|
+
let endPara;
|
|
224
|
+
for (const child of pCursor.remainingElementChildren()) {
|
|
225
|
+
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "r") {
|
|
226
|
+
const parsedRPr = readInline(child.child(A_NS, "rPr"), child);
|
|
227
|
+
const t = child.child(A_NS, "t");
|
|
228
|
+
if (t !== void 0) {
|
|
229
|
+
t.consumeAttr("space", XML_NS);
|
|
230
|
+
runs.push({
|
|
231
|
+
kind: parsedRPr.inlineKind ?? "text",
|
|
232
|
+
text: t.textContent,
|
|
233
|
+
style: parsedRPr.style,
|
|
234
|
+
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "br") {
|
|
240
|
+
const parsedRPr = readInline(child.child(A_NS, "rPr"), child);
|
|
241
|
+
runs.push({
|
|
242
|
+
kind: parsedRPr.inlineKind ?? "text",
|
|
243
|
+
text: "\n",
|
|
244
|
+
style: parsedRPr.style,
|
|
245
|
+
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
246
|
+
});
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
|
|
250
|
+
const outcome = readInlineField(child, location, host === "shape");
|
|
251
|
+
diagnostics.push(...outcome.diagnostics);
|
|
252
|
+
if (outcome.kind === "unsupported" && host !== "shape") continue;
|
|
253
|
+
const parsedRPr = readInline(outcome.rPrCursor, child);
|
|
254
|
+
if (outcome.kind === "unsupported") {
|
|
255
|
+
if (outcome.fallbackText !== "") runs.push({
|
|
256
|
+
kind: parsedRPr.inlineKind ?? "text",
|
|
257
|
+
text: outcome.fallbackText,
|
|
258
|
+
style: parsedRPr.style,
|
|
259
|
+
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
260
|
+
});
|
|
261
|
+
} else {
|
|
262
|
+
const fieldStyle = parsedRPr.inlineKind === void 0 ? parsedRPr.style : {
|
|
263
|
+
...parsedRPr.style,
|
|
264
|
+
baselineShift: parsedRPr.inlineKind === "sup" ? "30%" : "-25%"
|
|
265
|
+
};
|
|
266
|
+
runs.push({
|
|
267
|
+
...outcome.kind === "date-time" ? {
|
|
268
|
+
kind: "date-time",
|
|
269
|
+
format: outcome.fieldType
|
|
270
|
+
} : { kind: "slide-number" },
|
|
271
|
+
style: fieldStyle,
|
|
272
|
+
...parsedRPr.sizePt === void 0 ? {} : { sizePt: parsedRPr.sizePt }
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
|
|
278
|
+
endPara = readRunProperties(child, location, diagnostics, readShadowClear);
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
diagnostics.push({
|
|
282
|
+
code: "unconsumed-xml",
|
|
283
|
+
category: "unsupported",
|
|
284
|
+
disposition: "omitted",
|
|
285
|
+
kind: "element",
|
|
286
|
+
location: {
|
|
287
|
+
...location,
|
|
288
|
+
xpath: child.xpath
|
|
289
|
+
},
|
|
290
|
+
namespaceUri: child.namespaceUri,
|
|
291
|
+
localName: child.localName
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
const effectiveStyle = materializeDrawingParagraphStyle(effective, {
|
|
295
|
+
...location,
|
|
296
|
+
xpath: pCursor.xpath
|
|
297
|
+
}, diagnostics, runs.find((run) => run.sizePt !== void 0)?.sizePt ?? endPara?.sizePt);
|
|
298
|
+
const { align, lineHeight, spacingAfter, list } = effectiveStyle;
|
|
299
|
+
const finalDecoration = runs.length === 0 ? cascadeOoxmlTextDecoration(decoration, endPara?.decoration) : decoration;
|
|
300
|
+
if (runs.length === 0) reportOoxmlTextDecorationLoss(finalDecoration, {
|
|
301
|
+
...location,
|
|
302
|
+
xpath: pCursor.xpath
|
|
303
|
+
}, diagnostics);
|
|
304
|
+
const textDecoration = runs.length === 0 && endPara?.decoration !== void 0 ? projectOoxmlTextDecoration(finalDecoration) : paragraphDecoration;
|
|
305
|
+
const { baselineShift: _endBaselineShift, ...endStyle } = endPara?.style ?? {};
|
|
306
|
+
return {
|
|
307
|
+
runs,
|
|
308
|
+
style: {
|
|
309
|
+
...host === "placeholder" ? {
|
|
310
|
+
...resolveParagraphTextEffects(inherited?.style, local?.style, runs),
|
|
311
|
+
...align === void 0 ? {} : { align },
|
|
312
|
+
...lineHeight === void 0 ? {} : { lineHeight },
|
|
313
|
+
...spacingAfter === void 0 ? {} : { spacingAfter },
|
|
314
|
+
...list === void 0 ? {} : { list }
|
|
315
|
+
} : {
|
|
316
|
+
...effectiveStyle,
|
|
317
|
+
...runs.length === 0 ? endStyle : {}
|
|
318
|
+
},
|
|
319
|
+
...textDecoration === void 0 ? {} : { textDecoration }
|
|
320
|
+
},
|
|
321
|
+
...lvl === void 0 ? {} : { level0: lvl },
|
|
322
|
+
...materializeListStyle || hasDefaultRun ? { hasTextDefaults: true } : {},
|
|
323
|
+
...effective.buNone ? { buNone: true } : {}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/** Converts DrawingML percentage space-after using the effective text size. */
|
|
327
|
+
function materializeDrawingParagraphStyle(effective, location, diagnostics, sizePt) {
|
|
328
|
+
const { spacingBefore: _spacingBefore, ...style } = effective.style;
|
|
329
|
+
if (effective.spacingAfterPercent === void 0) return style;
|
|
330
|
+
const { val, xpath } = effective.spacingAfterPercent;
|
|
331
|
+
const spacingAfter = (sizePt ?? (typeof style.fontSize === "string" ? Number.parseFloat(style.fontSize) : 18)) * val / 1e5 * (4 / 3);
|
|
332
|
+
if (Math.round(spacingAfter * 75) <= 158400) return {
|
|
333
|
+
...style,
|
|
334
|
+
spacingAfter
|
|
335
|
+
};
|
|
336
|
+
diagnostics.push({
|
|
337
|
+
code: "invalid-xml-value",
|
|
338
|
+
category: "corrupt-input",
|
|
339
|
+
disposition: "omitted",
|
|
340
|
+
location: {
|
|
341
|
+
...location,
|
|
342
|
+
xpath
|
|
343
|
+
},
|
|
344
|
+
attributeOrElement: "a:spcPct/@val",
|
|
345
|
+
rawValue: String(val)
|
|
346
|
+
});
|
|
347
|
+
return style;
|
|
348
|
+
}
|
|
349
|
+
/** Reads the body-local DrawingML hierarchy for an unbound rich text host. */
|
|
350
|
+
function readRichTextListStyles(txBody, location, diagnostics) {
|
|
351
|
+
return readDrawingListStyles(txBody.child(A_NS, "lstStyle"), location, diagnostics, (cursor) => {
|
|
352
|
+
const { style: { baselineShift: _baselineShift, ...style }, decoration } = readRunProperties(cursor, location, diagnostics, true);
|
|
353
|
+
return {
|
|
354
|
+
style,
|
|
355
|
+
...decoration === void 0 ? {} : { decoration }
|
|
356
|
+
};
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Shared rich-text body reader for text boxes, shapes, table cells, and speaker notes.
|
|
361
|
+
*/
|
|
362
|
+
function readRichTextBody(txBody, location, diagnostics, host = "free", ancestorDecorations) {
|
|
363
|
+
let paddingTop;
|
|
364
|
+
let paddingRight;
|
|
365
|
+
let paddingBottom;
|
|
366
|
+
let paddingLeft;
|
|
367
|
+
let verticalAlign;
|
|
368
|
+
let textWrap;
|
|
369
|
+
const bodyPr = txBody.child(A_NS, "bodyPr");
|
|
370
|
+
if (bodyPr !== void 0) {
|
|
371
|
+
const rawBodyPr = bodyPr.attrsObject([
|
|
372
|
+
"wrap",
|
|
373
|
+
"rtlCol",
|
|
374
|
+
"lIns",
|
|
375
|
+
"tIns",
|
|
376
|
+
"rIns",
|
|
377
|
+
"bIns",
|
|
378
|
+
"anchor",
|
|
379
|
+
"anchorCtr",
|
|
380
|
+
"spcFirstLastPara",
|
|
381
|
+
"numCol",
|
|
382
|
+
"spcCol"
|
|
383
|
+
]);
|
|
384
|
+
const parsedBodyPr = BodyPrFragmentSchema.safeParse(rawBodyPr);
|
|
385
|
+
if (!parsedBodyPr.success) diagnostics.push({
|
|
386
|
+
code: "invalid-xml-value",
|
|
387
|
+
category: "corrupt-input",
|
|
388
|
+
disposition: "recovered",
|
|
389
|
+
location: {
|
|
390
|
+
...location,
|
|
391
|
+
xpath: bodyPr.xpath
|
|
392
|
+
},
|
|
393
|
+
attributeOrElement: "a:bodyPr",
|
|
394
|
+
rawValue: JSON.stringify(rawBodyPr)
|
|
395
|
+
});
|
|
396
|
+
else {
|
|
397
|
+
const b = parsedBodyPr.data;
|
|
398
|
+
if (b.wrap === "none") textWrap = "nowrap";
|
|
399
|
+
else if (b.wrap === "square") textWrap = "normal";
|
|
400
|
+
if (b.anchor !== void 0) verticalAlign = anchorToVerticalAlign[b.anchor];
|
|
401
|
+
}
|
|
402
|
+
const insets = readOoxmlBoxInsets({
|
|
403
|
+
rawAttrs: rawBodyPr,
|
|
404
|
+
attrNames: {
|
|
405
|
+
left: "lIns",
|
|
406
|
+
top: "tIns",
|
|
407
|
+
right: "rIns",
|
|
408
|
+
bottom: "bIns"
|
|
409
|
+
},
|
|
410
|
+
elementXpath: bodyPr.xpath,
|
|
411
|
+
location,
|
|
412
|
+
diagnostics
|
|
413
|
+
});
|
|
414
|
+
paddingLeft = insets.paddingLeft;
|
|
415
|
+
paddingTop = insets.paddingTop;
|
|
416
|
+
paddingRight = insets.paddingRight;
|
|
417
|
+
paddingBottom = insets.paddingBottom;
|
|
418
|
+
bodyPr.ignoreEmptyChild(A_NS, "noAutofit");
|
|
419
|
+
bodyPr.ignoreEmptyChild(A_NS, "spAutoFit");
|
|
420
|
+
bodyPr.child(A_NS, "normAutofit")?.attrsObject(["fontScale", "lnSpcReduction"]);
|
|
421
|
+
}
|
|
422
|
+
const listStyles = host === "placeholder" ? readPlaceholderListOverrides(txBody, location, diagnostics) : readRichTextListStyles(txBody, location, diagnostics);
|
|
423
|
+
const importedParagraphs = txBody.children(A_NS, "p").map((pCursor) => readParagraph(pCursor, location, diagnostics, listStyles, ancestorDecorations, host));
|
|
424
|
+
return {
|
|
425
|
+
boxStyle: {
|
|
426
|
+
...paddingTop === void 0 ? {} : { paddingTop },
|
|
427
|
+
...paddingRight === void 0 ? {} : { paddingRight },
|
|
428
|
+
...paddingBottom === void 0 ? {} : { paddingBottom },
|
|
429
|
+
...paddingLeft === void 0 ? {} : { paddingLeft },
|
|
430
|
+
...verticalAlign === void 0 ? {} : { verticalAlign },
|
|
431
|
+
...textWrap === void 0 ? {} : { textWrap }
|
|
432
|
+
},
|
|
433
|
+
importedParagraphs
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
/** Returns a flat TextStyle only when one whole paragraph can be expressed on the host. */
|
|
437
|
+
function promoteSingleParagraph(paragraphs) {
|
|
438
|
+
if (paragraphs.length !== 1) return void 0;
|
|
439
|
+
const paragraph = paragraphs[0];
|
|
440
|
+
const { list, marginLeft, indent } = paragraph.style;
|
|
441
|
+
if (list !== void 0 || marginLeft !== void 0 || indent !== void 0) return void 0;
|
|
442
|
+
const run = paragraph.runs[0];
|
|
443
|
+
if (paragraph.runs.length > 1 || run !== void 0 && (run.kind !== "text" || run.style.baselineShift !== void 0)) return void 0;
|
|
444
|
+
return {
|
|
445
|
+
style: Object.fromEntries(Object.entries({
|
|
446
|
+
...paragraph.style,
|
|
447
|
+
...run?.style
|
|
448
|
+
}).filter(([key]) => textStyleKeys.has(key))),
|
|
449
|
+
...run === void 0 ? {} : { text: run.text }
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
/** Populates a `RichTextContainer` (`TextNode`, `ShapeNode`, `CellNode`, `NotesNode`) from imported paragraphs. */
|
|
453
|
+
function populateRichTextNode(target, importedParagraphs) {
|
|
454
|
+
const paragraphNodes = importedParagraphs.map((para) => {
|
|
455
|
+
const pNode = createParagraphNode(Object.keys(para.style).length === 0 ? {} : { style: para.style });
|
|
456
|
+
if (para.runs.length === 1 && para.runs[0].kind === "text" && Object.keys(para.runs[0].style).length === 0) pNode.content(para.runs[0].text);
|
|
457
|
+
else if (para.runs.length > 0) pNode.content(...para.runs.map((run) => {
|
|
458
|
+
const runProps = Object.keys(run.style).length === 0 ? {} : { style: run.style };
|
|
459
|
+
if (run.kind === "slide-number") return createSlideNumberNode(runProps);
|
|
460
|
+
if (run.kind === "date-time") return createDateTimeNode({
|
|
461
|
+
...runProps,
|
|
462
|
+
format: run.format
|
|
463
|
+
});
|
|
464
|
+
if (run.kind === "sup") return createSupNode(runProps).content(run.text);
|
|
465
|
+
if (run.kind === "sub") return createSubNode(runProps).content(run.text);
|
|
466
|
+
return Object.keys(run.style).length === 0 ? run.text : createSpanNode({ style: run.style }).content(run.text);
|
|
467
|
+
}));
|
|
468
|
+
return pNode;
|
|
469
|
+
});
|
|
470
|
+
target.content(...paragraphNodes);
|
|
471
|
+
}
|
|
472
|
+
export { populateRichTextNode, promoteSingleParagraph, readRichTextBody, textFieldDateTimeImportHandler, textFieldSlideNumImportHandler };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { authorIdSchema } from "
|
|
2
|
-
import { layoutStyleShape } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import "
|
|
10
|
-
import { motionPropsShape } from "
|
|
11
|
-
import "
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
4
|
+
import { geometrySchema } from "../../kernel/geometry-schemas.js";
|
|
5
|
+
import { textStyleShape, visualStyleShape } from "../../kernel/theme.js";
|
|
6
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
7
|
+
import "./geometry.js";
|
|
8
|
+
import { optionalNameSchema } from "./identity.js";
|
|
9
|
+
import { morphKeySchema } from "./morph-api.js";
|
|
10
|
+
import { motionPropsShape } from "./motion-schemas.js";
|
|
11
|
+
import "../../kernel/capability.js";
|
|
12
|
+
import { RichTextContainer } from "../../kernel/document.js";
|
|
13
|
+
import "../../kernel/pptx-write/xml.js";
|
|
14
14
|
import { z } from "zod";
|
|
15
|
-
// ../
|
|
15
|
+
// ../core/dist/capabilities/shared/shape-declaration.js
|
|
16
16
|
const shapeCoordinateSchema = z.number().finite().min(-1e6).max(1e6);
|
|
17
17
|
const shapeSizeSchema = z.number().finite().positive().refine((value) => {
|
|
18
18
|
const extentEmu = pxToEmu(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { masterTextStyleCategoryForRole, resolvePlaceholderBoxFromLayers } from "
|
|
2
|
-
import "
|
|
3
|
-
// ../
|
|
1
|
+
import { masterTextStyleCategoryForRole, resolvePlaceholderBoxFromLayers } from "../../kernel/placeholders.js";
|
|
2
|
+
import "../../kernel/capability.js";
|
|
3
|
+
// ../core/dist/capabilities/shared/style-inheritance.js
|
|
4
4
|
function replaceWhenDeclared(inherited, localValue, isDeclaredLocally) {
|
|
5
5
|
return isDeclaredLocally && localValue !== void 0 ? localValue : inherited;
|
|
6
6
|
}
|
|
@@ -35,6 +35,7 @@ const sharedStyleRules = Object.freeze({
|
|
|
35
35
|
letterSpacing: levelRule(),
|
|
36
36
|
textTransform: levelRule(),
|
|
37
37
|
textDecoration: levelRule(),
|
|
38
|
+
textStroke: levelRule(),
|
|
38
39
|
textShadow: {
|
|
39
40
|
freeContainer: "inherit",
|
|
40
41
|
placeholderLayer: "levelStyle",
|
|
@@ -129,8 +130,14 @@ function resolvePlaceholderLevelTextStyle(placeholder, levelIndex0, slideLocalSt
|
|
|
129
130
|
applyLayer(result, placeholder.layoutPlaceholder?.style, "levelStyle");
|
|
130
131
|
applyLayer(result, layoutPhLevel, "levelStyle");
|
|
131
132
|
applyLayer(result, slideLocalStyle, "levelStyle");
|
|
132
|
-
const
|
|
133
|
-
|
|
133
|
+
for (const key of [
|
|
134
|
+
"list",
|
|
135
|
+
"marginLeft",
|
|
136
|
+
"indent"
|
|
137
|
+
]) {
|
|
138
|
+
const value = layoutPhLevel?.[key] ?? masterPhLevel?.[key] ?? masterTxLevel?.[key];
|
|
139
|
+
if (value !== void 0) result[key] = value;
|
|
140
|
+
}
|
|
134
141
|
return result;
|
|
135
142
|
}
|
|
136
143
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommonNode, RichTextContainer } from "
|
|
2
|
-
// ../
|
|
1
|
+
import { CommonNode, RichTextContainer } from "../../kernel/document.js";
|
|
2
|
+
// ../core/dist/capabilities/shared/text-declaration.js
|
|
3
3
|
/** Creates the editable text box shared by the command factory and the Text JSX element. */
|
|
4
4
|
function createTextNode(props) {
|
|
5
5
|
return new RichTextContainer("text", "text", props);
|
|
@@ -24,4 +24,8 @@ function createSubNode(props) {
|
|
|
24
24
|
function createSlideNumberNode(props) {
|
|
25
25
|
return new CommonNode("slide-number", "slide-number", props);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
/** Creates the native dynamic date field shared by the command factory and JSX element. */
|
|
28
|
+
function createDateTimeNode(props) {
|
|
29
|
+
return new CommonNode("date-time", "date-time", props);
|
|
30
|
+
}
|
|
31
|
+
export { createDateTimeNode, createParagraphNode, createSlideNumberNode, createSpanNode, createSubNode, createSupNode, createTextNode };
|