@officedk/pptxdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import "../../kernel/capability.js";
|
|
3
|
+
import "../../kernel/pptx-read/index.js";
|
|
4
|
+
import { P_NS, R_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
5
|
+
import { defineShowMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
6
|
+
import { xmlDocument, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
7
|
+
import { commentCodegen } from "./comment-codegen.js";
|
|
8
|
+
import { commentDeclarationPropsSchema } from "./comment-declaration.js";
|
|
9
|
+
import { legacyCommentsImportHandler } from "./comment-import.js";
|
|
10
|
+
// ../core/dist/capabilities/comment/comment.js
|
|
11
|
+
const authorTables = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
function authorKey(author, initials) {
|
|
13
|
+
return JSON.stringify([author, initials]);
|
|
14
|
+
}
|
|
15
|
+
function commentAuthorTable(slides) {
|
|
16
|
+
const existing = authorTables.get(slides);
|
|
17
|
+
if (existing !== void 0) return existing;
|
|
18
|
+
const authors = /* @__PURE__ */ new Map();
|
|
19
|
+
const identityByComment = /* @__PURE__ */ new Map();
|
|
20
|
+
for (const slide of slides) for (const comment of slide.comments ?? []) {
|
|
21
|
+
const key = authorKey(comment.author, comment.initials);
|
|
22
|
+
let author = authors.get(key);
|
|
23
|
+
if (author === void 0) {
|
|
24
|
+
author = {
|
|
25
|
+
id: authors.size,
|
|
26
|
+
author: comment.author,
|
|
27
|
+
initials: comment.initials,
|
|
28
|
+
lastIndex: 0
|
|
29
|
+
};
|
|
30
|
+
authors.set(key, author);
|
|
31
|
+
}
|
|
32
|
+
identityByComment.set(comment, {
|
|
33
|
+
authorId: author.id,
|
|
34
|
+
index: ++author.lastIndex
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const entries = [...authors.values()].map(({ id, author, initials, lastIndex }) => `<p:cmAuthor id="${id}" name="${xmlEscape(author)}" initials="${xmlEscape(initials)}" lastIdx="${lastIndex}" clrIdx="${id}"/>`);
|
|
38
|
+
const result = {
|
|
39
|
+
xml: xmlDocument(`<p:cmAuthorLst xmlns:p="${P_NS}">${entries.join("")}</p:cmAuthorLst>`),
|
|
40
|
+
identityByComment
|
|
41
|
+
};
|
|
42
|
+
authorTables.set(slides, result);
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
function emitLegacyComments(comments, context) {
|
|
46
|
+
if (comments.length === 0) return { xml: "" };
|
|
47
|
+
if (context.slides === void 0) throw new CapabilityError("invalid-structure", "Comment emission requires the resolved slide list");
|
|
48
|
+
const authors = commentAuthorTable(context.slides);
|
|
49
|
+
context.registerSharedPart("comment-authors", {
|
|
50
|
+
part: {
|
|
51
|
+
pathTemplate: "ppt/commentAuthors.xml",
|
|
52
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml"
|
|
53
|
+
},
|
|
54
|
+
presentationRelationshipType: `${R_NS}/commentAuthors`,
|
|
55
|
+
content: () => authors.xml
|
|
56
|
+
});
|
|
57
|
+
context.registerPackagePart({
|
|
58
|
+
part: {
|
|
59
|
+
pathTemplate: `ppt/comments/comment${context.slideNumber}.xml`,
|
|
60
|
+
contentType: "application/vnd.openxmlformats-officedocument.presentationml.comments+xml"
|
|
61
|
+
},
|
|
62
|
+
slideRelationshipType: `${R_NS}/comments`,
|
|
63
|
+
content() {
|
|
64
|
+
const entries = comments.map((comment) => {
|
|
65
|
+
const identity = authors.identityByComment.get(comment);
|
|
66
|
+
const { position, createdAt, text } = comment;
|
|
67
|
+
const dt = createdAt === void 0 ? "" : ` dt="${xmlEscape(createdAt)}"`;
|
|
68
|
+
return `<p:cm authorId="${identity.authorId}"${dt} idx="${identity.index}"><p:pos x="${Math.round(position.x * 6)}" y="${Math.round(position.y * 6)}"/><p:text>${xmlEscape(text)}</p:text></p:cm>`;
|
|
69
|
+
});
|
|
70
|
+
return xmlDocument(`<p:cmLst xmlns:p="${P_NS}">${entries.join("")}</p:cmLst>`);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return { xml: "" };
|
|
74
|
+
}
|
|
75
|
+
function initialsFromAuthor(author) {
|
|
76
|
+
return author.trim().split(/\s+/u).map((word) => Array.from(word)[0].toUpperCase()).join("");
|
|
77
|
+
}
|
|
78
|
+
const legacyCommentsMechanism = defineShowMechanism({
|
|
79
|
+
key: "legacy-comments",
|
|
80
|
+
role: "show",
|
|
81
|
+
emit: emitLegacyComments,
|
|
82
|
+
import: legacyCommentsImportHandler
|
|
83
|
+
});
|
|
84
|
+
/** Page-affiliated plain-text review comments with no layout or paint participation. */
|
|
85
|
+
const commentCapability = Object.freeze({
|
|
86
|
+
declaration: "comment",
|
|
87
|
+
slot: "timing",
|
|
88
|
+
always: true,
|
|
89
|
+
codegen: commentCodegen,
|
|
90
|
+
mechanisms: [legacyCommentsMechanism],
|
|
91
|
+
transparentDeclarations: [{
|
|
92
|
+
declaration: "comment",
|
|
93
|
+
children: "owned",
|
|
94
|
+
compileDeclaration(input) {
|
|
95
|
+
const parsed = commentDeclarationPropsSchema.safeParse(input.props);
|
|
96
|
+
if (!parsed.success) {
|
|
97
|
+
const issue = parsed.error.issues[0];
|
|
98
|
+
if (issue.code === "unrecognized_keys") throw new CapabilityError("unknown-parameter", `Comment contains unsupported parameter ${issue.keys[0]}`, void 0, {
|
|
99
|
+
prop: issue.keys[0],
|
|
100
|
+
field: zodIssueField(issue)
|
|
101
|
+
});
|
|
102
|
+
throw new CapabilityError("invalid-prop", `Invalid Comment.${issue.path.join(".")}: ${issue.message}`, void 0, { field: zodIssueField(issue) });
|
|
103
|
+
}
|
|
104
|
+
if (input.children.length !== 0) throw new CapabilityError("invalid-structure", "Comment accepts only a plain text string");
|
|
105
|
+
const { id, author, initials = initialsFromAuthor(author), position, createdAt, text } = parsed.data;
|
|
106
|
+
return [{
|
|
107
|
+
capability: "comment",
|
|
108
|
+
value: {
|
|
109
|
+
...id === void 0 ? {} : { id },
|
|
110
|
+
author,
|
|
111
|
+
initials,
|
|
112
|
+
position,
|
|
113
|
+
text,
|
|
114
|
+
...createdAt === void 0 ? {} : { createdAt }
|
|
115
|
+
}
|
|
116
|
+
}];
|
|
117
|
+
}
|
|
118
|
+
}],
|
|
119
|
+
bindSlide(_input, context) {
|
|
120
|
+
const comments = Object.freeze(context.contributions.filter(({ capability }) => capability === "comment").map(({ path, value }, index) => {
|
|
121
|
+
const { position, ...fields } = value;
|
|
122
|
+
const offset = 24 + index * 24;
|
|
123
|
+
return Object.freeze({
|
|
124
|
+
...fields,
|
|
125
|
+
path,
|
|
126
|
+
position: Object.freeze(position ?? {
|
|
127
|
+
x: offset,
|
|
128
|
+
y: offset
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
}));
|
|
132
|
+
return { resolveSlide() {
|
|
133
|
+
return {
|
|
134
|
+
extensions: [],
|
|
135
|
+
...comments.length === 0 ? {} : { comments },
|
|
136
|
+
emit: (emitContext) => legacyCommentsMechanism.emit(comments, emitContext)
|
|
137
|
+
};
|
|
138
|
+
} };
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
export { commentCapability, legacyCommentsMechanism };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { commentCapability } from "./comment.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { slideDateTimeValueSchema, slideFooterValueSchema, slideNumberValueSchema } from "../../kernel/author-schemas.js";
|
|
2
|
+
import { footerPlaceholdersSchema } from "../../kernel/masters.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
import { defineSlideCodegen, serializeValidatedValue } from "../../kernel/codegen.js";
|
|
5
|
+
import { printHeaderFooterSchema } from "./print-header-footer.js";
|
|
6
|
+
// ../core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js
|
|
7
|
+
/** Source codegen contribution for `footerPlaceholders` and slide `footer` / `dateTime` / `slideNumber`. */
|
|
8
|
+
const footerPlaceholderCodegen = defineSlideCodegen({ slideProps: {
|
|
9
|
+
notesHeaderFooter: (value, ctx) => serializeValidatedValue("notesHeaderFooter", (candidate) => printHeaderFooterSchema.safeParse(candidate), value, ctx),
|
|
10
|
+
handoutHeaderFooter: (value, ctx) => serializeValidatedValue("handoutHeaderFooter", (candidate) => printHeaderFooterSchema.safeParse(candidate), value, ctx),
|
|
11
|
+
footerPlaceholders: (value, ctx) => serializeValidatedValue("footerPlaceholders", (candidate) => footerPlaceholdersSchema.safeParse(candidate), value, ctx),
|
|
12
|
+
footer: (value, ctx) => serializeValidatedValue("footer", (candidate) => slideFooterValueSchema.safeParse(candidate), value, ctx),
|
|
13
|
+
dateTime: (value, ctx) => serializeValidatedValue("dateTime", (candidate) => slideDateTimeValueSchema.safeParse(candidate), value, ctx),
|
|
14
|
+
slideNumber: (value, ctx) => serializeValidatedValue("slideNumber", (candidate) => slideNumberValueSchema.safeParse(candidate), value, ctx)
|
|
15
|
+
} });
|
|
16
|
+
export { footerPlaceholderCodegen };
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "
|
|
6
|
-
import {
|
|
7
|
-
import "
|
|
8
|
-
import {
|
|
9
|
-
import "
|
|
10
|
-
import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, readOoxmlBoxInsets, readOoxmlRunAttrStyles } from "../../../import/dist/xml-fragments.js";
|
|
11
|
-
import { readRunFontSlots } from "../../../import/dist/fonts.js";
|
|
12
|
-
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
13
|
-
import "../../../import/dist/index.js";
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { dateTimeFormatSchema } from "../../kernel/date-time-format.js";
|
|
3
|
+
import { emuToPx, pxToEmu } from "../../kernel/drawing-units.js";
|
|
4
|
+
import { schemeColorNameSchema, textStyleFrom } from "../../kernel/theme.js";
|
|
5
|
+
import { resolvePlaceholderBoxFromLayers } from "../../kernel/placeholders.js";
|
|
6
|
+
import { slideDateTimeValueSchema, slideFooterValueSchema, slideNumberValueSchema } from "../../kernel/author-schemas.js";
|
|
7
|
+
import { footerPlaceholdersSchema } from "../../kernel/masters.js";
|
|
8
|
+
import { footerSlots } from "../shared/container-slots.js";
|
|
9
|
+
import "../shared/date-time.js";
|
|
14
10
|
import { emitTextBody, parseTextContent, renderTextOutlinesSvg, resolveTextBody } from "../shared/text-service.js";
|
|
15
|
-
import
|
|
11
|
+
import "../../kernel/capability.js";
|
|
12
|
+
import { A_NS, P_NS, XML_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
13
|
+
import { extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlNonNegativeIntSchema, readOoxmlBoxInsets, readOoxmlRunAttrStyles } from "../../kernel/pptx-read/xml-fragments.js";
|
|
14
|
+
import { readRunFillAndStroke } from "../../kernel/pptx-read/visual.js";
|
|
15
|
+
import { readRunFontSlots } from "../../kernel/pptx-read/fonts.js";
|
|
16
|
+
import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
17
|
+
import "../../kernel/index.js";
|
|
18
|
+
import "../../kernel/pptx-read/index.js";
|
|
19
|
+
import { xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
20
|
+
import { footerPlaceholderCodegen } from "./footer-placeholder-codegen.js";
|
|
21
|
+
import { bindPrintHeaderFooter, printHeaderFooterMechanism } from "./print-header-footer.js";
|
|
16
22
|
import { z } from "zod";
|
|
17
|
-
// ../
|
|
23
|
+
// ../core/dist/capabilities/footer-placeholder/footer-placeholder.js
|
|
18
24
|
const slotToOoxmlType = {
|
|
19
25
|
dateTime: "dt",
|
|
20
26
|
footer: "ftr",
|
|
@@ -69,6 +75,7 @@ function defaultSlotBox(slot, dimensions) {
|
|
|
69
75
|
width: Math.round(dimensions.width * .23),
|
|
70
76
|
height
|
|
71
77
|
};
|
|
78
|
+
default: return slot;
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
function hasExplicitGeometry(spec) {
|
|
@@ -96,15 +103,22 @@ function resolveBoxFromSpecs(slot, dimensions, ...specs) {
|
|
|
96
103
|
};
|
|
97
104
|
}
|
|
98
105
|
function buildFooterTextBody(args) {
|
|
99
|
-
const { slot, content, style, box, theme, slideNumber } = args;
|
|
106
|
+
const { slot, content, format, referenceDate, style, box, theme, slideNumber } = args;
|
|
100
107
|
const parsed = parseTextContent(slot === "slideNumber" ? [{
|
|
101
108
|
type: "slide-number",
|
|
102
109
|
props: {},
|
|
103
110
|
children: []
|
|
111
|
+
}] : format !== void 0 ? [{
|
|
112
|
+
type: "date-time",
|
|
113
|
+
props: { format },
|
|
114
|
+
children: []
|
|
104
115
|
}] : content === void 0 || content === "" ? [] : [{
|
|
105
116
|
type: "#text",
|
|
106
117
|
text: content
|
|
107
|
-
}], style === void 0 ? void 0 : textStyleFrom(style, theme), theme, {
|
|
118
|
+
}], style === void 0 ? void 0 : textStyleFrom(style, theme), theme, {
|
|
119
|
+
slideNumber,
|
|
120
|
+
referenceDate
|
|
121
|
+
}, `footerPlaceholders.${slot}.style`);
|
|
108
122
|
return resolveTextBody(parsed.paragraphs, parsed.style, theme, parsed.style.verticalAlign ?? "middle", {
|
|
109
123
|
width: box.width,
|
|
110
124
|
height: box.height,
|
|
@@ -167,7 +181,7 @@ function paintFooterPlaceholderModel(model, paintContext) {
|
|
|
167
181
|
}
|
|
168
182
|
return { svg: svgParts.join("") };
|
|
169
183
|
}
|
|
170
|
-
function normalizeSlideSlotOverride(
|
|
184
|
+
function normalizeSlideSlotOverride(value) {
|
|
171
185
|
if (value === void 0) return { explicit: false };
|
|
172
186
|
if (typeof value === "boolean") return {
|
|
173
187
|
explicit: true,
|
|
@@ -181,7 +195,8 @@ function normalizeSlideSlotOverride(slot, value) {
|
|
|
181
195
|
return {
|
|
182
196
|
explicit: true,
|
|
183
197
|
visible: value.visible ?? true,
|
|
184
|
-
...
|
|
198
|
+
..."format" in value && value.format !== void 0 ? { format: value.format } : {},
|
|
199
|
+
..."text" in value && value.text !== void 0 ? { text: value.text } : {},
|
|
185
200
|
...value.style === void 0 ? {} : { style: value.style },
|
|
186
201
|
...value.idx === void 0 ? {} : { idx: value.idx },
|
|
187
202
|
...value.size === void 0 ? {} : { size: value.size }
|
|
@@ -194,18 +209,26 @@ function isHeaderFooterEnabled(slot, masterHf, layoutHf) {
|
|
|
194
209
|
if (masterFlag !== void 0) return masterFlag;
|
|
195
210
|
return true;
|
|
196
211
|
}
|
|
212
|
+
const slideFooterOverrides = z.object({
|
|
213
|
+
footer: slideFooterValueSchema.optional(),
|
|
214
|
+
slideNumber: slideNumberValueSchema.optional(),
|
|
215
|
+
dateTime: slideDateTimeValueSchema.optional()
|
|
216
|
+
});
|
|
197
217
|
function resolveSlideFooterModel(args) {
|
|
198
|
-
const { slideProps, inheritance, dimensions, theme, slideNumber } = args;
|
|
218
|
+
const { slideProps, inheritance, dimensions, theme, slideNumber, referenceDate } = args;
|
|
199
219
|
const masterPlaceholders = inheritance?.master?.footerPlaceholders;
|
|
200
220
|
const layoutPlaceholders = inheritance?.layout?.footerPlaceholders;
|
|
201
221
|
const masterHf = inheritance?.master?.headerFooter;
|
|
202
222
|
const layoutHf = inheritance?.layout?.headerFooter;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
223
|
+
const parsed = slideFooterOverrides.safeParse(slideProps);
|
|
224
|
+
if (!parsed.success) {
|
|
225
|
+
const issue = parsed.error.issues[0];
|
|
226
|
+
throw new CapabilityError("invalid-prop", issue?.message ?? "Invalid slide footer override", void 0, { field: zodIssueField(issue) });
|
|
227
|
+
}
|
|
228
|
+
const { dateTime: parsedDateTime, footer: parsedFooter, slideNumber: parsedSlideNumber } = parsed.data;
|
|
206
229
|
const items = [];
|
|
207
230
|
for (const slot of slotOrder) {
|
|
208
|
-
const slideOverride = normalizeSlideSlotOverride(slot
|
|
231
|
+
const slideOverride = normalizeSlideSlotOverride(slot === "dateTime" ? parsedDateTime : slot === "footer" ? parsedFooter : parsedSlideNumber);
|
|
209
232
|
const masterSpec = masterPlaceholders?.[slot];
|
|
210
233
|
const layoutSpec = layoutPlaceholders?.[slot];
|
|
211
234
|
const hfEnabled = isHeaderFooterEnabled(slot, masterHf, layoutHf);
|
|
@@ -221,12 +244,24 @@ function resolveSlideFooterModel(args) {
|
|
|
221
244
|
const slideStyleSpec = slideOverride.explicit && slideOverride.style !== void 0 ? { style: slideOverride.style } : void 0;
|
|
222
245
|
const box = resolveBoxFromSpecs(slot, dimensions, masterSpec, layoutSpec, slideStyleSpec);
|
|
223
246
|
const style = mergeFooterStyle(masterSpec?.style, layoutSpec?.style, slideOverride.explicit ? slideOverride.style : void 0);
|
|
224
|
-
|
|
247
|
+
let content;
|
|
248
|
+
let format;
|
|
249
|
+
if (slot === "dateTime") {
|
|
250
|
+
const contentSpec = [
|
|
251
|
+
slideOverride.explicit ? slideOverride : void 0,
|
|
252
|
+
layoutPlaceholders?.dateTime,
|
|
253
|
+
masterPlaceholders?.dateTime
|
|
254
|
+
].find((layer) => layer?.text !== void 0 || layer?.format !== void 0);
|
|
255
|
+
content = contentSpec?.text;
|
|
256
|
+
format = contentSpec?.format ?? (contentSpec === void 0 && parsedDateTime === true ? "datetimeFigureOut" : void 0);
|
|
257
|
+
} else if (slot === "footer") content = (slideOverride.explicit ? slideOverride.text : void 0) ?? layoutSpec?.text ?? masterSpec?.text;
|
|
225
258
|
const idx = (slideOverride.explicit ? slideOverride.idx : void 0) ?? layoutSpec?.idx ?? masterSpec?.idx ?? defaults.idx;
|
|
226
259
|
const size = (slideOverride.explicit ? slideOverride.size : void 0) ?? layoutSpec?.size ?? masterSpec?.size ?? defaults.size;
|
|
227
260
|
const text = buildFooterTextBody({
|
|
228
261
|
slot,
|
|
229
262
|
content,
|
|
263
|
+
format,
|
|
264
|
+
referenceDate,
|
|
230
265
|
style,
|
|
231
266
|
box,
|
|
232
267
|
theme,
|
|
@@ -240,13 +275,14 @@ function resolveSlideFooterModel(args) {
|
|
|
240
275
|
box,
|
|
241
276
|
emitGeometry: !hasExplicitGeometry(layoutSpec) || slideStyleSpec !== void 0,
|
|
242
277
|
name: `${defaults.namePrefix} ${idx}`,
|
|
243
|
-
text
|
|
278
|
+
text,
|
|
279
|
+
...format === void 0 ? {} : { format }
|
|
244
280
|
});
|
|
245
281
|
}
|
|
246
282
|
return { items };
|
|
247
283
|
}
|
|
248
284
|
function resolveContainerFooterModel(args) {
|
|
249
|
-
const { targetType, footerPlaceholders, dimensions, theme } = args;
|
|
285
|
+
const { targetType, footerPlaceholders, dimensions, theme, referenceDate } = args;
|
|
250
286
|
const items = [];
|
|
251
287
|
for (const slot of slotOrder) {
|
|
252
288
|
const spec = footerPlaceholders[slot];
|
|
@@ -255,9 +291,12 @@ function resolveContainerFooterModel(args) {
|
|
|
255
291
|
const box = resolveBoxFromSpecs(slot, dimensions, spec);
|
|
256
292
|
const idx = spec.idx ?? defaults.idx;
|
|
257
293
|
const size = spec.size ?? defaults.size;
|
|
294
|
+
const format = slot === "dateTime" ? footerPlaceholders.dateTime?.format : void 0;
|
|
258
295
|
const text = buildFooterTextBody({
|
|
259
296
|
slot,
|
|
260
297
|
content: spec.text,
|
|
298
|
+
format,
|
|
299
|
+
referenceDate,
|
|
261
300
|
style: spec.style,
|
|
262
301
|
box,
|
|
263
302
|
theme,
|
|
@@ -271,7 +310,8 @@ function resolveContainerFooterModel(args) {
|
|
|
271
310
|
box,
|
|
272
311
|
emitGeometry: targetType === "slide-master" || hasExplicitGeometry(spec),
|
|
273
312
|
name: `${defaults.namePrefix} ${idx}`,
|
|
274
|
-
text
|
|
313
|
+
text,
|
|
314
|
+
...format === void 0 ? {} : { format }
|
|
275
315
|
});
|
|
276
316
|
}
|
|
277
317
|
return { items };
|
|
@@ -406,11 +446,9 @@ function readFooterRunStyle(rPrCursor, location, diagnostics) {
|
|
|
406
446
|
location,
|
|
407
447
|
diagnostics,
|
|
408
448
|
allowBaseline: false,
|
|
409
|
-
allowNoneTextDecoration: false,
|
|
410
449
|
diagnoseUnsupportedEnums: false
|
|
411
450
|
});
|
|
412
|
-
const
|
|
413
|
-
const color = solidFill === void 0 ? void 0 : readFooterXmlColor(solidFill, location, diagnostics);
|
|
451
|
+
const { color, textStroke } = readRunFillAndStroke(rPrCursor, location, diagnostics, (solidFill) => readFooterXmlColor(solidFill, location, diagnostics));
|
|
414
452
|
const { fontFamily, eastAsianFontFamily } = readRunFontSlots(rPrCursor);
|
|
415
453
|
return {
|
|
416
454
|
...attrStyles.fontSize === void 0 ? {} : { fontSize: attrStyles.fontSize },
|
|
@@ -419,6 +457,7 @@ function readFooterRunStyle(rPrCursor, location, diagnostics) {
|
|
|
419
457
|
...attrStyles.lang === void 0 ? {} : { lang: attrStyles.lang },
|
|
420
458
|
...attrStyles.letterSpacing === void 0 ? {} : { letterSpacing: attrStyles.letterSpacing },
|
|
421
459
|
...color === void 0 ? {} : { color },
|
|
460
|
+
...textStroke === void 0 ? {} : { textStroke },
|
|
422
461
|
...fontFamily === void 0 ? {} : { fontFamily },
|
|
423
462
|
...eastAsianFontFamily === void 0 ? {} : { eastAsianFontFamily }
|
|
424
463
|
};
|
|
@@ -485,6 +524,7 @@ function readFooterPlaceholderImport(context) {
|
|
|
485
524
|
const spPr = cursor.child(P_NS, "spPr");
|
|
486
525
|
const box = spPr === void 0 ? void 0 : readSpPrTransformBox(spPr, location, diagnostics);
|
|
487
526
|
let style;
|
|
527
|
+
let format;
|
|
488
528
|
const textParts = [];
|
|
489
529
|
const txBody = cursor.child(P_NS, "txBody");
|
|
490
530
|
if (txBody !== void 0) {
|
|
@@ -549,15 +589,26 @@ function readFooterPlaceholderImport(context) {
|
|
|
549
589
|
}
|
|
550
590
|
} else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "fld") {
|
|
551
591
|
hasRunOrField = true;
|
|
552
|
-
FieldAttrSchema.safeParse(child.attrsObject(["id", "type"]));
|
|
592
|
+
const fieldType = FieldAttrSchema.safeParse(child.attrsObject(["id", "type"]));
|
|
593
|
+
const parsedFormat = dateTimeFormatSchema.safeParse(fieldType.data?.type);
|
|
594
|
+
if (slot === "dateTime" && parsedFormat.success && format === void 0) format = parsedFormat.data;
|
|
595
|
+
else if (slot !== "slideNumber" || fieldType.data?.type !== "slidenum") diagnostics.push({
|
|
596
|
+
code: "unsupported-mechanism",
|
|
597
|
+
category: "unsupported",
|
|
598
|
+
disposition: "omitted",
|
|
599
|
+
location: {
|
|
600
|
+
...location,
|
|
601
|
+
xpath: child.xpath
|
|
602
|
+
},
|
|
603
|
+
namespaceUri: A_NS,
|
|
604
|
+
localName: "fld",
|
|
605
|
+
mechanismHint: `text-field:${fieldType.data?.type ?? "unknown"}`
|
|
606
|
+
});
|
|
553
607
|
const rPr = child.child(A_NS, "rPr");
|
|
554
608
|
if (rPr !== void 0) style = mergeFooterStyle(style, readFooterRunStyle(rPr, location, diagnostics));
|
|
555
609
|
child.ignoreEmptyChild(A_NS, "pPr");
|
|
556
610
|
const t = child.child(A_NS, "t");
|
|
557
|
-
if (t !== void 0)
|
|
558
|
-
t.consumeAttr("space", XML_NS);
|
|
559
|
-
paragraphText += t.textContent;
|
|
560
|
-
}
|
|
611
|
+
if (t !== void 0) t.consumeAttr("space", XML_NS);
|
|
561
612
|
} else if (child.namespaceUri === "http://schemas.openxmlformats.org/drawingml/2006/main" && child.localName === "endParaRPr") {
|
|
562
613
|
const endStyle = readFooterRunStyle(child, location, diagnostics);
|
|
563
614
|
if (!hasRunOrField) style = mergeFooterStyle(style, endStyle);
|
|
@@ -579,7 +630,7 @@ function readFooterPlaceholderImport(context) {
|
|
|
579
630
|
const spec = {
|
|
580
631
|
...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
|
|
581
632
|
...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz },
|
|
582
|
-
...slot !== "slideNumber" && combinedText !== "" ? { text: combinedText } : {},
|
|
633
|
+
...format !== void 0 ? { format } : slot !== "slideNumber" && combinedText !== "" ? { text: combinedText } : {},
|
|
583
634
|
...specStyle === void 0 ? {} : { style: specStyle },
|
|
584
635
|
visible: false
|
|
585
636
|
};
|
|
@@ -597,9 +648,17 @@ function readFooterPlaceholderImport(context) {
|
|
|
597
648
|
};
|
|
598
649
|
containerNode.set({ slideNumber: value });
|
|
599
650
|
} else {
|
|
600
|
-
const
|
|
601
|
-
...
|
|
602
|
-
|
|
651
|
+
const slideStyle = slot === "dateTime" && box !== void 0 ? {
|
|
652
|
+
...style,
|
|
653
|
+
position: "absolute",
|
|
654
|
+
left: box.x,
|
|
655
|
+
top: box.y,
|
|
656
|
+
width: box.width,
|
|
657
|
+
height: box.height
|
|
658
|
+
} : style;
|
|
659
|
+
const value = format === void 0 && slideStyle === void 0 && parsedPh.data.idx === void 0 && parsedPh.data.sz === void 0 ? combinedText : {
|
|
660
|
+
...format !== void 0 ? { format } : slot === "dateTime" || combinedText !== "" ? { text: combinedText } : {},
|
|
661
|
+
...slideStyle === void 0 ? {} : { style: slideStyle },
|
|
603
662
|
...parsedPh.data.idx === void 0 ? {} : { idx: parsedPh.data.idx },
|
|
604
663
|
...parsedPh.data.sz === void 0 ? {} : { size: parsedPh.data.sz }
|
|
605
664
|
};
|
|
@@ -612,7 +671,13 @@ const footerPlaceholderShapeImportHandler = {
|
|
|
612
671
|
target: "shape-tree",
|
|
613
672
|
localName: "sp",
|
|
614
673
|
matches(cursor) {
|
|
615
|
-
|
|
674
|
+
const type = readFooterPlaceholderOoxmlType(cursor);
|
|
675
|
+
if (type === "dt") {
|
|
676
|
+
const nv = directDomChild(cursor.element, P_NS, "nvSpPr");
|
|
677
|
+
const textBox = (nv === void 0 ? void 0 : directDomChild(nv, P_NS, "cNvSpPr"))?.getAttribute("txBox");
|
|
678
|
+
if (textBox === "1" || textBox === "true") return false;
|
|
679
|
+
}
|
|
680
|
+
return type !== void 0;
|
|
616
681
|
},
|
|
617
682
|
read: readFooterPlaceholderImport
|
|
618
683
|
};
|
|
@@ -626,28 +691,25 @@ const footerPlaceholderMechanism = defineCanvasMechanism({
|
|
|
626
691
|
});
|
|
627
692
|
/** Slide capability resolving, painting, emitting, and importing `dateTime`, `footer`, `slideNumber`, and master/layout `footerPlaceholders`. */
|
|
628
693
|
const footerPlaceholderCapability = {
|
|
629
|
-
|
|
630
|
-
slideProp: "footer",
|
|
631
|
-
slideProps: [
|
|
632
|
-
"footer",
|
|
633
|
-
"dateTime",
|
|
634
|
-
"slideNumber"
|
|
635
|
-
],
|
|
694
|
+
...footerSlots,
|
|
636
695
|
slot: "shape-tree",
|
|
637
696
|
always: true,
|
|
638
|
-
mechanisms: [footerPlaceholderMechanism],
|
|
697
|
+
mechanisms: [footerPlaceholderMechanism, printHeaderFooterMechanism],
|
|
639
698
|
codegen: footerPlaceholderCodegen,
|
|
699
|
+
bindDeck: bindPrintHeaderFooter,
|
|
640
700
|
bindSlide(input, context) {
|
|
641
701
|
const model = input.type === "slide-master" || input.type === "slide-layout" ? resolveContainerFooterModel({
|
|
642
702
|
targetType: input.type,
|
|
643
703
|
footerPlaceholders: footerPlaceholdersSchema.parse(input.props["footerPlaceholders"] ?? {}),
|
|
644
704
|
dimensions: context.dimensions,
|
|
645
|
-
theme: context.theme
|
|
705
|
+
theme: context.theme,
|
|
706
|
+
referenceDate: context.options.referenceDate
|
|
646
707
|
}) : resolveSlideFooterModel({
|
|
647
708
|
slideProps: input.props,
|
|
648
709
|
...context.inheritance === void 0 ? {} : { inheritance: context.inheritance },
|
|
649
710
|
dimensions: context.dimensions,
|
|
650
711
|
theme: context.theme,
|
|
712
|
+
referenceDate: context.options.referenceDate,
|
|
651
713
|
slideNumber: context.slideNumber
|
|
652
714
|
});
|
|
653
715
|
return { resolveSlide() {
|
|
@@ -664,6 +726,7 @@ const footerPlaceholderCapability = {
|
|
|
664
726
|
slots[item.slot] = {
|
|
665
727
|
box: item.box,
|
|
666
728
|
text: item.text.text,
|
|
729
|
+
...item.format === void 0 ? {} : { format: item.format },
|
|
667
730
|
textMetrics: item.text.textMetrics
|
|
668
731
|
};
|
|
669
732
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { dateTimeFormatSchema } from "../../kernel/date-time-format.js";
|
|
2
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
3
|
+
import { XmlElementCursor, parseXmlPart } from "../../kernel/pptx-read/xml-reader.js";
|
|
4
|
+
import { resolvePartPath } from "../../kernel/pptx-read/opc.js";
|
|
5
|
+
import { peekShapeTreeObjectIdentity } from "../../kernel/pptx-read/resources.js";
|
|
6
|
+
import "../../kernel/pptx-read/index.js";
|
|
7
|
+
// ../core/dist/capabilities/footer-placeholder/print-header-footer-import.js
|
|
8
|
+
const slotTypes = {
|
|
9
|
+
hdr: "header",
|
|
10
|
+
dt: "dateTime",
|
|
11
|
+
ftr: "footer",
|
|
12
|
+
sldNum: "pageNumber"
|
|
13
|
+
};
|
|
14
|
+
function readCornerText(corner) {
|
|
15
|
+
const body = corner?.child(P_NS, "txBody");
|
|
16
|
+
if (body === void 0) return {};
|
|
17
|
+
const contents = body.children(A_NS, "p").map((p) => p.matchingChildren((element) => element.namespaceURI === "http://schemas.openxmlformats.org/drawingml/2006/main" && (element.localName === "r" || element.localName === "fld" || element.localName === "br")));
|
|
18
|
+
const field = contents.flat().find((item) => item.localName === "fld");
|
|
19
|
+
const type = field?.attr("type");
|
|
20
|
+
const lang = field?.child(A_NS, "rPr")?.attr("lang");
|
|
21
|
+
return {
|
|
22
|
+
text: contents.some((paragraph) => paragraph.length > 0) ? contents.map((paragraph) => paragraph.map((item) => item.localName === "br" ? "\n" : item.child("http://schemas.openxmlformats.org/drawingml/2006/main", "t")?.textContent ?? "").join("")).join("\n") : void 0,
|
|
23
|
+
type,
|
|
24
|
+
lang
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function readConfiguration({ headerFooter, placeholders }) {
|
|
28
|
+
const entries = Object.entries(slotTypes).flatMap(([type, slot]) => {
|
|
29
|
+
const corner = placeholders.get(type);
|
|
30
|
+
const flag = headerFooter?.attr(type);
|
|
31
|
+
if (!(flag === void 0 ? headerFooter !== void 0 || corner !== void 0 : flag === "1" || flag === "true")) return corner === void 0 ? [] : [[slot, false]];
|
|
32
|
+
if (type === "sldNum") return [[slot, true]];
|
|
33
|
+
const { text, type: fieldType, lang } = readCornerText(corner);
|
|
34
|
+
if (type === "dt") {
|
|
35
|
+
const format = dateTimeFormatSchema.safeParse(fieldType);
|
|
36
|
+
if (format.success) return [[slot, {
|
|
37
|
+
format: format.data,
|
|
38
|
+
...lang === void 0 ? {} : { lang }
|
|
39
|
+
}]];
|
|
40
|
+
}
|
|
41
|
+
return [[slot, text ?? true]];
|
|
42
|
+
});
|
|
43
|
+
return Object.fromEntries(entries);
|
|
44
|
+
}
|
|
45
|
+
function matchesMasterText(expected, actual) {
|
|
46
|
+
if (actual.type === void 0 && actual.text === void 0) return true;
|
|
47
|
+
if (typeof expected === "object") return expected.format === actual.type && (expected.lang ?? "en-US") === (actual.lang ?? "en-US");
|
|
48
|
+
if (typeof expected === "boolean") return expected && (actual.type === "slidenum" || actual.text === "");
|
|
49
|
+
return expected === actual.text && actual.type === void 0;
|
|
50
|
+
}
|
|
51
|
+
function reportNotesOverrides(context, master, diagnostics) {
|
|
52
|
+
const { package: pkg, presentationCursor, relById } = context;
|
|
53
|
+
let hasNotesSlides = false;
|
|
54
|
+
const slides = presentationCursor.child("http://schemas.openxmlformats.org/presentationml/2006/main", "sldIdLst")?.children("http://schemas.openxmlformats.org/presentationml/2006/main", "sldId") ?? [];
|
|
55
|
+
for (const [index, slide] of slides.entries()) {
|
|
56
|
+
const slideRel = relById?.get(slide.attr("id", "http://schemas.openxmlformats.org/officeDocument/2006/relationships") ?? "");
|
|
57
|
+
if (slideRel?.Type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" || slideRel.TargetMode === "External") continue;
|
|
58
|
+
const slidePath = resolvePartPath(pkg.presentationPath, slideRel.Target);
|
|
59
|
+
if (slidePath === void 0) continue;
|
|
60
|
+
const notesRel = pkg.readRelationships(slidePath).entries.find((rel) => rel.Type === "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" && rel.TargetMode !== "External");
|
|
61
|
+
if (notesRel === void 0) continue;
|
|
62
|
+
const notesPath = resolvePartPath(slidePath, notesRel.Target);
|
|
63
|
+
if (notesPath === void 0) continue;
|
|
64
|
+
const source = pkg.readTextPart(notesPath);
|
|
65
|
+
if (source === void 0) continue;
|
|
66
|
+
hasNotesSlides = true;
|
|
67
|
+
let root;
|
|
68
|
+
try {
|
|
69
|
+
root = XmlElementCursor.createRoot(parseXmlPart(notesPath, source), notesPath);
|
|
70
|
+
} catch {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (root.namespaceUri !== "http://schemas.openxmlformats.org/presentationml/2006/main" || root.localName !== "notes") continue;
|
|
74
|
+
const corners = root.child("http://schemas.openxmlformats.org/presentationml/2006/main", "cSld")?.child("http://schemas.openxmlformats.org/presentationml/2006/main", "spTree")?.children("http://schemas.openxmlformats.org/presentationml/2006/main", "sp") ?? [];
|
|
75
|
+
for (const corner of corners) {
|
|
76
|
+
const type = corner.child(P_NS, "nvSpPr")?.child(P_NS, "nvPr")?.child(P_NS, "ph")?.attr("type");
|
|
77
|
+
if (type === void 0 || !Object.hasOwn(slotTypes, type)) continue;
|
|
78
|
+
const slot = slotTypes[type];
|
|
79
|
+
const text = readCornerText(corner);
|
|
80
|
+
if (matchesMasterText(master[slot], text)) continue;
|
|
81
|
+
diagnostics.push({
|
|
82
|
+
code: "compatibility-fallback",
|
|
83
|
+
category: "unsupported",
|
|
84
|
+
disposition: "fallback",
|
|
85
|
+
location: {
|
|
86
|
+
part: notesPath,
|
|
87
|
+
xpath: corner.xpath,
|
|
88
|
+
slideIndex: index,
|
|
89
|
+
...peekShapeTreeObjectIdentity(corner.element)
|
|
90
|
+
},
|
|
91
|
+
preferredMechanism: "notes-page-header-footer-override",
|
|
92
|
+
selectedFallback: "notes-master-header-footer",
|
|
93
|
+
loss: {
|
|
94
|
+
lost: "native-mechanism",
|
|
95
|
+
retainedAs: "notes-master-header-footer"
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return hasNotesSlides;
|
|
101
|
+
}
|
|
102
|
+
const printHeaderFooterImportHandler = {
|
|
103
|
+
target: "deck",
|
|
104
|
+
stage: "post-slides",
|
|
105
|
+
read(context) {
|
|
106
|
+
const deckNode = context.deckNode;
|
|
107
|
+
const diagnostics = [];
|
|
108
|
+
let notesHeaderFooter;
|
|
109
|
+
const result = context.readPrintMasters?.((part) => {
|
|
110
|
+
const configuration = readConfiguration(part);
|
|
111
|
+
if (part.kind === "notesMaster") notesHeaderFooter ??= configuration;
|
|
112
|
+
else deckNode.set({ handoutHeaderFooter: configuration });
|
|
113
|
+
});
|
|
114
|
+
diagnostics.push(...result?.diagnostics ?? []);
|
|
115
|
+
if (notesHeaderFooter !== void 0) {
|
|
116
|
+
if (!reportNotesOverrides(context, notesHeaderFooter, diagnostics) || Object.keys(notesHeaderFooter).length > 0) deckNode.set({ notesHeaderFooter });
|
|
117
|
+
}
|
|
118
|
+
return { diagnostics };
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
export { printHeaderFooterImportHandler };
|