@syncfusion/ej2-office-common 35.1.37

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.
Files changed (147) hide show
  1. package/.eslintrc.json +263 -0
  2. package/.prettierrc.json +5 -0
  3. package/README.md +167 -0
  4. package/api-extractor.json +35 -0
  5. package/core.js +4 -0
  6. package/dist/ej2-office-common.umd.min.js +11 -0
  7. package/dist/ej2-office-common.umd.min.js.map +1 -0
  8. package/dist/es6/ej2-office-common.es2015.js +6585 -0
  9. package/dist/es6/ej2-office-common.es2015.js.map +1 -0
  10. package/dist/es6/ej2-office-common.es5.js +7955 -0
  11. package/dist/es6/ej2-office-common.es5.js.map +1 -0
  12. package/dist/global/ej2-office-common.min.js +11 -0
  13. package/dist/global/ej2-office-common.min.js.map +1 -0
  14. package/dist/global/index.d.ts +14 -0
  15. package/encryption.js +4 -0
  16. package/features.js +4 -0
  17. package/global.json +6 -0
  18. package/index.js +4 -0
  19. package/license +10 -0
  20. package/nuget.config +7 -0
  21. package/package.json +23 -0
  22. package/src/all.d.ts +41 -0
  23. package/src/all.js +38 -0
  24. package/src/core/index.d.ts +6 -0
  25. package/src/core/index.js +6 -0
  26. package/src/core/xml/index.d.ts +7 -0
  27. package/src/core/xml/index.js +6 -0
  28. package/src/core/xml/model.d.ts +71 -0
  29. package/src/core/xml/model.js +20 -0
  30. package/src/encryption/agile-constants.d.ts +61 -0
  31. package/src/encryption/agile-constants.js +71 -0
  32. package/src/encryption/agile-encryption-info.d.ts +46 -0
  33. package/src/encryption/agile-encryption-info.js +333 -0
  34. package/src/encryption/agile-password.d.ts +8 -0
  35. package/src/encryption/agile-password.js +58 -0
  36. package/src/encryption/cfb-reader.d.ts +11 -0
  37. package/src/encryption/cfb-reader.js +345 -0
  38. package/src/encryption/crypto-primitives.d.ts +74 -0
  39. package/src/encryption/crypto-primitives.js +302 -0
  40. package/src/encryption/decrypt-encrypted-package.d.ts +16 -0
  41. package/src/encryption/decrypt-encrypted-package.js +138 -0
  42. package/src/encryption/encryption-info-xml.d.ts +21 -0
  43. package/src/encryption/encryption-info-xml.js +282 -0
  44. package/src/encryption/errors.d.ts +66 -0
  45. package/src/encryption/errors.js +124 -0
  46. package/src/encryption/index.d.ts +35 -0
  47. package/src/encryption/index.js +100 -0
  48. package/src/features/diagrams/constants.d.ts +83 -0
  49. package/src/features/diagrams/constants.js +101 -0
  50. package/src/features/diagrams/diagram-data-model.d.ts +148 -0
  51. package/src/features/diagrams/diagram-data-model.js +446 -0
  52. package/src/features/diagrams/diagram-parsers.d.ts +28 -0
  53. package/src/features/diagrams/diagram-parsers.js +182 -0
  54. package/src/features/diagrams/diagram-serializers.d.ts +20 -0
  55. package/src/features/diagrams/diagram-serializers.js +110 -0
  56. package/src/features/diagrams/diagram-views.d.ts +60 -0
  57. package/src/features/diagrams/diagram-views.js +213 -0
  58. package/src/features/diagrams/element-tree.d.ts +55 -0
  59. package/src/features/diagrams/element-tree.js +197 -0
  60. package/src/features/diagrams/errors.d.ts +17 -0
  61. package/src/features/diagrams/errors.js +59 -0
  62. package/src/features/diagrams/index.d.ts +17 -0
  63. package/src/features/diagrams/index.js +17 -0
  64. package/src/features/diagrams/smart-art-catalog.d.ts +107 -0
  65. package/src/features/diagrams/smart-art-catalog.js +422 -0
  66. package/src/features/diagrams/smart-art-diagram.d.ts +96 -0
  67. package/src/features/diagrams/smart-art-diagram.js +258 -0
  68. package/src/features/index.d.ts +11 -0
  69. package/src/features/index.js +11 -0
  70. package/src/features/ink/constants.d.ts +54 -0
  71. package/src/features/ink/constants.js +54 -0
  72. package/src/features/ink/index.d.ts +18 -0
  73. package/src/features/ink/index.js +15 -0
  74. package/src/features/ink/ink-effects.d.ts +35 -0
  75. package/src/features/ink/ink-effects.js +45 -0
  76. package/src/features/ink/ink-model.d.ts +237 -0
  77. package/src/features/ink/ink-model.js +406 -0
  78. package/src/features/ink/ink-parser.d.ts +59 -0
  79. package/src/features/ink/ink-parser.js +671 -0
  80. package/src/features/ink/ink-serializer.d.ts +16 -0
  81. package/src/features/ink/ink-serializer.js +281 -0
  82. package/src/features/ink/ink-units.d.ts +33 -0
  83. package/src/features/ink/ink-units.js +92 -0
  84. package/src/features/ink/ink-xml.d.ts +26 -0
  85. package/src/features/ink/ink-xml.js +165 -0
  86. package/src/features/ink/trace-codec.d.ts +127 -0
  87. package/src/features/ink/trace-codec.js +266 -0
  88. package/src/features/mathml/constants.d.ts +47 -0
  89. package/src/features/mathml/constants.js +47 -0
  90. package/src/features/mathml/errors.d.ts +50 -0
  91. package/src/features/mathml/errors.js +69 -0
  92. package/src/features/mathml/index.d.ts +30 -0
  93. package/src/features/mathml/index.js +22 -0
  94. package/src/features/mathml/math-factory.d.ts +26 -0
  95. package/src/features/mathml/math-factory.js +568 -0
  96. package/src/features/mathml/model/controls.d.ts +896 -0
  97. package/src/features/mathml/model/controls.js +1541 -0
  98. package/src/features/mathml/model/enums.d.ts +153 -0
  99. package/src/features/mathml/model/enums.js +133 -0
  100. package/src/features/mathml/model/math-element.d.ts +173 -0
  101. package/src/features/mathml/model/math-element.js +315 -0
  102. package/src/features/mathml/model/roots.d.ts +82 -0
  103. package/src/features/mathml/model/roots.js +177 -0
  104. package/src/features/mathml/openxml.d.ts +56 -0
  105. package/src/features/mathml/openxml.js +87 -0
  106. package/src/features/mathml/parse/math-parser.d.ts +43 -0
  107. package/src/features/mathml/parse/math-parser.js +636 -0
  108. package/src/features/mathml/serialize/math-serializer.d.ts +34 -0
  109. package/src/features/mathml/serialize/math-serializer.js +749 -0
  110. package/src/features/smart-art/diagram-xml.d.ts +63 -0
  111. package/src/features/smart-art/diagram-xml.js +459 -0
  112. package/src/features/smart-art/errors.d.ts +24 -0
  113. package/src/features/smart-art/errors.js +47 -0
  114. package/src/features/smart-art/index.d.ts +26 -0
  115. package/src/features/smart-art/index.js +26 -0
  116. package/src/features/smart-art/minimal-samples.d.ts +18 -0
  117. package/src/features/smart-art/minimal-samples.js +40 -0
  118. package/src/features/smart-art/mutators.d.ts +60 -0
  119. package/src/features/smart-art/mutators.js +566 -0
  120. package/src/features/smart-art/namespaces.d.ts +153 -0
  121. package/src/features/smart-art/namespaces.js +163 -0
  122. package/src/features/smart-art/package-graph.d.ts +61 -0
  123. package/src/features/smart-art/package-graph.js +413 -0
  124. package/src/features/smart-art/parse-colors.d.ts +19 -0
  125. package/src/features/smart-art/parse-colors.js +39 -0
  126. package/src/features/smart-art/parse-data.d.ts +21 -0
  127. package/src/features/smart-art/parse-data.js +121 -0
  128. package/src/features/smart-art/parse-layout.d.ts +20 -0
  129. package/src/features/smart-art/parse-layout.js +40 -0
  130. package/src/features/smart-art/parse-rel-ids.d.ts +71 -0
  131. package/src/features/smart-art/parse-rel-ids.js +233 -0
  132. package/src/features/smart-art/parse-style.d.ts +19 -0
  133. package/src/features/smart-art/parse-style.js +39 -0
  134. package/src/features/smart-art/point-text.d.ts +80 -0
  135. package/src/features/smart-art/point-text.js +424 -0
  136. package/src/features/smart-art/register.d.ts +33 -0
  137. package/src/features/smart-art/register.js +95 -0
  138. package/src/features/smart-art/serialize.d.ts +40 -0
  139. package/src/features/smart-art/serialize.js +48 -0
  140. package/src/features/smart-art/types.d.ts +403 -0
  141. package/src/features/smart-art/types.js +28 -0
  142. package/src/global.js +1 -0
  143. package/src/index.d.ts +21 -0
  144. package/src/index.js +22 -0
  145. package/tsconfig.build.json +13 -0
  146. package/tsconfig.harness.json +32 -0
  147. package/tslint.json +111 -0
@@ -0,0 +1,424 @@
1
+ /**
2
+ * Common plain-text and structure query APIs for DrawingML diagram points.
3
+ *
4
+ * @remarks
5
+ * Text lives under `dgm:pt/dgm:t` as DrawingML `a:CT_TextBody` (`dml-main.xsd`:
6
+ * required `bodyPr`, optional `lstStyle`, one or more `p`). Plain text is the
7
+ * concatenation of `a:t` under each paragraph, with paragraphs joined by `\n`.
8
+ * Write rebuilds a minimal schema-valid text body while preserving other `pt`
9
+ * children and any existing `bodyPr` / `lstStyle`. Citations: `dml-diagram.xsd`
10
+ * `CT_Pt`; `dml-main.xsd` `CT_TextBody` / `CT_TextParagraph`; ECMA-376 Part 1
11
+ * §14.2.4. Structure add/remove of points and connections is deferred (no
12
+ * schema-valid factory beyond enumerate in this task).
13
+ *
14
+ * @public
15
+ */
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __values = (this && this.__values) || function (o) {
28
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
29
+ if (m) return m.call(o);
30
+ return {
31
+ next: function () {
32
+ if (o && i >= o.length) o = void 0;
33
+ return { value: o && o[i++], done: !o };
34
+ }
35
+ };
36
+ };
37
+ var __read = (this && this.__read) || function (o, n) {
38
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
39
+ if (!m) return o;
40
+ var i = m.call(o), r, ar = [], e;
41
+ try {
42
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
43
+ }
44
+ catch (error) { e = { error: error }; }
45
+ finally {
46
+ try {
47
+ if (r && !r.done && (m = i["return"])) m.call(i);
48
+ }
49
+ finally { if (e) throw e.error; }
50
+ }
51
+ return ar;
52
+ };
53
+ var __spread = (this && this.__spread) || function () {
54
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
55
+ return ar;
56
+ };
57
+ import { cloneElement, elementChildren, findChild, getAttribute } from './diagram-xml';
58
+ import { DiagramPartError } from './errors';
59
+ import { DIAGRAM_NAMESPACE, DRAWINGML_MAIN_NAMESPACE } from './namespaces';
60
+ import { parseDiagramData } from './parse-data';
61
+ import { serializeDiagramData } from './serialize';
62
+ /**
63
+ * Returns the points of a Diagram Data part (structure enumerate).
64
+ *
65
+ * @param data - Parsed {@link DiagramDataPart}.
66
+ * @returns The part's `points` array (same reference; treat as read-only).
67
+ *
68
+ * @public
69
+ */
70
+ export function listDiagramPoints(data) {
71
+ return data.points;
72
+ }
73
+ /**
74
+ * Returns the connections of a Diagram Data part (structure enumerate).
75
+ *
76
+ * @param data - Parsed {@link DiagramDataPart}.
77
+ * @returns The part's `connections` array (same reference; treat as read-only).
78
+ *
79
+ * @public
80
+ */
81
+ export function listDiagramConnections(data) {
82
+ return data.connections;
83
+ }
84
+ /**
85
+ * Finds a point by `modelId`.
86
+ *
87
+ * @param data - Parsed {@link DiagramDataPart}.
88
+ * @param modelId - `dgm:pt@modelId` value.
89
+ * @returns The matching {@link DiagramPoint}, or `undefined` when absent.
90
+ *
91
+ * @public
92
+ */
93
+ export function diagramPoint(data, modelId) {
94
+ var e_1, _a;
95
+ try {
96
+ for (var _b = __values(data.points), _c = _b.next(); !_c.done; _c = _b.next()) {
97
+ var point = _c.value;
98
+ if (point.modelId === modelId) {
99
+ return point;
100
+ }
101
+ }
102
+ }
103
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
104
+ finally {
105
+ try {
106
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
107
+ }
108
+ finally { if (e_1) throw e_1.error; }
109
+ }
110
+ return undefined;
111
+ }
112
+ /**
113
+ * Reads plain text from a diagram point's `dgm:t` DrawingML text body.
114
+ *
115
+ * @remarks
116
+ * Walks `a:p` paragraphs in document order. Within each paragraph, concatenates
117
+ * text from `a:t` descendants (including under `a:r` and `a:fld`). Paragraphs
118
+ * are joined with `\n`. Missing `dgm:t` yields an empty string.
119
+ *
120
+ * @param point - Modeled point (from parse or {@link listDiagramPoints}).
121
+ * @returns Plain text; empty string when the point has no text body or no `a:t`.
122
+ *
123
+ * @public
124
+ */
125
+ export function diagramPointText(point) {
126
+ var textBody = point.textBody != null ? point.textBody : findChild(point.element, 't', DIAGRAM_NAMESPACE);
127
+ if (textBody === undefined) {
128
+ return '';
129
+ }
130
+ return plainTextFromTextBody(textBody);
131
+ }
132
+ /**
133
+ * Returns a new {@link DiagramDataPart} with plain text written to the named point.
134
+ *
135
+ * @remarks
136
+ * Does not mutate `data`. Rebuilds `dgm:t` as a minimal valid `a:CT_TextBody`
137
+ * (`bodyPr` + one `p`/`r`/`t` per line). When a text body already exists,
138
+ * `bodyPr` and `lstStyle` (if present) are preserved; paragraph children are
139
+ * replaced. Other `dgm:pt` siblings and package root extensions are preserved
140
+ * via root rewrite + reparse. Unknown `modelId` throws.
141
+ *
142
+ * Prefer this name over a `set*` verb (API-RULES R1.1 content-mutation ban on
143
+ * `set*` / free-function `set*` patterns).
144
+ *
145
+ * @param data - Source data part (immutable).
146
+ * @param modelId - Target `dgm:pt@modelId`.
147
+ * @param text - Plain text; `\n` splits paragraphs.
148
+ * @returns New data part with updated point text and synced root.
149
+ * @throws {DiagramPartError} When no point matches `modelId`.
150
+ *
151
+ * @public
152
+ */
153
+ export function withDiagramPointText(data, modelId, text) {
154
+ var target = diagramPoint(data, modelId);
155
+ if (target === undefined) {
156
+ throw new DiagramPartError("Unknown diagram point modelId \"" + modelId + "\"");
157
+ }
158
+ var newRoot = replacePointTextOnRoot(data.root, modelId, text);
159
+ // Reparse so points[].textBody / element stay consistent with root.
160
+ return parseDiagramData(serializeDiagramData(__assign({}, data, { root: newRoot })));
161
+ }
162
+ function plainTextFromTextBody(textBody) {
163
+ var paragraphs = elementChildren(textBody).filter(function (el) { return el.localName === 'p' && el.namespaceUri === DRAWINGML_MAIN_NAMESPACE; });
164
+ if (paragraphs.length === 0) {
165
+ // Fallback: collect any a:t under the body (malformed-but-present text).
166
+ return collectDrawingMlText(textBody);
167
+ }
168
+ return paragraphs.map(function (p) { return collectDrawingMlText(p); }).join('\n');
169
+ }
170
+ function collectDrawingMlText(el) {
171
+ var e_2, _a;
172
+ var out = '';
173
+ try {
174
+ for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
175
+ var child = _c.value;
176
+ if (child.kind === 'text') {
177
+ continue;
178
+ }
179
+ if (child.localName === 't' && child.namespaceUri === DRAWINGML_MAIN_NAMESPACE) {
180
+ out += textContent(child);
181
+ continue;
182
+ }
183
+ out += collectDrawingMlText(child);
184
+ }
185
+ }
186
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
187
+ finally {
188
+ try {
189
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
190
+ }
191
+ finally { if (e_2) throw e_2.error; }
192
+ }
193
+ return out;
194
+ }
195
+ function textContent(el) {
196
+ var e_3, _a;
197
+ var out = '';
198
+ try {
199
+ for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
200
+ var child = _c.value;
201
+ if (child.kind === 'text') {
202
+ out += child.value;
203
+ }
204
+ else {
205
+ out += textContent(child);
206
+ }
207
+ }
208
+ }
209
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
210
+ finally {
211
+ try {
212
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
213
+ }
214
+ finally { if (e_3) throw e_3.error; }
215
+ }
216
+ return out;
217
+ }
218
+ function replacePointTextOnRoot(root, modelId, text) {
219
+ return mapTree(root, function (el) {
220
+ if (el.localName === 'pt' && el.namespaceUri === DIAGRAM_NAMESPACE && getAttribute(el, 'modelId') === modelId) {
221
+ return withPointTextElement(el, text);
222
+ }
223
+ return undefined;
224
+ });
225
+ }
226
+ /**
227
+ * Deep-maps an element tree. When `visitor` returns an element, that subtree is
228
+ * replaced as-is (no further recursion into the replacement). Otherwise children
229
+ * are mapped recursively.
230
+ */
231
+ function mapTree(el, visitor) {
232
+ var e_4, _a;
233
+ var replaced = visitor(el);
234
+ if (replaced !== undefined) {
235
+ return replaced;
236
+ }
237
+ var changed = false;
238
+ var children = [];
239
+ try {
240
+ for (var _b = __values(el.children), _c = _b.next(); !_c.done; _c = _b.next()) {
241
+ var child = _c.value;
242
+ if (child.kind === 'text') {
243
+ children.push({
244
+ kind: 'text',
245
+ value: child.value
246
+ });
247
+ continue;
248
+ }
249
+ var next = mapTree(child, visitor);
250
+ if (next !== child) {
251
+ changed = true;
252
+ }
253
+ children.push(next);
254
+ }
255
+ }
256
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
257
+ finally {
258
+ try {
259
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
260
+ }
261
+ finally { if (e_4) throw e_4.error; }
262
+ }
263
+ if (!changed) {
264
+ return el;
265
+ }
266
+ return { kind: 'element',
267
+ prefix: el.prefix,
268
+ localName: el.localName,
269
+ namespaceUri: el.namespaceUri,
270
+ qName: el.qName,
271
+ attributes: el.attributes.map(function (a) { return (__assign({}, a)); }),
272
+ children: children
273
+ };
274
+ }
275
+ function withPointTextElement(pt, text) {
276
+ var e_5, _a;
277
+ var existingT = findChild(pt, 't', DIAGRAM_NAMESPACE);
278
+ var newT = buildTextBodyElement(existingT, text);
279
+ var children = [];
280
+ var replaced = false;
281
+ try {
282
+ for (var _b = __values(pt.children), _c = _b.next(); !_c.done; _c = _b.next()) {
283
+ var child = _c.value;
284
+ if (!replaced && child.kind === 'element' && child.localName === 't' && child.namespaceUri === DIAGRAM_NAMESPACE) {
285
+ children.push(newT);
286
+ replaced = true;
287
+ continue;
288
+ }
289
+ if (child.kind === 'text') {
290
+ children.push({
291
+ kind: 'text',
292
+ value: child.value
293
+ });
294
+ }
295
+ else {
296
+ children.push(cloneElement(child));
297
+ }
298
+ }
299
+ }
300
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
301
+ finally {
302
+ try {
303
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
304
+ }
305
+ finally { if (e_5) throw e_5.error; }
306
+ }
307
+ if (!replaced) {
308
+ children.push(newT);
309
+ }
310
+ return { kind: 'element',
311
+ prefix: pt.prefix,
312
+ localName: pt.localName,
313
+ namespaceUri: pt.namespaceUri,
314
+ qName: pt.qName,
315
+ attributes: pt.attributes.map(function (a) { return (__assign({}, a)); }),
316
+ children: children
317
+ };
318
+ }
319
+ /**
320
+ * Builds `dgm:t` with DrawingML `a:CT_TextBody` children.
321
+ *
322
+ * Order per XSD: bodyPr (required), lstStyle (optional), p+ (required ≥1).
323
+ */
324
+ function buildTextBodyElement(existing, text) {
325
+ var e_6, _a;
326
+ var aPrefix = existing !== undefined ? drawingMlPrefix(existing) : 'a';
327
+ var dgmPrefix = (existing == null ? void 0 : existing.prefix) && existing.prefix.length > 0 ? existing.prefix : 'dgm';
328
+ var bodyPr = existing !== undefined ? findChild(existing, 'bodyPr', DRAWINGML_MAIN_NAMESPACE) : undefined;
329
+ var lstStyle = existing !== undefined ? findChild(existing, 'lstStyle', DRAWINGML_MAIN_NAMESPACE) : undefined;
330
+ var lines = splitPlainTextLines(text);
331
+ var paragraphs = lines.map(function (line) { return aElement(aPrefix, 'p', [aElement(aPrefix, 'r', [aTextElement(aPrefix, line)])]); });
332
+ var children = [];
333
+ if (bodyPr !== undefined) {
334
+ children.push(cloneElement(bodyPr));
335
+ }
336
+ else {
337
+ children.push(aElement(aPrefix, 'bodyPr', []));
338
+ }
339
+ if (lstStyle !== undefined) {
340
+ children.push(cloneElement(lstStyle));
341
+ }
342
+ try {
343
+ for (var paragraphs_1 = __values(paragraphs), paragraphs_1_1 = paragraphs_1.next(); !paragraphs_1_1.done; paragraphs_1_1 = paragraphs_1.next()) {
344
+ var p = paragraphs_1_1.value;
345
+ children.push(p);
346
+ }
347
+ }
348
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
349
+ finally {
350
+ try {
351
+ if (paragraphs_1_1 && !paragraphs_1_1.done && (_a = paragraphs_1.return)) _a.call(paragraphs_1);
352
+ }
353
+ finally { if (e_6) throw e_6.error; }
354
+ }
355
+ // Ensure xmlns:a is in scope on dgm:t when the root may not declare it yet
356
+ // (e.g. blank points from minimal samples that only declare dgm).
357
+ var attributes = existing !== undefined ? existing.attributes.map(function (a) { return (__assign({}, a)); }) : [{
358
+ prefix: 'xmlns',
359
+ localName: 'a',
360
+ namespaceUri: 'http://www.w3.org/2000/xmlns/',
361
+ value: DRAWINGML_MAIN_NAMESPACE,
362
+ qName: 'xmlns:a'
363
+ }];
364
+ // If existing t lacked xmlns:a and ancestors also might miss it after rewrite,
365
+ // ensure declaration when we detect no a attributes already present.
366
+ var hasANs = attributes.some(function (a) { return a.prefix === 'xmlns' && a.localName === 'a' || a.prefix === '' && a.localName === 'xmlns' && a.value === DRAWINGML_MAIN_NAMESPACE; });
367
+ var finalAttributes = hasANs ? attributes : __spread(attributes, [{
368
+ prefix: 'xmlns',
369
+ localName: 'a',
370
+ namespaceUri: 'http://www.w3.org/2000/xmlns/',
371
+ value: DRAWINGML_MAIN_NAMESPACE,
372
+ qName: 'xmlns:a'
373
+ }]);
374
+ return { kind: 'element',
375
+ prefix: dgmPrefix,
376
+ localName: 't',
377
+ namespaceUri: DIAGRAM_NAMESPACE,
378
+ qName: dgmPrefix.length > 0 ? dgmPrefix + ":t" : 't',
379
+ attributes: finalAttributes,
380
+ children: children
381
+ };
382
+ }
383
+ function splitPlainTextLines(text) {
384
+ if (text.length === 0) {
385
+ return [''];
386
+ }
387
+ return text.split('\n');
388
+ }
389
+ function aElement(prefix, localName, children) {
390
+ var p = prefix.length > 0 ? prefix : 'a';
391
+ return { kind: 'element',
392
+ prefix: p,
393
+ localName: localName,
394
+ namespaceUri: DRAWINGML_MAIN_NAMESPACE,
395
+ qName: p + ":" + localName,
396
+ attributes: [],
397
+ children: __spread(children)
398
+ };
399
+ }
400
+ function aTextElement(prefix, value) {
401
+ return aElement(prefix, 't', [{
402
+ kind: 'text',
403
+ value: value
404
+ }]);
405
+ }
406
+ function drawingMlPrefix(textBody) {
407
+ var e_7, _a;
408
+ try {
409
+ for (var _b = __values(elementChildren(textBody)), _c = _b.next(); !_c.done; _c = _b.next()) {
410
+ var child = _c.value;
411
+ if (child.namespaceUri === DRAWINGML_MAIN_NAMESPACE && child.prefix.length > 0) {
412
+ return child.prefix;
413
+ }
414
+ }
415
+ }
416
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
417
+ finally {
418
+ try {
419
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
420
+ }
421
+ finally { if (e_7) throw e_7.error; }
422
+ }
423
+ return 'a';
424
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * SmartArt feature registration — in-module content-type handler table.
3
+ *
4
+ * @remarks
5
+ * This encryption-base tree has no shared FeatureRegistry. Handlers for the four
6
+ * Transitional diagram content types live in a module-local map installed by
7
+ * {@link registerSmartArtFeature}. Safe to call multiple times (idempotent).
8
+ *
9
+ * Citations: ECMA-376 Part 1 §14.2.3–14.2.6 content types.
10
+ *
11
+ * @public
12
+ */
13
+ import { DiagramPartHandler } from './types';
14
+ /**
15
+ * Registers SmartArt (DrawingML diagram) parse/serialize handlers for the four
16
+ * Transitional diagram content types.
17
+ *
18
+ * @remarks
19
+ * Idempotent: subsequent calls leave the installed table unchanged.
20
+ * Does not accept or return PowerPoint, Word, or Excel product types.
21
+ *
22
+ * @public
23
+ */
24
+ export declare function registerSmartArtFeature(): void;
25
+ /**
26
+ * Looks up a registered diagram part handler by content type.
27
+ *
28
+ * @param contentType - One of the four Transitional diagram content types.
29
+ * @returns The handler, or `undefined` if registration has not run or the type is unknown.
30
+ *
31
+ * @public
32
+ */
33
+ export declare function getDiagramPartHandler(contentType: string): DiagramPartHandler | undefined;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * SmartArt feature registration — in-module content-type handler table.
3
+ *
4
+ * @remarks
5
+ * This encryption-base tree has no shared FeatureRegistry. Handlers for the four
6
+ * Transitional diagram content types live in a module-local map installed by
7
+ * {@link registerSmartArtFeature}. Safe to call multiple times (idempotent).
8
+ *
9
+ * Citations: ECMA-376 Part 1 §14.2.3–14.2.6 content types.
10
+ *
11
+ * @public
12
+ */
13
+ import { DiagramPartError } from './errors';
14
+ import { DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_STYLE_CONTENT_TYPE, } from './namespaces';
15
+ import { parseDiagramColors } from './parse-colors';
16
+ import { parseDiagramData } from './parse-data';
17
+ import { parseDiagramLayout } from './parse-layout';
18
+ import { parseDiagramStyle } from './parse-style';
19
+ import { serializeDiagramColors, serializeDiagramData, serializeDiagramLayout, serializeDiagramStyle, } from './serialize';
20
+ var handlers = new Map();
21
+ var installed = false;
22
+ function installHandlers() {
23
+ if (installed) {
24
+ return;
25
+ }
26
+ var dataHandler = {
27
+ contentType: DIAGRAM_DATA_CONTENT_TYPE,
28
+ parse: function (xml) { return parseDiagramData(xml); },
29
+ serialize: function (part) {
30
+ if (part.kind !== 'diagramData') {
31
+ throw new DiagramPartError('Handler serialize kind mismatch for diagramData');
32
+ }
33
+ return serializeDiagramData(part);
34
+ },
35
+ };
36
+ var colorsHandler = {
37
+ contentType: DIAGRAM_COLORS_CONTENT_TYPE,
38
+ parse: function (xml) { return parseDiagramColors(xml); },
39
+ serialize: function (part) {
40
+ if (part.kind !== 'diagramColors') {
41
+ throw new DiagramPartError('Handler serialize kind mismatch for diagramColors');
42
+ }
43
+ return serializeDiagramColors(part);
44
+ },
45
+ };
46
+ var layoutHandler = {
47
+ contentType: DIAGRAM_LAYOUT_CONTENT_TYPE,
48
+ parse: function (xml) { return parseDiagramLayout(xml); },
49
+ serialize: function (part) {
50
+ if (part.kind !== 'diagramLayout') {
51
+ throw new DiagramPartError('Handler serialize kind mismatch for diagramLayout');
52
+ }
53
+ return serializeDiagramLayout(part);
54
+ },
55
+ };
56
+ var styleHandler = {
57
+ contentType: DIAGRAM_STYLE_CONTENT_TYPE,
58
+ parse: function (xml) { return parseDiagramStyle(xml); },
59
+ serialize: function (part) {
60
+ if (part.kind !== 'diagramStyle') {
61
+ throw new DiagramPartError('Handler serialize kind mismatch for diagramStyle');
62
+ }
63
+ return serializeDiagramStyle(part);
64
+ },
65
+ };
66
+ handlers.set(DIAGRAM_DATA_CONTENT_TYPE, dataHandler);
67
+ handlers.set(DIAGRAM_COLORS_CONTENT_TYPE, colorsHandler);
68
+ handlers.set(DIAGRAM_LAYOUT_CONTENT_TYPE, layoutHandler);
69
+ handlers.set(DIAGRAM_STYLE_CONTENT_TYPE, styleHandler);
70
+ installed = true;
71
+ }
72
+ /**
73
+ * Registers SmartArt (DrawingML diagram) parse/serialize handlers for the four
74
+ * Transitional diagram content types.
75
+ *
76
+ * @remarks
77
+ * Idempotent: subsequent calls leave the installed table unchanged.
78
+ * Does not accept or return PowerPoint, Word, or Excel product types.
79
+ *
80
+ * @public
81
+ */
82
+ export function registerSmartArtFeature() {
83
+ installHandlers();
84
+ }
85
+ /**
86
+ * Looks up a registered diagram part handler by content type.
87
+ *
88
+ * @param contentType - One of the four Transitional diagram content types.
89
+ * @returns The handler, or `undefined` if registration has not run or the type is unknown.
90
+ *
91
+ * @public
92
+ */
93
+ export function getDiagramPartHandler(contentType) {
94
+ return handlers.get(contentType);
95
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Serialize DrawingML diagram parts from preserved root elements.
3
+ *
4
+ * @remarks
5
+ * v1 serialize is root-identity: write the cloned `root` captured at parse time
6
+ * so unknown children, attributes, and MC content round-trip. Citations:
7
+ * ECMA-376 Part 1 §14.2.3–14.2.6; preserve policy in `docs/ooxml-mapping/smart-art.md`.
8
+ *
9
+ * @public
10
+ */
11
+ import { DiagramColorsPart, DiagramDataPart, DiagramLayoutPart, DiagramStylePart } from './types';
12
+ /**
13
+ * Serializes a {@link DiagramDataPart} to a Diagram Data part XML document.
14
+ *
15
+ * @remarks
16
+ * Root-identity serialize of the cloned `root` captured at parse time. Kind is
17
+ * enforced by the TypeScript parameter type; runtime kind mismatch checks live
18
+ * on content-type handlers in `register.ts`.
19
+ *
20
+ * @public
21
+ */
22
+ export declare function serializeDiagramData(part: DiagramDataPart): string;
23
+ /**
24
+ * Serializes a {@link DiagramColorsPart} to a Diagram Colors part XML document.
25
+ *
26
+ * @public
27
+ */
28
+ export declare function serializeDiagramColors(part: DiagramColorsPart): string;
29
+ /**
30
+ * Serializes a {@link DiagramLayoutPart} to a Diagram Layout Definition part XML document.
31
+ *
32
+ * @public
33
+ */
34
+ export declare function serializeDiagramLayout(part: DiagramLayoutPart): string;
35
+ /**
36
+ * Serializes a {@link DiagramStylePart} to a Diagram Style part XML document.
37
+ *
38
+ * @public
39
+ */
40
+ export declare function serializeDiagramStyle(part: DiagramStylePart): string;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Serialize DrawingML diagram parts from preserved root elements.
3
+ *
4
+ * @remarks
5
+ * v1 serialize is root-identity: write the cloned `root` captured at parse time
6
+ * so unknown children, attributes, and MC content round-trip. Citations:
7
+ * ECMA-376 Part 1 §14.2.3–14.2.6; preserve policy in `docs/ooxml-mapping/smart-art.md`.
8
+ *
9
+ * @public
10
+ */
11
+ import { serializeDiagramXml } from './diagram-xml';
12
+ /**
13
+ * Serializes a {@link DiagramDataPart} to a Diagram Data part XML document.
14
+ *
15
+ * @remarks
16
+ * Root-identity serialize of the cloned `root` captured at parse time. Kind is
17
+ * enforced by the TypeScript parameter type; runtime kind mismatch checks live
18
+ * on content-type handlers in `register.ts`.
19
+ *
20
+ * @public
21
+ */
22
+ export function serializeDiagramData(part) {
23
+ return serializeDiagramXml(part.root);
24
+ }
25
+ /**
26
+ * Serializes a {@link DiagramColorsPart} to a Diagram Colors part XML document.
27
+ *
28
+ * @public
29
+ */
30
+ export function serializeDiagramColors(part) {
31
+ return serializeDiagramXml(part.root);
32
+ }
33
+ /**
34
+ * Serializes a {@link DiagramLayoutPart} to a Diagram Layout Definition part XML document.
35
+ *
36
+ * @public
37
+ */
38
+ export function serializeDiagramLayout(part) {
39
+ return serializeDiagramXml(part.root);
40
+ }
41
+ /**
42
+ * Serializes a {@link DiagramStylePart} to a Diagram Style part XML document.
43
+ *
44
+ * @public
45
+ */
46
+ export function serializeDiagramStyle(part) {
47
+ return serializeDiagramXml(part.root);
48
+ }