camunda-bpmn-js 1.4.0 → 2.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/README.md +1 -1
- package/dist/base-modeler.development.js +2307 -928
- package/dist/base-modeler.production.min.js +32 -33
- package/dist/base-navigated-viewer.development.js +679 -480
- package/dist/base-navigated-viewer.production.min.js +1 -3
- package/dist/base-viewer.development.js +651 -472
- package/dist/base-viewer.production.min.js +1 -3
- package/dist/camunda-cloud-modeler.development.js +7690 -2583
- package/dist/camunda-cloud-modeler.production.min.js +36 -37
- package/dist/camunda-cloud-navigated-viewer.development.js +679 -480
- package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -3
- package/dist/camunda-cloud-viewer.development.js +651 -472
- package/dist/camunda-cloud-viewer.production.min.js +1 -3
- package/dist/camunda-platform-modeler.development.js +6763 -2266
- package/dist/camunda-platform-modeler.production.min.js +35 -36
- package/dist/camunda-platform-navigated-viewer.development.js +679 -480
- package/dist/camunda-platform-navigated-viewer.production.min.js +1 -3
- package/dist/camunda-platform-viewer.development.js +651 -472
- package/dist/camunda-platform-viewer.production.min.js +1 -3
- package/lib/camunda-cloud/Modeler.js +13 -9
- package/lib/camunda-platform/Modeler.js +6 -1
- package/package.json +8 -7
|
@@ -435,6 +435,14 @@
|
|
|
435
435
|
|
|
436
436
|
var DEFAULT_RENDER_PRIORITY$1 = 1000;
|
|
437
437
|
|
|
438
|
+
/**
|
|
439
|
+
* @typedef {import('../model').Base} Base
|
|
440
|
+
* @typedef {import('../model').Connection} Connection
|
|
441
|
+
* @typedef {import('../model').Shape} Shape
|
|
442
|
+
*
|
|
443
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
444
|
+
*/
|
|
445
|
+
|
|
438
446
|
/**
|
|
439
447
|
* The base implementation of shape and connection renderers.
|
|
440
448
|
*
|
|
@@ -473,52 +481,51 @@
|
|
|
473
481
|
}
|
|
474
482
|
|
|
475
483
|
/**
|
|
476
|
-
*
|
|
477
|
-
* the element/connection.
|
|
484
|
+
* Checks whether an element can be rendered.
|
|
478
485
|
*
|
|
479
|
-
* @param {
|
|
486
|
+
* @param {Base} element The element to be rendered.
|
|
480
487
|
*
|
|
481
|
-
* @returns {boolean}
|
|
488
|
+
* @returns {boolean} Whether the element can be rendered.
|
|
482
489
|
*/
|
|
483
|
-
BaseRenderer.prototype.canRender = function() {};
|
|
490
|
+
BaseRenderer.prototype.canRender = function(element) {};
|
|
484
491
|
|
|
485
492
|
/**
|
|
486
|
-
*
|
|
493
|
+
* Draws a shape.
|
|
487
494
|
*
|
|
488
|
-
* @param {
|
|
489
|
-
* @param {Shape} shape
|
|
495
|
+
* @param {SVGElement} visuals The SVG element to draw the shape into.
|
|
496
|
+
* @param {Shape} shape The shape to be drawn.
|
|
490
497
|
*
|
|
491
|
-
* @returns {
|
|
498
|
+
* @returns {SVGElement} The SVG element of the shape drawn.
|
|
492
499
|
*/
|
|
493
|
-
BaseRenderer.prototype.drawShape = function() {};
|
|
500
|
+
BaseRenderer.prototype.drawShape = function(visuals, shape) {};
|
|
494
501
|
|
|
495
502
|
/**
|
|
496
|
-
*
|
|
503
|
+
* Draws a connection.
|
|
497
504
|
*
|
|
498
|
-
* @param {
|
|
499
|
-
* @param {Connection} connection
|
|
505
|
+
* @param {SVGElement} visuals The SVG element to draw the connection into.
|
|
506
|
+
* @param {Connection} connection The connection to be drawn.
|
|
500
507
|
*
|
|
501
|
-
* @returns {
|
|
508
|
+
* @returns {SVGElement} The SVG element of the connection drawn.
|
|
502
509
|
*/
|
|
503
|
-
BaseRenderer.prototype.drawConnection = function() {};
|
|
510
|
+
BaseRenderer.prototype.drawConnection = function(visuals, connection) {};
|
|
504
511
|
|
|
505
512
|
/**
|
|
506
|
-
* Gets the SVG path of
|
|
513
|
+
* Gets the SVG path of the graphical representation of a shape.
|
|
507
514
|
*
|
|
508
|
-
* @param {Shape} shape
|
|
515
|
+
* @param {Shape} shape The shape.
|
|
509
516
|
*
|
|
510
|
-
* @return {string}
|
|
517
|
+
* @return {string} The SVG path of the shape.
|
|
511
518
|
*/
|
|
512
|
-
BaseRenderer.prototype.getShapePath = function() {};
|
|
519
|
+
BaseRenderer.prototype.getShapePath = function(shape) {};
|
|
513
520
|
|
|
514
521
|
/**
|
|
515
|
-
* Gets the SVG path of
|
|
522
|
+
* Gets the SVG path of the graphical representation of a connection.
|
|
516
523
|
*
|
|
517
|
-
* @param {Connection} connection
|
|
524
|
+
* @param {Connection} connection The connection.
|
|
518
525
|
*
|
|
519
|
-
* @return {string}
|
|
526
|
+
* @return {string} The SVG path of the connection.
|
|
520
527
|
*/
|
|
521
|
-
BaseRenderer.prototype.getConnectionPath = function() {};
|
|
528
|
+
BaseRenderer.prototype.getConnectionPath = function(connection) {};
|
|
522
529
|
|
|
523
530
|
/**
|
|
524
531
|
* Is an element of the given BPMN type?
|
|
@@ -1325,9 +1332,15 @@
|
|
|
1325
1332
|
}
|
|
1326
1333
|
|
|
1327
1334
|
/**
|
|
1328
|
-
* @
|
|
1335
|
+
* @typedef {(string|number)[]} Component
|
|
1336
|
+
*
|
|
1337
|
+
* @typedef {import('../util/Types').Point} Point
|
|
1338
|
+
*/
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* @param {Component[]} elements
|
|
1329
1342
|
*
|
|
1330
|
-
* @return {
|
|
1343
|
+
* @return {string}
|
|
1331
1344
|
*/
|
|
1332
1345
|
function componentsToPath(elements) {
|
|
1333
1346
|
return elements.flat().join(',').replace(/,?([A-z]),?/g, '$1');
|
|
@@ -1407,9 +1420,9 @@
|
|
|
1407
1420
|
}
|
|
1408
1421
|
|
|
1409
1422
|
/**
|
|
1410
|
-
* @param {
|
|
1411
|
-
* @param {
|
|
1412
|
-
* @param {
|
|
1423
|
+
* @param {Point[]} points
|
|
1424
|
+
* @param {*} [attrs]
|
|
1425
|
+
* @param {number} [radius]
|
|
1413
1426
|
*
|
|
1414
1427
|
* @return {SVGElement}
|
|
1415
1428
|
*/
|
|
@@ -1434,8 +1447,8 @@
|
|
|
1434
1447
|
}
|
|
1435
1448
|
|
|
1436
1449
|
/**
|
|
1437
|
-
* @param {
|
|
1438
|
-
* @param {
|
|
1450
|
+
* @param {SVGElement} gfx
|
|
1451
|
+
* @param {Point[]} points
|
|
1439
1452
|
*
|
|
1440
1453
|
* @return {SVGElement}
|
|
1441
1454
|
*/
|
|
@@ -2156,7 +2169,7 @@
|
|
|
2156
2169
|
}
|
|
2157
2170
|
|
|
2158
2171
|
/**
|
|
2159
|
-
* @param {
|
|
2172
|
+
* @param {SVGElement} element
|
|
2160
2173
|
* @param {number} x
|
|
2161
2174
|
* @param {number} y
|
|
2162
2175
|
* @param {number} angle
|
|
@@ -4236,6 +4249,10 @@
|
|
|
4236
4249
|
return getRectPath(element);
|
|
4237
4250
|
};
|
|
4238
4251
|
|
|
4252
|
+
/**
|
|
4253
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
4254
|
+
*/
|
|
4255
|
+
|
|
4239
4256
|
var DEFAULT_BOX_PADDING = 0;
|
|
4240
4257
|
|
|
4241
4258
|
var DEFAULT_LABEL_SIZE$1 = {
|
|
@@ -4309,7 +4326,8 @@
|
|
|
4309
4326
|
*
|
|
4310
4327
|
* Alters the lines passed.
|
|
4311
4328
|
*
|
|
4312
|
-
* @param
|
|
4329
|
+
* @param {string[]} lines
|
|
4330
|
+
*
|
|
4313
4331
|
* @return {Object} the line descriptor, an object { width, height, text }
|
|
4314
4332
|
*/
|
|
4315
4333
|
function layoutNext(lines, maxWidth, fakeText) {
|
|
@@ -4354,8 +4372,9 @@
|
|
|
4354
4372
|
* Shortens a line based on spacing and hyphens.
|
|
4355
4373
|
* Returns the shortened result on success.
|
|
4356
4374
|
*
|
|
4357
|
-
* @param
|
|
4358
|
-
* @param
|
|
4375
|
+
* @param {string} line
|
|
4376
|
+
* @param {number} maxLength the maximum characters of the string
|
|
4377
|
+
*
|
|
4359
4378
|
* @return {string} the shortened string
|
|
4360
4379
|
*/
|
|
4361
4380
|
function semanticShorten(line, maxLength) {
|
|
@@ -5195,6 +5214,10 @@
|
|
|
5195
5214
|
pathMap: [ 'type', PathMap ]
|
|
5196
5215
|
};
|
|
5197
5216
|
|
|
5217
|
+
/**
|
|
5218
|
+
* @typedef {import('./').Replacements} Replacements
|
|
5219
|
+
*/
|
|
5220
|
+
|
|
5198
5221
|
/**
|
|
5199
5222
|
* A simple translation stub to be used for multi-language support
|
|
5200
5223
|
* in diagrams. Can be easily replaced with a more sophisticated
|
|
@@ -5209,7 +5232,7 @@
|
|
|
5209
5232
|
* }
|
|
5210
5233
|
*
|
|
5211
5234
|
* @param {string} template to interpolate
|
|
5212
|
-
* @param {
|
|
5235
|
+
* @param {Replacements} [replacements] a map with substitutes
|
|
5213
5236
|
*
|
|
5214
5237
|
* @return {string} the translated string
|
|
5215
5238
|
*/
|
|
@@ -5362,8 +5385,6 @@
|
|
|
5362
5385
|
}, size);
|
|
5363
5386
|
}
|
|
5364
5387
|
|
|
5365
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5366
|
-
|
|
5367
5388
|
function getDefaultExportFromCjs (x) {
|
|
5368
5389
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5369
5390
|
}
|
|
@@ -5380,9 +5401,9 @@
|
|
|
5380
5401
|
/**
|
|
5381
5402
|
* Convert the given bounds to a { top, left, bottom, right } descriptor.
|
|
5382
5403
|
*
|
|
5383
|
-
* @param {
|
|
5404
|
+
* @param {Point|Rect} bounds
|
|
5384
5405
|
*
|
|
5385
|
-
* @return {
|
|
5406
|
+
* @return {RectTRBL}
|
|
5386
5407
|
*/
|
|
5387
5408
|
function asTRBL(bounds) {
|
|
5388
5409
|
return {
|
|
@@ -5397,9 +5418,9 @@
|
|
|
5397
5418
|
/**
|
|
5398
5419
|
* Convert a { top, left, bottom, right } to an objects bounds.
|
|
5399
5420
|
*
|
|
5400
|
-
* @param {
|
|
5421
|
+
* @param {RectTRBL} trbl
|
|
5401
5422
|
*
|
|
5402
|
-
* @return {
|
|
5423
|
+
* @return {Rect}
|
|
5403
5424
|
*/
|
|
5404
5425
|
function asBounds(trbl) {
|
|
5405
5426
|
return {
|
|
@@ -5414,7 +5435,7 @@
|
|
|
5414
5435
|
/**
|
|
5415
5436
|
* Get the mid of the given bounds or point.
|
|
5416
5437
|
*
|
|
5417
|
-
* @param {
|
|
5438
|
+
* @param {Point|Rect} bounds
|
|
5418
5439
|
*
|
|
5419
5440
|
* @return {Point}
|
|
5420
5441
|
*/
|
|
@@ -5429,7 +5450,7 @@
|
|
|
5429
5450
|
/**
|
|
5430
5451
|
* Get the mid of the given Connection.
|
|
5431
5452
|
*
|
|
5432
|
-
* @param {
|
|
5453
|
+
* @param {Connection} connection
|
|
5433
5454
|
*
|
|
5434
5455
|
* @return {Point}
|
|
5435
5456
|
*/
|
|
@@ -5488,7 +5509,7 @@
|
|
|
5488
5509
|
/**
|
|
5489
5510
|
* Get the mid of the given Element.
|
|
5490
5511
|
*
|
|
5491
|
-
* @param {
|
|
5512
|
+
* @param {Connection} connection
|
|
5492
5513
|
*
|
|
5493
5514
|
* @return {Point}
|
|
5494
5515
|
*/
|
|
@@ -5898,6 +5919,14 @@
|
|
|
5898
5919
|
return isPrimaryButton(event) && originalEvent.shiftKey;
|
|
5899
5920
|
}
|
|
5900
5921
|
|
|
5922
|
+
/**
|
|
5923
|
+
* @typedef {import('../../model').Base} Base
|
|
5924
|
+
*
|
|
5925
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
5926
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
5927
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
5928
|
+
*/
|
|
5929
|
+
|
|
5901
5930
|
function allowAll(event) { return true; }
|
|
5902
5931
|
|
|
5903
5932
|
function allowPrimaryAndAuxiliary(event) {
|
|
@@ -5927,6 +5956,8 @@
|
|
|
5927
5956
|
* prevents the original DOM operation.
|
|
5928
5957
|
*
|
|
5929
5958
|
* @param {EventBus} eventBus
|
|
5959
|
+
* @param {ElementRegistry} elementRegistry
|
|
5960
|
+
* @param {Styles} styles
|
|
5930
5961
|
*/
|
|
5931
5962
|
function InteractionEvents(eventBus, elementRegistry, styles) {
|
|
5932
5963
|
|
|
@@ -5936,8 +5967,8 @@
|
|
|
5936
5967
|
* Fire an interaction event.
|
|
5937
5968
|
*
|
|
5938
5969
|
* @param {string} type local event name, e.g. element.click.
|
|
5939
|
-
* @param {
|
|
5940
|
-
* @param {
|
|
5970
|
+
* @param {MouseEvent|TouchEvent} event native event
|
|
5971
|
+
* @param {Base} [element] the diagram element to emit the event on;
|
|
5941
5972
|
* defaults to the event target
|
|
5942
5973
|
*/
|
|
5943
5974
|
function fire(type, event, element) {
|
|
@@ -6019,8 +6050,8 @@
|
|
|
6019
6050
|
* on the target shape or connection.
|
|
6020
6051
|
*
|
|
6021
6052
|
* @param {string} eventName the name of the triggered DOM event
|
|
6022
|
-
* @param {MouseEvent} event
|
|
6023
|
-
* @param {
|
|
6053
|
+
* @param {MouseEvent|TouchEvent} event
|
|
6054
|
+
* @param {Base} targetElement
|
|
6024
6055
|
*/
|
|
6025
6056
|
function triggerMouseEvent(eventName, event, targetElement) {
|
|
6026
6057
|
|
|
@@ -6186,7 +6217,7 @@
|
|
|
6186
6217
|
/**
|
|
6187
6218
|
* Create default hit for the given element.
|
|
6188
6219
|
*
|
|
6189
|
-
* @param {
|
|
6220
|
+
* @param {Base} element
|
|
6190
6221
|
* @param {SVGElement} gfx
|
|
6191
6222
|
*
|
|
6192
6223
|
* @return {SVGElement} created hit
|
|
@@ -6258,8 +6289,8 @@
|
|
|
6258
6289
|
/**
|
|
6259
6290
|
* Update default hit of the element.
|
|
6260
6291
|
*
|
|
6261
|
-
* @param
|
|
6262
|
-
* @param
|
|
6292
|
+
* @param {Base} element
|
|
6293
|
+
* @param {SVGElement} gfx
|
|
6263
6294
|
*
|
|
6264
6295
|
* @return {SVGElement} updated hit
|
|
6265
6296
|
*/
|
|
@@ -6307,7 +6338,7 @@
|
|
|
6307
6338
|
* @event element.hover
|
|
6308
6339
|
*
|
|
6309
6340
|
* @type {Object}
|
|
6310
|
-
* @property {
|
|
6341
|
+
* @property {Base} element
|
|
6311
6342
|
* @property {SVGElement} gfx
|
|
6312
6343
|
* @property {Event} originalEvent
|
|
6313
6344
|
*/
|
|
@@ -6318,7 +6349,7 @@
|
|
|
6318
6349
|
* @event element.out
|
|
6319
6350
|
*
|
|
6320
6351
|
* @type {Object}
|
|
6321
|
-
* @property {
|
|
6352
|
+
* @property {Base} element
|
|
6322
6353
|
* @property {SVGElement} gfx
|
|
6323
6354
|
* @property {Event} originalEvent
|
|
6324
6355
|
*/
|
|
@@ -6329,7 +6360,7 @@
|
|
|
6329
6360
|
* @event element.click
|
|
6330
6361
|
*
|
|
6331
6362
|
* @type {Object}
|
|
6332
|
-
* @property {
|
|
6363
|
+
* @property {Base} element
|
|
6333
6364
|
* @property {SVGElement} gfx
|
|
6334
6365
|
* @property {Event} originalEvent
|
|
6335
6366
|
*/
|
|
@@ -6340,7 +6371,7 @@
|
|
|
6340
6371
|
* @event element.dblclick
|
|
6341
6372
|
*
|
|
6342
6373
|
* @type {Object}
|
|
6343
|
-
* @property {
|
|
6374
|
+
* @property {Base} element
|
|
6344
6375
|
* @property {SVGElement} gfx
|
|
6345
6376
|
* @property {Event} originalEvent
|
|
6346
6377
|
*/
|
|
@@ -6351,7 +6382,7 @@
|
|
|
6351
6382
|
* @event element.mousedown
|
|
6352
6383
|
*
|
|
6353
6384
|
* @type {Object}
|
|
6354
|
-
* @property {
|
|
6385
|
+
* @property {Base} element
|
|
6355
6386
|
* @property {SVGElement} gfx
|
|
6356
6387
|
* @property {Event} originalEvent
|
|
6357
6388
|
*/
|
|
@@ -6362,7 +6393,7 @@
|
|
|
6362
6393
|
* @event element.mouseup
|
|
6363
6394
|
*
|
|
6364
6395
|
* @type {Object}
|
|
6365
|
-
* @property {
|
|
6396
|
+
* @property {Base} element
|
|
6366
6397
|
* @property {SVGElement} gfx
|
|
6367
6398
|
* @property {Event} originalEvent
|
|
6368
6399
|
*/
|
|
@@ -6374,7 +6405,7 @@
|
|
|
6374
6405
|
* @event element.contextmenu
|
|
6375
6406
|
*
|
|
6376
6407
|
* @type {Object}
|
|
6377
|
-
* @property {
|
|
6408
|
+
* @property {Base} element
|
|
6378
6409
|
* @property {SVGElement} gfx
|
|
6379
6410
|
* @property {Event} originalEvent
|
|
6380
6411
|
*/
|
|
@@ -6388,10 +6419,10 @@
|
|
|
6388
6419
|
* Returns the surrounding bbox for all elements in
|
|
6389
6420
|
* the array or the element primitive.
|
|
6390
6421
|
*
|
|
6391
|
-
* @param {
|
|
6422
|
+
* @param {Base|Base[]} elements
|
|
6392
6423
|
* @param {boolean} [stopRecursion=false]
|
|
6393
6424
|
*
|
|
6394
|
-
* @return {
|
|
6425
|
+
* @return {Rect}
|
|
6395
6426
|
*/
|
|
6396
6427
|
function getBBox(elements, stopRecursion) {
|
|
6397
6428
|
|
|
@@ -6462,6 +6493,12 @@
|
|
|
6462
6493
|
|
|
6463
6494
|
var LOW_PRIORITY$2 = 500;
|
|
6464
6495
|
|
|
6496
|
+
/**
|
|
6497
|
+
* @typedef {import('../../model').Base} Base
|
|
6498
|
+
*
|
|
6499
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6500
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
6501
|
+
*/
|
|
6465
6502
|
|
|
6466
6503
|
/**
|
|
6467
6504
|
* @class
|
|
@@ -6471,9 +6508,8 @@
|
|
|
6471
6508
|
*
|
|
6472
6509
|
* @param {EventBus} eventBus
|
|
6473
6510
|
* @param {Styles} styles
|
|
6474
|
-
* @param {ElementRegistry} elementRegistry
|
|
6475
6511
|
*/
|
|
6476
|
-
function Outline(eventBus, styles
|
|
6512
|
+
function Outline(eventBus, styles) {
|
|
6477
6513
|
|
|
6478
6514
|
this.offset = 6;
|
|
6479
6515
|
|
|
@@ -6531,8 +6567,8 @@
|
|
|
6531
6567
|
* Updates the outline of a shape respecting the dimension of the
|
|
6532
6568
|
* element and an outline offset.
|
|
6533
6569
|
*
|
|
6534
|
-
* @param
|
|
6535
|
-
* @param
|
|
6570
|
+
* @param {SVGElement} outline
|
|
6571
|
+
* @param {Base} element
|
|
6536
6572
|
*/
|
|
6537
6573
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6538
6574
|
|
|
@@ -6550,8 +6586,8 @@
|
|
|
6550
6586
|
* Updates the outline of a connection respecting the bounding box of
|
|
6551
6587
|
* the connection and an outline offset.
|
|
6552
6588
|
*
|
|
6553
|
-
* @param
|
|
6554
|
-
* @param
|
|
6589
|
+
* @param {SVGElement} outline
|
|
6590
|
+
* @param {Base} element
|
|
6555
6591
|
*/
|
|
6556
6592
|
Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
|
6557
6593
|
|
|
@@ -6574,13 +6610,17 @@
|
|
|
6574
6610
|
outline: [ 'type', Outline ]
|
|
6575
6611
|
};
|
|
6576
6612
|
|
|
6613
|
+
/**
|
|
6614
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6615
|
+
*/
|
|
6616
|
+
|
|
6577
6617
|
/**
|
|
6578
6618
|
* A service that offers the current selection in a diagram.
|
|
6579
6619
|
* Offers the api to control the selection, too.
|
|
6580
6620
|
*
|
|
6581
6621
|
* @class
|
|
6582
6622
|
*
|
|
6583
|
-
* @param {EventBus} eventBus
|
|
6623
|
+
* @param {EventBus} eventBus
|
|
6584
6624
|
*/
|
|
6585
6625
|
function Selection(eventBus, canvas) {
|
|
6586
6626
|
|
|
@@ -6636,8 +6676,8 @@
|
|
|
6636
6676
|
*
|
|
6637
6677
|
* @method Selection#select
|
|
6638
6678
|
*
|
|
6639
|
-
* @param
|
|
6640
|
-
* @param
|
|
6679
|
+
* @param {Object|Object[]} elements element or array of elements to be selected
|
|
6680
|
+
* @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
|
|
6641
6681
|
*/
|
|
6642
6682
|
Selection.prototype.select = function(elements, add) {
|
|
6643
6683
|
var selectedElements = this._selectedElements,
|
|
@@ -6676,6 +6716,12 @@
|
|
|
6676
6716
|
this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
|
6677
6717
|
};
|
|
6678
6718
|
|
|
6719
|
+
/**
|
|
6720
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6721
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6722
|
+
* @typedef {import('./Selection').default} Selection
|
|
6723
|
+
*/
|
|
6724
|
+
|
|
6679
6725
|
var MARKER_HOVER = 'hover',
|
|
6680
6726
|
MARKER_SELECTED = 'selected';
|
|
6681
6727
|
|
|
@@ -6692,6 +6738,7 @@
|
|
|
6692
6738
|
*
|
|
6693
6739
|
* @param {Canvas} canvas
|
|
6694
6740
|
* @param {EventBus} eventBus
|
|
6741
|
+
* @param {Selection} selection
|
|
6695
6742
|
*/
|
|
6696
6743
|
function SelectionVisuals(canvas, eventBus, selection) {
|
|
6697
6744
|
this._canvas = canvas;
|
|
@@ -6797,6 +6844,19 @@
|
|
|
6797
6844
|
};
|
|
6798
6845
|
}
|
|
6799
6846
|
|
|
6847
|
+
/**
|
|
6848
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6849
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
6850
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6851
|
+
* @typedef {import('./Selection').default} Selection
|
|
6852
|
+
*/
|
|
6853
|
+
|
|
6854
|
+
/**
|
|
6855
|
+
* @param {EventBus} eventBus
|
|
6856
|
+
* @param {Selection} selection
|
|
6857
|
+
* @param {Canvas} canvas
|
|
6858
|
+
* @param {ElementRegistry} elementRegistry
|
|
6859
|
+
*/
|
|
6800
6860
|
function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
|
6801
6861
|
|
|
6802
6862
|
// Select elements on create
|
|
@@ -6917,9 +6977,8 @@
|
|
|
6917
6977
|
/**
|
|
6918
6978
|
* Util that provides unique IDs.
|
|
6919
6979
|
*
|
|
6920
|
-
* @class
|
|
6980
|
+
* @class
|
|
6921
6981
|
* @constructor
|
|
6922
|
-
* @memberOf djs.util
|
|
6923
6982
|
*
|
|
6924
6983
|
* The ids can be customized via a given prefix and contain a random value to avoid collisions.
|
|
6925
6984
|
*
|
|
@@ -6934,8 +6993,6 @@
|
|
|
6934
6993
|
/**
|
|
6935
6994
|
* Returns a next unique ID.
|
|
6936
6995
|
*
|
|
6937
|
-
* @method djs.util.IdGenerator#next
|
|
6938
|
-
*
|
|
6939
6996
|
* @returns {string} the id
|
|
6940
6997
|
*/
|
|
6941
6998
|
IdGenerator.prototype.next = function() {
|
|
@@ -6947,6 +7004,18 @@
|
|
|
6947
7004
|
|
|
6948
7005
|
var LOW_PRIORITY$1 = 500;
|
|
6949
7006
|
|
|
7007
|
+
/**
|
|
7008
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7009
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7010
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7011
|
+
*
|
|
7012
|
+
* @typedef {import('./Overlays').Overlay} Overlay
|
|
7013
|
+
* @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
|
|
7014
|
+
* @typedef {import('./Overlays').OverlayContainer} OverlayContainer
|
|
7015
|
+
* @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
|
|
7016
|
+
* @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
|
|
7017
|
+
* @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
|
|
7018
|
+
*/
|
|
6950
7019
|
|
|
6951
7020
|
/**
|
|
6952
7021
|
* A service that allows users to attach overlays to diagram elements.
|
|
@@ -6956,6 +7025,7 @@
|
|
|
6956
7025
|
* @example
|
|
6957
7026
|
*
|
|
6958
7027
|
* // add a pink badge on the top left of the shape
|
|
7028
|
+
*
|
|
6959
7029
|
* overlays.add(someShape, {
|
|
6960
7030
|
* position: {
|
|
6961
7031
|
* top: -5,
|
|
@@ -7007,19 +7077,21 @@
|
|
|
7007
7077
|
* }
|
|
7008
7078
|
* }
|
|
7009
7079
|
*
|
|
7010
|
-
* @param {
|
|
7080
|
+
* @param {OverlaysConfig} config
|
|
7011
7081
|
* @param {EventBus} eventBus
|
|
7012
7082
|
* @param {Canvas} canvas
|
|
7013
7083
|
* @param {ElementRegistry} elementRegistry
|
|
7014
7084
|
*/
|
|
7015
7085
|
function Overlays(config, eventBus, canvas, elementRegistry) {
|
|
7016
|
-
|
|
7017
7086
|
this._eventBus = eventBus;
|
|
7018
7087
|
this._canvas = canvas;
|
|
7019
7088
|
this._elementRegistry = elementRegistry;
|
|
7020
7089
|
|
|
7021
7090
|
this._ids = ids;
|
|
7022
7091
|
|
|
7092
|
+
/**
|
|
7093
|
+
* @type {OverlaysConfigDefault}
|
|
7094
|
+
*/
|
|
7023
7095
|
this._overlayDefaults = assign$1({
|
|
7024
7096
|
|
|
7025
7097
|
// no show constraints
|
|
@@ -7030,16 +7102,18 @@
|
|
|
7030
7102
|
}, config && config.defaults);
|
|
7031
7103
|
|
|
7032
7104
|
/**
|
|
7033
|
-
*
|
|
7105
|
+
* @type {Map<string, Overlay>}
|
|
7034
7106
|
*/
|
|
7035
7107
|
this._overlays = {};
|
|
7036
7108
|
|
|
7037
7109
|
/**
|
|
7038
|
-
*
|
|
7110
|
+
* @type {OverlayContainer[]}
|
|
7039
7111
|
*/
|
|
7040
7112
|
this._overlayContainers = [];
|
|
7041
7113
|
|
|
7042
|
-
|
|
7114
|
+
/**
|
|
7115
|
+
* @type {HTMLElement}
|
|
7116
|
+
*/
|
|
7043
7117
|
this._overlayRoot = createRoot(canvas.getContainer());
|
|
7044
7118
|
|
|
7045
7119
|
this._init();
|
|
@@ -7055,12 +7129,12 @@
|
|
|
7055
7129
|
|
|
7056
7130
|
|
|
7057
7131
|
/**
|
|
7058
|
-
* Returns the overlay with the specified
|
|
7132
|
+
* Returns the overlay with the specified ID or a list of overlays
|
|
7059
7133
|
* for an element with a given type.
|
|
7060
7134
|
*
|
|
7061
7135
|
* @example
|
|
7062
7136
|
*
|
|
7063
|
-
* // return the single overlay with the given
|
|
7137
|
+
* // return the single overlay with the given ID
|
|
7064
7138
|
* overlays.get('some-id');
|
|
7065
7139
|
*
|
|
7066
7140
|
* // return all overlays for the shape
|
|
@@ -7069,16 +7143,12 @@
|
|
|
7069
7143
|
* // return all overlays on shape with type 'badge'
|
|
7070
7144
|
* overlays.get({ element: someShape, type: 'badge' });
|
|
7071
7145
|
*
|
|
7072
|
-
* // shape can also be specified as
|
|
7146
|
+
* // shape can also be specified as ID
|
|
7073
7147
|
* overlays.get({ element: 'element-id', type: 'badge' });
|
|
7074
7148
|
*
|
|
7149
|
+
* @param {OverlaysFilter} search The filter to be used to find the overlay(s).
|
|
7075
7150
|
*
|
|
7076
|
-
* @
|
|
7077
|
-
* @param {string} [search.id]
|
|
7078
|
-
* @param {string|djs.model.Base} [search.element]
|
|
7079
|
-
* @param {string} [search.type]
|
|
7080
|
-
*
|
|
7081
|
-
* @return {Object|Array<Object>} the overlay(s)
|
|
7151
|
+
* @return {Overlay|Overlay[]} The overlay(s).
|
|
7082
7152
|
*/
|
|
7083
7153
|
Overlays.prototype.get = function(search) {
|
|
7084
7154
|
|
|
@@ -7110,27 +7180,13 @@
|
|
|
7110
7180
|
};
|
|
7111
7181
|
|
|
7112
7182
|
/**
|
|
7113
|
-
* Adds
|
|
7114
|
-
*
|
|
7115
|
-
* @param {string|djs.model.Base} element attach overlay to this shape
|
|
7116
|
-
* @param {string} [type] optional type to assign to the overlay
|
|
7117
|
-
* @param {Object} overlay the overlay configuration
|
|
7183
|
+
* Adds an HTML overlay to an element.
|
|
7118
7184
|
*
|
|
7119
|
-
* @param {string
|
|
7120
|
-
* @param {
|
|
7121
|
-
* @param {
|
|
7122
|
-
* @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
|
|
7123
|
-
* @param {Object} overlay.position where to attach the overlay
|
|
7124
|
-
* @param {number} [overlay.position.left] relative to element bbox left attachment
|
|
7125
|
-
* @param {number} [overlay.position.top] relative to element bbox top attachment
|
|
7126
|
-
* @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
|
|
7127
|
-
* @param {number} [overlay.position.right] relative to element bbox right attachment
|
|
7128
|
-
* @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
|
|
7129
|
-
* diagram zoom
|
|
7130
|
-
* @param {number} [overlay.scale.min]
|
|
7131
|
-
* @param {number} [overlay.scale.max]
|
|
7185
|
+
* @param {Base|string} element The element to add the overlay to.
|
|
7186
|
+
* @param {string} [type] An optional type that can be used to filter.
|
|
7187
|
+
* @param {OverlayAttrs} overlay The overlay.
|
|
7132
7188
|
*
|
|
7133
|
-
* @return {string}
|
|
7189
|
+
* @return {string} The overlay's ID that can be used to get or remove it.
|
|
7134
7190
|
*/
|
|
7135
7191
|
Overlays.prototype.add = function(element, type, overlay) {
|
|
7136
7192
|
|
|
@@ -7171,11 +7227,11 @@
|
|
|
7171
7227
|
|
|
7172
7228
|
|
|
7173
7229
|
/**
|
|
7174
|
-
* Remove an overlay with the given
|
|
7230
|
+
* Remove an overlay with the given ID or all overlays matching the given filter.
|
|
7175
7231
|
*
|
|
7176
7232
|
* @see Overlays#get for filter options.
|
|
7177
7233
|
*
|
|
7178
|
-
* @param {
|
|
7234
|
+
* @param {OverlaysFilter} filter The filter to be used to find the overlay.
|
|
7179
7235
|
*/
|
|
7180
7236
|
Overlays.prototype.remove = function(filter) {
|
|
7181
7237
|
|
|
@@ -7211,19 +7267,32 @@
|
|
|
7211
7267
|
|
|
7212
7268
|
};
|
|
7213
7269
|
|
|
7270
|
+
/**
|
|
7271
|
+
* Checks whether overlays are shown.
|
|
7272
|
+
*
|
|
7273
|
+
* @returns {boolean} Whether overlays are shown.
|
|
7274
|
+
*/
|
|
7214
7275
|
Overlays.prototype.isShown = function() {
|
|
7215
7276
|
return this._overlayRoot.style.display !== 'none';
|
|
7216
7277
|
};
|
|
7217
7278
|
|
|
7279
|
+
/**
|
|
7280
|
+
* Show all overlays.
|
|
7281
|
+
*/
|
|
7218
7282
|
Overlays.prototype.show = function() {
|
|
7219
7283
|
setVisible(this._overlayRoot);
|
|
7220
7284
|
};
|
|
7221
7285
|
|
|
7222
|
-
|
|
7286
|
+
/**
|
|
7287
|
+
* Hide all overlays.
|
|
7288
|
+
*/
|
|
7223
7289
|
Overlays.prototype.hide = function() {
|
|
7224
7290
|
setVisible(this._overlayRoot, false);
|
|
7225
7291
|
};
|
|
7226
7292
|
|
|
7293
|
+
/**
|
|
7294
|
+
* Remove all overlays and their container.
|
|
7295
|
+
*/
|
|
7227
7296
|
Overlays.prototype.clear = function() {
|
|
7228
7297
|
this._overlays = {};
|
|
7229
7298
|
|
|
@@ -7599,6 +7668,13 @@
|
|
|
7599
7668
|
overlays: [ 'type', Overlays ]
|
|
7600
7669
|
};
|
|
7601
7670
|
|
|
7671
|
+
/**
|
|
7672
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7673
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7674
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7675
|
+
* @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
|
|
7676
|
+
*/
|
|
7677
|
+
|
|
7602
7678
|
/**
|
|
7603
7679
|
* Adds change support to the diagram, including
|
|
7604
7680
|
*
|
|
@@ -7668,32 +7744,41 @@
|
|
|
7668
7744
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7669
7745
|
};
|
|
7670
7746
|
|
|
7747
|
+
/**
|
|
7748
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
7749
|
+
* @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
|
|
7750
|
+
* @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
|
|
7751
|
+
*/
|
|
7752
|
+
|
|
7671
7753
|
var DEFAULT_PRIORITY$1 = 1000;
|
|
7672
7754
|
|
|
7673
7755
|
/**
|
|
7674
|
-
* A utility that can be used to plug
|
|
7756
|
+
* A utility that can be used to plug into the command execution for
|
|
7675
7757
|
* extension and/or validation.
|
|
7676
7758
|
*
|
|
7759
|
+
* @class
|
|
7760
|
+
* @constructor
|
|
7761
|
+
*
|
|
7677
7762
|
* @param {EventBus} eventBus
|
|
7678
7763
|
*
|
|
7679
7764
|
* @example
|
|
7680
7765
|
*
|
|
7681
|
-
* import inherits from 'inherits-browser';
|
|
7682
|
-
*
|
|
7683
7766
|
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7684
7767
|
*
|
|
7685
|
-
*
|
|
7686
|
-
*
|
|
7768
|
+
* class CommandLogger extends CommandInterceptor {
|
|
7769
|
+
* constructor(eventBus) {
|
|
7770
|
+
* super(eventBus);
|
|
7687
7771
|
*
|
|
7688
|
-
* this.preExecute(
|
|
7689
|
-
* console.log('
|
|
7772
|
+
* this.preExecute('shape.create', (event) => {
|
|
7773
|
+
* console.log('commandStack.shape-create.preExecute', event);
|
|
7690
7774
|
* });
|
|
7691
7775
|
* }
|
|
7692
|
-
*
|
|
7693
|
-
* inherits(CommandLogger, CommandInterceptor);
|
|
7694
|
-
*
|
|
7695
7776
|
*/
|
|
7696
7777
|
function CommandInterceptor(eventBus) {
|
|
7778
|
+
|
|
7779
|
+
/**
|
|
7780
|
+
* @type {EventBus}
|
|
7781
|
+
*/
|
|
7697
7782
|
this._eventBus = eventBus;
|
|
7698
7783
|
}
|
|
7699
7784
|
|
|
@@ -7706,16 +7791,15 @@
|
|
|
7706
7791
|
}
|
|
7707
7792
|
|
|
7708
7793
|
/**
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
*/
|
|
7794
|
+
* Intercept a command during one of the phases.
|
|
7795
|
+
*
|
|
7796
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7797
|
+
* @param {string} [hook] Phase during which to intercept command.
|
|
7798
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7799
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7800
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7801
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7802
|
+
*/
|
|
7719
7803
|
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7720
7804
|
|
|
7721
7805
|
if (isFunction(hook) || isNumber(hook)) {
|
|
@@ -7771,24 +7855,19 @@
|
|
|
7771
7855
|
];
|
|
7772
7856
|
|
|
7773
7857
|
/*
|
|
7774
|
-
*
|
|
7775
|
-
*
|
|
7776
|
-
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7777
|
-
* which will in term forward to CommandInterceptor#on.
|
|
7858
|
+
* Add prototype methods for each phase of command execution (e.g. execute,
|
|
7859
|
+
* revert).
|
|
7778
7860
|
*/
|
|
7779
7861
|
forEach$1(hooks, function(hook) {
|
|
7780
7862
|
|
|
7781
7863
|
/**
|
|
7782
|
-
*
|
|
7783
|
-
*
|
|
7784
|
-
* A named hook for plugging into the command execution
|
|
7864
|
+
* Add prototype method for a specific phase of command execution.
|
|
7785
7865
|
*
|
|
7786
|
-
* @param {string|
|
|
7787
|
-
* @param {number} [priority]
|
|
7788
|
-
* @param {
|
|
7789
|
-
* @param {boolean} [unwrap
|
|
7790
|
-
*
|
|
7791
|
-
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7866
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7867
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7868
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7869
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7870
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7792
7871
|
*/
|
|
7793
7872
|
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7794
7873
|
|
|
@@ -7804,12 +7883,18 @@
|
|
|
7804
7883
|
};
|
|
7805
7884
|
});
|
|
7806
7885
|
|
|
7886
|
+
/**
|
|
7887
|
+
* @typedef {import('didi').Injector} Injector
|
|
7888
|
+
*
|
|
7889
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7890
|
+
*/
|
|
7891
|
+
|
|
7807
7892
|
/**
|
|
7808
7893
|
* A modeling behavior that ensures we set the correct root element
|
|
7809
7894
|
* as we undo and redo commands.
|
|
7810
7895
|
*
|
|
7811
7896
|
* @param {Canvas} canvas
|
|
7812
|
-
* @param {
|
|
7897
|
+
* @param {Injector} injector
|
|
7813
7898
|
*/
|
|
7814
7899
|
function RootElementsBehavior(canvas, injector) {
|
|
7815
7900
|
|
|
@@ -7843,111 +7928,10 @@
|
|
|
7843
7928
|
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7844
7929
|
};
|
|
7845
7930
|
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
(function (module, exports) {
|
|
7851
|
-
(function(root, factory) {
|
|
7852
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7853
|
-
{
|
|
7854
|
-
// For Node.js.
|
|
7855
|
-
module.exports = factory(root);
|
|
7856
|
-
}
|
|
7857
|
-
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
|
|
7858
|
-
|
|
7859
|
-
if (root.CSS && root.CSS.escape) {
|
|
7860
|
-
return root.CSS.escape;
|
|
7861
|
-
}
|
|
7862
|
-
|
|
7863
|
-
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7864
|
-
var cssEscape = function(value) {
|
|
7865
|
-
if (arguments.length == 0) {
|
|
7866
|
-
throw new TypeError('`CSS.escape` requires an argument.');
|
|
7867
|
-
}
|
|
7868
|
-
var string = String(value);
|
|
7869
|
-
var length = string.length;
|
|
7870
|
-
var index = -1;
|
|
7871
|
-
var codeUnit;
|
|
7872
|
-
var result = '';
|
|
7873
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
7874
|
-
while (++index < length) {
|
|
7875
|
-
codeUnit = string.charCodeAt(index);
|
|
7876
|
-
// Note: there’s no need to special-case astral symbols, surrogate
|
|
7877
|
-
// pairs, or lone surrogates.
|
|
7878
|
-
|
|
7879
|
-
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
7880
|
-
// (U+FFFD).
|
|
7881
|
-
if (codeUnit == 0x0000) {
|
|
7882
|
-
result += '\uFFFD';
|
|
7883
|
-
continue;
|
|
7884
|
-
}
|
|
7885
|
-
|
|
7886
|
-
if (
|
|
7887
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
7888
|
-
// U+007F, […]
|
|
7889
|
-
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
|
7890
|
-
// If the character is the first character and is in the range [0-9]
|
|
7891
|
-
// (U+0030 to U+0039), […]
|
|
7892
|
-
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
|
7893
|
-
// If the character is the second character and is in the range [0-9]
|
|
7894
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
7895
|
-
(
|
|
7896
|
-
index == 1 &&
|
|
7897
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
|
7898
|
-
firstCodeUnit == 0x002D
|
|
7899
|
-
)
|
|
7900
|
-
) {
|
|
7901
|
-
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
7902
|
-
result += '\\' + codeUnit.toString(16) + ' ';
|
|
7903
|
-
continue;
|
|
7904
|
-
}
|
|
7905
|
-
|
|
7906
|
-
if (
|
|
7907
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
7908
|
-
// there is no second character, […]
|
|
7909
|
-
index == 0 &&
|
|
7910
|
-
length == 1 &&
|
|
7911
|
-
codeUnit == 0x002D
|
|
7912
|
-
) {
|
|
7913
|
-
result += '\\' + string.charAt(index);
|
|
7914
|
-
continue;
|
|
7915
|
-
}
|
|
7916
|
-
|
|
7917
|
-
// If the character is not handled by one of the above rules and is
|
|
7918
|
-
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
7919
|
-
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
7920
|
-
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
7921
|
-
if (
|
|
7922
|
-
codeUnit >= 0x0080 ||
|
|
7923
|
-
codeUnit == 0x002D ||
|
|
7924
|
-
codeUnit == 0x005F ||
|
|
7925
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
|
7926
|
-
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
|
7927
|
-
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
|
7928
|
-
) {
|
|
7929
|
-
// the character itself
|
|
7930
|
-
result += string.charAt(index);
|
|
7931
|
-
continue;
|
|
7932
|
-
}
|
|
7933
|
-
|
|
7934
|
-
// Otherwise, the escaped character.
|
|
7935
|
-
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
7936
|
-
result += '\\' + string.charAt(index);
|
|
7937
|
-
|
|
7938
|
-
}
|
|
7939
|
-
return result;
|
|
7940
|
-
};
|
|
7941
|
-
|
|
7942
|
-
if (!root.CSS) {
|
|
7943
|
-
root.CSS = {};
|
|
7944
|
-
}
|
|
7945
|
-
|
|
7946
|
-
root.CSS.escape = cssEscape;
|
|
7947
|
-
return cssEscape;
|
|
7948
|
-
|
|
7949
|
-
}));
|
|
7950
|
-
} (css_escape));
|
|
7931
|
+
/**
|
|
7932
|
+
* @param {string} str
|
|
7933
|
+
* @returns {string}
|
|
7934
|
+
*/
|
|
7951
7935
|
|
|
7952
7936
|
var HTML_ESCAPE_MAP = {
|
|
7953
7937
|
'&': '&',
|
|
@@ -9082,6 +9066,11 @@
|
|
|
9082
9066
|
return value;
|
|
9083
9067
|
}
|
|
9084
9068
|
|
|
9069
|
+
/**
|
|
9070
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
9071
|
+
* @typedef {import('./Styles').default} Styles
|
|
9072
|
+
*/
|
|
9073
|
+
|
|
9085
9074
|
// apply default renderer with lowest possible priority
|
|
9086
9075
|
// so that it only kicks in if noone else could render
|
|
9087
9076
|
var DEFAULT_RENDER_PRIORITY = 1;
|
|
@@ -9199,9 +9188,9 @@
|
|
|
9199
9188
|
/**
|
|
9200
9189
|
* Builds a style definition from a className, a list of traits and an object of additional attributes.
|
|
9201
9190
|
*
|
|
9202
|
-
* @param
|
|
9203
|
-
* @param
|
|
9204
|
-
* @param
|
|
9191
|
+
* @param {string} className
|
|
9192
|
+
* @param {Array<string>} traits
|
|
9193
|
+
* @param {Object} additionalAttrs
|
|
9205
9194
|
*
|
|
9206
9195
|
* @return {Object} the style defintion
|
|
9207
9196
|
*/
|
|
@@ -9214,8 +9203,8 @@
|
|
|
9214
9203
|
/**
|
|
9215
9204
|
* Builds a style definition from a list of traits and an object of additional attributes.
|
|
9216
9205
|
*
|
|
9217
|
-
* @param
|
|
9218
|
-
* @param
|
|
9206
|
+
* @param {Array<string>} traits
|
|
9207
|
+
* @param {Object} additionalAttrs
|
|
9219
9208
|
*
|
|
9220
9209
|
* @return {Object} the style defintion
|
|
9221
9210
|
*/
|
|
@@ -9252,8 +9241,8 @@
|
|
|
9252
9241
|
/**
|
|
9253
9242
|
* Failsafe remove an element from a collection
|
|
9254
9243
|
*
|
|
9255
|
-
* @param
|
|
9256
|
-
* @param
|
|
9244
|
+
* @param {Array<Object>} [collection]
|
|
9245
|
+
* @param {Object} [element]
|
|
9257
9246
|
*
|
|
9258
9247
|
* @return {number} the previous index of the element
|
|
9259
9248
|
*/
|
|
@@ -9323,6 +9312,27 @@
|
|
|
9323
9312
|
}
|
|
9324
9313
|
}
|
|
9325
9314
|
|
|
9315
|
+
/**
|
|
9316
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
9317
|
+
* @typedef {import('.').RootLike} RootLike
|
|
9318
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
9319
|
+
*
|
|
9320
|
+
* @typedef {import('./Canvas').CanvasConfig} CanvasConfig
|
|
9321
|
+
* @typedef {import('./Canvas').CanvasLayer} CanvasLayer
|
|
9322
|
+
* @typedef {import('./Canvas').CanvasLayers} CanvasLayers
|
|
9323
|
+
* @typedef {import('./Canvas').CanvasPlane} CanvasPlane
|
|
9324
|
+
* @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
|
|
9325
|
+
*
|
|
9326
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
9327
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
9328
|
+
* @typedef {import('./GraphicsFactory').default} GraphicsFactory
|
|
9329
|
+
*
|
|
9330
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
9331
|
+
* @typedef {import('../util/Types').Point} Point
|
|
9332
|
+
* @typedef {import('../util/Types').Rect} Rect
|
|
9333
|
+
* @typedef {import('../util/Types').RectTRBL} RectTRBL
|
|
9334
|
+
*/
|
|
9335
|
+
|
|
9326
9336
|
function round(number, resolution) {
|
|
9327
9337
|
return Math.round(number * resolution) / resolution;
|
|
9328
9338
|
}
|
|
@@ -9343,7 +9353,8 @@
|
|
|
9343
9353
|
* Creates a HTML container element for a SVG element with
|
|
9344
9354
|
* the given configuration
|
|
9345
9355
|
*
|
|
9346
|
-
* @param
|
|
9356
|
+
* @param {CanvasConfig} options
|
|
9357
|
+
*
|
|
9347
9358
|
* @return {HTMLElement} the container element
|
|
9348
9359
|
*/
|
|
9349
9360
|
function createContainer(options) {
|
|
@@ -9403,21 +9414,34 @@
|
|
|
9403
9414
|
*
|
|
9404
9415
|
* @emits Canvas#canvas.init
|
|
9405
9416
|
*
|
|
9406
|
-
* @param {
|
|
9417
|
+
* @param {CanvasConfig|null} config
|
|
9407
9418
|
* @param {EventBus} eventBus
|
|
9408
9419
|
* @param {GraphicsFactory} graphicsFactory
|
|
9409
9420
|
* @param {ElementRegistry} elementRegistry
|
|
9410
9421
|
*/
|
|
9411
9422
|
function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
|
9412
|
-
|
|
9413
9423
|
this._eventBus = eventBus;
|
|
9414
9424
|
this._elementRegistry = elementRegistry;
|
|
9415
9425
|
this._graphicsFactory = graphicsFactory;
|
|
9416
9426
|
|
|
9427
|
+
/**
|
|
9428
|
+
* @type {number}
|
|
9429
|
+
*/
|
|
9417
9430
|
this._rootsIdx = 0;
|
|
9418
9431
|
|
|
9432
|
+
/**
|
|
9433
|
+
* @type {CanvasLayers}
|
|
9434
|
+
*/
|
|
9419
9435
|
this._layers = {};
|
|
9436
|
+
|
|
9437
|
+
/**
|
|
9438
|
+
* @type {CanvasPlane[]}
|
|
9439
|
+
*/
|
|
9420
9440
|
this._planes = [];
|
|
9441
|
+
|
|
9442
|
+
/**
|
|
9443
|
+
* @type {RootLike|null}
|
|
9444
|
+
*/
|
|
9421
9445
|
this._rootElement = null;
|
|
9422
9446
|
|
|
9423
9447
|
this._init(config || {});
|
|
@@ -9442,6 +9466,8 @@
|
|
|
9442
9466
|
* ...
|
|
9443
9467
|
* </svg>
|
|
9444
9468
|
* </div>
|
|
9469
|
+
*
|
|
9470
|
+
* @param {CanvasConfig} config
|
|
9445
9471
|
*/
|
|
9446
9472
|
Canvas.prototype._init = function(config) {
|
|
9447
9473
|
|
|
@@ -9463,7 +9489,7 @@
|
|
|
9463
9489
|
this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
|
|
9464
9490
|
}
|
|
9465
9491
|
|
|
9466
|
-
eventBus.on('diagram.init',
|
|
9492
|
+
eventBus.on('diagram.init', () => {
|
|
9467
9493
|
|
|
9468
9494
|
/**
|
|
9469
9495
|
* An event indicating that the canvas is ready to be drawn on.
|
|
@@ -9481,7 +9507,7 @@
|
|
|
9481
9507
|
viewport: viewport
|
|
9482
9508
|
});
|
|
9483
9509
|
|
|
9484
|
-
}
|
|
9510
|
+
});
|
|
9485
9511
|
|
|
9486
9512
|
// reset viewbox on shape changes to
|
|
9487
9513
|
// recompute the viewbox
|
|
@@ -9492,15 +9518,15 @@
|
|
|
9492
9518
|
'connection.removed',
|
|
9493
9519
|
'elements.changed',
|
|
9494
9520
|
'root.set'
|
|
9495
|
-
],
|
|
9521
|
+
], () => {
|
|
9496
9522
|
delete this._cachedViewbox;
|
|
9497
|
-
}
|
|
9523
|
+
});
|
|
9498
9524
|
|
|
9499
9525
|
eventBus.on('diagram.destroy', 500, this._destroy, this);
|
|
9500
9526
|
eventBus.on('diagram.clear', 500, this._clear, this);
|
|
9501
9527
|
};
|
|
9502
9528
|
|
|
9503
|
-
Canvas.prototype._destroy = function(
|
|
9529
|
+
Canvas.prototype._destroy = function() {
|
|
9504
9530
|
this._eventBus.fire('canvas.destroy', {
|
|
9505
9531
|
svg: this._svg,
|
|
9506
9532
|
viewport: this._viewport
|
|
@@ -9547,7 +9573,7 @@
|
|
|
9547
9573
|
* Returns the default layer on which
|
|
9548
9574
|
* all elements are drawn.
|
|
9549
9575
|
*
|
|
9550
|
-
* @
|
|
9576
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9551
9577
|
*/
|
|
9552
9578
|
Canvas.prototype.getDefaultLayer = function() {
|
|
9553
9579
|
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
@@ -9563,10 +9589,10 @@
|
|
|
9563
9589
|
* A layer with a certain index is always created above all
|
|
9564
9590
|
* existing layers with the same index.
|
|
9565
9591
|
*
|
|
9566
|
-
* @param {string} name
|
|
9567
|
-
* @param {number} index
|
|
9592
|
+
* @param {string} name The name of the layer.
|
|
9593
|
+
* @param {number} [index] The index of the layer.
|
|
9568
9594
|
*
|
|
9569
|
-
* @
|
|
9595
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9570
9596
|
*/
|
|
9571
9597
|
Canvas.prototype.getLayer = function(name, index) {
|
|
9572
9598
|
|
|
@@ -9595,8 +9621,9 @@
|
|
|
9595
9621
|
*
|
|
9596
9622
|
* This is used to determine the node a layer should be inserted at.
|
|
9597
9623
|
*
|
|
9598
|
-
* @param {
|
|
9599
|
-
*
|
|
9624
|
+
* @param {number} index
|
|
9625
|
+
*
|
|
9626
|
+
* @return {number}
|
|
9600
9627
|
*/
|
|
9601
9628
|
Canvas.prototype._getChildIndex = function(index) {
|
|
9602
9629
|
return reduce(this._layers, function(childIndex, layer) {
|
|
@@ -9614,7 +9641,7 @@
|
|
|
9614
9641
|
* @param {string} name
|
|
9615
9642
|
* @param {number} [index=0]
|
|
9616
9643
|
*
|
|
9617
|
-
* @return {
|
|
9644
|
+
* @return {CanvasLayer}
|
|
9618
9645
|
*/
|
|
9619
9646
|
Canvas.prototype._createLayer = function(name, index) {
|
|
9620
9647
|
|
|
@@ -9635,8 +9662,9 @@
|
|
|
9635
9662
|
/**
|
|
9636
9663
|
* Shows a given layer.
|
|
9637
9664
|
*
|
|
9638
|
-
* @param {
|
|
9639
|
-
*
|
|
9665
|
+
* @param {string} layer The name of the layer.
|
|
9666
|
+
*
|
|
9667
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9640
9668
|
*/
|
|
9641
9669
|
Canvas.prototype.showLayer = function(name) {
|
|
9642
9670
|
|
|
@@ -9670,8 +9698,9 @@
|
|
|
9670
9698
|
/**
|
|
9671
9699
|
* Hides a given layer.
|
|
9672
9700
|
*
|
|
9673
|
-
* @param {
|
|
9674
|
-
*
|
|
9701
|
+
* @param {string} layer The name of the layer.
|
|
9702
|
+
*
|
|
9703
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9675
9704
|
*/
|
|
9676
9705
|
Canvas.prototype.hideLayer = function(name) {
|
|
9677
9706
|
|
|
@@ -9713,7 +9742,7 @@
|
|
|
9713
9742
|
/**
|
|
9714
9743
|
* Returns the currently active layer. Can be null.
|
|
9715
9744
|
*
|
|
9716
|
-
* @
|
|
9745
|
+
* @return {CanvasLayer|null} The active layer of `null`.
|
|
9717
9746
|
*/
|
|
9718
9747
|
Canvas.prototype.getActiveLayer = function() {
|
|
9719
9748
|
const plane = this._findPlaneForRoot(this.getRootElement());
|
|
@@ -9729,9 +9758,9 @@
|
|
|
9729
9758
|
/**
|
|
9730
9759
|
* Returns the plane which contains the given element.
|
|
9731
9760
|
*
|
|
9732
|
-
* @param {string
|
|
9761
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9733
9762
|
*
|
|
9734
|
-
* @return {
|
|
9763
|
+
* @return {RootLike|undefined} The root of the element.
|
|
9735
9764
|
*/
|
|
9736
9765
|
Canvas.prototype.findRoot = function(element) {
|
|
9737
9766
|
if (typeof element === 'string') {
|
|
@@ -9752,7 +9781,7 @@
|
|
|
9752
9781
|
/**
|
|
9753
9782
|
* Return a list of all root elements on the diagram.
|
|
9754
9783
|
*
|
|
9755
|
-
* @return {
|
|
9784
|
+
* @return {(RootLike)[]} The list of root elements.
|
|
9756
9785
|
*/
|
|
9757
9786
|
Canvas.prototype.getRootElements = function() {
|
|
9758
9787
|
return this._planes.map(function(plane) {
|
|
@@ -9771,7 +9800,7 @@
|
|
|
9771
9800
|
* Returns the html element that encloses the
|
|
9772
9801
|
* drawing canvas.
|
|
9773
9802
|
*
|
|
9774
|
-
* @return {
|
|
9803
|
+
* @return {HTMLElement} The HTML element of the container.
|
|
9775
9804
|
*/
|
|
9776
9805
|
Canvas.prototype.getContainer = function() {
|
|
9777
9806
|
return this._container;
|
|
@@ -9811,8 +9840,8 @@
|
|
|
9811
9840
|
*
|
|
9812
9841
|
* @event element.marker.update
|
|
9813
9842
|
* @type {Object}
|
|
9814
|
-
* @property {
|
|
9815
|
-
* @property {
|
|
9843
|
+
* @property {Base} element the shape
|
|
9844
|
+
* @property {SVGElement} gfx the graphical representation of the shape
|
|
9816
9845
|
* @property {string} marker
|
|
9817
9846
|
* @property {boolean} add true if the marker was added, false if it got removed
|
|
9818
9847
|
*/
|
|
@@ -9827,14 +9856,15 @@
|
|
|
9827
9856
|
* integrate extension into the marker life-cycle, too.
|
|
9828
9857
|
*
|
|
9829
9858
|
* @example
|
|
9859
|
+
*
|
|
9830
9860
|
* canvas.addMarker('foo', 'some-marker');
|
|
9831
9861
|
*
|
|
9832
9862
|
* const fooGfx = canvas.getGraphics('foo');
|
|
9833
9863
|
*
|
|
9834
9864
|
* fooGfx; // <g class="... some-marker"> ... </g>
|
|
9835
9865
|
*
|
|
9836
|
-
* @param {string
|
|
9837
|
-
* @param {string} marker
|
|
9866
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9867
|
+
* @param {string} marker The marker.
|
|
9838
9868
|
*/
|
|
9839
9869
|
Canvas.prototype.addMarker = function(element, marker) {
|
|
9840
9870
|
this._updateMarker(element, marker, true);
|
|
@@ -9847,18 +9877,18 @@
|
|
|
9847
9877
|
* Fires the element.marker.update event, making it possible to
|
|
9848
9878
|
* integrate extension into the marker life-cycle, too.
|
|
9849
9879
|
*
|
|
9850
|
-
* @param
|
|
9851
|
-
* @param
|
|
9880
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9881
|
+
* @param {string} marker The marker.
|
|
9852
9882
|
*/
|
|
9853
9883
|
Canvas.prototype.removeMarker = function(element, marker) {
|
|
9854
9884
|
this._updateMarker(element, marker, false);
|
|
9855
9885
|
};
|
|
9856
9886
|
|
|
9857
9887
|
/**
|
|
9858
|
-
* Check
|
|
9888
|
+
* Check whether an element has a given marker.
|
|
9859
9889
|
*
|
|
9860
|
-
* @param
|
|
9861
|
-
* @param
|
|
9890
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9891
|
+
* @param {string} marker The marker.
|
|
9862
9892
|
*/
|
|
9863
9893
|
Canvas.prototype.hasMarker = function(element, marker) {
|
|
9864
9894
|
if (!element.id) {
|
|
@@ -9876,8 +9906,8 @@
|
|
|
9876
9906
|
* Fires the element.marker.update event, making it possible to
|
|
9877
9907
|
* integrate extension into the marker life-cycle, too.
|
|
9878
9908
|
*
|
|
9879
|
-
* @param
|
|
9880
|
-
* @param
|
|
9909
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9910
|
+
* @param {string} marker The marker.
|
|
9881
9911
|
*/
|
|
9882
9912
|
Canvas.prototype.toggleMarker = function(element, marker) {
|
|
9883
9913
|
if (this.hasMarker(element, marker)) {
|
|
@@ -9900,7 +9930,7 @@
|
|
|
9900
9930
|
* root elements can be null. This is used for applications that want to manage
|
|
9901
9931
|
* root elements themselves.
|
|
9902
9932
|
*
|
|
9903
|
-
* @
|
|
9933
|
+
* @return {RootLike} The current root element.
|
|
9904
9934
|
*/
|
|
9905
9935
|
Canvas.prototype.getRootElement = function() {
|
|
9906
9936
|
const rootElement = this._rootElement;
|
|
@@ -9916,11 +9946,10 @@
|
|
|
9916
9946
|
/**
|
|
9917
9947
|
* Adds a given root element and returns it.
|
|
9918
9948
|
*
|
|
9919
|
-
* @param {
|
|
9949
|
+
* @param {ShapeLike} [rootElement] The root element to be added.
|
|
9920
9950
|
*
|
|
9921
|
-
* @return {
|
|
9951
|
+
* @return {RootLike} The added root element or an implicit root element.
|
|
9922
9952
|
*/
|
|
9923
|
-
|
|
9924
9953
|
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9925
9954
|
const idx = this._rootsIdx++;
|
|
9926
9955
|
|
|
@@ -9951,11 +9980,11 @@
|
|
|
9951
9980
|
};
|
|
9952
9981
|
|
|
9953
9982
|
/**
|
|
9954
|
-
* Removes a given
|
|
9983
|
+
* Removes a given root element and returns it.
|
|
9955
9984
|
*
|
|
9956
|
-
* @param {
|
|
9985
|
+
* @param {ShapeLike|string} rootElement The root element or its ID.
|
|
9957
9986
|
*
|
|
9958
|
-
* @return {
|
|
9987
|
+
* @return {ShapeLike|undefined} The removed root element.
|
|
9959
9988
|
*/
|
|
9960
9989
|
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
9961
9990
|
|
|
@@ -9989,15 +10018,13 @@
|
|
|
9989
10018
|
};
|
|
9990
10019
|
|
|
9991
10020
|
|
|
9992
|
-
// root element handling //////////////////////
|
|
9993
|
-
|
|
9994
10021
|
/**
|
|
9995
10022
|
* Sets a given element as the new root element for the canvas
|
|
9996
10023
|
* and returns the new root element.
|
|
9997
10024
|
*
|
|
9998
|
-
* @param {
|
|
10025
|
+
* @param {RootLike} rootElement The root element to be set.
|
|
9999
10026
|
*
|
|
10000
|
-
* @return {
|
|
10027
|
+
* @return {RootLike} The set root element.
|
|
10001
10028
|
*/
|
|
10002
10029
|
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
10003
10030
|
|
|
@@ -10084,8 +10111,6 @@
|
|
|
10084
10111
|
this._eventBus.fire('root.set', { element: rootElement });
|
|
10085
10112
|
};
|
|
10086
10113
|
|
|
10087
|
-
// add functionality //////////////////////
|
|
10088
|
-
|
|
10089
10114
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
10090
10115
|
if (!element.id) {
|
|
10091
10116
|
throw new Error('element must have an id');
|
|
@@ -10126,11 +10151,11 @@
|
|
|
10126
10151
|
* Extensions may hook into these events to perform their magic.
|
|
10127
10152
|
*
|
|
10128
10153
|
* @param {string} type
|
|
10129
|
-
* @param {
|
|
10130
|
-
* @param {
|
|
10154
|
+
* @param {ConnectionLike|ShapeLike} element
|
|
10155
|
+
* @param {ShapeLike} [parent]
|
|
10131
10156
|
* @param {number} [parentIndex]
|
|
10132
10157
|
*
|
|
10133
|
-
* @return {
|
|
10158
|
+
* @return {ConnectionLike|ShapeLike} The added element.
|
|
10134
10159
|
*/
|
|
10135
10160
|
Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
|
10136
10161
|
|
|
@@ -10159,26 +10184,26 @@
|
|
|
10159
10184
|
};
|
|
10160
10185
|
|
|
10161
10186
|
/**
|
|
10162
|
-
* Adds a shape to the canvas
|
|
10187
|
+
* Adds a shape to the canvas.
|
|
10163
10188
|
*
|
|
10164
|
-
* @param {
|
|
10165
|
-
* @param {
|
|
10166
|
-
* @param {number} [parentIndex]
|
|
10189
|
+
* @param {ShapeLike} shape The shape to be added
|
|
10190
|
+
* @param {ShapeLike} [parent] The shape's parent.
|
|
10191
|
+
* @param {number} [parentIndex] The index at which to add the shape to the parent's children.
|
|
10167
10192
|
*
|
|
10168
|
-
* @return {
|
|
10193
|
+
* @return {ShapeLike} The added shape.
|
|
10169
10194
|
*/
|
|
10170
10195
|
Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
|
10171
10196
|
return this._addElement('shape', shape, parent, parentIndex);
|
|
10172
10197
|
};
|
|
10173
10198
|
|
|
10174
10199
|
/**
|
|
10175
|
-
* Adds a connection to the canvas
|
|
10200
|
+
* Adds a connection to the canvas.
|
|
10176
10201
|
*
|
|
10177
|
-
* @param {
|
|
10178
|
-
* @param {
|
|
10179
|
-
* @param {number} [parentIndex]
|
|
10202
|
+
* @param {ConnectionLike} connection The connection to be added.
|
|
10203
|
+
* @param {ShapeLike} [parent] The connection's parent.
|
|
10204
|
+
* @param {number} [parentIndex] The index at which to add the connection to the parent's children.
|
|
10180
10205
|
*
|
|
10181
|
-
* @return {
|
|
10206
|
+
* @return {ConnectionLike} The added connection.
|
|
10182
10207
|
*/
|
|
10183
10208
|
Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
|
10184
10209
|
return this._addElement('connection', connection, parent, parentIndex);
|
|
@@ -10219,11 +10244,14 @@
|
|
|
10219
10244
|
|
|
10220
10245
|
|
|
10221
10246
|
/**
|
|
10222
|
-
* Removes a shape from the canvas
|
|
10247
|
+
* Removes a shape from the canvas.
|
|
10223
10248
|
*
|
|
10224
|
-
* @
|
|
10249
|
+
* @fires ShapeRemoveEvent
|
|
10250
|
+
* @fires ShapeRemovedEvent
|
|
10225
10251
|
*
|
|
10226
|
-
* @
|
|
10252
|
+
* @param {ShapeLike|string} shape The shape or its ID.
|
|
10253
|
+
*
|
|
10254
|
+
* @return {ShapeLike} The removed shape.
|
|
10227
10255
|
*/
|
|
10228
10256
|
Canvas.prototype.removeShape = function(shape) {
|
|
10229
10257
|
|
|
@@ -10232,10 +10260,10 @@
|
|
|
10232
10260
|
*
|
|
10233
10261
|
* @memberOf Canvas
|
|
10234
10262
|
*
|
|
10235
|
-
* @event
|
|
10263
|
+
* @event ShapeRemoveEvent
|
|
10236
10264
|
* @type {Object}
|
|
10237
|
-
* @property {
|
|
10238
|
-
* @property {
|
|
10265
|
+
* @property {ShapeLike} element The shape.
|
|
10266
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10239
10267
|
*/
|
|
10240
10268
|
|
|
10241
10269
|
/**
|
|
@@ -10243,21 +10271,24 @@
|
|
|
10243
10271
|
*
|
|
10244
10272
|
* @memberOf Canvas
|
|
10245
10273
|
*
|
|
10246
|
-
* @event
|
|
10274
|
+
* @event ShapeRemoved
|
|
10247
10275
|
* @type {Object}
|
|
10248
|
-
* @property {
|
|
10249
|
-
* @property {
|
|
10276
|
+
* @property {ShapeLike} element The shape.
|
|
10277
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10250
10278
|
*/
|
|
10251
10279
|
return this._removeElement(shape, 'shape');
|
|
10252
10280
|
};
|
|
10253
10281
|
|
|
10254
10282
|
|
|
10255
10283
|
/**
|
|
10256
|
-
* Removes a connection from the canvas
|
|
10284
|
+
* Removes a connection from the canvas.
|
|
10285
|
+
*
|
|
10286
|
+
* @fires ConnectionRemoveEvent
|
|
10287
|
+
* @fires ConnectionRemovedEvent
|
|
10257
10288
|
*
|
|
10258
|
-
* @param {string
|
|
10289
|
+
* @param {ConnectionLike|string} connection The connection or its ID.
|
|
10259
10290
|
*
|
|
10260
|
-
* @return {
|
|
10291
|
+
* @return {ConnectionLike} The removed connection.
|
|
10261
10292
|
*/
|
|
10262
10293
|
Canvas.prototype.removeConnection = function(connection) {
|
|
10263
10294
|
|
|
@@ -10266,10 +10297,10 @@
|
|
|
10266
10297
|
*
|
|
10267
10298
|
* @memberOf Canvas
|
|
10268
10299
|
*
|
|
10269
|
-
* @event
|
|
10300
|
+
* @event ConnectionRemoveEvent
|
|
10270
10301
|
* @type {Object}
|
|
10271
|
-
* @property {
|
|
10272
|
-
* @property {
|
|
10302
|
+
* @property {ConnectionLike} element The connection.
|
|
10303
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10273
10304
|
*/
|
|
10274
10305
|
|
|
10275
10306
|
/**
|
|
@@ -10279,20 +10310,20 @@
|
|
|
10279
10310
|
*
|
|
10280
10311
|
* @event connection.removed
|
|
10281
10312
|
* @type {Object}
|
|
10282
|
-
* @property {
|
|
10283
|
-
* @property {
|
|
10313
|
+
* @property {ConnectionLike} element The connection.
|
|
10314
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10284
10315
|
*/
|
|
10285
10316
|
return this._removeElement(connection, 'connection');
|
|
10286
10317
|
};
|
|
10287
10318
|
|
|
10288
10319
|
|
|
10289
10320
|
/**
|
|
10290
|
-
*
|
|
10321
|
+
* Returns the graphical element of an element.
|
|
10291
10322
|
*
|
|
10292
|
-
* @param {string
|
|
10293
|
-
* @param {boolean} [secondary=false]
|
|
10323
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
10324
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical element.
|
|
10294
10325
|
*
|
|
10295
|
-
* @return {SVGElement}
|
|
10326
|
+
* @return {SVGElement} The graphical element.
|
|
10296
10327
|
*/
|
|
10297
10328
|
Canvas.prototype.getGraphics = function(element, secondary) {
|
|
10298
10329
|
return this._elementRegistry.getGraphics(element, secondary);
|
|
@@ -10364,13 +10395,9 @@
|
|
|
10364
10395
|
* height: zoomedAndScrolledViewbox.outer.height
|
|
10365
10396
|
* });
|
|
10366
10397
|
*
|
|
10367
|
-
* @param
|
|
10368
|
-
* @param {number} box.x the top left X coordinate of the canvas visible in view box
|
|
10369
|
-
* @param {number} box.y the top left Y coordinate of the canvas visible in view box
|
|
10370
|
-
* @param {number} box.width the visible width
|
|
10371
|
-
* @param {number} box.height
|
|
10398
|
+
* @param {Rect} [box] The viewbox to be set.
|
|
10372
10399
|
*
|
|
10373
|
-
* @return {
|
|
10400
|
+
* @return {CanvasViewbox} The set viewbox.
|
|
10374
10401
|
*/
|
|
10375
10402
|
Canvas.prototype.viewbox = function(box) {
|
|
10376
10403
|
|
|
@@ -10439,10 +10466,9 @@
|
|
|
10439
10466
|
/**
|
|
10440
10467
|
* Gets or sets the scroll of the canvas.
|
|
10441
10468
|
*
|
|
10442
|
-
* @param {
|
|
10469
|
+
* @param {Point} [delta] The scroll to be set.
|
|
10443
10470
|
*
|
|
10444
|
-
* @
|
|
10445
|
-
* @param {number} [delta.dy]
|
|
10471
|
+
* @return {Point}
|
|
10446
10472
|
*/
|
|
10447
10473
|
Canvas.prototype.scroll = function(delta) {
|
|
10448
10474
|
|
|
@@ -10466,9 +10492,8 @@
|
|
|
10466
10492
|
* Scrolls the viewbox to contain the given element.
|
|
10467
10493
|
* Optionally specify a padding to be applied to the edges.
|
|
10468
10494
|
*
|
|
10469
|
-
* @param {
|
|
10470
|
-
* @param {
|
|
10471
|
-
*
|
|
10495
|
+
* @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
|
|
10496
|
+
* @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
|
|
10472
10497
|
*/
|
|
10473
10498
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
10474
10499
|
let defaultPadding = 100;
|
|
@@ -10536,17 +10561,17 @@
|
|
|
10536
10561
|
};
|
|
10537
10562
|
|
|
10538
10563
|
/**
|
|
10539
|
-
* Gets or sets the current zoom of the canvas, optionally zooming
|
|
10540
|
-
*
|
|
10564
|
+
* Gets or sets the current zoom of the canvas, optionally zooming to the
|
|
10565
|
+
* specified position.
|
|
10541
10566
|
*
|
|
10542
|
-
* The getter may return a cached zoom level. Call it with `false` as
|
|
10543
|
-
*
|
|
10567
|
+
* The getter may return a cached zoom level. Call it with `false` as the first
|
|
10568
|
+
* argument to force recomputation of the current level.
|
|
10544
10569
|
*
|
|
10545
|
-
* @param {string
|
|
10546
|
-
*
|
|
10547
|
-
* @param {
|
|
10570
|
+
* @param {number|string} [newScale] The new zoom level, either a number,
|
|
10571
|
+
* i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
|
|
10572
|
+
* @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
|
|
10548
10573
|
*
|
|
10549
|
-
* @return {number}
|
|
10574
|
+
* @return {number} The set zoom level.
|
|
10550
10575
|
*/
|
|
10551
10576
|
Canvas.prototype.zoom = function(newScale, center) {
|
|
10552
10577
|
|
|
@@ -10669,9 +10694,9 @@
|
|
|
10669
10694
|
|
|
10670
10695
|
|
|
10671
10696
|
/**
|
|
10672
|
-
* Returns the size of the canvas
|
|
10697
|
+
* Returns the size of the canvas.
|
|
10673
10698
|
*
|
|
10674
|
-
* @return {Dimensions}
|
|
10699
|
+
* @return {Dimensions} The size of the canvas.
|
|
10675
10700
|
*/
|
|
10676
10701
|
Canvas.prototype.getSize = function() {
|
|
10677
10702
|
return {
|
|
@@ -10682,14 +10707,14 @@
|
|
|
10682
10707
|
|
|
10683
10708
|
|
|
10684
10709
|
/**
|
|
10685
|
-
*
|
|
10710
|
+
* Returns the absolute bounding box of an element.
|
|
10686
10711
|
*
|
|
10687
|
-
* The absolute bounding box may be used to display overlays in the
|
|
10688
|
-
*
|
|
10689
|
-
* canvas coordinates.
|
|
10712
|
+
* The absolute bounding box may be used to display overlays in the callers
|
|
10713
|
+
* (browser) coordinate system rather than the zoomed in/out canvas coordinates.
|
|
10690
10714
|
*
|
|
10691
|
-
* @param
|
|
10692
|
-
*
|
|
10715
|
+
* @param {ShapeLike|ConnectionLike} element The element.
|
|
10716
|
+
*
|
|
10717
|
+
* @return {Rect} The element's absolute bounding box.
|
|
10693
10718
|
*/
|
|
10694
10719
|
Canvas.prototype.getAbsoluteBBox = function(element) {
|
|
10695
10720
|
const vbox = this.viewbox();
|
|
@@ -10724,8 +10749,7 @@
|
|
|
10724
10749
|
};
|
|
10725
10750
|
|
|
10726
10751
|
/**
|
|
10727
|
-
* Fires an event
|
|
10728
|
-
* canvas resizing
|
|
10752
|
+
* Fires an event so other modules can react to the canvas resizing.
|
|
10729
10753
|
*/
|
|
10730
10754
|
Canvas.prototype.resized = function() {
|
|
10731
10755
|
|
|
@@ -10737,11 +10761,21 @@
|
|
|
10737
10761
|
|
|
10738
10762
|
var ELEMENT_ID = 'data-element-id';
|
|
10739
10763
|
|
|
10764
|
+
/**
|
|
10765
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
10766
|
+
*
|
|
10767
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
10768
|
+
*
|
|
10769
|
+
* @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
|
|
10770
|
+
*/
|
|
10740
10771
|
|
|
10741
10772
|
/**
|
|
10773
|
+
* A registry that keeps track of all shapes in the diagram.
|
|
10774
|
+
*
|
|
10742
10775
|
* @class
|
|
10776
|
+
* @constructor
|
|
10743
10777
|
*
|
|
10744
|
-
*
|
|
10778
|
+
* @param {EventBus} eventBus
|
|
10745
10779
|
*/
|
|
10746
10780
|
function ElementRegistry(eventBus) {
|
|
10747
10781
|
this._elements = {};
|
|
@@ -10752,11 +10786,11 @@
|
|
|
10752
10786
|
ElementRegistry.$inject = [ 'eventBus' ];
|
|
10753
10787
|
|
|
10754
10788
|
/**
|
|
10755
|
-
*
|
|
10789
|
+
* Add an element and its graphical representation(s) to the registry.
|
|
10756
10790
|
*
|
|
10757
|
-
* @param {
|
|
10758
|
-
* @param {SVGElement} gfx
|
|
10759
|
-
* @param {SVGElement} [secondaryGfx]
|
|
10791
|
+
* @param {ElementLike} element The element to be added.
|
|
10792
|
+
* @param {SVGElement} gfx The primary graphical representation.
|
|
10793
|
+
* @param {SVGElement} [secondaryGfx] The secondary graphical representation.
|
|
10760
10794
|
*/
|
|
10761
10795
|
ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
|
10762
10796
|
|
|
@@ -10775,9 +10809,9 @@
|
|
|
10775
10809
|
};
|
|
10776
10810
|
|
|
10777
10811
|
/**
|
|
10778
|
-
*
|
|
10812
|
+
* Remove an element from the registry.
|
|
10779
10813
|
*
|
|
10780
|
-
* @param {string
|
|
10814
|
+
* @param {ElementLike|string} element
|
|
10781
10815
|
*/
|
|
10782
10816
|
ElementRegistry.prototype.remove = function(element) {
|
|
10783
10817
|
var elements = this._elements,
|
|
@@ -10798,10 +10832,10 @@
|
|
|
10798
10832
|
};
|
|
10799
10833
|
|
|
10800
10834
|
/**
|
|
10801
|
-
* Update
|
|
10835
|
+
* Update an elements ID.
|
|
10802
10836
|
*
|
|
10803
|
-
* @param {string
|
|
10804
|
-
* @param {string} newId
|
|
10837
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10838
|
+
* @param {string} newId The new ID.
|
|
10805
10839
|
*/
|
|
10806
10840
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
10807
10841
|
|
|
@@ -10827,11 +10861,11 @@
|
|
|
10827
10861
|
};
|
|
10828
10862
|
|
|
10829
10863
|
/**
|
|
10830
|
-
* Update the
|
|
10864
|
+
* Update the graphical representation of an element.
|
|
10831
10865
|
*
|
|
10832
|
-
* @param {string
|
|
10833
|
-
* @param {SVGElement} gfx
|
|
10834
|
-
* @param {boolean} [secondary=false]
|
|
10866
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10867
|
+
* @param {SVGElement} gfx The new graphical representation.
|
|
10868
|
+
* @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
|
|
10835
10869
|
*/
|
|
10836
10870
|
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
10837
10871
|
var id = filter.id || filter;
|
|
@@ -10852,17 +10886,17 @@
|
|
|
10852
10886
|
};
|
|
10853
10887
|
|
|
10854
10888
|
/**
|
|
10855
|
-
*
|
|
10889
|
+
* Get the element with the given ID or graphical representation.
|
|
10856
10890
|
*
|
|
10857
10891
|
* @example
|
|
10858
10892
|
*
|
|
10859
10893
|
* elementRegistry.get('SomeElementId_1');
|
|
10860
|
-
* elementRegistry.get(gfx);
|
|
10861
10894
|
*
|
|
10895
|
+
* elementRegistry.get(gfx);
|
|
10862
10896
|
*
|
|
10863
|
-
* @param {string|SVGElement} filter
|
|
10897
|
+
* @param {string|SVGElement} filter The elements ID or graphical representation.
|
|
10864
10898
|
*
|
|
10865
|
-
* @return {
|
|
10899
|
+
* @return {ElementLike|undefined} The element.
|
|
10866
10900
|
*/
|
|
10867
10901
|
ElementRegistry.prototype.get = function(filter) {
|
|
10868
10902
|
var id;
|
|
@@ -10880,9 +10914,9 @@
|
|
|
10880
10914
|
/**
|
|
10881
10915
|
* Return all elements that match a given filter function.
|
|
10882
10916
|
*
|
|
10883
|
-
* @param {
|
|
10917
|
+
* @param {ElementRegistryCallback} fn The filter function.
|
|
10884
10918
|
*
|
|
10885
|
-
* @return {
|
|
10919
|
+
* @return {ElementLike[]} The matching elements.
|
|
10886
10920
|
*/
|
|
10887
10921
|
ElementRegistry.prototype.filter = function(fn) {
|
|
10888
10922
|
|
|
@@ -10898,11 +10932,11 @@
|
|
|
10898
10932
|
};
|
|
10899
10933
|
|
|
10900
10934
|
/**
|
|
10901
|
-
* Return the first element that
|
|
10935
|
+
* Return the first element that matches the given filter function.
|
|
10902
10936
|
*
|
|
10903
|
-
* @param {Function} fn
|
|
10937
|
+
* @param {Function} fn The filter function.
|
|
10904
10938
|
*
|
|
10905
|
-
* @return {
|
|
10939
|
+
* @return {ElementLike|undefined} The matching element.
|
|
10906
10940
|
*/
|
|
10907
10941
|
ElementRegistry.prototype.find = function(fn) {
|
|
10908
10942
|
var map = this._elements,
|
|
@@ -10921,18 +10955,18 @@
|
|
|
10921
10955
|
};
|
|
10922
10956
|
|
|
10923
10957
|
/**
|
|
10924
|
-
*
|
|
10958
|
+
* Get all elements.
|
|
10925
10959
|
*
|
|
10926
|
-
* @return {
|
|
10960
|
+
* @return {ElementLike[]} All elements.
|
|
10927
10961
|
*/
|
|
10928
10962
|
ElementRegistry.prototype.getAll = function() {
|
|
10929
10963
|
return this.filter(function(e) { return e; });
|
|
10930
10964
|
};
|
|
10931
10965
|
|
|
10932
10966
|
/**
|
|
10933
|
-
*
|
|
10967
|
+
* Execute a given function for each element.
|
|
10934
10968
|
*
|
|
10935
|
-
* @param {Function} fn
|
|
10969
|
+
* @param {Function} fn The function to execute.
|
|
10936
10970
|
*/
|
|
10937
10971
|
ElementRegistry.prototype.forEach = function(fn) {
|
|
10938
10972
|
|
|
@@ -10948,19 +10982,20 @@
|
|
|
10948
10982
|
};
|
|
10949
10983
|
|
|
10950
10984
|
/**
|
|
10951
|
-
* Return the graphical representation of an element
|
|
10985
|
+
* Return the graphical representation of an element.
|
|
10952
10986
|
*
|
|
10953
10987
|
* @example
|
|
10988
|
+
*
|
|
10954
10989
|
* elementRegistry.getGraphics('SomeElementId_1');
|
|
10990
|
+
*
|
|
10955
10991
|
* elementRegistry.getGraphics(rootElement); // <g ...>
|
|
10956
10992
|
*
|
|
10957
10993
|
* elementRegistry.getGraphics(rootElement, true); // <svg ...>
|
|
10958
10994
|
*
|
|
10995
|
+
* @param {ElementLike|string} filter The element or its ID.
|
|
10996
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
|
|
10959
10997
|
*
|
|
10960
|
-
* @
|
|
10961
|
-
* @param {boolean} [secondary=false] whether to return the secondary connected element
|
|
10962
|
-
*
|
|
10963
|
-
* @return {SVGElement}
|
|
10998
|
+
* @return {SVGElement} The graphical representation.
|
|
10964
10999
|
*/
|
|
10965
11000
|
ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
|
10966
11001
|
var id = filter.id || filter;
|
|
@@ -10970,12 +11005,11 @@
|
|
|
10970
11005
|
};
|
|
10971
11006
|
|
|
10972
11007
|
/**
|
|
10973
|
-
* Validate
|
|
10974
|
-
* with an exception.
|
|
11008
|
+
* Validate an ID and throw an error if invalid.
|
|
10975
11009
|
*
|
|
10976
11010
|
* @param {string} id
|
|
10977
11011
|
*
|
|
10978
|
-
* @throws {Error}
|
|
11012
|
+
* @throws {Error} Error indicating that the ID is invalid or already assigned.
|
|
10979
11013
|
*/
|
|
10980
11014
|
ElementRegistry.prototype._validateId = function(id) {
|
|
10981
11015
|
if (!id) {
|
|
@@ -11315,14 +11349,6 @@
|
|
|
11315
11349
|
outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
|
11316
11350
|
incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
|
|
11317
11351
|
|
|
11318
|
-
/**
|
|
11319
|
-
* @namespace djs.model
|
|
11320
|
-
*/
|
|
11321
|
-
|
|
11322
|
-
/**
|
|
11323
|
-
* @memberOf djs.model
|
|
11324
|
-
*/
|
|
11325
|
-
|
|
11326
11352
|
/**
|
|
11327
11353
|
* The basic graphical representation
|
|
11328
11354
|
*
|
|
@@ -11519,21 +11545,47 @@
|
|
|
11519
11545
|
};
|
|
11520
11546
|
|
|
11521
11547
|
/**
|
|
11522
|
-
* Creates a
|
|
11548
|
+
* Creates a model element of the given type.
|
|
11523
11549
|
*
|
|
11524
11550
|
* @method create
|
|
11525
11551
|
*
|
|
11526
11552
|
* @example
|
|
11527
11553
|
*
|
|
11528
|
-
*
|
|
11529
|
-
* var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
|
|
11554
|
+
* import * as Model from 'diagram-js/lib/model';
|
|
11530
11555
|
*
|
|
11531
|
-
*
|
|
11556
|
+
* const connection = Model.create('connection', {
|
|
11557
|
+
* waypoints: [
|
|
11558
|
+
* { x: 100, y: 100 },
|
|
11559
|
+
* { x: 200, y: 100 }
|
|
11560
|
+
* ]
|
|
11561
|
+
* });
|
|
11562
|
+
*
|
|
11563
|
+
* const label = Model.create('label', {
|
|
11564
|
+
* x: 100,
|
|
11565
|
+
* y: 100,
|
|
11566
|
+
* width: 100,
|
|
11567
|
+
* height: 100,
|
|
11568
|
+
* labelTarget: shape
|
|
11569
|
+
* });
|
|
11570
|
+
*
|
|
11571
|
+
* const root = Model.create('root', {
|
|
11572
|
+
* x: 100,
|
|
11573
|
+
* y: 100,
|
|
11574
|
+
* width: 100,
|
|
11575
|
+
* height: 100
|
|
11576
|
+
* });
|
|
11577
|
+
*
|
|
11578
|
+
* const shape = Model.create('shape', {
|
|
11579
|
+
* x: 100,
|
|
11580
|
+
* y: 100,
|
|
11581
|
+
* width: 100,
|
|
11582
|
+
* height: 100
|
|
11583
|
+
* });
|
|
11532
11584
|
*
|
|
11533
|
-
* @param
|
|
11534
|
-
* @param
|
|
11585
|
+
* @param {string} type The type of model element to be created.
|
|
11586
|
+
* @param {Object} attrs Attributes to create the model element with.
|
|
11535
11587
|
*
|
|
11536
|
-
* @return {
|
|
11588
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11537
11589
|
*/
|
|
11538
11590
|
function create(type, attrs) {
|
|
11539
11591
|
var Type = types$6[type];
|
|
@@ -11544,36 +11596,78 @@
|
|
|
11544
11596
|
}
|
|
11545
11597
|
|
|
11546
11598
|
/**
|
|
11547
|
-
*
|
|
11599
|
+
* @typedef {import('../model/index').Base} Base
|
|
11600
|
+
* @typedef {import('../model/index').Connection} Connection
|
|
11601
|
+
* @typedef {import('../model/index').Label} Label
|
|
11602
|
+
* @typedef {import('../model/index').Root} Root
|
|
11603
|
+
* @typedef {import('../model/index').Shape} Shape
|
|
11604
|
+
* @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
|
|
11605
|
+
* @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
|
|
11606
|
+
* @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
|
|
11607
|
+
* @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
|
|
11608
|
+
*/
|
|
11609
|
+
|
|
11610
|
+
/**
|
|
11611
|
+
* A factory for model elements.
|
|
11612
|
+
*
|
|
11613
|
+
* @class
|
|
11614
|
+
* @constructor
|
|
11548
11615
|
*/
|
|
11549
11616
|
function ElementFactory() {
|
|
11550
11617
|
this._uid = 12;
|
|
11551
11618
|
}
|
|
11552
11619
|
|
|
11553
|
-
|
|
11620
|
+
/**
|
|
11621
|
+
* Create a root element.
|
|
11622
|
+
*
|
|
11623
|
+
* @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
|
|
11624
|
+
*
|
|
11625
|
+
* @return {Root} The created root element.
|
|
11626
|
+
*/
|
|
11554
11627
|
ElementFactory.prototype.createRoot = function(attrs) {
|
|
11555
11628
|
return this.create('root', attrs);
|
|
11556
11629
|
};
|
|
11557
11630
|
|
|
11631
|
+
/**
|
|
11632
|
+
* Create a label.
|
|
11633
|
+
*
|
|
11634
|
+
* @param {ModelAttrsLabel} attrs The attributes of the label to be created.
|
|
11635
|
+
*
|
|
11636
|
+
* @return {Label} The created label.
|
|
11637
|
+
*/
|
|
11558
11638
|
ElementFactory.prototype.createLabel = function(attrs) {
|
|
11559
11639
|
return this.create('label', attrs);
|
|
11560
11640
|
};
|
|
11561
11641
|
|
|
11642
|
+
/**
|
|
11643
|
+
* Create a shape.
|
|
11644
|
+
*
|
|
11645
|
+
* @param {ModelAttrsShape} attrs The attributes of the shape to be created.
|
|
11646
|
+
*
|
|
11647
|
+
* @return {Shape} The created shape.
|
|
11648
|
+
*/
|
|
11562
11649
|
ElementFactory.prototype.createShape = function(attrs) {
|
|
11563
11650
|
return this.create('shape', attrs);
|
|
11564
11651
|
};
|
|
11565
11652
|
|
|
11653
|
+
/**
|
|
11654
|
+
* Create a connection.
|
|
11655
|
+
*
|
|
11656
|
+
* @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
|
|
11657
|
+
*
|
|
11658
|
+
* @return {Connection} The created connection.
|
|
11659
|
+
*/
|
|
11566
11660
|
ElementFactory.prototype.createConnection = function(attrs) {
|
|
11567
11661
|
return this.create('connection', attrs);
|
|
11568
11662
|
};
|
|
11569
11663
|
|
|
11570
11664
|
/**
|
|
11571
|
-
* Create a model element
|
|
11572
|
-
* a number of pre-set attributes.
|
|
11665
|
+
* Create a model element of the given type with the given attributes.
|
|
11573
11666
|
*
|
|
11574
|
-
* @param
|
|
11575
|
-
* @param
|
|
11576
|
-
*
|
|
11667
|
+
* @param {string} type The type of the model element.
|
|
11668
|
+
* @param {Object} attrs The attributes of the model element.
|
|
11669
|
+
*
|
|
11670
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11577
11671
|
*/
|
|
11578
11672
|
ElementFactory.prototype.create = function(type, attrs) {
|
|
11579
11673
|
|
|
@@ -11592,6 +11686,16 @@
|
|
|
11592
11686
|
|
|
11593
11687
|
var slice = Array.prototype.slice;
|
|
11594
11688
|
|
|
11689
|
+
/**
|
|
11690
|
+
* @typedef {import('./EventBus').Event} Event
|
|
11691
|
+
* @typedef {import('./EventBus').EventCallback} EventCallback
|
|
11692
|
+
*
|
|
11693
|
+
* @typedef {Object} EventListener
|
|
11694
|
+
* @property {Function} callback
|
|
11695
|
+
* @property {EventListener|null} next
|
|
11696
|
+
* @property {number} priority
|
|
11697
|
+
*/
|
|
11698
|
+
|
|
11595
11699
|
/**
|
|
11596
11700
|
* A general purpose event bus.
|
|
11597
11701
|
*
|
|
@@ -11696,10 +11800,10 @@
|
|
|
11696
11800
|
*
|
|
11697
11801
|
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
11698
11802
|
*
|
|
11699
|
-
* @param {string|
|
|
11700
|
-
* @param {number} [priority=1000]
|
|
11701
|
-
* @param {
|
|
11702
|
-
* @param {
|
|
11803
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
11804
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11805
|
+
* @param {EventCallback} callback The callback.
|
|
11806
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11703
11807
|
*/
|
|
11704
11808
|
EventBus.prototype.on = function(events, priority, callback, that) {
|
|
11705
11809
|
|
|
@@ -11739,12 +11843,12 @@
|
|
|
11739
11843
|
|
|
11740
11844
|
|
|
11741
11845
|
/**
|
|
11742
|
-
* Register an event listener that is
|
|
11846
|
+
* Register an event listener that is called only once.
|
|
11743
11847
|
*
|
|
11744
|
-
* @param {string} event
|
|
11745
|
-
* @param {number} [priority=1000]
|
|
11746
|
-
* @param {
|
|
11747
|
-
* @param {
|
|
11848
|
+
* @param {string} event The event to listen to.
|
|
11849
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11850
|
+
* @param {EventCallback} callback The callback.
|
|
11851
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11748
11852
|
*/
|
|
11749
11853
|
EventBus.prototype.once = function(event, priority, callback, that) {
|
|
11750
11854
|
var self = this;
|
|
@@ -11783,8 +11887,8 @@
|
|
|
11783
11887
|
*
|
|
11784
11888
|
* If no callback is given, all listeners for a given event name are being removed.
|
|
11785
11889
|
*
|
|
11786
|
-
* @param {string|
|
|
11787
|
-
* @param {
|
|
11890
|
+
* @param {string|string[]} events The events.
|
|
11891
|
+
* @param {EventCallback} [callback] The callback.
|
|
11788
11892
|
*/
|
|
11789
11893
|
EventBus.prototype.off = function(events, callback) {
|
|
11790
11894
|
|
|
@@ -11800,11 +11904,11 @@
|
|
|
11800
11904
|
|
|
11801
11905
|
|
|
11802
11906
|
/**
|
|
11803
|
-
* Create an
|
|
11907
|
+
* Create an event recognized be the event bus.
|
|
11804
11908
|
*
|
|
11805
|
-
* @param {Object} data
|
|
11909
|
+
* @param {Object} data Event data.
|
|
11806
11910
|
*
|
|
11807
|
-
* @return {
|
|
11911
|
+
* @return {Event} An event that will be recognized by the event bus.
|
|
11808
11912
|
*/
|
|
11809
11913
|
EventBus.prototype.createEvent = function(data) {
|
|
11810
11914
|
var event = new InternalEvent();
|
|
@@ -11816,7 +11920,7 @@
|
|
|
11816
11920
|
|
|
11817
11921
|
|
|
11818
11922
|
/**
|
|
11819
|
-
* Fires
|
|
11923
|
+
* Fires an event.
|
|
11820
11924
|
*
|
|
11821
11925
|
* @example
|
|
11822
11926
|
*
|
|
@@ -11838,12 +11942,11 @@
|
|
|
11838
11942
|
*
|
|
11839
11943
|
* events.fire({ type: 'foo' }, 'I am bar!');
|
|
11840
11944
|
*
|
|
11841
|
-
* @param {string} [
|
|
11842
|
-
* @param {Object} [
|
|
11843
|
-
* @param {
|
|
11945
|
+
* @param {string} [type] The event type.
|
|
11946
|
+
* @param {Object} [data] The event or event data.
|
|
11947
|
+
* @param {...*} additional Additional arguments the callback will be called with.
|
|
11844
11948
|
*
|
|
11845
|
-
* @return {
|
|
11846
|
-
* default action was prevented by listeners
|
|
11949
|
+
* @return {*} The return value. Will be set to `false` if the default was prevented.
|
|
11847
11950
|
*/
|
|
11848
11951
|
EventBus.prototype.fire = function(type, data) {
|
|
11849
11952
|
var event,
|
|
@@ -11908,7 +12011,13 @@
|
|
|
11908
12011
|
return returnValue;
|
|
11909
12012
|
};
|
|
11910
12013
|
|
|
11911
|
-
|
|
12014
|
+
/**
|
|
12015
|
+
* Handle an error by firing an event.
|
|
12016
|
+
*
|
|
12017
|
+
* @param {Error} error The error to be handled.
|
|
12018
|
+
*
|
|
12019
|
+
* @return {boolean} Whether the error was handled.
|
|
12020
|
+
*/
|
|
11912
12021
|
EventBus.prototype.handleError = function(error) {
|
|
11913
12022
|
return this.fire('error', { error: error }) === false;
|
|
11914
12023
|
};
|
|
@@ -11971,7 +12080,7 @@
|
|
|
11971
12080
|
return returnValue;
|
|
11972
12081
|
};
|
|
11973
12082
|
|
|
11974
|
-
|
|
12083
|
+
/**
|
|
11975
12084
|
* Add new listener with a certain priority to the list
|
|
11976
12085
|
* of listeners (for the given event).
|
|
11977
12086
|
*
|
|
@@ -11985,7 +12094,7 @@
|
|
|
11985
12094
|
* * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
|
|
11986
12095
|
*
|
|
11987
12096
|
* @param {string} event
|
|
11988
|
-
* @param {
|
|
12097
|
+
* @param {EventListener} listener
|
|
11989
12098
|
*/
|
|
11990
12099
|
EventBus.prototype._addListener = function(event, newListener) {
|
|
11991
12100
|
|
|
@@ -12091,9 +12200,9 @@
|
|
|
12091
12200
|
* Invoke function. Be fast...
|
|
12092
12201
|
*
|
|
12093
12202
|
* @param {Function} fn
|
|
12094
|
-
* @param {
|
|
12203
|
+
* @param {*[]} args
|
|
12095
12204
|
*
|
|
12096
|
-
* @return {
|
|
12205
|
+
* @return {*}
|
|
12097
12206
|
*/
|
|
12098
12207
|
function invokeFunction(fn, args) {
|
|
12099
12208
|
return fn.apply(null, args);
|
|
@@ -12107,11 +12216,11 @@
|
|
|
12107
12216
|
*/
|
|
12108
12217
|
|
|
12109
12218
|
/**
|
|
12110
|
-
* Returns the visual part of a diagram element
|
|
12219
|
+
* Returns the visual part of a diagram element.
|
|
12111
12220
|
*
|
|
12112
|
-
* @param {
|
|
12221
|
+
* @param {SVGElement} gfx
|
|
12113
12222
|
*
|
|
12114
|
-
* @return {
|
|
12223
|
+
* @return {SVGElement}
|
|
12115
12224
|
*/
|
|
12116
12225
|
function getVisual(gfx) {
|
|
12117
12226
|
return gfx.childNodes[0];
|
|
@@ -12120,15 +12229,28 @@
|
|
|
12120
12229
|
/**
|
|
12121
12230
|
* Returns the children for a given diagram element.
|
|
12122
12231
|
*
|
|
12123
|
-
* @param {
|
|
12124
|
-
* @return {
|
|
12232
|
+
* @param {SVGElement} gfx
|
|
12233
|
+
* @return {SVGElement}
|
|
12125
12234
|
*/
|
|
12126
12235
|
function getChildren(gfx) {
|
|
12127
12236
|
return gfx.parentNode.childNodes[1];
|
|
12128
12237
|
}
|
|
12129
12238
|
|
|
12130
12239
|
/**
|
|
12131
|
-
*
|
|
12240
|
+
* @typedef {import('../model').ModelType} ModelType
|
|
12241
|
+
* @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
|
|
12242
|
+
* @typedef {import('../model').ModelTypeShape} ModelTypeShape
|
|
12243
|
+
*
|
|
12244
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
12245
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
12246
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
12247
|
+
*
|
|
12248
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
12249
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
12250
|
+
*/
|
|
12251
|
+
|
|
12252
|
+
/**
|
|
12253
|
+
* A factory that creates graphical elements.
|
|
12132
12254
|
*
|
|
12133
12255
|
* @param {EventBus} eventBus
|
|
12134
12256
|
* @param {ElementRegistry} elementRegistry
|
|
@@ -12196,7 +12318,7 @@
|
|
|
12196
12318
|
* </g>
|
|
12197
12319
|
*
|
|
12198
12320
|
* @param {string} type the type of the element, i.e. shape | connection
|
|
12199
|
-
* @param {SVGElement}
|
|
12321
|
+
* @param {SVGElement} childrenGfx
|
|
12200
12322
|
* @param {number} [parentIndex] position to create container in parent
|
|
12201
12323
|
* @param {boolean} [isFrame] is frame element
|
|
12202
12324
|
*
|
|
@@ -12234,11 +12356,25 @@
|
|
|
12234
12356
|
return gfx;
|
|
12235
12357
|
};
|
|
12236
12358
|
|
|
12359
|
+
/**
|
|
12360
|
+
* Create a graphical element.
|
|
12361
|
+
*
|
|
12362
|
+
* @param {ModelType} type The type of the element.
|
|
12363
|
+
* @param {ElementLike} element The element.
|
|
12364
|
+
* @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
|
|
12365
|
+
*
|
|
12366
|
+
* @return {SVGElement} The graphical element.
|
|
12367
|
+
*/
|
|
12237
12368
|
GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
|
12238
12369
|
var childrenGfx = this._getChildrenContainer(element.parent);
|
|
12239
12370
|
return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
|
12240
12371
|
};
|
|
12241
12372
|
|
|
12373
|
+
/**
|
|
12374
|
+
* Update the containments of the given elements.
|
|
12375
|
+
*
|
|
12376
|
+
* @param {ElementLike[]} elements The elements.
|
|
12377
|
+
*/
|
|
12242
12378
|
GraphicsFactory.prototype.updateContainments = function(elements) {
|
|
12243
12379
|
|
|
12244
12380
|
var self = this,
|
|
@@ -12274,30 +12410,63 @@
|
|
|
12274
12410
|
});
|
|
12275
12411
|
};
|
|
12276
12412
|
|
|
12413
|
+
/**
|
|
12414
|
+
* Draw a shape.
|
|
12415
|
+
*
|
|
12416
|
+
* @param {SVGElement} visual The graphical element.
|
|
12417
|
+
* @param {ShapeLike} element The shape.
|
|
12418
|
+
*/
|
|
12277
12419
|
GraphicsFactory.prototype.drawShape = function(visual, element) {
|
|
12278
12420
|
var eventBus = this._eventBus;
|
|
12279
12421
|
|
|
12280
12422
|
return eventBus.fire('render.shape', { gfx: visual, element: element });
|
|
12281
12423
|
};
|
|
12282
12424
|
|
|
12425
|
+
/**
|
|
12426
|
+
* Get the path of a shape.
|
|
12427
|
+
*
|
|
12428
|
+
* @param {ShapeLike} element The shape.
|
|
12429
|
+
*
|
|
12430
|
+
* @return {string} The path of the shape.
|
|
12431
|
+
*/
|
|
12283
12432
|
GraphicsFactory.prototype.getShapePath = function(element) {
|
|
12284
12433
|
var eventBus = this._eventBus;
|
|
12285
12434
|
|
|
12286
12435
|
return eventBus.fire('render.getShapePath', element);
|
|
12287
12436
|
};
|
|
12288
12437
|
|
|
12438
|
+
/**
|
|
12439
|
+
* Draw a connection.
|
|
12440
|
+
*
|
|
12441
|
+
* @param {SVGElement} visual The graphical element.
|
|
12442
|
+
* @param {ConnectionLike} element The connection.
|
|
12443
|
+
*/
|
|
12289
12444
|
GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
|
12290
12445
|
var eventBus = this._eventBus;
|
|
12291
12446
|
|
|
12292
12447
|
return eventBus.fire('render.connection', { gfx: visual, element: element });
|
|
12293
12448
|
};
|
|
12294
12449
|
|
|
12295
|
-
|
|
12450
|
+
/**
|
|
12451
|
+
* Get the path of a connection.
|
|
12452
|
+
*
|
|
12453
|
+
* @param {ConnectionLike} element The connection.
|
|
12454
|
+
*
|
|
12455
|
+
* @return {string} The path of the connection.
|
|
12456
|
+
*/
|
|
12457
|
+
GraphicsFactory.prototype.getConnectionPath = function(connection) {
|
|
12296
12458
|
var eventBus = this._eventBus;
|
|
12297
12459
|
|
|
12298
|
-
return eventBus.fire('render.getConnectionPath',
|
|
12460
|
+
return eventBus.fire('render.getConnectionPath', connection);
|
|
12299
12461
|
};
|
|
12300
12462
|
|
|
12463
|
+
/**
|
|
12464
|
+
* Update an elements graphical representation.
|
|
12465
|
+
*
|
|
12466
|
+
* @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
|
|
12467
|
+
* @param {ElementLike} element The element.
|
|
12468
|
+
* @param {SVGElement} gfx The graphical representation.
|
|
12469
|
+
*/
|
|
12301
12470
|
GraphicsFactory.prototype.update = function(type, element, gfx) {
|
|
12302
12471
|
|
|
12303
12472
|
// do NOT update root element
|
|
@@ -12327,6 +12496,11 @@
|
|
|
12327
12496
|
}
|
|
12328
12497
|
};
|
|
12329
12498
|
|
|
12499
|
+
/**
|
|
12500
|
+
* Remove a graphical element.
|
|
12501
|
+
*
|
|
12502
|
+
* @param {ElementLike} element The element.
|
|
12503
|
+
*/
|
|
12330
12504
|
GraphicsFactory.prototype.remove = function(element) {
|
|
12331
12505
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12332
12506
|
|
|
@@ -12360,13 +12534,17 @@
|
|
|
12360
12534
|
};
|
|
12361
12535
|
|
|
12362
12536
|
/**
|
|
12363
|
-
* @typedef {
|
|
12537
|
+
* @typedef {import('didi').InjectionContext} InjectionContext
|
|
12538
|
+
* @typedef {import('didi').LocalsMap} LocalsMap
|
|
12539
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
12540
|
+
*
|
|
12541
|
+
* @typedef {import('./Diagram').DiagramOptions} DiagramOptions
|
|
12364
12542
|
*/
|
|
12365
12543
|
|
|
12366
12544
|
/**
|
|
12367
12545
|
* Bootstrap an injector from a list of modules, instantiating a number of default components
|
|
12368
12546
|
*
|
|
12369
|
-
* @param {
|
|
12547
|
+
* @param {ModuleDeclaration[]} modules
|
|
12370
12548
|
*
|
|
12371
12549
|
* @return {Injector} a injector to use to access the components
|
|
12372
12550
|
*/
|
|
@@ -12381,7 +12559,8 @@
|
|
|
12381
12559
|
/**
|
|
12382
12560
|
* Creates an injector from passed options.
|
|
12383
12561
|
*
|
|
12384
|
-
* @param {
|
|
12562
|
+
* @param {DiagramOptions} [options]
|
|
12563
|
+
*
|
|
12385
12564
|
* @return {Injector}
|
|
12386
12565
|
*/
|
|
12387
12566
|
function createInjector(options) {
|
|
@@ -12404,8 +12583,7 @@
|
|
|
12404
12583
|
*
|
|
12405
12584
|
* To register extensions with the diagram, pass them as Array<Module> to the constructor.
|
|
12406
12585
|
*
|
|
12407
|
-
* @class
|
|
12408
|
-
* @memberOf djs
|
|
12586
|
+
* @class
|
|
12409
12587
|
* @constructor
|
|
12410
12588
|
*
|
|
12411
12589
|
* @example
|
|
@@ -12443,9 +12621,9 @@
|
|
|
12443
12621
|
*
|
|
12444
12622
|
* // 'shape ... was added to the diagram' logged to console
|
|
12445
12623
|
*
|
|
12446
|
-
* @param {
|
|
12447
|
-
* @param {
|
|
12448
|
-
* @param {Injector} [injector]
|
|
12624
|
+
* @param {DiagramOptions} [options]
|
|
12625
|
+
* @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
|
|
12626
|
+
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
|
|
12449
12627
|
*/
|
|
12450
12628
|
function Diagram(options, injector) {
|
|
12451
12629
|
|
|
@@ -12455,22 +12633,23 @@
|
|
|
12455
12633
|
// API
|
|
12456
12634
|
|
|
12457
12635
|
/**
|
|
12458
|
-
* Resolves a diagram service
|
|
12636
|
+
* Resolves a diagram service.
|
|
12459
12637
|
*
|
|
12460
12638
|
* @method Diagram#get
|
|
12461
12639
|
*
|
|
12462
|
-
* @param {string} name
|
|
12463
|
-
* @param {boolean} [strict=true]
|
|
12640
|
+
* @param {string} name The name of the service to get.
|
|
12641
|
+
* @param {boolean} [strict=true] If false, resolve missing services to null.
|
|
12464
12642
|
*/
|
|
12465
12643
|
this.get = injector.get;
|
|
12466
12644
|
|
|
12467
12645
|
/**
|
|
12468
|
-
* Executes a function
|
|
12646
|
+
* Executes a function with its dependencies injected.
|
|
12469
12647
|
*
|
|
12470
12648
|
* @method Diagram#invoke
|
|
12471
12649
|
*
|
|
12472
|
-
* @param {Function
|
|
12473
|
-
* @param {
|
|
12650
|
+
* @param {Function} fn The function to be executed.
|
|
12651
|
+
* @param {InjectionContext} [context] The context.
|
|
12652
|
+
* @param {LocalsMap} [locals] The locals.
|
|
12474
12653
|
*/
|
|
12475
12654
|
this.invoke = injector.invoke;
|
|
12476
12655
|
|