@officedk/pptxdk 0.0.0-stage → 0.1.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/README.md +48 -2
- package/dist/build.d.ts +94 -0
- package/dist/build.js +148 -0
- package/dist/capabilities/dist/all.js +32 -0
- package/dist/capabilities/dist/box/box-codegen.js +51 -0
- package/dist/capabilities/dist/box/box-declaration.js +31 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +138 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +77 -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 +2272 -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 +1078 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1124 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -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 +190 -0
- package/dist/capabilities/dist/chart/preview/layout.js +519 -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 +48 -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 +148 -0
- package/dist/capabilities/dist/font/font-embedding.js +289 -0
- package/dist/capabilities/dist/font/font-family.js +10 -0
- package/dist/capabilities/dist/font/font-import.js +302 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +25 -0
- package/dist/capabilities/dist/group/group-codegen.js +51 -0
- package/dist/capabilities/dist/group/group-declaration.js +42 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +319 -0
- package/dist/capabilities/dist/group/group-xml.js +7 -0
- package/dist/capabilities/dist/group/group.js +211 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +94 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +221 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +778 -0
- package/dist/capabilities/dist/image/image-schemas.js +149 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +472 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +527 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1033 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
- package/dist/capabilities/dist/motion/motion-query.js +420 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
- package/dist/capabilities/dist/motion/motion.js +1372 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +20 -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 +35 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +191 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +579 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +337 -0
- package/dist/capabilities/dist/shared/geometry.js +1423 -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 +113 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
- package/dist/capabilities/dist/shared/style-parse.js +11 -0
- package/dist/capabilities/dist/shared/text-schemas.js +216 -0
- package/dist/capabilities/dist/shared/text-service.js +1883 -0
- package/dist/capabilities/dist/shared/visual.js +918 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
- package/dist/capabilities/dist/table/table-codegen.js +81 -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 +539 -0
- package/dist/capabilities/dist/table/table-schemas.js +279 -0
- package/dist/capabilities/dist/table/table-xml.js +37 -0
- package/dist/capabilities/dist/table/table.js +662 -0
- package/dist/capabilities/dist/text/text-codegen.js +129 -0
- package/dist/capabilities/dist/text/text-declaration.js +19 -0
- package/dist/capabilities/dist/text/text-elements.js +38 -0
- package/dist/capabilities/dist/text/text-import.js +1077 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +335 -0
- package/dist/capabilities/dist/transition/transition-api.js +139 -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-D_xeNVIw.d.ts +29496 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +78 -0
- package/dist/codegen/dist/codegen.js +611 -0
- package/dist/codegen/dist/identifiers.js +193 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +49 -0
- package/dist/core/dist/author-ids.js +48 -0
- package/dist/core/dist/author-schemas.js +313 -0
- package/dist/core/dist/block-flex-layout.js +749 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +13 -0
- package/dist/core/dist/declaration.js +15 -0
- package/dist/core/dist/diagnostics.js +21 -0
- package/dist/core/dist/document-internals.js +13 -0
- package/dist/core/dist/document.js +408 -0
- package/dist/core/dist/geometry-schemas.js +249 -0
- package/dist/core/dist/grid-layout.js +445 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +45 -0
- package/dist/core/dist/layout-protocol.js +66 -0
- package/dist/core/dist/layout-schemas.js +208 -0
- package/dist/core/dist/layout.js +299 -0
- package/dist/core/dist/masters.js +169 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +213 -0
- package/dist/core/dist/query.js +155 -0
- package/dist/core/dist/resolution.js +11 -0
- package/dist/core/dist/resolve.js +1827 -0
- package/dist/core/dist/stage-options.js +67 -0
- package/dist/core/dist/theme.js +931 -0
- package/dist/document-BHPUODPP.d.ts +27759 -0
- package/dist/emit/dist/emit.js +936 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +606 -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 +153 -0
- package/dist/import/dist/fonts.js +250 -0
- package/dist/import/dist/import.js +504 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1153 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +60 -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 +671 -0
- package/dist/import/dist/visual.js +761 -0
- package/dist/import/dist/xml-fragments.js +36 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-B5m3hqjC.d.ts +7 -0
- package/dist/index-CCy-Yo8G.d.ts +1208 -0
- package/dist/index-DpxcZ4Gs.d.ts +725 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +70 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +194 -0
- package/dist/pptxdk/src/cli-commands.js +913 -0
- package/dist/pptxdk/src/compose.js +44 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +240 -0
- package/dist/preview/dist/options.js +53 -0
- package/dist/preview-Cfw0QdMM.d.ts +86 -0
- package/dist/preview.d.ts +3 -0
- package/dist/preview.js +27 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +65 -0
- package/dist/react/dist/elements.js +59 -0
- package/dist/react/dist/index.js +68 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +145 -0
- package/dist/react.js +27 -0
- package/dist/transition-Cips9wma.d.ts +82 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +14 -0
- package/package.json +78 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "../../../codegen/dist/index.js";
|
|
2
|
+
import { defineObjectCodegen } from "../../../codegen/dist/types.js";
|
|
3
|
+
import { CommonNode } from "../../../core/dist/document.js";
|
|
4
|
+
// ../capabilities/dist/group/group-codegen.js
|
|
5
|
+
const objectMotionPropKeys = /* @__PURE__ */ new Set([
|
|
6
|
+
"enter",
|
|
7
|
+
"emphasis",
|
|
8
|
+
"motion"
|
|
9
|
+
]);
|
|
10
|
+
function collectGroupProps(node, ctx) {
|
|
11
|
+
const extra = ctx.emitObjectExtraProps(node.props);
|
|
12
|
+
const entries = [];
|
|
13
|
+
for (const [key, value] of Object.entries(node.props)) {
|
|
14
|
+
if (value === void 0) continue;
|
|
15
|
+
if (objectMotionPropKeys.has(key)) {
|
|
16
|
+
if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
|
|
17
|
+
else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
entries.push([key, value]);
|
|
21
|
+
}
|
|
22
|
+
return entries;
|
|
23
|
+
}
|
|
24
|
+
function emitGroupChildren(node, ctx) {
|
|
25
|
+
const children = [];
|
|
26
|
+
let childIndex = 0;
|
|
27
|
+
for (const child of node.children) if (child instanceof CommonNode) {
|
|
28
|
+
children.push(ctx.emitChildNode(child, childIndex));
|
|
29
|
+
childIndex += 1;
|
|
30
|
+
} else if ("text" in child && typeof child.text === "string" && child.text.trim() !== "") ctx.fail("invalid-document", "Group cannot directly contain text content");
|
|
31
|
+
return children;
|
|
32
|
+
}
|
|
33
|
+
function emitGroupVanilla(node, ctx) {
|
|
34
|
+
const callee = ctx.useImport("group");
|
|
35
|
+
const propsEntries = collectGroupProps(node, ctx);
|
|
36
|
+
const args = propsEntries.length === 0 ? [] : [ctx.formatProps(propsEntries)];
|
|
37
|
+
const children = emitGroupChildren(node, ctx);
|
|
38
|
+
return ctx.formatVanillaCall(callee, args, children);
|
|
39
|
+
}
|
|
40
|
+
function emitGroupReact(node, ctx) {
|
|
41
|
+
const tag = ctx.useImport("Group");
|
|
42
|
+
const propsEntries = collectGroupProps(node, ctx);
|
|
43
|
+
const children = emitGroupChildren(node, ctx);
|
|
44
|
+
return ctx.formatJsxElement(tag, propsEntries, children);
|
|
45
|
+
}
|
|
46
|
+
/** Source codegen contribution for native `group` container declarations. */
|
|
47
|
+
const groupCodegen = defineObjectCodegen({ declarations: { group: {
|
|
48
|
+
emitVanilla: emitGroupVanilla,
|
|
49
|
+
emitReact: emitGroupReact
|
|
50
|
+
} } });
|
|
51
|
+
export { groupCodegen };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../../core/dist/author-ids.js";
|
|
2
|
+
import { layoutStyleSchema } from "../../../core/dist/layout-schemas.js";
|
|
3
|
+
import { textStyleSchema, themeScopeSchema, visualStyleSchema } from "../../../core/dist/theme.js";
|
|
4
|
+
import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
|
|
5
|
+
import "../../../core/dist/capability.js";
|
|
6
|
+
import { CommonContainer } from "../../../core/dist/document.js";
|
|
7
|
+
import { motionPropsSchema } from "../motion/motion-schemas.js";
|
|
8
|
+
import { shapeCoordinateSchema, shapeSizeSchema } from "../shape/shape-declaration.js";
|
|
9
|
+
import { optionalNameSchema } from "../shared/identity.js";
|
|
10
|
+
import { morphKeySchema } from "../shared/morph-api.js";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
const groupStyleSchema = z.strictObject({
|
|
13
|
+
...layoutStyleSchema.unwrap().shape,
|
|
14
|
+
...textStyleSchema.unwrap().shape,
|
|
15
|
+
rotate: visualStyleSchema.unwrap().shape.rotate
|
|
16
|
+
}).readonly();
|
|
17
|
+
const motionPropsShape = motionPropsSchema.unwrap().shape;
|
|
18
|
+
const groupBoundsSchema = z.strictObject({
|
|
19
|
+
x: shapeCoordinateSchema,
|
|
20
|
+
y: shapeCoordinateSchema,
|
|
21
|
+
width: shapeSizeSchema,
|
|
22
|
+
height: shapeSizeSchema
|
|
23
|
+
}).readonly();
|
|
24
|
+
const groupDeclarationPropsObjectSchema = z.strictObject({
|
|
25
|
+
id: authorIdSchema.optional(),
|
|
26
|
+
name: optionalNameSchema.optional(),
|
|
27
|
+
morphKey: morphKeySchema.optional(),
|
|
28
|
+
link: linkTargetSchema.optional(),
|
|
29
|
+
bounds: groupBoundsSchema.optional(),
|
|
30
|
+
style: groupStyleSchema.optional(),
|
|
31
|
+
theme: themeScopeSchema.optional(),
|
|
32
|
+
enter: motionPropsShape.enter,
|
|
33
|
+
emphasis: motionPropsShape.emphasis,
|
|
34
|
+
motion: motionPropsShape.motion
|
|
35
|
+
});
|
|
36
|
+
const groupDeclarationPropsKeys = Object.keys(groupDeclarationPropsObjectSchema.shape);
|
|
37
|
+
const groupDeclarationPropsSchema = groupDeclarationPropsObjectSchema.readonly();
|
|
38
|
+
/** Creates the editable native group shared by the command factory and the Group JSX element. */
|
|
39
|
+
function createGroupNode(props) {
|
|
40
|
+
return new CommonContainer("group", "group", props);
|
|
41
|
+
}
|
|
42
|
+
export { createGroupNode, groupDeclarationPropsKeys, groupDeclarationPropsSchema, groupStyleSchema };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hostNodeCreator } from "../../../core/dist/host.js";
|
|
2
|
+
import { motionElement } from "../motion/motion-elements.js";
|
|
3
|
+
import { createGroupNode } from "./group-declaration.js";
|
|
4
|
+
// ../capabilities/dist/group/group-elements.js
|
|
5
|
+
/** Declares an editable group preserving native member structure within the React tree. */
|
|
6
|
+
function Group(props) {
|
|
7
|
+
return motionElement("group", {
|
|
8
|
+
...props,
|
|
9
|
+
[hostNodeCreator]: createGroupNode
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { Group };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { pxToEmu } from "../../../emit/dist/ooxml.js";
|
|
2
|
+
import { CommonNode } from "../../../core/dist/document.js";
|
|
3
|
+
import "../../../emit/dist/index.js";
|
|
4
|
+
import { A_NS, P_NS, emuToPx } from "../../../import/dist/namespaces.js";
|
|
5
|
+
import { extentEmuFragmentSchema, offsetEmuFragmentSchema, transformAttributesFragmentSchema } from "../../../import/dist/xml-fragments.js";
|
|
6
|
+
import { peekShapeTreeObjectIdentity } from "../../../import/dist/resources.js";
|
|
7
|
+
import "../../../import/dist/index.js";
|
|
8
|
+
import { imageImportHandler } from "../image/image-import.js";
|
|
9
|
+
import { readNonVisualCommonProperties, readShapeSp } from "../shape/shape-import.js";
|
|
10
|
+
import { attachDeferredSlideLink, consumeNonPlaceholderNvPr } from "../shared/identity.js";
|
|
11
|
+
import { textBoxImportHandler } from "../text/text-import.js";
|
|
12
|
+
import { createGroupNode } from "./group-declaration.js";
|
|
13
|
+
// ../capabilities/dist/group/group-import.js
|
|
14
|
+
function nodeBoundsEmu(node) {
|
|
15
|
+
const props = node.props;
|
|
16
|
+
if (props.bounds !== void 0) return {
|
|
17
|
+
x: pxToEmu(props.bounds.x),
|
|
18
|
+
y: pxToEmu(props.bounds.y),
|
|
19
|
+
width: pxToEmu(props.bounds.width),
|
|
20
|
+
height: pxToEmu(props.bounds.height)
|
|
21
|
+
};
|
|
22
|
+
if (typeof props.x === "number" && typeof props.y === "number" && typeof props.width === "number" && typeof props.height === "number") return {
|
|
23
|
+
x: pxToEmu(props.x),
|
|
24
|
+
y: pxToEmu(props.y),
|
|
25
|
+
width: pxToEmu(props.width),
|
|
26
|
+
height: pxToEmu(props.height)
|
|
27
|
+
};
|
|
28
|
+
if (node.type === "group") return memberUnionEmu(node.children.filter((child) => child instanceof CommonNode));
|
|
29
|
+
}
|
|
30
|
+
function memberUnionEmu(members) {
|
|
31
|
+
if (members.length === 0) return void 0;
|
|
32
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
33
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
34
|
+
let maxRight = Number.NEGATIVE_INFINITY;
|
|
35
|
+
let maxBottom = Number.NEGATIVE_INFINITY;
|
|
36
|
+
for (const member of members) {
|
|
37
|
+
const box = nodeBoundsEmu(member);
|
|
38
|
+
if (box === void 0) return void 0;
|
|
39
|
+
minX = Math.min(minX, box.x);
|
|
40
|
+
minY = Math.min(minY, box.y);
|
|
41
|
+
maxRight = Math.max(maxRight, box.x + box.width);
|
|
42
|
+
maxBottom = Math.max(maxBottom, box.y + box.height);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
x: minX,
|
|
46
|
+
y: minY,
|
|
47
|
+
width: maxRight - minX,
|
|
48
|
+
height: maxBottom - minY
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const identityMapper = (box) => box;
|
|
52
|
+
function applyMemberMapper(node, memberMapper) {
|
|
53
|
+
const props = node.props;
|
|
54
|
+
if (typeof props.x === "number" && typeof props.y === "number" && typeof props.width === "number" && typeof props.height === "number") node.set(memberMapper({
|
|
55
|
+
x: props.x,
|
|
56
|
+
y: props.y,
|
|
57
|
+
width: props.width,
|
|
58
|
+
height: props.height
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Reads a Transitional `<p:grpSp>` recursively into an editable `GroupNode`,
|
|
63
|
+
* applying affine `(chOff, chExt) -> (off, ext)` coordinate mapping for external groups.
|
|
64
|
+
*/
|
|
65
|
+
function readGroupSp(context, parentMapper = identityMapper) {
|
|
66
|
+
const { cursor, part, slideIndex } = context;
|
|
67
|
+
const diagnostics = [];
|
|
68
|
+
const nvGrpSpPr = cursor.child(P_NS, "nvGrpSpPr");
|
|
69
|
+
if (nvGrpSpPr === void 0) {
|
|
70
|
+
diagnostics.push({
|
|
71
|
+
code: "corrupt-part",
|
|
72
|
+
category: "corrupt-input",
|
|
73
|
+
disposition: "omitted",
|
|
74
|
+
location: {
|
|
75
|
+
part,
|
|
76
|
+
xpath: cursor.xpath,
|
|
77
|
+
slideIndex
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return { diagnostics };
|
|
81
|
+
}
|
|
82
|
+
const cNvPr = nvGrpSpPr.child(P_NS, "cNvPr");
|
|
83
|
+
const { objectId, objectName, link, deferredSlideLink } = readNonVisualCommonProperties(cNvPr, context, diagnostics);
|
|
84
|
+
nvGrpSpPr.ignoreEmptyChild(P_NS, "cNvGrpSpPr");
|
|
85
|
+
consumeNonPlaceholderNvPr(nvGrpSpPr);
|
|
86
|
+
const location = {
|
|
87
|
+
part,
|
|
88
|
+
slideIndex,
|
|
89
|
+
...objectId === void 0 ? {} : { objectId },
|
|
90
|
+
...objectName === void 0 ? {} : { objectName }
|
|
91
|
+
};
|
|
92
|
+
const grpSpPr = cursor.child(P_NS, "grpSpPr");
|
|
93
|
+
if (grpSpPr === void 0) {
|
|
94
|
+
diagnostics.push({
|
|
95
|
+
code: "corrupt-part",
|
|
96
|
+
category: "corrupt-input",
|
|
97
|
+
disposition: "omitted",
|
|
98
|
+
location: {
|
|
99
|
+
...location,
|
|
100
|
+
xpath: cursor.xpath
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return { diagnostics };
|
|
104
|
+
}
|
|
105
|
+
const xfrm = grpSpPr.child(A_NS, "xfrm");
|
|
106
|
+
const off = xfrm?.child(A_NS, "off");
|
|
107
|
+
const ext = xfrm?.child(A_NS, "ext");
|
|
108
|
+
const chOff = xfrm?.child(A_NS, "chOff");
|
|
109
|
+
const chExt = xfrm?.child(A_NS, "chExt");
|
|
110
|
+
if (xfrm === void 0 || off === void 0 || ext === void 0 || chOff === void 0 || chExt === void 0) {
|
|
111
|
+
diagnostics.push({
|
|
112
|
+
code: "corrupt-part",
|
|
113
|
+
category: "corrupt-input",
|
|
114
|
+
disposition: "omitted",
|
|
115
|
+
location: {
|
|
116
|
+
...location,
|
|
117
|
+
xpath: grpSpPr.xpath
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return { diagnostics };
|
|
121
|
+
}
|
|
122
|
+
const parsedXfrm = transformAttributesFragmentSchema.safeParse(xfrm.attrsObject([
|
|
123
|
+
"rot",
|
|
124
|
+
"flipH",
|
|
125
|
+
"flipV"
|
|
126
|
+
]));
|
|
127
|
+
const parsedOff = offsetEmuFragmentSchema.safeParse(off.attrsObject(["x", "y"]));
|
|
128
|
+
const parsedExt = extentEmuFragmentSchema.safeParse(ext.attrsObject(["cx", "cy"]));
|
|
129
|
+
const parsedChOff = offsetEmuFragmentSchema.safeParse(chOff.attrsObject(["x", "y"]));
|
|
130
|
+
const parsedChExt = extentEmuFragmentSchema.safeParse(chExt.attrsObject(["cx", "cy"]));
|
|
131
|
+
if (!parsedOff.success || !parsedExt.success || !parsedChOff.success || !parsedChExt.success) {
|
|
132
|
+
diagnostics.push({
|
|
133
|
+
code: "invalid-xml-value",
|
|
134
|
+
category: "corrupt-input",
|
|
135
|
+
disposition: "omitted",
|
|
136
|
+
location: {
|
|
137
|
+
...location,
|
|
138
|
+
xpath: xfrm.xpath
|
|
139
|
+
},
|
|
140
|
+
attributeOrElement: "a:xfrm"
|
|
141
|
+
});
|
|
142
|
+
return { diagnostics };
|
|
143
|
+
}
|
|
144
|
+
if (parsedXfrm.success) {
|
|
145
|
+
if (parsedXfrm.data.flipH === true) diagnostics.push({
|
|
146
|
+
code: "unsupported-mechanism",
|
|
147
|
+
category: "unsupported",
|
|
148
|
+
disposition: "omitted",
|
|
149
|
+
location: {
|
|
150
|
+
...location,
|
|
151
|
+
xpath: `${xfrm.xpath}/@flipH`
|
|
152
|
+
},
|
|
153
|
+
namespaceUri: A_NS,
|
|
154
|
+
localName: "flipH",
|
|
155
|
+
mechanismHint: "group-flipH"
|
|
156
|
+
});
|
|
157
|
+
if (parsedXfrm.data.flipV === true) diagnostics.push({
|
|
158
|
+
code: "unsupported-mechanism",
|
|
159
|
+
category: "unsupported",
|
|
160
|
+
disposition: "omitted",
|
|
161
|
+
location: {
|
|
162
|
+
...location,
|
|
163
|
+
xpath: `${xfrm.xpath}/@flipV`
|
|
164
|
+
},
|
|
165
|
+
namespaceUri: A_NS,
|
|
166
|
+
localName: "flipV",
|
|
167
|
+
mechanismHint: "group-flipV"
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const rotate = parsedXfrm.success && parsedXfrm.data.rot !== void 0 && parsedXfrm.data.rot !== 0 ? parsedXfrm.data.rot / 6e4 : void 0;
|
|
171
|
+
const offX = emuToPx(parsedOff.data.x);
|
|
172
|
+
const offY = emuToPx(parsedOff.data.y);
|
|
173
|
+
const extW = emuToPx(parsedExt.data.cx);
|
|
174
|
+
const extH = emuToPx(parsedExt.data.cy);
|
|
175
|
+
const chX = emuToPx(parsedChOff.data.x);
|
|
176
|
+
const chY = emuToPx(parsedChOff.data.y);
|
|
177
|
+
const chW = emuToPx(parsedChExt.data.cx);
|
|
178
|
+
const chH = emuToPx(parsedChExt.data.cy);
|
|
179
|
+
const scaleX = chW > 0 ? extW / chW : 1;
|
|
180
|
+
const scaleY = chH > 0 ? extH / chH : 1;
|
|
181
|
+
grpSpPr.ignoreEmptyChild(A_NS, "noFill");
|
|
182
|
+
grpSpPr.ignoreEmptyChild(A_NS, "effectLst");
|
|
183
|
+
for (const extraChild of grpSpPr.remainingElementChildren()) diagnostics.push({
|
|
184
|
+
code: "unsupported-mechanism",
|
|
185
|
+
category: "unsupported",
|
|
186
|
+
disposition: "omitted",
|
|
187
|
+
location: {
|
|
188
|
+
...location,
|
|
189
|
+
xpath: extraChild.xpath
|
|
190
|
+
},
|
|
191
|
+
namespaceUri: extraChild.namespaceUri,
|
|
192
|
+
localName: extraChild.localName,
|
|
193
|
+
mechanismHint: `group:${extraChild.localName}`
|
|
194
|
+
});
|
|
195
|
+
const memberMapper = (box) => parentMapper({
|
|
196
|
+
x: offX + (box.x - chX) * scaleX,
|
|
197
|
+
y: offY + (box.y - chY) * scaleY,
|
|
198
|
+
width: box.width * scaleX,
|
|
199
|
+
height: box.height * scaleY
|
|
200
|
+
});
|
|
201
|
+
const members = [];
|
|
202
|
+
for (const childCursor of cursor.remainingElementChildren()) {
|
|
203
|
+
if (childCursor.namespaceUri !== "http://schemas.openxmlformats.org/presentationml/2006/main") {
|
|
204
|
+
diagnostics.push({
|
|
205
|
+
code: "unsupported-mechanism",
|
|
206
|
+
category: "unsupported",
|
|
207
|
+
disposition: "omitted",
|
|
208
|
+
location: {
|
|
209
|
+
...location,
|
|
210
|
+
xpath: childCursor.xpath
|
|
211
|
+
},
|
|
212
|
+
namespaceUri: childCursor.namespaceUri,
|
|
213
|
+
localName: childCursor.localName
|
|
214
|
+
});
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const childContext = {
|
|
218
|
+
...context,
|
|
219
|
+
cursor: childCursor
|
|
220
|
+
};
|
|
221
|
+
if (childCursor.localName === "grpSp") {
|
|
222
|
+
const outcome = readGroupSp(childContext, memberMapper);
|
|
223
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
224
|
+
if (outcome.node !== void 0) {
|
|
225
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
226
|
+
if (identity.objectId !== void 0) context.registerImportedObject?.(identity.objectId, outcome.node);
|
|
227
|
+
members.push(outcome.node);
|
|
228
|
+
}
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (childCursor.localName === "sp") {
|
|
232
|
+
if (textBoxImportHandler.matches?.(childCursor)) {
|
|
233
|
+
const outcome = textBoxImportHandler.read(childContext);
|
|
234
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
235
|
+
if (outcome.node !== void 0) {
|
|
236
|
+
applyMemberMapper(outcome.node, memberMapper);
|
|
237
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
238
|
+
if (identity.objectId !== void 0) context.registerImportedObject?.(identity.objectId, outcome.node);
|
|
239
|
+
members.push(outcome.node);
|
|
240
|
+
}
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const outcome = readShapeSp(childContext, memberMapper);
|
|
244
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
245
|
+
if (outcome.node !== void 0) {
|
|
246
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
247
|
+
if (identity.objectId !== void 0) context.registerImportedObject?.(identity.objectId, outcome.node);
|
|
248
|
+
members.push(outcome.node);
|
|
249
|
+
}
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
if (childCursor.localName === "pic") {
|
|
253
|
+
const outcome = imageImportHandler.read(childContext);
|
|
254
|
+
if (outcome.diagnostics !== void 0) diagnostics.push(...outcome.diagnostics);
|
|
255
|
+
if (outcome.node !== void 0) {
|
|
256
|
+
applyMemberMapper(outcome.node, memberMapper);
|
|
257
|
+
const identity = peekShapeTreeObjectIdentity(childCursor.element);
|
|
258
|
+
if (identity.objectId !== void 0) context.registerImportedObject?.(identity.objectId, outcome.node);
|
|
259
|
+
members.push(outcome.node);
|
|
260
|
+
}
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
diagnostics.push({
|
|
264
|
+
code: "unsupported-mechanism",
|
|
265
|
+
category: "unsupported",
|
|
266
|
+
disposition: "omitted",
|
|
267
|
+
location: {
|
|
268
|
+
...location,
|
|
269
|
+
xpath: childCursor.xpath
|
|
270
|
+
},
|
|
271
|
+
namespaceUri: childCursor.namespaceUri,
|
|
272
|
+
localName: childCursor.localName
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
if (members.length === 0) {
|
|
276
|
+
if (diagnostics.length === 0) diagnostics.push({
|
|
277
|
+
code: "corrupt-part",
|
|
278
|
+
category: "corrupt-input",
|
|
279
|
+
disposition: "omitted",
|
|
280
|
+
location: {
|
|
281
|
+
...location,
|
|
282
|
+
xpath: cursor.xpath
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
return { diagnostics };
|
|
286
|
+
}
|
|
287
|
+
const mappedGroupBox = parentMapper({
|
|
288
|
+
x: offX,
|
|
289
|
+
y: offY,
|
|
290
|
+
width: extW,
|
|
291
|
+
height: extH
|
|
292
|
+
});
|
|
293
|
+
const unionEmu = memberUnionEmu(members);
|
|
294
|
+
const preserveExplicitGroupBox = pxToEmu(mappedGroupBox.width) > 0 && pxToEmu(mappedGroupBox.height) > 0 && (unionEmu === void 0 || unionEmu.x !== pxToEmu(mappedGroupBox.x) || unionEmu.y !== pxToEmu(mappedGroupBox.y) || unionEmu.width !== pxToEmu(mappedGroupBox.width) || unionEmu.height !== pxToEmu(mappedGroupBox.height));
|
|
295
|
+
const props = {
|
|
296
|
+
...objectName === void 0 ? {} : { name: objectName },
|
|
297
|
+
...link === void 0 ? {} : { link },
|
|
298
|
+
...preserveExplicitGroupBox ? { bounds: {
|
|
299
|
+
x: mappedGroupBox.x,
|
|
300
|
+
y: mappedGroupBox.y,
|
|
301
|
+
width: mappedGroupBox.width,
|
|
302
|
+
height: mappedGroupBox.height
|
|
303
|
+
} } : {},
|
|
304
|
+
...rotate === void 0 ? {} : { style: { rotate } }
|
|
305
|
+
};
|
|
306
|
+
const node = createGroupNode(props);
|
|
307
|
+
node.append(...members);
|
|
308
|
+
attachDeferredSlideLink(node, deferredSlideLink, context);
|
|
309
|
+
return {
|
|
310
|
+
node,
|
|
311
|
+
diagnostics
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
const groupImportHandler = {
|
|
315
|
+
target: "shape-tree",
|
|
316
|
+
localName: "grpSp",
|
|
317
|
+
read: (context) => readGroupSp(context)
|
|
318
|
+
};
|
|
319
|
+
export { groupImportHandler, readGroupSp };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ../capabilities/dist/group/group-xml.js
|
|
2
|
+
/** Internal PresentationML wrapper for native groups; member baselines stay in slide coordinates. */
|
|
3
|
+
function groupXml(id, escapedName, box, members, rotation, linkXml) {
|
|
4
|
+
const angle = rotation === void 0 ? void 0 : Math.round((rotation % 360 + 360) % 360 * 6e4);
|
|
5
|
+
return `<p:grpSp><p:nvGrpSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm${angle === void 0 || angle === 0 ? "" : ` rot="${angle}"`}><a:off x="${box.x}" y="${box.y}"/><a:ext cx="${box.width}" cy="${box.height}"/><a:chOff x="${box.x}" y="${box.y}"/><a:chExt cx="${box.width}" cy="${box.height}"/></a:xfrm></p:grpSpPr>${members}</p:grpSp>`;
|
|
6
|
+
}
|
|
7
|
+
export { groupXml };
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import { textStyleFrom } from "../../../core/dist/theme.js";
|
|
3
|
+
import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
|
|
4
|
+
import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
|
|
5
|
+
import "../../../core/dist/capability.js";
|
|
6
|
+
import { pxToEmu, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
7
|
+
import "../../../emit/dist/index.js";
|
|
8
|
+
import "../../../import/dist/index.js";
|
|
9
|
+
import { defineCanvasMechanism } from "../../../import/dist/mechanism.js";
|
|
10
|
+
import { motionContainerAnnotations, validateMotionFlag } from "../motion/motion-api.js";
|
|
11
|
+
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
|
|
12
|
+
import { groupCodegen } from "./group-codegen.js";
|
|
13
|
+
import { groupDeclarationPropsKeys, groupDeclarationPropsSchema, groupStyleSchema } from "./group-declaration.js";
|
|
14
|
+
import { groupImportHandler } from "./group-import.js";
|
|
15
|
+
import { groupXml } from "./group-xml.js";
|
|
16
|
+
// ../capabilities/dist/group/group.js
|
|
17
|
+
const allowedParameters = groupDeclarationPropsKeys;
|
|
18
|
+
const emuPerPixel = 9525;
|
|
19
|
+
const maximumGroupExtentEmu = 2147483647;
|
|
20
|
+
function motionMembers(objects) {
|
|
21
|
+
return objects.map((object) => ({
|
|
22
|
+
id: object.id,
|
|
23
|
+
kind: object.kind,
|
|
24
|
+
name: object.name,
|
|
25
|
+
...object.authorId === void 0 ? {} : { authorId: object.authorId },
|
|
26
|
+
...object.box === void 0 ? {} : { box: object.box },
|
|
27
|
+
...object.members === void 0 ? {} : { members: motionMembers(object.members) }
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function bounds(members) {
|
|
31
|
+
if (members.length === 0) throw new CapabilityError("empty-group", "Group requires at least one native object member");
|
|
32
|
+
const memberBoxes = members.map((member) => {
|
|
33
|
+
const box = member.box;
|
|
34
|
+
if (box === void 0 || !Number.isFinite(box.x) || !Number.isFinite(box.y) || !Number.isFinite(box.width) || !Number.isFinite(box.height) || box.width <= 0 || box.height <= 0) throw new CapabilityError("member-without-geometry", `Group member ${member.name} is missing composable geometry bounds`);
|
|
35
|
+
const x = pxToEmu(box.x);
|
|
36
|
+
const y = pxToEmu(box.y);
|
|
37
|
+
return {
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
right: x + pxToEmu(box.width),
|
|
41
|
+
bottom: y + pxToEmu(box.height)
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const x = Math.min(...memberBoxes.map((box) => box.x));
|
|
45
|
+
const y = Math.min(...memberBoxes.map((box) => box.y));
|
|
46
|
+
const right = Math.max(...memberBoxes.map((box) => box.right));
|
|
47
|
+
const bottom = Math.max(...memberBoxes.map((box) => box.bottom));
|
|
48
|
+
const width = right - x;
|
|
49
|
+
const height = bottom - y;
|
|
50
|
+
if (width < 1 || height < 1 || width > maximumGroupExtentEmu || height > maximumGroupExtentEmu) throw new CapabilityError("invalid-group-geometry", "Group member bounds exceed writable PresentationML dimensions");
|
|
51
|
+
return {
|
|
52
|
+
emu: {
|
|
53
|
+
x,
|
|
54
|
+
y,
|
|
55
|
+
width,
|
|
56
|
+
height
|
|
57
|
+
},
|
|
58
|
+
pixels: {
|
|
59
|
+
x: x / emuPerPixel,
|
|
60
|
+
y: y / emuPerPixel,
|
|
61
|
+
width: width / emuPerPixel,
|
|
62
|
+
height: height / emuPerPixel
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const groupAllowedStyleKeys = new Set(Object.keys(groupStyleSchema.unwrap().shape));
|
|
67
|
+
function roundSvgNumber(value) {
|
|
68
|
+
const rounded = Math.round(value * 1e6) / 1e6;
|
|
69
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
70
|
+
}
|
|
71
|
+
function emitGroupModel(model, emitContext) {
|
|
72
|
+
return { xml: groupXml(emitContext.id, model.escapedName, model.emu, emitContext.childrenXml, model.rotation, nativeLinkXml(emitContext.nativeLink)) };
|
|
73
|
+
}
|
|
74
|
+
function paintGroupModel(model, paintContext) {
|
|
75
|
+
const childrenSvg = paintContext.childrenSvg ?? "";
|
|
76
|
+
const cx = roundSvgNumber(model.box.x + model.box.width / 2);
|
|
77
|
+
const cy = roundSvgNumber(model.box.y + model.box.height / 2);
|
|
78
|
+
return { svg: `<g transform="rotate(${roundSvgNumber(model.angle)} ${cx} ${cy})">${childrenSvg}</g>` };
|
|
79
|
+
}
|
|
80
|
+
/** Native canvas mechanism for PresentationML `<p:grpSp>` native groups. */
|
|
81
|
+
const groupMechanism = defineCanvasMechanism({
|
|
82
|
+
key: "group",
|
|
83
|
+
role: "canvas",
|
|
84
|
+
emit: emitGroupModel,
|
|
85
|
+
paint: paintGroupModel,
|
|
86
|
+
import: groupImportHandler
|
|
87
|
+
});
|
|
88
|
+
/** Preserves members as native objects and writes group bounds according to final member geometry; layout participation uses generic container collaboration. */
|
|
89
|
+
const groupCapability = {
|
|
90
|
+
declaration: "group",
|
|
91
|
+
codegen: groupCodegen,
|
|
92
|
+
mechanisms: [groupMechanism],
|
|
93
|
+
bind(input, context) {
|
|
94
|
+
const unknown = Object.keys(input.props).find((key) => !allowedParameters.includes(key));
|
|
95
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Group contains unsupported parameter ${unknown}`);
|
|
96
|
+
validateMotionFlag(input.props["motion"]);
|
|
97
|
+
const requestedName = parseOptionalName(input.props["name"]);
|
|
98
|
+
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
99
|
+
const link = parseLinkTarget(input.props["link"]);
|
|
100
|
+
const contract = parseCapabilityLayoutContract({
|
|
101
|
+
nativeKind: "grpSp",
|
|
102
|
+
props: input.props,
|
|
103
|
+
allowedStyleKeys: groupAllowedStyleKeys,
|
|
104
|
+
allowPadding: true,
|
|
105
|
+
isContainer: true,
|
|
106
|
+
path: context.path
|
|
107
|
+
});
|
|
108
|
+
const rawStyle = input.props["style"];
|
|
109
|
+
const styleRecord = typeof rawStyle === "object" && rawStyle !== null && !Array.isArray(rawStyle) ? rawStyle : {};
|
|
110
|
+
const rawRotation = styleRecord["rotate"];
|
|
111
|
+
if (rawRotation !== void 0 && !groupStyleSchema.unwrap().shape.rotate.safeParse(rawRotation).success) throw new CapabilityError("invalid-visual-style", "rotate must be a finite angle");
|
|
112
|
+
const rotation = rawRotation;
|
|
113
|
+
let explicitBox;
|
|
114
|
+
if (input.props["bounds"] !== void 0) {
|
|
115
|
+
const parsedBounds = groupDeclarationPropsSchema.unwrap().shape.bounds.safeParse(input.props["bounds"]);
|
|
116
|
+
if (!parsedBounds.success) throw new CapabilityError("invalid-group-geometry", parsedBounds.error.issues[0]?.message ?? "Invalid Group bounds");
|
|
117
|
+
explicitBox = parsedBounds.data;
|
|
118
|
+
}
|
|
119
|
+
const theme = context.theme.with(input.props["theme"], textStyleFrom(styleRecord));
|
|
120
|
+
const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
|
|
121
|
+
const motionProps = {
|
|
122
|
+
...input.props["enter"] !== void 0 ? { enter: input.props["enter"] } : {},
|
|
123
|
+
...input.props["emphasis"] !== void 0 ? { emphasis: input.props["emphasis"] } : {},
|
|
124
|
+
...input.props["motion"] !== void 0 ? { motion: input.props["motion"] } : {}
|
|
125
|
+
};
|
|
126
|
+
const container = {
|
|
127
|
+
children: input.children,
|
|
128
|
+
theme,
|
|
129
|
+
emitsObject: true,
|
|
130
|
+
layoutMode: "when-styled",
|
|
131
|
+
childComposition: "members",
|
|
132
|
+
restrictsMemberContinuity: true,
|
|
133
|
+
observesLayout: false,
|
|
134
|
+
propagatesBaseline: false,
|
|
135
|
+
checksCanvasOverflow: false
|
|
136
|
+
};
|
|
137
|
+
const native = {
|
|
138
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
139
|
+
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
140
|
+
...link === void 0 ? {} : { link }
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
contract,
|
|
144
|
+
container,
|
|
145
|
+
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
146
|
+
resolve(resolveContext) {
|
|
147
|
+
const resolvedChildren = resolveContext.resolveChildren(input.children);
|
|
148
|
+
const geometry = bounds(resolvedChildren.objects);
|
|
149
|
+
const outputGeometry = resolveContext.layoutBox ?? explicitBox ?? geometry.pixels;
|
|
150
|
+
if (outputGeometry.width <= 0 || outputGeometry.height <= 0) throw new CapabilityError("invalid-group-geometry", "Group layout width and height must be greater than 0");
|
|
151
|
+
const outputEmu = {
|
|
152
|
+
x: pxToEmu(outputGeometry.x),
|
|
153
|
+
y: pxToEmu(outputGeometry.y),
|
|
154
|
+
width: pxToEmu(outputGeometry.width),
|
|
155
|
+
height: pxToEmu(outputGeometry.height)
|
|
156
|
+
};
|
|
157
|
+
const name = resolveContext.morphName ?? requestedName ?? `Group ${resolveContext.id - 1}`;
|
|
158
|
+
let escapedName;
|
|
159
|
+
try {
|
|
160
|
+
escapedName = xmlEscape(name);
|
|
161
|
+
} catch {
|
|
162
|
+
throw new CapabilityError("invalid-xml-character", "Group.name contains characters not allowed in XML 1.0");
|
|
163
|
+
}
|
|
164
|
+
const members = motionMembers(resolvedChildren.objects);
|
|
165
|
+
const annotations = motionContainerAnnotations(motionProps, {
|
|
166
|
+
kind: "group",
|
|
167
|
+
name,
|
|
168
|
+
...authorId === void 0 ? {} : { authorId },
|
|
169
|
+
textBody: false,
|
|
170
|
+
filled: false,
|
|
171
|
+
box: outputGeometry,
|
|
172
|
+
rotationDegrees: rotation ?? 0,
|
|
173
|
+
members
|
|
174
|
+
});
|
|
175
|
+
const angle = rotation ?? 0;
|
|
176
|
+
const resolvedModel = {
|
|
177
|
+
escapedName,
|
|
178
|
+
box: outputGeometry,
|
|
179
|
+
emu: outputEmu,
|
|
180
|
+
angle,
|
|
181
|
+
...rotation === void 0 ? {} : { rotation }
|
|
182
|
+
};
|
|
183
|
+
const transform = {
|
|
184
|
+
box: outputGeometry,
|
|
185
|
+
angle,
|
|
186
|
+
flipH: false,
|
|
187
|
+
flipV: false
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
observation: {
|
|
191
|
+
id: resolveContext.id,
|
|
192
|
+
kind: "group",
|
|
193
|
+
name,
|
|
194
|
+
box: outputGeometry,
|
|
195
|
+
members: resolvedChildren.objects
|
|
196
|
+
},
|
|
197
|
+
transform,
|
|
198
|
+
extensions: [],
|
|
199
|
+
...annotations.length === 0 ? {} : { annotations },
|
|
200
|
+
emit(emitContext) {
|
|
201
|
+
return groupMechanism.emit(resolvedModel, emitContext);
|
|
202
|
+
},
|
|
203
|
+
paint(paintContext) {
|
|
204
|
+
return groupMechanism.paint(resolvedModel, paintContext);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
export { groupCapability, groupMechanism };
|