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/BaseViewer.js
CHANGED
|
@@ -37,7 +37,20 @@ import {
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* @typedef {
|
|
40
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
41
|
+
*
|
|
42
|
+
* @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
|
|
43
|
+
* @typedef {import('./BaseViewer').ModdleElement} ModdleElement
|
|
44
|
+
* @typedef {import('./BaseViewer').ImportXMLResult} ImportXMLResult
|
|
45
|
+
* @typedef {import('./BaseViewer').ImportXMLError} ImportXMLError
|
|
46
|
+
* @typedef {import('./BaseViewer').ImportDefinitionsResult} ImportDefinitionsResult
|
|
47
|
+
* @typedef {import('./BaseViewer').ImportDefinitionsError} ImportDefinitionsError
|
|
48
|
+
* @typedef {import('./BaseViewer').ModdleElement} ModdleElement
|
|
49
|
+
* @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
|
|
50
|
+
* @typedef {import('./BaseViewer').OpenResult} OpenResult
|
|
51
|
+
* @typedef {import('./BaseViewer').OpenError} OpenError
|
|
52
|
+
* @typedef {import('./BaseViewer').SaveXMLOptions} SaveXMLOptions
|
|
53
|
+
* @typedef {import('./BaseViewer').SaveXMLResult} SaveXMLResult
|
|
41
54
|
*/
|
|
42
55
|
|
|
43
56
|
/**
|
|
@@ -46,20 +59,20 @@ import {
|
|
|
46
59
|
* Have a look at {@link Viewer}, {@link NavigatedViewer} or {@link Modeler} for
|
|
47
60
|
* bundles that include actual features.
|
|
48
61
|
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
51
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
52
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
53
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
54
|
-
* @param {Module[]} [options.modules] a list of modules to override the default modules
|
|
55
|
-
* @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
|
|
62
|
+
* @param {BaseModelerOptions} [options] The options to configure the viewer.
|
|
56
63
|
*/
|
|
57
64
|
export default function BaseViewer(options) {
|
|
58
65
|
|
|
66
|
+
/**
|
|
67
|
+
* @type {BaseModelerOptions}
|
|
68
|
+
*/
|
|
59
69
|
options = assign({}, DEFAULT_OPTIONS, options);
|
|
60
70
|
|
|
61
71
|
this._moddle = this._createModdle(options);
|
|
62
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @type {HTMLElement}
|
|
75
|
+
*/
|
|
63
76
|
this._container = this._createContainer(options);
|
|
64
77
|
|
|
65
78
|
/* <project-logo> */
|
|
@@ -73,22 +86,6 @@ export default function BaseViewer(options) {
|
|
|
73
86
|
|
|
74
87
|
inherits(BaseViewer, Diagram);
|
|
75
88
|
|
|
76
|
-
/**
|
|
77
|
-
* The importXML result.
|
|
78
|
-
*
|
|
79
|
-
* @typedef {Object} ImportXMLResult
|
|
80
|
-
*
|
|
81
|
-
* @property {Array<string>} warnings
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The importXML error.
|
|
86
|
-
*
|
|
87
|
-
* @typedef {Error} ImportXMLError
|
|
88
|
-
*
|
|
89
|
-
* @property {Array<string>} warnings
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
89
|
/**
|
|
93
90
|
* Parse and render a BPMN 2.0 diagram.
|
|
94
91
|
*
|
|
@@ -99,7 +96,7 @@ inherits(BaseViewer, Diagram);
|
|
|
99
96
|
*
|
|
100
97
|
* During import the viewer will fire life-cycle events:
|
|
101
98
|
*
|
|
102
|
-
* * import.parse.start (about to read model from
|
|
99
|
+
* * import.parse.start (about to read model from XML)
|
|
103
100
|
* * import.parse.complete (model read; may have worked or not)
|
|
104
101
|
* * import.render.start (graphical import start)
|
|
105
102
|
* * import.render.complete (graphical import finished)
|
|
@@ -107,10 +104,18 @@ inherits(BaseViewer, Diagram);
|
|
|
107
104
|
*
|
|
108
105
|
* You can use these events to hook into the life-cycle.
|
|
109
106
|
*
|
|
110
|
-
* @
|
|
111
|
-
*
|
|
107
|
+
* @throws {ImportXMLError} An error thrown during the import of the XML.
|
|
108
|
+
*
|
|
109
|
+
* @fires BaseViewer#ImportParseStart
|
|
110
|
+
* @fires BaseViewer#ImportParseComplete
|
|
111
|
+
* @fires Importer#ImportRenderStart
|
|
112
|
+
* @fires Importer#ImportRenderComplete
|
|
113
|
+
* @fires BaseViewer#ImportDone
|
|
114
|
+
*
|
|
115
|
+
* @param {string} xml The BPMN 2.0 XML to be imported.
|
|
116
|
+
* @param {ModdleElement|string} [bpmnDiagram] The optional diagram or Id of the BPMN diagram to open.
|
|
112
117
|
*
|
|
113
|
-
*
|
|
118
|
+
* @return {Promise<ImportXMLResult>} A promise resolving with warnings that were produced during the import.
|
|
114
119
|
*/
|
|
115
120
|
BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
|
|
116
121
|
|
|
@@ -146,6 +151,14 @@ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(x
|
|
|
146
151
|
|
|
147
152
|
// hook in pre-parse listeners +
|
|
148
153
|
// allow xml manipulation
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* A `import.parse.start` event.
|
|
157
|
+
*
|
|
158
|
+
* @event BaseViewer#ImportParseStart
|
|
159
|
+
* @type {Object}
|
|
160
|
+
* @property {string} xml The XML that is to be parsed.
|
|
161
|
+
*/
|
|
149
162
|
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
|
150
163
|
|
|
151
164
|
let parseResult;
|
|
@@ -168,6 +181,18 @@ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(x
|
|
|
168
181
|
|
|
169
182
|
// hook in post parse listeners +
|
|
170
183
|
// allow definitions manipulation
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* A `import.parse.complete` event.
|
|
187
|
+
*
|
|
188
|
+
* @event BaseViewer#ImportParseComplete
|
|
189
|
+
* @type {Object}
|
|
190
|
+
* @property {Error|null} error An error thrown when parsing the XML.
|
|
191
|
+
* @property {ModdleElement} definitions The definitions model element.
|
|
192
|
+
* @property {ModdleElementsById} elementsById The model elements by ID.
|
|
193
|
+
* @property {ModdleElement[]} references The referenced model elements.
|
|
194
|
+
* @property {string[]} warnings The warnings produced when parsing the XML.
|
|
195
|
+
*/
|
|
171
196
|
definitions = this._emit('import.parse.complete', ParseCompleteEvent({
|
|
172
197
|
error: null,
|
|
173
198
|
definitions: definitions,
|
|
@@ -180,6 +205,14 @@ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(x
|
|
|
180
205
|
|
|
181
206
|
aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
|
|
182
207
|
|
|
208
|
+
/**
|
|
209
|
+
* A `import.parse.complete` event.
|
|
210
|
+
*
|
|
211
|
+
* @event BaseViewer#ImportDone
|
|
212
|
+
* @type {Object}
|
|
213
|
+
* @property {ImportXMLError|null} error An error thrown during import.
|
|
214
|
+
* @property {string[]} warnings The warnings.
|
|
215
|
+
*/
|
|
183
216
|
this._emit('import.done', { error: null, warnings: aggregatedWarnings });
|
|
184
217
|
|
|
185
218
|
return { warnings: aggregatedWarnings };
|
|
@@ -196,21 +229,6 @@ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(x
|
|
|
196
229
|
}
|
|
197
230
|
});
|
|
198
231
|
|
|
199
|
-
/**
|
|
200
|
-
* The importDefinitions result.
|
|
201
|
-
*
|
|
202
|
-
* @typedef {Object} ImportDefinitionsResult
|
|
203
|
-
*
|
|
204
|
-
* @property {Array<string>} warnings
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* The importDefinitions error.
|
|
209
|
-
*
|
|
210
|
-
* @typedef {Error} ImportDefinitionsError
|
|
211
|
-
*
|
|
212
|
-
* @property {Array<string>} warnings
|
|
213
|
-
*/
|
|
214
232
|
|
|
215
233
|
/**
|
|
216
234
|
* Import parsed definitions and render a BPMN 2.0 diagram.
|
|
@@ -227,10 +245,12 @@ BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(x
|
|
|
227
245
|
*
|
|
228
246
|
* You can use these events to hook into the life-cycle.
|
|
229
247
|
*
|
|
230
|
-
* @
|
|
231
|
-
* @param {ModdleElement<BPMNDiagram>|string} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
|
|
248
|
+
* @throws {ImportDefinitionsError} An error thrown during the import of the definitions.
|
|
232
249
|
*
|
|
233
|
-
*
|
|
250
|
+
* @param {ModdleElement} definitions The definitions.
|
|
251
|
+
* @param {ModdleElement|string} [bpmnDiagram] The optional diagram or ID of the BPMN diagram to open.
|
|
252
|
+
*
|
|
253
|
+
* @return {Promise<ImportDefinitionsResult>} A promise resolving with warnings that were produced during the import.
|
|
234
254
|
*/
|
|
235
255
|
BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
|
|
236
256
|
this._setDefinitions(definitions);
|
|
@@ -239,21 +259,6 @@ BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function imp
|
|
|
239
259
|
return { warnings: result.warnings };
|
|
240
260
|
});
|
|
241
261
|
|
|
242
|
-
/**
|
|
243
|
-
* The open result.
|
|
244
|
-
*
|
|
245
|
-
* @typedef {Object} OpenResult
|
|
246
|
-
*
|
|
247
|
-
* @property {Array<string>} warnings
|
|
248
|
-
*/
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* The open error.
|
|
252
|
-
*
|
|
253
|
-
* @typedef {Error} OpenError
|
|
254
|
-
*
|
|
255
|
-
* @property {Array<string>} warnings
|
|
256
|
-
*/
|
|
257
262
|
|
|
258
263
|
/**
|
|
259
264
|
* Open diagram of previously imported XML.
|
|
@@ -270,9 +275,11 @@ BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function imp
|
|
|
270
275
|
*
|
|
271
276
|
* You can use these events to hook into the life-cycle.
|
|
272
277
|
*
|
|
273
|
-
* @
|
|
278
|
+
* @throws {OpenError} An error thrown during opening.
|
|
279
|
+
*
|
|
280
|
+
* @param {ModdleElement|string} bpmnDiagramOrId The diagram or Id of the BPMN diagram to open.
|
|
274
281
|
*
|
|
275
|
-
*
|
|
282
|
+
* @return {Promise<OpenResult>} A promise resolving with warnings that were produced during opening.
|
|
276
283
|
*/
|
|
277
284
|
BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
|
|
278
285
|
|
|
@@ -313,14 +320,6 @@ BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagram
|
|
|
313
320
|
return { warnings };
|
|
314
321
|
});
|
|
315
322
|
|
|
316
|
-
/**
|
|
317
|
-
* The saveXML result.
|
|
318
|
-
*
|
|
319
|
-
* @typedef {Object} SaveXMLResult
|
|
320
|
-
*
|
|
321
|
-
* @property {string} xml
|
|
322
|
-
*/
|
|
323
|
-
|
|
324
323
|
/**
|
|
325
324
|
* Export the currently displayed BPMN 2.0 diagram as
|
|
326
325
|
* a BPMN 2.0 XML document.
|
|
@@ -335,11 +334,14 @@ BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagram
|
|
|
335
334
|
*
|
|
336
335
|
* You can use these events to hook into the life-cycle.
|
|
337
336
|
*
|
|
338
|
-
* @
|
|
339
|
-
*
|
|
340
|
-
* @
|
|
337
|
+
* @throws {Error} An error thrown during export.
|
|
338
|
+
*
|
|
339
|
+
* @fires BaseViewer#SaveXMLStart
|
|
340
|
+
* @fires BaseViewer#SaveXMLDone
|
|
341
341
|
*
|
|
342
|
-
*
|
|
342
|
+
* @param {SaveXMLOptions} [options] The options.
|
|
343
|
+
*
|
|
344
|
+
* @return {Promise<SaveXMLResult>} A promise resolving with the XML.
|
|
343
345
|
*/
|
|
344
346
|
BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
|
|
345
347
|
|
|
@@ -354,6 +356,14 @@ BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(optio
|
|
|
354
356
|
}
|
|
355
357
|
|
|
356
358
|
// allow to fiddle around with definitions
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* A `saveXML.start` event.
|
|
362
|
+
*
|
|
363
|
+
* @event BaseViewer#SaveXMLStart
|
|
364
|
+
* @type {Object}
|
|
365
|
+
* @property {ModdleElement} definitions The definitions model element.
|
|
366
|
+
*/
|
|
357
367
|
definitions = this._emit('saveXML.start', {
|
|
358
368
|
definitions
|
|
359
369
|
}) || definitions;
|
|
@@ -370,6 +380,14 @@ BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(optio
|
|
|
370
380
|
|
|
371
381
|
const result = error ? { error } : { xml };
|
|
372
382
|
|
|
383
|
+
/**
|
|
384
|
+
* A `saveXML.done` event.
|
|
385
|
+
*
|
|
386
|
+
* @event BaseViewer#SaveXMLDone
|
|
387
|
+
* @type {Object}
|
|
388
|
+
* @property {Error} [error] An error thrown when saving the XML.
|
|
389
|
+
* @property {string} [xml] The saved XML.
|
|
390
|
+
*/
|
|
373
391
|
this._emit('saveXML.done', result);
|
|
374
392
|
|
|
375
393
|
if (error) {
|
|
@@ -379,13 +397,6 @@ BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(optio
|
|
|
379
397
|
return result;
|
|
380
398
|
});
|
|
381
399
|
|
|
382
|
-
/**
|
|
383
|
-
* The saveSVG result.
|
|
384
|
-
*
|
|
385
|
-
* @typedef {Object} SaveSVGResult
|
|
386
|
-
*
|
|
387
|
-
* @property {string} svg
|
|
388
|
-
*/
|
|
389
400
|
|
|
390
401
|
/**
|
|
391
402
|
* Export the currently displayed BPMN 2.0 diagram as
|
|
@@ -400,11 +411,13 @@ BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(optio
|
|
|
400
411
|
*
|
|
401
412
|
* You can use these events to hook into the life-cycle.
|
|
402
413
|
*
|
|
403
|
-
* @
|
|
414
|
+
* @throws {Error} An error thrown during export.
|
|
404
415
|
*
|
|
405
|
-
*
|
|
416
|
+
* @fires BaseViewer#SaveSVGDone
|
|
417
|
+
*
|
|
418
|
+
* @return {Promise<SaveSVGResult>} A promise resolving with the SVG.
|
|
406
419
|
*/
|
|
407
|
-
BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(
|
|
420
|
+
BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG() {
|
|
408
421
|
this._emit('saveSVG.start');
|
|
409
422
|
|
|
410
423
|
let svg, err;
|
|
@@ -433,6 +446,14 @@ BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(optio
|
|
|
433
446
|
err = e;
|
|
434
447
|
}
|
|
435
448
|
|
|
449
|
+
/**
|
|
450
|
+
* A `saveSVG.done` event.
|
|
451
|
+
*
|
|
452
|
+
* @event BaseViewer#SaveSVGDone
|
|
453
|
+
* @type {Object}
|
|
454
|
+
* @property {Error} [error] An error thrown when saving the SVG.
|
|
455
|
+
* @property {string} [svg] The saved SVG.
|
|
456
|
+
*/
|
|
436
457
|
this._emit('saveSVG.done', {
|
|
437
458
|
error: err,
|
|
438
459
|
svg: svg
|
|
@@ -484,21 +505,17 @@ BaseViewer.prototype._setDefinitions = function(definitions) {
|
|
|
484
505
|
/**
|
|
485
506
|
* Return modules to instantiate with.
|
|
486
507
|
*
|
|
487
|
-
* @
|
|
488
|
-
*
|
|
489
|
-
* @return {Module[]}
|
|
508
|
+
* @return {ModuleDeclaration[]} The modules.
|
|
490
509
|
*/
|
|
491
|
-
BaseViewer.prototype.getModules = function(
|
|
510
|
+
BaseViewer.prototype.getModules = function() {
|
|
492
511
|
return this._modules;
|
|
493
512
|
};
|
|
494
513
|
|
|
495
514
|
/**
|
|
496
515
|
* Remove all drawn elements from the viewer.
|
|
497
516
|
*
|
|
498
|
-
* After calling this method the viewer can still
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
* @method BaseViewer#clear
|
|
517
|
+
* After calling this method the viewer can still be reused for opening another
|
|
518
|
+
* diagram.
|
|
502
519
|
*/
|
|
503
520
|
BaseViewer.prototype.clear = function() {
|
|
504
521
|
if (!this.getDefinitions()) {
|
|
@@ -512,8 +529,8 @@ BaseViewer.prototype.clear = function() {
|
|
|
512
529
|
};
|
|
513
530
|
|
|
514
531
|
/**
|
|
515
|
-
* Destroy the viewer instance and remove all its
|
|
516
|
-
*
|
|
532
|
+
* Destroy the viewer instance and remove all its remainders from the document
|
|
533
|
+
* tree.
|
|
517
534
|
*/
|
|
518
535
|
BaseViewer.prototype.destroy = function() {
|
|
519
536
|
|
|
@@ -525,29 +542,34 @@ BaseViewer.prototype.destroy = function() {
|
|
|
525
542
|
};
|
|
526
543
|
|
|
527
544
|
/**
|
|
528
|
-
* Register an event listener
|
|
545
|
+
* Register an event listener.
|
|
529
546
|
*
|
|
530
|
-
* Remove
|
|
547
|
+
* Remove an event listener via {@link BaseViewer#off}.
|
|
531
548
|
*
|
|
532
|
-
* @param {string} event
|
|
533
|
-
* @param {number} [priority]
|
|
534
|
-
* @param {
|
|
535
|
-
* @param {
|
|
549
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
550
|
+
* @param {number} [priority] The priority with which to listen.
|
|
551
|
+
* @param {EventCallback} callback The callback.
|
|
552
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
536
553
|
*/
|
|
537
|
-
BaseViewer.prototype.on = function(
|
|
538
|
-
return this.get('eventBus').on(
|
|
554
|
+
BaseViewer.prototype.on = function(events, priority, callback, that) {
|
|
555
|
+
return this.get('eventBus').on(events, priority, callback, that);
|
|
539
556
|
};
|
|
540
557
|
|
|
541
558
|
/**
|
|
542
|
-
*
|
|
559
|
+
* Remove an event listener.
|
|
543
560
|
*
|
|
544
|
-
* @param {string} event
|
|
545
|
-
* @param {Function} callback
|
|
561
|
+
* @param {string|string[]} events The event(s).
|
|
562
|
+
* @param {Function} [callback] The callback.
|
|
546
563
|
*/
|
|
547
|
-
BaseViewer.prototype.off = function(
|
|
548
|
-
this.get('eventBus').off(
|
|
564
|
+
BaseViewer.prototype.off = function(events, callback) {
|
|
565
|
+
this.get('eventBus').off(events, callback);
|
|
549
566
|
};
|
|
550
567
|
|
|
568
|
+
/**
|
|
569
|
+
* Attach the viewer to an HTML element.
|
|
570
|
+
*
|
|
571
|
+
* @param {HTMLElement} parentNode The parent node to attach to.
|
|
572
|
+
*/
|
|
551
573
|
BaseViewer.prototype.attachTo = function(parentNode) {
|
|
552
574
|
|
|
553
575
|
if (!parentNode) {
|
|
@@ -574,10 +596,20 @@ BaseViewer.prototype.attachTo = function(parentNode) {
|
|
|
574
596
|
this.get('canvas').resized();
|
|
575
597
|
};
|
|
576
598
|
|
|
599
|
+
/**
|
|
600
|
+
* Get the definitions model element.
|
|
601
|
+
*
|
|
602
|
+
* @returns {ModdleElement} The definitions model element.
|
|
603
|
+
*/
|
|
577
604
|
BaseViewer.prototype.getDefinitions = function() {
|
|
578
605
|
return this._definitions;
|
|
579
606
|
};
|
|
580
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Detach the viewer.
|
|
610
|
+
*
|
|
611
|
+
* @fires BaseViewer#DetachEvent
|
|
612
|
+
*/
|
|
581
613
|
BaseViewer.prototype.detach = function() {
|
|
582
614
|
|
|
583
615
|
const container = this._container,
|
|
@@ -587,6 +619,12 @@ BaseViewer.prototype.detach = function() {
|
|
|
587
619
|
return;
|
|
588
620
|
}
|
|
589
621
|
|
|
622
|
+
/**
|
|
623
|
+
* A `detach` event.
|
|
624
|
+
*
|
|
625
|
+
* @event BaseViewer#DetachEvent
|
|
626
|
+
* @type {Object}
|
|
627
|
+
*/
|
|
590
628
|
this._emit('detach', {});
|
|
591
629
|
|
|
592
630
|
parentNode.removeChild(container);
|
|
@@ -624,7 +662,7 @@ BaseViewer.prototype._init = function(container, moddle, options) {
|
|
|
624
662
|
* @param {string} type
|
|
625
663
|
* @param {Object} event
|
|
626
664
|
*
|
|
627
|
-
* @return {Object}
|
|
665
|
+
* @return {Object} The return value after calling all event listeners.
|
|
628
666
|
*/
|
|
629
667
|
BaseViewer.prototype._emit = function(type, event) {
|
|
630
668
|
return this.get('eventBus').fire(type, event);
|
package/lib/Modeler.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import BaseModeler from "./BaseModeler";
|
|
2
|
+
|
|
3
|
+
import { ImportXMLResult } from "./BaseViewer";
|
|
4
|
+
|
|
5
|
+
export default class Modeler extends BaseModeler {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a new diagram to start modeling.
|
|
9
|
+
*
|
|
10
|
+
* @throws An error thrown during the import of the XML.
|
|
11
|
+
*
|
|
12
|
+
* @return A promise resolving with warnings that were produced during the import.
|
|
13
|
+
*/
|
|
14
|
+
createDiagram(): Promise<ImportXMLResult>;
|
|
15
|
+
}
|
package/lib/Modeler.js
CHANGED
|
@@ -20,7 +20,6 @@ import ConnectionPreviewModule from 'diagram-js/lib/features/connection-preview'
|
|
|
20
20
|
import ContextPadModule from './features/context-pad';
|
|
21
21
|
import CopyPasteModule from './features/copy-paste';
|
|
22
22
|
import CreateModule from 'diagram-js/lib/features/create';
|
|
23
|
-
import CreateAppendAnythingModule from './features/create-append-anything';
|
|
24
23
|
import DistributeElementsModule from './features/distribute-elements';
|
|
25
24
|
import EditorActionsModule from './features/editor-actions';
|
|
26
25
|
import GridSnappingModule from './features/grid-snapping';
|
|
@@ -62,7 +61,8 @@ var initialDiagram =
|
|
|
62
61
|
|
|
63
62
|
|
|
64
63
|
/**
|
|
65
|
-
* @typedef {
|
|
64
|
+
* @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
|
|
65
|
+
* @typedef {import('./BaseViewer').ImportXMLResult} ImportXMLResult
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -129,13 +129,7 @@ var initialDiagram =
|
|
|
129
129
|
* var bpmnModeler = new Modeler({ additionalModules: [ overrideModule ]});
|
|
130
130
|
* ```
|
|
131
131
|
*
|
|
132
|
-
* @param {
|
|
133
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
134
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
135
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
136
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
137
|
-
* @param {Module[]} [options.modules] a list of modules to override the default modules
|
|
138
|
-
* @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
|
|
132
|
+
* @param {BaseModelerOptions} [options] The options to configure the modeler.
|
|
139
133
|
*/
|
|
140
134
|
export default function Modeler(options) {
|
|
141
135
|
BaseModeler.call(this, options);
|
|
@@ -147,26 +141,12 @@ inherits(Modeler, BaseModeler);
|
|
|
147
141
|
Modeler.Viewer = Viewer;
|
|
148
142
|
Modeler.NavigatedViewer = NavigatedViewer;
|
|
149
143
|
|
|
150
|
-
/**
|
|
151
|
-
* The createDiagram result.
|
|
152
|
-
*
|
|
153
|
-
* @typedef {Object} CreateDiagramResult
|
|
154
|
-
*
|
|
155
|
-
* @property {Array<string>} warnings
|
|
156
|
-
*/
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The createDiagram error.
|
|
160
|
-
*
|
|
161
|
-
* @typedef {Error} CreateDiagramError
|
|
162
|
-
*
|
|
163
|
-
* @property {Array<string>} warnings
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
144
|
/**
|
|
167
145
|
* Create a new diagram to start modeling.
|
|
168
146
|
*
|
|
169
|
-
*
|
|
147
|
+
* @throws {ImportXMLError} An error thrown during the import of the XML.
|
|
148
|
+
*
|
|
149
|
+
* @return {Promise<ImportXMLResult>} A promise resolving with warnings that were produced during the import.
|
|
170
150
|
*/
|
|
171
151
|
Modeler.prototype.createDiagram = wrapForCompatibility(function createDiagram() {
|
|
172
152
|
return this.importXML(initialDiagram);
|
|
@@ -195,7 +175,6 @@ Modeler.prototype._modelingModules = [
|
|
|
195
175
|
ContextPadModule,
|
|
196
176
|
CopyPasteModule,
|
|
197
177
|
CreateModule,
|
|
198
|
-
CreateAppendAnythingModule,
|
|
199
178
|
DistributeElementsModule,
|
|
200
179
|
EditorActionsModule,
|
|
201
180
|
GridSnappingModule,
|
package/lib/NavigatedViewer.js
CHANGED
|
@@ -6,11 +6,14 @@ import KeyboardMoveModule from 'diagram-js/lib/navigation/keyboard-move';
|
|
|
6
6
|
import MoveCanvasModule from 'diagram-js/lib/navigation/movecanvas';
|
|
7
7
|
import ZoomScrollModule from 'diagram-js/lib/navigation/zoomscroll';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @typedef { import('./BaseViewer').BaseViewerOptions } BaseViewerOptions
|
|
11
|
+
*/
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
|
-
* A viewer
|
|
14
|
+
* A viewer with mouse and keyboard navigation features.
|
|
12
15
|
*
|
|
13
|
-
* @param {
|
|
16
|
+
* @param {BaseViewerOptions} [options]
|
|
14
17
|
*/
|
|
15
18
|
export default function NavigatedViewer(options) {
|
|
16
19
|
Viewer.call(this, options);
|
package/lib/Viewer.d.ts
ADDED
package/lib/Viewer.js
CHANGED
|
@@ -10,7 +10,7 @@ import BaseViewer from './BaseViewer';
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* @typedef { import('
|
|
13
|
+
* @typedef { import('./BaseViewer').BaseViewerOptions } BaseViewerOptions
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -52,13 +52,7 @@ import BaseViewer from './BaseViewer';
|
|
|
52
52
|
* bpmnViewer.importXML(...);
|
|
53
53
|
* ```
|
|
54
54
|
*
|
|
55
|
-
* @param {
|
|
56
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
57
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
58
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
59
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
60
|
-
* @param {Module[]} [options.modules] a list of modules to override the default modules
|
|
61
|
-
* @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
|
|
55
|
+
* @param {BaseViewerOptions} [options] The options to configure the viewer.
|
|
62
56
|
*/
|
|
63
57
|
export default function Viewer(options) {
|
|
64
58
|
BaseViewer.call(this, options);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M150%25201650h1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%25221300%2522%2520x%253D%2522150%2522%2520y%253D%2522350%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%2522800%2522%2520x%253D%25221050%2522%2520y%253D%2522850%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M900%2520150v1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522600%2522%2520x%253D%2522250%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522800%2522%2520height%253D%2522600%2522%2520x%253D%2522500%2522%2520y%253D%25221050%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M100%2520150v1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522600%2522%2520x%253D%2522100%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522800%2522%2520height%253D%2522600%2522%2520x%253D%2522100%2522%2520y%253D%25221050%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M1650%2520150v1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522600%2522%2520x%253D%2522350%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522800%2522%2520height%253D%2522600%2522%2520x%253D%2522850%2522%2520y%253D%25221050%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25202000%25202000%2522%253E%253Cpath%2520d%253D%2522M200%2520150v1700%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%25221300%2522%2520height%253D%2522700%2522%2520x%253D%2522500%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522700%2522%2520height%253D%2522700%2522%2520x%253D%2522500%2522%2520y%253D%25221150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M150%2520150h1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%25221300%2522%2520x%253D%2522150%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%2522800%2522%2520x%253D%25221050%2522%2520y%253D%2522150%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
data:image/svg+xml,data%3Aimage%2Fsvg%2Bxml%2C%253Csvg%2520xmlns%253D%2522http%253A%252F%252Fwww.w3.org%252F2000%252Fsvg%2522%2520viewBox%253D%25220%25200%25201800%25201800%2522%253E%253Cpath%2520d%253D%2522M150%2520900h1500%2522%2520style%253D%2522stroke%253AcurrentColor%253Bstroke-width%253A100%253Bstroke-linecap%253Around%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%25221300%2522%2520x%253D%2522150%2522%2520y%253D%2522250%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253Anone%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%2522%252F%253E%253Crect%2520width%253D%2522600%2522%2520height%253D%2522800%2522%2520x%253D%25221050%2522%2520y%253D%2522500%2522%2520rx%253D%25221%2522%2520style%253D%2522fill%253AcurrentColor%253Bstroke%253AcurrentColor%253Bstroke-width%253A100%253Bopacity%253A.5%2522%252F%253E%253C%252Fsvg%253E
|
|
@@ -87,8 +87,12 @@ export default function RootElementReferenceBehavior(
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
// create shape
|
|
90
|
-
this.executed(
|
|
91
|
-
|
|
90
|
+
this.executed([
|
|
91
|
+
'shape.create',
|
|
92
|
+
'element.updateProperties',
|
|
93
|
+
'element.updateModdleProperties'
|
|
94
|
+
], function(context) {
|
|
95
|
+
var shape = context.shape || context.element;
|
|
92
96
|
|
|
93
97
|
if (!canHaveRootElementReference(shape)) {
|
|
94
98
|
return;
|
|
@@ -108,7 +112,11 @@ export default function RootElementReferenceBehavior(
|
|
|
108
112
|
}
|
|
109
113
|
}, true);
|
|
110
114
|
|
|
111
|
-
this.reverted(
|
|
115
|
+
this.reverted([
|
|
116
|
+
'shape.create',
|
|
117
|
+
'element.updateProperties',
|
|
118
|
+
'element.updateModdleProperties'
|
|
119
|
+
], function(context) {
|
|
112
120
|
var addedRootElement = context.addedRootElement;
|
|
113
121
|
|
|
114
122
|
if (!addedRootElement) {
|