@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.
- package/.eslintrc.json +263 -0
- package/.prettierrc.json +5 -0
- package/README.md +167 -0
- package/api-extractor.json +35 -0
- package/core.js +4 -0
- package/dist/ej2-office-common.umd.min.js +11 -0
- package/dist/ej2-office-common.umd.min.js.map +1 -0
- package/dist/es6/ej2-office-common.es2015.js +6585 -0
- package/dist/es6/ej2-office-common.es2015.js.map +1 -0
- package/dist/es6/ej2-office-common.es5.js +7955 -0
- package/dist/es6/ej2-office-common.es5.js.map +1 -0
- package/dist/global/ej2-office-common.min.js +11 -0
- package/dist/global/ej2-office-common.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/encryption.js +4 -0
- package/features.js +4 -0
- package/global.json +6 -0
- package/index.js +4 -0
- package/license +10 -0
- package/nuget.config +7 -0
- package/package.json +23 -0
- package/src/all.d.ts +41 -0
- package/src/all.js +38 -0
- package/src/core/index.d.ts +6 -0
- package/src/core/index.js +6 -0
- package/src/core/xml/index.d.ts +7 -0
- package/src/core/xml/index.js +6 -0
- package/src/core/xml/model.d.ts +71 -0
- package/src/core/xml/model.js +20 -0
- package/src/encryption/agile-constants.d.ts +61 -0
- package/src/encryption/agile-constants.js +71 -0
- package/src/encryption/agile-encryption-info.d.ts +46 -0
- package/src/encryption/agile-encryption-info.js +333 -0
- package/src/encryption/agile-password.d.ts +8 -0
- package/src/encryption/agile-password.js +58 -0
- package/src/encryption/cfb-reader.d.ts +11 -0
- package/src/encryption/cfb-reader.js +345 -0
- package/src/encryption/crypto-primitives.d.ts +74 -0
- package/src/encryption/crypto-primitives.js +302 -0
- package/src/encryption/decrypt-encrypted-package.d.ts +16 -0
- package/src/encryption/decrypt-encrypted-package.js +138 -0
- package/src/encryption/encryption-info-xml.d.ts +21 -0
- package/src/encryption/encryption-info-xml.js +282 -0
- package/src/encryption/errors.d.ts +66 -0
- package/src/encryption/errors.js +124 -0
- package/src/encryption/index.d.ts +35 -0
- package/src/encryption/index.js +100 -0
- package/src/features/diagrams/constants.d.ts +83 -0
- package/src/features/diagrams/constants.js +101 -0
- package/src/features/diagrams/diagram-data-model.d.ts +148 -0
- package/src/features/diagrams/diagram-data-model.js +446 -0
- package/src/features/diagrams/diagram-parsers.d.ts +28 -0
- package/src/features/diagrams/diagram-parsers.js +182 -0
- package/src/features/diagrams/diagram-serializers.d.ts +20 -0
- package/src/features/diagrams/diagram-serializers.js +110 -0
- package/src/features/diagrams/diagram-views.d.ts +60 -0
- package/src/features/diagrams/diagram-views.js +213 -0
- package/src/features/diagrams/element-tree.d.ts +55 -0
- package/src/features/diagrams/element-tree.js +197 -0
- package/src/features/diagrams/errors.d.ts +17 -0
- package/src/features/diagrams/errors.js +59 -0
- package/src/features/diagrams/index.d.ts +17 -0
- package/src/features/diagrams/index.js +17 -0
- package/src/features/diagrams/smart-art-catalog.d.ts +107 -0
- package/src/features/diagrams/smart-art-catalog.js +422 -0
- package/src/features/diagrams/smart-art-diagram.d.ts +96 -0
- package/src/features/diagrams/smart-art-diagram.js +258 -0
- package/src/features/index.d.ts +11 -0
- package/src/features/index.js +11 -0
- package/src/features/ink/constants.d.ts +54 -0
- package/src/features/ink/constants.js +54 -0
- package/src/features/ink/index.d.ts +18 -0
- package/src/features/ink/index.js +15 -0
- package/src/features/ink/ink-effects.d.ts +35 -0
- package/src/features/ink/ink-effects.js +45 -0
- package/src/features/ink/ink-model.d.ts +237 -0
- package/src/features/ink/ink-model.js +406 -0
- package/src/features/ink/ink-parser.d.ts +59 -0
- package/src/features/ink/ink-parser.js +671 -0
- package/src/features/ink/ink-serializer.d.ts +16 -0
- package/src/features/ink/ink-serializer.js +281 -0
- package/src/features/ink/ink-units.d.ts +33 -0
- package/src/features/ink/ink-units.js +92 -0
- package/src/features/ink/ink-xml.d.ts +26 -0
- package/src/features/ink/ink-xml.js +165 -0
- package/src/features/ink/trace-codec.d.ts +127 -0
- package/src/features/ink/trace-codec.js +266 -0
- package/src/features/mathml/constants.d.ts +47 -0
- package/src/features/mathml/constants.js +47 -0
- package/src/features/mathml/errors.d.ts +50 -0
- package/src/features/mathml/errors.js +69 -0
- package/src/features/mathml/index.d.ts +30 -0
- package/src/features/mathml/index.js +22 -0
- package/src/features/mathml/math-factory.d.ts +26 -0
- package/src/features/mathml/math-factory.js +568 -0
- package/src/features/mathml/model/controls.d.ts +896 -0
- package/src/features/mathml/model/controls.js +1541 -0
- package/src/features/mathml/model/enums.d.ts +153 -0
- package/src/features/mathml/model/enums.js +133 -0
- package/src/features/mathml/model/math-element.d.ts +173 -0
- package/src/features/mathml/model/math-element.js +315 -0
- package/src/features/mathml/model/roots.d.ts +82 -0
- package/src/features/mathml/model/roots.js +177 -0
- package/src/features/mathml/openxml.d.ts +56 -0
- package/src/features/mathml/openxml.js +87 -0
- package/src/features/mathml/parse/math-parser.d.ts +43 -0
- package/src/features/mathml/parse/math-parser.js +636 -0
- package/src/features/mathml/serialize/math-serializer.d.ts +34 -0
- package/src/features/mathml/serialize/math-serializer.js +749 -0
- package/src/features/smart-art/diagram-xml.d.ts +63 -0
- package/src/features/smart-art/diagram-xml.js +459 -0
- package/src/features/smart-art/errors.d.ts +24 -0
- package/src/features/smart-art/errors.js +47 -0
- package/src/features/smart-art/index.d.ts +26 -0
- package/src/features/smart-art/index.js +26 -0
- package/src/features/smart-art/minimal-samples.d.ts +18 -0
- package/src/features/smart-art/minimal-samples.js +40 -0
- package/src/features/smart-art/mutators.d.ts +60 -0
- package/src/features/smart-art/mutators.js +566 -0
- package/src/features/smart-art/namespaces.d.ts +153 -0
- package/src/features/smart-art/namespaces.js +163 -0
- package/src/features/smart-art/package-graph.d.ts +61 -0
- package/src/features/smart-art/package-graph.js +413 -0
- package/src/features/smart-art/parse-colors.d.ts +19 -0
- package/src/features/smart-art/parse-colors.js +39 -0
- package/src/features/smart-art/parse-data.d.ts +21 -0
- package/src/features/smart-art/parse-data.js +121 -0
- package/src/features/smart-art/parse-layout.d.ts +20 -0
- package/src/features/smart-art/parse-layout.js +40 -0
- package/src/features/smart-art/parse-rel-ids.d.ts +71 -0
- package/src/features/smart-art/parse-rel-ids.js +233 -0
- package/src/features/smart-art/parse-style.d.ts +19 -0
- package/src/features/smart-art/parse-style.js +39 -0
- package/src/features/smart-art/point-text.d.ts +80 -0
- package/src/features/smart-art/point-text.js +424 -0
- package/src/features/smart-art/register.d.ts +33 -0
- package/src/features/smart-art/register.js +95 -0
- package/src/features/smart-art/serialize.d.ts +40 -0
- package/src/features/smart-art/serialize.js +48 -0
- package/src/features/smart-art/types.d.ts +403 -0
- package/src/features/smart-art/types.js +28 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.js +22 -0
- package/tsconfig.build.json +13 -0
- package/tsconfig.harness.json +32 -0
- package/tslint.json +111 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse `dgm:relIds` (`CT_RelIds`) from host graphic-data XML.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Citations: `dml-diagram.xsd` `CT_RelIds` (required `r:dm`/`r:lo`/`r:qs`/`r:cs`);
|
|
6
|
+
* [MS-ODRAWXML] §3.7.1 sample; [MS-OE376] GraphicData URI → `relIds`.
|
|
7
|
+
*
|
|
8
|
+
* Explicit parse APIs throw {@link DiagramPartError} when any required attribute
|
|
9
|
+
* is missing or empty. Package enumerate (preserve-on-load) skips incomplete
|
|
10
|
+
* hooks without throwing — see {@link findDiagramRelIds}.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
import { DiagramXmlElement } from './diagram-xml';
|
|
15
|
+
import { DiagramRelIds } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* Reads the four required `CT_RelIds` attributes from a `dgm:relIds` element.
|
|
18
|
+
*
|
|
19
|
+
* @returns The ids, or `undefined` when any required attribute is missing/empty
|
|
20
|
+
* (preserve path for package open).
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
export declare function tryReadDiagramRelIds(el: DiagramXmlElement): DiagramRelIds | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Requires a complete `CT_RelIds` on the element or throws.
|
|
27
|
+
*
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
export declare function requireDiagramRelIds(el: DiagramXmlElement): DiagramRelIds;
|
|
31
|
+
/**
|
|
32
|
+
* True when `el` is `a:graphicData` with the diagram GraphicData URI.
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
export declare function isDiagramGraphicData(el: DiagramXmlElement): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Finds complete `dgm:relIds` payloads under diagram `a:graphicData` hooks.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Incomplete `CT_RelIds` (missing/empty required attributes) are skipped — the
|
|
42
|
+
* preserve-on-load policy for package open. Use {@link parseDiagramRelIds} when
|
|
43
|
+
* the caller explicitly requires a complete hook.
|
|
44
|
+
*
|
|
45
|
+
* When a `relIds` element is nested under `a:graphicData`, only diagram URI
|
|
46
|
+
* hooks are accepted. A bare `dgm:relIds` document root is always accepted when
|
|
47
|
+
* complete.
|
|
48
|
+
*
|
|
49
|
+
* @param xml - Host part or fragment XML that may contain `a:graphicData` /
|
|
50
|
+
* `dgm:relIds`.
|
|
51
|
+
* @returns Zero or more complete {@link DiagramRelIds} values in document order.
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare function findDiagramRelIds(xml: string): ReadonlyArray<DiagramRelIds>;
|
|
56
|
+
/**
|
|
57
|
+
* Parses a complete `dgm:relIds` (`CT_RelIds`) from XML.
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Accepts a document whose root is `dgm:relIds`, or a larger tree containing
|
|
61
|
+
* exactly one complete diagram `relIds` hook (as returned by
|
|
62
|
+
* {@link findDiagramRelIds}). Throws when none or multiple complete hooks are
|
|
63
|
+
* present, or when the only hook is incomplete.
|
|
64
|
+
*
|
|
65
|
+
* @param xml - XML text.
|
|
66
|
+
* @returns The four relationship id strings.
|
|
67
|
+
* @throws {DiagramPartError} Incomplete or ambiguous `relIds`.
|
|
68
|
+
*
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseDiagramRelIds(xml: string): DiagramRelIds;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse `dgm:relIds` (`CT_RelIds`) from host graphic-data XML.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Citations: `dml-diagram.xsd` `CT_RelIds` (required `r:dm`/`r:lo`/`r:qs`/`r:cs`);
|
|
6
|
+
* [MS-ODRAWXML] §3.7.1 sample; [MS-OE376] GraphicData URI → `relIds`.
|
|
7
|
+
*
|
|
8
|
+
* Explicit parse APIs throw {@link DiagramPartError} when any required attribute
|
|
9
|
+
* is missing or empty. Package enumerate (preserve-on-load) skips incomplete
|
|
10
|
+
* hooks without throwing — see {@link findDiagramRelIds}.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
var __values = (this && this.__values) || function (o) {
|
|
15
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
16
|
+
if (m) return m.call(o);
|
|
17
|
+
return {
|
|
18
|
+
next: function () {
|
|
19
|
+
if (o && i >= o.length) o = void 0;
|
|
20
|
+
return { value: o && o[i++], done: !o };
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
import { elementChildren, findChild, getAttribute, parseDiagramXml, } from './diagram-xml';
|
|
25
|
+
import { DiagramPartError } from './errors';
|
|
26
|
+
import { DIAGRAM_GRAPHIC_DATA_URI, DIAGRAM_NAMESPACE, DRAWINGML_MAIN_NAMESPACE, OFFICE_DOCUMENT_RELATIONSHIPS_NAMESPACE, } from './namespaces';
|
|
27
|
+
function readRelIdAttr(el, localName) {
|
|
28
|
+
var value = getAttribute(el, localName, OFFICE_DOCUMENT_RELATIONSHIPS_NAMESPACE);
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
var trimmed = value.trim();
|
|
33
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reads the four required `CT_RelIds` attributes from a `dgm:relIds` element.
|
|
37
|
+
*
|
|
38
|
+
* @returns The ids, or `undefined` when any required attribute is missing/empty
|
|
39
|
+
* (preserve path for package open).
|
|
40
|
+
*
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
export function tryReadDiagramRelIds(el) {
|
|
44
|
+
if (el.localName !== 'relIds' || el.namespaceUri !== DIAGRAM_NAMESPACE) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
var dm = readRelIdAttr(el, 'dm');
|
|
48
|
+
var lo = readRelIdAttr(el, 'lo');
|
|
49
|
+
var qs = readRelIdAttr(el, 'qs');
|
|
50
|
+
var cs = readRelIdAttr(el, 'cs');
|
|
51
|
+
if (dm === undefined || lo === undefined || qs === undefined || cs === undefined) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return { dm: dm, lo: lo, qs: qs, cs: cs };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Requires a complete `CT_RelIds` on the element or throws.
|
|
58
|
+
*
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
export function requireDiagramRelIds(el) {
|
|
62
|
+
var ids = tryReadDiagramRelIds(el);
|
|
63
|
+
if (ids === undefined) {
|
|
64
|
+
throw new DiagramPartError('dgm:relIds requires non-empty r:dm, r:lo, r:qs, and r:cs (CT_RelIds)');
|
|
65
|
+
}
|
|
66
|
+
return ids;
|
|
67
|
+
}
|
|
68
|
+
function collectRelIdsElements(root, out) {
|
|
69
|
+
var e_1, _a;
|
|
70
|
+
if (root.localName === 'relIds' && root.namespaceUri === DIAGRAM_NAMESPACE) {
|
|
71
|
+
out.push(root);
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
for (var _b = __values(elementChildren(root)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
75
|
+
var child = _c.value;
|
|
76
|
+
collectRelIdsElements(child, out);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
80
|
+
finally {
|
|
81
|
+
try {
|
|
82
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
83
|
+
}
|
|
84
|
+
finally { if (e_1) throw e_1.error; }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* True when `el` is `a:graphicData` with the diagram GraphicData URI.
|
|
89
|
+
*
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
export function isDiagramGraphicData(el) {
|
|
93
|
+
if (el.localName !== 'graphicData' || el.namespaceUri !== DRAWINGML_MAIN_NAMESPACE) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
var uri = getAttribute(el, 'uri', '');
|
|
97
|
+
return uri === DIAGRAM_GRAPHIC_DATA_URI;
|
|
98
|
+
}
|
|
99
|
+
function findPath(node, target, path) {
|
|
100
|
+
var e_2, _a;
|
|
101
|
+
path.push(node);
|
|
102
|
+
if (node === target) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
for (var _b = __values(elementChildren(node)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
107
|
+
var child = _c.value;
|
|
108
|
+
if (findPath(child, target, path)) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
114
|
+
finally {
|
|
115
|
+
try {
|
|
116
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
117
|
+
}
|
|
118
|
+
finally { if (e_2) throw e_2.error; }
|
|
119
|
+
}
|
|
120
|
+
path.pop();
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function findOwningGraphicData(root, target) {
|
|
124
|
+
var path = [];
|
|
125
|
+
if (!findPath(root, target, path)) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
for (var i = path.length - 1; i >= 0; i -= 1) {
|
|
129
|
+
var node = path[i];
|
|
130
|
+
if (node !== undefined &&
|
|
131
|
+
node.localName === 'graphicData' &&
|
|
132
|
+
node.namespaceUri === DRAWINGML_MAIN_NAMESPACE) {
|
|
133
|
+
return node;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Finds complete `dgm:relIds` payloads under diagram `a:graphicData` hooks.
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* Incomplete `CT_RelIds` (missing/empty required attributes) are skipped — the
|
|
143
|
+
* preserve-on-load policy for package open. Use {@link parseDiagramRelIds} when
|
|
144
|
+
* the caller explicitly requires a complete hook.
|
|
145
|
+
*
|
|
146
|
+
* When a `relIds` element is nested under `a:graphicData`, only diagram URI
|
|
147
|
+
* hooks are accepted. A bare `dgm:relIds` document root is always accepted when
|
|
148
|
+
* complete.
|
|
149
|
+
*
|
|
150
|
+
* @param xml - Host part or fragment XML that may contain `a:graphicData` /
|
|
151
|
+
* `dgm:relIds`.
|
|
152
|
+
* @returns Zero or more complete {@link DiagramRelIds} values in document order.
|
|
153
|
+
*
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export function findDiagramRelIds(xml) {
|
|
157
|
+
var e_3, _a;
|
|
158
|
+
var root = parseDiagramXml(xml);
|
|
159
|
+
var elements = [];
|
|
160
|
+
collectRelIdsElements(root, elements);
|
|
161
|
+
var accepted = [];
|
|
162
|
+
try {
|
|
163
|
+
for (var elements_1 = __values(elements), elements_1_1 = elements_1.next(); !elements_1_1.done; elements_1_1 = elements_1.next()) {
|
|
164
|
+
var el = elements_1_1.value;
|
|
165
|
+
var ids = tryReadDiagramRelIds(el);
|
|
166
|
+
if (ids === undefined) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (el === root) {
|
|
170
|
+
accepted.push(ids);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
var owner = findOwningGraphicData(root, el);
|
|
174
|
+
if (owner === undefined || isDiagramGraphicData(owner)) {
|
|
175
|
+
accepted.push(ids);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
180
|
+
finally {
|
|
181
|
+
try {
|
|
182
|
+
if (elements_1_1 && !elements_1_1.done && (_a = elements_1.return)) _a.call(elements_1);
|
|
183
|
+
}
|
|
184
|
+
finally { if (e_3) throw e_3.error; }
|
|
185
|
+
}
|
|
186
|
+
return accepted;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Parses a complete `dgm:relIds` (`CT_RelIds`) from XML.
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* Accepts a document whose root is `dgm:relIds`, or a larger tree containing
|
|
193
|
+
* exactly one complete diagram `relIds` hook (as returned by
|
|
194
|
+
* {@link findDiagramRelIds}). Throws when none or multiple complete hooks are
|
|
195
|
+
* present, or when the only hook is incomplete.
|
|
196
|
+
*
|
|
197
|
+
* @param xml - XML text.
|
|
198
|
+
* @returns The four relationship id strings.
|
|
199
|
+
* @throws {DiagramPartError} Incomplete or ambiguous `relIds`.
|
|
200
|
+
*
|
|
201
|
+
* @public
|
|
202
|
+
*/
|
|
203
|
+
export function parseDiagramRelIds(xml) {
|
|
204
|
+
var root = parseDiagramXml(xml);
|
|
205
|
+
if (root.localName === 'relIds' && root.namespaceUri === DIAGRAM_NAMESPACE) {
|
|
206
|
+
return requireDiagramRelIds(root);
|
|
207
|
+
}
|
|
208
|
+
// Single graphicData → relIds convenience (MS-ODRAWXML sample shape).
|
|
209
|
+
if (isDiagramGraphicData(root)) {
|
|
210
|
+
var child = findChild(root, 'relIds', DIAGRAM_NAMESPACE);
|
|
211
|
+
if (child === undefined) {
|
|
212
|
+
throw new DiagramPartError('a:graphicData (diagram) is missing dgm:relIds');
|
|
213
|
+
}
|
|
214
|
+
return requireDiagramRelIds(child);
|
|
215
|
+
}
|
|
216
|
+
var found = findDiagramRelIds(xml);
|
|
217
|
+
if (found.length === 0) {
|
|
218
|
+
var elements = [];
|
|
219
|
+
collectRelIdsElements(root, elements);
|
|
220
|
+
if (elements.length > 0) {
|
|
221
|
+
throw new DiagramPartError('dgm:relIds requires non-empty r:dm, r:lo, r:qs, and r:cs (CT_RelIds)');
|
|
222
|
+
}
|
|
223
|
+
throw new DiagramPartError('No dgm:relIds element found');
|
|
224
|
+
}
|
|
225
|
+
if (found.length > 1) {
|
|
226
|
+
throw new DiagramPartError('parseDiagramRelIds expects exactly one dgm:relIds hook');
|
|
227
|
+
}
|
|
228
|
+
var only = found[0];
|
|
229
|
+
if (only === undefined) {
|
|
230
|
+
throw new DiagramPartError('No dgm:relIds element found');
|
|
231
|
+
}
|
|
232
|
+
return only;
|
|
233
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse Diagram Style part (`dgm:styleDef` / `CT_StyleDefinition`).
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Citations: Transitional `dml-diagram.xsd` (`CT_StyleDefinition`);
|
|
6
|
+
* ECMA-376 Part 1 §14.2.6. v1: optional `uniqueId` + opaque root preserve.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
import { DiagramStylePart } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Parses a Diagram Style part XML document into a {@link DiagramStylePart}.
|
|
13
|
+
*
|
|
14
|
+
* @param xml - UTF-8 XML for a single `dgm:styleDef` root.
|
|
15
|
+
* @throws {DiagramPartError} Malformed XML or wrong root element.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseDiagramStyle(xml: string): DiagramStylePart;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse Diagram Style part (`dgm:styleDef` / `CT_StyleDefinition`).
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Citations: Transitional `dml-diagram.xsd` (`CT_StyleDefinition`);
|
|
6
|
+
* ECMA-376 Part 1 §14.2.6. v1: optional `uniqueId` + opaque root preserve.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
var __assign = (this && this.__assign) || function () {
|
|
11
|
+
__assign = Object.assign || function(t) {
|
|
12
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
13
|
+
s = arguments[i];
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
};
|
|
19
|
+
return __assign.apply(this, arguments);
|
|
20
|
+
};
|
|
21
|
+
import { cloneElement, getAttribute, parseDiagramXml } from './diagram-xml';
|
|
22
|
+
import { DiagramPartError } from './errors';
|
|
23
|
+
import { DIAGRAM_NAMESPACE } from './namespaces';
|
|
24
|
+
/**
|
|
25
|
+
* Parses a Diagram Style part XML document into a {@link DiagramStylePart}.
|
|
26
|
+
*
|
|
27
|
+
* @param xml - UTF-8 XML for a single `dgm:styleDef` root.
|
|
28
|
+
* @throws {DiagramPartError} Malformed XML or wrong root element.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export function parseDiagramStyle(xml) {
|
|
33
|
+
var root = parseDiagramXml(xml);
|
|
34
|
+
if (root.localName !== 'styleDef' || root.namespaceUri !== DIAGRAM_NAMESPACE) {
|
|
35
|
+
throw new DiagramPartError("Expected dgm:styleDef root, got " + root.qName + " in ns \"" + root.namespaceUri + "\"");
|
|
36
|
+
}
|
|
37
|
+
var uniqueId = getAttribute(root, 'uniqueId');
|
|
38
|
+
return __assign({ kind: 'diagramStyle' }, (uniqueId !== undefined ? { uniqueId: uniqueId } : {}), { root: cloneElement(root) });
|
|
39
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
import { DiagramConnection, DiagramDataPart, DiagramPoint } from './types';
|
|
17
|
+
/**
|
|
18
|
+
* Returns the points of a Diagram Data part (structure enumerate).
|
|
19
|
+
*
|
|
20
|
+
* @param data - Parsed {@link DiagramDataPart}.
|
|
21
|
+
* @returns The part's `points` array (same reference; treat as read-only).
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function listDiagramPoints(data: DiagramDataPart): ReadonlyArray<DiagramPoint>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the connections of a Diagram Data part (structure enumerate).
|
|
28
|
+
*
|
|
29
|
+
* @param data - Parsed {@link DiagramDataPart}.
|
|
30
|
+
* @returns The part's `connections` array (same reference; treat as read-only).
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function listDiagramConnections(data: DiagramDataPart): ReadonlyArray<DiagramConnection>;
|
|
35
|
+
/**
|
|
36
|
+
* Finds a point by `modelId`.
|
|
37
|
+
*
|
|
38
|
+
* @param data - Parsed {@link DiagramDataPart}.
|
|
39
|
+
* @param modelId - `dgm:pt@modelId` value.
|
|
40
|
+
* @returns The matching {@link DiagramPoint}, or `undefined` when absent.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export declare function diagramPoint(data: DiagramDataPart, modelId: string): DiagramPoint | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Reads plain text from a diagram point's `dgm:t` DrawingML text body.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* Walks `a:p` paragraphs in document order. Within each paragraph, concatenates
|
|
50
|
+
* text from `a:t` descendants (including under `a:r` and `a:fld`). Paragraphs
|
|
51
|
+
* are joined with `\n`. Missing `dgm:t` yields an empty string.
|
|
52
|
+
*
|
|
53
|
+
* @param point - Modeled point (from parse or {@link listDiagramPoints}).
|
|
54
|
+
* @returns Plain text; empty string when the point has no text body or no `a:t`.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare function diagramPointText(point: DiagramPoint): string;
|
|
59
|
+
/**
|
|
60
|
+
* Returns a new {@link DiagramDataPart} with plain text written to the named point.
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* Does not mutate `data`. Rebuilds `dgm:t` as a minimal valid `a:CT_TextBody`
|
|
64
|
+
* (`bodyPr` + one `p`/`r`/`t` per line). When a text body already exists,
|
|
65
|
+
* `bodyPr` and `lstStyle` (if present) are preserved; paragraph children are
|
|
66
|
+
* replaced. Other `dgm:pt` siblings and package root extensions are preserved
|
|
67
|
+
* via root rewrite + reparse. Unknown `modelId` throws.
|
|
68
|
+
*
|
|
69
|
+
* Prefer this name over a `set*` verb (API-RULES R1.1 content-mutation ban on
|
|
70
|
+
* `set*` / free-function `set*` patterns).
|
|
71
|
+
*
|
|
72
|
+
* @param data - Source data part (immutable).
|
|
73
|
+
* @param modelId - Target `dgm:pt@modelId`.
|
|
74
|
+
* @param text - Plain text; `\n` splits paragraphs.
|
|
75
|
+
* @returns New data part with updated point text and synced root.
|
|
76
|
+
* @throws {DiagramPartError} When no point matches `modelId`.
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare function withDiagramPointText(data: DiagramDataPart, modelId: string, text: string): DiagramDataPart;
|