@office-open/core 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -60
- package/dist/chart/index.d.mts +2 -2
- package/dist/chart/index.mjs +2 -2
- package/dist/chart-DNpai28f.mjs +365 -0
- package/dist/descriptor/index.d.mts +2 -0
- package/dist/descriptor/index.mjs +2 -0
- package/dist/descriptor-57JUzfpG.mjs +282 -0
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{index-Cj2Yf5mk.d.mts → index-BKotL3AP.d.mts} +10 -7
- package/dist/{index-DEvpdl1o.d.mts → index-BqJRDf5H.d.mts} +1423 -1837
- package/dist/index-D81RV9Vc.d.mts +153 -0
- package/dist/{index-BCUfgp9A.d.mts → index-DmPBJwSk.d.mts} +2 -2
- package/dist/{index-D0N5Bw2M.d.mts → index-eu1aFQCm.d.mts} +39 -28
- package/dist/index-xXbaecaB.d.mts +137 -0
- package/dist/index.d.mts +8 -558
- package/dist/index.mjs +7 -2091
- package/dist/patch/index.d.mts +1 -1
- package/dist/smartart/index.d.mts +2 -2
- package/dist/smartart/index.mjs +2 -2
- package/dist/{smartart-9ZpWgmIy.mjs → smartart-DCY-Vdv7.mjs} +120 -204
- package/dist/src-DPuDEZYF.mjs +7477 -0
- package/dist/theme/index.d.mts +2 -2
- package/dist/theme/index.mjs +2 -2
- package/dist/{theme-FWD_20fH.mjs → theme-CiNzdl-9.mjs} +117 -22
- package/dist/{values.d.mts → util/values.d.mts} +1 -1
- package/dist/{values.mjs → util/values.mjs} +1 -1
- package/dist/{values-BOWpTgBE.mjs → values-CVIZcTRw.mjs} +1 -1
- package/dist/{values-COjPGYkS.d.mts → values-Dqj8cbcy.d.mts} +1 -1
- package/package.json +13 -10
- package/dist/chart-CigYrDhf.mjs +0 -1242
- package/dist/drawingml-B-2eEHAF.mjs +0 -7109
- package/dist/index-Bh6s66Up.d.mts +0 -381
- package/dist/index-CoTp4wVf.d.mts +0 -202
- package/dist/xml-components-BuFdDxHN.mjs +0 -322
package/dist/patch/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "../index-
|
|
1
|
+
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "../index-DmPBJwSk.mjs";
|
|
2
2
|
export { DOCX_NS, PPTX_NS, type RenderedParagraphNode, type ReplacerConfig, TokenNotFoundError, type XmlNamespaceConfig, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { COLOR_CATEGORIES,
|
|
1
|
+
import { a as PointPropertySetOptions, c as stringifyDataModel, d as getColorXml, f as getLayoutXml, g as STYLE_CATEGORIES, h as LAYOUT_CATEGORIES, i as SmartArtData, l as stringifyConnection, m as COLOR_CATEGORIES, n as createDataModel, o as stringifyPoint, p as getStyleXml, r as SmartArtCollection, s as stringifyTransPoint, t as TreeNode, u as DEFAULT_DRAWING_XML } from "../index-eu1aFQCm.mjs";
|
|
2
|
+
export { COLOR_CATEGORIES, DEFAULT_DRAWING_XML, LAYOUT_CATEGORIES, PointPropertySetOptions, STYLE_CATEGORIES, SmartArtCollection, SmartArtData, TreeNode, createDataModel, getColorXml, getLayoutXml, getStyleXml, stringifyConnection, stringifyDataModel, stringifyPoint, stringifyTransPoint };
|
package/dist/smartart/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { COLOR_CATEGORIES,
|
|
1
|
+
import { a as stringifyDataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as stringifyTransPoint, l as getLayoutXml, n as SmartArtCollection, o as stringifyConnection, p as STYLE_CATEGORIES, r as stringifyPoint, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "../smartart-DCY-Vdv7.mjs";
|
|
2
|
+
export { COLOR_CATEGORIES, DEFAULT_DRAWING_XML, LAYOUT_CATEGORIES, STYLE_CATEGORIES, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml, stringifyConnection, stringifyDataModel, stringifyPoint, stringifyTransPoint };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { escapeXml } from "@office-open/xml";
|
|
2
2
|
//#region src/smartart/categories.ts
|
|
3
3
|
/** Layout ID → OOXML category type */
|
|
4
4
|
const LAYOUT_CATEGORIES = {
|
|
@@ -133,166 +133,103 @@ const DEFAULT_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone
|
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/smartart/data-model/connection.ts
|
|
135
135
|
/**
|
|
136
|
-
* dgm:cxn — SmartArt data model connection (edge).
|
|
136
|
+
* dgm:cxn — SmartArt data model connection (edge) XML stringifier.
|
|
137
137
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
this.root.push(chartAttr(attrs));
|
|
153
|
-
}
|
|
154
|
-
};
|
|
138
|
+
function stringifyConnection(opts) {
|
|
139
|
+
const attrs = [
|
|
140
|
+
`modelId="${escapeXml(String(opts.modelId))}"`,
|
|
141
|
+
`srcId="${escapeXml(String(opts.srcId))}"`,
|
|
142
|
+
`destId="${escapeXml(String(opts.destId))}"`,
|
|
143
|
+
`srcOrd="${opts.srcOrd ?? 0}"`,
|
|
144
|
+
`destOrd="${opts.destOrd ?? 0}"`
|
|
145
|
+
];
|
|
146
|
+
if (opts.type) attrs.push(`type="${escapeXml(opts.type)}"`);
|
|
147
|
+
if (opts.parTransId) attrs.push(`parTransId="${escapeXml(opts.parTransId)}"`);
|
|
148
|
+
if (opts.sibTransId) attrs.push(`sibTransId="${escapeXml(opts.sibTransId)}"`);
|
|
149
|
+
if (opts.presId) attrs.push(`presId="${escapeXml(opts.presId)}"`);
|
|
150
|
+
return `<dgm:cxn ${attrs.join(" ")}/>`;
|
|
151
|
+
}
|
|
155
152
|
//#endregion
|
|
156
153
|
//#region src/smartart/data-model/data-model.ts
|
|
157
154
|
/**
|
|
158
|
-
* CT_DataModel —
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
constructor(points, connections) {
|
|
162
|
-
super("dgm:dataModel");
|
|
163
|
-
this.root.push(chartAttr({
|
|
164
|
-
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
165
|
-
"xmlns:dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram"
|
|
166
|
-
}));
|
|
167
|
-
const ptLst = new class extends XmlComponent {
|
|
168
|
-
constructor() {
|
|
169
|
-
super("dgm:ptLst");
|
|
170
|
-
}
|
|
171
|
-
}();
|
|
172
|
-
for (const pt of points) ptLst["root"].push(pt);
|
|
173
|
-
this.root.push(ptLst);
|
|
174
|
-
const cxnLst = new class extends XmlComponent {
|
|
175
|
-
constructor() {
|
|
176
|
-
super("dgm:cxnLst");
|
|
177
|
-
}
|
|
178
|
-
}();
|
|
179
|
-
for (const cxn of connections) cxnLst["root"].push(cxn);
|
|
180
|
-
this.root.push(cxnLst);
|
|
181
|
-
this.root.push(new EmptyElement$2("dgm:bg"));
|
|
182
|
-
this.root.push(new EmptyElement$2("dgm:whole"));
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
var EmptyElement$2 = class extends XmlComponent {
|
|
186
|
-
constructor(tag) {
|
|
187
|
-
super(tag);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
//#endregion
|
|
191
|
-
//#region src/smartart/data-model/point.ts
|
|
192
|
-
/**
|
|
193
|
-
* dgm:pt — SmartArt data model point (node).
|
|
155
|
+
* CT_DataModel XML stringifier — assembles complete SmartArt data model XML.
|
|
156
|
+
*
|
|
157
|
+
* @module
|
|
194
158
|
*/
|
|
195
|
-
var Point = class extends XmlComponent {
|
|
196
|
-
constructor(modelId, text, type = "node", propertySet) {
|
|
197
|
-
super("dgm:pt");
|
|
198
|
-
this.root.push(chartAttr({
|
|
199
|
-
modelId,
|
|
200
|
-
type
|
|
201
|
-
}));
|
|
202
|
-
if (propertySet) this.root.push(new PropertySet(propertySet));
|
|
203
|
-
this.root.push(new PointText(text));
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
159
|
/**
|
|
207
|
-
* dgm:
|
|
160
|
+
* Build the complete dgm:dataModel XML from pre-serialized point and connection strings.
|
|
208
161
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (opts.customFlipVertical !== void 0) attr.custFlipVert = opts.customFlipVertical ? "1" : "0";
|
|
222
|
-
if (opts.customFlipHorizontal !== void 0) attr.custFlipHor = opts.customFlipHorizontal ? "1" : "0";
|
|
223
|
-
if (opts.customSizeX !== void 0) attr.custSzX = opts.customSizeX;
|
|
224
|
-
if (opts.customSizeY !== void 0) attr.custSzY = opts.customSizeY;
|
|
225
|
-
if (opts.customScaleX !== void 0) attr.custScaleX = opts.customScaleX;
|
|
226
|
-
if (opts.customScaleY !== void 0) attr.custScaleY = opts.customScaleY;
|
|
227
|
-
if (opts.customText !== void 0) attr.custT = opts.customText ? "1" : "0";
|
|
228
|
-
if (opts.customLinearFactorX !== void 0) attr.custLinFactX = opts.customLinearFactorX;
|
|
229
|
-
if (opts.customLinearFactorY !== void 0) attr.custLinFactY = opts.customLinearFactorY;
|
|
230
|
-
if (opts.customLinearFactorNeighborX !== void 0) attr.custLinFactNeighborX = opts.customLinearFactorNeighborX;
|
|
231
|
-
if (opts.customLinearFactorNeighborY !== void 0) attr.custLinFactNeighborY = opts.customLinearFactorNeighborY;
|
|
232
|
-
if (opts.customRadialScaleRadius !== void 0) attr.custRadScaleRad = opts.customRadialScaleRadius;
|
|
233
|
-
if (opts.customRadialScaleIncrement !== void 0) attr.custRadScaleInc = opts.customRadialScaleIncrement;
|
|
234
|
-
if (opts.coherent3DOffset !== void 0) attr.coherent3DOff = opts.coherent3DOffset ? "1" : "0";
|
|
235
|
-
if (opts.hideGeometry !== void 0) attr.hideGeom = opts.hideGeometry ? "1" : "0";
|
|
236
|
-
if (opts.hideLastTransition !== void 0) attr.hideLastTrans = opts.hideLastTransition ? "1" : "0";
|
|
237
|
-
if (opts.lockTextEntry !== void 0) attr.lkTxEntry = opts.lockTextEntry ? "1" : "0";
|
|
238
|
-
if (opts.moveWith !== void 0) attr.moveWith = opts.moveWith;
|
|
239
|
-
if (opts.useDefault !== void 0) attr.useDef = opts.useDefault ? "1" : "0";
|
|
240
|
-
if (opts.zOrderOffset !== void 0) attr.zOrderOff = opts.zOrderOffset;
|
|
241
|
-
if (opts.layoutTypeId !== void 0) attr.loTypeId = opts.layoutTypeId;
|
|
242
|
-
if (opts.layoutCategoryId !== void 0) attr.loCatId = opts.layoutCategoryId;
|
|
243
|
-
if (opts.quickStyleTypeId !== void 0) attr.qsTypeId = opts.quickStyleTypeId;
|
|
244
|
-
if (opts.quickStyleCategoryId !== void 0) attr.qsCatId = opts.quickStyleCategoryId;
|
|
245
|
-
if (opts.colorStyleTypeId !== void 0) attr.csTypeId = opts.colorStyleTypeId;
|
|
246
|
-
if (opts.colorStyleCategoryId !== void 0) attr.csCatId = opts.colorStyleCategoryId;
|
|
247
|
-
if (Object.keys(attr).length > 0) this.root.push({ _attr: attr });
|
|
248
|
-
}
|
|
249
|
-
};
|
|
162
|
+
function stringifyDataModel(points, connections) {
|
|
163
|
+
return [
|
|
164
|
+
"<dgm:dataModel xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\">",
|
|
165
|
+
`<dgm:ptLst>${points.join("")}</dgm:ptLst>`,
|
|
166
|
+
`<dgm:cxnLst>${connections.join("")}</dgm:cxnLst>`,
|
|
167
|
+
"<dgm:bg/>",
|
|
168
|
+
"<dgm:whole/>",
|
|
169
|
+
"</dgm:dataModel>"
|
|
170
|
+
].join("");
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/smartart/data-model/point.ts
|
|
250
174
|
/**
|
|
251
|
-
*
|
|
175
|
+
* dgm:pt — SmartArt data model point (node) XML stringifier.
|
|
252
176
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this.root.push(new EmptyElement$1("dgm:spPr"));
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
var EmptyElement$1 = class extends XmlComponent {
|
|
265
|
-
constructor(tag) {
|
|
266
|
-
super(tag);
|
|
267
|
-
}
|
|
268
|
-
};
|
|
177
|
+
function stringifyPoint(modelId, text, type = "node", propertySet) {
|
|
178
|
+
const parts = [];
|
|
179
|
+
parts.push(`<dgm:pt modelId="${escapeXml(String(modelId))}" type="${escapeXml(type)}">`);
|
|
180
|
+
if (propertySet) parts.push(stringifyPropertySet(propertySet));
|
|
181
|
+
parts.push(stringifyPointText(text));
|
|
182
|
+
parts.push("</dgm:pt>");
|
|
183
|
+
return parts.join("");
|
|
184
|
+
}
|
|
269
185
|
/**
|
|
270
|
-
* dgm:
|
|
186
|
+
* dgm:pt — transition point (parTrans or sibTrans) XML stringifier.
|
|
271
187
|
*/
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
};
|
|
188
|
+
function stringifyTransPoint(modelId, type, cxnId) {
|
|
189
|
+
return `<dgm:pt modelId="${escapeXml(modelId)}" type="${escapeXml(type)}" cxnId="${escapeXml(cxnId)}"><dgm:spPr/></dgm:pt>`;
|
|
190
|
+
}
|
|
191
|
+
function stringifyPropertySet(opts) {
|
|
192
|
+
const attr = [];
|
|
193
|
+
if (opts.presentationAssociationId !== void 0) attr.push(`presAssocID="${escapeXml(opts.presentationAssociationId)}"`);
|
|
194
|
+
if (opts.presentationName !== void 0) attr.push(`presName="${escapeXml(opts.presentationName)}"`);
|
|
195
|
+
if (opts.presentationStyleLabel !== void 0) attr.push(`presStyleLbl="${escapeXml(opts.presentationStyleLabel)}"`);
|
|
196
|
+
if (opts.presentationStyleIndex !== void 0) attr.push(`presStyleIdx="${opts.presentationStyleIndex}"`);
|
|
197
|
+
if (opts.presentationStyleCount !== void 0) attr.push(`presStyleCnt="${opts.presentationStyleCount}"`);
|
|
198
|
+
if (opts.placeholderText !== void 0) attr.push(`phldrT="${escapeXml(opts.placeholderText)}"`);
|
|
199
|
+
if (opts.placeholder !== void 0) attr.push(`phldr="${opts.placeholder ? 1 : 0}"`);
|
|
200
|
+
if (opts.customAngle !== void 0) attr.push(`custAng="${opts.customAngle}"`);
|
|
201
|
+
if (opts.customFlipVertical !== void 0) attr.push(`custFlipVert="${opts.customFlipVertical ? 1 : 0}"`);
|
|
202
|
+
if (opts.customFlipHorizontal !== void 0) attr.push(`custFlipHor="${opts.customFlipHorizontal ? 1 : 0}"`);
|
|
203
|
+
if (opts.customSizeX !== void 0) attr.push(`custSzX="${opts.customSizeX}"`);
|
|
204
|
+
if (opts.customSizeY !== void 0) attr.push(`custSzY="${opts.customSizeY}"`);
|
|
205
|
+
if (opts.customScaleX !== void 0) attr.push(`custScaleX="${opts.customScaleX}"`);
|
|
206
|
+
if (opts.customScaleY !== void 0) attr.push(`custScaleY="${opts.customScaleY}"`);
|
|
207
|
+
if (opts.customText !== void 0) attr.push(`custT="${opts.customText ? 1 : 0}"`);
|
|
208
|
+
if (opts.customLinearFactorX !== void 0) attr.push(`custLinFactX="${opts.customLinearFactorX}"`);
|
|
209
|
+
if (opts.customLinearFactorY !== void 0) attr.push(`custLinFactY="${opts.customLinearFactorY}"`);
|
|
210
|
+
if (opts.customLinearFactorNeighborX !== void 0) attr.push(`custLinFactNeighborX="${opts.customLinearFactorNeighborX}"`);
|
|
211
|
+
if (opts.customLinearFactorNeighborY !== void 0) attr.push(`custLinFactNeighborY="${opts.customLinearFactorNeighborY}"`);
|
|
212
|
+
if (opts.customRadialScaleRadius !== void 0) attr.push(`custRadScaleRad="${opts.customRadialScaleRadius}"`);
|
|
213
|
+
if (opts.customRadialScaleIncrement !== void 0) attr.push(`custRadScaleInc="${opts.customRadialScaleIncrement}"`);
|
|
214
|
+
if (opts.coherent3DOffset !== void 0) attr.push(`coherent3DOff="${opts.coherent3DOffset ? 1 : 0}"`);
|
|
215
|
+
if (opts.hideGeometry !== void 0) attr.push(`hideGeom="${opts.hideGeometry ? 1 : 0}"`);
|
|
216
|
+
if (opts.hideLastTransition !== void 0) attr.push(`hideLastTrans="${opts.hideLastTransition ? 1 : 0}"`);
|
|
217
|
+
if (opts.lockTextEntry !== void 0) attr.push(`lkTxEntry="${opts.lockTextEntry ? 1 : 0}"`);
|
|
218
|
+
if (opts.moveWith !== void 0) attr.push(`moveWith="${escapeXml(opts.moveWith)}"`);
|
|
219
|
+
if (opts.useDefault !== void 0) attr.push(`useDef="${opts.useDefault ? 1 : 0}"`);
|
|
220
|
+
if (opts.zOrderOffset !== void 0) attr.push(`zOrderOff="${opts.zOrderOffset}"`);
|
|
221
|
+
if (opts.layoutTypeId !== void 0) attr.push(`loTypeId="${escapeXml(opts.layoutTypeId)}"`);
|
|
222
|
+
if (opts.layoutCategoryId !== void 0) attr.push(`loCatId="${escapeXml(opts.layoutCategoryId)}"`);
|
|
223
|
+
if (opts.quickStyleTypeId !== void 0) attr.push(`qsTypeId="${escapeXml(opts.quickStyleTypeId)}"`);
|
|
224
|
+
if (opts.quickStyleCategoryId !== void 0) attr.push(`qsCatId="${escapeXml(opts.quickStyleCategoryId)}"`);
|
|
225
|
+
if (opts.colorStyleTypeId !== void 0) attr.push(`csTypeId="${escapeXml(opts.colorStyleTypeId)}"`);
|
|
226
|
+
if (opts.colorStyleCategoryId !== void 0) attr.push(`csCatId="${escapeXml(opts.colorStyleCategoryId)}"`);
|
|
227
|
+
if (attr.length === 0) return "";
|
|
228
|
+
return `<dgm:prSet ${attr.join(" ")}/>`;
|
|
229
|
+
}
|
|
230
|
+
function stringifyPointText(text) {
|
|
231
|
+
return `<dgm:t><a:bodyPr/><a:lstStyle/><a:p>${text ? `<a:r><a:t>${escapeXml(text)}</a:t></a:r>` : ""}</a:p></dgm:t>`;
|
|
232
|
+
}
|
|
296
233
|
//#endregion
|
|
297
234
|
//#region src/smartart/smartart-collection.ts
|
|
298
235
|
/**
|
|
@@ -312,76 +249,55 @@ var SmartArtCollection = class {
|
|
|
312
249
|
};
|
|
313
250
|
//#endregion
|
|
314
251
|
//#region src/smartart/tree-to-model.ts
|
|
315
|
-
function
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}();
|
|
330
|
-
prSet["root"].push(chartAttr({
|
|
331
|
-
loTypeId: `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`,
|
|
332
|
-
loCatId: LAYOUT_CATEGORIES[layout] ?? "list",
|
|
333
|
-
qsTypeId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`,
|
|
334
|
-
qsCatId: STYLE_CATEGORIES[style] ?? "simple",
|
|
335
|
-
csTypeId: `urn:microsoft.com/office/officeart/2005/8/colors/${color}`,
|
|
336
|
-
csCatId: COLOR_CATEGORIES[color] ?? "accent1",
|
|
337
|
-
phldr: "0"
|
|
338
|
-
}));
|
|
339
|
-
pt["root"].push(prSet);
|
|
340
|
-
pt["root"].push(new EmptyElement("dgm:spPr"));
|
|
341
|
-
pt["root"].push(createEmptyTextBody());
|
|
342
|
-
return pt;
|
|
343
|
-
}
|
|
344
|
-
function createEmptyTextBody() {
|
|
345
|
-
const t = new class extends XmlComponent {
|
|
346
|
-
constructor() {
|
|
347
|
-
super("dgm:t");
|
|
348
|
-
}
|
|
349
|
-
}();
|
|
350
|
-
t["root"].push(new EmptyElement("a:bodyPr"));
|
|
351
|
-
t["root"].push(new EmptyElement("a:lstStyle"));
|
|
352
|
-
t["root"].push(new EmptyElement("a:p"));
|
|
353
|
-
return t;
|
|
252
|
+
function stringifyDocPoint(layout, style, color) {
|
|
253
|
+
const loTypeId = `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`;
|
|
254
|
+
const loCatId = LAYOUT_CATEGORIES[layout] ?? "list";
|
|
255
|
+
const qsTypeId = `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`;
|
|
256
|
+
const qsCatId = STYLE_CATEGORIES[style] ?? "simple";
|
|
257
|
+
const csTypeId = `urn:microsoft.com/office/officeart/2005/8/colors/${color}`;
|
|
258
|
+
const csCatId = COLOR_CATEGORIES[color] ?? "accent1";
|
|
259
|
+
return [
|
|
260
|
+
"<dgm:pt modelId=\"0\" type=\"doc\">",
|
|
261
|
+
`<dgm:prSet loTypeId="${escapeXml(loTypeId)}" loCatId="${escapeXml(loCatId)}" qsTypeId="${escapeXml(qsTypeId)}" qsCatId="${escapeXml(qsCatId)}" csTypeId="${escapeXml(csTypeId)}" csCatId="${escapeXml(csCatId)}" phldr="0"/>`,
|
|
262
|
+
"<dgm:spPr/>",
|
|
263
|
+
"<dgm:t><a:bodyPr/><a:lstStyle/><a:p/></dgm:t>",
|
|
264
|
+
"</dgm:pt>"
|
|
265
|
+
].join("");
|
|
354
266
|
}
|
|
355
|
-
var EmptyElement = class extends XmlComponent {
|
|
356
|
-
constructor(tag) {
|
|
357
|
-
super(tag);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
267
|
function uuid() {
|
|
361
268
|
return `{${crypto.randomUUID().toUpperCase()}}`;
|
|
362
269
|
}
|
|
363
270
|
/**
|
|
364
|
-
* Creates
|
|
271
|
+
* Creates SmartArt data model XML from tree nodes with layout/style/color settings.
|
|
272
|
+
* Returns the XML string body (no XML declaration).
|
|
365
273
|
*/
|
|
366
274
|
const createDataModel = (nodes, layout = "default", style = "simple1", color = "accent1_2") => {
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
-
|
|
275
|
+
const pointStrs = [];
|
|
276
|
+
const connectionStrs = [];
|
|
277
|
+
pointStrs.push(stringifyDocPoint(layout, style, color));
|
|
370
278
|
for (let i = 0; i < nodes.length; i++) {
|
|
371
279
|
const walk = (node, parentUuid, srcOrd) => {
|
|
372
280
|
const nodeUuid = uuid();
|
|
373
281
|
const parTransUuid = uuid();
|
|
374
282
|
const sibTransUuid = uuid();
|
|
375
283
|
const cxnUuid = uuid();
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
284
|
+
pointStrs.push(stringifyTransPoint(parTransUuid, "parTrans", cxnUuid));
|
|
285
|
+
pointStrs.push(stringifyTransPoint(sibTransUuid, "sibTrans", cxnUuid));
|
|
286
|
+
pointStrs.push(stringifyPoint(nodeUuid, node.text));
|
|
287
|
+
connectionStrs.push(stringifyConnection({
|
|
288
|
+
modelId: parTransUuid,
|
|
289
|
+
srcId: parentUuid,
|
|
290
|
+
destId: nodeUuid,
|
|
291
|
+
srcOrd,
|
|
292
|
+
destOrd: 0,
|
|
293
|
+
parTransId: parTransUuid,
|
|
294
|
+
sibTransId: sibTransUuid
|
|
295
|
+
}));
|
|
380
296
|
if (node.children) for (let j = 0; j < node.children.length; j++) walk(node.children[j], nodeUuid, j);
|
|
381
297
|
};
|
|
382
298
|
walk(nodes[i], "0", i);
|
|
383
299
|
}
|
|
384
|
-
return
|
|
300
|
+
return stringifyDataModel(pointStrs, connectionStrs);
|
|
385
301
|
};
|
|
386
302
|
//#endregion
|
|
387
|
-
export {
|
|
303
|
+
export { stringifyDataModel as a, getColorXml as c, COLOR_CATEGORIES as d, LAYOUT_CATEGORIES as f, stringifyTransPoint as i, getLayoutXml as l, SmartArtCollection as n, stringifyConnection as o, STYLE_CATEGORIES as p, stringifyPoint as r, DEFAULT_DRAWING_XML as s, createDataModel as t, getStyleXml as u };
|