pptx-viewer-core 1.2.3 → 1.2.4
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/CHANGELOG.md +6 -0
- package/dist/cli/index.js +0 -0
- package/dist/cli/index.mjs +0 -0
- package/dist/index.js +212 -15
- package/dist/index.mjs +212 -15
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to this project are documented here.
|
|
|
4
4
|
This file is generated from [Conventional Commits](https://www.conventionalcommits.org)
|
|
5
5
|
by [git-cliff](https://git-cliff.org); do not edit it by hand.
|
|
6
6
|
|
|
7
|
+
## [1.2.3](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-viewer-core@1.2.3) - 2026-07-08
|
|
8
|
+
|
|
9
|
+
### Documentation
|
|
10
|
+
|
|
11
|
+
- **core:** Remove explicit jszip/fast-xml-parser mention from install section (by @ChristopherVR) ([6b72906](https://github.com/ChristopherVR/pptx-viewer/commit/6b72906c08447ba38a704ff4572c89d7cad7e60c))
|
|
12
|
+
|
|
7
13
|
## [1.2.2](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-viewer-core@1.2.2) - 2026-07-07
|
|
8
14
|
|
|
9
15
|
## [1.2.1](https://github.com/ChristopherVR/pptx-viewer/releases/tag/pptx-viewer-core@1.2.1) - 2026-07-06
|
package/dist/cli/index.js
CHANGED
|
Binary file
|
package/dist/cli/index.mjs
CHANGED
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -16907,6 +16907,7 @@ function getDefaultShapeType(layoutType) {
|
|
|
16907
16907
|
case "cycle":
|
|
16908
16908
|
case "target":
|
|
16909
16909
|
case "gear":
|
|
16910
|
+
return "ellipse";
|
|
16910
16911
|
case "relationship":
|
|
16911
16912
|
case "venn":
|
|
16912
16913
|
return "ellipse";
|
|
@@ -16914,7 +16915,10 @@ function getDefaultShapeType(layoutType) {
|
|
|
16914
16915
|
return "chevron";
|
|
16915
16916
|
case "pyramid":
|
|
16916
16917
|
case "funnel":
|
|
16917
|
-
return "
|
|
16918
|
+
return "trapezoid";
|
|
16919
|
+
case "timeline":
|
|
16920
|
+
case "bending":
|
|
16921
|
+
return "roundRect";
|
|
16918
16922
|
default:
|
|
16919
16923
|
return "roundRect";
|
|
16920
16924
|
}
|
|
@@ -17004,7 +17008,7 @@ function layoutCycle(nodes, bounds, themeColorMap) {
|
|
|
17004
17008
|
const ny = cy + radius * Math.sin(angle) - nodeH / 2;
|
|
17005
17009
|
const fill = accentColor(i, themeColorMap);
|
|
17006
17010
|
elements.push(
|
|
17007
|
-
makeShapeElement(nextId("sa-cycle"), nx, ny, nodeW, nodeH, "
|
|
17011
|
+
makeShapeElement(nextId("sa-cycle"), nx, ny, nodeW, nodeH, "ellipse", fill, node.text, {
|
|
17008
17012
|
fontSize: Math.max(7, Math.min(10, nodeW * 0.1))
|
|
17009
17013
|
})
|
|
17010
17014
|
);
|
|
@@ -17071,7 +17075,7 @@ function layoutPyramid(nodes, bounds, themeColorMap) {
|
|
|
17071
17075
|
const x = bounds.x + (bounds.width - w) / 2;
|
|
17072
17076
|
const y = bounds.y + padding + i * (bandH + gap);
|
|
17073
17077
|
const fill = accentColor(i, themeColorMap);
|
|
17074
|
-
return makeShapeElement(nextId("sa-pyramid"), x, y, w, bandH, "
|
|
17078
|
+
return makeShapeElement(nextId("sa-pyramid"), x, y, w, bandH, "trapezoid", fill, node.text, {
|
|
17075
17079
|
fontSize: Math.max(8, Math.min(11, bandH * 0.4))
|
|
17076
17080
|
});
|
|
17077
17081
|
});
|
|
@@ -17820,7 +17824,7 @@ function decomposeSmartArt(smartArtData, containerBounds, themeColorMap, layoutD
|
|
|
17820
17824
|
themeColorMap,
|
|
17821
17825
|
smartArtData.colorTransform?.fillColors
|
|
17822
17826
|
);
|
|
17823
|
-
const layoutType =
|
|
17827
|
+
const layoutType = resolveEffectiveLayoutType(smartArtData);
|
|
17824
17828
|
const namedLayout = smartArtData.layout;
|
|
17825
17829
|
if (namedLayout) {
|
|
17826
17830
|
const namedResult = dispatchNamedLayout(namedLayout, nodes, containerBounds, effectiveThemeMap);
|
|
@@ -17851,6 +17855,52 @@ function dispatchLayoutByType(layoutType, nodes, containerBounds, effectiveTheme
|
|
|
17851
17855
|
return layoutWithHeuristic(nodes, containerBounds, effectiveThemeMap);
|
|
17852
17856
|
}
|
|
17853
17857
|
}
|
|
17858
|
+
var LAYOUT_PRESET_TO_TYPE = {
|
|
17859
|
+
basicBlockList: "list",
|
|
17860
|
+
alternatingHexagons: "list",
|
|
17861
|
+
horizontalBulletList: "list",
|
|
17862
|
+
stackedList: "list",
|
|
17863
|
+
tableList: "list",
|
|
17864
|
+
trapezoidList: "list",
|
|
17865
|
+
pictureAccentList: "list",
|
|
17866
|
+
verticalBlockList: "list",
|
|
17867
|
+
groupedList: "list",
|
|
17868
|
+
pyramidList: "list",
|
|
17869
|
+
horizontalPictureList: "list",
|
|
17870
|
+
basicMatrix: "matrix",
|
|
17871
|
+
basicPyramid: "pyramid",
|
|
17872
|
+
invertedPyramid: "pyramid",
|
|
17873
|
+
basicChevronProcess: "chevron",
|
|
17874
|
+
continuousBlockProcess: "process",
|
|
17875
|
+
segmentedProcess: "process",
|
|
17876
|
+
upwardArrow: "process",
|
|
17877
|
+
basicTimeline: "timeline",
|
|
17878
|
+
bendingProcess: "bending",
|
|
17879
|
+
stepDownProcess: "process",
|
|
17880
|
+
alternatingFlow: "process",
|
|
17881
|
+
descendingProcess: "process",
|
|
17882
|
+
accentProcess: "process",
|
|
17883
|
+
verticalChevronList: "chevron",
|
|
17884
|
+
basicFunnel: "funnel",
|
|
17885
|
+
basicCycle: "cycle",
|
|
17886
|
+
basicPie: "cycle",
|
|
17887
|
+
basicRadial: "cycle",
|
|
17888
|
+
basicVenn: "relationship",
|
|
17889
|
+
convergingRadial: "cycle",
|
|
17890
|
+
linearVenn: "relationship",
|
|
17891
|
+
basicTarget: "target",
|
|
17892
|
+
interlockingGears: "gear",
|
|
17893
|
+
hierarchy: "hierarchy"
|
|
17894
|
+
};
|
|
17895
|
+
function resolveEffectiveLayoutType(data) {
|
|
17896
|
+
if (data.resolvedLayoutType && data.resolvedLayoutType !== "unknown") {
|
|
17897
|
+
return data.resolvedLayoutType;
|
|
17898
|
+
}
|
|
17899
|
+
if (data.layout && LAYOUT_PRESET_TO_TYPE[data.layout]) {
|
|
17900
|
+
return LAYOUT_PRESET_TO_TYPE[data.layout];
|
|
17901
|
+
}
|
|
17902
|
+
return resolveLayoutFromRawType(data.layoutType);
|
|
17903
|
+
}
|
|
17854
17904
|
function buildEffectiveThemeMap(themeColorMap, colorTransformFills) {
|
|
17855
17905
|
if (!colorTransformFills || colorTransformFills.length === 0) {
|
|
17856
17906
|
return themeColorMap;
|
|
@@ -36091,14 +36141,19 @@ function transPointXml(guid, type, cxnGuid) {
|
|
|
36091
36141
|
function docPointXml(docGuid, ids) {
|
|
36092
36142
|
return `<dgm:pt modelId="${docGuid}" type="doc"><dgm:prSet loTypeId="${xmlEscape(ids.layoutUniqueId)}" loCatId="${xmlEscape(ids.layoutCategory)}" qsTypeId="${xmlEscape(ids.quickStyleUniqueId)}" qsCatId="simple" csTypeId="${xmlEscape(ids.colorsUniqueId)}" csCatId="${xmlEscape(ids.colorsCategory)}"/><dgm:spPr/>${EMPTY_TEXT_BODY}</dgm:pt>`;
|
|
36093
36143
|
}
|
|
36094
|
-
function
|
|
36095
|
-
const docGuid = newSmartArtGuid();
|
|
36144
|
+
function buildNodeGuidMap(nodes) {
|
|
36096
36145
|
const guidByNodeId = /* @__PURE__ */ new Map();
|
|
36097
|
-
for (const node of
|
|
36146
|
+
for (const node of nodes) {
|
|
36098
36147
|
if (node.id && !guidByNodeId.has(node.id)) {
|
|
36099
36148
|
guidByNodeId.set(node.id, GUID_MODEL_ID.test(node.id) ? node.id : newSmartArtGuid());
|
|
36100
36149
|
}
|
|
36101
36150
|
}
|
|
36151
|
+
return guidByNodeId;
|
|
36152
|
+
}
|
|
36153
|
+
var DSP_DATA_MODEL_EXT_URI = "http://schemas.microsoft.com/office/drawing/2008/diagram";
|
|
36154
|
+
function buildFabricatedDiagramDataXml(data, ids, options = {}) {
|
|
36155
|
+
const docGuid = newSmartArtGuid();
|
|
36156
|
+
const guidByNodeId = options.guidByNodeId ?? buildNodeGuidMap(data.nodes);
|
|
36102
36157
|
const points2 = [docPointXml(docGuid, ids)];
|
|
36103
36158
|
const connections = [];
|
|
36104
36159
|
const nextSrcOrd = /* @__PURE__ */ new Map();
|
|
@@ -36121,7 +36176,121 @@ function buildFabricatedDiagramDataXml(data, ids) {
|
|
|
36121
36176
|
);
|
|
36122
36177
|
}
|
|
36123
36178
|
return `${XML_PROLOG}\r
|
|
36124
|
-
<dgm:dataModel ${DGM_XMLNS}><dgm:ptLst>${points2.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole
|
|
36179
|
+
<dgm:dataModel ${DGM_XMLNS}><dgm:ptLst>${points2.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/>${dataModelExtXml(options.drawingRelId)}</dgm:dataModel>`;
|
|
36180
|
+
}
|
|
36181
|
+
function dataModelExtXml(drawingRelId) {
|
|
36182
|
+
if (!drawingRelId) {
|
|
36183
|
+
return "";
|
|
36184
|
+
}
|
|
36185
|
+
return `<dgm:extLst><a:ext uri="${DSP_DATA_MODEL_EXT_URI}"><dsp:dataModelExt xmlns:dsp="${DSP_DATA_MODEL_EXT_URI}" relId="${xmlEscape(drawingRelId)}" minVer="http://schemas.openxmlformats.org/drawingml/2006/diagram"/></a:ext></dgm:extLst>`;
|
|
36186
|
+
}
|
|
36187
|
+
|
|
36188
|
+
// src/core/core/runtime/smartart-fabrication-drawing.ts
|
|
36189
|
+
var DIAGRAM_DRAWING_CONTENT_TYPE = "application/vnd.ms-office.drawingml.diagramDrawing+xml";
|
|
36190
|
+
var DIAGRAM_DRAWING_REL_TYPE = "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing";
|
|
36191
|
+
var DSP_XMLNS = 'xmlns:dsp="http://schemas.microsoft.com/office/drawing/2008/diagram" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"';
|
|
36192
|
+
var ACCENTS = ["accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
|
|
36193
|
+
function toEmu(px2) {
|
|
36194
|
+
return Math.round(px2 * EMU_PER_PX);
|
|
36195
|
+
}
|
|
36196
|
+
function normalizeHex3(color) {
|
|
36197
|
+
if (!color) {
|
|
36198
|
+
return void 0;
|
|
36199
|
+
}
|
|
36200
|
+
const hex8 = color.replace(/^#/u, "").trim();
|
|
36201
|
+
return /^[0-9A-Fa-f]{6}$/u.test(hex8) ? hex8.toUpperCase() : void 0;
|
|
36202
|
+
}
|
|
36203
|
+
function resolveShapeModelId(shape, index, nodes, guidByNodeId) {
|
|
36204
|
+
const direct = guidByNodeId.get(shape.id);
|
|
36205
|
+
if (direct) {
|
|
36206
|
+
return direct;
|
|
36207
|
+
}
|
|
36208
|
+
const matched = nodes.find(
|
|
36209
|
+
(node) => node.id && (shape.id === node.id || shape.id.endsWith(`-${node.id}`))
|
|
36210
|
+
);
|
|
36211
|
+
if (matched?.id) {
|
|
36212
|
+
const guid = guidByNodeId.get(matched.id);
|
|
36213
|
+
if (guid) {
|
|
36214
|
+
return guid;
|
|
36215
|
+
}
|
|
36216
|
+
}
|
|
36217
|
+
const positional = nodes[index]?.id;
|
|
36218
|
+
if (positional) {
|
|
36219
|
+
const guid = guidByNodeId.get(positional);
|
|
36220
|
+
if (guid) {
|
|
36221
|
+
return guid;
|
|
36222
|
+
}
|
|
36223
|
+
}
|
|
36224
|
+
return newSmartArtGuid();
|
|
36225
|
+
}
|
|
36226
|
+
function textBodyXml(shape) {
|
|
36227
|
+
const text = shape.text ?? "";
|
|
36228
|
+
const fontColor = normalizeHex3(shape.fontColor);
|
|
36229
|
+
const size = shape.fontSize && shape.fontSize > 0 ? ` sz="${Math.round(shape.fontSize * 100)}"` : "";
|
|
36230
|
+
const fill = fontColor ? `<a:solidFill><a:srgbClr val="${fontColor}"/></a:solidFill>` : "";
|
|
36231
|
+
const rPr = `<a:rPr lang="en-US"${size}>${fill}</a:rPr>`;
|
|
36232
|
+
const run = text ? `<a:r>${rPr}<a:t>${xmlEscape(text)}</a:t></a:r>` : `<a:endParaRPr lang="en-US"/>`;
|
|
36233
|
+
return `<dsp:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="ctr"/>${run}</a:p></dsp:txBody>`;
|
|
36234
|
+
}
|
|
36235
|
+
function styleXml(index) {
|
|
36236
|
+
const accent = ACCENTS[index % ACCENTS.length];
|
|
36237
|
+
return `<dsp:style><a:lnRef idx="2"><a:schemeClr val="${accent}"><a:shade val="50000"/></a:schemeClr></a:lnRef><a:fillRef idx="1"><a:schemeClr val="${accent}"/></a:fillRef><a:effectRef idx="0"><a:schemeClr val="${accent}"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef></dsp:style>`;
|
|
36238
|
+
}
|
|
36239
|
+
function shapePropsXml(shape) {
|
|
36240
|
+
const rot = shape.rotation ? ` rot="${Math.round(shape.rotation * 6e4)}"` : "";
|
|
36241
|
+
const xfrm = `<a:xfrm${rot}><a:off x="${toEmu(shape.x)}" y="${toEmu(shape.y)}"/><a:ext cx="${toEmu(Math.max(shape.width, 1))}" cy="${toEmu(Math.max(shape.height, 1))}"/></a:xfrm>`;
|
|
36242
|
+
const prst = shape.shapeType && shape.shapeType.length > 0 ? shape.shapeType : "rect";
|
|
36243
|
+
const geom = `<a:prstGeom prst="${xmlEscape(prst)}"><a:avLst/></a:prstGeom>`;
|
|
36244
|
+
const fillHex = normalizeHex3(shape.fillColor);
|
|
36245
|
+
const fill = fillHex ? `<a:solidFill><a:srgbClr val="${fillHex}"/></a:solidFill>` : "";
|
|
36246
|
+
const strokeHex = normalizeHex3(shape.strokeColor);
|
|
36247
|
+
const strokeW = shape.strokeWidth && shape.strokeWidth > 0 ? ` w="${Math.round(shape.strokeWidth * 12700)}"` : "";
|
|
36248
|
+
const ln = strokeHex ? `<a:ln${strokeW}><a:solidFill><a:srgbClr val="${strokeHex}"/></a:solidFill></a:ln>` : "";
|
|
36249
|
+
return `<dsp:spPr>${xfrm}${geom}${fill}${ln}</dsp:spPr>`;
|
|
36250
|
+
}
|
|
36251
|
+
function shapeXml(shape, index, nodes, guidByNodeId) {
|
|
36252
|
+
const modelId = resolveShapeModelId(shape, index, nodes, guidByNodeId);
|
|
36253
|
+
return `<dsp:sp modelId="${modelId}"><dsp:nvSpPr><dsp:cNvPr id="0" name=""/><dsp:cNvSpPr/></dsp:nvSpPr>${shapePropsXml(shape)}${styleXml(index)}${textBodyXml(shape)}</dsp:sp>`;
|
|
36254
|
+
}
|
|
36255
|
+
function buildFabricatedDrawingXml(shapes, nodes, guidByNodeId) {
|
|
36256
|
+
if (!shapes || shapes.length === 0) {
|
|
36257
|
+
return void 0;
|
|
36258
|
+
}
|
|
36259
|
+
const body = shapes.map((shape, index) => shapeXml(shape, index, nodes, guidByNodeId)).join("");
|
|
36260
|
+
return `${XML_PROLOG}\r
|
|
36261
|
+
<dsp:drawing ${DSP_XMLNS}><dsp:spTree><dsp:nvGrpSpPr><dsp:cNvPr id="0" name=""/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr><dsp:grpSpPr/>${body}</dsp:spTree></dsp:drawing>`;
|
|
36262
|
+
}
|
|
36263
|
+
function buildDiagramDataRelsXml(drawingRelId, drawingFileName) {
|
|
36264
|
+
return `${XML_PROLOG}\r
|
|
36265
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="${xmlEscape(drawingRelId)}" Type="${DIAGRAM_DRAWING_REL_TYPE}" Target="${xmlEscape(drawingFileName)}"/></Relationships>`;
|
|
36266
|
+
}
|
|
36267
|
+
function smartArtElementsToDrawingShapes(elements) {
|
|
36268
|
+
if (!elements || elements.length === 0) {
|
|
36269
|
+
return [];
|
|
36270
|
+
}
|
|
36271
|
+
const shapes = [];
|
|
36272
|
+
for (const el of elements) {
|
|
36273
|
+
if (el.type !== "shape") {
|
|
36274
|
+
continue;
|
|
36275
|
+
}
|
|
36276
|
+
const shape = el;
|
|
36277
|
+
shapes.push({
|
|
36278
|
+
id: shape.id,
|
|
36279
|
+
shapeType: shape.shapeType ?? "rect",
|
|
36280
|
+
x: shape.x,
|
|
36281
|
+
y: shape.y,
|
|
36282
|
+
width: shape.width,
|
|
36283
|
+
height: shape.height,
|
|
36284
|
+
rotation: shape.rotation,
|
|
36285
|
+
fillColor: shape.shapeStyle?.fillColor,
|
|
36286
|
+
strokeColor: shape.shapeStyle?.strokeColor,
|
|
36287
|
+
strokeWidth: shape.shapeStyle?.strokeWidth,
|
|
36288
|
+
text: shape.text,
|
|
36289
|
+
fontSize: shape.textStyle?.fontSize,
|
|
36290
|
+
fontColor: shape.textStyle?.color
|
|
36291
|
+
});
|
|
36292
|
+
}
|
|
36293
|
+
return shapes;
|
|
36125
36294
|
}
|
|
36126
36295
|
|
|
36127
36296
|
// src/core/core/runtime/smartart-fabrication-hierarchy.ts
|
|
@@ -36329,14 +36498,29 @@ var PptxHandlerRuntime32 = class _PptxHandlerRuntime extends PptxHandlerRuntime3
|
|
|
36329
36498
|
const data = el.smartArtData;
|
|
36330
36499
|
const family = resolveFabricatedLayoutFamily(data);
|
|
36331
36500
|
const index = this.nextDiagramPartIndex();
|
|
36501
|
+
const guidByNodeId = buildNodeGuidMap(data.nodes);
|
|
36502
|
+
const drawingShapes = data.drawingShapes && data.drawingShapes.length > 0 ? data.drawingShapes : smartArtElementsToDrawingShapes(
|
|
36503
|
+
decomposeSmartArt(data, {
|
|
36504
|
+
x: 0,
|
|
36505
|
+
y: 0,
|
|
36506
|
+
width: Math.max(el.width, 1),
|
|
36507
|
+
height: Math.max(el.height, 1)
|
|
36508
|
+
})
|
|
36509
|
+
);
|
|
36510
|
+
const drawingRelId = "rId1";
|
|
36511
|
+
const drawingXml = buildFabricatedDrawingXml(drawingShapes, data.nodes, guidByNodeId);
|
|
36332
36512
|
const payloads = {
|
|
36333
|
-
data: buildFabricatedDiagramDataXml(
|
|
36334
|
-
|
|
36335
|
-
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
|
|
36513
|
+
data: buildFabricatedDiagramDataXml(
|
|
36514
|
+
data,
|
|
36515
|
+
{
|
|
36516
|
+
layoutUniqueId: fabricatedLayoutUniqueId(family),
|
|
36517
|
+
layoutCategory: fabricatedLayoutCategory(family),
|
|
36518
|
+
quickStyleUniqueId: FABRICATED_QUICKSTYLE_UNIQUE_ID,
|
|
36519
|
+
colorsUniqueId: fabricatedColorsUniqueId(data.colorScheme),
|
|
36520
|
+
colorsCategory: fabricatedColorsCategory(data.colorScheme)
|
|
36521
|
+
},
|
|
36522
|
+
{ guidByNodeId, drawingRelId: drawingXml ? drawingRelId : void 0 }
|
|
36523
|
+
),
|
|
36340
36524
|
layout: buildFabricatedLayoutDefXml(family),
|
|
36341
36525
|
quickStyle: buildFabricatedQuickStyleXml(),
|
|
36342
36526
|
colors: buildFabricatedColorsXml(data.colorScheme)
|
|
@@ -36360,6 +36544,19 @@ var PptxHandlerRuntime32 = class _PptxHandlerRuntime extends PptxHandlerRuntime3
|
|
|
36360
36544
|
});
|
|
36361
36545
|
relIds[kind.relAttr] = relId;
|
|
36362
36546
|
}
|
|
36547
|
+
if (drawingXml) {
|
|
36548
|
+
const drawingFile = `drawing${index}.xml`;
|
|
36549
|
+
const drawingPath = `ppt/diagrams/${drawingFile}`;
|
|
36550
|
+
this.zip.file(drawingPath, drawingXml);
|
|
36551
|
+
(this.pendingDiagramContentTypes ??= []).push({
|
|
36552
|
+
partName: `/${drawingPath}`,
|
|
36553
|
+
contentType: DIAGRAM_DRAWING_CONTENT_TYPE
|
|
36554
|
+
});
|
|
36555
|
+
this.zip.file(
|
|
36556
|
+
`ppt/diagrams/_rels/data${index}.xml.rels`,
|
|
36557
|
+
buildDiagramDataRelsXml(drawingRelId, drawingFile)
|
|
36558
|
+
);
|
|
36559
|
+
}
|
|
36363
36560
|
const EMU = _PptxHandlerRuntime.EMU_PER_PX;
|
|
36364
36561
|
return {
|
|
36365
36562
|
"p:nvGraphicFramePr": {
|
package/dist/index.mjs
CHANGED
|
@@ -16902,6 +16902,7 @@ function getDefaultShapeType(layoutType) {
|
|
|
16902
16902
|
case "cycle":
|
|
16903
16903
|
case "target":
|
|
16904
16904
|
case "gear":
|
|
16905
|
+
return "ellipse";
|
|
16905
16906
|
case "relationship":
|
|
16906
16907
|
case "venn":
|
|
16907
16908
|
return "ellipse";
|
|
@@ -16909,7 +16910,10 @@ function getDefaultShapeType(layoutType) {
|
|
|
16909
16910
|
return "chevron";
|
|
16910
16911
|
case "pyramid":
|
|
16911
16912
|
case "funnel":
|
|
16912
|
-
return "
|
|
16913
|
+
return "trapezoid";
|
|
16914
|
+
case "timeline":
|
|
16915
|
+
case "bending":
|
|
16916
|
+
return "roundRect";
|
|
16913
16917
|
default:
|
|
16914
16918
|
return "roundRect";
|
|
16915
16919
|
}
|
|
@@ -16999,7 +17003,7 @@ function layoutCycle(nodes, bounds, themeColorMap) {
|
|
|
16999
17003
|
const ny = cy + radius * Math.sin(angle) - nodeH / 2;
|
|
17000
17004
|
const fill = accentColor(i, themeColorMap);
|
|
17001
17005
|
elements.push(
|
|
17002
|
-
makeShapeElement(nextId("sa-cycle"), nx, ny, nodeW, nodeH, "
|
|
17006
|
+
makeShapeElement(nextId("sa-cycle"), nx, ny, nodeW, nodeH, "ellipse", fill, node.text, {
|
|
17003
17007
|
fontSize: Math.max(7, Math.min(10, nodeW * 0.1))
|
|
17004
17008
|
})
|
|
17005
17009
|
);
|
|
@@ -17066,7 +17070,7 @@ function layoutPyramid(nodes, bounds, themeColorMap) {
|
|
|
17066
17070
|
const x = bounds.x + (bounds.width - w) / 2;
|
|
17067
17071
|
const y = bounds.y + padding + i * (bandH + gap);
|
|
17068
17072
|
const fill = accentColor(i, themeColorMap);
|
|
17069
|
-
return makeShapeElement(nextId("sa-pyramid"), x, y, w, bandH, "
|
|
17073
|
+
return makeShapeElement(nextId("sa-pyramid"), x, y, w, bandH, "trapezoid", fill, node.text, {
|
|
17070
17074
|
fontSize: Math.max(8, Math.min(11, bandH * 0.4))
|
|
17071
17075
|
});
|
|
17072
17076
|
});
|
|
@@ -17815,7 +17819,7 @@ function decomposeSmartArt(smartArtData, containerBounds, themeColorMap, layoutD
|
|
|
17815
17819
|
themeColorMap,
|
|
17816
17820
|
smartArtData.colorTransform?.fillColors
|
|
17817
17821
|
);
|
|
17818
|
-
const layoutType =
|
|
17822
|
+
const layoutType = resolveEffectiveLayoutType(smartArtData);
|
|
17819
17823
|
const namedLayout = smartArtData.layout;
|
|
17820
17824
|
if (namedLayout) {
|
|
17821
17825
|
const namedResult = dispatchNamedLayout(namedLayout, nodes, containerBounds, effectiveThemeMap);
|
|
@@ -17846,6 +17850,52 @@ function dispatchLayoutByType(layoutType, nodes, containerBounds, effectiveTheme
|
|
|
17846
17850
|
return layoutWithHeuristic(nodes, containerBounds, effectiveThemeMap);
|
|
17847
17851
|
}
|
|
17848
17852
|
}
|
|
17853
|
+
var LAYOUT_PRESET_TO_TYPE = {
|
|
17854
|
+
basicBlockList: "list",
|
|
17855
|
+
alternatingHexagons: "list",
|
|
17856
|
+
horizontalBulletList: "list",
|
|
17857
|
+
stackedList: "list",
|
|
17858
|
+
tableList: "list",
|
|
17859
|
+
trapezoidList: "list",
|
|
17860
|
+
pictureAccentList: "list",
|
|
17861
|
+
verticalBlockList: "list",
|
|
17862
|
+
groupedList: "list",
|
|
17863
|
+
pyramidList: "list",
|
|
17864
|
+
horizontalPictureList: "list",
|
|
17865
|
+
basicMatrix: "matrix",
|
|
17866
|
+
basicPyramid: "pyramid",
|
|
17867
|
+
invertedPyramid: "pyramid",
|
|
17868
|
+
basicChevronProcess: "chevron",
|
|
17869
|
+
continuousBlockProcess: "process",
|
|
17870
|
+
segmentedProcess: "process",
|
|
17871
|
+
upwardArrow: "process",
|
|
17872
|
+
basicTimeline: "timeline",
|
|
17873
|
+
bendingProcess: "bending",
|
|
17874
|
+
stepDownProcess: "process",
|
|
17875
|
+
alternatingFlow: "process",
|
|
17876
|
+
descendingProcess: "process",
|
|
17877
|
+
accentProcess: "process",
|
|
17878
|
+
verticalChevronList: "chevron",
|
|
17879
|
+
basicFunnel: "funnel",
|
|
17880
|
+
basicCycle: "cycle",
|
|
17881
|
+
basicPie: "cycle",
|
|
17882
|
+
basicRadial: "cycle",
|
|
17883
|
+
basicVenn: "relationship",
|
|
17884
|
+
convergingRadial: "cycle",
|
|
17885
|
+
linearVenn: "relationship",
|
|
17886
|
+
basicTarget: "target",
|
|
17887
|
+
interlockingGears: "gear",
|
|
17888
|
+
hierarchy: "hierarchy"
|
|
17889
|
+
};
|
|
17890
|
+
function resolveEffectiveLayoutType(data) {
|
|
17891
|
+
if (data.resolvedLayoutType && data.resolvedLayoutType !== "unknown") {
|
|
17892
|
+
return data.resolvedLayoutType;
|
|
17893
|
+
}
|
|
17894
|
+
if (data.layout && LAYOUT_PRESET_TO_TYPE[data.layout]) {
|
|
17895
|
+
return LAYOUT_PRESET_TO_TYPE[data.layout];
|
|
17896
|
+
}
|
|
17897
|
+
return resolveLayoutFromRawType(data.layoutType);
|
|
17898
|
+
}
|
|
17849
17899
|
function buildEffectiveThemeMap(themeColorMap, colorTransformFills) {
|
|
17850
17900
|
if (!colorTransformFills || colorTransformFills.length === 0) {
|
|
17851
17901
|
return themeColorMap;
|
|
@@ -36086,14 +36136,19 @@ function transPointXml(guid, type, cxnGuid) {
|
|
|
36086
36136
|
function docPointXml(docGuid, ids) {
|
|
36087
36137
|
return `<dgm:pt modelId="${docGuid}" type="doc"><dgm:prSet loTypeId="${xmlEscape(ids.layoutUniqueId)}" loCatId="${xmlEscape(ids.layoutCategory)}" qsTypeId="${xmlEscape(ids.quickStyleUniqueId)}" qsCatId="simple" csTypeId="${xmlEscape(ids.colorsUniqueId)}" csCatId="${xmlEscape(ids.colorsCategory)}"/><dgm:spPr/>${EMPTY_TEXT_BODY}</dgm:pt>`;
|
|
36088
36138
|
}
|
|
36089
|
-
function
|
|
36090
|
-
const docGuid = newSmartArtGuid();
|
|
36139
|
+
function buildNodeGuidMap(nodes) {
|
|
36091
36140
|
const guidByNodeId = /* @__PURE__ */ new Map();
|
|
36092
|
-
for (const node of
|
|
36141
|
+
for (const node of nodes) {
|
|
36093
36142
|
if (node.id && !guidByNodeId.has(node.id)) {
|
|
36094
36143
|
guidByNodeId.set(node.id, GUID_MODEL_ID.test(node.id) ? node.id : newSmartArtGuid());
|
|
36095
36144
|
}
|
|
36096
36145
|
}
|
|
36146
|
+
return guidByNodeId;
|
|
36147
|
+
}
|
|
36148
|
+
var DSP_DATA_MODEL_EXT_URI = "http://schemas.microsoft.com/office/drawing/2008/diagram";
|
|
36149
|
+
function buildFabricatedDiagramDataXml(data, ids, options = {}) {
|
|
36150
|
+
const docGuid = newSmartArtGuid();
|
|
36151
|
+
const guidByNodeId = options.guidByNodeId ?? buildNodeGuidMap(data.nodes);
|
|
36097
36152
|
const points2 = [docPointXml(docGuid, ids)];
|
|
36098
36153
|
const connections = [];
|
|
36099
36154
|
const nextSrcOrd = /* @__PURE__ */ new Map();
|
|
@@ -36116,7 +36171,121 @@ function buildFabricatedDiagramDataXml(data, ids) {
|
|
|
36116
36171
|
);
|
|
36117
36172
|
}
|
|
36118
36173
|
return `${XML_PROLOG}\r
|
|
36119
|
-
<dgm:dataModel ${DGM_XMLNS}><dgm:ptLst>${points2.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole
|
|
36174
|
+
<dgm:dataModel ${DGM_XMLNS}><dgm:ptLst>${points2.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/>${dataModelExtXml(options.drawingRelId)}</dgm:dataModel>`;
|
|
36175
|
+
}
|
|
36176
|
+
function dataModelExtXml(drawingRelId) {
|
|
36177
|
+
if (!drawingRelId) {
|
|
36178
|
+
return "";
|
|
36179
|
+
}
|
|
36180
|
+
return `<dgm:extLst><a:ext uri="${DSP_DATA_MODEL_EXT_URI}"><dsp:dataModelExt xmlns:dsp="${DSP_DATA_MODEL_EXT_URI}" relId="${xmlEscape(drawingRelId)}" minVer="http://schemas.openxmlformats.org/drawingml/2006/diagram"/></a:ext></dgm:extLst>`;
|
|
36181
|
+
}
|
|
36182
|
+
|
|
36183
|
+
// src/core/core/runtime/smartart-fabrication-drawing.ts
|
|
36184
|
+
var DIAGRAM_DRAWING_CONTENT_TYPE = "application/vnd.ms-office.drawingml.diagramDrawing+xml";
|
|
36185
|
+
var DIAGRAM_DRAWING_REL_TYPE = "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing";
|
|
36186
|
+
var DSP_XMLNS = 'xmlns:dsp="http://schemas.microsoft.com/office/drawing/2008/diagram" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"';
|
|
36187
|
+
var ACCENTS = ["accent1", "accent2", "accent3", "accent4", "accent5", "accent6"];
|
|
36188
|
+
function toEmu(px2) {
|
|
36189
|
+
return Math.round(px2 * EMU_PER_PX);
|
|
36190
|
+
}
|
|
36191
|
+
function normalizeHex3(color) {
|
|
36192
|
+
if (!color) {
|
|
36193
|
+
return void 0;
|
|
36194
|
+
}
|
|
36195
|
+
const hex8 = color.replace(/^#/u, "").trim();
|
|
36196
|
+
return /^[0-9A-Fa-f]{6}$/u.test(hex8) ? hex8.toUpperCase() : void 0;
|
|
36197
|
+
}
|
|
36198
|
+
function resolveShapeModelId(shape, index, nodes, guidByNodeId) {
|
|
36199
|
+
const direct = guidByNodeId.get(shape.id);
|
|
36200
|
+
if (direct) {
|
|
36201
|
+
return direct;
|
|
36202
|
+
}
|
|
36203
|
+
const matched = nodes.find(
|
|
36204
|
+
(node) => node.id && (shape.id === node.id || shape.id.endsWith(`-${node.id}`))
|
|
36205
|
+
);
|
|
36206
|
+
if (matched?.id) {
|
|
36207
|
+
const guid = guidByNodeId.get(matched.id);
|
|
36208
|
+
if (guid) {
|
|
36209
|
+
return guid;
|
|
36210
|
+
}
|
|
36211
|
+
}
|
|
36212
|
+
const positional = nodes[index]?.id;
|
|
36213
|
+
if (positional) {
|
|
36214
|
+
const guid = guidByNodeId.get(positional);
|
|
36215
|
+
if (guid) {
|
|
36216
|
+
return guid;
|
|
36217
|
+
}
|
|
36218
|
+
}
|
|
36219
|
+
return newSmartArtGuid();
|
|
36220
|
+
}
|
|
36221
|
+
function textBodyXml(shape) {
|
|
36222
|
+
const text = shape.text ?? "";
|
|
36223
|
+
const fontColor = normalizeHex3(shape.fontColor);
|
|
36224
|
+
const size = shape.fontSize && shape.fontSize > 0 ? ` sz="${Math.round(shape.fontSize * 100)}"` : "";
|
|
36225
|
+
const fill = fontColor ? `<a:solidFill><a:srgbClr val="${fontColor}"/></a:solidFill>` : "";
|
|
36226
|
+
const rPr = `<a:rPr lang="en-US"${size}>${fill}</a:rPr>`;
|
|
36227
|
+
const run = text ? `<a:r>${rPr}<a:t>${xmlEscape(text)}</a:t></a:r>` : `<a:endParaRPr lang="en-US"/>`;
|
|
36228
|
+
return `<dsp:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="ctr"/>${run}</a:p></dsp:txBody>`;
|
|
36229
|
+
}
|
|
36230
|
+
function styleXml(index) {
|
|
36231
|
+
const accent = ACCENTS[index % ACCENTS.length];
|
|
36232
|
+
return `<dsp:style><a:lnRef idx="2"><a:schemeClr val="${accent}"><a:shade val="50000"/></a:schemeClr></a:lnRef><a:fillRef idx="1"><a:schemeClr val="${accent}"/></a:fillRef><a:effectRef idx="0"><a:schemeClr val="${accent}"/></a:effectRef><a:fontRef idx="minor"><a:schemeClr val="lt1"/></a:fontRef></dsp:style>`;
|
|
36233
|
+
}
|
|
36234
|
+
function shapePropsXml(shape) {
|
|
36235
|
+
const rot = shape.rotation ? ` rot="${Math.round(shape.rotation * 6e4)}"` : "";
|
|
36236
|
+
const xfrm = `<a:xfrm${rot}><a:off x="${toEmu(shape.x)}" y="${toEmu(shape.y)}"/><a:ext cx="${toEmu(Math.max(shape.width, 1))}" cy="${toEmu(Math.max(shape.height, 1))}"/></a:xfrm>`;
|
|
36237
|
+
const prst = shape.shapeType && shape.shapeType.length > 0 ? shape.shapeType : "rect";
|
|
36238
|
+
const geom = `<a:prstGeom prst="${xmlEscape(prst)}"><a:avLst/></a:prstGeom>`;
|
|
36239
|
+
const fillHex = normalizeHex3(shape.fillColor);
|
|
36240
|
+
const fill = fillHex ? `<a:solidFill><a:srgbClr val="${fillHex}"/></a:solidFill>` : "";
|
|
36241
|
+
const strokeHex = normalizeHex3(shape.strokeColor);
|
|
36242
|
+
const strokeW = shape.strokeWidth && shape.strokeWidth > 0 ? ` w="${Math.round(shape.strokeWidth * 12700)}"` : "";
|
|
36243
|
+
const ln = strokeHex ? `<a:ln${strokeW}><a:solidFill><a:srgbClr val="${strokeHex}"/></a:solidFill></a:ln>` : "";
|
|
36244
|
+
return `<dsp:spPr>${xfrm}${geom}${fill}${ln}</dsp:spPr>`;
|
|
36245
|
+
}
|
|
36246
|
+
function shapeXml(shape, index, nodes, guidByNodeId) {
|
|
36247
|
+
const modelId = resolveShapeModelId(shape, index, nodes, guidByNodeId);
|
|
36248
|
+
return `<dsp:sp modelId="${modelId}"><dsp:nvSpPr><dsp:cNvPr id="0" name=""/><dsp:cNvSpPr/></dsp:nvSpPr>${shapePropsXml(shape)}${styleXml(index)}${textBodyXml(shape)}</dsp:sp>`;
|
|
36249
|
+
}
|
|
36250
|
+
function buildFabricatedDrawingXml(shapes, nodes, guidByNodeId) {
|
|
36251
|
+
if (!shapes || shapes.length === 0) {
|
|
36252
|
+
return void 0;
|
|
36253
|
+
}
|
|
36254
|
+
const body = shapes.map((shape, index) => shapeXml(shape, index, nodes, guidByNodeId)).join("");
|
|
36255
|
+
return `${XML_PROLOG}\r
|
|
36256
|
+
<dsp:drawing ${DSP_XMLNS}><dsp:spTree><dsp:nvGrpSpPr><dsp:cNvPr id="0" name=""/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr><dsp:grpSpPr/>${body}</dsp:spTree></dsp:drawing>`;
|
|
36257
|
+
}
|
|
36258
|
+
function buildDiagramDataRelsXml(drawingRelId, drawingFileName) {
|
|
36259
|
+
return `${XML_PROLOG}\r
|
|
36260
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="${xmlEscape(drawingRelId)}" Type="${DIAGRAM_DRAWING_REL_TYPE}" Target="${xmlEscape(drawingFileName)}"/></Relationships>`;
|
|
36261
|
+
}
|
|
36262
|
+
function smartArtElementsToDrawingShapes(elements) {
|
|
36263
|
+
if (!elements || elements.length === 0) {
|
|
36264
|
+
return [];
|
|
36265
|
+
}
|
|
36266
|
+
const shapes = [];
|
|
36267
|
+
for (const el of elements) {
|
|
36268
|
+
if (el.type !== "shape") {
|
|
36269
|
+
continue;
|
|
36270
|
+
}
|
|
36271
|
+
const shape = el;
|
|
36272
|
+
shapes.push({
|
|
36273
|
+
id: shape.id,
|
|
36274
|
+
shapeType: shape.shapeType ?? "rect",
|
|
36275
|
+
x: shape.x,
|
|
36276
|
+
y: shape.y,
|
|
36277
|
+
width: shape.width,
|
|
36278
|
+
height: shape.height,
|
|
36279
|
+
rotation: shape.rotation,
|
|
36280
|
+
fillColor: shape.shapeStyle?.fillColor,
|
|
36281
|
+
strokeColor: shape.shapeStyle?.strokeColor,
|
|
36282
|
+
strokeWidth: shape.shapeStyle?.strokeWidth,
|
|
36283
|
+
text: shape.text,
|
|
36284
|
+
fontSize: shape.textStyle?.fontSize,
|
|
36285
|
+
fontColor: shape.textStyle?.color
|
|
36286
|
+
});
|
|
36287
|
+
}
|
|
36288
|
+
return shapes;
|
|
36120
36289
|
}
|
|
36121
36290
|
|
|
36122
36291
|
// src/core/core/runtime/smartart-fabrication-hierarchy.ts
|
|
@@ -36324,14 +36493,29 @@ var PptxHandlerRuntime32 = class _PptxHandlerRuntime extends PptxHandlerRuntime3
|
|
|
36324
36493
|
const data = el.smartArtData;
|
|
36325
36494
|
const family = resolveFabricatedLayoutFamily(data);
|
|
36326
36495
|
const index = this.nextDiagramPartIndex();
|
|
36496
|
+
const guidByNodeId = buildNodeGuidMap(data.nodes);
|
|
36497
|
+
const drawingShapes = data.drawingShapes && data.drawingShapes.length > 0 ? data.drawingShapes : smartArtElementsToDrawingShapes(
|
|
36498
|
+
decomposeSmartArt(data, {
|
|
36499
|
+
x: 0,
|
|
36500
|
+
y: 0,
|
|
36501
|
+
width: Math.max(el.width, 1),
|
|
36502
|
+
height: Math.max(el.height, 1)
|
|
36503
|
+
})
|
|
36504
|
+
);
|
|
36505
|
+
const drawingRelId = "rId1";
|
|
36506
|
+
const drawingXml = buildFabricatedDrawingXml(drawingShapes, data.nodes, guidByNodeId);
|
|
36327
36507
|
const payloads = {
|
|
36328
|
-
data: buildFabricatedDiagramDataXml(
|
|
36329
|
-
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36508
|
+
data: buildFabricatedDiagramDataXml(
|
|
36509
|
+
data,
|
|
36510
|
+
{
|
|
36511
|
+
layoutUniqueId: fabricatedLayoutUniqueId(family),
|
|
36512
|
+
layoutCategory: fabricatedLayoutCategory(family),
|
|
36513
|
+
quickStyleUniqueId: FABRICATED_QUICKSTYLE_UNIQUE_ID,
|
|
36514
|
+
colorsUniqueId: fabricatedColorsUniqueId(data.colorScheme),
|
|
36515
|
+
colorsCategory: fabricatedColorsCategory(data.colorScheme)
|
|
36516
|
+
},
|
|
36517
|
+
{ guidByNodeId, drawingRelId: drawingXml ? drawingRelId : void 0 }
|
|
36518
|
+
),
|
|
36335
36519
|
layout: buildFabricatedLayoutDefXml(family),
|
|
36336
36520
|
quickStyle: buildFabricatedQuickStyleXml(),
|
|
36337
36521
|
colors: buildFabricatedColorsXml(data.colorScheme)
|
|
@@ -36355,6 +36539,19 @@ var PptxHandlerRuntime32 = class _PptxHandlerRuntime extends PptxHandlerRuntime3
|
|
|
36355
36539
|
});
|
|
36356
36540
|
relIds[kind.relAttr] = relId;
|
|
36357
36541
|
}
|
|
36542
|
+
if (drawingXml) {
|
|
36543
|
+
const drawingFile = `drawing${index}.xml`;
|
|
36544
|
+
const drawingPath = `ppt/diagrams/${drawingFile}`;
|
|
36545
|
+
this.zip.file(drawingPath, drawingXml);
|
|
36546
|
+
(this.pendingDiagramContentTypes ??= []).push({
|
|
36547
|
+
partName: `/${drawingPath}`,
|
|
36548
|
+
contentType: DIAGRAM_DRAWING_CONTENT_TYPE
|
|
36549
|
+
});
|
|
36550
|
+
this.zip.file(
|
|
36551
|
+
`ppt/diagrams/_rels/data${index}.xml.rels`,
|
|
36552
|
+
buildDiagramDataRelsXml(drawingRelId, drawingFile)
|
|
36553
|
+
);
|
|
36554
|
+
}
|
|
36358
36555
|
const EMU = _PptxHandlerRuntime.EMU_PER_PX;
|
|
36359
36556
|
return {
|
|
36360
36557
|
"p:nvGraphicFramePr": {
|