@officedk/pptxdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
7
|
-
import {
|
|
8
|
-
import "
|
|
9
|
-
import { fontPresentationContributions, requiresFontGlyph, requiresVisibleFontGlyph } from "
|
|
10
|
-
import { findMissingFontGlyphs, isTrueTypeFontEmbeddable, openMeasureFontFace, resolveDeclaredFaceSlot, shapeFontAdvances, shapeFontOutlines, validateFontFaceResource } from "
|
|
11
|
-
import { parseStepDeclarationProps, pickMotionProps, validateMotionFlag } from "
|
|
12
|
-
import { motionPropKeySet } from "
|
|
1
|
+
import { componentLabel } from "../../kernel/declaration.js";
|
|
2
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
3
|
+
import { paragraphIndentToEmu, pxToEmu } from "../../kernel/drawing-units.js";
|
|
4
|
+
import { hasFontFaceBytes, peekFontFaceResource, resolveFontClassification } from "../../kernel/font-seal.js";
|
|
5
|
+
import { isFont, isTextGradient, textStyleKeys, validateTextStyle } from "../../kernel/theme.js";
|
|
6
|
+
import { maximumParagraphIndentPx } from "../../kernel/placeholders.js";
|
|
7
|
+
import { formatDateTime } from "./date-time.js";
|
|
8
|
+
import { paddingStyleKeys } from "../../kernel/block-flex-layout.js";
|
|
9
|
+
import { fontPresentationContributions, requiresFontGlyph, requiresVisibleFontGlyph } from "./font/font-embedding.js";
|
|
10
|
+
import { findMissingFontGlyphs, fontFaceCoversCodePoint, isTrueTypeFontEmbeddable, openMeasureFontFace, resolveDeclaredFaceSlot, shapeFontAdvances, shapeFontOutlines, unkernedFontAdvances, validateFontFaceResource } from "./font/font-engine.js";
|
|
11
|
+
import { parseStepDeclarationProps, pickMotionProps, validateMotionFlag } from "./motion-api.js";
|
|
12
|
+
import { motionPropKeySet } from "./motion-schemas.js";
|
|
13
|
+
import "../../kernel/capability.js";
|
|
14
|
+
import { textDecorationAttributes, textFillXml, textStrokeXml, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
15
|
+
import { referenceDateTimestamp } from "../../kernel/stage-options.js";
|
|
13
16
|
import { hasLocalDeclaration, localDeclaredKeySet, resolvePlaceholderBaseTextStyle, resolvePlaceholderLevelTextStyle } from "./style-inheritance.js";
|
|
14
|
-
import { parseBaselineShiftThousandths, parseParagraphStyle, parseRunStyle, parseTextInsets } from "./text-schemas.js";
|
|
15
|
-
import { resolveShadow, textShadowXml } from "./visual.js";
|
|
17
|
+
import { dateTimeAuthorPropsKeys, dateTimeAuthorPropsObjectSchema, isInlineRichTextNodeType, isInlineTextFieldNodeType, parseBaselineShiftThousandths, parseParagraphStyle, parseRunStyle, parseTextInsets, spanAuthorPropsKeys } from "./text-schemas.js";
|
|
18
|
+
import { borderAttributes, gradientDefSvg, resolveGradientSpec, resolveShadow, resolveTextStroke, textShadowXml } from "./visual.js";
|
|
16
19
|
import LineBreakerImplementation from "linebreak";
|
|
17
|
-
// ../
|
|
20
|
+
// ../core/dist/capabilities/shared/text-service.js
|
|
18
21
|
/**
|
|
19
|
-
* Author metadata accepted on
|
|
22
|
+
* Author metadata accepted on paragraphs and inline text declarations declarations.
|
|
20
23
|
*
|
|
21
24
|
* Scoped id validation belongs to the formal build around these nodes; the shared text parser must
|
|
22
25
|
* skip the field while resolving styles instead of reporting it as an unimplemented parameter.
|
|
23
26
|
*/
|
|
24
27
|
const textAuthorMetadataKeys = /* @__PURE__ */ new Set(["id"]);
|
|
28
|
+
const spanAllowedPropKeySet = new Set(spanAuthorPropsKeys);
|
|
29
|
+
const dateTimeAllowedPropKeySet = new Set(dateTimeAuthorPropsKeys);
|
|
25
30
|
const LineBreaker = LineBreakerImplementation;
|
|
26
31
|
const graphemes = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
27
32
|
const defaultTextStyle = Object.freeze({
|
|
@@ -35,11 +40,11 @@ const defaultTextStyle = Object.freeze({
|
|
|
35
40
|
function record(value) {
|
|
36
41
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37
42
|
}
|
|
38
|
-
function escapedXml(value) {
|
|
43
|
+
function escapedXml(value, field) {
|
|
39
44
|
try {
|
|
40
45
|
return xmlEscape(value);
|
|
41
46
|
} catch {
|
|
42
|
-
throw new CapabilityError("invalid-xml-character", "Text content or font name contains characters not allowed in XML 1.0");
|
|
47
|
+
throw new CapabilityError("invalid-xml-character", "Text content or font name contains characters not allowed in XML 1.0", void 0, { field });
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
function isHostText(child) {
|
|
@@ -160,6 +165,15 @@ function normalizedFonts(style) {
|
|
|
160
165
|
function isEastAsianCodePoint(cp) {
|
|
161
166
|
return cp >= 11904 && cp <= 12031 || cp >= 12032 && cp <= 12255 || cp >= 12272 && cp <= 12351 || cp >= 12352 && cp <= 12543 || cp >= 12544 && cp <= 12591 || cp >= 12592 && cp <= 12687 || cp >= 12704 && cp <= 12735 || cp >= 12784 && cp <= 12799 || cp >= 12800 && cp <= 13311 || cp >= 13312 && cp <= 19903 || cp >= 19968 && cp <= 40959 || cp >= 4352 && cp <= 4607 || cp >= 43360 && cp <= 43391 || cp >= 44032 && cp <= 55295 || cp >= 63744 && cp <= 64255 || cp >= 65040 && cp <= 65055 || cp >= 65072 && cp <= 65135 || cp >= 65281 && cp <= 65376 || cp >= 65377 && cp <= 65503 || cp >= 65504 && cp <= 65510 || cp >= 110592 && cp <= 110959 || cp >= 131072 && cp <= 205743;
|
|
162
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* East Asian ambiguous punctuation and symbols (UAX #11 subset) routed to the East Asian
|
|
170
|
+
* font slot under `zh*`/`ja*`/`ko*` `lang` or adjacent East Asian context when covered by
|
|
171
|
+
* the EA face. Excludes Greek, Cyrillic, ASCII, `U+2013` (`–`), `U+00B7` (`·`), and `U+00B0` (`°`).
|
|
172
|
+
*/
|
|
173
|
+
function isAmbiguousEastAsianCodePoint(cp) {
|
|
174
|
+
return cp === 161 || cp === 164 || cp >= 167 && cp <= 168 || cp === 170 || cp >= 173 && cp <= 174 || cp >= 177 && cp <= 180 || cp === 182 || cp >= 184 && cp <= 186 || cp >= 188 && cp <= 191 || cp === 215 || cp === 247 || cp >= 8212 && cp <= 8214 || cp >= 8216 && cp <= 8223 || cp >= 8224 && cp <= 8225 || cp >= 8229 && cp <= 8230 || cp === 8240 || cp >= 8242 && cp <= 8243 || cp === 8245 || cp === 8251 || cp === 8451 || cp === 8453 || cp === 8457 || cp === 8470 || cp === 8481 || cp === 8491 || cp >= 8544 && cp <= 8555 || cp >= 8560 && cp <= 8569 || cp >= 8592 && cp <= 8601 || cp >= 8632 && cp <= 8633 || cp === 8658 || cp === 8660 || cp === 8679 || cp === 8704 || cp >= 8706 && cp <= 8707 || cp >= 8711 && cp <= 8712 || cp === 8715 || cp === 8719 || cp === 8721 || cp === 8725 || cp === 8730 || cp >= 8733 && cp <= 8736 || cp === 8739 || cp === 8741 || cp >= 8743 && cp <= 8748 || cp === 8750 || cp >= 8756 && cp <= 8759 || cp >= 8764 && cp <= 8765 || cp === 8776 || cp === 8780 || cp === 8786 || cp >= 8800 && cp <= 8801 || cp >= 8804 && cp <= 8807 || cp >= 8810 && cp <= 8811 || cp >= 8814 && cp <= 8815 || cp >= 8834 && cp <= 8835 || cp >= 8838 && cp <= 8839 || cp === 8853 || cp === 8857 || cp === 8869 || cp === 8895 || cp === 8978 || cp >= 9312 && cp <= 9449 || cp >= 9451 && cp <= 9471 || cp >= 9472 && cp <= 9587 || cp >= 9600 && cp <= 9621 || cp >= 9632 && cp <= 9633 || cp >= 9635 && cp <= 9641 || cp >= 9650 && cp <= 9651 || cp >= 9654 && cp <= 9655 || cp >= 9660 && cp <= 9661 || cp >= 9664 && cp <= 9665 || cp >= 9670 && cp <= 9672 || cp === 9675 || cp >= 9678 && cp <= 9681 || cp >= 9698 && cp <= 9701 || cp === 9711 || cp >= 9733 && cp <= 9734 || cp === 9737 || cp >= 9742 && cp <= 9743 || cp === 9756 || cp === 9758 || cp === 9792 || cp === 9794 || cp >= 9824 && cp <= 9825 || cp >= 9827 && cp <= 9829 || cp >= 9831 && cp <= 9834 || cp >= 9836 && cp <= 9837 || cp === 9839 || cp >= 10102 && cp <= 10111;
|
|
175
|
+
}
|
|
176
|
+
const eastAsianLangPattern = /^(?:zh|ja|ko)(?:$|-)/iu;
|
|
163
177
|
function isNeutralScriptChar(ch, cp) {
|
|
164
178
|
return cp !== 12288 && /^[\p{White_Space}\p{Cc}\p{Default_Ignorable_Code_Point}]$/u.test(ch);
|
|
165
179
|
}
|
|
@@ -177,57 +191,162 @@ function effectiveEastAsianRunStyle(style) {
|
|
|
177
191
|
themeFont: style.eastAsianThemeFont
|
|
178
192
|
};
|
|
179
193
|
}
|
|
180
|
-
function
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
function createEastAsianCoverageChecker(style) {
|
|
195
|
+
if (style.eastAsianFontFamily === void 0) return void 0;
|
|
196
|
+
const fonts = normalizedFontsForReference(style.eastAsianFontFamily, style.fontWeight, style.fontStyle).filter((font) => font.hasResource && font.data !== void 0);
|
|
197
|
+
if (fonts.length === 0) return void 0;
|
|
198
|
+
const faces = [];
|
|
199
|
+
for (const font of fonts) try {
|
|
200
|
+
faces.push(validateFontFaceResource({
|
|
201
|
+
family: font.family,
|
|
202
|
+
weight: font.weight,
|
|
203
|
+
style: font.style,
|
|
204
|
+
substitute: font.substitute,
|
|
205
|
+
data: font.data,
|
|
206
|
+
identity: font.identity
|
|
207
|
+
}));
|
|
208
|
+
} catch {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
return (cp) => faces.some((face) => fontFaceCoversCodePoint(face, cp));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Segments all runs of a single paragraph into effective Latin / East Asian script segments.
|
|
215
|
+
*
|
|
216
|
+
* Uses paragraph-wide strong-script context so ambiguous East Asian punctuation in undeclared-`lang`
|
|
217
|
+
* runs and boundary neutral whitespace between East Asian and Latin/digit runs match native DrawingML
|
|
218
|
+
* slot selection across measurement, preview, FontUsage, and font subsetting.
|
|
219
|
+
*/
|
|
220
|
+
function splitParagraphRunsForEffectiveScripts(runs) {
|
|
221
|
+
const runMeta = runs.map((run) => {
|
|
222
|
+
const eaStyle = effectiveEastAsianRunStyle(run.style);
|
|
223
|
+
const hasDistinctEa = eaStyle !== run.style;
|
|
224
|
+
return {
|
|
225
|
+
run,
|
|
226
|
+
eaStyle,
|
|
227
|
+
hasDistinctEa,
|
|
228
|
+
coversEa: hasDistinctEa ? createEastAsianCoverageChecker(run.style) : void 0
|
|
229
|
+
};
|
|
230
|
+
});
|
|
231
|
+
const chars = [];
|
|
232
|
+
for (let runIndex = 0; runIndex < runMeta.length; runIndex += 1) {
|
|
233
|
+
const { run } = runMeta[runIndex];
|
|
234
|
+
for (const ch of run.text) {
|
|
235
|
+
const cp = ch.codePointAt(0);
|
|
236
|
+
if (cp === void 0) continue;
|
|
237
|
+
const isNeutral = isNeutralScriptChar(ch, cp);
|
|
238
|
+
const definiteScript = isNeutral ? void 0 : isEastAsianCodePoint(cp) ? "ea" : isAmbiguousEastAsianCodePoint(cp) ? void 0 : "latin";
|
|
239
|
+
chars.push({
|
|
240
|
+
runIndex,
|
|
241
|
+
ch,
|
|
242
|
+
cp,
|
|
243
|
+
isNeutral,
|
|
244
|
+
definiteScript,
|
|
245
|
+
resolvedScript: definiteScript
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const n = chars.length;
|
|
250
|
+
const prevStrong = Array.from({ length: n });
|
|
251
|
+
let lastStrong;
|
|
252
|
+
for (let i = 0; i < n; i += 1) {
|
|
253
|
+
prevStrong[i] = lastStrong;
|
|
254
|
+
const def = chars[i].definiteScript;
|
|
255
|
+
if (def !== void 0) lastStrong = def;
|
|
256
|
+
}
|
|
257
|
+
const nextStrong = Array.from({ length: n });
|
|
258
|
+
let upcomingStrong;
|
|
259
|
+
for (let i = n - 1; i >= 0; i -= 1) {
|
|
260
|
+
nextStrong[i] = upcomingStrong;
|
|
261
|
+
const def = chars[i].definiteScript;
|
|
262
|
+
if (def !== void 0) upcomingStrong = def;
|
|
263
|
+
}
|
|
264
|
+
for (let i = 0; i < n; i += 1) {
|
|
265
|
+
const entry = chars[i];
|
|
266
|
+
if (entry.isNeutral) continue;
|
|
267
|
+
const meta = runMeta[entry.runIndex];
|
|
268
|
+
if (!meta.hasDistinctEa) {
|
|
269
|
+
entry.resolvedScript = "latin";
|
|
202
270
|
continue;
|
|
203
271
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
272
|
+
if (entry.definiteScript !== void 0) {
|
|
273
|
+
entry.resolvedScript = entry.definiteScript;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
const lang = meta.run.style.lang;
|
|
277
|
+
let candidate;
|
|
278
|
+
if (lang !== void 0) candidate = eastAsianLangPattern.test(lang) ? "ea" : "latin";
|
|
279
|
+
else candidate = prevStrong[i] === "ea" || nextStrong[i] === "ea" ? "ea" : "latin";
|
|
280
|
+
if (candidate === "ea" && meta.coversEa !== void 0) entry.resolvedScript = meta.coversEa(entry.cp) ? "ea" : "latin";
|
|
281
|
+
else entry.resolvedScript = candidate;
|
|
282
|
+
}
|
|
283
|
+
const prevResolved = Array.from({ length: n });
|
|
284
|
+
let lastResolved;
|
|
285
|
+
for (let i = 0; i < n; i += 1) {
|
|
286
|
+
prevResolved[i] = lastResolved;
|
|
287
|
+
if (!chars[i].isNeutral) lastResolved = chars[i].resolvedScript;
|
|
288
|
+
}
|
|
289
|
+
const nextResolved = Array.from({ length: n });
|
|
290
|
+
let upcomingResolved;
|
|
291
|
+
for (let i = n - 1; i >= 0; i -= 1) {
|
|
292
|
+
nextResolved[i] = upcomingResolved;
|
|
293
|
+
if (!chars[i].isNeutral) upcomingResolved = chars[i].resolvedScript;
|
|
294
|
+
}
|
|
295
|
+
for (let i = 0; i < n; i += 1) {
|
|
296
|
+
const entry = chars[i];
|
|
297
|
+
if (!entry.isNeutral) continue;
|
|
298
|
+
const prev = prevResolved[i];
|
|
299
|
+
const next = nextResolved[i];
|
|
300
|
+
if (prev === "latin" || next === "latin") entry.resolvedScript = "latin";
|
|
301
|
+
else if (prev === "ea" || next === "ea") entry.resolvedScript = "ea";
|
|
302
|
+
else entry.resolvedScript = "latin";
|
|
303
|
+
}
|
|
304
|
+
const perRun = runMeta.map(() => []);
|
|
305
|
+
let charPos = 0;
|
|
306
|
+
for (let runIndex = 0; runIndex < runMeta.length; runIndex += 1) {
|
|
307
|
+
const { run, eaStyle, hasDistinctEa } = runMeta[runIndex];
|
|
308
|
+
if (run.text === "" || !hasDistinctEa) {
|
|
309
|
+
perRun[runIndex].push({
|
|
310
|
+
script: "latin",
|
|
311
|
+
text: run.text,
|
|
312
|
+
style: run.style
|
|
215
313
|
});
|
|
216
|
-
|
|
217
|
-
|
|
314
|
+
while (charPos < n && chars[charPos].runIndex === runIndex) charPos += 1;
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
let activeScript;
|
|
318
|
+
let buffer = "";
|
|
319
|
+
while (charPos < n && chars[charPos].runIndex === runIndex) {
|
|
320
|
+
const entry = chars[charPos];
|
|
321
|
+
const script = entry.resolvedScript ?? "latin";
|
|
322
|
+
if (activeScript === void 0) {
|
|
323
|
+
activeScript = script;
|
|
324
|
+
buffer = entry.ch;
|
|
325
|
+
} else if (script === activeScript) buffer += entry.ch;
|
|
326
|
+
else {
|
|
327
|
+
perRun[runIndex].push({
|
|
328
|
+
script: activeScript,
|
|
329
|
+
text: buffer,
|
|
330
|
+
style: activeScript === "ea" ? eaStyle : run.style
|
|
331
|
+
});
|
|
332
|
+
activeScript = script;
|
|
333
|
+
buffer = entry.ch;
|
|
334
|
+
}
|
|
335
|
+
charPos += 1;
|
|
218
336
|
}
|
|
337
|
+
if (activeScript !== void 0 && buffer !== "") perRun[runIndex].push({
|
|
338
|
+
script: activeScript,
|
|
339
|
+
text: buffer,
|
|
340
|
+
style: activeScript === "ea" ? eaStyle : run.style
|
|
341
|
+
});
|
|
219
342
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
343
|
+
return perRun;
|
|
344
|
+
}
|
|
345
|
+
function splitRunForEffectiveScripts(text, style) {
|
|
346
|
+
return splitParagraphRunsForEffectiveScripts([{
|
|
347
|
+
text,
|
|
223
348
|
style
|
|
224
|
-
}];
|
|
225
|
-
if (buffer !== "") segments.push({
|
|
226
|
-
script: activeScript,
|
|
227
|
-
text: buffer,
|
|
228
|
-
style: activeScript === "ea" ? eaStyle : style
|
|
229
|
-
});
|
|
230
|
-
return segments;
|
|
349
|
+
}])[0];
|
|
231
350
|
}
|
|
232
351
|
function hasIndependentThemeMinorEa(theme) {
|
|
233
352
|
if (theme.theme.fonts.minorEastAsian !== void 0) return true;
|
|
@@ -244,9 +363,6 @@ function validateRunStyle(style) {
|
|
|
244
363
|
if (baselineShift !== void 0 && parseBaselineShiftThousandths(baselineShift) === void 0) throw new CapabilityError("invalid-baseline-shift", "baselineShift must be a non-zero finite percentage string within DrawingML ST_Percentage range", void 0, { field: "style.baselineShift" });
|
|
245
364
|
return style;
|
|
246
365
|
}
|
|
247
|
-
function readRunStyle(value, label = "Span.style") {
|
|
248
|
-
return parseRunStyle(value, label);
|
|
249
|
-
}
|
|
250
366
|
function mergeRunStyle(parent, child, theme) {
|
|
251
367
|
const declared = Object.fromEntries(Object.entries(child).filter(([, value]) => value !== void 0));
|
|
252
368
|
if (child.fontFamily !== void 0) {
|
|
@@ -261,7 +377,7 @@ function mergeRunStyle(parent, child, theme) {
|
|
|
261
377
|
if (child.eastAsianThemeFont === void 0 && eaFont.themeFont === void 0) delete declared["eastAsianThemeFont"];
|
|
262
378
|
else declared["eastAsianThemeFont"] = child.eastAsianThemeFont ?? eaFont.themeFont;
|
|
263
379
|
}
|
|
264
|
-
if (child.color !== void 0 && !isResolvedColor(child.color)) declared["color"] = theme
|
|
380
|
+
if (child.color !== void 0 && !isResolvedColor(child.color)) declared["color"] = resolveRunColor(theme, child.color);
|
|
265
381
|
if (child.lang !== void 0) declared["lang"] = child.lang;
|
|
266
382
|
const merged = {
|
|
267
383
|
...parent,
|
|
@@ -309,7 +425,7 @@ function mergeLocalRunDeclared(parent, child, theme) {
|
|
|
309
425
|
if (resolvedEa.themeFont === void 0) delete declared["eastAsianThemeFont"];
|
|
310
426
|
else declared["eastAsianThemeFont"] = resolvedEa.themeFont;
|
|
311
427
|
}
|
|
312
|
-
if (hasLocalDeclaration(child, "color") && !isResolvedColor(child["color"])) declared["color"] = theme
|
|
428
|
+
if (hasLocalDeclaration(child, "color") && !isResolvedColor(child["color"])) declared["color"] = resolveRunColor(theme, child["color"]);
|
|
313
429
|
return declared;
|
|
314
430
|
}
|
|
315
431
|
function resolveRunStyleFromRecord(style, theme) {
|
|
@@ -318,7 +434,7 @@ function resolveRunStyleFromRecord(style, theme) {
|
|
|
318
434
|
const eaFont = rawEa !== void 0 ? theme.resolveEastAsianFont(rawEa) : hasIndependentThemeMinorEa(theme) ? theme.resolveEastAsianFont("minor") : font.themeFont !== void 0 ? theme.resolveEastAsianFont(font.themeFont) : void 0;
|
|
319
435
|
const includeEa = rawEa !== void 0 || hasIndependentThemeMinorEa(theme) || eaFont !== void 0 && (eaFont.font ?? eaFont.family) !== (font.font ?? font.family);
|
|
320
436
|
const rawColor = style["color"];
|
|
321
|
-
const color = rawColor === void 0 ? theme
|
|
437
|
+
const color = rawColor === void 0 ? resolveRunColor(theme, defaultTextStyle.color) : isResolvedColor(rawColor) ? rawColor : resolveRunColor(theme, rawColor);
|
|
322
438
|
return validateRunStyle({
|
|
323
439
|
fontFamily: font.font ?? font.family,
|
|
324
440
|
...includeEa && eaFont !== void 0 ? {
|
|
@@ -333,6 +449,7 @@ function resolveRunStyleFromRecord(style, theme) {
|
|
|
333
449
|
...style["letterSpacing"] === void 0 ? {} : { letterSpacing: style["letterSpacing"] },
|
|
334
450
|
...style["textTransform"] === void 0 ? {} : { textTransform: style["textTransform"] },
|
|
335
451
|
...style["textDecoration"] === void 0 ? {} : { textDecoration: style["textDecoration"] },
|
|
452
|
+
textStroke: style["textStroke"],
|
|
336
453
|
...style["textShadow"] === void 0 || style["textShadow"] === "none" ? {} : { textShadow: style["textShadow"] },
|
|
337
454
|
...style["lang"] === void 0 ? {} : { lang: style["lang"] }
|
|
338
455
|
});
|
|
@@ -352,13 +469,13 @@ function readPlaceholderTextStyle(value, label, placeholder) {
|
|
|
352
469
|
const font = masterTheme.resolveFont(merged.fontFamily ?? defaultTextStyle.fontFamily);
|
|
353
470
|
const eaFont = eaDeclared ? masterTheme.resolveEastAsianFont(effectiveBase["eastAsianFontFamily"]) : hasIndependentThemeMinorEa(masterTheme) ? masterTheme.resolveEastAsianFont("minor") : font.themeFont !== void 0 ? masterTheme.resolveEastAsianFont(font.themeFont) : void 0;
|
|
354
471
|
const includeEa = eaDeclared || hasIndependentThemeMinorEa(masterTheme) || eaFont !== void 0 && (eaFont.font ?? eaFont.family) !== (font.font ?? font.family);
|
|
355
|
-
if (merged.color !== void 0 && !isResolvedColor(merged.color)) masterTheme
|
|
472
|
+
if (merged.color !== void 0 && !isResolvedColor(merged.color)) resolveRunColor(masterTheme, merged.color);
|
|
356
473
|
validateTextStyle({
|
|
357
474
|
...merged,
|
|
358
475
|
fontFamily: font.font ?? font.family,
|
|
359
476
|
...includeEa && eaFont !== void 0 ? { eastAsianFontFamily: eaFont.font ?? eaFont.family } : { eastAsianFontFamily: void 0 },
|
|
360
477
|
...isResolvedColor(merged.color) ? { color: void 0 } : {}
|
|
361
|
-
});
|
|
478
|
+
}, masterTheme);
|
|
362
479
|
const result = {
|
|
363
480
|
...merged,
|
|
364
481
|
fontFamily: font.font ?? font.family,
|
|
@@ -374,7 +491,7 @@ function readPlaceholderTextStyle(value, label, placeholder) {
|
|
|
374
491
|
localDeclaredStyle
|
|
375
492
|
};
|
|
376
493
|
}
|
|
377
|
-
function readTextStyle(value, label, theme) {
|
|
494
|
+
function readTextStyle(value, label, theme, preserveShadowReset = false) {
|
|
378
495
|
const props = styleRecord(value, label);
|
|
379
496
|
onlyKnownKeys(props, [...textStyleKeys], label);
|
|
380
497
|
const rawCombined = {
|
|
@@ -390,13 +507,13 @@ function readTextStyle(value, label, theme) {
|
|
|
390
507
|
const font = theme.resolveFont(style.fontFamily ?? defaultTextStyle.fontFamily);
|
|
391
508
|
const eaFont = eaDeclared ? theme.resolveEastAsianFont(rawCombined["eastAsianFontFamily"]) : hasIndependentThemeMinorEa(theme) ? theme.resolveEastAsianFont("minor") : font.themeFont !== void 0 ? theme.resolveEastAsianFont(font.themeFont) : void 0;
|
|
392
509
|
const includeEa = eaDeclared || hasIndependentThemeMinorEa(theme) || eaFont !== void 0 && (eaFont.font ?? eaFont.family) !== (font.font ?? font.family);
|
|
393
|
-
if (style.color !== void 0 && !isResolvedColor(style.color)) theme
|
|
510
|
+
if (style.color !== void 0 && !isResolvedColor(style.color)) resolveRunColor(theme, style.color);
|
|
394
511
|
validateTextStyle({
|
|
395
512
|
...style,
|
|
396
513
|
fontFamily: font.font ?? font.family,
|
|
397
514
|
...includeEa && eaFont !== void 0 ? { eastAsianFontFamily: eaFont.font ?? eaFont.family } : { eastAsianFontFamily: void 0 },
|
|
398
515
|
...isResolvedColor(style.color) ? { color: void 0 } : {}
|
|
399
|
-
});
|
|
516
|
+
}, theme);
|
|
400
517
|
const result = {
|
|
401
518
|
...style,
|
|
402
519
|
fontFamily: font.font ?? font.family,
|
|
@@ -406,14 +523,11 @@ function readTextStyle(value, label, theme) {
|
|
|
406
523
|
} : { eastAsianFontFamily: void 0 },
|
|
407
524
|
...font.themeFont === void 0 ? {} : { themeFont: font.themeFont }
|
|
408
525
|
};
|
|
409
|
-
if (result.textShadow === "none") delete result.textShadow;
|
|
526
|
+
if (!preserveShadowReset && result.textShadow === "none") delete result.textShadow;
|
|
410
527
|
return result;
|
|
411
528
|
}
|
|
412
|
-
function
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
function collectRuns(children, style, runs, theme, fields, localDeclared) {
|
|
416
|
-
for (const child of children) {
|
|
529
|
+
function collectRuns(children, style, runs, theme, fields, parentPath, localDeclared, firstIndex = 0) {
|
|
530
|
+
for (const [index, child] of children.entries()) {
|
|
417
531
|
if (!hostChild(child)) throw new CapabilityError("invalid-text-child", "Text content tree contains invalid nodes");
|
|
418
532
|
if (isHostText(child)) {
|
|
419
533
|
if (child.text !== "") runs.push({
|
|
@@ -423,11 +537,16 @@ function collectRuns(children, style, runs, theme, fields, localDeclared) {
|
|
|
423
537
|
});
|
|
424
538
|
continue;
|
|
425
539
|
}
|
|
426
|
-
if (child.type
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
const
|
|
430
|
-
const
|
|
540
|
+
if (!isInlineRichTextNodeType(child.type)) throw new CapabilityError("unsupported-text-child", `${child.type} cannot be used as text paragraph or run`);
|
|
541
|
+
const label = componentLabel(child, firstIndex + index);
|
|
542
|
+
const path = parentPath === "" ? label : `${parentPath}/${label}`;
|
|
543
|
+
const allowedInlineKeys = child.type === "date-time" ? dateTimeAllowedPropKeySet : spanAllowedPropKeySet;
|
|
544
|
+
const unknown = Object.keys(child.props).find((key) => !allowedInlineKeys.has(key));
|
|
545
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Span contains unimplemented parameter ${unknown}`, path, {
|
|
546
|
+
prop: unknown,
|
|
547
|
+
field: unknown
|
|
548
|
+
});
|
|
549
|
+
const parsedSpanStyle = parseRunStyle(child.props["style"], path, theme);
|
|
431
550
|
let spanStyle = parsedSpanStyle;
|
|
432
551
|
if (child.type === "sup" || child.type === "sub") {
|
|
433
552
|
const defaultShift = child.type === "sup" ? "30%" : "-25%";
|
|
@@ -448,20 +567,24 @@ function collectRuns(children, style, runs, theme, fields, localDeclared) {
|
|
|
448
567
|
}
|
|
449
568
|
const nextStyle = mergeRunStyle(style, spanStyle, theme);
|
|
450
569
|
const nextLocalDeclared = localDeclared === void 0 ? void 0 : mergeLocalRunDeclared(localDeclared, spanStyle, theme);
|
|
451
|
-
if (child.type
|
|
452
|
-
|
|
570
|
+
if (isInlineTextFieldNodeType(child.type)) {
|
|
571
|
+
const isDateTime = child.type === "date-time";
|
|
572
|
+
if (child.children.length > 0) throw new CapabilityError(isDateTime ? "invalid-date-time" : "invalid-slide-number", `${isDateTime ? "DateTime" : "SlideNumber"} cannot contain children`, path);
|
|
573
|
+
const format = isDateTime ? dateTimeAuthorPropsObjectSchema.shape.format.safeParse(child.props["format"]) : void 0;
|
|
574
|
+
if (format?.success === false) throw new CapabilityError("invalid-date-time", "DateTime.format must be a supported date/time format", path, { field: "format" });
|
|
575
|
+
const resolvedFormat = format?.data ?? "datetimeFigureOut";
|
|
453
576
|
runs.push({
|
|
454
|
-
text: String(fields.slideNumber),
|
|
577
|
+
text: format === void 0 ? String(fields.slideNumber) : formatDateTime(resolvedFormat, referenceDateTimestamp(fields.referenceDate), nextStyle.lang),
|
|
455
578
|
style: nextStyle,
|
|
456
579
|
...nextLocalDeclared === void 0 ? {} : { localDeclared: nextLocalDeclared },
|
|
457
580
|
field: {
|
|
458
581
|
id: fields.createId?.() ?? "00000000-0000-4000-8000-000000000001",
|
|
459
|
-
type: "slidenum"
|
|
582
|
+
type: format === void 0 ? "slidenum" : resolvedFormat
|
|
460
583
|
}
|
|
461
584
|
});
|
|
462
585
|
continue;
|
|
463
586
|
}
|
|
464
|
-
collectRuns(child.children, nextStyle, runs, theme, fields, nextLocalDeclared);
|
|
587
|
+
collectRuns(child.children, nextStyle, runs, theme, fields, path, nextLocalDeclared);
|
|
465
588
|
}
|
|
466
589
|
}
|
|
467
590
|
function resolveDecoration(value) {
|
|
@@ -480,6 +603,16 @@ function resolveTextShadowModel(theme, value) {
|
|
|
480
603
|
function resolveAlign(value, fallback = "left") {
|
|
481
604
|
return value ?? fallback;
|
|
482
605
|
}
|
|
606
|
+
const verticalAlignOffsets = {
|
|
607
|
+
top: 0,
|
|
608
|
+
middle: .5,
|
|
609
|
+
bottom: 1
|
|
610
|
+
};
|
|
611
|
+
const bodyAnchors = {
|
|
612
|
+
top: "t",
|
|
613
|
+
middle: "ctr",
|
|
614
|
+
bottom: "b"
|
|
615
|
+
};
|
|
483
616
|
function resolveVerticalAlign(value) {
|
|
484
617
|
return value ?? "top";
|
|
485
618
|
}
|
|
@@ -500,14 +633,6 @@ function resolveListModel(value) {
|
|
|
500
633
|
default: return value;
|
|
501
634
|
}
|
|
502
635
|
}
|
|
503
|
-
function decorationAttribute(decoration) {
|
|
504
|
-
switch (decoration) {
|
|
505
|
-
case "none": return [];
|
|
506
|
-
case "underline": return ["u=\"sng\""];
|
|
507
|
-
case "line-through": return ["strike=\"sngStrike\""];
|
|
508
|
-
default: return decoration;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
636
|
function transformAttribute(transform) {
|
|
512
637
|
switch (transform) {
|
|
513
638
|
case "none": return [];
|
|
@@ -531,8 +656,8 @@ function runFontSlotsXml(style, differential = false) {
|
|
|
531
656
|
const latinClsAttrs = fontClassificationAttrsForRun(style.fontFamily, style.themeFont, style.fontWeight, style.fontStyle);
|
|
532
657
|
const latinTypeface = style.themeFont === "major" ? "+mj-lt" : style.themeFont === "minor" ? "+mn-lt" : latinFont.family;
|
|
533
658
|
const csTypeface = style.themeFont === "major" ? "+mj-cs" : style.themeFont === "minor" ? "+mn-cs" : latinFont.family;
|
|
534
|
-
latinXml = `<a:latin typeface="${escapedXml(latinTypeface)}"${latinClsAttrs}/>`;
|
|
535
|
-
csXml = `<a:cs typeface="${escapedXml(csTypeface)}"/>`;
|
|
659
|
+
latinXml = `<a:latin typeface="${escapedXml(latinTypeface, "style.fontFamily")}"${latinClsAttrs}/>`;
|
|
660
|
+
csXml = `<a:cs typeface="${escapedXml(csTypeface, "style.fontFamily")}"/>`;
|
|
536
661
|
}
|
|
537
662
|
let eaXml = "";
|
|
538
663
|
if (!differential || hasEa) {
|
|
@@ -540,88 +665,103 @@ function runFontSlotsXml(style, differential = false) {
|
|
|
540
665
|
const eaTheme = hasEa ? style.eastAsianThemeFont : style.themeFont;
|
|
541
666
|
const eaFont = normalizedFontsForReference(eaRef, style.fontWeight, style.fontStyle)[0];
|
|
542
667
|
const eaClsAttrs = fontClassificationAttrsForRun(eaRef, eaTheme, style.fontWeight, style.fontStyle);
|
|
543
|
-
eaXml = `<a:ea typeface="${escapedXml(eaTheme === "major" ? "+mj-ea" : eaTheme === "minor" ? "+mn-ea" : eaFont.family)}"${eaClsAttrs}/>`;
|
|
668
|
+
eaXml = `<a:ea typeface="${escapedXml(eaTheme === "major" ? "+mj-ea" : eaTheme === "minor" ? "+mn-ea" : eaFont.family, "style.eastAsianFontFamily")}"${eaClsAttrs}/>`;
|
|
544
669
|
}
|
|
545
670
|
return `${latinXml}${eaXml}${csXml}`;
|
|
546
671
|
}
|
|
547
|
-
function
|
|
548
|
-
if (
|
|
672
|
+
function resolveRunColor(theme, fill) {
|
|
673
|
+
if (!isTextGradient(fill)) return theme.resolveColor(fill);
|
|
674
|
+
resolveGradientSpec(theme, fill, void 0, "style.color");
|
|
675
|
+
return fill;
|
|
676
|
+
}
|
|
677
|
+
function runPropertiesXml(style, tag, theme, mode = "resolved") {
|
|
678
|
+
const shadowXml = style.textShadow === "none" ? "<a:effectLst/>" : textShadowXml(theme, style.textShadow);
|
|
679
|
+
const includeKern = tag === "a:rPr" || tag === "a:defRPr";
|
|
680
|
+
if (mode === "differential") {
|
|
549
681
|
const attributes = [];
|
|
550
|
-
if (style.lang !== void 0) attributes.push(`lang="${escapedXml(style.lang)}"`);
|
|
682
|
+
if (style.lang !== void 0) attributes.push(`lang="${escapedXml(style.lang, "style.lang")}"`);
|
|
551
683
|
if (style.fontSize !== void 0) attributes.push(`sz="${centipoints(fontSizePoints(style.fontSize))}"`);
|
|
552
684
|
if (style.fontWeight !== void 0) {
|
|
553
685
|
const font = normalizedFonts(style)[0];
|
|
554
686
|
attributes.push(`b="${outputBold(font) ? 1 : 0}"`);
|
|
555
687
|
}
|
|
556
688
|
if (style.fontStyle !== void 0) attributes.push(`i="${style.fontStyle === "italic" ? 1 : 0}"`);
|
|
557
|
-
|
|
689
|
+
attributes.push(...textDecorationAttributes(style.textDecoration));
|
|
690
|
+
if (includeKern && style.fontSize !== void 0) attributes.push("kern=\"100\"");
|
|
558
691
|
if (style.textTransform !== void 0) attributes.push(...transformAttribute(resolveTransform(style.textTransform)));
|
|
559
692
|
if (style.letterSpacing !== void 0) attributes.push(`spc="${letterSpacingCentipoints(style.letterSpacing)}"`);
|
|
560
693
|
if (style.baselineShift !== void 0) {
|
|
561
694
|
const baseline = parseBaselineShiftThousandths(style.baselineShift);
|
|
562
695
|
if (baseline !== void 0) attributes.push(`baseline="${baseline}"`);
|
|
563
696
|
}
|
|
564
|
-
const fillXml = style.color === void 0 ? "" :
|
|
565
|
-
const
|
|
697
|
+
const fillXml = style.color === void 0 ? "" : textFillXml(theme, style.color);
|
|
698
|
+
const strokeXml = textStrokeXml(theme, style.textStroke);
|
|
566
699
|
const fontXml = style.fontFamily !== void 0 || style.themeFont !== void 0 || style.eastAsianFontFamily !== void 0 || style.eastAsianThemeFont !== void 0 ? runFontSlotsXml(style, true) : "";
|
|
567
700
|
const attrText = attributes.length === 0 ? "" : ` ${attributes.join(" ")}`;
|
|
568
|
-
const childrenXml = `${fillXml}${shadowXml}${fontXml}`;
|
|
701
|
+
const childrenXml = `${strokeXml}${fillXml}${shadowXml}${fontXml}`;
|
|
569
702
|
return childrenXml === "" ? `<${tag}${attrText}/>` : `<${tag}${attrText}>${childrenXml}</${tag}>`;
|
|
570
703
|
}
|
|
571
704
|
const font = normalizedFonts(style)[0];
|
|
572
705
|
const points = fontSizePoints(style.fontSize);
|
|
573
706
|
const bold = outputBold(font);
|
|
574
|
-
const
|
|
707
|
+
const strokeXml = textStrokeXml(theme, style.textStroke);
|
|
575
708
|
const fontSlots = runFontSlotsXml(style);
|
|
576
|
-
const decoration = resolveDecoration(style.textDecoration);
|
|
577
709
|
const transform = resolveTransform(style.textTransform);
|
|
578
710
|
const baselineAttr = style.baselineShift === void 0 ? [] : (() => {
|
|
579
711
|
const baseline = parseBaselineShiftThousandths(style.baselineShift);
|
|
580
712
|
return baseline === void 0 ? [] : [`baseline="${baseline}"`];
|
|
581
713
|
})();
|
|
714
|
+
const chartDefault = mode === "chart-default";
|
|
582
715
|
return `<${tag} ${[
|
|
583
|
-
...style.lang !== void 0 ? [`lang="${escapedXml(style.lang)}"`] : [],
|
|
716
|
+
...style.lang !== void 0 ? [`lang="${escapedXml(style.lang, "style.lang")}"`] : [],
|
|
584
717
|
`sz="${centipoints(points)}"`,
|
|
585
718
|
`b="${bold ? 1 : 0}"`,
|
|
586
719
|
`i="${font.style === "italic" ? 1 : 0}"`,
|
|
587
|
-
...
|
|
720
|
+
...textDecorationAttributes(style.textDecoration),
|
|
721
|
+
...includeKern ? ["kern=\"100\""] : [],
|
|
588
722
|
...transformAttribute(transform),
|
|
589
|
-
...
|
|
723
|
+
...chartDefault && style.textTransform === "none" ? ["cap=\"none\""] : [],
|
|
724
|
+
...style.letterSpacing === void 0 || !chartDefault && style.letterSpacing === 0 ? [] : [`spc="${letterSpacingCentipoints(style.letterSpacing)}"`],
|
|
590
725
|
...baselineAttr
|
|
591
|
-
].join(" ")}
|
|
726
|
+
].join(" ")}>${strokeXml}${textFillXml(theme, style.color ?? "dk1")}${shadowXml}${fontSlots}</${tag}>`;
|
|
592
727
|
}
|
|
593
728
|
function displayedText(run) {
|
|
594
729
|
return run.style.textTransform === "uppercase" ? run.text.toUpperCase() : run.text;
|
|
595
730
|
}
|
|
596
|
-
/** Emits a native
|
|
597
|
-
function
|
|
731
|
+
/** Emits a native text field using a fresh or preallocated field GUID. */
|
|
732
|
+
function emitTextFieldRunXml(run, theme, createFieldId, differential = false) {
|
|
598
733
|
const fieldId = createFieldId !== void 0 ? createFieldId() : run.field?.id ?? "00000000-0000-4000-8000-000000000001";
|
|
599
734
|
const fieldType = run.field?.type ?? "slidenum";
|
|
600
|
-
const rPr = differential ? runPropertiesXml(run.localDeclared ?? {}, "a:rPr", theme,
|
|
735
|
+
const rPr = differential ? runPropertiesXml(run.localDeclared ?? {}, "a:rPr", theme, "differential") : runPropertiesXml(run.style, "a:rPr", theme);
|
|
601
736
|
return `<a:fld id="${escapedXml(fieldId)}" type="${fieldType}">${rPr}<a:t>${escapedXml(run.text)}</a:t></a:fld>`;
|
|
602
737
|
}
|
|
603
738
|
function runXml(run, theme, differential = false) {
|
|
604
|
-
if (run.field !== void 0) return
|
|
739
|
+
if (run.field !== void 0) return emitTextFieldRunXml(run, theme, void 0, differential);
|
|
605
740
|
const text = escapedXml(run.text);
|
|
606
|
-
return `<a:r>${differential ? runPropertiesXml(run.localDeclared ?? {}, "a:rPr", theme,
|
|
741
|
+
return `<a:r>${differential ? runPropertiesXml(run.localDeclared ?? {}, "a:rPr", theme, "differential") : runPropertiesXml(run.style, "a:rPr", theme)}<a:t xml:space="preserve">${text}</a:t></a:r>`;
|
|
607
742
|
}
|
|
608
|
-
function textResourceClaims(
|
|
743
|
+
function textResourceClaims(runGroups, declaredFonts = []) {
|
|
609
744
|
const used = /* @__PURE__ */ new Map();
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
745
|
+
const includeFont = (font, text) => {
|
|
746
|
+
const key = `${font.family.toLocaleLowerCase("en-US")}\u0000${font.weight}\u0000${font.style}`;
|
|
747
|
+
const entry = used.get(key) ?? {
|
|
748
|
+
fonts: [],
|
|
749
|
+
fontPolicies: /* @__PURE__ */ new Map(),
|
|
750
|
+
text: []
|
|
751
|
+
};
|
|
752
|
+
if (!entry.fonts.some(({ identity }) => identity === font.identity)) entry.fonts.push(font);
|
|
753
|
+
const policyKey = `${font.identity}\u0000${font.substitute ? 1 : 0}\u0000${font.embeddable ? 1 : 0}`;
|
|
754
|
+
entry.fontPolicies.set(policyKey, font);
|
|
755
|
+
if (text !== void 0) entry.text.push(text);
|
|
756
|
+
used.set(key, entry);
|
|
757
|
+
};
|
|
758
|
+
for (const font of declaredFonts) includeFont(font);
|
|
759
|
+
for (const runs of runGroups) {
|
|
760
|
+
const segmentedRuns = splitParagraphRunsForEffectiveScripts(runs.map((run) => ({
|
|
761
|
+
text: displayedText(run) + (run.field?.type === "slidenum" ? "0123456789" : ""),
|
|
762
|
+
style: run.style
|
|
763
|
+
})));
|
|
764
|
+
for (const scriptSegments of segmentedRuns) for (const seg of scriptSegments) for (const font of normalizedFonts(seg.style)) includeFont(font, seg.text);
|
|
625
765
|
}
|
|
626
766
|
const resourceClaims = [];
|
|
627
767
|
const fontUses = [];
|
|
@@ -729,6 +869,14 @@ function textResourceClaims(runs) {
|
|
|
729
869
|
}
|
|
730
870
|
};
|
|
731
871
|
}
|
|
872
|
+
/** Claims explicitly declared theme faces without attributing text characters to them. */
|
|
873
|
+
function declaredFontResourceClaims(font) {
|
|
874
|
+
const faces = font.faces ?? [];
|
|
875
|
+
return textResourceClaims([], faces.length === 0 ? normalizedFontsForReference(font, void 0, void 0) : faces.flatMap((face) => {
|
|
876
|
+
const { weight, style } = resolveDeclaredFaceSlot(face);
|
|
877
|
+
return normalizedFontsForReference(font, weight, style);
|
|
878
|
+
}));
|
|
879
|
+
}
|
|
732
880
|
function alignmentValue(value) {
|
|
733
881
|
if (value === void 0) return void 0;
|
|
734
882
|
switch (value) {
|
|
@@ -748,10 +896,13 @@ function paragraphXml(paragraph, theme, differential = false) {
|
|
|
748
896
|
if (paragraphBaseDirection(runs.map((run) => displayedText(run)).join("")) === "rtl") attributes.push("rtl=\"1\"");
|
|
749
897
|
const resolvedList = resolveListModel(style.list);
|
|
750
898
|
if (resolvedList !== void 0) attributes.push(`lvl="${resolvedList.level}"`);
|
|
751
|
-
if (!differential && paragraph.resolvedListIndent !== void 0) {
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
|
|
899
|
+
if (style.marginLeft !== void 0 || !differential && paragraph.resolvedListIndent !== void 0) {
|
|
900
|
+
const marginLeft = style.marginLeft ?? paragraph.resolvedListIndent.marginLeft;
|
|
901
|
+
attributes.push(`marL="${paragraphIndentToEmu(marginLeft)}"`);
|
|
902
|
+
}
|
|
903
|
+
if (style.indent !== void 0 || !differential && paragraph.resolvedListIndent !== void 0) {
|
|
904
|
+
const indent = style.indent ?? paragraph.resolvedListIndent.indent;
|
|
905
|
+
attributes.push(`indent="${paragraphIndentToEmu(indent)}"`);
|
|
755
906
|
}
|
|
756
907
|
const lineSpacing = lineSpacingXml(style.lineHeight);
|
|
757
908
|
const spacingAfter = style.spacingAfter === void 0 || style.spacingAfter === 0 ? "" : `<a:spcAft><a:spcPts val="${spacingCentipoints(style.spacingAfter, "spacingAfter")}"/></a:spcAft>`;
|
|
@@ -768,12 +919,12 @@ function paragraphXml(paragraph, theme, differential = false) {
|
|
|
768
919
|
const endStyle = differential ? paragraph.localEndStyle ?? {} : paragraph.endStyle;
|
|
769
920
|
let defRPr = "";
|
|
770
921
|
if (runs.length === 0) {
|
|
771
|
-
const candidate = runPropertiesXml(endStyle, "a:defRPr", theme, differential);
|
|
922
|
+
const candidate = runPropertiesXml(endStyle, "a:defRPr", theme, differential ? "differential" : "resolved");
|
|
772
923
|
defRPr = differential && candidate === "<a:defRPr/>" ? "" : candidate;
|
|
773
924
|
}
|
|
774
925
|
const pPrChildren = `${lineSpacing}${spacingAfter}${list}${defRPr}`;
|
|
775
926
|
const pPr = attributes.length + pPrChildren.length === 0 ? "" : `<a:pPr${attributes.length === 0 ? "" : ` ${attributes.join(" ")}`}${pPrChildren.length === 0 ? "/>" : `>${pPrChildren}</a:pPr>`}`;
|
|
776
|
-
const endProperties = runs.length === 0 ? runPropertiesXml(endStyle, "a:
|
|
927
|
+
const endProperties = runs.length === 0 ? runPropertiesXml(endStyle, "a:endParaRPr", theme, differential ? "differential" : "resolved") : "";
|
|
777
928
|
return `<a:p>${pPr}${runs.map((run) => runXml(run, theme, differential)).join("")}${endProperties}</a:p>`;
|
|
778
929
|
}
|
|
779
930
|
function normalizeParagraphs(children, textStyle, theme, fields, placeholder, localSlideDeclaredStyle, allowParagraphMotion = false) {
|
|
@@ -790,6 +941,7 @@ function normalizeParagraphs(children, textStyle, theme, fields, placeholder, lo
|
|
|
790
941
|
textTransform: textStyle.textTransform,
|
|
791
942
|
textDecoration: textStyle.textDecoration,
|
|
792
943
|
textShadow: textStyle.textShadow,
|
|
944
|
+
textStroke: textStyle.textStroke,
|
|
793
945
|
lang: textStyle.lang
|
|
794
946
|
};
|
|
795
947
|
validateRunStyle(baseRunStyle);
|
|
@@ -821,26 +973,30 @@ function normalizeParagraphs(children, textStyle, theme, fields, placeholder, lo
|
|
|
821
973
|
inline = [];
|
|
822
974
|
}
|
|
823
975
|
};
|
|
824
|
-
const appendParagraphNode = (node, currentStep) => {
|
|
976
|
+
const appendParagraphNode = (node, path, currentStep) => {
|
|
825
977
|
flushInline();
|
|
826
978
|
const unknown = Object.keys(node.props).find((key) => key !== "style" && !textAuthorMetadataKeys.has(key) && !(allowParagraphMotion && motionPropKeySet.has(key)));
|
|
827
979
|
if (unknown !== void 0) {
|
|
828
980
|
if (motionPropKeySet.has(unknown)) throw new CapabilityError("unsupported-motion-host", "Paragraph motion properties are only supported inside page-level Text and Shape");
|
|
829
|
-
throw new CapabilityError("unknown-parameter", `P contains unimplemented parameter ${unknown}
|
|
981
|
+
throw new CapabilityError("unknown-parameter", `P contains unimplemented parameter ${unknown}`, path, {
|
|
982
|
+
prop: unknown,
|
|
983
|
+
field: unknown
|
|
984
|
+
});
|
|
830
985
|
}
|
|
831
986
|
if (allowParagraphMotion) {
|
|
832
987
|
const motionProps = pickMotionProps(node.props);
|
|
833
|
-
validateMotionFlag(motionProps["motion"]);
|
|
988
|
+
validateMotionFlag(motionProps["motion"], path);
|
|
834
989
|
if (Object.keys(motionProps).length > 0) paragraphMotions.push({
|
|
835
990
|
paragraphIndex: paragraphs.length,
|
|
991
|
+
path,
|
|
836
992
|
props: motionProps,
|
|
837
993
|
...currentStep === void 0 ? {} : { step: currentStep }
|
|
838
994
|
});
|
|
839
995
|
}
|
|
840
|
-
const
|
|
996
|
+
const effectiveTheme = placeholder?.masterTheme ?? theme;
|
|
997
|
+
const localPStyle = parseParagraphStyle(node.props["style"], path, effectiveTheme);
|
|
841
998
|
const rawLevel = localPStyle.list?.level ?? 0;
|
|
842
999
|
const levelBase = placeholder === void 0 ? void 0 : resolvePlaceholderLevelTextStyle(placeholder, rawLevel, localSlideDeclaredStyle);
|
|
843
|
-
const effectiveTheme = placeholder?.masterTheme ?? theme;
|
|
844
1000
|
const effectiveBaseP = levelBase === void 0 ? baseParagraphStyle : {
|
|
845
1001
|
...levelBase.lineHeight === void 0 ? {} : { lineHeight: levelBase.lineHeight },
|
|
846
1002
|
...levelBase.align === void 0 ? {} : { align: levelBase.align },
|
|
@@ -864,6 +1020,7 @@ function normalizeParagraphs(children, textStyle, theme, fields, placeholder, lo
|
|
|
864
1020
|
textTransform: style.textTransform,
|
|
865
1021
|
textDecoration: style.textDecoration,
|
|
866
1022
|
textShadow: style.textShadow,
|
|
1023
|
+
textStroke: style.textStroke,
|
|
867
1024
|
lang: style.lang
|
|
868
1025
|
}, effectiveTheme);
|
|
869
1026
|
const mergedLocalPStyle = placeholder === void 0 ? void 0 : {
|
|
@@ -872,7 +1029,7 @@ function normalizeParagraphs(children, textStyle, theme, fields, placeholder, lo
|
|
|
872
1029
|
};
|
|
873
1030
|
const localPRunDeclared = placeholder === void 0 ? void 0 : mergeLocalRunDeclared(localSlideRunDeclared ?? {}, localPStyle, effectiveTheme);
|
|
874
1031
|
const runs = [];
|
|
875
|
-
collectRuns(node.children, paragraphRunStyle, runs, effectiveTheme, fields, localPRunDeclared);
|
|
1032
|
+
collectRuns(node.children, paragraphRunStyle, runs, effectiveTheme, fields, path, localPRunDeclared);
|
|
876
1033
|
paragraphs.push({
|
|
877
1034
|
runs,
|
|
878
1035
|
style,
|
|
@@ -882,24 +1039,25 @@ function normalizeParagraphs(children, textStyle, theme, fields, placeholder, lo
|
|
|
882
1039
|
wrap: textStyle.textWrap ?? "normal"
|
|
883
1040
|
});
|
|
884
1041
|
};
|
|
885
|
-
for (const child of children) {
|
|
1042
|
+
for (const [index, child] of children.entries()) {
|
|
886
1043
|
if (!hostChild(child)) throw new CapabilityError("invalid-text-child", "Text content tree contains invalid nodes");
|
|
887
|
-
if (isHostText(child) || child.type
|
|
888
|
-
collectRuns([child], baseRunStyle, inline, theme, fields, localSlideRunDeclared);
|
|
1044
|
+
if (isHostText(child) || isInlineRichTextNodeType(child.type)) {
|
|
1045
|
+
collectRuns([child], baseRunStyle, inline, theme, fields, "", localSlideRunDeclared, index);
|
|
889
1046
|
continue;
|
|
890
1047
|
}
|
|
891
1048
|
if (child.type === "motion-step") {
|
|
892
1049
|
if (!allowParagraphMotion) throw new CapabilityError("unsupported-text-child", "Step cannot be used directly inside this text container");
|
|
893
1050
|
flushInline();
|
|
894
|
-
const
|
|
895
|
-
|
|
1051
|
+
const stepPath = componentLabel(child, index);
|
|
1052
|
+
const step = parseStepDeclarationProps(child.props, stepPath);
|
|
1053
|
+
for (const [nestedIndex, nested] of child.children.entries()) {
|
|
896
1054
|
if (!hostChild(nested) || isHostText(nested) || nested.type !== "paragraph") throw new CapabilityError("unsupported-text-child", "Step inside Text or Shape can only contain P paragraphs");
|
|
897
|
-
appendParagraphNode(nested, step);
|
|
1055
|
+
appendParagraphNode(nested, `${stepPath}/${componentLabel(nested, nestedIndex)}`, step);
|
|
898
1056
|
}
|
|
899
1057
|
continue;
|
|
900
1058
|
}
|
|
901
1059
|
if (child.type !== "paragraph") throw new CapabilityError("unsupported-text-child", `${child.type} cannot be used directly in text box`);
|
|
902
|
-
appendParagraphNode(child);
|
|
1060
|
+
appendParagraphNode(child, componentLabel(child, index));
|
|
903
1061
|
}
|
|
904
1062
|
flushInline();
|
|
905
1063
|
if (paragraphs.length === 0) paragraphs.push({
|
|
@@ -961,15 +1119,27 @@ function measureRunFace(style) {
|
|
|
961
1119
|
function missingCharacters(face, text) {
|
|
962
1120
|
return findMissingFontGlyphs(face, text, requiresVisibleFontGlyph);
|
|
963
1121
|
}
|
|
964
|
-
function
|
|
1122
|
+
function pieceWidthPoints(face, advances, points, tenths, bold) {
|
|
965
1123
|
const nativeEighthPointGrid = 8;
|
|
966
1124
|
const twipsPerPoint = 20;
|
|
967
|
-
let
|
|
968
|
-
let
|
|
1125
|
+
let unitsSum = 0;
|
|
1126
|
+
let glyphEighth = 0;
|
|
969
1127
|
let twips = 0;
|
|
1128
|
+
for (const xAdvance of advances) {
|
|
1129
|
+
unitsSum += xAdvance;
|
|
1130
|
+
const advance = xAdvance / face.unitsPerEm * points;
|
|
1131
|
+
glyphEighth += Math.round(advance * nativeEighthPointGrid) / nativeEighthPointGrid;
|
|
1132
|
+
const tenthAdvance = xAdvance / face.unitsPerEm * tenths;
|
|
1133
|
+
twips += Math.round(tenthAdvance * twipsPerPoint) / twipsPerPoint + (bold ? 1 / twipsPerPoint : 0);
|
|
1134
|
+
}
|
|
1135
|
+
const natural = unitsSum / face.unitsPerEm * points;
|
|
1136
|
+
const eighthCeil = Math.ceil(natural * nativeEighthPointGrid) / nativeEighthPointGrid;
|
|
1137
|
+
return Math.max(natural, eighthCeil, glyphEighth, twips);
|
|
1138
|
+
}
|
|
1139
|
+
function rangeWidth(pieces, text, start, end) {
|
|
1140
|
+
let widthPx = 0;
|
|
970
1141
|
let spacing = 0;
|
|
971
|
-
let
|
|
972
|
-
let pendingTracking = 0;
|
|
1142
|
+
let pendingNegativeTracking = 0;
|
|
973
1143
|
for (const piece of pieces) {
|
|
974
1144
|
const from = Math.max(start, piece.start);
|
|
975
1145
|
const to = Math.min(end, piece.end);
|
|
@@ -979,27 +1149,27 @@ function rangeWidth(pieces, text, start, end) {
|
|
|
979
1149
|
const visible = Array.from(transformed).filter(requiresFontGlyph).join("");
|
|
980
1150
|
if (visible === "") continue;
|
|
981
1151
|
const face = piece.face;
|
|
982
|
-
const advances = shapeFontAdvances(face, visible);
|
|
983
1152
|
const unscaledPoints = fontSizePoints(piece.style.fontSize);
|
|
984
|
-
const points = piece.style.baselineShift !== void 0 ? unscaledPoints *
|
|
1153
|
+
const points = piece.style.baselineShift !== void 0 && parseBaselineShiftThousandths(piece.style.baselineShift) !== void 0 ? unscaledPoints * (2 / 3) : unscaledPoints;
|
|
985
1154
|
const tenths = Math.ceil(centipoints(points) / 10) / 10;
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
eighthPoint += Math.round(advance * nativeEighthPointGrid) / nativeEighthPointGrid;
|
|
990
|
-
const tenthAdvance = xAdvance / face.unitsPerEm * tenths;
|
|
991
|
-
twips += Math.round(tenthAdvance * twipsPerPoint) / twipsPerPoint;
|
|
992
|
-
}
|
|
1155
|
+
const shapedPt = pieceWidthPoints(face, shapeFontAdvances(face, visible), points, tenths, piece.bold);
|
|
1156
|
+
const unkernedPt = pieceWidthPoints(face, unkernedFontAdvances(face, visible), points, tenths, piece.bold);
|
|
1157
|
+
widthPx += Math.max(shapedPt, unkernedPt) * (4 / 3);
|
|
993
1158
|
const pieceTracking = piece.style.letterSpacing ?? 0;
|
|
994
1159
|
const visibleCount = Array.from(graphemes.segment(visible)).length;
|
|
995
1160
|
if (visibleCount > 0) {
|
|
996
|
-
if (
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1161
|
+
if (pendingNegativeTracking < 0) {
|
|
1162
|
+
spacing += pendingNegativeTracking;
|
|
1163
|
+
pendingNegativeTracking = 0;
|
|
1164
|
+
}
|
|
1165
|
+
if (pieceTracking > 0) spacing += pieceTracking * visibleCount;
|
|
1166
|
+
else if (pieceTracking < 0) {
|
|
1167
|
+
spacing += pieceTracking * (visibleCount - 1);
|
|
1168
|
+
pendingNegativeTracking = pieceTracking;
|
|
1169
|
+
}
|
|
1000
1170
|
}
|
|
1001
1171
|
}
|
|
1002
|
-
return
|
|
1172
|
+
return widthPx + spacing;
|
|
1003
1173
|
}
|
|
1004
1174
|
function trimLineEnd(text, start, end) {
|
|
1005
1175
|
let trimmed = end;
|
|
@@ -1019,7 +1189,7 @@ function trimMandatoryBreakEnd(text, start, end) {
|
|
|
1019
1189
|
while (trimmed > start && /[\n\r\v\f\u0085\u2028\u2029]/u.test(text[trimmed - 1] ?? "")) trimmed -= 1;
|
|
1020
1190
|
return trimmed;
|
|
1021
1191
|
}
|
|
1022
|
-
function wrapParagraph(text, pieces, width) {
|
|
1192
|
+
function wrapParagraph(text, pieces, width, firstLineWidth = width) {
|
|
1023
1193
|
if (text === "") return {
|
|
1024
1194
|
lines: [{
|
|
1025
1195
|
start: 0,
|
|
@@ -1041,6 +1211,7 @@ function wrapParagraph(text, pieces, width) {
|
|
|
1041
1211
|
});
|
|
1042
1212
|
const lines = [];
|
|
1043
1213
|
const epsilon = .01;
|
|
1214
|
+
const lineWidth = () => lines.length === 0 ? firstLineWidth : width;
|
|
1044
1215
|
let lineStart = 0;
|
|
1045
1216
|
let lineEnd = 0;
|
|
1046
1217
|
let unitStart = 0;
|
|
@@ -1049,7 +1220,7 @@ function wrapParagraph(text, pieces, width) {
|
|
|
1049
1220
|
const unitEnd = lineBreak.position;
|
|
1050
1221
|
const breakContentEnd = trimMandatoryBreakEnd(text, unitStart, unitEnd);
|
|
1051
1222
|
const required = lineBreak.required || breakContentEnd < unitEnd;
|
|
1052
|
-
if (rangeWidth(pieces, text, lineStart, trimLineEnd(text, lineStart, unitEnd)) <=
|
|
1223
|
+
if (rangeWidth(pieces, text, lineStart, trimLineEnd(text, lineStart, unitEnd)) <= lineWidth() + epsilon) {
|
|
1053
1224
|
lineEnd = unitEnd;
|
|
1054
1225
|
if (required) {
|
|
1055
1226
|
lines.push({
|
|
@@ -1071,20 +1242,20 @@ function wrapParagraph(text, pieces, width) {
|
|
|
1071
1242
|
lineStart = unitStart;
|
|
1072
1243
|
lineEnd = unitStart;
|
|
1073
1244
|
}
|
|
1074
|
-
if (rangeWidth(pieces, text, unitStart, trimLineEnd(text, unitStart, unitEnd)) <=
|
|
1245
|
+
if (rangeWidth(pieces, text, unitStart, trimLineEnd(text, unitStart, unitEnd)) <= lineWidth() + epsilon) lineEnd = unitEnd;
|
|
1075
1246
|
else {
|
|
1076
1247
|
let chunkStart = unitStart;
|
|
1077
1248
|
let previous = chunkStart;
|
|
1078
1249
|
const fallbackEnd = required ? breakContentEnd : unitEnd;
|
|
1079
1250
|
for (const boundary of graphemeEnds(text, unitStart, fallbackEnd)) {
|
|
1080
|
-
if (rangeWidth(pieces, text, chunkStart, trimLineEnd(text, chunkStart, boundary)) >
|
|
1251
|
+
if (rangeWidth(pieces, text, chunkStart, trimLineEnd(text, chunkStart, boundary)) > lineWidth() + epsilon && previous > chunkStart) {
|
|
1081
1252
|
lines.push({
|
|
1082
1253
|
start: chunkStart,
|
|
1083
1254
|
end: previous
|
|
1084
1255
|
});
|
|
1085
1256
|
chunkStart = previous;
|
|
1086
1257
|
}
|
|
1087
|
-
if (rangeWidth(pieces, text, chunkStart, trimLineEnd(text, chunkStart, boundary)) >
|
|
1258
|
+
if (rangeWidth(pieces, text, chunkStart, trimLineEnd(text, chunkStart, boundary)) > lineWidth() + epsilon && previous === chunkStart) {
|
|
1088
1259
|
lines.push({
|
|
1089
1260
|
start: chunkStart,
|
|
1090
1261
|
end: boundary
|
|
@@ -1126,7 +1297,10 @@ function wrapParagraph(text, pieces, width) {
|
|
|
1126
1297
|
}
|
|
1127
1298
|
function paragraphLineHeight(paragraph) {
|
|
1128
1299
|
if (paragraph.style.lineHeight !== void 0 && !isLineHeightPercent(paragraph.style.lineHeight)) return spacingCentipoints(positiveLength(paragraph.style.lineHeight, "lineHeight"), "lineHeight") / 75;
|
|
1129
|
-
const styles = paragraph.runs.length > 0 ? paragraph.runs.
|
|
1300
|
+
const styles = paragraph.runs.length > 0 ? splitParagraphRunsForEffectiveScripts(paragraph.runs.map((run) => ({
|
|
1301
|
+
text: displayedText(run),
|
|
1302
|
+
style: run.style
|
|
1303
|
+
}))).flatMap((segments, idx) => paragraph.runs[idx].text === "" ? [paragraph.runs[idx].style] : segments.map((seg) => seg.style)) : [paragraph.endStyle];
|
|
1130
1304
|
let maximum = 0;
|
|
1131
1305
|
for (const style of styles) {
|
|
1132
1306
|
const face = measureRunFace(style);
|
|
@@ -1149,7 +1323,10 @@ function paragraphLineHeight(paragraph) {
|
|
|
1149
1323
|
function paragraphBaseline(paragraph) {
|
|
1150
1324
|
if (paragraph.runs.length !== 1 || paragraph.runs[0].text === "") return;
|
|
1151
1325
|
const run = paragraph.runs[0];
|
|
1152
|
-
const segments =
|
|
1326
|
+
const segments = splitParagraphRunsForEffectiveScripts([{
|
|
1327
|
+
text: displayedText(run),
|
|
1328
|
+
style: run.style
|
|
1329
|
+
}])[0];
|
|
1153
1330
|
if (segments.length !== 1) return;
|
|
1154
1331
|
const style = segments[0].style;
|
|
1155
1332
|
const face = measureRunFace(style);
|
|
@@ -1165,8 +1342,13 @@ function paragraphPieces(paragraph) {
|
|
|
1165
1342
|
}];
|
|
1166
1343
|
const pieces = [];
|
|
1167
1344
|
let start = 0;
|
|
1168
|
-
|
|
1169
|
-
|
|
1345
|
+
const segmentedRuns = splitParagraphRunsForEffectiveScripts(sourceRuns.map((run) => ({
|
|
1346
|
+
text: displayedText(run),
|
|
1347
|
+
style: run.style
|
|
1348
|
+
})));
|
|
1349
|
+
for (let runIndex = 0; runIndex < segmentedRuns.length; runIndex += 1) {
|
|
1350
|
+
const segments = segmentedRuns[runIndex];
|
|
1351
|
+
const bold = outputBold(normalizedFonts(sourceRuns[runIndex].style)[0]);
|
|
1170
1352
|
for (const seg of segments) {
|
|
1171
1353
|
const face = measureRunFace(seg.style);
|
|
1172
1354
|
const letterSpacing = seg.style.letterSpacing === void 0 ? void 0 : letterSpacingCentipoints(seg.style.letterSpacing) / 75;
|
|
@@ -1179,7 +1361,8 @@ function paragraphPieces(paragraph) {
|
|
|
1179
1361
|
style: measureStyle,
|
|
1180
1362
|
start,
|
|
1181
1363
|
end: start + seg.text.length,
|
|
1182
|
-
face
|
|
1364
|
+
face,
|
|
1365
|
+
bold
|
|
1183
1366
|
});
|
|
1184
1367
|
start += seg.text.length;
|
|
1185
1368
|
}
|
|
@@ -1193,12 +1376,12 @@ function computeDefaultListIndentMetrics(paragraph) {
|
|
|
1193
1376
|
const resolvedList = resolveListModel(paragraph.style.list);
|
|
1194
1377
|
if (resolvedList === void 0) return void 0;
|
|
1195
1378
|
const baseFontPx = fontSizePoints((paragraph.runs[0]?.style ?? paragraph.endStyle).fontSize) * 4 / 3;
|
|
1196
|
-
const hangingIndent = Math.max(baseFontPx * 1.25, 20);
|
|
1197
|
-
const
|
|
1379
|
+
const hangingIndent = Math.min(maximumParagraphIndentPx, Math.max(baseFontPx * 1.25, 20));
|
|
1380
|
+
const contentIndent = Math.min(maximumParagraphIndentPx, resolvedList.level * (baseFontPx * 1.5) + hangingIndent);
|
|
1198
1381
|
return {
|
|
1199
|
-
levelIndent,
|
|
1382
|
+
levelIndent: contentIndent - hangingIndent,
|
|
1200
1383
|
hangingIndent,
|
|
1201
|
-
contentIndent
|
|
1384
|
+
contentIndent,
|
|
1202
1385
|
baseFontPx
|
|
1203
1386
|
};
|
|
1204
1387
|
}
|
|
@@ -1207,11 +1390,11 @@ function listIndentMetrics(paragraph) {
|
|
|
1207
1390
|
if (defaults === void 0) return {
|
|
1208
1391
|
levelIndent: 0,
|
|
1209
1392
|
hangingIndent: 0,
|
|
1210
|
-
contentIndent: 0,
|
|
1393
|
+
contentIndent: paragraph.style.marginLeft ?? 0,
|
|
1211
1394
|
baseFontPx: 0
|
|
1212
1395
|
};
|
|
1213
1396
|
if (paragraph.resolvedListIndent !== void 0) {
|
|
1214
|
-
const hangingIndent =
|
|
1397
|
+
const hangingIndent = -paragraph.resolvedListIndent.indent;
|
|
1215
1398
|
const contentIndent = Math.max(0, paragraph.resolvedListIndent.marginLeft);
|
|
1216
1399
|
return {
|
|
1217
1400
|
levelIndent: Math.max(0, contentIndent - hangingIndent),
|
|
@@ -1222,7 +1405,8 @@ function listIndentMetrics(paragraph) {
|
|
|
1222
1405
|
}
|
|
1223
1406
|
return defaults;
|
|
1224
1407
|
}
|
|
1225
|
-
|
|
1408
|
+
/** Returns the width of the widest unbreakable span, including list indentation. */
|
|
1409
|
+
function measureParagraphMinContentWidth(paragraph) {
|
|
1226
1410
|
const { text, pieces } = paragraphPieces(paragraph);
|
|
1227
1411
|
const { contentIndent } = listIndentMetrics(paragraph);
|
|
1228
1412
|
if (text === "") return contentIndent;
|
|
@@ -1240,35 +1424,37 @@ function paragraphMinContentWidth(paragraph) {
|
|
|
1240
1424
|
function paragraphMeasurement(paragraph, width) {
|
|
1241
1425
|
const { text, pieces } = paragraphPieces(paragraph);
|
|
1242
1426
|
const { contentIndent } = listIndentMetrics(paragraph);
|
|
1243
|
-
const
|
|
1427
|
+
const wrapWidth = paragraph.wrap === "nowrap" ? Number.MAX_VALUE : Math.max(1, width - contentIndent);
|
|
1428
|
+
const firstLineIndent = paragraph.style.list === void 0 ? paragraph.style.indent ?? 0 : 0;
|
|
1429
|
+
const wrapped = wrapParagraph(text, pieces, wrapWidth, paragraph.wrap === "nowrap" ? wrapWidth : Math.max(1, width - contentIndent - firstLineIndent));
|
|
1244
1430
|
const spacingAfter = paragraph.style.spacingAfter === void 0 ? 0 : spacingCentipoints(paragraph.style.spacingAfter, "spacingAfter") / 75;
|
|
1245
1431
|
return {
|
|
1246
1432
|
lineCount: wrapped.lines.length,
|
|
1247
1433
|
lines: wrapped.lines,
|
|
1248
1434
|
text,
|
|
1249
1435
|
pieces,
|
|
1250
|
-
width: wrapped.width + contentIndent,
|
|
1436
|
+
width: Math.max(...wrapped.lines.map((line, index) => line.width + contentIndent + (index === 0 ? firstLineIndent : 0))),
|
|
1251
1437
|
lineHeight: paragraphLineHeight(paragraph),
|
|
1252
1438
|
spacingAfter
|
|
1253
1439
|
};
|
|
1254
1440
|
}
|
|
1255
1441
|
function assertParagraphsHaveVisibleGlyphs(paragraphs) {
|
|
1256
1442
|
for (const paragraph of paragraphs) {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1443
|
+
const segmentedRuns = splitParagraphRunsForEffectiveScripts(paragraph.runs.map((run) => ({
|
|
1444
|
+
text: displayedText(run) + (run.field?.type === "slidenum" ? "0123456789" : ""),
|
|
1445
|
+
style: run.style
|
|
1446
|
+
})));
|
|
1447
|
+
for (const segments of segmentedRuns) for (const seg of segments) {
|
|
1448
|
+
if (!Array.from(seg.text).some(requiresVisibleFontGlyph)) continue;
|
|
1449
|
+
const missing = missingCharacters(measureRunFace(seg.style), seg.text);
|
|
1450
|
+
if (missing.length > 0) {
|
|
1451
|
+
const font = fontDetailsFromRunStyle(seg.style);
|
|
1452
|
+
const shown = missing.slice(0, 10).join(" ");
|
|
1453
|
+
const extra = missing.length - 10;
|
|
1454
|
+
throw new CapabilityError("font-missing-glyph", `${font.family} is missing glyphs for characters ${shown}${extra > 0 ? `, and ${extra} more characters` : ""}`, void 0, {
|
|
1455
|
+
font,
|
|
1456
|
+
characters: missing
|
|
1457
|
+
});
|
|
1272
1458
|
}
|
|
1273
1459
|
}
|
|
1274
1460
|
const list = paragraph.style.list;
|
|
@@ -1290,7 +1476,8 @@ function assertParagraphsHaveVisibleGlyphs(paragraphs) {
|
|
|
1290
1476
|
}
|
|
1291
1477
|
}
|
|
1292
1478
|
}
|
|
1293
|
-
|
|
1479
|
+
/** Measures shaped line ranges for reuse by static outline drawing. */
|
|
1480
|
+
function measureParagraphs(paragraphs, width = Number.POSITIVE_INFINITY) {
|
|
1294
1481
|
assertParagraphsHaveVisibleGlyphs(paragraphs);
|
|
1295
1482
|
const measured = paragraphs.map((paragraph) => paragraphMeasurement(paragraph, width));
|
|
1296
1483
|
let height = 0;
|
|
@@ -1308,7 +1495,7 @@ function roundSvgNumber(value) {
|
|
|
1308
1495
|
const rounded = Math.round(value * 1e6) / 1e6;
|
|
1309
1496
|
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
1310
1497
|
}
|
|
1311
|
-
function decorationForSegment(decoration, face, fontPx, startX, endX, color, textShadow) {
|
|
1498
|
+
function decorationForSegment(decoration, face, fontPx, startX, endX, color, textShadow, textStroke) {
|
|
1312
1499
|
if (endX <= startX) return void 0;
|
|
1313
1500
|
const unitsPerEm = face.unitsPerEm;
|
|
1314
1501
|
switch (decoration) {
|
|
@@ -1321,7 +1508,8 @@ function decorationForSegment(decoration, face, fontPx, startX, endX, color, tex
|
|
|
1321
1508
|
width: endX - startX,
|
|
1322
1509
|
height: thickness,
|
|
1323
1510
|
color,
|
|
1324
|
-
...textShadow === void 0 ? {} : { textShadow }
|
|
1511
|
+
...textShadow === void 0 ? {} : { textShadow },
|
|
1512
|
+
textStroke
|
|
1325
1513
|
};
|
|
1326
1514
|
}
|
|
1327
1515
|
case "line-through": {
|
|
@@ -1332,7 +1520,8 @@ function decorationForSegment(decoration, face, fontPx, startX, endX, color, tex
|
|
|
1332
1520
|
width: endX - startX,
|
|
1333
1521
|
height: thickness,
|
|
1334
1522
|
color,
|
|
1335
|
-
...textShadow === void 0 ? {} : { textShadow }
|
|
1523
|
+
...textShadow === void 0 ? {} : { textShadow },
|
|
1524
|
+
textStroke
|
|
1336
1525
|
};
|
|
1337
1526
|
}
|
|
1338
1527
|
default: return decoration;
|
|
@@ -1560,7 +1749,7 @@ function previewParagraphOutlines(paragraph, widthOrMeasured) {
|
|
|
1560
1749
|
const face = piece.face;
|
|
1561
1750
|
const unscaledFontPx = fontSizePoints(piece.style.fontSize) * 4 / 3;
|
|
1562
1751
|
const baselineMilli = piece.style.baselineShift !== void 0 ? parseBaselineShiftThousandths(piece.style.baselineShift) : void 0;
|
|
1563
|
-
const fontPx = baselineMilli !== void 0 ? unscaledFontPx *
|
|
1752
|
+
const fontPx = baselineMilli !== void 0 ? unscaledFontPx * (2 / 3) : unscaledFontPx;
|
|
1564
1753
|
const scale = fontPx / face.unitsPerEm;
|
|
1565
1754
|
const unscaledScale = unscaledFontPx / face.unitsPerEm;
|
|
1566
1755
|
const baselineShiftPx = baselineMilli !== void 0 ? -(baselineMilli / 1e5) * unscaledFontPx : 0;
|
|
@@ -1591,6 +1780,10 @@ function previewParagraphOutlines(paragraph, widthOrMeasured) {
|
|
|
1591
1780
|
y: baselineShiftPx - item.yOffset * scale,
|
|
1592
1781
|
scale,
|
|
1593
1782
|
color: piece.style.color,
|
|
1783
|
+
textStroke: piece.style.textStroke,
|
|
1784
|
+
advance: item.xAdvance * scale,
|
|
1785
|
+
ascent: face.ascent * scale,
|
|
1786
|
+
descent: Math.abs(face.descent * scale),
|
|
1594
1787
|
...piece.style.textShadow === void 0 ? {} : { textShadow: piece.style.textShadow },
|
|
1595
1788
|
isSpace: item.isSpace && item.xAdvance > 0,
|
|
1596
1789
|
clusterKey: `${segIndex}:${item.cluster}`
|
|
@@ -1604,7 +1797,7 @@ function previewParagraphOutlines(paragraph, widthOrMeasured) {
|
|
|
1604
1797
|
}
|
|
1605
1798
|
const glyphEnd = glyphs.length;
|
|
1606
1799
|
if (segStartX !== void 0 && glyphEnd > glyphStart) {
|
|
1607
|
-
const decoration = decorationForSegment(resolveDecoration(piece.style.textDecoration), face, fontPx, segStartX, segEndX, piece.style.color, piece.style.textShadow);
|
|
1800
|
+
const decoration = decorationForSegment(resolveDecoration(piece.style.textDecoration), face, fontPx, segStartX, segEndX, piece.style.color, piece.style.textShadow, piece.style.textStroke);
|
|
1608
1801
|
if (decoration !== void 0) decorations.push({
|
|
1609
1802
|
...decoration,
|
|
1610
1803
|
y: decoration.y + baselineShiftPx,
|
|
@@ -1715,6 +1908,10 @@ function shapeListPrefix(paragraph, prefixText) {
|
|
|
1715
1908
|
y: -item.yOffset * scale,
|
|
1716
1909
|
scale,
|
|
1717
1910
|
color: seg.style.color,
|
|
1911
|
+
textStroke: seg.style.textStroke,
|
|
1912
|
+
advance: item.xAdvance * scale,
|
|
1913
|
+
ascent: prefixFace.ascent * scale,
|
|
1914
|
+
descent: Math.abs(prefixFace.descent * scale),
|
|
1718
1915
|
...seg.style.textShadow === void 0 ? {} : { textShadow: seg.style.textShadow }
|
|
1719
1916
|
});
|
|
1720
1917
|
cursor += item.xAdvance * scale;
|
|
@@ -1745,7 +1942,8 @@ function previewTextBoxOutlines(options) {
|
|
|
1745
1942
|
}));
|
|
1746
1943
|
const totalHeight = outlinedParagraphs.reduce((total, { layout }, index) => total + layout.lines.length * layout.lineHeight + (index < outlinedParagraphs.length - 1 ? layout.spacingAfter : 0), 0);
|
|
1747
1944
|
const freeHeight = box.height - insets.top - insets.bottom - totalHeight;
|
|
1748
|
-
|
|
1945
|
+
const verticalOffset = verticalAlignOffsets[verticalAlign];
|
|
1946
|
+
let top = box.y + insets.top + (verticalOffset === 0 ? 0 : freeHeight * verticalOffset);
|
|
1749
1947
|
const activeNumberSeq = /* @__PURE__ */ new Map();
|
|
1750
1948
|
return outlinedParagraphs.flatMap(({ paragraph, layout }) => {
|
|
1751
1949
|
const resolvedList = resolveListModel(paragraph.style.list);
|
|
@@ -1771,9 +1969,11 @@ function previewTextBoxOutlines(options) {
|
|
|
1771
1969
|
}
|
|
1772
1970
|
const listPrefix = prefixText === void 0 ? void 0 : shapeListPrefix(paragraph, prefixText);
|
|
1773
1971
|
const listIndent = listIndentMetrics(paragraph);
|
|
1774
|
-
const availableLineWidth = Math.max(1, innerWidth - listIndent.contentIndent);
|
|
1775
1972
|
const align = resolveAlign(paragraph.style.align, layout.baseDir === "rtl" ? "right" : "left");
|
|
1776
1973
|
const lines = layout.lines.map((line, lineIndex) => {
|
|
1974
|
+
const firstLineIndent = lineIndex === 0 && resolvedList === void 0 ? paragraph.style.indent ?? 0 : 0;
|
|
1975
|
+
const contentIndent = listIndent.contentIndent + firstLineIndent;
|
|
1976
|
+
const availableLineWidth = Math.max(1, innerWidth - contentIndent);
|
|
1777
1977
|
const justified = align === "justify" ? applyJustifyLine(line, availableLineWidth) : {
|
|
1778
1978
|
glyphs: line.glyphs,
|
|
1779
1979
|
decorations: line.decorations,
|
|
@@ -1799,16 +1999,16 @@ function previewTextBoxOutlines(options) {
|
|
|
1799
1999
|
}
|
|
1800
2000
|
else switch (align) {
|
|
1801
2001
|
case "center":
|
|
1802
|
-
horizontalOffset =
|
|
2002
|
+
horizontalOffset = contentIndent + (availableLineWidth - justified.advance) / 2;
|
|
1803
2003
|
prefixOffset = horizontalOffset - (listPrefix?.advance ?? 0) - .4 * listIndent.baseFontPx;
|
|
1804
2004
|
break;
|
|
1805
2005
|
case "right":
|
|
1806
|
-
horizontalOffset =
|
|
2006
|
+
horizontalOffset = contentIndent + (availableLineWidth - justified.advance);
|
|
1807
2007
|
prefixOffset = horizontalOffset - (listPrefix?.advance ?? 0) - .4 * listIndent.baseFontPx;
|
|
1808
2008
|
break;
|
|
1809
2009
|
case "left":
|
|
1810
2010
|
case "justify":
|
|
1811
|
-
horizontalOffset =
|
|
2011
|
+
horizontalOffset = contentIndent;
|
|
1812
2012
|
prefixOffset = listIndent.levelIndent;
|
|
1813
2013
|
break;
|
|
1814
2014
|
default: return align;
|
|
@@ -1841,21 +2041,79 @@ function previewTextBoxOutlines(options) {
|
|
|
1841
2041
|
return lines;
|
|
1842
2042
|
});
|
|
1843
2043
|
}
|
|
1844
|
-
|
|
1845
|
-
|
|
2044
|
+
function textFillAttributes(fill, theme, gradientPaint) {
|
|
2045
|
+
if (isTextGradient(fill)) return `fill="url(#${gradientPaint(fill)})"`;
|
|
2046
|
+
const color = isResolvedColor(fill) ? fill : theme.resolveColor(fill ?? "tx1");
|
|
2047
|
+
return `fill="#${color.hex}" fill-opacity="${color.alpha ?? 1}"`;
|
|
2048
|
+
}
|
|
2049
|
+
function textStrokeAttributes(value, theme) {
|
|
2050
|
+
const outline = resolveTextStroke(theme, value);
|
|
2051
|
+
return outline === void 0 ? "" : ` ${borderAttributes(outline)}`;
|
|
2052
|
+
}
|
|
2053
|
+
/** Font outlines use absolute M/L/Q/C/Z commands in an upward-positive coordinate system. */
|
|
2054
|
+
function screenGlyphPath(glyph) {
|
|
2055
|
+
let position = 0;
|
|
2056
|
+
return glyph.path.replace(/([MLQCZ])|(-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/giu, (_, command, coordinate) => {
|
|
2057
|
+
if (command !== void 0) {
|
|
2058
|
+
position = 0;
|
|
2059
|
+
return command;
|
|
2060
|
+
}
|
|
2061
|
+
const value = Number(coordinate) * glyph.scale;
|
|
2062
|
+
return ` ${roundSvgNumber(position++ % 2 === 0 ? glyph.x + value : glyph.y - value)}`;
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
function renderGlyphPathSvg(glyph, theme, gradientPaint) {
|
|
1846
2066
|
if (glyph.path === "") return "";
|
|
1847
|
-
const
|
|
1848
|
-
|
|
2067
|
+
const fill = textFillAttributes(glyph.color, theme, gradientPaint);
|
|
2068
|
+
const stroke = textStrokeAttributes(glyph.textStroke, theme);
|
|
2069
|
+
if (isTextGradient(glyph.color) || stroke !== "") return `<path d="${screenGlyphPath(glyph)}" ${fill}${stroke}/>`;
|
|
2070
|
+
return `<path d="${xmlEscape(glyph.path)}" ${fill} transform="translate(${glyph.x} ${glyph.y}) scale(${glyph.scale} ${-glyph.scale})"/>`;
|
|
1849
2071
|
}
|
|
1850
|
-
function renderDecorationRectSvg(deco, theme) {
|
|
1851
|
-
const
|
|
1852
|
-
|
|
2072
|
+
function renderDecorationRectSvg(deco, theme, gradientPaint) {
|
|
2073
|
+
const fill = textFillAttributes(deco.color, theme, gradientPaint);
|
|
2074
|
+
const stroke = textStrokeAttributes(deco.textStroke, theme);
|
|
2075
|
+
return `<rect x="${roundSvgNumber(deco.x)}" y="${roundSvgNumber(deco.y)}" width="${roundSvgNumber(deco.width)}" height="${roundSvgNumber(deco.height)}" ${fill}${stroke}/>`;
|
|
1853
2076
|
}
|
|
1854
2077
|
/** Renders box-level positioned glyph outlines into SVG path fragments without importing textCapability. */
|
|
1855
2078
|
function renderTextOutlinesSvg(options) {
|
|
1856
2079
|
const { theme, idPrefix = "txt", rotate = 0, ...layoutOptions } = options;
|
|
1857
2080
|
const lines = previewTextBoxOutlines(layoutOptions);
|
|
1858
2081
|
const defs = [];
|
|
2082
|
+
const gradientBounds = /* @__PURE__ */ new Map();
|
|
2083
|
+
const includeGradientBounds = (color, x1, y1, x2, y2) => {
|
|
2084
|
+
if (!isTextGradient(color)) return;
|
|
2085
|
+
const key = JSON.stringify(color);
|
|
2086
|
+
const bounds = gradientBounds.get(key);
|
|
2087
|
+
if (bounds === void 0) gradientBounds.set(key, {
|
|
2088
|
+
gradient: color,
|
|
2089
|
+
x1,
|
|
2090
|
+
y1,
|
|
2091
|
+
x2,
|
|
2092
|
+
y2
|
|
2093
|
+
});
|
|
2094
|
+
else {
|
|
2095
|
+
bounds.x1 = Math.min(bounds.x1, x1);
|
|
2096
|
+
bounds.y1 = Math.min(bounds.y1, y1);
|
|
2097
|
+
bounds.x2 = Math.max(bounds.x2, x2);
|
|
2098
|
+
bounds.y2 = Math.max(bounds.y2, y2);
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
for (const line of lines) {
|
|
2102
|
+
for (const glyph of line.glyphs) includeGradientBounds(glyph.color, glyph.x, glyph.y - glyph.ascent, glyph.x + glyph.advance, glyph.y + glyph.descent);
|
|
2103
|
+
for (const deco of line.decorations ?? []) includeGradientBounds(deco.color, deco.x, deco.y, deco.x + deco.width, deco.y + deco.height);
|
|
2104
|
+
}
|
|
2105
|
+
const gradientIds = /* @__PURE__ */ new Map();
|
|
2106
|
+
for (const [key, { gradient, x1, y1, x2, y2 }] of gradientBounds) {
|
|
2107
|
+
const id = `${idPrefix}-text-fill-${gradientIds.size}`;
|
|
2108
|
+
gradientIds.set(key, id);
|
|
2109
|
+
defs.push(gradientDefSvg(id, resolveGradientSpec(theme, gradient, void 0, "style.color"), {
|
|
2110
|
+
x: x1,
|
|
2111
|
+
y: y1,
|
|
2112
|
+
width: Math.max(1, x2 - x1),
|
|
2113
|
+
height: Math.max(1, y2 - y1)
|
|
2114
|
+
}));
|
|
2115
|
+
}
|
|
2116
|
+
const gradientPaint = (gradient) => gradientIds.get(JSON.stringify(gradient));
|
|
1859
2117
|
const shadowFilterIds = /* @__PURE__ */ new Map();
|
|
1860
2118
|
let shadowIndex = 0;
|
|
1861
2119
|
const filterIdForShadow = (rawShadow) => {
|
|
@@ -1907,16 +2165,62 @@ function renderTextOutlinesSvg(options) {
|
|
|
1907
2165
|
activeGroup.push(elementSvg);
|
|
1908
2166
|
};
|
|
1909
2167
|
for (const line of lines) {
|
|
1910
|
-
for (const glyph of line.glyphs) pushElement(renderGlyphPathSvg(glyph, theme), glyph.textShadow);
|
|
1911
|
-
for (const deco of line.decorations ?? []) pushElement(renderDecorationRectSvg(deco, theme), deco.textShadow);
|
|
2168
|
+
for (const glyph of line.glyphs) pushElement(renderGlyphPathSvg(glyph, theme, gradientPaint), glyph.textShadow);
|
|
2169
|
+
for (const deco of line.decorations ?? []) pushElement(renderDecorationRectSvg(deco, theme, gradientPaint), deco.textShadow);
|
|
1912
2170
|
}
|
|
1913
2171
|
flushGroup();
|
|
1914
2172
|
return `${defs.length > 0 ? `<defs>${defs.join("")}</defs>` : ""}${parts.join("")}`;
|
|
1915
2173
|
}
|
|
2174
|
+
const alignF32Buf = /* @__PURE__ */ new Float32Array(1);
|
|
2175
|
+
const alignU32Buf = new Uint32Array(alignF32Buf.buffer);
|
|
2176
|
+
function ceilFloat32ForOuterEmu(value) {
|
|
2177
|
+
if (!(value > 0) || !Number.isFinite(value)) return value;
|
|
2178
|
+
alignF32Buf[0] = value;
|
|
2179
|
+
if (alignF32Buf[0] < value) alignU32Buf[0] = alignU32Buf[0] + 1;
|
|
2180
|
+
return alignF32Buf[0];
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* Aligns a measured inner text width upward to the smallest pixel value whose
|
|
2184
|
+
* outer `Math.round(outerPx * 9525)` minus emitted `lIns`/`rIns` EMU insets is
|
|
2185
|
+
* at least `Math.ceil(rawInnerWidthPx * 9525 - 1e-9)`, accounting for Yoga's
|
|
2186
|
+
* float32 rounding of both the inner width and horizontal padding insets.
|
|
2187
|
+
*/
|
|
2188
|
+
function alignMeasuredTextWidthForOuterEmu(rawInnerWidthPx, leftInsetPx, rightInsetPx) {
|
|
2189
|
+
const requiredOuterEmu = Math.max(0, Math.ceil(rawInnerWidthPx * 9525 - 1e-9)) + (Math.round(leftInsetPx * 9525) + Math.round(rightInsetPx * 9525));
|
|
2190
|
+
let candidate = Math.max(0, requiredOuterEmu / 9525 - leftInsetPx - rightInsetPx);
|
|
2191
|
+
const leftF32 = Math.fround(leftInsetPx);
|
|
2192
|
+
const rightF32 = Math.fround(rightInsetPx);
|
|
2193
|
+
for (let step = 0; step < 8; step += 1) {
|
|
2194
|
+
const innerF32 = ceilFloat32ForOuterEmu(candidate);
|
|
2195
|
+
const okLeftFirst = Math.round(Math.fround(Math.fround(innerF32 + leftF32) + rightF32) * 9525) >= requiredOuterEmu;
|
|
2196
|
+
const okInsetsFirst = Math.round(Math.fround(Math.fround(leftF32 + rightF32) + innerF32) * 9525) >= requiredOuterEmu;
|
|
2197
|
+
const okF64 = Math.round((innerF32 + leftInsetPx + rightInsetPx) * 9525) >= requiredOuterEmu;
|
|
2198
|
+
if (okLeftFirst && okInsetsFirst && okF64) return candidate;
|
|
2199
|
+
alignF32Buf[0] = innerF32 === 0 ? 0 : innerF32;
|
|
2200
|
+
alignU32Buf[0] = alignU32Buf[0] + 1;
|
|
2201
|
+
candidate = alignF32Buf[0];
|
|
2202
|
+
}
|
|
2203
|
+
return candidate;
|
|
2204
|
+
}
|
|
2205
|
+
/**
|
|
2206
|
+
* Applies outer-EMU width alignment to both `width` and `minContentWidth` of a
|
|
2207
|
+
* text layout measurement unless the solver requested an exact width.
|
|
2208
|
+
*/
|
|
2209
|
+
function alignMeasuredTextWidthsForOuterEmu(measured, insets, request) {
|
|
2210
|
+
if (request.widthMode === "exactly") return {
|
|
2211
|
+
width: measured.width,
|
|
2212
|
+
minContentWidth: measured.minContentWidth
|
|
2213
|
+
};
|
|
2214
|
+
const alignedWidth = alignMeasuredTextWidthForOuterEmu(measured.width, insets.left, insets.right);
|
|
2215
|
+
return {
|
|
2216
|
+
width: request.availableWidth !== void 0 && measured.width <= request.availableWidth && alignedWidth > request.availableWidth ? request.availableWidth : alignedWidth,
|
|
2217
|
+
minContentWidth: alignMeasuredTextWidthForOuterEmu(measured.minContentWidth, insets.left, insets.right)
|
|
2218
|
+
};
|
|
2219
|
+
}
|
|
1916
2220
|
/** Returns layout dimensions based on actual fonts and line breaking rules from normalized paragraphs. */
|
|
1917
2221
|
function measureTextLayoutFromParagraphs(paragraphs, style, availableWidth) {
|
|
1918
2222
|
const measured = measureParagraphs(paragraphs, availableWidth ?? Number.POSITIVE_INFINITY);
|
|
1919
|
-
const minContentWidth = Math.max(0, ...paragraphs.map(
|
|
2223
|
+
const minContentWidth = Math.max(0, ...paragraphs.map(measureParagraphMinContentWidth));
|
|
1920
2224
|
let baseline;
|
|
1921
2225
|
if (style.verticalAlign === void 0 || style.verticalAlign === "top") {
|
|
1922
2226
|
if (paragraphs[0] === void 0) baseline = void 0;
|
|
@@ -1935,11 +2239,7 @@ function measureTextLayoutFromParagraphs(paragraphs, style, availableWidth) {
|
|
|
1935
2239
|
};
|
|
1936
2240
|
}
|
|
1937
2241
|
function bodyAnchor(verticalAlign) {
|
|
1938
|
-
return
|
|
1939
|
-
top: "t",
|
|
1940
|
-
middle: "ctr",
|
|
1941
|
-
bottom: "b"
|
|
1942
|
-
}[verticalAlign ?? "top"];
|
|
2242
|
+
return bodyAnchors[resolveVerticalAlign(verticalAlign)];
|
|
1943
2243
|
}
|
|
1944
2244
|
function textInsets(value, placeholder) {
|
|
1945
2245
|
if (placeholder === void 0) return parseTextInsets(value);
|
|
@@ -1993,20 +2293,20 @@ function parseTextContent(children, styleValue, theme, fields = { slideNumber: 1
|
|
|
1993
2293
|
const parseTextParagraphs = parseTextContent;
|
|
1994
2294
|
function validateEmittableParagraphs(paragraphs, theme) {
|
|
1995
2295
|
for (const paragraph of paragraphs) {
|
|
1996
|
-
if (paragraph.style.list?.type === "bullet") escapedXml(paragraph.style.list.character ?? "•");
|
|
2296
|
+
if (paragraph.style.list?.type === "bullet") escapedXml(paragraph.style.list.character ?? "•", "style.list.character");
|
|
1997
2297
|
if (paragraph.runs.length === 0) {
|
|
1998
|
-
for (const font of normalizedFonts(paragraph.endStyle)) escapedXml(font.family);
|
|
1999
|
-
if (paragraph.endStyle.eastAsianFontFamily !== void 0) for (const eaFont of normalizedFontsForReference(paragraph.endStyle.eastAsianFontFamily, paragraph.endStyle.fontWeight, paragraph.endStyle.fontStyle)) escapedXml(eaFont.family);
|
|
2000
|
-
if (paragraph.endStyle.lang !== void 0) escapedXml(paragraph.endStyle.lang);
|
|
2298
|
+
for (const font of normalizedFonts(paragraph.endStyle)) escapedXml(font.family, "style.fontFamily");
|
|
2299
|
+
if (paragraph.endStyle.eastAsianFontFamily !== void 0) for (const eaFont of normalizedFontsForReference(paragraph.endStyle.eastAsianFontFamily, paragraph.endStyle.fontWeight, paragraph.endStyle.fontStyle)) escapedXml(eaFont.family, "style.eastAsianFontFamily");
|
|
2300
|
+
if (paragraph.endStyle.lang !== void 0) escapedXml(paragraph.endStyle.lang, "style.lang");
|
|
2001
2301
|
if (paragraph.endStyle.textShadow !== void 0 && paragraph.endStyle.textShadow !== "none") textShadowXml(theme, paragraph.endStyle.textShadow);
|
|
2002
2302
|
centipoints(fontSizePoints(paragraph.endStyle.fontSize));
|
|
2003
2303
|
continue;
|
|
2004
2304
|
}
|
|
2005
2305
|
for (const run of paragraph.runs) {
|
|
2006
2306
|
escapedXml(run.text);
|
|
2007
|
-
for (const font of normalizedFonts(run.style)) escapedXml(font.family);
|
|
2008
|
-
if (run.style.eastAsianFontFamily !== void 0) for (const eaFont of normalizedFontsForReference(run.style.eastAsianFontFamily, run.style.fontWeight, run.style.fontStyle)) escapedXml(eaFont.family);
|
|
2009
|
-
if (run.style.lang !== void 0) escapedXml(run.style.lang);
|
|
2307
|
+
for (const font of normalizedFonts(run.style)) escapedXml(font.family, "style.fontFamily");
|
|
2308
|
+
if (run.style.eastAsianFontFamily !== void 0) for (const eaFont of normalizedFontsForReference(run.style.eastAsianFontFamily, run.style.fontWeight, run.style.fontStyle)) escapedXml(eaFont.family, "style.eastAsianFontFamily");
|
|
2309
|
+
if (run.style.lang !== void 0) escapedXml(run.style.lang, "style.lang");
|
|
2010
2310
|
if (run.style.textShadow !== void 0 && run.style.textShadow !== "none") textShadowXml(theme, run.style.textShadow);
|
|
2011
2311
|
}
|
|
2012
2312
|
}
|
|
@@ -2056,24 +2356,24 @@ function resolveTextBody(rawParagraphs, style, theme, verticalAlign = "top", lay
|
|
|
2056
2356
|
return metrics === void 0 ? paragraph : {
|
|
2057
2357
|
...paragraph,
|
|
2058
2358
|
resolvedListIndent: {
|
|
2059
|
-
marginLeft: metrics.contentIndent,
|
|
2060
|
-
indent: -metrics.hangingIndent
|
|
2359
|
+
marginLeft: paragraph.style.marginLeft ?? metrics.contentIndent,
|
|
2360
|
+
indent: paragraph.style.indent ?? -metrics.hangingIndent
|
|
2061
2361
|
}
|
|
2062
2362
|
};
|
|
2063
2363
|
});
|
|
2064
|
-
const
|
|
2364
|
+
const runGroups = paragraphs.map((paragraph) => paragraph.runs.length > 0 ? paragraph.runs : [{
|
|
2065
2365
|
text: "",
|
|
2066
2366
|
style: paragraph.endStyle
|
|
2067
2367
|
}]);
|
|
2068
|
-
const
|
|
2368
|
+
const listRunGroups = paragraphs.flatMap((paragraph) => {
|
|
2069
2369
|
const list = paragraph.style.list;
|
|
2070
2370
|
if (list === void 0) return [];
|
|
2071
|
-
return [{
|
|
2371
|
+
return [[{
|
|
2072
2372
|
text: list.type === "bullet" ? list.character ?? "•" : "0123456789.",
|
|
2073
2373
|
style: paragraph.runs[0]?.style ?? paragraph.endStyle
|
|
2074
|
-
}];
|
|
2374
|
+
}]];
|
|
2075
2375
|
});
|
|
2076
|
-
const { resourceClaims, fontUses, fontUsages, missingGlyphErrors, unmeasuredIssues } = textResourceClaims([...
|
|
2376
|
+
const { resourceClaims, fontUses, fontUsages, missingGlyphErrors, unmeasuredIssues } = textResourceClaims([...runGroups, ...listRunGroups]);
|
|
2077
2377
|
let measured;
|
|
2078
2378
|
let measurementError;
|
|
2079
2379
|
if (layout !== void 0) try {
|
|
@@ -2168,8 +2468,8 @@ function emitTextBody(resolved, theme, options = {}) {
|
|
|
2168
2468
|
};
|
|
2169
2469
|
}
|
|
2170
2470
|
/** Generates shared font styles for native chart text and registers font claims based on actual categories, series, and label text. */
|
|
2171
|
-
function writeChartTextProperties(styleValue, texts, label, theme) {
|
|
2172
|
-
const style = readTextStyle(styleValue, label, theme);
|
|
2471
|
+
function writeChartTextProperties(styleValue, texts, label, theme, customText) {
|
|
2472
|
+
const style = readTextStyle(styleValue, label, theme, true);
|
|
2173
2473
|
const runStyle = {
|
|
2174
2474
|
fontFamily: style.fontFamily,
|
|
2175
2475
|
...style.eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily: style.eastAsianFontFamily },
|
|
@@ -2183,24 +2483,34 @@ function writeChartTextProperties(styleValue, texts, label, theme) {
|
|
|
2183
2483
|
textTransform: style.textTransform,
|
|
2184
2484
|
textDecoration: style.textDecoration,
|
|
2185
2485
|
textShadow: style.textShadow,
|
|
2486
|
+
textStroke: style.textStroke,
|
|
2186
2487
|
lang: style.lang
|
|
2187
2488
|
};
|
|
2188
2489
|
validateRunStyle(runStyle);
|
|
2189
|
-
const
|
|
2490
|
+
const runGroups = texts.map((text) => [{
|
|
2190
2491
|
text,
|
|
2191
2492
|
style: runStyle
|
|
2192
|
-
})
|
|
2493
|
+
}]);
|
|
2193
2494
|
for (const text of texts) escapedXml(text);
|
|
2194
|
-
const { resourceClaims, fontUses, fontUsages, missingGlyphErrors } = textResourceClaims(
|
|
2195
|
-
const defaultProperties = runPropertiesXml(runStyle, "a:defRPr", theme);
|
|
2495
|
+
const { resourceClaims, fontUses, fontUsages, missingGlyphErrors } = textResourceClaims(runGroups);
|
|
2496
|
+
const defaultProperties = runPropertiesXml(runStyle, "a:defRPr", theme, "chart-default");
|
|
2196
2497
|
const outputText = texts.join("\n");
|
|
2197
2498
|
const lineSpacing = lineSpacingXml(style.lineHeight);
|
|
2198
2499
|
const alignment = alignmentValue(style.align);
|
|
2199
2500
|
const paragraphAlignment = alignment === void 0 ? "" : ` algn="${alignment}"`;
|
|
2200
|
-
const spacingAfter = style.spacingAfter === void 0
|
|
2201
|
-
const endParaLang = runStyle.lang !== void 0 ? ` lang="${escapedXml(runStyle.lang)}"` : "";
|
|
2501
|
+
const spacingAfter = style.spacingAfter === void 0 ? "" : `<a:spcAft><a:spcPts val="${spacingCentipoints(style.spacingAfter, "spacingAfter")}"/></a:spcAft>`;
|
|
2502
|
+
const endParaLang = runStyle.lang !== void 0 ? ` lang="${escapedXml(runStyle.lang, "style.lang")}"` : "";
|
|
2503
|
+
const body = `<a:bodyPr anchor="${bodyAnchor(style.verticalAlign)}"/><a:lstStyle/>`;
|
|
2504
|
+
const paragraphProperties = `<a:pPr${paragraphAlignment}>${lineSpacing}${spacingAfter}${defaultProperties}</a:pPr>`;
|
|
2505
|
+
const endParagraph = `<a:endParaRPr${endParaLang}/>`;
|
|
2506
|
+
let customTextXml;
|
|
2507
|
+
if (customText !== void 0) {
|
|
2508
|
+
const runProperties = runPropertiesXml(runStyle, "a:rPr", theme, "chart-default");
|
|
2509
|
+
customTextXml = `<c:tx><c:rich>${body}${customText.split("\n").map((line) => `<a:p>${paragraphProperties}<a:r>${runProperties}<a:t>${escapedXml(line)}</a:t></a:r>${endParagraph}</a:p>`).join("")}</c:rich></c:tx>`;
|
|
2510
|
+
}
|
|
2202
2511
|
return {
|
|
2203
|
-
xml: `<c:txPr
|
|
2512
|
+
xml: `<c:txPr>${body}<a:p>${paragraphProperties}${endParagraph}</a:p></c:txPr>`,
|
|
2513
|
+
...customTextXml === void 0 ? {} : { customTextXml },
|
|
2204
2514
|
text: outputText,
|
|
2205
2515
|
resourceClaims,
|
|
2206
2516
|
fontUses,
|
|
@@ -2224,21 +2534,22 @@ function writeChartTitle(text, styleValue, label, theme, rotationDegrees) {
|
|
|
2224
2534
|
textTransform: style.textTransform,
|
|
2225
2535
|
textDecoration: style.textDecoration,
|
|
2226
2536
|
textShadow: style.textShadow,
|
|
2537
|
+
textStroke: style.textStroke,
|
|
2227
2538
|
lang: style.lang
|
|
2228
2539
|
};
|
|
2229
2540
|
validateRunStyle(runStyle);
|
|
2230
2541
|
const escapedText = escapedXml(text);
|
|
2231
|
-
const { resourceClaims, fontUses, fontUsages, missingGlyphErrors } = textResourceClaims([{
|
|
2542
|
+
const { resourceClaims, fontUses, fontUsages, missingGlyphErrors } = textResourceClaims([[{
|
|
2232
2543
|
text,
|
|
2233
2544
|
style: runStyle
|
|
2234
|
-
}]);
|
|
2545
|
+
}]]);
|
|
2235
2546
|
const runProperties = runPropertiesXml(runStyle, "a:rPr", theme);
|
|
2236
2547
|
const defaultProperties = runPropertiesXml(runStyle, "a:defRPr", theme);
|
|
2237
2548
|
const lineSpacing = lineSpacingXml(style.lineHeight);
|
|
2238
2549
|
const alignment = alignmentValue(style.align);
|
|
2239
2550
|
const paragraphAlignment = alignment === void 0 ? "" : ` algn="${alignment}"`;
|
|
2240
2551
|
const spacingAfter = style.spacingAfter === void 0 || style.spacingAfter === 0 ? "" : `<a:spcAft><a:spcPts val="${spacingCentipoints(style.spacingAfter, "spacingAfter")}"/></a:spcAft>`;
|
|
2241
|
-
const endParaLang = runStyle.lang !== void 0 ? ` lang="${escapedXml(runStyle.lang)}"` : "";
|
|
2552
|
+
const endParaLang = runStyle.lang !== void 0 ? ` lang="${escapedXml(runStyle.lang, "style.lang")}"` : "";
|
|
2242
2553
|
const bodyProperties = `<a:bodyPr${rotationDegrees !== void 0 && rotationDegrees !== 0 ? ` rot="${Math.round(rotationDegrees * 6e4)}"` : ""} anchor="${bodyAnchor(style.verticalAlign)}"/>`;
|
|
2243
2554
|
return {
|
|
2244
2555
|
xml: `<c:title><c:tx><c:rich>${bodyProperties}<a:lstStyle/><a:p><a:pPr${paragraphAlignment}>${lineSpacing}${spacingAfter}${defaultProperties}</a:pPr><a:r>${runProperties}<a:t>${escapedText}</a:t></a:r><a:endParaRPr${endParaLang}/></a:p></c:rich></c:tx><c:overlay val="0"/><c:txPr>${bodyProperties}<a:lstStyle/><a:p><a:pPr${paragraphAlignment}>${lineSpacing}${spacingAfter}${defaultProperties}</a:pPr><a:endParaRPr${endParaLang}/></a:p></c:txPr></c:title>`,
|
|
@@ -2249,4 +2560,4 @@ function writeChartTitle(text, styleValue, label, theme, rotationDegrees) {
|
|
|
2249
2560
|
missingGlyphErrors
|
|
2250
2561
|
};
|
|
2251
2562
|
}
|
|
2252
|
-
export { computeTextMetrics,
|
|
2563
|
+
export { alignMeasuredTextWidthForOuterEmu, alignMeasuredTextWidthsForOuterEmu, computeTextMetrics, declaredFontResourceClaims, emitTextBody, emitTextFieldRunXml, measureParagraphMinContentWidth, measureParagraphs, measureTextLayoutFromParagraphs, parseTextContent, parseTextParagraphs, previewParagraphOutlines, previewTextBoxOutlines, renderTextOutlinesSvg, resolveTextBody, textInsets, withPreviewFontBoundary, writeChartTextProperties, writeChartTitle };
|