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