bpmn-js 11.5.0 → 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 +5337 -5375
- 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/palette/dist/create.svg +1 -0
- package/lib/features/replace/BpmnReplace.js +3 -12
- package/package.json +13 -10
- 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/resources/append.svg +0 -3
- package/lib/icons/resources/create.svg +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* bpmn-js - bpmn-navigated-viewer
|
|
2
|
+
* bpmn-js - bpmn-navigated-viewer v12.0.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2014-present, camunda Services GmbH
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Source Code: https://github.com/bpmn-io/bpmn-js
|
|
10
10
|
*
|
|
11
|
-
* Date: 2023-
|
|
11
|
+
* Date: 2023-03-29
|
|
12
12
|
*/
|
|
13
13
|
(function (global, factory) {
|
|
14
14
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -447,6 +447,14 @@
|
|
|
447
447
|
|
|
448
448
|
var DEFAULT_RENDER_PRIORITY$1 = 1000;
|
|
449
449
|
|
|
450
|
+
/**
|
|
451
|
+
* @typedef {import('../model').Base} Base
|
|
452
|
+
* @typedef {import('../model').Connection} Connection
|
|
453
|
+
* @typedef {import('../model').Shape} Shape
|
|
454
|
+
*
|
|
455
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
456
|
+
*/
|
|
457
|
+
|
|
450
458
|
/**
|
|
451
459
|
* The base implementation of shape and connection renderers.
|
|
452
460
|
*
|
|
@@ -485,52 +493,51 @@
|
|
|
485
493
|
}
|
|
486
494
|
|
|
487
495
|
/**
|
|
488
|
-
*
|
|
489
|
-
* the element/connection.
|
|
496
|
+
* Checks whether an element can be rendered.
|
|
490
497
|
*
|
|
491
|
-
* @param {
|
|
498
|
+
* @param {Base} element The element to be rendered.
|
|
492
499
|
*
|
|
493
|
-
* @returns {boolean}
|
|
500
|
+
* @returns {boolean} Whether the element can be rendered.
|
|
494
501
|
*/
|
|
495
|
-
BaseRenderer.prototype.canRender = function() {};
|
|
502
|
+
BaseRenderer.prototype.canRender = function(element) {};
|
|
496
503
|
|
|
497
504
|
/**
|
|
498
|
-
*
|
|
505
|
+
* Draws a shape.
|
|
499
506
|
*
|
|
500
|
-
* @param {
|
|
501
|
-
* @param {Shape} shape
|
|
507
|
+
* @param {SVGElement} visuals The SVG element to draw the shape into.
|
|
508
|
+
* @param {Shape} shape The shape to be drawn.
|
|
502
509
|
*
|
|
503
|
-
* @returns {
|
|
510
|
+
* @returns {SVGElement} The SVG element of the shape drawn.
|
|
504
511
|
*/
|
|
505
|
-
BaseRenderer.prototype.drawShape = function() {};
|
|
512
|
+
BaseRenderer.prototype.drawShape = function(visuals, shape) {};
|
|
506
513
|
|
|
507
514
|
/**
|
|
508
|
-
*
|
|
515
|
+
* Draws a connection.
|
|
509
516
|
*
|
|
510
|
-
* @param {
|
|
511
|
-
* @param {Connection} connection
|
|
517
|
+
* @param {SVGElement} visuals The SVG element to draw the connection into.
|
|
518
|
+
* @param {Connection} connection The connection to be drawn.
|
|
512
519
|
*
|
|
513
|
-
* @returns {
|
|
520
|
+
* @returns {SVGElement} The SVG element of the connection drawn.
|
|
514
521
|
*/
|
|
515
|
-
BaseRenderer.prototype.drawConnection = function() {};
|
|
522
|
+
BaseRenderer.prototype.drawConnection = function(visuals, connection) {};
|
|
516
523
|
|
|
517
524
|
/**
|
|
518
|
-
* Gets the SVG path of
|
|
525
|
+
* Gets the SVG path of the graphical representation of a shape.
|
|
519
526
|
*
|
|
520
|
-
* @param {Shape} shape
|
|
527
|
+
* @param {Shape} shape The shape.
|
|
521
528
|
*
|
|
522
|
-
* @return {string}
|
|
529
|
+
* @return {string} The SVG path of the shape.
|
|
523
530
|
*/
|
|
524
|
-
BaseRenderer.prototype.getShapePath = function() {};
|
|
531
|
+
BaseRenderer.prototype.getShapePath = function(shape) {};
|
|
525
532
|
|
|
526
533
|
/**
|
|
527
|
-
* Gets the SVG path of
|
|
534
|
+
* Gets the SVG path of the graphical representation of a connection.
|
|
528
535
|
*
|
|
529
|
-
* @param {Connection} connection
|
|
536
|
+
* @param {Connection} connection The connection.
|
|
530
537
|
*
|
|
531
|
-
* @return {string}
|
|
538
|
+
* @return {string} The SVG path of the connection.
|
|
532
539
|
*/
|
|
533
|
-
BaseRenderer.prototype.getConnectionPath = function() {};
|
|
540
|
+
BaseRenderer.prototype.getConnectionPath = function(connection) {};
|
|
534
541
|
|
|
535
542
|
/**
|
|
536
543
|
* Is an element of the given BPMN type?
|
|
@@ -1337,9 +1344,15 @@
|
|
|
1337
1344
|
}
|
|
1338
1345
|
|
|
1339
1346
|
/**
|
|
1340
|
-
* @
|
|
1347
|
+
* @typedef {(string|number)[]} Component
|
|
1341
1348
|
*
|
|
1342
|
-
* @
|
|
1349
|
+
* @typedef {import('../util/Types').Point} Point
|
|
1350
|
+
*/
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* @param {Component[]} elements
|
|
1354
|
+
*
|
|
1355
|
+
* @return {string}
|
|
1343
1356
|
*/
|
|
1344
1357
|
function componentsToPath(elements) {
|
|
1345
1358
|
return elements.flat().join(',').replace(/,?([A-z]),?/g, '$1');
|
|
@@ -1419,9 +1432,9 @@
|
|
|
1419
1432
|
}
|
|
1420
1433
|
|
|
1421
1434
|
/**
|
|
1422
|
-
* @param {
|
|
1423
|
-
* @param {
|
|
1424
|
-
* @param {
|
|
1435
|
+
* @param {Point[]} points
|
|
1436
|
+
* @param {*} [attrs]
|
|
1437
|
+
* @param {number} [radius]
|
|
1425
1438
|
*
|
|
1426
1439
|
* @return {SVGElement}
|
|
1427
1440
|
*/
|
|
@@ -1446,8 +1459,8 @@
|
|
|
1446
1459
|
}
|
|
1447
1460
|
|
|
1448
1461
|
/**
|
|
1449
|
-
* @param {
|
|
1450
|
-
* @param {
|
|
1462
|
+
* @param {SVGElement} gfx
|
|
1463
|
+
* @param {Point[]} points
|
|
1451
1464
|
*
|
|
1452
1465
|
* @return {SVGElement}
|
|
1453
1466
|
*/
|
|
@@ -2162,7 +2175,7 @@
|
|
|
2162
2175
|
}
|
|
2163
2176
|
|
|
2164
2177
|
/**
|
|
2165
|
-
* @param {
|
|
2178
|
+
* @param {SVGElement} element
|
|
2166
2179
|
* @param {number} x
|
|
2167
2180
|
* @param {number} y
|
|
2168
2181
|
* @param {number} angle
|
|
@@ -4242,6 +4255,10 @@
|
|
|
4242
4255
|
return getRectPath(element);
|
|
4243
4256
|
};
|
|
4244
4257
|
|
|
4258
|
+
/**
|
|
4259
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
4260
|
+
*/
|
|
4261
|
+
|
|
4245
4262
|
var DEFAULT_BOX_PADDING = 0;
|
|
4246
4263
|
|
|
4247
4264
|
var DEFAULT_LABEL_SIZE$1 = {
|
|
@@ -4315,7 +4332,8 @@
|
|
|
4315
4332
|
*
|
|
4316
4333
|
* Alters the lines passed.
|
|
4317
4334
|
*
|
|
4318
|
-
* @param
|
|
4335
|
+
* @param {string[]} lines
|
|
4336
|
+
*
|
|
4319
4337
|
* @return {Object} the line descriptor, an object { width, height, text }
|
|
4320
4338
|
*/
|
|
4321
4339
|
function layoutNext(lines, maxWidth, fakeText) {
|
|
@@ -4360,8 +4378,9 @@
|
|
|
4360
4378
|
* Shortens a line based on spacing and hyphens.
|
|
4361
4379
|
* Returns the shortened result on success.
|
|
4362
4380
|
*
|
|
4363
|
-
* @param
|
|
4364
|
-
* @param
|
|
4381
|
+
* @param {string} line
|
|
4382
|
+
* @param {number} maxLength the maximum characters of the string
|
|
4383
|
+
*
|
|
4365
4384
|
* @return {string} the shortened string
|
|
4366
4385
|
*/
|
|
4367
4386
|
function semanticShorten(line, maxLength) {
|
|
@@ -5201,6 +5220,10 @@
|
|
|
5201
5220
|
pathMap: [ 'type', PathMap ]
|
|
5202
5221
|
};
|
|
5203
5222
|
|
|
5223
|
+
/**
|
|
5224
|
+
* @typedef {import('./').Replacements} Replacements
|
|
5225
|
+
*/
|
|
5226
|
+
|
|
5204
5227
|
/**
|
|
5205
5228
|
* A simple translation stub to be used for multi-language support
|
|
5206
5229
|
* in diagrams. Can be easily replaced with a more sophisticated
|
|
@@ -5215,7 +5238,7 @@
|
|
|
5215
5238
|
* }
|
|
5216
5239
|
*
|
|
5217
5240
|
* @param {string} template to interpolate
|
|
5218
|
-
* @param {
|
|
5241
|
+
* @param {Replacements} [replacements] a map with substitutes
|
|
5219
5242
|
*
|
|
5220
5243
|
* @return {string} the translated string
|
|
5221
5244
|
*/
|
|
@@ -5368,8 +5391,6 @@
|
|
|
5368
5391
|
}, size);
|
|
5369
5392
|
}
|
|
5370
5393
|
|
|
5371
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5372
|
-
|
|
5373
5394
|
function getDefaultExportFromCjs (x) {
|
|
5374
5395
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5375
5396
|
}
|
|
@@ -5386,9 +5407,9 @@
|
|
|
5386
5407
|
/**
|
|
5387
5408
|
* Convert the given bounds to a { top, left, bottom, right } descriptor.
|
|
5388
5409
|
*
|
|
5389
|
-
* @param {
|
|
5410
|
+
* @param {Point|Rect} bounds
|
|
5390
5411
|
*
|
|
5391
|
-
* @return {
|
|
5412
|
+
* @return {RectTRBL}
|
|
5392
5413
|
*/
|
|
5393
5414
|
function asTRBL(bounds) {
|
|
5394
5415
|
return {
|
|
@@ -5403,9 +5424,9 @@
|
|
|
5403
5424
|
/**
|
|
5404
5425
|
* Convert a { top, left, bottom, right } to an objects bounds.
|
|
5405
5426
|
*
|
|
5406
|
-
* @param {
|
|
5427
|
+
* @param {RectTRBL} trbl
|
|
5407
5428
|
*
|
|
5408
|
-
* @return {
|
|
5429
|
+
* @return {Rect}
|
|
5409
5430
|
*/
|
|
5410
5431
|
function asBounds(trbl) {
|
|
5411
5432
|
return {
|
|
@@ -5420,7 +5441,7 @@
|
|
|
5420
5441
|
/**
|
|
5421
5442
|
* Get the mid of the given bounds or point.
|
|
5422
5443
|
*
|
|
5423
|
-
* @param {
|
|
5444
|
+
* @param {Point|Rect} bounds
|
|
5424
5445
|
*
|
|
5425
5446
|
* @return {Point}
|
|
5426
5447
|
*/
|
|
@@ -5435,7 +5456,7 @@
|
|
|
5435
5456
|
/**
|
|
5436
5457
|
* Get the mid of the given Connection.
|
|
5437
5458
|
*
|
|
5438
|
-
* @param {
|
|
5459
|
+
* @param {Connection} connection
|
|
5439
5460
|
*
|
|
5440
5461
|
* @return {Point}
|
|
5441
5462
|
*/
|
|
@@ -5494,7 +5515,7 @@
|
|
|
5494
5515
|
/**
|
|
5495
5516
|
* Get the mid of the given Element.
|
|
5496
5517
|
*
|
|
5497
|
-
* @param {
|
|
5518
|
+
* @param {Connection} connection
|
|
5498
5519
|
*
|
|
5499
5520
|
* @return {Point}
|
|
5500
5521
|
*/
|
|
@@ -5921,6 +5942,14 @@
|
|
|
5921
5942
|
return isPrimaryButton(event) && originalEvent.shiftKey;
|
|
5922
5943
|
}
|
|
5923
5944
|
|
|
5945
|
+
/**
|
|
5946
|
+
* @typedef {import('../../model').Base} Base
|
|
5947
|
+
*
|
|
5948
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
5949
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
5950
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
5951
|
+
*/
|
|
5952
|
+
|
|
5924
5953
|
function allowAll(event) { return true; }
|
|
5925
5954
|
|
|
5926
5955
|
function allowPrimaryAndAuxiliary(event) {
|
|
@@ -5950,6 +5979,8 @@
|
|
|
5950
5979
|
* prevents the original DOM operation.
|
|
5951
5980
|
*
|
|
5952
5981
|
* @param {EventBus} eventBus
|
|
5982
|
+
* @param {ElementRegistry} elementRegistry
|
|
5983
|
+
* @param {Styles} styles
|
|
5953
5984
|
*/
|
|
5954
5985
|
function InteractionEvents(eventBus, elementRegistry, styles) {
|
|
5955
5986
|
|
|
@@ -5959,8 +5990,8 @@
|
|
|
5959
5990
|
* Fire an interaction event.
|
|
5960
5991
|
*
|
|
5961
5992
|
* @param {string} type local event name, e.g. element.click.
|
|
5962
|
-
* @param {
|
|
5963
|
-
* @param {
|
|
5993
|
+
* @param {MouseEvent|TouchEvent} event native event
|
|
5994
|
+
* @param {Base} [element] the diagram element to emit the event on;
|
|
5964
5995
|
* defaults to the event target
|
|
5965
5996
|
*/
|
|
5966
5997
|
function fire(type, event, element) {
|
|
@@ -6042,8 +6073,8 @@
|
|
|
6042
6073
|
* on the target shape or connection.
|
|
6043
6074
|
*
|
|
6044
6075
|
* @param {string} eventName the name of the triggered DOM event
|
|
6045
|
-
* @param {MouseEvent} event
|
|
6046
|
-
* @param {
|
|
6076
|
+
* @param {MouseEvent|TouchEvent} event
|
|
6077
|
+
* @param {Base} targetElement
|
|
6047
6078
|
*/
|
|
6048
6079
|
function triggerMouseEvent(eventName, event, targetElement) {
|
|
6049
6080
|
|
|
@@ -6209,7 +6240,7 @@
|
|
|
6209
6240
|
/**
|
|
6210
6241
|
* Create default hit for the given element.
|
|
6211
6242
|
*
|
|
6212
|
-
* @param {
|
|
6243
|
+
* @param {Base} element
|
|
6213
6244
|
* @param {SVGElement} gfx
|
|
6214
6245
|
*
|
|
6215
6246
|
* @return {SVGElement} created hit
|
|
@@ -6281,8 +6312,8 @@
|
|
|
6281
6312
|
/**
|
|
6282
6313
|
* Update default hit of the element.
|
|
6283
6314
|
*
|
|
6284
|
-
* @param
|
|
6285
|
-
* @param
|
|
6315
|
+
* @param {Base} element
|
|
6316
|
+
* @param {SVGElement} gfx
|
|
6286
6317
|
*
|
|
6287
6318
|
* @return {SVGElement} updated hit
|
|
6288
6319
|
*/
|
|
@@ -6330,7 +6361,7 @@
|
|
|
6330
6361
|
* @event element.hover
|
|
6331
6362
|
*
|
|
6332
6363
|
* @type {Object}
|
|
6333
|
-
* @property {
|
|
6364
|
+
* @property {Base} element
|
|
6334
6365
|
* @property {SVGElement} gfx
|
|
6335
6366
|
* @property {Event} originalEvent
|
|
6336
6367
|
*/
|
|
@@ -6341,7 +6372,7 @@
|
|
|
6341
6372
|
* @event element.out
|
|
6342
6373
|
*
|
|
6343
6374
|
* @type {Object}
|
|
6344
|
-
* @property {
|
|
6375
|
+
* @property {Base} element
|
|
6345
6376
|
* @property {SVGElement} gfx
|
|
6346
6377
|
* @property {Event} originalEvent
|
|
6347
6378
|
*/
|
|
@@ -6352,7 +6383,7 @@
|
|
|
6352
6383
|
* @event element.click
|
|
6353
6384
|
*
|
|
6354
6385
|
* @type {Object}
|
|
6355
|
-
* @property {
|
|
6386
|
+
* @property {Base} element
|
|
6356
6387
|
* @property {SVGElement} gfx
|
|
6357
6388
|
* @property {Event} originalEvent
|
|
6358
6389
|
*/
|
|
@@ -6363,7 +6394,7 @@
|
|
|
6363
6394
|
* @event element.dblclick
|
|
6364
6395
|
*
|
|
6365
6396
|
* @type {Object}
|
|
6366
|
-
* @property {
|
|
6397
|
+
* @property {Base} element
|
|
6367
6398
|
* @property {SVGElement} gfx
|
|
6368
6399
|
* @property {Event} originalEvent
|
|
6369
6400
|
*/
|
|
@@ -6374,7 +6405,7 @@
|
|
|
6374
6405
|
* @event element.mousedown
|
|
6375
6406
|
*
|
|
6376
6407
|
* @type {Object}
|
|
6377
|
-
* @property {
|
|
6408
|
+
* @property {Base} element
|
|
6378
6409
|
* @property {SVGElement} gfx
|
|
6379
6410
|
* @property {Event} originalEvent
|
|
6380
6411
|
*/
|
|
@@ -6385,7 +6416,7 @@
|
|
|
6385
6416
|
* @event element.mouseup
|
|
6386
6417
|
*
|
|
6387
6418
|
* @type {Object}
|
|
6388
|
-
* @property {
|
|
6419
|
+
* @property {Base} element
|
|
6389
6420
|
* @property {SVGElement} gfx
|
|
6390
6421
|
* @property {Event} originalEvent
|
|
6391
6422
|
*/
|
|
@@ -6397,7 +6428,7 @@
|
|
|
6397
6428
|
* @event element.contextmenu
|
|
6398
6429
|
*
|
|
6399
6430
|
* @type {Object}
|
|
6400
|
-
* @property {
|
|
6431
|
+
* @property {Base} element
|
|
6401
6432
|
* @property {SVGElement} gfx
|
|
6402
6433
|
* @property {Event} originalEvent
|
|
6403
6434
|
*/
|
|
@@ -6411,10 +6442,10 @@
|
|
|
6411
6442
|
* Returns the surrounding bbox for all elements in
|
|
6412
6443
|
* the array or the element primitive.
|
|
6413
6444
|
*
|
|
6414
|
-
* @param {
|
|
6445
|
+
* @param {Base|Base[]} elements
|
|
6415
6446
|
* @param {boolean} [stopRecursion=false]
|
|
6416
6447
|
*
|
|
6417
|
-
* @return {
|
|
6448
|
+
* @return {Rect}
|
|
6418
6449
|
*/
|
|
6419
6450
|
function getBBox(elements, stopRecursion) {
|
|
6420
6451
|
|
|
@@ -6485,6 +6516,12 @@
|
|
|
6485
6516
|
|
|
6486
6517
|
var LOW_PRIORITY$3 = 500;
|
|
6487
6518
|
|
|
6519
|
+
/**
|
|
6520
|
+
* @typedef {import('../../model').Base} Base
|
|
6521
|
+
*
|
|
6522
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6523
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
6524
|
+
*/
|
|
6488
6525
|
|
|
6489
6526
|
/**
|
|
6490
6527
|
* @class
|
|
@@ -6494,9 +6531,8 @@
|
|
|
6494
6531
|
*
|
|
6495
6532
|
* @param {EventBus} eventBus
|
|
6496
6533
|
* @param {Styles} styles
|
|
6497
|
-
* @param {ElementRegistry} elementRegistry
|
|
6498
6534
|
*/
|
|
6499
|
-
function Outline(eventBus, styles
|
|
6535
|
+
function Outline(eventBus, styles) {
|
|
6500
6536
|
|
|
6501
6537
|
this.offset = 6;
|
|
6502
6538
|
|
|
@@ -6554,8 +6590,8 @@
|
|
|
6554
6590
|
* Updates the outline of a shape respecting the dimension of the
|
|
6555
6591
|
* element and an outline offset.
|
|
6556
6592
|
*
|
|
6557
|
-
* @param
|
|
6558
|
-
* @param
|
|
6593
|
+
* @param {SVGElement} outline
|
|
6594
|
+
* @param {Base} element
|
|
6559
6595
|
*/
|
|
6560
6596
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6561
6597
|
|
|
@@ -6573,8 +6609,8 @@
|
|
|
6573
6609
|
* Updates the outline of a connection respecting the bounding box of
|
|
6574
6610
|
* the connection and an outline offset.
|
|
6575
6611
|
*
|
|
6576
|
-
* @param
|
|
6577
|
-
* @param
|
|
6612
|
+
* @param {SVGElement} outline
|
|
6613
|
+
* @param {Base} element
|
|
6578
6614
|
*/
|
|
6579
6615
|
Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
|
6580
6616
|
|
|
@@ -6597,13 +6633,17 @@
|
|
|
6597
6633
|
outline: [ 'type', Outline ]
|
|
6598
6634
|
};
|
|
6599
6635
|
|
|
6636
|
+
/**
|
|
6637
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6638
|
+
*/
|
|
6639
|
+
|
|
6600
6640
|
/**
|
|
6601
6641
|
* A service that offers the current selection in a diagram.
|
|
6602
6642
|
* Offers the api to control the selection, too.
|
|
6603
6643
|
*
|
|
6604
6644
|
* @class
|
|
6605
6645
|
*
|
|
6606
|
-
* @param {EventBus} eventBus
|
|
6646
|
+
* @param {EventBus} eventBus
|
|
6607
6647
|
*/
|
|
6608
6648
|
function Selection(eventBus, canvas) {
|
|
6609
6649
|
|
|
@@ -6659,8 +6699,8 @@
|
|
|
6659
6699
|
*
|
|
6660
6700
|
* @method Selection#select
|
|
6661
6701
|
*
|
|
6662
|
-
* @param
|
|
6663
|
-
* @param
|
|
6702
|
+
* @param {Object|Object[]} elements element or array of elements to be selected
|
|
6703
|
+
* @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
|
|
6664
6704
|
*/
|
|
6665
6705
|
Selection.prototype.select = function(elements, add) {
|
|
6666
6706
|
var selectedElements = this._selectedElements,
|
|
@@ -6699,6 +6739,12 @@
|
|
|
6699
6739
|
this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
|
6700
6740
|
};
|
|
6701
6741
|
|
|
6742
|
+
/**
|
|
6743
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6744
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6745
|
+
* @typedef {import('./Selection').default} Selection
|
|
6746
|
+
*/
|
|
6747
|
+
|
|
6702
6748
|
var MARKER_HOVER = 'hover',
|
|
6703
6749
|
MARKER_SELECTED = 'selected';
|
|
6704
6750
|
|
|
@@ -6715,6 +6761,7 @@
|
|
|
6715
6761
|
*
|
|
6716
6762
|
* @param {Canvas} canvas
|
|
6717
6763
|
* @param {EventBus} eventBus
|
|
6764
|
+
* @param {Selection} selection
|
|
6718
6765
|
*/
|
|
6719
6766
|
function SelectionVisuals(canvas, eventBus, selection) {
|
|
6720
6767
|
this._canvas = canvas;
|
|
@@ -6820,6 +6867,19 @@
|
|
|
6820
6867
|
};
|
|
6821
6868
|
}
|
|
6822
6869
|
|
|
6870
|
+
/**
|
|
6871
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6872
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
6873
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6874
|
+
* @typedef {import('./Selection').default} Selection
|
|
6875
|
+
*/
|
|
6876
|
+
|
|
6877
|
+
/**
|
|
6878
|
+
* @param {EventBus} eventBus
|
|
6879
|
+
* @param {Selection} selection
|
|
6880
|
+
* @param {Canvas} canvas
|
|
6881
|
+
* @param {ElementRegistry} elementRegistry
|
|
6882
|
+
*/
|
|
6823
6883
|
function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
|
6824
6884
|
|
|
6825
6885
|
// Select elements on create
|
|
@@ -6940,9 +7000,8 @@
|
|
|
6940
7000
|
/**
|
|
6941
7001
|
* Util that provides unique IDs.
|
|
6942
7002
|
*
|
|
6943
|
-
* @class
|
|
7003
|
+
* @class
|
|
6944
7004
|
* @constructor
|
|
6945
|
-
* @memberOf djs.util
|
|
6946
7005
|
*
|
|
6947
7006
|
* The ids can be customized via a given prefix and contain a random value to avoid collisions.
|
|
6948
7007
|
*
|
|
@@ -6957,8 +7016,6 @@
|
|
|
6957
7016
|
/**
|
|
6958
7017
|
* Returns a next unique ID.
|
|
6959
7018
|
*
|
|
6960
|
-
* @method djs.util.IdGenerator#next
|
|
6961
|
-
*
|
|
6962
7019
|
* @returns {string} the id
|
|
6963
7020
|
*/
|
|
6964
7021
|
IdGenerator.prototype.next = function() {
|
|
@@ -6970,6 +7027,18 @@
|
|
|
6970
7027
|
|
|
6971
7028
|
var LOW_PRIORITY$2 = 500;
|
|
6972
7029
|
|
|
7030
|
+
/**
|
|
7031
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7032
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7033
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7034
|
+
*
|
|
7035
|
+
* @typedef {import('./Overlays').Overlay} Overlay
|
|
7036
|
+
* @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
|
|
7037
|
+
* @typedef {import('./Overlays').OverlayContainer} OverlayContainer
|
|
7038
|
+
* @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
|
|
7039
|
+
* @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
|
|
7040
|
+
* @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
|
|
7041
|
+
*/
|
|
6973
7042
|
|
|
6974
7043
|
/**
|
|
6975
7044
|
* A service that allows users to attach overlays to diagram elements.
|
|
@@ -6979,6 +7048,7 @@
|
|
|
6979
7048
|
* @example
|
|
6980
7049
|
*
|
|
6981
7050
|
* // add a pink badge on the top left of the shape
|
|
7051
|
+
*
|
|
6982
7052
|
* overlays.add(someShape, {
|
|
6983
7053
|
* position: {
|
|
6984
7054
|
* top: -5,
|
|
@@ -7030,19 +7100,21 @@
|
|
|
7030
7100
|
* }
|
|
7031
7101
|
* }
|
|
7032
7102
|
*
|
|
7033
|
-
* @param {
|
|
7103
|
+
* @param {OverlaysConfig} config
|
|
7034
7104
|
* @param {EventBus} eventBus
|
|
7035
7105
|
* @param {Canvas} canvas
|
|
7036
7106
|
* @param {ElementRegistry} elementRegistry
|
|
7037
7107
|
*/
|
|
7038
7108
|
function Overlays(config, eventBus, canvas, elementRegistry) {
|
|
7039
|
-
|
|
7040
7109
|
this._eventBus = eventBus;
|
|
7041
7110
|
this._canvas = canvas;
|
|
7042
7111
|
this._elementRegistry = elementRegistry;
|
|
7043
7112
|
|
|
7044
7113
|
this._ids = ids;
|
|
7045
7114
|
|
|
7115
|
+
/**
|
|
7116
|
+
* @type {OverlaysConfigDefault}
|
|
7117
|
+
*/
|
|
7046
7118
|
this._overlayDefaults = assign$1({
|
|
7047
7119
|
|
|
7048
7120
|
// no show constraints
|
|
@@ -7053,16 +7125,18 @@
|
|
|
7053
7125
|
}, config && config.defaults);
|
|
7054
7126
|
|
|
7055
7127
|
/**
|
|
7056
|
-
*
|
|
7128
|
+
* @type {Map<string, Overlay>}
|
|
7057
7129
|
*/
|
|
7058
7130
|
this._overlays = {};
|
|
7059
7131
|
|
|
7060
7132
|
/**
|
|
7061
|
-
*
|
|
7133
|
+
* @type {OverlayContainer[]}
|
|
7062
7134
|
*/
|
|
7063
7135
|
this._overlayContainers = [];
|
|
7064
7136
|
|
|
7065
|
-
|
|
7137
|
+
/**
|
|
7138
|
+
* @type {HTMLElement}
|
|
7139
|
+
*/
|
|
7066
7140
|
this._overlayRoot = createRoot(canvas.getContainer());
|
|
7067
7141
|
|
|
7068
7142
|
this._init();
|
|
@@ -7078,12 +7152,12 @@
|
|
|
7078
7152
|
|
|
7079
7153
|
|
|
7080
7154
|
/**
|
|
7081
|
-
* Returns the overlay with the specified
|
|
7155
|
+
* Returns the overlay with the specified ID or a list of overlays
|
|
7082
7156
|
* for an element with a given type.
|
|
7083
7157
|
*
|
|
7084
7158
|
* @example
|
|
7085
7159
|
*
|
|
7086
|
-
* // return the single overlay with the given
|
|
7160
|
+
* // return the single overlay with the given ID
|
|
7087
7161
|
* overlays.get('some-id');
|
|
7088
7162
|
*
|
|
7089
7163
|
* // return all overlays for the shape
|
|
@@ -7092,16 +7166,12 @@
|
|
|
7092
7166
|
* // return all overlays on shape with type 'badge'
|
|
7093
7167
|
* overlays.get({ element: someShape, type: 'badge' });
|
|
7094
7168
|
*
|
|
7095
|
-
* // shape can also be specified as
|
|
7169
|
+
* // shape can also be specified as ID
|
|
7096
7170
|
* overlays.get({ element: 'element-id', type: 'badge' });
|
|
7097
7171
|
*
|
|
7172
|
+
* @param {OverlaysFilter} search The filter to be used to find the overlay(s).
|
|
7098
7173
|
*
|
|
7099
|
-
* @
|
|
7100
|
-
* @param {string} [search.id]
|
|
7101
|
-
* @param {string|djs.model.Base} [search.element]
|
|
7102
|
-
* @param {string} [search.type]
|
|
7103
|
-
*
|
|
7104
|
-
* @return {Object|Array<Object>} the overlay(s)
|
|
7174
|
+
* @return {Overlay|Overlay[]} The overlay(s).
|
|
7105
7175
|
*/
|
|
7106
7176
|
Overlays.prototype.get = function(search) {
|
|
7107
7177
|
|
|
@@ -7133,27 +7203,13 @@
|
|
|
7133
7203
|
};
|
|
7134
7204
|
|
|
7135
7205
|
/**
|
|
7136
|
-
* Adds
|
|
7137
|
-
*
|
|
7138
|
-
* @param {string|djs.model.Base} element attach overlay to this shape
|
|
7139
|
-
* @param {string} [type] optional type to assign to the overlay
|
|
7140
|
-
* @param {Object} overlay the overlay configuration
|
|
7206
|
+
* Adds an HTML overlay to an element.
|
|
7141
7207
|
*
|
|
7142
|
-
* @param {string
|
|
7143
|
-
* @param {
|
|
7144
|
-
* @param {
|
|
7145
|
-
* @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
|
|
7146
|
-
* @param {Object} overlay.position where to attach the overlay
|
|
7147
|
-
* @param {number} [overlay.position.left] relative to element bbox left attachment
|
|
7148
|
-
* @param {number} [overlay.position.top] relative to element bbox top attachment
|
|
7149
|
-
* @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
|
|
7150
|
-
* @param {number} [overlay.position.right] relative to element bbox right attachment
|
|
7151
|
-
* @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
|
|
7152
|
-
* diagram zoom
|
|
7153
|
-
* @param {number} [overlay.scale.min]
|
|
7154
|
-
* @param {number} [overlay.scale.max]
|
|
7208
|
+
* @param {Base|string} element The element to add the overlay to.
|
|
7209
|
+
* @param {string} [type] An optional type that can be used to filter.
|
|
7210
|
+
* @param {OverlayAttrs} overlay The overlay.
|
|
7155
7211
|
*
|
|
7156
|
-
* @return {string}
|
|
7212
|
+
* @return {string} The overlay's ID that can be used to get or remove it.
|
|
7157
7213
|
*/
|
|
7158
7214
|
Overlays.prototype.add = function(element, type, overlay) {
|
|
7159
7215
|
|
|
@@ -7194,11 +7250,11 @@
|
|
|
7194
7250
|
|
|
7195
7251
|
|
|
7196
7252
|
/**
|
|
7197
|
-
* Remove an overlay with the given
|
|
7253
|
+
* Remove an overlay with the given ID or all overlays matching the given filter.
|
|
7198
7254
|
*
|
|
7199
7255
|
* @see Overlays#get for filter options.
|
|
7200
7256
|
*
|
|
7201
|
-
* @param {
|
|
7257
|
+
* @param {OverlaysFilter} filter The filter to be used to find the overlay.
|
|
7202
7258
|
*/
|
|
7203
7259
|
Overlays.prototype.remove = function(filter) {
|
|
7204
7260
|
|
|
@@ -7234,19 +7290,32 @@
|
|
|
7234
7290
|
|
|
7235
7291
|
};
|
|
7236
7292
|
|
|
7293
|
+
/**
|
|
7294
|
+
* Checks whether overlays are shown.
|
|
7295
|
+
*
|
|
7296
|
+
* @returns {boolean} Whether overlays are shown.
|
|
7297
|
+
*/
|
|
7237
7298
|
Overlays.prototype.isShown = function() {
|
|
7238
7299
|
return this._overlayRoot.style.display !== 'none';
|
|
7239
7300
|
};
|
|
7240
7301
|
|
|
7302
|
+
/**
|
|
7303
|
+
* Show all overlays.
|
|
7304
|
+
*/
|
|
7241
7305
|
Overlays.prototype.show = function() {
|
|
7242
7306
|
setVisible(this._overlayRoot);
|
|
7243
7307
|
};
|
|
7244
7308
|
|
|
7245
|
-
|
|
7309
|
+
/**
|
|
7310
|
+
* Hide all overlays.
|
|
7311
|
+
*/
|
|
7246
7312
|
Overlays.prototype.hide = function() {
|
|
7247
7313
|
setVisible(this._overlayRoot, false);
|
|
7248
7314
|
};
|
|
7249
7315
|
|
|
7316
|
+
/**
|
|
7317
|
+
* Remove all overlays and their container.
|
|
7318
|
+
*/
|
|
7250
7319
|
Overlays.prototype.clear = function() {
|
|
7251
7320
|
this._overlays = {};
|
|
7252
7321
|
|
|
@@ -7622,6 +7691,13 @@
|
|
|
7622
7691
|
overlays: [ 'type', Overlays ]
|
|
7623
7692
|
};
|
|
7624
7693
|
|
|
7694
|
+
/**
|
|
7695
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7696
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7697
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7698
|
+
* @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
|
|
7699
|
+
*/
|
|
7700
|
+
|
|
7625
7701
|
/**
|
|
7626
7702
|
* Adds change support to the diagram, including
|
|
7627
7703
|
*
|
|
@@ -7691,32 +7767,41 @@
|
|
|
7691
7767
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7692
7768
|
};
|
|
7693
7769
|
|
|
7770
|
+
/**
|
|
7771
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
7772
|
+
* @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
|
|
7773
|
+
* @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
|
|
7774
|
+
*/
|
|
7775
|
+
|
|
7694
7776
|
var DEFAULT_PRIORITY$2 = 1000;
|
|
7695
7777
|
|
|
7696
7778
|
/**
|
|
7697
|
-
* A utility that can be used to plug
|
|
7779
|
+
* A utility that can be used to plug into the command execution for
|
|
7698
7780
|
* extension and/or validation.
|
|
7699
7781
|
*
|
|
7782
|
+
* @class
|
|
7783
|
+
* @constructor
|
|
7784
|
+
*
|
|
7700
7785
|
* @param {EventBus} eventBus
|
|
7701
7786
|
*
|
|
7702
7787
|
* @example
|
|
7703
7788
|
*
|
|
7704
|
-
* import inherits from 'inherits-browser';
|
|
7705
|
-
*
|
|
7706
7789
|
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7707
7790
|
*
|
|
7708
|
-
*
|
|
7709
|
-
*
|
|
7791
|
+
* class CommandLogger extends CommandInterceptor {
|
|
7792
|
+
* constructor(eventBus) {
|
|
7793
|
+
* super(eventBus);
|
|
7710
7794
|
*
|
|
7711
|
-
* this.preExecute(
|
|
7712
|
-
* console.log('
|
|
7795
|
+
* this.preExecute('shape.create', (event) => {
|
|
7796
|
+
* console.log('commandStack.shape-create.preExecute', event);
|
|
7713
7797
|
* });
|
|
7714
7798
|
* }
|
|
7715
|
-
*
|
|
7716
|
-
* inherits(CommandLogger, CommandInterceptor);
|
|
7717
|
-
*
|
|
7718
7799
|
*/
|
|
7719
7800
|
function CommandInterceptor(eventBus) {
|
|
7801
|
+
|
|
7802
|
+
/**
|
|
7803
|
+
* @type {EventBus}
|
|
7804
|
+
*/
|
|
7720
7805
|
this._eventBus = eventBus;
|
|
7721
7806
|
}
|
|
7722
7807
|
|
|
@@ -7729,16 +7814,15 @@
|
|
|
7729
7814
|
}
|
|
7730
7815
|
|
|
7731
7816
|
/**
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
*/
|
|
7817
|
+
* Intercept a command during one of the phases.
|
|
7818
|
+
*
|
|
7819
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7820
|
+
* @param {string} [hook] Phase during which to intercept command.
|
|
7821
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7822
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7823
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7824
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7825
|
+
*/
|
|
7742
7826
|
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7743
7827
|
|
|
7744
7828
|
if (isFunction(hook) || isNumber(hook)) {
|
|
@@ -7794,24 +7878,19 @@
|
|
|
7794
7878
|
];
|
|
7795
7879
|
|
|
7796
7880
|
/*
|
|
7797
|
-
*
|
|
7798
|
-
*
|
|
7799
|
-
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7800
|
-
* which will in term forward to CommandInterceptor#on.
|
|
7881
|
+
* Add prototype methods for each phase of command execution (e.g. execute,
|
|
7882
|
+
* revert).
|
|
7801
7883
|
*/
|
|
7802
7884
|
forEach$1(hooks, function(hook) {
|
|
7803
7885
|
|
|
7804
7886
|
/**
|
|
7805
|
-
*
|
|
7806
|
-
*
|
|
7807
|
-
* A named hook for plugging into the command execution
|
|
7887
|
+
* Add prototype method for a specific phase of command execution.
|
|
7808
7888
|
*
|
|
7809
|
-
* @param {string|
|
|
7810
|
-
* @param {number} [priority]
|
|
7811
|
-
* @param {
|
|
7812
|
-
* @param {boolean} [unwrap
|
|
7813
|
-
*
|
|
7814
|
-
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7889
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7890
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7891
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7892
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7893
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7815
7894
|
*/
|
|
7816
7895
|
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7817
7896
|
|
|
@@ -7827,12 +7906,18 @@
|
|
|
7827
7906
|
};
|
|
7828
7907
|
});
|
|
7829
7908
|
|
|
7909
|
+
/**
|
|
7910
|
+
* @typedef {import('didi').Injector} Injector
|
|
7911
|
+
*
|
|
7912
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7913
|
+
*/
|
|
7914
|
+
|
|
7830
7915
|
/**
|
|
7831
7916
|
* A modeling behavior that ensures we set the correct root element
|
|
7832
7917
|
* as we undo and redo commands.
|
|
7833
7918
|
*
|
|
7834
7919
|
* @param {Canvas} canvas
|
|
7835
|
-
* @param {
|
|
7920
|
+
* @param {Injector} injector
|
|
7836
7921
|
*/
|
|
7837
7922
|
function RootElementsBehavior(canvas, injector) {
|
|
7838
7923
|
|
|
@@ -7866,111 +7951,10 @@
|
|
|
7866
7951
|
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7867
7952
|
};
|
|
7868
7953
|
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
(function (module, exports) {
|
|
7874
|
-
(function(root, factory) {
|
|
7875
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7876
|
-
{
|
|
7877
|
-
// For Node.js.
|
|
7878
|
-
module.exports = factory(root);
|
|
7879
|
-
}
|
|
7880
|
-
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
|
|
7881
|
-
|
|
7882
|
-
if (root.CSS && root.CSS.escape) {
|
|
7883
|
-
return root.CSS.escape;
|
|
7884
|
-
}
|
|
7885
|
-
|
|
7886
|
-
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7887
|
-
var cssEscape = function(value) {
|
|
7888
|
-
if (arguments.length == 0) {
|
|
7889
|
-
throw new TypeError('`CSS.escape` requires an argument.');
|
|
7890
|
-
}
|
|
7891
|
-
var string = String(value);
|
|
7892
|
-
var length = string.length;
|
|
7893
|
-
var index = -1;
|
|
7894
|
-
var codeUnit;
|
|
7895
|
-
var result = '';
|
|
7896
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
7897
|
-
while (++index < length) {
|
|
7898
|
-
codeUnit = string.charCodeAt(index);
|
|
7899
|
-
// Note: there’s no need to special-case astral symbols, surrogate
|
|
7900
|
-
// pairs, or lone surrogates.
|
|
7901
|
-
|
|
7902
|
-
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
7903
|
-
// (U+FFFD).
|
|
7904
|
-
if (codeUnit == 0x0000) {
|
|
7905
|
-
result += '\uFFFD';
|
|
7906
|
-
continue;
|
|
7907
|
-
}
|
|
7908
|
-
|
|
7909
|
-
if (
|
|
7910
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
7911
|
-
// U+007F, […]
|
|
7912
|
-
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
|
7913
|
-
// If the character is the first character and is in the range [0-9]
|
|
7914
|
-
// (U+0030 to U+0039), […]
|
|
7915
|
-
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
|
7916
|
-
// If the character is the second character and is in the range [0-9]
|
|
7917
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
7918
|
-
(
|
|
7919
|
-
index == 1 &&
|
|
7920
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
|
7921
|
-
firstCodeUnit == 0x002D
|
|
7922
|
-
)
|
|
7923
|
-
) {
|
|
7924
|
-
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
7925
|
-
result += '\\' + codeUnit.toString(16) + ' ';
|
|
7926
|
-
continue;
|
|
7927
|
-
}
|
|
7928
|
-
|
|
7929
|
-
if (
|
|
7930
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
7931
|
-
// there is no second character, […]
|
|
7932
|
-
index == 0 &&
|
|
7933
|
-
length == 1 &&
|
|
7934
|
-
codeUnit == 0x002D
|
|
7935
|
-
) {
|
|
7936
|
-
result += '\\' + string.charAt(index);
|
|
7937
|
-
continue;
|
|
7938
|
-
}
|
|
7939
|
-
|
|
7940
|
-
// If the character is not handled by one of the above rules and is
|
|
7941
|
-
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
7942
|
-
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
7943
|
-
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
7944
|
-
if (
|
|
7945
|
-
codeUnit >= 0x0080 ||
|
|
7946
|
-
codeUnit == 0x002D ||
|
|
7947
|
-
codeUnit == 0x005F ||
|
|
7948
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
|
7949
|
-
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
|
7950
|
-
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
|
7951
|
-
) {
|
|
7952
|
-
// the character itself
|
|
7953
|
-
result += string.charAt(index);
|
|
7954
|
-
continue;
|
|
7955
|
-
}
|
|
7956
|
-
|
|
7957
|
-
// Otherwise, the escaped character.
|
|
7958
|
-
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
7959
|
-
result += '\\' + string.charAt(index);
|
|
7960
|
-
|
|
7961
|
-
}
|
|
7962
|
-
return result;
|
|
7963
|
-
};
|
|
7964
|
-
|
|
7965
|
-
if (!root.CSS) {
|
|
7966
|
-
root.CSS = {};
|
|
7967
|
-
}
|
|
7968
|
-
|
|
7969
|
-
root.CSS.escape = cssEscape;
|
|
7970
|
-
return cssEscape;
|
|
7971
|
-
|
|
7972
|
-
}));
|
|
7973
|
-
} (css_escape));
|
|
7954
|
+
/**
|
|
7955
|
+
* @param {string} str
|
|
7956
|
+
* @returns {string}
|
|
7957
|
+
*/
|
|
7974
7958
|
|
|
7975
7959
|
var HTML_ESCAPE_MAP = {
|
|
7976
7960
|
'&': '&',
|
|
@@ -9105,6 +9089,11 @@
|
|
|
9105
9089
|
return value;
|
|
9106
9090
|
}
|
|
9107
9091
|
|
|
9092
|
+
/**
|
|
9093
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
9094
|
+
* @typedef {import('./Styles').default} Styles
|
|
9095
|
+
*/
|
|
9096
|
+
|
|
9108
9097
|
// apply default renderer with lowest possible priority
|
|
9109
9098
|
// so that it only kicks in if noone else could render
|
|
9110
9099
|
var DEFAULT_RENDER_PRIORITY = 1;
|
|
@@ -9222,9 +9211,9 @@
|
|
|
9222
9211
|
/**
|
|
9223
9212
|
* Builds a style definition from a className, a list of traits and an object of additional attributes.
|
|
9224
9213
|
*
|
|
9225
|
-
* @param
|
|
9226
|
-
* @param
|
|
9227
|
-
* @param
|
|
9214
|
+
* @param {string} className
|
|
9215
|
+
* @param {Array<string>} traits
|
|
9216
|
+
* @param {Object} additionalAttrs
|
|
9228
9217
|
*
|
|
9229
9218
|
* @return {Object} the style defintion
|
|
9230
9219
|
*/
|
|
@@ -9237,8 +9226,8 @@
|
|
|
9237
9226
|
/**
|
|
9238
9227
|
* Builds a style definition from a list of traits and an object of additional attributes.
|
|
9239
9228
|
*
|
|
9240
|
-
* @param
|
|
9241
|
-
* @param
|
|
9229
|
+
* @param {Array<string>} traits
|
|
9230
|
+
* @param {Object} additionalAttrs
|
|
9242
9231
|
*
|
|
9243
9232
|
* @return {Object} the style defintion
|
|
9244
9233
|
*/
|
|
@@ -9275,8 +9264,8 @@
|
|
|
9275
9264
|
/**
|
|
9276
9265
|
* Failsafe remove an element from a collection
|
|
9277
9266
|
*
|
|
9278
|
-
* @param
|
|
9279
|
-
* @param
|
|
9267
|
+
* @param {Array<Object>} [collection]
|
|
9268
|
+
* @param {Object} [element]
|
|
9280
9269
|
*
|
|
9281
9270
|
* @return {number} the previous index of the element
|
|
9282
9271
|
*/
|
|
@@ -9346,6 +9335,27 @@
|
|
|
9346
9335
|
}
|
|
9347
9336
|
}
|
|
9348
9337
|
|
|
9338
|
+
/**
|
|
9339
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
9340
|
+
* @typedef {import('.').RootLike} RootLike
|
|
9341
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
9342
|
+
*
|
|
9343
|
+
* @typedef {import('./Canvas').CanvasConfig} CanvasConfig
|
|
9344
|
+
* @typedef {import('./Canvas').CanvasLayer} CanvasLayer
|
|
9345
|
+
* @typedef {import('./Canvas').CanvasLayers} CanvasLayers
|
|
9346
|
+
* @typedef {import('./Canvas').CanvasPlane} CanvasPlane
|
|
9347
|
+
* @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
|
|
9348
|
+
*
|
|
9349
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
9350
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
9351
|
+
* @typedef {import('./GraphicsFactory').default} GraphicsFactory
|
|
9352
|
+
*
|
|
9353
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
9354
|
+
* @typedef {import('../util/Types').Point} Point
|
|
9355
|
+
* @typedef {import('../util/Types').Rect} Rect
|
|
9356
|
+
* @typedef {import('../util/Types').RectTRBL} RectTRBL
|
|
9357
|
+
*/
|
|
9358
|
+
|
|
9349
9359
|
function round(number, resolution) {
|
|
9350
9360
|
return Math.round(number * resolution) / resolution;
|
|
9351
9361
|
}
|
|
@@ -9366,7 +9376,8 @@
|
|
|
9366
9376
|
* Creates a HTML container element for a SVG element with
|
|
9367
9377
|
* the given configuration
|
|
9368
9378
|
*
|
|
9369
|
-
* @param
|
|
9379
|
+
* @param {CanvasConfig} options
|
|
9380
|
+
*
|
|
9370
9381
|
* @return {HTMLElement} the container element
|
|
9371
9382
|
*/
|
|
9372
9383
|
function createContainer(options) {
|
|
@@ -9426,21 +9437,34 @@
|
|
|
9426
9437
|
*
|
|
9427
9438
|
* @emits Canvas#canvas.init
|
|
9428
9439
|
*
|
|
9429
|
-
* @param {
|
|
9440
|
+
* @param {CanvasConfig|null} config
|
|
9430
9441
|
* @param {EventBus} eventBus
|
|
9431
9442
|
* @param {GraphicsFactory} graphicsFactory
|
|
9432
9443
|
* @param {ElementRegistry} elementRegistry
|
|
9433
9444
|
*/
|
|
9434
9445
|
function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
|
9435
|
-
|
|
9436
9446
|
this._eventBus = eventBus;
|
|
9437
9447
|
this._elementRegistry = elementRegistry;
|
|
9438
9448
|
this._graphicsFactory = graphicsFactory;
|
|
9439
9449
|
|
|
9450
|
+
/**
|
|
9451
|
+
* @type {number}
|
|
9452
|
+
*/
|
|
9440
9453
|
this._rootsIdx = 0;
|
|
9441
9454
|
|
|
9455
|
+
/**
|
|
9456
|
+
* @type {CanvasLayers}
|
|
9457
|
+
*/
|
|
9442
9458
|
this._layers = {};
|
|
9459
|
+
|
|
9460
|
+
/**
|
|
9461
|
+
* @type {CanvasPlane[]}
|
|
9462
|
+
*/
|
|
9443
9463
|
this._planes = [];
|
|
9464
|
+
|
|
9465
|
+
/**
|
|
9466
|
+
* @type {RootLike|null}
|
|
9467
|
+
*/
|
|
9444
9468
|
this._rootElement = null;
|
|
9445
9469
|
|
|
9446
9470
|
this._init(config || {});
|
|
@@ -9465,6 +9489,8 @@
|
|
|
9465
9489
|
* ...
|
|
9466
9490
|
* </svg>
|
|
9467
9491
|
* </div>
|
|
9492
|
+
*
|
|
9493
|
+
* @param {CanvasConfig} config
|
|
9468
9494
|
*/
|
|
9469
9495
|
Canvas.prototype._init = function(config) {
|
|
9470
9496
|
|
|
@@ -9486,7 +9512,7 @@
|
|
|
9486
9512
|
this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
|
|
9487
9513
|
}
|
|
9488
9514
|
|
|
9489
|
-
eventBus.on('diagram.init',
|
|
9515
|
+
eventBus.on('diagram.init', () => {
|
|
9490
9516
|
|
|
9491
9517
|
/**
|
|
9492
9518
|
* An event indicating that the canvas is ready to be drawn on.
|
|
@@ -9504,7 +9530,7 @@
|
|
|
9504
9530
|
viewport: viewport
|
|
9505
9531
|
});
|
|
9506
9532
|
|
|
9507
|
-
}
|
|
9533
|
+
});
|
|
9508
9534
|
|
|
9509
9535
|
// reset viewbox on shape changes to
|
|
9510
9536
|
// recompute the viewbox
|
|
@@ -9515,15 +9541,15 @@
|
|
|
9515
9541
|
'connection.removed',
|
|
9516
9542
|
'elements.changed',
|
|
9517
9543
|
'root.set'
|
|
9518
|
-
],
|
|
9544
|
+
], () => {
|
|
9519
9545
|
delete this._cachedViewbox;
|
|
9520
|
-
}
|
|
9546
|
+
});
|
|
9521
9547
|
|
|
9522
9548
|
eventBus.on('diagram.destroy', 500, this._destroy, this);
|
|
9523
9549
|
eventBus.on('diagram.clear', 500, this._clear, this);
|
|
9524
9550
|
};
|
|
9525
9551
|
|
|
9526
|
-
Canvas.prototype._destroy = function(
|
|
9552
|
+
Canvas.prototype._destroy = function() {
|
|
9527
9553
|
this._eventBus.fire('canvas.destroy', {
|
|
9528
9554
|
svg: this._svg,
|
|
9529
9555
|
viewport: this._viewport
|
|
@@ -9570,7 +9596,7 @@
|
|
|
9570
9596
|
* Returns the default layer on which
|
|
9571
9597
|
* all elements are drawn.
|
|
9572
9598
|
*
|
|
9573
|
-
* @
|
|
9599
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9574
9600
|
*/
|
|
9575
9601
|
Canvas.prototype.getDefaultLayer = function() {
|
|
9576
9602
|
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
@@ -9586,10 +9612,10 @@
|
|
|
9586
9612
|
* A layer with a certain index is always created above all
|
|
9587
9613
|
* existing layers with the same index.
|
|
9588
9614
|
*
|
|
9589
|
-
* @param {string} name
|
|
9590
|
-
* @param {number} index
|
|
9615
|
+
* @param {string} name The name of the layer.
|
|
9616
|
+
* @param {number} [index] The index of the layer.
|
|
9591
9617
|
*
|
|
9592
|
-
* @
|
|
9618
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9593
9619
|
*/
|
|
9594
9620
|
Canvas.prototype.getLayer = function(name, index) {
|
|
9595
9621
|
|
|
@@ -9618,8 +9644,9 @@
|
|
|
9618
9644
|
*
|
|
9619
9645
|
* This is used to determine the node a layer should be inserted at.
|
|
9620
9646
|
*
|
|
9621
|
-
* @param {
|
|
9622
|
-
*
|
|
9647
|
+
* @param {number} index
|
|
9648
|
+
*
|
|
9649
|
+
* @return {number}
|
|
9623
9650
|
*/
|
|
9624
9651
|
Canvas.prototype._getChildIndex = function(index) {
|
|
9625
9652
|
return reduce(this._layers, function(childIndex, layer) {
|
|
@@ -9637,7 +9664,7 @@
|
|
|
9637
9664
|
* @param {string} name
|
|
9638
9665
|
* @param {number} [index=0]
|
|
9639
9666
|
*
|
|
9640
|
-
* @return {
|
|
9667
|
+
* @return {CanvasLayer}
|
|
9641
9668
|
*/
|
|
9642
9669
|
Canvas.prototype._createLayer = function(name, index) {
|
|
9643
9670
|
|
|
@@ -9658,8 +9685,9 @@
|
|
|
9658
9685
|
/**
|
|
9659
9686
|
* Shows a given layer.
|
|
9660
9687
|
*
|
|
9661
|
-
* @param {
|
|
9662
|
-
*
|
|
9688
|
+
* @param {string} layer The name of the layer.
|
|
9689
|
+
*
|
|
9690
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9663
9691
|
*/
|
|
9664
9692
|
Canvas.prototype.showLayer = function(name) {
|
|
9665
9693
|
|
|
@@ -9693,8 +9721,9 @@
|
|
|
9693
9721
|
/**
|
|
9694
9722
|
* Hides a given layer.
|
|
9695
9723
|
*
|
|
9696
|
-
* @param {
|
|
9697
|
-
*
|
|
9724
|
+
* @param {string} layer The name of the layer.
|
|
9725
|
+
*
|
|
9726
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9698
9727
|
*/
|
|
9699
9728
|
Canvas.prototype.hideLayer = function(name) {
|
|
9700
9729
|
|
|
@@ -9736,7 +9765,7 @@
|
|
|
9736
9765
|
/**
|
|
9737
9766
|
* Returns the currently active layer. Can be null.
|
|
9738
9767
|
*
|
|
9739
|
-
* @
|
|
9768
|
+
* @return {CanvasLayer|null} The active layer of `null`.
|
|
9740
9769
|
*/
|
|
9741
9770
|
Canvas.prototype.getActiveLayer = function() {
|
|
9742
9771
|
const plane = this._findPlaneForRoot(this.getRootElement());
|
|
@@ -9752,9 +9781,9 @@
|
|
|
9752
9781
|
/**
|
|
9753
9782
|
* Returns the plane which contains the given element.
|
|
9754
9783
|
*
|
|
9755
|
-
* @param {string
|
|
9784
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9756
9785
|
*
|
|
9757
|
-
* @return {
|
|
9786
|
+
* @return {RootLike|undefined} The root of the element.
|
|
9758
9787
|
*/
|
|
9759
9788
|
Canvas.prototype.findRoot = function(element) {
|
|
9760
9789
|
if (typeof element === 'string') {
|
|
@@ -9775,7 +9804,7 @@
|
|
|
9775
9804
|
/**
|
|
9776
9805
|
* Return a list of all root elements on the diagram.
|
|
9777
9806
|
*
|
|
9778
|
-
* @return {
|
|
9807
|
+
* @return {(RootLike)[]} The list of root elements.
|
|
9779
9808
|
*/
|
|
9780
9809
|
Canvas.prototype.getRootElements = function() {
|
|
9781
9810
|
return this._planes.map(function(plane) {
|
|
@@ -9794,7 +9823,7 @@
|
|
|
9794
9823
|
* Returns the html element that encloses the
|
|
9795
9824
|
* drawing canvas.
|
|
9796
9825
|
*
|
|
9797
|
-
* @return {
|
|
9826
|
+
* @return {HTMLElement} The HTML element of the container.
|
|
9798
9827
|
*/
|
|
9799
9828
|
Canvas.prototype.getContainer = function() {
|
|
9800
9829
|
return this._container;
|
|
@@ -9834,8 +9863,8 @@
|
|
|
9834
9863
|
*
|
|
9835
9864
|
* @event element.marker.update
|
|
9836
9865
|
* @type {Object}
|
|
9837
|
-
* @property {
|
|
9838
|
-
* @property {
|
|
9866
|
+
* @property {Base} element the shape
|
|
9867
|
+
* @property {SVGElement} gfx the graphical representation of the shape
|
|
9839
9868
|
* @property {string} marker
|
|
9840
9869
|
* @property {boolean} add true if the marker was added, false if it got removed
|
|
9841
9870
|
*/
|
|
@@ -9850,14 +9879,15 @@
|
|
|
9850
9879
|
* integrate extension into the marker life-cycle, too.
|
|
9851
9880
|
*
|
|
9852
9881
|
* @example
|
|
9882
|
+
*
|
|
9853
9883
|
* canvas.addMarker('foo', 'some-marker');
|
|
9854
9884
|
*
|
|
9855
9885
|
* const fooGfx = canvas.getGraphics('foo');
|
|
9856
9886
|
*
|
|
9857
9887
|
* fooGfx; // <g class="... some-marker"> ... </g>
|
|
9858
9888
|
*
|
|
9859
|
-
* @param {string
|
|
9860
|
-
* @param {string} marker
|
|
9889
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9890
|
+
* @param {string} marker The marker.
|
|
9861
9891
|
*/
|
|
9862
9892
|
Canvas.prototype.addMarker = function(element, marker) {
|
|
9863
9893
|
this._updateMarker(element, marker, true);
|
|
@@ -9870,18 +9900,18 @@
|
|
|
9870
9900
|
* Fires the element.marker.update event, making it possible to
|
|
9871
9901
|
* integrate extension into the marker life-cycle, too.
|
|
9872
9902
|
*
|
|
9873
|
-
* @param
|
|
9874
|
-
* @param
|
|
9903
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9904
|
+
* @param {string} marker The marker.
|
|
9875
9905
|
*/
|
|
9876
9906
|
Canvas.prototype.removeMarker = function(element, marker) {
|
|
9877
9907
|
this._updateMarker(element, marker, false);
|
|
9878
9908
|
};
|
|
9879
9909
|
|
|
9880
9910
|
/**
|
|
9881
|
-
* Check
|
|
9911
|
+
* Check whether an element has a given marker.
|
|
9882
9912
|
*
|
|
9883
|
-
* @param
|
|
9884
|
-
* @param
|
|
9913
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9914
|
+
* @param {string} marker The marker.
|
|
9885
9915
|
*/
|
|
9886
9916
|
Canvas.prototype.hasMarker = function(element, marker) {
|
|
9887
9917
|
if (!element.id) {
|
|
@@ -9899,8 +9929,8 @@
|
|
|
9899
9929
|
* Fires the element.marker.update event, making it possible to
|
|
9900
9930
|
* integrate extension into the marker life-cycle, too.
|
|
9901
9931
|
*
|
|
9902
|
-
* @param
|
|
9903
|
-
* @param
|
|
9932
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9933
|
+
* @param {string} marker The marker.
|
|
9904
9934
|
*/
|
|
9905
9935
|
Canvas.prototype.toggleMarker = function(element, marker) {
|
|
9906
9936
|
if (this.hasMarker(element, marker)) {
|
|
@@ -9923,7 +9953,7 @@
|
|
|
9923
9953
|
* root elements can be null. This is used for applications that want to manage
|
|
9924
9954
|
* root elements themselves.
|
|
9925
9955
|
*
|
|
9926
|
-
* @
|
|
9956
|
+
* @return {RootLike} The current root element.
|
|
9927
9957
|
*/
|
|
9928
9958
|
Canvas.prototype.getRootElement = function() {
|
|
9929
9959
|
const rootElement = this._rootElement;
|
|
@@ -9939,11 +9969,10 @@
|
|
|
9939
9969
|
/**
|
|
9940
9970
|
* Adds a given root element and returns it.
|
|
9941
9971
|
*
|
|
9942
|
-
* @param {
|
|
9972
|
+
* @param {ShapeLike} [rootElement] The root element to be added.
|
|
9943
9973
|
*
|
|
9944
|
-
* @return {
|
|
9974
|
+
* @return {RootLike} The added root element or an implicit root element.
|
|
9945
9975
|
*/
|
|
9946
|
-
|
|
9947
9976
|
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9948
9977
|
const idx = this._rootsIdx++;
|
|
9949
9978
|
|
|
@@ -9974,11 +10003,11 @@
|
|
|
9974
10003
|
};
|
|
9975
10004
|
|
|
9976
10005
|
/**
|
|
9977
|
-
* Removes a given
|
|
10006
|
+
* Removes a given root element and returns it.
|
|
9978
10007
|
*
|
|
9979
|
-
* @param {
|
|
10008
|
+
* @param {ShapeLike|string} rootElement The root element or its ID.
|
|
9980
10009
|
*
|
|
9981
|
-
* @return {
|
|
10010
|
+
* @return {ShapeLike|undefined} The removed root element.
|
|
9982
10011
|
*/
|
|
9983
10012
|
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
9984
10013
|
|
|
@@ -10012,15 +10041,13 @@
|
|
|
10012
10041
|
};
|
|
10013
10042
|
|
|
10014
10043
|
|
|
10015
|
-
// root element handling //////////////////////
|
|
10016
|
-
|
|
10017
10044
|
/**
|
|
10018
10045
|
* Sets a given element as the new root element for the canvas
|
|
10019
10046
|
* and returns the new root element.
|
|
10020
10047
|
*
|
|
10021
|
-
* @param {
|
|
10048
|
+
* @param {RootLike} rootElement The root element to be set.
|
|
10022
10049
|
*
|
|
10023
|
-
* @return {
|
|
10050
|
+
* @return {RootLike} The set root element.
|
|
10024
10051
|
*/
|
|
10025
10052
|
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
10026
10053
|
|
|
@@ -10107,8 +10134,6 @@
|
|
|
10107
10134
|
this._eventBus.fire('root.set', { element: rootElement });
|
|
10108
10135
|
};
|
|
10109
10136
|
|
|
10110
|
-
// add functionality //////////////////////
|
|
10111
|
-
|
|
10112
10137
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
10113
10138
|
if (!element.id) {
|
|
10114
10139
|
throw new Error('element must have an id');
|
|
@@ -10149,11 +10174,11 @@
|
|
|
10149
10174
|
* Extensions may hook into these events to perform their magic.
|
|
10150
10175
|
*
|
|
10151
10176
|
* @param {string} type
|
|
10152
|
-
* @param {
|
|
10153
|
-
* @param {
|
|
10177
|
+
* @param {ConnectionLike|ShapeLike} element
|
|
10178
|
+
* @param {ShapeLike} [parent]
|
|
10154
10179
|
* @param {number} [parentIndex]
|
|
10155
10180
|
*
|
|
10156
|
-
* @return {
|
|
10181
|
+
* @return {ConnectionLike|ShapeLike} The added element.
|
|
10157
10182
|
*/
|
|
10158
10183
|
Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
|
10159
10184
|
|
|
@@ -10182,26 +10207,26 @@
|
|
|
10182
10207
|
};
|
|
10183
10208
|
|
|
10184
10209
|
/**
|
|
10185
|
-
* Adds a shape to the canvas
|
|
10210
|
+
* Adds a shape to the canvas.
|
|
10186
10211
|
*
|
|
10187
|
-
* @param {
|
|
10188
|
-
* @param {
|
|
10189
|
-
* @param {number} [parentIndex]
|
|
10212
|
+
* @param {ShapeLike} shape The shape to be added
|
|
10213
|
+
* @param {ShapeLike} [parent] The shape's parent.
|
|
10214
|
+
* @param {number} [parentIndex] The index at which to add the shape to the parent's children.
|
|
10190
10215
|
*
|
|
10191
|
-
* @return {
|
|
10216
|
+
* @return {ShapeLike} The added shape.
|
|
10192
10217
|
*/
|
|
10193
10218
|
Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
|
10194
10219
|
return this._addElement('shape', shape, parent, parentIndex);
|
|
10195
10220
|
};
|
|
10196
10221
|
|
|
10197
10222
|
/**
|
|
10198
|
-
* Adds a connection to the canvas
|
|
10223
|
+
* Adds a connection to the canvas.
|
|
10199
10224
|
*
|
|
10200
|
-
* @param {
|
|
10201
|
-
* @param {
|
|
10202
|
-
* @param {number} [parentIndex]
|
|
10225
|
+
* @param {ConnectionLike} connection The connection to be added.
|
|
10226
|
+
* @param {ShapeLike} [parent] The connection's parent.
|
|
10227
|
+
* @param {number} [parentIndex] The index at which to add the connection to the parent's children.
|
|
10203
10228
|
*
|
|
10204
|
-
* @return {
|
|
10229
|
+
* @return {ConnectionLike} The added connection.
|
|
10205
10230
|
*/
|
|
10206
10231
|
Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
|
10207
10232
|
return this._addElement('connection', connection, parent, parentIndex);
|
|
@@ -10242,11 +10267,14 @@
|
|
|
10242
10267
|
|
|
10243
10268
|
|
|
10244
10269
|
/**
|
|
10245
|
-
* Removes a shape from the canvas
|
|
10270
|
+
* Removes a shape from the canvas.
|
|
10246
10271
|
*
|
|
10247
|
-
* @
|
|
10272
|
+
* @fires ShapeRemoveEvent
|
|
10273
|
+
* @fires ShapeRemovedEvent
|
|
10248
10274
|
*
|
|
10249
|
-
* @
|
|
10275
|
+
* @param {ShapeLike|string} shape The shape or its ID.
|
|
10276
|
+
*
|
|
10277
|
+
* @return {ShapeLike} The removed shape.
|
|
10250
10278
|
*/
|
|
10251
10279
|
Canvas.prototype.removeShape = function(shape) {
|
|
10252
10280
|
|
|
@@ -10255,10 +10283,10 @@
|
|
|
10255
10283
|
*
|
|
10256
10284
|
* @memberOf Canvas
|
|
10257
10285
|
*
|
|
10258
|
-
* @event
|
|
10286
|
+
* @event ShapeRemoveEvent
|
|
10259
10287
|
* @type {Object}
|
|
10260
|
-
* @property {
|
|
10261
|
-
* @property {
|
|
10288
|
+
* @property {ShapeLike} element The shape.
|
|
10289
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10262
10290
|
*/
|
|
10263
10291
|
|
|
10264
10292
|
/**
|
|
@@ -10266,21 +10294,24 @@
|
|
|
10266
10294
|
*
|
|
10267
10295
|
* @memberOf Canvas
|
|
10268
10296
|
*
|
|
10269
|
-
* @event
|
|
10297
|
+
* @event ShapeRemoved
|
|
10270
10298
|
* @type {Object}
|
|
10271
|
-
* @property {
|
|
10272
|
-
* @property {
|
|
10299
|
+
* @property {ShapeLike} element The shape.
|
|
10300
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10273
10301
|
*/
|
|
10274
10302
|
return this._removeElement(shape, 'shape');
|
|
10275
10303
|
};
|
|
10276
10304
|
|
|
10277
10305
|
|
|
10278
10306
|
/**
|
|
10279
|
-
* Removes a connection from the canvas
|
|
10307
|
+
* Removes a connection from the canvas.
|
|
10308
|
+
*
|
|
10309
|
+
* @fires ConnectionRemoveEvent
|
|
10310
|
+
* @fires ConnectionRemovedEvent
|
|
10280
10311
|
*
|
|
10281
|
-
* @param {string
|
|
10312
|
+
* @param {ConnectionLike|string} connection The connection or its ID.
|
|
10282
10313
|
*
|
|
10283
|
-
* @return {
|
|
10314
|
+
* @return {ConnectionLike} The removed connection.
|
|
10284
10315
|
*/
|
|
10285
10316
|
Canvas.prototype.removeConnection = function(connection) {
|
|
10286
10317
|
|
|
@@ -10289,10 +10320,10 @@
|
|
|
10289
10320
|
*
|
|
10290
10321
|
* @memberOf Canvas
|
|
10291
10322
|
*
|
|
10292
|
-
* @event
|
|
10323
|
+
* @event ConnectionRemoveEvent
|
|
10293
10324
|
* @type {Object}
|
|
10294
|
-
* @property {
|
|
10295
|
-
* @property {
|
|
10325
|
+
* @property {ConnectionLike} element The connection.
|
|
10326
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10296
10327
|
*/
|
|
10297
10328
|
|
|
10298
10329
|
/**
|
|
@@ -10302,20 +10333,20 @@
|
|
|
10302
10333
|
*
|
|
10303
10334
|
* @event connection.removed
|
|
10304
10335
|
* @type {Object}
|
|
10305
|
-
* @property {
|
|
10306
|
-
* @property {
|
|
10336
|
+
* @property {ConnectionLike} element The connection.
|
|
10337
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10307
10338
|
*/
|
|
10308
10339
|
return this._removeElement(connection, 'connection');
|
|
10309
10340
|
};
|
|
10310
10341
|
|
|
10311
10342
|
|
|
10312
10343
|
/**
|
|
10313
|
-
*
|
|
10344
|
+
* Returns the graphical element of an element.
|
|
10314
10345
|
*
|
|
10315
|
-
* @param {string
|
|
10316
|
-
* @param {boolean} [secondary=false]
|
|
10346
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
10347
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical element.
|
|
10317
10348
|
*
|
|
10318
|
-
* @return {SVGElement}
|
|
10349
|
+
* @return {SVGElement} The graphical element.
|
|
10319
10350
|
*/
|
|
10320
10351
|
Canvas.prototype.getGraphics = function(element, secondary) {
|
|
10321
10352
|
return this._elementRegistry.getGraphics(element, secondary);
|
|
@@ -10387,13 +10418,9 @@
|
|
|
10387
10418
|
* height: zoomedAndScrolledViewbox.outer.height
|
|
10388
10419
|
* });
|
|
10389
10420
|
*
|
|
10390
|
-
* @param
|
|
10391
|
-
* @param {number} box.x the top left X coordinate of the canvas visible in view box
|
|
10392
|
-
* @param {number} box.y the top left Y coordinate of the canvas visible in view box
|
|
10393
|
-
* @param {number} box.width the visible width
|
|
10394
|
-
* @param {number} box.height
|
|
10421
|
+
* @param {Rect} [box] The viewbox to be set.
|
|
10395
10422
|
*
|
|
10396
|
-
* @return {
|
|
10423
|
+
* @return {CanvasViewbox} The set viewbox.
|
|
10397
10424
|
*/
|
|
10398
10425
|
Canvas.prototype.viewbox = function(box) {
|
|
10399
10426
|
|
|
@@ -10462,10 +10489,9 @@
|
|
|
10462
10489
|
/**
|
|
10463
10490
|
* Gets or sets the scroll of the canvas.
|
|
10464
10491
|
*
|
|
10465
|
-
* @param {
|
|
10492
|
+
* @param {Point} [delta] The scroll to be set.
|
|
10466
10493
|
*
|
|
10467
|
-
* @
|
|
10468
|
-
* @param {number} [delta.dy]
|
|
10494
|
+
* @return {Point}
|
|
10469
10495
|
*/
|
|
10470
10496
|
Canvas.prototype.scroll = function(delta) {
|
|
10471
10497
|
|
|
@@ -10489,9 +10515,8 @@
|
|
|
10489
10515
|
* Scrolls the viewbox to contain the given element.
|
|
10490
10516
|
* Optionally specify a padding to be applied to the edges.
|
|
10491
10517
|
*
|
|
10492
|
-
* @param {
|
|
10493
|
-
* @param {
|
|
10494
|
-
*
|
|
10518
|
+
* @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
|
|
10519
|
+
* @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
|
|
10495
10520
|
*/
|
|
10496
10521
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
10497
10522
|
let defaultPadding = 100;
|
|
@@ -10559,17 +10584,17 @@
|
|
|
10559
10584
|
};
|
|
10560
10585
|
|
|
10561
10586
|
/**
|
|
10562
|
-
* Gets or sets the current zoom of the canvas, optionally zooming
|
|
10563
|
-
*
|
|
10587
|
+
* Gets or sets the current zoom of the canvas, optionally zooming to the
|
|
10588
|
+
* specified position.
|
|
10564
10589
|
*
|
|
10565
|
-
* The getter may return a cached zoom level. Call it with `false` as
|
|
10566
|
-
*
|
|
10590
|
+
* The getter may return a cached zoom level. Call it with `false` as the first
|
|
10591
|
+
* argument to force recomputation of the current level.
|
|
10567
10592
|
*
|
|
10568
|
-
* @param {string
|
|
10569
|
-
*
|
|
10570
|
-
* @param {
|
|
10593
|
+
* @param {number|string} [newScale] The new zoom level, either a number,
|
|
10594
|
+
* i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
|
|
10595
|
+
* @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
|
|
10571
10596
|
*
|
|
10572
|
-
* @return {number}
|
|
10597
|
+
* @return {number} The set zoom level.
|
|
10573
10598
|
*/
|
|
10574
10599
|
Canvas.prototype.zoom = function(newScale, center) {
|
|
10575
10600
|
|
|
@@ -10692,9 +10717,9 @@
|
|
|
10692
10717
|
|
|
10693
10718
|
|
|
10694
10719
|
/**
|
|
10695
|
-
* Returns the size of the canvas
|
|
10720
|
+
* Returns the size of the canvas.
|
|
10696
10721
|
*
|
|
10697
|
-
* @return {Dimensions}
|
|
10722
|
+
* @return {Dimensions} The size of the canvas.
|
|
10698
10723
|
*/
|
|
10699
10724
|
Canvas.prototype.getSize = function() {
|
|
10700
10725
|
return {
|
|
@@ -10705,14 +10730,14 @@
|
|
|
10705
10730
|
|
|
10706
10731
|
|
|
10707
10732
|
/**
|
|
10708
|
-
*
|
|
10733
|
+
* Returns the absolute bounding box of an element.
|
|
10709
10734
|
*
|
|
10710
|
-
* The absolute bounding box may be used to display overlays in the
|
|
10711
|
-
*
|
|
10712
|
-
* canvas coordinates.
|
|
10735
|
+
* The absolute bounding box may be used to display overlays in the callers
|
|
10736
|
+
* (browser) coordinate system rather than the zoomed in/out canvas coordinates.
|
|
10713
10737
|
*
|
|
10714
|
-
* @param
|
|
10715
|
-
*
|
|
10738
|
+
* @param {ShapeLike|ConnectionLike} element The element.
|
|
10739
|
+
*
|
|
10740
|
+
* @return {Rect} The element's absolute bounding box.
|
|
10716
10741
|
*/
|
|
10717
10742
|
Canvas.prototype.getAbsoluteBBox = function(element) {
|
|
10718
10743
|
const vbox = this.viewbox();
|
|
@@ -10747,8 +10772,7 @@
|
|
|
10747
10772
|
};
|
|
10748
10773
|
|
|
10749
10774
|
/**
|
|
10750
|
-
* Fires an event
|
|
10751
|
-
* canvas resizing
|
|
10775
|
+
* Fires an event so other modules can react to the canvas resizing.
|
|
10752
10776
|
*/
|
|
10753
10777
|
Canvas.prototype.resized = function() {
|
|
10754
10778
|
|
|
@@ -10760,11 +10784,21 @@
|
|
|
10760
10784
|
|
|
10761
10785
|
var ELEMENT_ID = 'data-element-id';
|
|
10762
10786
|
|
|
10787
|
+
/**
|
|
10788
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
10789
|
+
*
|
|
10790
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
10791
|
+
*
|
|
10792
|
+
* @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
|
|
10793
|
+
*/
|
|
10763
10794
|
|
|
10764
10795
|
/**
|
|
10796
|
+
* A registry that keeps track of all shapes in the diagram.
|
|
10797
|
+
*
|
|
10765
10798
|
* @class
|
|
10799
|
+
* @constructor
|
|
10766
10800
|
*
|
|
10767
|
-
*
|
|
10801
|
+
* @param {EventBus} eventBus
|
|
10768
10802
|
*/
|
|
10769
10803
|
function ElementRegistry(eventBus) {
|
|
10770
10804
|
this._elements = {};
|
|
@@ -10775,11 +10809,11 @@
|
|
|
10775
10809
|
ElementRegistry.$inject = [ 'eventBus' ];
|
|
10776
10810
|
|
|
10777
10811
|
/**
|
|
10778
|
-
*
|
|
10812
|
+
* Add an element and its graphical representation(s) to the registry.
|
|
10779
10813
|
*
|
|
10780
|
-
* @param {
|
|
10781
|
-
* @param {SVGElement} gfx
|
|
10782
|
-
* @param {SVGElement} [secondaryGfx]
|
|
10814
|
+
* @param {ElementLike} element The element to be added.
|
|
10815
|
+
* @param {SVGElement} gfx The primary graphical representation.
|
|
10816
|
+
* @param {SVGElement} [secondaryGfx] The secondary graphical representation.
|
|
10783
10817
|
*/
|
|
10784
10818
|
ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
|
10785
10819
|
|
|
@@ -10798,9 +10832,9 @@
|
|
|
10798
10832
|
};
|
|
10799
10833
|
|
|
10800
10834
|
/**
|
|
10801
|
-
*
|
|
10835
|
+
* Remove an element from the registry.
|
|
10802
10836
|
*
|
|
10803
|
-
* @param {string
|
|
10837
|
+
* @param {ElementLike|string} element
|
|
10804
10838
|
*/
|
|
10805
10839
|
ElementRegistry.prototype.remove = function(element) {
|
|
10806
10840
|
var elements = this._elements,
|
|
@@ -10821,10 +10855,10 @@
|
|
|
10821
10855
|
};
|
|
10822
10856
|
|
|
10823
10857
|
/**
|
|
10824
|
-
* Update
|
|
10858
|
+
* Update an elements ID.
|
|
10825
10859
|
*
|
|
10826
|
-
* @param {string
|
|
10827
|
-
* @param {string} newId
|
|
10860
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10861
|
+
* @param {string} newId The new ID.
|
|
10828
10862
|
*/
|
|
10829
10863
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
10830
10864
|
|
|
@@ -10850,11 +10884,11 @@
|
|
|
10850
10884
|
};
|
|
10851
10885
|
|
|
10852
10886
|
/**
|
|
10853
|
-
* Update the
|
|
10887
|
+
* Update the graphical representation of an element.
|
|
10854
10888
|
*
|
|
10855
|
-
* @param {string
|
|
10856
|
-
* @param {SVGElement} gfx
|
|
10857
|
-
* @param {boolean} [secondary=false]
|
|
10889
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10890
|
+
* @param {SVGElement} gfx The new graphical representation.
|
|
10891
|
+
* @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
|
|
10858
10892
|
*/
|
|
10859
10893
|
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
10860
10894
|
var id = filter.id || filter;
|
|
@@ -10875,17 +10909,17 @@
|
|
|
10875
10909
|
};
|
|
10876
10910
|
|
|
10877
10911
|
/**
|
|
10878
|
-
*
|
|
10912
|
+
* Get the element with the given ID or graphical representation.
|
|
10879
10913
|
*
|
|
10880
10914
|
* @example
|
|
10881
10915
|
*
|
|
10882
10916
|
* elementRegistry.get('SomeElementId_1');
|
|
10883
|
-
* elementRegistry.get(gfx);
|
|
10884
10917
|
*
|
|
10918
|
+
* elementRegistry.get(gfx);
|
|
10885
10919
|
*
|
|
10886
|
-
* @param {string|SVGElement} filter
|
|
10920
|
+
* @param {string|SVGElement} filter The elements ID or graphical representation.
|
|
10887
10921
|
*
|
|
10888
|
-
* @return {
|
|
10922
|
+
* @return {ElementLike|undefined} The element.
|
|
10889
10923
|
*/
|
|
10890
10924
|
ElementRegistry.prototype.get = function(filter) {
|
|
10891
10925
|
var id;
|
|
@@ -10903,9 +10937,9 @@
|
|
|
10903
10937
|
/**
|
|
10904
10938
|
* Return all elements that match a given filter function.
|
|
10905
10939
|
*
|
|
10906
|
-
* @param {
|
|
10940
|
+
* @param {ElementRegistryCallback} fn The filter function.
|
|
10907
10941
|
*
|
|
10908
|
-
* @return {
|
|
10942
|
+
* @return {ElementLike[]} The matching elements.
|
|
10909
10943
|
*/
|
|
10910
10944
|
ElementRegistry.prototype.filter = function(fn) {
|
|
10911
10945
|
|
|
@@ -10921,11 +10955,11 @@
|
|
|
10921
10955
|
};
|
|
10922
10956
|
|
|
10923
10957
|
/**
|
|
10924
|
-
* Return the first element that
|
|
10958
|
+
* Return the first element that matches the given filter function.
|
|
10925
10959
|
*
|
|
10926
|
-
* @param {Function} fn
|
|
10960
|
+
* @param {Function} fn The filter function.
|
|
10927
10961
|
*
|
|
10928
|
-
* @return {
|
|
10962
|
+
* @return {ElementLike|undefined} The matching element.
|
|
10929
10963
|
*/
|
|
10930
10964
|
ElementRegistry.prototype.find = function(fn) {
|
|
10931
10965
|
var map = this._elements,
|
|
@@ -10944,18 +10978,18 @@
|
|
|
10944
10978
|
};
|
|
10945
10979
|
|
|
10946
10980
|
/**
|
|
10947
|
-
*
|
|
10981
|
+
* Get all elements.
|
|
10948
10982
|
*
|
|
10949
|
-
* @return {
|
|
10983
|
+
* @return {ElementLike[]} All elements.
|
|
10950
10984
|
*/
|
|
10951
10985
|
ElementRegistry.prototype.getAll = function() {
|
|
10952
10986
|
return this.filter(function(e) { return e; });
|
|
10953
10987
|
};
|
|
10954
10988
|
|
|
10955
10989
|
/**
|
|
10956
|
-
*
|
|
10990
|
+
* Execute a given function for each element.
|
|
10957
10991
|
*
|
|
10958
|
-
* @param {Function} fn
|
|
10992
|
+
* @param {Function} fn The function to execute.
|
|
10959
10993
|
*/
|
|
10960
10994
|
ElementRegistry.prototype.forEach = function(fn) {
|
|
10961
10995
|
|
|
@@ -10971,19 +11005,20 @@
|
|
|
10971
11005
|
};
|
|
10972
11006
|
|
|
10973
11007
|
/**
|
|
10974
|
-
* Return the graphical representation of an element
|
|
11008
|
+
* Return the graphical representation of an element.
|
|
10975
11009
|
*
|
|
10976
11010
|
* @example
|
|
11011
|
+
*
|
|
10977
11012
|
* elementRegistry.getGraphics('SomeElementId_1');
|
|
11013
|
+
*
|
|
10978
11014
|
* elementRegistry.getGraphics(rootElement); // <g ...>
|
|
10979
11015
|
*
|
|
10980
11016
|
* elementRegistry.getGraphics(rootElement, true); // <svg ...>
|
|
10981
11017
|
*
|
|
11018
|
+
* @param {ElementLike|string} filter The element or its ID.
|
|
11019
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
|
|
10982
11020
|
*
|
|
10983
|
-
* @
|
|
10984
|
-
* @param {boolean} [secondary=false] whether to return the secondary connected element
|
|
10985
|
-
*
|
|
10986
|
-
* @return {SVGElement}
|
|
11021
|
+
* @return {SVGElement} The graphical representation.
|
|
10987
11022
|
*/
|
|
10988
11023
|
ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
|
10989
11024
|
var id = filter.id || filter;
|
|
@@ -10993,12 +11028,11 @@
|
|
|
10993
11028
|
};
|
|
10994
11029
|
|
|
10995
11030
|
/**
|
|
10996
|
-
* Validate
|
|
10997
|
-
* with an exception.
|
|
11031
|
+
* Validate an ID and throw an error if invalid.
|
|
10998
11032
|
*
|
|
10999
11033
|
* @param {string} id
|
|
11000
11034
|
*
|
|
11001
|
-
* @throws {Error}
|
|
11035
|
+
* @throws {Error} Error indicating that the ID is invalid or already assigned.
|
|
11002
11036
|
*/
|
|
11003
11037
|
ElementRegistry.prototype._validateId = function(id) {
|
|
11004
11038
|
if (!id) {
|
|
@@ -11010,7 +11044,11 @@
|
|
|
11010
11044
|
}
|
|
11011
11045
|
};
|
|
11012
11046
|
|
|
11013
|
-
var
|
|
11047
|
+
var objectRefsExports = {};
|
|
11048
|
+
var objectRefs = {
|
|
11049
|
+
get exports(){ return objectRefsExports; },
|
|
11050
|
+
set exports(v){ objectRefsExports = v; },
|
|
11051
|
+
};
|
|
11014
11052
|
|
|
11015
11053
|
var collection = {};
|
|
11016
11054
|
|
|
@@ -11330,7 +11368,7 @@
|
|
|
11330
11368
|
module.exports.Collection = collection;
|
|
11331
11369
|
} (objectRefs));
|
|
11332
11370
|
|
|
11333
|
-
var Refs = /*@__PURE__*/getDefaultExportFromCjs(
|
|
11371
|
+
var Refs = /*@__PURE__*/getDefaultExportFromCjs(objectRefsExports);
|
|
11334
11372
|
|
|
11335
11373
|
var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
|
|
11336
11374
|
labelRefs = new Refs({ name: 'labels', enumerable: true, collection: true }, { name: 'labelTarget' }),
|
|
@@ -11338,14 +11376,6 @@
|
|
|
11338
11376
|
outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
|
11339
11377
|
incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
|
|
11340
11378
|
|
|
11341
|
-
/**
|
|
11342
|
-
* @namespace djs.model
|
|
11343
|
-
*/
|
|
11344
|
-
|
|
11345
|
-
/**
|
|
11346
|
-
* @memberOf djs.model
|
|
11347
|
-
*/
|
|
11348
|
-
|
|
11349
11379
|
/**
|
|
11350
11380
|
* The basic graphical representation
|
|
11351
11381
|
*
|
|
@@ -11542,21 +11572,47 @@
|
|
|
11542
11572
|
};
|
|
11543
11573
|
|
|
11544
11574
|
/**
|
|
11545
|
-
* Creates a
|
|
11575
|
+
* Creates a model element of the given type.
|
|
11546
11576
|
*
|
|
11547
11577
|
* @method create
|
|
11548
11578
|
*
|
|
11549
11579
|
* @example
|
|
11550
11580
|
*
|
|
11551
|
-
*
|
|
11552
|
-
*
|
|
11581
|
+
* import * as Model from 'diagram-js/lib/model';
|
|
11582
|
+
*
|
|
11583
|
+
* const connection = Model.create('connection', {
|
|
11584
|
+
* waypoints: [
|
|
11585
|
+
* { x: 100, y: 100 },
|
|
11586
|
+
* { x: 200, y: 100 }
|
|
11587
|
+
* ]
|
|
11588
|
+
* });
|
|
11589
|
+
*
|
|
11590
|
+
* const label = Model.create('label', {
|
|
11591
|
+
* x: 100,
|
|
11592
|
+
* y: 100,
|
|
11593
|
+
* width: 100,
|
|
11594
|
+
* height: 100,
|
|
11595
|
+
* labelTarget: shape
|
|
11596
|
+
* });
|
|
11553
11597
|
*
|
|
11554
|
-
*
|
|
11598
|
+
* const root = Model.create('root', {
|
|
11599
|
+
* x: 100,
|
|
11600
|
+
* y: 100,
|
|
11601
|
+
* width: 100,
|
|
11602
|
+
* height: 100
|
|
11603
|
+
* });
|
|
11555
11604
|
*
|
|
11556
|
-
*
|
|
11557
|
-
*
|
|
11605
|
+
* const shape = Model.create('shape', {
|
|
11606
|
+
* x: 100,
|
|
11607
|
+
* y: 100,
|
|
11608
|
+
* width: 100,
|
|
11609
|
+
* height: 100
|
|
11610
|
+
* });
|
|
11611
|
+
*
|
|
11612
|
+
* @param {string} type The type of model element to be created.
|
|
11613
|
+
* @param {Object} attrs Attributes to create the model element with.
|
|
11558
11614
|
*
|
|
11559
|
-
* @return {
|
|
11615
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11560
11616
|
*/
|
|
11561
11617
|
function create(type, attrs) {
|
|
11562
11618
|
var Type = types$6[type];
|
|
@@ -11567,36 +11623,78 @@
|
|
|
11567
11623
|
}
|
|
11568
11624
|
|
|
11569
11625
|
/**
|
|
11570
|
-
*
|
|
11626
|
+
* @typedef {import('../model/index').Base} Base
|
|
11627
|
+
* @typedef {import('../model/index').Connection} Connection
|
|
11628
|
+
* @typedef {import('../model/index').Label} Label
|
|
11629
|
+
* @typedef {import('../model/index').Root} Root
|
|
11630
|
+
* @typedef {import('../model/index').Shape} Shape
|
|
11631
|
+
* @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
|
|
11632
|
+
* @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
|
|
11633
|
+
* @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
|
|
11634
|
+
* @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
|
|
11635
|
+
*/
|
|
11636
|
+
|
|
11637
|
+
/**
|
|
11638
|
+
* A factory for model elements.
|
|
11639
|
+
*
|
|
11640
|
+
* @class
|
|
11641
|
+
* @constructor
|
|
11571
11642
|
*/
|
|
11572
11643
|
function ElementFactory() {
|
|
11573
11644
|
this._uid = 12;
|
|
11574
11645
|
}
|
|
11575
11646
|
|
|
11576
|
-
|
|
11647
|
+
/**
|
|
11648
|
+
* Create a root element.
|
|
11649
|
+
*
|
|
11650
|
+
* @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
|
|
11651
|
+
*
|
|
11652
|
+
* @return {Root} The created root element.
|
|
11653
|
+
*/
|
|
11577
11654
|
ElementFactory.prototype.createRoot = function(attrs) {
|
|
11578
11655
|
return this.create('root', attrs);
|
|
11579
11656
|
};
|
|
11580
11657
|
|
|
11658
|
+
/**
|
|
11659
|
+
* Create a label.
|
|
11660
|
+
*
|
|
11661
|
+
* @param {ModelAttrsLabel} attrs The attributes of the label to be created.
|
|
11662
|
+
*
|
|
11663
|
+
* @return {Label} The created label.
|
|
11664
|
+
*/
|
|
11581
11665
|
ElementFactory.prototype.createLabel = function(attrs) {
|
|
11582
11666
|
return this.create('label', attrs);
|
|
11583
11667
|
};
|
|
11584
11668
|
|
|
11669
|
+
/**
|
|
11670
|
+
* Create a shape.
|
|
11671
|
+
*
|
|
11672
|
+
* @param {ModelAttrsShape} attrs The attributes of the shape to be created.
|
|
11673
|
+
*
|
|
11674
|
+
* @return {Shape} The created shape.
|
|
11675
|
+
*/
|
|
11585
11676
|
ElementFactory.prototype.createShape = function(attrs) {
|
|
11586
11677
|
return this.create('shape', attrs);
|
|
11587
11678
|
};
|
|
11588
11679
|
|
|
11680
|
+
/**
|
|
11681
|
+
* Create a connection.
|
|
11682
|
+
*
|
|
11683
|
+
* @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
|
|
11684
|
+
*
|
|
11685
|
+
* @return {Connection} The created connection.
|
|
11686
|
+
*/
|
|
11589
11687
|
ElementFactory.prototype.createConnection = function(attrs) {
|
|
11590
11688
|
return this.create('connection', attrs);
|
|
11591
11689
|
};
|
|
11592
11690
|
|
|
11593
11691
|
/**
|
|
11594
|
-
* Create a model element
|
|
11595
|
-
* a number of pre-set attributes.
|
|
11692
|
+
* Create a model element of the given type with the given attributes.
|
|
11596
11693
|
*
|
|
11597
|
-
* @param
|
|
11598
|
-
* @param
|
|
11599
|
-
*
|
|
11694
|
+
* @param {string} type The type of the model element.
|
|
11695
|
+
* @param {Object} attrs The attributes of the model element.
|
|
11696
|
+
*
|
|
11697
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11600
11698
|
*/
|
|
11601
11699
|
ElementFactory.prototype.create = function(type, attrs) {
|
|
11602
11700
|
|
|
@@ -11615,6 +11713,16 @@
|
|
|
11615
11713
|
|
|
11616
11714
|
var slice = Array.prototype.slice;
|
|
11617
11715
|
|
|
11716
|
+
/**
|
|
11717
|
+
* @typedef {import('./EventBus').Event} Event
|
|
11718
|
+
* @typedef {import('./EventBus').EventCallback} EventCallback
|
|
11719
|
+
*
|
|
11720
|
+
* @typedef {Object} EventListener
|
|
11721
|
+
* @property {Function} callback
|
|
11722
|
+
* @property {EventListener|null} next
|
|
11723
|
+
* @property {number} priority
|
|
11724
|
+
*/
|
|
11725
|
+
|
|
11618
11726
|
/**
|
|
11619
11727
|
* A general purpose event bus.
|
|
11620
11728
|
*
|
|
@@ -11719,10 +11827,10 @@
|
|
|
11719
11827
|
*
|
|
11720
11828
|
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
11721
11829
|
*
|
|
11722
|
-
* @param {string|
|
|
11723
|
-
* @param {number} [priority=1000]
|
|
11724
|
-
* @param {
|
|
11725
|
-
* @param {
|
|
11830
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
11831
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11832
|
+
* @param {EventCallback} callback The callback.
|
|
11833
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11726
11834
|
*/
|
|
11727
11835
|
EventBus.prototype.on = function(events, priority, callback, that) {
|
|
11728
11836
|
|
|
@@ -11762,12 +11870,12 @@
|
|
|
11762
11870
|
|
|
11763
11871
|
|
|
11764
11872
|
/**
|
|
11765
|
-
* Register an event listener that is
|
|
11873
|
+
* Register an event listener that is called only once.
|
|
11766
11874
|
*
|
|
11767
|
-
* @param {string} event
|
|
11768
|
-
* @param {number} [priority=1000]
|
|
11769
|
-
* @param {
|
|
11770
|
-
* @param {
|
|
11875
|
+
* @param {string} event The event to listen to.
|
|
11876
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11877
|
+
* @param {EventCallback} callback The callback.
|
|
11878
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11771
11879
|
*/
|
|
11772
11880
|
EventBus.prototype.once = function(event, priority, callback, that) {
|
|
11773
11881
|
var self = this;
|
|
@@ -11806,8 +11914,8 @@
|
|
|
11806
11914
|
*
|
|
11807
11915
|
* If no callback is given, all listeners for a given event name are being removed.
|
|
11808
11916
|
*
|
|
11809
|
-
* @param {string|
|
|
11810
|
-
* @param {
|
|
11917
|
+
* @param {string|string[]} events The events.
|
|
11918
|
+
* @param {EventCallback} [callback] The callback.
|
|
11811
11919
|
*/
|
|
11812
11920
|
EventBus.prototype.off = function(events, callback) {
|
|
11813
11921
|
|
|
@@ -11823,11 +11931,11 @@
|
|
|
11823
11931
|
|
|
11824
11932
|
|
|
11825
11933
|
/**
|
|
11826
|
-
* Create an
|
|
11934
|
+
* Create an event recognized be the event bus.
|
|
11827
11935
|
*
|
|
11828
|
-
* @param {Object} data
|
|
11936
|
+
* @param {Object} data Event data.
|
|
11829
11937
|
*
|
|
11830
|
-
* @return {
|
|
11938
|
+
* @return {Event} An event that will be recognized by the event bus.
|
|
11831
11939
|
*/
|
|
11832
11940
|
EventBus.prototype.createEvent = function(data) {
|
|
11833
11941
|
var event = new InternalEvent();
|
|
@@ -11839,7 +11947,7 @@
|
|
|
11839
11947
|
|
|
11840
11948
|
|
|
11841
11949
|
/**
|
|
11842
|
-
* Fires
|
|
11950
|
+
* Fires an event.
|
|
11843
11951
|
*
|
|
11844
11952
|
* @example
|
|
11845
11953
|
*
|
|
@@ -11861,12 +11969,11 @@
|
|
|
11861
11969
|
*
|
|
11862
11970
|
* events.fire({ type: 'foo' }, 'I am bar!');
|
|
11863
11971
|
*
|
|
11864
|
-
* @param {string} [
|
|
11865
|
-
* @param {Object} [
|
|
11866
|
-
* @param {
|
|
11972
|
+
* @param {string} [type] The event type.
|
|
11973
|
+
* @param {Object} [data] The event or event data.
|
|
11974
|
+
* @param {...*} additional Additional arguments the callback will be called with.
|
|
11867
11975
|
*
|
|
11868
|
-
* @return {
|
|
11869
|
-
* default action was prevented by listeners
|
|
11976
|
+
* @return {*} The return value. Will be set to `false` if the default was prevented.
|
|
11870
11977
|
*/
|
|
11871
11978
|
EventBus.prototype.fire = function(type, data) {
|
|
11872
11979
|
var event,
|
|
@@ -11931,7 +12038,13 @@
|
|
|
11931
12038
|
return returnValue;
|
|
11932
12039
|
};
|
|
11933
12040
|
|
|
11934
|
-
|
|
12041
|
+
/**
|
|
12042
|
+
* Handle an error by firing an event.
|
|
12043
|
+
*
|
|
12044
|
+
* @param {Error} error The error to be handled.
|
|
12045
|
+
*
|
|
12046
|
+
* @return {boolean} Whether the error was handled.
|
|
12047
|
+
*/
|
|
11935
12048
|
EventBus.prototype.handleError = function(error) {
|
|
11936
12049
|
return this.fire('error', { error: error }) === false;
|
|
11937
12050
|
};
|
|
@@ -11994,7 +12107,7 @@
|
|
|
11994
12107
|
return returnValue;
|
|
11995
12108
|
};
|
|
11996
12109
|
|
|
11997
|
-
|
|
12110
|
+
/**
|
|
11998
12111
|
* Add new listener with a certain priority to the list
|
|
11999
12112
|
* of listeners (for the given event).
|
|
12000
12113
|
*
|
|
@@ -12008,7 +12121,7 @@
|
|
|
12008
12121
|
* * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
|
|
12009
12122
|
*
|
|
12010
12123
|
* @param {string} event
|
|
12011
|
-
* @param {
|
|
12124
|
+
* @param {EventListener} listener
|
|
12012
12125
|
*/
|
|
12013
12126
|
EventBus.prototype._addListener = function(event, newListener) {
|
|
12014
12127
|
|
|
@@ -12114,9 +12227,9 @@
|
|
|
12114
12227
|
* Invoke function. Be fast...
|
|
12115
12228
|
*
|
|
12116
12229
|
* @param {Function} fn
|
|
12117
|
-
* @param {
|
|
12230
|
+
* @param {*[]} args
|
|
12118
12231
|
*
|
|
12119
|
-
* @return {
|
|
12232
|
+
* @return {*}
|
|
12120
12233
|
*/
|
|
12121
12234
|
function invokeFunction(fn, args) {
|
|
12122
12235
|
return fn.apply(null, args);
|
|
@@ -12130,11 +12243,11 @@
|
|
|
12130
12243
|
*/
|
|
12131
12244
|
|
|
12132
12245
|
/**
|
|
12133
|
-
* Returns the visual part of a diagram element
|
|
12246
|
+
* Returns the visual part of a diagram element.
|
|
12134
12247
|
*
|
|
12135
|
-
* @param {
|
|
12248
|
+
* @param {SVGElement} gfx
|
|
12136
12249
|
*
|
|
12137
|
-
* @return {
|
|
12250
|
+
* @return {SVGElement}
|
|
12138
12251
|
*/
|
|
12139
12252
|
function getVisual(gfx) {
|
|
12140
12253
|
return gfx.childNodes[0];
|
|
@@ -12143,15 +12256,28 @@
|
|
|
12143
12256
|
/**
|
|
12144
12257
|
* Returns the children for a given diagram element.
|
|
12145
12258
|
*
|
|
12146
|
-
* @param {
|
|
12147
|
-
* @return {
|
|
12259
|
+
* @param {SVGElement} gfx
|
|
12260
|
+
* @return {SVGElement}
|
|
12148
12261
|
*/
|
|
12149
12262
|
function getChildren(gfx) {
|
|
12150
12263
|
return gfx.parentNode.childNodes[1];
|
|
12151
12264
|
}
|
|
12152
12265
|
|
|
12153
12266
|
/**
|
|
12154
|
-
*
|
|
12267
|
+
* @typedef {import('../model').ModelType} ModelType
|
|
12268
|
+
* @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
|
|
12269
|
+
* @typedef {import('../model').ModelTypeShape} ModelTypeShape
|
|
12270
|
+
*
|
|
12271
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
12272
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
12273
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
12274
|
+
*
|
|
12275
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
12276
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
12277
|
+
*/
|
|
12278
|
+
|
|
12279
|
+
/**
|
|
12280
|
+
* A factory that creates graphical elements.
|
|
12155
12281
|
*
|
|
12156
12282
|
* @param {EventBus} eventBus
|
|
12157
12283
|
* @param {ElementRegistry} elementRegistry
|
|
@@ -12219,7 +12345,7 @@
|
|
|
12219
12345
|
* </g>
|
|
12220
12346
|
*
|
|
12221
12347
|
* @param {string} type the type of the element, i.e. shape | connection
|
|
12222
|
-
* @param {SVGElement}
|
|
12348
|
+
* @param {SVGElement} childrenGfx
|
|
12223
12349
|
* @param {number} [parentIndex] position to create container in parent
|
|
12224
12350
|
* @param {boolean} [isFrame] is frame element
|
|
12225
12351
|
*
|
|
@@ -12257,11 +12383,25 @@
|
|
|
12257
12383
|
return gfx;
|
|
12258
12384
|
};
|
|
12259
12385
|
|
|
12386
|
+
/**
|
|
12387
|
+
* Create a graphical element.
|
|
12388
|
+
*
|
|
12389
|
+
* @param {ModelType} type The type of the element.
|
|
12390
|
+
* @param {ElementLike} element The element.
|
|
12391
|
+
* @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
|
|
12392
|
+
*
|
|
12393
|
+
* @return {SVGElement} The graphical element.
|
|
12394
|
+
*/
|
|
12260
12395
|
GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
|
12261
12396
|
var childrenGfx = this._getChildrenContainer(element.parent);
|
|
12262
12397
|
return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
|
12263
12398
|
};
|
|
12264
12399
|
|
|
12400
|
+
/**
|
|
12401
|
+
* Update the containments of the given elements.
|
|
12402
|
+
*
|
|
12403
|
+
* @param {ElementLike[]} elements The elements.
|
|
12404
|
+
*/
|
|
12265
12405
|
GraphicsFactory.prototype.updateContainments = function(elements) {
|
|
12266
12406
|
|
|
12267
12407
|
var self = this,
|
|
@@ -12297,30 +12437,63 @@
|
|
|
12297
12437
|
});
|
|
12298
12438
|
};
|
|
12299
12439
|
|
|
12440
|
+
/**
|
|
12441
|
+
* Draw a shape.
|
|
12442
|
+
*
|
|
12443
|
+
* @param {SVGElement} visual The graphical element.
|
|
12444
|
+
* @param {ShapeLike} element The shape.
|
|
12445
|
+
*/
|
|
12300
12446
|
GraphicsFactory.prototype.drawShape = function(visual, element) {
|
|
12301
12447
|
var eventBus = this._eventBus;
|
|
12302
12448
|
|
|
12303
12449
|
return eventBus.fire('render.shape', { gfx: visual, element: element });
|
|
12304
12450
|
};
|
|
12305
12451
|
|
|
12452
|
+
/**
|
|
12453
|
+
* Get the path of a shape.
|
|
12454
|
+
*
|
|
12455
|
+
* @param {ShapeLike} element The shape.
|
|
12456
|
+
*
|
|
12457
|
+
* @return {string} The path of the shape.
|
|
12458
|
+
*/
|
|
12306
12459
|
GraphicsFactory.prototype.getShapePath = function(element) {
|
|
12307
12460
|
var eventBus = this._eventBus;
|
|
12308
12461
|
|
|
12309
12462
|
return eventBus.fire('render.getShapePath', element);
|
|
12310
12463
|
};
|
|
12311
12464
|
|
|
12465
|
+
/**
|
|
12466
|
+
* Draw a connection.
|
|
12467
|
+
*
|
|
12468
|
+
* @param {SVGElement} visual The graphical element.
|
|
12469
|
+
* @param {ConnectionLike} element The connection.
|
|
12470
|
+
*/
|
|
12312
12471
|
GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
|
12313
12472
|
var eventBus = this._eventBus;
|
|
12314
12473
|
|
|
12315
12474
|
return eventBus.fire('render.connection', { gfx: visual, element: element });
|
|
12316
12475
|
};
|
|
12317
12476
|
|
|
12318
|
-
|
|
12477
|
+
/**
|
|
12478
|
+
* Get the path of a connection.
|
|
12479
|
+
*
|
|
12480
|
+
* @param {ConnectionLike} element The connection.
|
|
12481
|
+
*
|
|
12482
|
+
* @return {string} The path of the connection.
|
|
12483
|
+
*/
|
|
12484
|
+
GraphicsFactory.prototype.getConnectionPath = function(connection) {
|
|
12319
12485
|
var eventBus = this._eventBus;
|
|
12320
12486
|
|
|
12321
|
-
return eventBus.fire('render.getConnectionPath',
|
|
12487
|
+
return eventBus.fire('render.getConnectionPath', connection);
|
|
12322
12488
|
};
|
|
12323
12489
|
|
|
12490
|
+
/**
|
|
12491
|
+
* Update an elements graphical representation.
|
|
12492
|
+
*
|
|
12493
|
+
* @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
|
|
12494
|
+
* @param {ElementLike} element The element.
|
|
12495
|
+
* @param {SVGElement} gfx The graphical representation.
|
|
12496
|
+
*/
|
|
12324
12497
|
GraphicsFactory.prototype.update = function(type, element, gfx) {
|
|
12325
12498
|
|
|
12326
12499
|
// do NOT update root element
|
|
@@ -12350,6 +12523,11 @@
|
|
|
12350
12523
|
}
|
|
12351
12524
|
};
|
|
12352
12525
|
|
|
12526
|
+
/**
|
|
12527
|
+
* Remove a graphical element.
|
|
12528
|
+
*
|
|
12529
|
+
* @param {ElementLike} element The element.
|
|
12530
|
+
*/
|
|
12353
12531
|
GraphicsFactory.prototype.remove = function(element) {
|
|
12354
12532
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12355
12533
|
|
|
@@ -12383,13 +12561,17 @@
|
|
|
12383
12561
|
};
|
|
12384
12562
|
|
|
12385
12563
|
/**
|
|
12386
|
-
* @typedef {
|
|
12564
|
+
* @typedef {import('didi').InjectionContext} InjectionContext
|
|
12565
|
+
* @typedef {import('didi').LocalsMap} LocalsMap
|
|
12566
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
12567
|
+
*
|
|
12568
|
+
* @typedef {import('./Diagram').DiagramOptions} DiagramOptions
|
|
12387
12569
|
*/
|
|
12388
12570
|
|
|
12389
12571
|
/**
|
|
12390
12572
|
* Bootstrap an injector from a list of modules, instantiating a number of default components
|
|
12391
12573
|
*
|
|
12392
|
-
* @param {
|
|
12574
|
+
* @param {ModuleDeclaration[]} modules
|
|
12393
12575
|
*
|
|
12394
12576
|
* @return {Injector} a injector to use to access the components
|
|
12395
12577
|
*/
|
|
@@ -12404,7 +12586,8 @@
|
|
|
12404
12586
|
/**
|
|
12405
12587
|
* Creates an injector from passed options.
|
|
12406
12588
|
*
|
|
12407
|
-
* @param {
|
|
12589
|
+
* @param {DiagramOptions} [options]
|
|
12590
|
+
*
|
|
12408
12591
|
* @return {Injector}
|
|
12409
12592
|
*/
|
|
12410
12593
|
function createInjector(options) {
|
|
@@ -12427,8 +12610,7 @@
|
|
|
12427
12610
|
*
|
|
12428
12611
|
* To register extensions with the diagram, pass them as Array<Module> to the constructor.
|
|
12429
12612
|
*
|
|
12430
|
-
* @class
|
|
12431
|
-
* @memberOf djs
|
|
12613
|
+
* @class
|
|
12432
12614
|
* @constructor
|
|
12433
12615
|
*
|
|
12434
12616
|
* @example
|
|
@@ -12466,9 +12648,9 @@
|
|
|
12466
12648
|
*
|
|
12467
12649
|
* // 'shape ... was added to the diagram' logged to console
|
|
12468
12650
|
*
|
|
12469
|
-
* @param {
|
|
12470
|
-
* @param {
|
|
12471
|
-
* @param {Injector} [injector]
|
|
12651
|
+
* @param {DiagramOptions} [options]
|
|
12652
|
+
* @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
|
|
12653
|
+
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
|
|
12472
12654
|
*/
|
|
12473
12655
|
function Diagram(options, injector) {
|
|
12474
12656
|
|
|
@@ -12478,22 +12660,23 @@
|
|
|
12478
12660
|
// API
|
|
12479
12661
|
|
|
12480
12662
|
/**
|
|
12481
|
-
* Resolves a diagram service
|
|
12663
|
+
* Resolves a diagram service.
|
|
12482
12664
|
*
|
|
12483
12665
|
* @method Diagram#get
|
|
12484
12666
|
*
|
|
12485
|
-
* @param {string} name
|
|
12486
|
-
* @param {boolean} [strict=true]
|
|
12667
|
+
* @param {string} name The name of the service to get.
|
|
12668
|
+
* @param {boolean} [strict=true] If false, resolve missing services to null.
|
|
12487
12669
|
*/
|
|
12488
12670
|
this.get = injector.get;
|
|
12489
12671
|
|
|
12490
12672
|
/**
|
|
12491
|
-
* Executes a function
|
|
12673
|
+
* Executes a function with its dependencies injected.
|
|
12492
12674
|
*
|
|
12493
12675
|
* @method Diagram#invoke
|
|
12494
12676
|
*
|
|
12495
|
-
* @param {Function
|
|
12496
|
-
* @param {
|
|
12677
|
+
* @param {Function} fn The function to be executed.
|
|
12678
|
+
* @param {InjectionContext} [context] The context.
|
|
12679
|
+
* @param {LocalsMap} [locals] The locals.
|
|
12497
12680
|
*/
|
|
12498
12681
|
this.invoke = injector.invoke;
|
|
12499
12682
|
|
|
@@ -20899,7 +21082,20 @@
|
|
|
20899
21082
|
|
|
20900
21083
|
|
|
20901
21084
|
/**
|
|
20902
|
-
* @typedef {
|
|
21085
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
21086
|
+
*
|
|
21087
|
+
* @typedef {import('./BaseViewer').BaseModelerOptions} BaseModelerOptions
|
|
21088
|
+
* @typedef {import('./BaseViewer').ModdleElement} ModdleElement
|
|
21089
|
+
* @typedef {import('./BaseViewer').ImportXMLResult} ImportXMLResult
|
|
21090
|
+
* @typedef {import('./BaseViewer').ImportXMLError} ImportXMLError
|
|
21091
|
+
* @typedef {import('./BaseViewer').ImportDefinitionsResult} ImportDefinitionsResult
|
|
21092
|
+
* @typedef {import('./BaseViewer').ImportDefinitionsError} ImportDefinitionsError
|
|
21093
|
+
* @typedef {import('./BaseViewer').ModdleElement} ModdleElement
|
|
21094
|
+
* @typedef {import('./BaseViewer').ModdleElementsById} ModdleElementsById
|
|
21095
|
+
* @typedef {import('./BaseViewer').OpenResult} OpenResult
|
|
21096
|
+
* @typedef {import('./BaseViewer').OpenError} OpenError
|
|
21097
|
+
* @typedef {import('./BaseViewer').SaveXMLOptions} SaveXMLOptions
|
|
21098
|
+
* @typedef {import('./BaseViewer').SaveXMLResult} SaveXMLResult
|
|
20903
21099
|
*/
|
|
20904
21100
|
|
|
20905
21101
|
/**
|
|
@@ -20908,20 +21104,20 @@
|
|
|
20908
21104
|
* Have a look at {@link Viewer}, {@link NavigatedViewer} or {@link Modeler} for
|
|
20909
21105
|
* bundles that include actual features.
|
|
20910
21106
|
*
|
|
20911
|
-
* @param {
|
|
20912
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
20913
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
20914
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
20915
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
20916
|
-
* @param {Module[]} [options.modules] a list of modules to override the default modules
|
|
20917
|
-
* @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
|
|
21107
|
+
* @param {BaseModelerOptions} [options] The options to configure the viewer.
|
|
20918
21108
|
*/
|
|
20919
21109
|
function BaseViewer(options) {
|
|
20920
21110
|
|
|
21111
|
+
/**
|
|
21112
|
+
* @type {BaseModelerOptions}
|
|
21113
|
+
*/
|
|
20921
21114
|
options = assign$1({}, DEFAULT_OPTIONS, options);
|
|
20922
21115
|
|
|
20923
21116
|
this._moddle = this._createModdle(options);
|
|
20924
21117
|
|
|
21118
|
+
/**
|
|
21119
|
+
* @type {HTMLElement}
|
|
21120
|
+
*/
|
|
20925
21121
|
this._container = this._createContainer(options);
|
|
20926
21122
|
|
|
20927
21123
|
/* <project-logo> */
|
|
@@ -20935,22 +21131,6 @@
|
|
|
20935
21131
|
|
|
20936
21132
|
e(BaseViewer, Diagram);
|
|
20937
21133
|
|
|
20938
|
-
/**
|
|
20939
|
-
* The importXML result.
|
|
20940
|
-
*
|
|
20941
|
-
* @typedef {Object} ImportXMLResult
|
|
20942
|
-
*
|
|
20943
|
-
* @property {Array<string>} warnings
|
|
20944
|
-
*/
|
|
20945
|
-
|
|
20946
|
-
/**
|
|
20947
|
-
* The importXML error.
|
|
20948
|
-
*
|
|
20949
|
-
* @typedef {Error} ImportXMLError
|
|
20950
|
-
*
|
|
20951
|
-
* @property {Array<string>} warnings
|
|
20952
|
-
*/
|
|
20953
|
-
|
|
20954
21134
|
/**
|
|
20955
21135
|
* Parse and render a BPMN 2.0 diagram.
|
|
20956
21136
|
*
|
|
@@ -20961,7 +21141,7 @@
|
|
|
20961
21141
|
*
|
|
20962
21142
|
* During import the viewer will fire life-cycle events:
|
|
20963
21143
|
*
|
|
20964
|
-
* * import.parse.start (about to read model from
|
|
21144
|
+
* * import.parse.start (about to read model from XML)
|
|
20965
21145
|
* * import.parse.complete (model read; may have worked or not)
|
|
20966
21146
|
* * import.render.start (graphical import start)
|
|
20967
21147
|
* * import.render.complete (graphical import finished)
|
|
@@ -20969,10 +21149,18 @@
|
|
|
20969
21149
|
*
|
|
20970
21150
|
* You can use these events to hook into the life-cycle.
|
|
20971
21151
|
*
|
|
20972
|
-
* @
|
|
20973
|
-
* @param {ModdleElement<BPMNDiagram>|string} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
|
|
21152
|
+
* @throws {ImportXMLError} An error thrown during the import of the XML.
|
|
20974
21153
|
*
|
|
20975
|
-
*
|
|
21154
|
+
* @fires BaseViewer#ImportParseStart
|
|
21155
|
+
* @fires BaseViewer#ImportParseComplete
|
|
21156
|
+
* @fires Importer#ImportRenderStart
|
|
21157
|
+
* @fires Importer#ImportRenderComplete
|
|
21158
|
+
* @fires BaseViewer#ImportDone
|
|
21159
|
+
*
|
|
21160
|
+
* @param {string} xml The BPMN 2.0 XML to be imported.
|
|
21161
|
+
* @param {ModdleElement|string} [bpmnDiagram] The optional diagram or Id of the BPMN diagram to open.
|
|
21162
|
+
*
|
|
21163
|
+
* @return {Promise<ImportXMLResult>} A promise resolving with warnings that were produced during the import.
|
|
20976
21164
|
*/
|
|
20977
21165
|
BaseViewer.prototype.importXML = wrapForCompatibility(async function importXML(xml, bpmnDiagram) {
|
|
20978
21166
|
|
|
@@ -21008,6 +21196,14 @@
|
|
|
21008
21196
|
|
|
21009
21197
|
// hook in pre-parse listeners +
|
|
21010
21198
|
// allow xml manipulation
|
|
21199
|
+
|
|
21200
|
+
/**
|
|
21201
|
+
* A `import.parse.start` event.
|
|
21202
|
+
*
|
|
21203
|
+
* @event BaseViewer#ImportParseStart
|
|
21204
|
+
* @type {Object}
|
|
21205
|
+
* @property {string} xml The XML that is to be parsed.
|
|
21206
|
+
*/
|
|
21011
21207
|
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
|
21012
21208
|
|
|
21013
21209
|
let parseResult;
|
|
@@ -21030,6 +21226,18 @@
|
|
|
21030
21226
|
|
|
21031
21227
|
// hook in post parse listeners +
|
|
21032
21228
|
// allow definitions manipulation
|
|
21229
|
+
|
|
21230
|
+
/**
|
|
21231
|
+
* A `import.parse.complete` event.
|
|
21232
|
+
*
|
|
21233
|
+
* @event BaseViewer#ImportParseComplete
|
|
21234
|
+
* @type {Object}
|
|
21235
|
+
* @property {Error|null} error An error thrown when parsing the XML.
|
|
21236
|
+
* @property {ModdleElement} definitions The definitions model element.
|
|
21237
|
+
* @property {ModdleElementsById} elementsById The model elements by ID.
|
|
21238
|
+
* @property {ModdleElement[]} references The referenced model elements.
|
|
21239
|
+
* @property {string[]} warnings The warnings produced when parsing the XML.
|
|
21240
|
+
*/
|
|
21033
21241
|
definitions = this._emit('import.parse.complete', ParseCompleteEvent({
|
|
21034
21242
|
error: null,
|
|
21035
21243
|
definitions: definitions,
|
|
@@ -21042,6 +21250,14 @@
|
|
|
21042
21250
|
|
|
21043
21251
|
aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
|
|
21044
21252
|
|
|
21253
|
+
/**
|
|
21254
|
+
* A `import.parse.complete` event.
|
|
21255
|
+
*
|
|
21256
|
+
* @event BaseViewer#ImportDone
|
|
21257
|
+
* @type {Object}
|
|
21258
|
+
* @property {ImportXMLError|null} error An error thrown during import.
|
|
21259
|
+
* @property {string[]} warnings The warnings.
|
|
21260
|
+
*/
|
|
21045
21261
|
this._emit('import.done', { error: null, warnings: aggregatedWarnings });
|
|
21046
21262
|
|
|
21047
21263
|
return { warnings: aggregatedWarnings };
|
|
@@ -21058,21 +21274,6 @@
|
|
|
21058
21274
|
}
|
|
21059
21275
|
});
|
|
21060
21276
|
|
|
21061
|
-
/**
|
|
21062
|
-
* The importDefinitions result.
|
|
21063
|
-
*
|
|
21064
|
-
* @typedef {Object} ImportDefinitionsResult
|
|
21065
|
-
*
|
|
21066
|
-
* @property {Array<string>} warnings
|
|
21067
|
-
*/
|
|
21068
|
-
|
|
21069
|
-
/**
|
|
21070
|
-
* The importDefinitions error.
|
|
21071
|
-
*
|
|
21072
|
-
* @typedef {Error} ImportDefinitionsError
|
|
21073
|
-
*
|
|
21074
|
-
* @property {Array<string>} warnings
|
|
21075
|
-
*/
|
|
21076
21277
|
|
|
21077
21278
|
/**
|
|
21078
21279
|
* Import parsed definitions and render a BPMN 2.0 diagram.
|
|
@@ -21089,10 +21290,12 @@
|
|
|
21089
21290
|
*
|
|
21090
21291
|
* You can use these events to hook into the life-cycle.
|
|
21091
21292
|
*
|
|
21092
|
-
* @
|
|
21093
|
-
*
|
|
21293
|
+
* @throws {ImportDefinitionsError} An error thrown during the import of the definitions.
|
|
21294
|
+
*
|
|
21295
|
+
* @param {ModdleElement} definitions The definitions.
|
|
21296
|
+
* @param {ModdleElement|string} [bpmnDiagram] The optional diagram or ID of the BPMN diagram to open.
|
|
21094
21297
|
*
|
|
21095
|
-
*
|
|
21298
|
+
* @return {Promise<ImportDefinitionsResult>} A promise resolving with warnings that were produced during the import.
|
|
21096
21299
|
*/
|
|
21097
21300
|
BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
|
|
21098
21301
|
this._setDefinitions(definitions);
|
|
@@ -21101,21 +21304,6 @@
|
|
|
21101
21304
|
return { warnings: result.warnings };
|
|
21102
21305
|
});
|
|
21103
21306
|
|
|
21104
|
-
/**
|
|
21105
|
-
* The open result.
|
|
21106
|
-
*
|
|
21107
|
-
* @typedef {Object} OpenResult
|
|
21108
|
-
*
|
|
21109
|
-
* @property {Array<string>} warnings
|
|
21110
|
-
*/
|
|
21111
|
-
|
|
21112
|
-
/**
|
|
21113
|
-
* The open error.
|
|
21114
|
-
*
|
|
21115
|
-
* @typedef {Error} OpenError
|
|
21116
|
-
*
|
|
21117
|
-
* @property {Array<string>} warnings
|
|
21118
|
-
*/
|
|
21119
21307
|
|
|
21120
21308
|
/**
|
|
21121
21309
|
* Open diagram of previously imported XML.
|
|
@@ -21132,9 +21320,11 @@
|
|
|
21132
21320
|
*
|
|
21133
21321
|
* You can use these events to hook into the life-cycle.
|
|
21134
21322
|
*
|
|
21135
|
-
* @
|
|
21323
|
+
* @throws {OpenError} An error thrown during opening.
|
|
21136
21324
|
*
|
|
21137
|
-
*
|
|
21325
|
+
* @param {ModdleElement|string} bpmnDiagramOrId The diagram or Id of the BPMN diagram to open.
|
|
21326
|
+
*
|
|
21327
|
+
* @return {Promise<OpenResult>} A promise resolving with warnings that were produced during opening.
|
|
21138
21328
|
*/
|
|
21139
21329
|
BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
|
|
21140
21330
|
|
|
@@ -21175,14 +21365,6 @@
|
|
|
21175
21365
|
return { warnings };
|
|
21176
21366
|
});
|
|
21177
21367
|
|
|
21178
|
-
/**
|
|
21179
|
-
* The saveXML result.
|
|
21180
|
-
*
|
|
21181
|
-
* @typedef {Object} SaveXMLResult
|
|
21182
|
-
*
|
|
21183
|
-
* @property {string} xml
|
|
21184
|
-
*/
|
|
21185
|
-
|
|
21186
21368
|
/**
|
|
21187
21369
|
* Export the currently displayed BPMN 2.0 diagram as
|
|
21188
21370
|
* a BPMN 2.0 XML document.
|
|
@@ -21197,11 +21379,14 @@
|
|
|
21197
21379
|
*
|
|
21198
21380
|
* You can use these events to hook into the life-cycle.
|
|
21199
21381
|
*
|
|
21200
|
-
* @
|
|
21201
|
-
* @param {boolean} [options.format=false] output formatted XML
|
|
21202
|
-
* @param {boolean} [options.preamble=true] output preamble
|
|
21382
|
+
* @throws {Error} An error thrown during export.
|
|
21203
21383
|
*
|
|
21204
|
-
*
|
|
21384
|
+
* @fires BaseViewer#SaveXMLStart
|
|
21385
|
+
* @fires BaseViewer#SaveXMLDone
|
|
21386
|
+
*
|
|
21387
|
+
* @param {SaveXMLOptions} [options] The options.
|
|
21388
|
+
*
|
|
21389
|
+
* @return {Promise<SaveXMLResult>} A promise resolving with the XML.
|
|
21205
21390
|
*/
|
|
21206
21391
|
BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
|
|
21207
21392
|
|
|
@@ -21216,6 +21401,14 @@
|
|
|
21216
21401
|
}
|
|
21217
21402
|
|
|
21218
21403
|
// allow to fiddle around with definitions
|
|
21404
|
+
|
|
21405
|
+
/**
|
|
21406
|
+
* A `saveXML.start` event.
|
|
21407
|
+
*
|
|
21408
|
+
* @event BaseViewer#SaveXMLStart
|
|
21409
|
+
* @type {Object}
|
|
21410
|
+
* @property {ModdleElement} definitions The definitions model element.
|
|
21411
|
+
*/
|
|
21219
21412
|
definitions = this._emit('saveXML.start', {
|
|
21220
21413
|
definitions
|
|
21221
21414
|
}) || definitions;
|
|
@@ -21232,6 +21425,14 @@
|
|
|
21232
21425
|
|
|
21233
21426
|
const result = error ? { error } : { xml };
|
|
21234
21427
|
|
|
21428
|
+
/**
|
|
21429
|
+
* A `saveXML.done` event.
|
|
21430
|
+
*
|
|
21431
|
+
* @event BaseViewer#SaveXMLDone
|
|
21432
|
+
* @type {Object}
|
|
21433
|
+
* @property {Error} [error] An error thrown when saving the XML.
|
|
21434
|
+
* @property {string} [xml] The saved XML.
|
|
21435
|
+
*/
|
|
21235
21436
|
this._emit('saveXML.done', result);
|
|
21236
21437
|
|
|
21237
21438
|
if (error) {
|
|
@@ -21241,13 +21442,6 @@
|
|
|
21241
21442
|
return result;
|
|
21242
21443
|
});
|
|
21243
21444
|
|
|
21244
|
-
/**
|
|
21245
|
-
* The saveSVG result.
|
|
21246
|
-
*
|
|
21247
|
-
* @typedef {Object} SaveSVGResult
|
|
21248
|
-
*
|
|
21249
|
-
* @property {string} svg
|
|
21250
|
-
*/
|
|
21251
21445
|
|
|
21252
21446
|
/**
|
|
21253
21447
|
* Export the currently displayed BPMN 2.0 diagram as
|
|
@@ -21262,11 +21456,13 @@
|
|
|
21262
21456
|
*
|
|
21263
21457
|
* You can use these events to hook into the life-cycle.
|
|
21264
21458
|
*
|
|
21265
|
-
* @
|
|
21459
|
+
* @throws {Error} An error thrown during export.
|
|
21460
|
+
*
|
|
21461
|
+
* @fires BaseViewer#SaveSVGDone
|
|
21266
21462
|
*
|
|
21267
|
-
*
|
|
21463
|
+
* @return {Promise<SaveSVGResult>} A promise resolving with the SVG.
|
|
21268
21464
|
*/
|
|
21269
|
-
BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(
|
|
21465
|
+
BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG() {
|
|
21270
21466
|
this._emit('saveSVG.start');
|
|
21271
21467
|
|
|
21272
21468
|
let svg, err;
|
|
@@ -21295,6 +21491,14 @@
|
|
|
21295
21491
|
err = e;
|
|
21296
21492
|
}
|
|
21297
21493
|
|
|
21494
|
+
/**
|
|
21495
|
+
* A `saveSVG.done` event.
|
|
21496
|
+
*
|
|
21497
|
+
* @event BaseViewer#SaveSVGDone
|
|
21498
|
+
* @type {Object}
|
|
21499
|
+
* @property {Error} [error] An error thrown when saving the SVG.
|
|
21500
|
+
* @property {string} [svg] The saved SVG.
|
|
21501
|
+
*/
|
|
21298
21502
|
this._emit('saveSVG.done', {
|
|
21299
21503
|
error: err,
|
|
21300
21504
|
svg: svg
|
|
@@ -21346,21 +21550,17 @@
|
|
|
21346
21550
|
/**
|
|
21347
21551
|
* Return modules to instantiate with.
|
|
21348
21552
|
*
|
|
21349
|
-
* @
|
|
21350
|
-
*
|
|
21351
|
-
* @return {Module[]}
|
|
21553
|
+
* @return {ModuleDeclaration[]} The modules.
|
|
21352
21554
|
*/
|
|
21353
|
-
BaseViewer.prototype.getModules = function(
|
|
21555
|
+
BaseViewer.prototype.getModules = function() {
|
|
21354
21556
|
return this._modules;
|
|
21355
21557
|
};
|
|
21356
21558
|
|
|
21357
21559
|
/**
|
|
21358
21560
|
* Remove all drawn elements from the viewer.
|
|
21359
21561
|
*
|
|
21360
|
-
* After calling this method the viewer can still
|
|
21361
|
-
*
|
|
21362
|
-
*
|
|
21363
|
-
* @method BaseViewer#clear
|
|
21562
|
+
* After calling this method the viewer can still be reused for opening another
|
|
21563
|
+
* diagram.
|
|
21364
21564
|
*/
|
|
21365
21565
|
BaseViewer.prototype.clear = function() {
|
|
21366
21566
|
if (!this.getDefinitions()) {
|
|
@@ -21374,8 +21574,8 @@
|
|
|
21374
21574
|
};
|
|
21375
21575
|
|
|
21376
21576
|
/**
|
|
21377
|
-
* Destroy the viewer instance and remove all its
|
|
21378
|
-
*
|
|
21577
|
+
* Destroy the viewer instance and remove all its remainders from the document
|
|
21578
|
+
* tree.
|
|
21379
21579
|
*/
|
|
21380
21580
|
BaseViewer.prototype.destroy = function() {
|
|
21381
21581
|
|
|
@@ -21387,29 +21587,34 @@
|
|
|
21387
21587
|
};
|
|
21388
21588
|
|
|
21389
21589
|
/**
|
|
21390
|
-
* Register an event listener
|
|
21590
|
+
* Register an event listener.
|
|
21391
21591
|
*
|
|
21392
|
-
* Remove
|
|
21592
|
+
* Remove an event listener via {@link BaseViewer#off}.
|
|
21393
21593
|
*
|
|
21394
|
-
* @param {string} event
|
|
21395
|
-
* @param {number} [priority]
|
|
21396
|
-
* @param {
|
|
21397
|
-
* @param {
|
|
21594
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
21595
|
+
* @param {number} [priority] The priority with which to listen.
|
|
21596
|
+
* @param {EventCallback} callback The callback.
|
|
21597
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
21398
21598
|
*/
|
|
21399
|
-
BaseViewer.prototype.on = function(
|
|
21400
|
-
return this.get('eventBus').on(
|
|
21599
|
+
BaseViewer.prototype.on = function(events, priority, callback, that) {
|
|
21600
|
+
return this.get('eventBus').on(events, priority, callback, that);
|
|
21401
21601
|
};
|
|
21402
21602
|
|
|
21403
21603
|
/**
|
|
21404
|
-
*
|
|
21604
|
+
* Remove an event listener.
|
|
21405
21605
|
*
|
|
21406
|
-
* @param {string} event
|
|
21407
|
-
* @param {Function} callback
|
|
21606
|
+
* @param {string|string[]} events The event(s).
|
|
21607
|
+
* @param {Function} [callback] The callback.
|
|
21408
21608
|
*/
|
|
21409
|
-
BaseViewer.prototype.off = function(
|
|
21410
|
-
this.get('eventBus').off(
|
|
21609
|
+
BaseViewer.prototype.off = function(events, callback) {
|
|
21610
|
+
this.get('eventBus').off(events, callback);
|
|
21411
21611
|
};
|
|
21412
21612
|
|
|
21613
|
+
/**
|
|
21614
|
+
* Attach the viewer to an HTML element.
|
|
21615
|
+
*
|
|
21616
|
+
* @param {HTMLElement} parentNode The parent node to attach to.
|
|
21617
|
+
*/
|
|
21413
21618
|
BaseViewer.prototype.attachTo = function(parentNode) {
|
|
21414
21619
|
|
|
21415
21620
|
if (!parentNode) {
|
|
@@ -21436,10 +21641,20 @@
|
|
|
21436
21641
|
this.get('canvas').resized();
|
|
21437
21642
|
};
|
|
21438
21643
|
|
|
21644
|
+
/**
|
|
21645
|
+
* Get the definitions model element.
|
|
21646
|
+
*
|
|
21647
|
+
* @returns {ModdleElement} The definitions model element.
|
|
21648
|
+
*/
|
|
21439
21649
|
BaseViewer.prototype.getDefinitions = function() {
|
|
21440
21650
|
return this._definitions;
|
|
21441
21651
|
};
|
|
21442
21652
|
|
|
21653
|
+
/**
|
|
21654
|
+
* Detach the viewer.
|
|
21655
|
+
*
|
|
21656
|
+
* @fires BaseViewer#DetachEvent
|
|
21657
|
+
*/
|
|
21443
21658
|
BaseViewer.prototype.detach = function() {
|
|
21444
21659
|
|
|
21445
21660
|
const container = this._container,
|
|
@@ -21449,6 +21664,12 @@
|
|
|
21449
21664
|
return;
|
|
21450
21665
|
}
|
|
21451
21666
|
|
|
21667
|
+
/**
|
|
21668
|
+
* A `detach` event.
|
|
21669
|
+
*
|
|
21670
|
+
* @event BaseViewer#DetachEvent
|
|
21671
|
+
* @type {Object}
|
|
21672
|
+
*/
|
|
21452
21673
|
this._emit('detach', {});
|
|
21453
21674
|
|
|
21454
21675
|
parentNode.removeChild(container);
|
|
@@ -21486,7 +21707,7 @@
|
|
|
21486
21707
|
* @param {string} type
|
|
21487
21708
|
* @param {Object} event
|
|
21488
21709
|
*
|
|
21489
|
-
* @return {Object}
|
|
21710
|
+
* @return {Object} The return value after calling all event listeners.
|
|
21490
21711
|
*/
|
|
21491
21712
|
BaseViewer.prototype._emit = function(type, event) {
|
|
21492
21713
|
return this.get('eventBus').fire(type, event);
|
|
@@ -21612,7 +21833,7 @@
|
|
|
21612
21833
|
/* </project-logo> */
|
|
21613
21834
|
|
|
21614
21835
|
/**
|
|
21615
|
-
* @typedef { import('
|
|
21836
|
+
* @typedef { import('./BaseViewer').BaseViewerOptions } BaseViewerOptions
|
|
21616
21837
|
*/
|
|
21617
21838
|
|
|
21618
21839
|
/**
|
|
@@ -21654,13 +21875,7 @@
|
|
|
21654
21875
|
* bpmnViewer.importXML(...);
|
|
21655
21876
|
* ```
|
|
21656
21877
|
*
|
|
21657
|
-
* @param {
|
|
21658
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
21659
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
21660
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
21661
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
21662
|
-
* @param {Module[]} [options.modules] a list of modules to override the default modules
|
|
21663
|
-
* @param {Module[]} [options.additionalModules] a list of modules to use with the default modules
|
|
21878
|
+
* @param {BaseViewerOptions} [options] The options to configure the viewer.
|
|
21664
21879
|
*/
|
|
21665
21880
|
function Viewer(options) {
|
|
21666
21881
|
BaseViewer.call(this, options);
|
|
@@ -21746,6 +21961,10 @@
|
|
|
21746
21961
|
);
|
|
21747
21962
|
}
|
|
21748
21963
|
|
|
21964
|
+
/**
|
|
21965
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
21966
|
+
*/
|
|
21967
|
+
|
|
21749
21968
|
var KEYDOWN_EVENT = 'keyboard.keydown',
|
|
21750
21969
|
KEYUP_EVENT = 'keyboard.keyup';
|
|
21751
21970
|
|
|
@@ -21774,7 +21993,7 @@
|
|
|
21774
21993
|
* A default binding for the keyboard may be specified via the
|
|
21775
21994
|
* `keyboard.bindTo` configuration option.
|
|
21776
21995
|
*
|
|
21777
|
-
* @param {
|
|
21996
|
+
* @param {Object} config
|
|
21778
21997
|
* @param {EventBus} eventBus
|
|
21779
21998
|
*/
|
|
21780
21999
|
function Keyboard(config, eventBus) {
|
|
@@ -22105,6 +22324,11 @@
|
|
|
22105
22324
|
keyboardBindings: [ 'type', KeyboardBindings ]
|
|
22106
22325
|
};
|
|
22107
22326
|
|
|
22327
|
+
/**
|
|
22328
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
22329
|
+
* @typedef {import('../../features/keyboard/Keyboard').default} Keyboard
|
|
22330
|
+
*/
|
|
22331
|
+
|
|
22108
22332
|
var DEFAULT_CONFIG = {
|
|
22109
22333
|
moveSpeed: 50,
|
|
22110
22334
|
moveSpeedAccelerated: 200
|
|
@@ -22277,6 +22501,11 @@
|
|
|
22277
22501
|
};
|
|
22278
22502
|
}
|
|
22279
22503
|
|
|
22504
|
+
/**
|
|
22505
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
22506
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
22507
|
+
*/
|
|
22508
|
+
|
|
22280
22509
|
var THRESHOLD = 15;
|
|
22281
22510
|
|
|
22282
22511
|
|
|
@@ -22396,8 +22625,9 @@
|
|
|
22396
22625
|
};
|
|
22397
22626
|
|
|
22398
22627
|
/**
|
|
22399
|
-
* Get the logarithm of x with base 10
|
|
22400
|
-
*
|
|
22628
|
+
* Get the logarithm of x with base 10.
|
|
22629
|
+
*
|
|
22630
|
+
* @param {number} x
|
|
22401
22631
|
*/
|
|
22402
22632
|
function log10(x) {
|
|
22403
22633
|
return Math.log(x) / Math.log(10);
|
|
@@ -22424,6 +22654,11 @@
|
|
|
22424
22654
|
return Math.max(range.min, Math.min(range.max, scale));
|
|
22425
22655
|
}
|
|
22426
22656
|
|
|
22657
|
+
/**
|
|
22658
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
22659
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
22660
|
+
*/
|
|
22661
|
+
|
|
22427
22662
|
var sign = Math.sign || function(n) {
|
|
22428
22663
|
return n >= 0 ? 1 : -1;
|
|
22429
22664
|
};
|
|
@@ -22614,7 +22849,7 @@
|
|
|
22614
22849
|
/**
|
|
22615
22850
|
* Toggle the zoom scroll ability via mouse wheel.
|
|
22616
22851
|
*
|
|
22617
|
-
* @param
|
|
22852
|
+
* @param {boolean} [newEnabled] new enabled state
|
|
22618
22853
|
*/
|
|
22619
22854
|
ZoomScroll.prototype.toggle = function toggle(newEnabled) {
|
|
22620
22855
|
|
|
@@ -22651,9 +22886,13 @@
|
|
|
22651
22886
|
};
|
|
22652
22887
|
|
|
22653
22888
|
/**
|
|
22654
|
-
*
|
|
22889
|
+
* @typedef { import('./BaseViewer').BaseViewerOptions } BaseViewerOptions
|
|
22890
|
+
*/
|
|
22891
|
+
|
|
22892
|
+
/**
|
|
22893
|
+
* A viewer with mouse and keyboard navigation features.
|
|
22655
22894
|
*
|
|
22656
|
-
* @param {
|
|
22895
|
+
* @param {BaseViewerOptions} [options]
|
|
22657
22896
|
*/
|
|
22658
22897
|
function NavigatedViewer(options) {
|
|
22659
22898
|
Viewer.call(this, options);
|