@office-open/core 0.3.5 → 0.4.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/dist/_chunks/index-B3rs5exK.d.mts +87 -0
- package/dist/_chunks/{index-eOE0yRGG.d.mts → index-hmJg8TDw.d.mts} +1 -1
- package/dist/_chunks/smartart-D_qXltR5.mjs +336 -0
- package/dist/chart/index.d.mts +41 -11
- package/dist/chart/index.mjs +263 -12
- package/dist/drawingml/index.d.mts +105 -76
- package/dist/drawingml/index.mjs +225 -123
- package/dist/index.d.mts +75 -17
- package/dist/index.mjs +167 -7
- package/dist/smartart/index.d.mts +2 -69
- package/dist/smartart/index.mjs +2 -304
- package/dist/values.d.mts +1 -1
- package/package.json +3 -3
- /package/dist/_chunks/{values--NnXAmqa.d.mts → values-COMdgNmb.d.mts} +0 -0
package/dist/smartart/index.mjs
CHANGED
|
@@ -1,304 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** Layout ID → OOXML category type */
|
|
4
|
-
const LAYOUT_CATEGORIES = {
|
|
5
|
-
default: "list",
|
|
6
|
-
list1: "list",
|
|
7
|
-
list2: "list",
|
|
8
|
-
vList2: "list",
|
|
9
|
-
hList1: "list",
|
|
10
|
-
pList1: "list",
|
|
11
|
-
process1: "process",
|
|
12
|
-
process2: "process",
|
|
13
|
-
process3: "process",
|
|
14
|
-
process4: "process",
|
|
15
|
-
chevron1: "process",
|
|
16
|
-
chevron2: "process",
|
|
17
|
-
arrow1: "process",
|
|
18
|
-
arrow2: "process",
|
|
19
|
-
cycle1: "cycle",
|
|
20
|
-
cycle2: "cycle",
|
|
21
|
-
cycle3: "cycle",
|
|
22
|
-
cycle4: "cycle",
|
|
23
|
-
cycle5: "cycle",
|
|
24
|
-
hierarchy1: "hier",
|
|
25
|
-
hierarchy2: "hier",
|
|
26
|
-
hierarchy3: "hier",
|
|
27
|
-
hierarchy4: "hier",
|
|
28
|
-
orgChart1: "hier",
|
|
29
|
-
pyramid1: "pyramid",
|
|
30
|
-
pyramid2: "pyramid",
|
|
31
|
-
pyramid3: "pyramid",
|
|
32
|
-
matrix1: "matrix",
|
|
33
|
-
matrix2: "matrix",
|
|
34
|
-
matrix3: "matrix",
|
|
35
|
-
radial1: "rel",
|
|
36
|
-
radial2: "rel",
|
|
37
|
-
radial3: "rel",
|
|
38
|
-
venn1: "rel",
|
|
39
|
-
funnel1: "rel",
|
|
40
|
-
balance1: "rel",
|
|
41
|
-
gear1: "rel",
|
|
42
|
-
constOrg1: "rel",
|
|
43
|
-
oppId1: "rel"
|
|
44
|
-
};
|
|
45
|
-
/** Style ID → OOXML category type */
|
|
46
|
-
const STYLE_CATEGORIES = {
|
|
47
|
-
simple1: "simple",
|
|
48
|
-
simple2: "simple",
|
|
49
|
-
simple3: "simple",
|
|
50
|
-
simple4: "simple",
|
|
51
|
-
simple5: "simple",
|
|
52
|
-
moderate1: "moderate",
|
|
53
|
-
moderate2: "moderate",
|
|
54
|
-
moderate3: "moderate",
|
|
55
|
-
moderate4: "moderate",
|
|
56
|
-
polished1: "polished",
|
|
57
|
-
polished2: "polished",
|
|
58
|
-
polished3: "polished",
|
|
59
|
-
polished4: "polished",
|
|
60
|
-
professional1: "professional",
|
|
61
|
-
professional2: "professional",
|
|
62
|
-
professional3: "professional",
|
|
63
|
-
professional4: "professional",
|
|
64
|
-
cartoon1: "cartoon",
|
|
65
|
-
cartoon2: "cartoon",
|
|
66
|
-
cartoon3: "cartoon",
|
|
67
|
-
cartoon4: "cartoon",
|
|
68
|
-
powdery1: "powdery",
|
|
69
|
-
powdery2: "powdery",
|
|
70
|
-
powdery3: "powdery",
|
|
71
|
-
powdery4: "powdery",
|
|
72
|
-
burnt1: "burnt",
|
|
73
|
-
burnt2: "burnt",
|
|
74
|
-
burnt3: "burnt",
|
|
75
|
-
burnt4: "burnt"
|
|
76
|
-
};
|
|
77
|
-
/** Color ID → OOXML category type */
|
|
78
|
-
const COLOR_CATEGORIES = {
|
|
79
|
-
accent1_2: "accent1",
|
|
80
|
-
accent2_2: "accent2",
|
|
81
|
-
accent3_2: "accent3",
|
|
82
|
-
accent4_2: "accent4",
|
|
83
|
-
accent5_2: "accent5",
|
|
84
|
-
accent6_2: "accent6",
|
|
85
|
-
colorful1: "colorful",
|
|
86
|
-
colorful2: "colorful",
|
|
87
|
-
colorful3: "colorful",
|
|
88
|
-
colorful4: "colorful",
|
|
89
|
-
dark1: "dark",
|
|
90
|
-
dark2: "dark",
|
|
91
|
-
primary1: "primary",
|
|
92
|
-
primary2: "primary",
|
|
93
|
-
gray1: "gray",
|
|
94
|
-
gray2: "gray"
|
|
95
|
-
};
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/smartart/data-model/connection.ts
|
|
98
|
-
/**
|
|
99
|
-
* dgm:cxn — SmartArt data model connection (edge).
|
|
100
|
-
*/
|
|
101
|
-
var Connection = class extends XmlComponent {
|
|
102
|
-
constructor(modelId, srcId, destId, type, srcOrd = 0, destOrd = 0, parTransId, sibTransId) {
|
|
103
|
-
super("dgm:cxn");
|
|
104
|
-
const attrs = {
|
|
105
|
-
modelId,
|
|
106
|
-
srcId,
|
|
107
|
-
destId,
|
|
108
|
-
srcOrd,
|
|
109
|
-
destOrd
|
|
110
|
-
};
|
|
111
|
-
if (type) attrs.type = type;
|
|
112
|
-
if (parTransId) attrs.parTransId = parTransId;
|
|
113
|
-
if (sibTransId) attrs.sibTransId = sibTransId;
|
|
114
|
-
this.root.push(chartAttr(attrs));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
//#endregion
|
|
118
|
-
//#region src/smartart/data-model/data-model.ts
|
|
119
|
-
/**
|
|
120
|
-
* CT_DataModel — the complete data model for a SmartArt diagram.
|
|
121
|
-
*/
|
|
122
|
-
var DataModel = class extends XmlComponent {
|
|
123
|
-
constructor(points, connections) {
|
|
124
|
-
super("dgm:dataModel");
|
|
125
|
-
this.root.push(chartAttr({
|
|
126
|
-
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
127
|
-
"xmlns:dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram"
|
|
128
|
-
}));
|
|
129
|
-
const ptLst = new class extends XmlComponent {
|
|
130
|
-
constructor() {
|
|
131
|
-
super("dgm:ptLst");
|
|
132
|
-
}
|
|
133
|
-
}();
|
|
134
|
-
for (const pt of points) ptLst["root"].push(pt);
|
|
135
|
-
this.root.push(ptLst);
|
|
136
|
-
const cxnLst = new class extends XmlComponent {
|
|
137
|
-
constructor() {
|
|
138
|
-
super("dgm:cxnLst");
|
|
139
|
-
}
|
|
140
|
-
}();
|
|
141
|
-
for (const cxn of connections) cxnLst["root"].push(cxn);
|
|
142
|
-
this.root.push(cxnLst);
|
|
143
|
-
this.root.push(new EmptyElement$2("dgm:bg"));
|
|
144
|
-
this.root.push(new EmptyElement$2("dgm:whole"));
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var EmptyElement$2 = class extends XmlComponent {
|
|
148
|
-
constructor(tag) {
|
|
149
|
-
super(tag);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/smartart/data-model/point.ts
|
|
154
|
-
/**
|
|
155
|
-
* dgm:pt — SmartArt data model point (node).
|
|
156
|
-
*/
|
|
157
|
-
var Point = class extends XmlComponent {
|
|
158
|
-
constructor(modelId, text, type = "node") {
|
|
159
|
-
super("dgm:pt");
|
|
160
|
-
this.root.push(chartAttr({
|
|
161
|
-
modelId,
|
|
162
|
-
type
|
|
163
|
-
}));
|
|
164
|
-
this.root.push(new PointText(text));
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
/**
|
|
168
|
-
* Transition point (parTrans or sibTrans) — no text body, references a connection.
|
|
169
|
-
*/
|
|
170
|
-
var TransPoint = class extends XmlComponent {
|
|
171
|
-
constructor(modelId, type, cxnId) {
|
|
172
|
-
super("dgm:pt");
|
|
173
|
-
this.root.push(chartAttr({
|
|
174
|
-
modelId,
|
|
175
|
-
type,
|
|
176
|
-
cxnId
|
|
177
|
-
}));
|
|
178
|
-
this.root.push(new EmptyElement$1("dgm:spPr"));
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
var EmptyElement$1 = class extends XmlComponent {
|
|
182
|
-
constructor(tag) {
|
|
183
|
-
super(tag);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* dgm:t — text body within a point.
|
|
188
|
-
*/
|
|
189
|
-
var PointText = class extends XmlComponent {
|
|
190
|
-
constructor(text) {
|
|
191
|
-
super("dgm:t");
|
|
192
|
-
this.root.push(new EmptyElement$1("a:bodyPr"));
|
|
193
|
-
this.root.push(new EmptyElement$1("a:lstStyle"));
|
|
194
|
-
const p = new EmptyElement$1("a:p");
|
|
195
|
-
if (text) {
|
|
196
|
-
const t = new class extends XmlComponent {
|
|
197
|
-
constructor() {
|
|
198
|
-
super("a:t");
|
|
199
|
-
}
|
|
200
|
-
}();
|
|
201
|
-
t["root"].push(text);
|
|
202
|
-
const r = new class extends XmlComponent {
|
|
203
|
-
constructor() {
|
|
204
|
-
super("a:r");
|
|
205
|
-
}
|
|
206
|
-
}();
|
|
207
|
-
r["root"].push(t);
|
|
208
|
-
p["root"].push(r);
|
|
209
|
-
}
|
|
210
|
-
this.root.push(p);
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/smartart/smartart-collection.ts
|
|
215
|
-
/**
|
|
216
|
-
* Manages SmartArt parts in a document.
|
|
217
|
-
*/
|
|
218
|
-
var SmartArtCollection = class {
|
|
219
|
-
map;
|
|
220
|
-
constructor() {
|
|
221
|
-
this.map = /* @__PURE__ */ new Map();
|
|
222
|
-
}
|
|
223
|
-
addSmartArt(key, data) {
|
|
224
|
-
this.map.set(key, data);
|
|
225
|
-
}
|
|
226
|
-
get Array() {
|
|
227
|
-
return [...this.map.values()];
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/smartart/tree-to-model.ts
|
|
232
|
-
function createDocPoint(layout, style, color) {
|
|
233
|
-
const pt = new class extends XmlComponent {
|
|
234
|
-
constructor() {
|
|
235
|
-
super("dgm:pt");
|
|
236
|
-
}
|
|
237
|
-
}();
|
|
238
|
-
pt["root"].push(chartAttr({
|
|
239
|
-
modelId: 0,
|
|
240
|
-
type: "doc"
|
|
241
|
-
}));
|
|
242
|
-
const prSet = new class extends XmlComponent {
|
|
243
|
-
constructor() {
|
|
244
|
-
super("dgm:prSet");
|
|
245
|
-
}
|
|
246
|
-
}();
|
|
247
|
-
prSet["root"].push(chartAttr({
|
|
248
|
-
loTypeId: `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`,
|
|
249
|
-
loCatId: LAYOUT_CATEGORIES[layout] ?? "list",
|
|
250
|
-
qsTypeId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`,
|
|
251
|
-
qsCatId: STYLE_CATEGORIES[style] ?? "simple",
|
|
252
|
-
csTypeId: `urn:microsoft.com/office/officeart/2005/8/colors/${color}`,
|
|
253
|
-
csCatId: COLOR_CATEGORIES[color] ?? "accent1",
|
|
254
|
-
phldr: "0"
|
|
255
|
-
}));
|
|
256
|
-
pt["root"].push(prSet);
|
|
257
|
-
pt["root"].push(new EmptyElement("dgm:spPr"));
|
|
258
|
-
pt["root"].push(createEmptyTextBody());
|
|
259
|
-
return pt;
|
|
260
|
-
}
|
|
261
|
-
function createEmptyTextBody() {
|
|
262
|
-
const t = new class extends XmlComponent {
|
|
263
|
-
constructor() {
|
|
264
|
-
super("dgm:t");
|
|
265
|
-
}
|
|
266
|
-
}();
|
|
267
|
-
t["root"].push(new EmptyElement("a:bodyPr"));
|
|
268
|
-
t["root"].push(new EmptyElement("a:lstStyle"));
|
|
269
|
-
t["root"].push(new EmptyElement("a:p"));
|
|
270
|
-
return t;
|
|
271
|
-
}
|
|
272
|
-
var EmptyElement = class extends XmlComponent {
|
|
273
|
-
constructor(tag) {
|
|
274
|
-
super(tag);
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
function uuid() {
|
|
278
|
-
return `{${crypto.randomUUID().toUpperCase()}}`;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Creates a DataModel from tree nodes with layout/style/color settings.
|
|
282
|
-
*/
|
|
283
|
-
const createDataModel = (nodes, layout = "default", style = "simple1", color = "accent1_2") => {
|
|
284
|
-
const points = [];
|
|
285
|
-
const connections = [];
|
|
286
|
-
points.push(createDocPoint(layout, style, color));
|
|
287
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
288
|
-
const walk = (node, parentUuid, srcOrd) => {
|
|
289
|
-
const nodeUuid = uuid();
|
|
290
|
-
const parTransUuid = uuid();
|
|
291
|
-
const sibTransUuid = uuid();
|
|
292
|
-
const cxnUuid = uuid();
|
|
293
|
-
points.push(new TransPoint(parTransUuid, "parTrans", cxnUuid));
|
|
294
|
-
points.push(new TransPoint(sibTransUuid, "sibTrans", cxnUuid));
|
|
295
|
-
points.push(new Point(nodeUuid, node.text));
|
|
296
|
-
connections.push(new Connection(parTransUuid, parentUuid, nodeUuid, void 0, srcOrd, 0, parTransUuid, sibTransUuid));
|
|
297
|
-
if (node.children) for (let j = 0; j < node.children.length; j++) walk(node.children[j], nodeUuid, j);
|
|
298
|
-
};
|
|
299
|
-
walk(nodes[i], "0", i);
|
|
300
|
-
}
|
|
301
|
-
return new DataModel(points, connections);
|
|
302
|
-
};
|
|
303
|
-
//#endregion
|
|
304
|
-
export { COLOR_CATEGORIES, Connection, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel };
|
|
1
|
+
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "../_chunks/smartart-D_qXltR5.mjs";
|
|
2
|
+
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel, getColorXml, getLayoutXml, getStyleXml };
|
package/dist/values.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./_chunks/values
|
|
1
|
+
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./_chunks/values-COMdgNmb.mjs";
|
|
2
2
|
export { Percentage, PositivePercentage, PositiveUniversalMeasure, RelativeMeasure, ThemeColor, ThemeFont, UniversalMeasure, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Shared OOXML infrastructure: XmlComponent, value validators, unit converters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"shared",
|
|
10
10
|
"xml"
|
|
11
11
|
],
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://www.office-open.com",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/DemoMacro/office-open/issues"
|
|
15
15
|
},
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"fflate": "0.8.2",
|
|
60
60
|
"hash.js": "1.1.7",
|
|
61
61
|
"nanoid": "5.1.9",
|
|
62
|
-
"@office-open/xml": "0.
|
|
62
|
+
"@office-open/xml": "0.4.0"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"dev": "basis build --stub",
|
|
File without changes
|