bpmn-js 11.4.1 → 12.0.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/bpmn-modeler.development.js +5348 -5378
- package/dist/bpmn-modeler.production.min.js +17 -18
- package/dist/bpmn-navigated-viewer.development.js +838 -599
- package/dist/bpmn-navigated-viewer.production.min.js +3 -5
- package/dist/bpmn-viewer.development.js +808 -593
- package/dist/bpmn-viewer.production.min.js +4 -6
- package/lib/BaseModeler.d.ts +5 -0
- package/lib/BaseModeler.js +16 -18
- package/lib/BaseViewer.d.ts +366 -0
- package/lib/BaseViewer.js +147 -109
- package/lib/Modeler.d.ts +15 -0
- package/lib/Modeler.js +6 -27
- package/lib/NavigatedViewer.d.ts +3 -0
- package/lib/NavigatedViewer.js +5 -2
- package/lib/Viewer.d.ts +3 -0
- package/lib/Viewer.js +2 -8
- package/lib/features/align-elements/dist/align-bottom-tool.svg +1 -0
- package/lib/features/align-elements/dist/align-horizontal-center-tool.svg +1 -0
- package/lib/features/align-elements/dist/align-left-tool.svg +1 -0
- package/lib/features/align-elements/dist/align-right-tool.svg +1 -0
- package/lib/features/align-elements/dist/align-tool.svg +1 -0
- package/lib/features/align-elements/dist/align-top-tool.svg +1 -0
- package/lib/features/align-elements/dist/align-vertical-center-tool.svg +1 -0
- package/lib/features/modeling/behavior/RootElementReferenceBehavior.js +11 -3
- package/lib/features/replace/BpmnReplace.js +3 -12
- package/lib/features/replace-preview/BpmnReplacePreview.js +1 -1
- package/package.json +13 -11
- package/lib/features/create-append-anything/AppendContextPadProvider.js +0 -77
- package/lib/features/create-append-anything/AppendMenuProvider.js +0 -187
- package/lib/features/create-append-anything/AppendRules.js +0 -83
- package/lib/features/create-append-anything/CreateAppendEditorActions.js +0 -58
- package/lib/features/create-append-anything/CreateAppendKeyboardBindings.js +0 -90
- package/lib/features/create-append-anything/CreateMenuProvider.js +0 -114
- package/lib/features/create-append-anything/CreatePaletteProvider.js +0 -72
- package/lib/features/create-append-anything/index.js +0 -37
- package/lib/features/create-append-anything/util/OptionsUtil.js +0 -617
- package/lib/icons/Icons.js +0 -11
- package/lib/icons/dist/append.svg +0 -1
- package/lib/icons/dist/connect-context-pad.svg +0 -1
- package/lib/icons/dist/connect-palette.svg +0 -1
- package/lib/icons/resources/append.svg +0 -3
- package/lib/icons/resources/create.svg +0 -3
- /package/lib/{icons → features/palette}/dist/create.svg +0 -0
package/lib/BaseModeler.js
CHANGED
|
@@ -6,21 +6,19 @@ import BaseViewer from './BaseViewer';
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @typedef {
|
|
9
|
+
* @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
|
|
10
|
+
* @typedef {import('./BaseViewer').ModdleElement} ModdleElement
|
|
11
|
+
* @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
|
|
12
|
+
*
|
|
13
|
+
* @typedef {import('.').Moddle} Moddle
|
|
10
14
|
*/
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
17
|
* A base modeler for BPMN 2.0 diagrams.
|
|
14
18
|
*
|
|
15
|
-
*
|
|
19
|
+
* See {@link Modeler} for a fully-featured modeler.
|
|
16
20
|
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
19
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
20
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
21
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
22
|
-
* @param {Module[]} [options.modules] a list of modules to override the default modules
|
|
23
|
-
* @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
|
|
21
|
+
* @param {BaseModelerOptions} [options] The options to configure the modeler.
|
|
24
22
|
*/
|
|
25
23
|
export default function BaseModeler(options) {
|
|
26
24
|
BaseViewer.call(this, options);
|
|
@@ -41,27 +39,27 @@ inherits(BaseModeler, BaseViewer);
|
|
|
41
39
|
|
|
42
40
|
|
|
43
41
|
/**
|
|
44
|
-
* Create a moddle instance, attaching
|
|
42
|
+
* Create a moddle instance, attaching IDs to it.
|
|
43
|
+
*
|
|
44
|
+
* @param {BaseModelerOptions} options
|
|
45
45
|
*
|
|
46
|
-
* @
|
|
46
|
+
* @return {Moddle}
|
|
47
47
|
*/
|
|
48
48
|
BaseModeler.prototype._createModdle = function(options) {
|
|
49
49
|
var moddle = BaseViewer.prototype._createModdle.call(this, options);
|
|
50
50
|
|
|
51
|
-
// attach ids to moddle to be able to track
|
|
52
|
-
//
|
|
53
|
-
// tree
|
|
51
|
+
// attach ids to moddle to be able to track and validated ids in the BPMN 2.0
|
|
52
|
+
// XML document tree
|
|
54
53
|
moddle.ids = new Ids([ 32, 36, 1 ]);
|
|
55
54
|
|
|
56
55
|
return moddle;
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
/**
|
|
60
|
-
* Collect
|
|
61
|
-
* definitions object.
|
|
59
|
+
* Collect IDs processed during parsing of the definitions object.
|
|
62
60
|
*
|
|
63
61
|
* @param {ModdleElement} definitions
|
|
64
|
-
* @param {
|
|
62
|
+
* @param {ModdleElementsById} elementsById
|
|
65
63
|
*/
|
|
66
64
|
BaseModeler.prototype._collectIds = function(definitions, elementsById) {
|
|
67
65
|
|
|
@@ -73,6 +71,6 @@ BaseModeler.prototype._collectIds = function(definitions, elementsById) {
|
|
|
73
71
|
ids.clear();
|
|
74
72
|
|
|
75
73
|
for (id in elementsById) {
|
|
76
|
-
ids.claim(id, elementsById[id]);
|
|
74
|
+
ids.claim(id, elementsById[ id ]);
|
|
77
75
|
}
|
|
78
76
|
};
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { ModuleDeclaration } from "didi";
|
|
2
|
+
|
|
3
|
+
import Diagram from 'diagram-js/lib/Diagram';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Event,
|
|
7
|
+
EventCallback
|
|
8
|
+
} from 'diagram-js/lib/core/EventBus';
|
|
9
|
+
|
|
10
|
+
export type ModdleExtension = Object;
|
|
11
|
+
|
|
12
|
+
export type ModdleExtensions = {
|
|
13
|
+
[key: string]: ModdleExtension;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type BaseViewerOptions = {
|
|
17
|
+
width?: number|string;
|
|
18
|
+
height?: number|string;
|
|
19
|
+
position?: string;
|
|
20
|
+
container?: string|HTMLElement;
|
|
21
|
+
moddleExtensions?: ModdleExtensions;
|
|
22
|
+
additionalModules?: ModuleDeclaration[];
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ModdleElement = Object;
|
|
26
|
+
|
|
27
|
+
export type ModdleElementsById = {
|
|
28
|
+
[id: string]: ModdleElement;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ImportXMLResult = {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The warnings produced when parsing the XML.
|
|
35
|
+
*/
|
|
36
|
+
warnings: string[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type ImportXMLError = ImportXMLResult & Error;
|
|
40
|
+
|
|
41
|
+
export type ImportDefinitionsResult = ImportXMLResult;
|
|
42
|
+
|
|
43
|
+
export type ImportDefinitionsError = ImportXMLError;
|
|
44
|
+
|
|
45
|
+
export type OpenResult = ImportXMLResult;
|
|
46
|
+
|
|
47
|
+
export type OpenError = ImportXMLError;
|
|
48
|
+
|
|
49
|
+
export type SaveXMLOptions = {
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether to format the XML. Defaults to `false`.
|
|
53
|
+
*/
|
|
54
|
+
format?: boolean;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether to include the preamble. Defaults to `true`.
|
|
58
|
+
*/
|
|
59
|
+
preamble?: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type SaveXMLResult = {
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The saved XML.
|
|
66
|
+
*/
|
|
67
|
+
xml?: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* An error thrown when saving the XML.
|
|
71
|
+
*/
|
|
72
|
+
error?: Error;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export type SaveSVGResult = {
|
|
76
|
+
svg: string;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
declare namespace Events {
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A `import.parse.start` event.
|
|
83
|
+
*/
|
|
84
|
+
export type ImportParseStart = {
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The XML that is to be parsed.
|
|
88
|
+
*/
|
|
89
|
+
xml: string;
|
|
90
|
+
} & Event;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A `import.parse.complete` event.
|
|
94
|
+
*/
|
|
95
|
+
export type ImportParseComplete = {
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* An error thrown when parsing the XML.
|
|
99
|
+
*/
|
|
100
|
+
error?: ImportXMLError;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The definitions model element.
|
|
104
|
+
*/
|
|
105
|
+
definitions?: ModdleElement;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The model elements by ID.
|
|
109
|
+
*/
|
|
110
|
+
elementsById?: ModdleElementsById;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The referenced model elements.
|
|
114
|
+
*/
|
|
115
|
+
references?: ModdleElement[];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The warnings produced when parsing the XML.
|
|
119
|
+
*/
|
|
120
|
+
warnings: string[];
|
|
121
|
+
} & Event;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* A `import.done` event.
|
|
125
|
+
*/
|
|
126
|
+
export type ImportDone = {
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* An error thrown when parsing the XML.
|
|
130
|
+
*/
|
|
131
|
+
error?: ImportXMLError;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The warnings produced when parsing the XML.
|
|
135
|
+
*/
|
|
136
|
+
warnings: string[];
|
|
137
|
+
} & Event;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* A `saveXML.start` event.
|
|
141
|
+
*/
|
|
142
|
+
export type SaveXMLStart = {
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The definitions model element.
|
|
146
|
+
*/
|
|
147
|
+
definitions: ModdleElement;
|
|
148
|
+
} & Event;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* A `saveXML.done` event.
|
|
152
|
+
*/
|
|
153
|
+
export type SaveXMLDone = SaveXMLResult & Event;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A `saveSVG.done` event.
|
|
157
|
+
*/
|
|
158
|
+
export type SaveSVGDone = {
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* An error thrown when saving the SVG.
|
|
162
|
+
*/
|
|
163
|
+
error?: Error;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The saved SVG.
|
|
167
|
+
*/
|
|
168
|
+
svg: string;
|
|
169
|
+
} & Event;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default class BaseViewer extends Diagram {
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The constructor.
|
|
176
|
+
*
|
|
177
|
+
* @param options The options to configure the viewer.
|
|
178
|
+
*/
|
|
179
|
+
constructor(options?: BaseViewerOptions);
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Parse and render a BPMN 2.0 diagram.
|
|
183
|
+
*
|
|
184
|
+
* Once finished the viewer reports back the result to the
|
|
185
|
+
* provided callback function with (err, warnings).
|
|
186
|
+
*
|
|
187
|
+
* ## Life-Cycle Events
|
|
188
|
+
*
|
|
189
|
+
* During import the viewer will fire life-cycle events:
|
|
190
|
+
*
|
|
191
|
+
* * import.parse.start (about to read model from XML)
|
|
192
|
+
* * import.parse.complete (model read; may have worked or not)
|
|
193
|
+
* * import.render.start (graphical import start)
|
|
194
|
+
* * import.render.complete (graphical import finished)
|
|
195
|
+
* * import.done (everything done)
|
|
196
|
+
*
|
|
197
|
+
* You can use these events to hook into the life-cycle.
|
|
198
|
+
*
|
|
199
|
+
* @throws An error thrown during the import of the XML.
|
|
200
|
+
*
|
|
201
|
+
* @param xml The BPMN 2.0 XML to be imported.
|
|
202
|
+
* @param bpmnDiagram The optional diagram or Id of the BPMN diagram to open.
|
|
203
|
+
*
|
|
204
|
+
* @return A promise resolving with warnings that were produced during the import.
|
|
205
|
+
*/
|
|
206
|
+
importXML(xml: string, bpmnDiagram?: ModdleElement | string): Promise<ImportXMLResult>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Import parsed definitions and render a BPMN 2.0 diagram.
|
|
210
|
+
*
|
|
211
|
+
* Once finished the viewer reports back the result to the
|
|
212
|
+
* provided callback function with (err, warnings).
|
|
213
|
+
*
|
|
214
|
+
* ## Life-Cycle Events
|
|
215
|
+
*
|
|
216
|
+
* During import the viewer will fire life-cycle events:
|
|
217
|
+
*
|
|
218
|
+
* * import.render.start (graphical import start)
|
|
219
|
+
* * import.render.complete (graphical import finished)
|
|
220
|
+
*
|
|
221
|
+
* You can use these events to hook into the life-cycle.
|
|
222
|
+
*
|
|
223
|
+
* @throws An error thrown during the import of the definitions.
|
|
224
|
+
*
|
|
225
|
+
* @param definitions The definitions.
|
|
226
|
+
* @param bpmnDiagram The optional diagram or ID of the BPMN diagram to open.
|
|
227
|
+
*
|
|
228
|
+
* @return A promise resolving with warnings that were produced during the import.
|
|
229
|
+
*/
|
|
230
|
+
importDefinitions(definitions: ModdleElement, bpmnDiagram?: ModdleElement | string): Promise<ImportDefinitionsResult>;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Open diagram of previously imported XML.
|
|
234
|
+
*
|
|
235
|
+
* Once finished the viewer reports back the result to the
|
|
236
|
+
* provided callback function with (err, warnings).
|
|
237
|
+
*
|
|
238
|
+
* ## Life-Cycle Events
|
|
239
|
+
*
|
|
240
|
+
* During switch the viewer will fire life-cycle events:
|
|
241
|
+
*
|
|
242
|
+
* * import.render.start (graphical import start)
|
|
243
|
+
* * import.render.complete (graphical import finished)
|
|
244
|
+
*
|
|
245
|
+
* You can use these events to hook into the life-cycle.
|
|
246
|
+
*
|
|
247
|
+
* @throws An error thrown during opening.
|
|
248
|
+
*
|
|
249
|
+
* @param bpmnDiagramOrId The diagram or Id of the BPMN diagram to open.
|
|
250
|
+
*
|
|
251
|
+
* @return A promise resolving with warnings that were produced during opening.
|
|
252
|
+
*/
|
|
253
|
+
open(bpmnDiagramOrId: ModdleElement | string): Promise<OpenResult>;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Export the currently displayed BPMN 2.0 diagram as
|
|
257
|
+
* a BPMN 2.0 XML document.
|
|
258
|
+
*
|
|
259
|
+
* ## Life-Cycle Events
|
|
260
|
+
*
|
|
261
|
+
* During XML saving the viewer will fire life-cycle events:
|
|
262
|
+
*
|
|
263
|
+
* * saveXML.start (before serialization)
|
|
264
|
+
* * saveXML.serialized (after xml generation)
|
|
265
|
+
* * saveXML.done (everything done)
|
|
266
|
+
*
|
|
267
|
+
* You can use these events to hook into the life-cycle.
|
|
268
|
+
*
|
|
269
|
+
* @throws An error thrown during export.
|
|
270
|
+
*
|
|
271
|
+
* @param options The options.
|
|
272
|
+
*
|
|
273
|
+
* @return A promise resolving with the XML.
|
|
274
|
+
*/
|
|
275
|
+
saveXML(options: SaveXMLOptions): Promise<SaveXMLResult>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Export the currently displayed BPMN 2.0 diagram as
|
|
279
|
+
* an SVG image.
|
|
280
|
+
*
|
|
281
|
+
* ## Life-Cycle Events
|
|
282
|
+
*
|
|
283
|
+
* During SVG saving the viewer will fire life-cycle events:
|
|
284
|
+
*
|
|
285
|
+
* * saveSVG.start (before serialization)
|
|
286
|
+
* * saveSVG.done (everything done)
|
|
287
|
+
*
|
|
288
|
+
* You can use these events to hook into the life-cycle.
|
|
289
|
+
*
|
|
290
|
+
* @throws An error thrown during export.
|
|
291
|
+
*
|
|
292
|
+
* @return A promise resolving with the SVG.
|
|
293
|
+
*/
|
|
294
|
+
saveSVG(): Promise<SaveSVGResult>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Return modules to instantiate with.
|
|
298
|
+
*
|
|
299
|
+
* @return The modules.
|
|
300
|
+
*/
|
|
301
|
+
getModules(): ModuleDeclaration[];
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Remove all drawn elements from the viewer.
|
|
305
|
+
*
|
|
306
|
+
* After calling this method the viewer can still be reused for opening another
|
|
307
|
+
* diagram.
|
|
308
|
+
*/
|
|
309
|
+
clear(): void;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Destroy the viewer instance and remove all its remainders from the document
|
|
313
|
+
* tree.
|
|
314
|
+
*/
|
|
315
|
+
destroy(): void;
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Register an event listener.
|
|
319
|
+
*
|
|
320
|
+
* Remove a previously added listener via {@link BaseViewer#off}.
|
|
321
|
+
*
|
|
322
|
+
* @param events The event(s) to listen to.
|
|
323
|
+
* @param callback The callback.
|
|
324
|
+
* @param that Value of `this` the callback will be called with.
|
|
325
|
+
*/
|
|
326
|
+
on<T extends Event>(events: string | string[], callback: EventCallback<T>, that?: any): void;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Register an event listener.
|
|
330
|
+
*
|
|
331
|
+
* Remove a previously added listener via {@link BaseViewer#off}.
|
|
332
|
+
*
|
|
333
|
+
* @param events The event(s) to listen to.
|
|
334
|
+
* @param priority The priority with which to listen.
|
|
335
|
+
* @param callback The callback.
|
|
336
|
+
* @param that Value of `this` the callback will be called with.
|
|
337
|
+
*/
|
|
338
|
+
on<T extends Event>(events: string | string[], priority: number, callback: EventCallback<T>, that?: any): void;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Remove an event listener.
|
|
342
|
+
*
|
|
343
|
+
* @param events The event(s).
|
|
344
|
+
* @param callback The callback.
|
|
345
|
+
*/
|
|
346
|
+
off(events: string | string[], callback?: EventCallback<any>): void;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Attach the viewer to an HTML element.
|
|
350
|
+
*
|
|
351
|
+
* @param parentNode The parent node to attach to.
|
|
352
|
+
*/
|
|
353
|
+
attachTo(parentNode: HTMLElement): void;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Get the definitions model element.
|
|
357
|
+
*
|
|
358
|
+
* @returns The definitions model element.
|
|
359
|
+
*/
|
|
360
|
+
getDefinitions(): ModdleElement | undefined;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Detach the viewer.
|
|
364
|
+
*/
|
|
365
|
+
detach(): void;
|
|
366
|
+
}
|