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
|
*/
|
|
@@ -5366,8 +5389,6 @@
|
|
|
5366
5389
|
return element && !!element.labelTarget;
|
|
5367
5390
|
}
|
|
5368
5391
|
|
|
5369
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5370
|
-
|
|
5371
5392
|
function getDefaultExportFromCjs (x) {
|
|
5372
5393
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5373
5394
|
}
|
|
@@ -5384,9 +5405,9 @@
|
|
|
5384
5405
|
/**
|
|
5385
5406
|
* Convert the given bounds to a { top, left, bottom, right } descriptor.
|
|
5386
5407
|
*
|
|
5387
|
-
* @param {
|
|
5408
|
+
* @param {Point|Rect} bounds
|
|
5388
5409
|
*
|
|
5389
|
-
* @return {
|
|
5410
|
+
* @return {RectTRBL}
|
|
5390
5411
|
*/
|
|
5391
5412
|
function asTRBL(bounds) {
|
|
5392
5413
|
return {
|
|
@@ -5401,9 +5422,9 @@
|
|
|
5401
5422
|
/**
|
|
5402
5423
|
* Convert a { top, left, bottom, right } to an objects bounds.
|
|
5403
5424
|
*
|
|
5404
|
-
* @param {
|
|
5425
|
+
* @param {RectTRBL} trbl
|
|
5405
5426
|
*
|
|
5406
|
-
* @return {
|
|
5427
|
+
* @return {Rect}
|
|
5407
5428
|
*/
|
|
5408
5429
|
function asBounds(trbl) {
|
|
5409
5430
|
return {
|
|
@@ -5418,7 +5439,7 @@
|
|
|
5418
5439
|
/**
|
|
5419
5440
|
* Get the mid of the given bounds or point.
|
|
5420
5441
|
*
|
|
5421
|
-
* @param {
|
|
5442
|
+
* @param {Point|Rect} bounds
|
|
5422
5443
|
*
|
|
5423
5444
|
* @return {Point}
|
|
5424
5445
|
*/
|
|
@@ -5433,7 +5454,7 @@
|
|
|
5433
5454
|
/**
|
|
5434
5455
|
* Get the mid of the given Connection.
|
|
5435
5456
|
*
|
|
5436
|
-
* @param {
|
|
5457
|
+
* @param {Connection} connection
|
|
5437
5458
|
*
|
|
5438
5459
|
* @return {Point}
|
|
5439
5460
|
*/
|
|
@@ -5492,7 +5513,7 @@
|
|
|
5492
5513
|
/**
|
|
5493
5514
|
* Get the mid of the given Element.
|
|
5494
5515
|
*
|
|
5495
|
-
* @param {
|
|
5516
|
+
* @param {Connection} connection
|
|
5496
5517
|
*
|
|
5497
5518
|
* @return {Point}
|
|
5498
5519
|
*/
|
|
@@ -5902,6 +5923,14 @@
|
|
|
5902
5923
|
return isPrimaryButton(event) && originalEvent.shiftKey;
|
|
5903
5924
|
}
|
|
5904
5925
|
|
|
5926
|
+
/**
|
|
5927
|
+
* @typedef {import('../../model').Base} Base
|
|
5928
|
+
*
|
|
5929
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
5930
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
5931
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
5932
|
+
*/
|
|
5933
|
+
|
|
5905
5934
|
function allowAll(event) { return true; }
|
|
5906
5935
|
|
|
5907
5936
|
function allowPrimaryAndAuxiliary(event) {
|
|
@@ -5931,6 +5960,8 @@
|
|
|
5931
5960
|
* prevents the original DOM operation.
|
|
5932
5961
|
*
|
|
5933
5962
|
* @param {EventBus} eventBus
|
|
5963
|
+
* @param {ElementRegistry} elementRegistry
|
|
5964
|
+
* @param {Styles} styles
|
|
5934
5965
|
*/
|
|
5935
5966
|
function InteractionEvents(eventBus, elementRegistry, styles) {
|
|
5936
5967
|
|
|
@@ -5940,8 +5971,8 @@
|
|
|
5940
5971
|
* Fire an interaction event.
|
|
5941
5972
|
*
|
|
5942
5973
|
* @param {string} type local event name, e.g. element.click.
|
|
5943
|
-
* @param {
|
|
5944
|
-
* @param {
|
|
5974
|
+
* @param {MouseEvent|TouchEvent} event native event
|
|
5975
|
+
* @param {Base} [element] the diagram element to emit the event on;
|
|
5945
5976
|
* defaults to the event target
|
|
5946
5977
|
*/
|
|
5947
5978
|
function fire(type, event, element) {
|
|
@@ -6023,8 +6054,8 @@
|
|
|
6023
6054
|
* on the target shape or connection.
|
|
6024
6055
|
*
|
|
6025
6056
|
* @param {string} eventName the name of the triggered DOM event
|
|
6026
|
-
* @param {MouseEvent} event
|
|
6027
|
-
* @param {
|
|
6057
|
+
* @param {MouseEvent|TouchEvent} event
|
|
6058
|
+
* @param {Base} targetElement
|
|
6028
6059
|
*/
|
|
6029
6060
|
function triggerMouseEvent(eventName, event, targetElement) {
|
|
6030
6061
|
|
|
@@ -6190,7 +6221,7 @@
|
|
|
6190
6221
|
/**
|
|
6191
6222
|
* Create default hit for the given element.
|
|
6192
6223
|
*
|
|
6193
|
-
* @param {
|
|
6224
|
+
* @param {Base} element
|
|
6194
6225
|
* @param {SVGElement} gfx
|
|
6195
6226
|
*
|
|
6196
6227
|
* @return {SVGElement} created hit
|
|
@@ -6262,8 +6293,8 @@
|
|
|
6262
6293
|
/**
|
|
6263
6294
|
* Update default hit of the element.
|
|
6264
6295
|
*
|
|
6265
|
-
* @param
|
|
6266
|
-
* @param
|
|
6296
|
+
* @param {Base} element
|
|
6297
|
+
* @param {SVGElement} gfx
|
|
6267
6298
|
*
|
|
6268
6299
|
* @return {SVGElement} updated hit
|
|
6269
6300
|
*/
|
|
@@ -6311,7 +6342,7 @@
|
|
|
6311
6342
|
* @event element.hover
|
|
6312
6343
|
*
|
|
6313
6344
|
* @type {Object}
|
|
6314
|
-
* @property {
|
|
6345
|
+
* @property {Base} element
|
|
6315
6346
|
* @property {SVGElement} gfx
|
|
6316
6347
|
* @property {Event} originalEvent
|
|
6317
6348
|
*/
|
|
@@ -6322,7 +6353,7 @@
|
|
|
6322
6353
|
* @event element.out
|
|
6323
6354
|
*
|
|
6324
6355
|
* @type {Object}
|
|
6325
|
-
* @property {
|
|
6356
|
+
* @property {Base} element
|
|
6326
6357
|
* @property {SVGElement} gfx
|
|
6327
6358
|
* @property {Event} originalEvent
|
|
6328
6359
|
*/
|
|
@@ -6333,7 +6364,7 @@
|
|
|
6333
6364
|
* @event element.click
|
|
6334
6365
|
*
|
|
6335
6366
|
* @type {Object}
|
|
6336
|
-
* @property {
|
|
6367
|
+
* @property {Base} element
|
|
6337
6368
|
* @property {SVGElement} gfx
|
|
6338
6369
|
* @property {Event} originalEvent
|
|
6339
6370
|
*/
|
|
@@ -6344,7 +6375,7 @@
|
|
|
6344
6375
|
* @event element.dblclick
|
|
6345
6376
|
*
|
|
6346
6377
|
* @type {Object}
|
|
6347
|
-
* @property {
|
|
6378
|
+
* @property {Base} element
|
|
6348
6379
|
* @property {SVGElement} gfx
|
|
6349
6380
|
* @property {Event} originalEvent
|
|
6350
6381
|
*/
|
|
@@ -6355,7 +6386,7 @@
|
|
|
6355
6386
|
* @event element.mousedown
|
|
6356
6387
|
*
|
|
6357
6388
|
* @type {Object}
|
|
6358
|
-
* @property {
|
|
6389
|
+
* @property {Base} element
|
|
6359
6390
|
* @property {SVGElement} gfx
|
|
6360
6391
|
* @property {Event} originalEvent
|
|
6361
6392
|
*/
|
|
@@ -6366,7 +6397,7 @@
|
|
|
6366
6397
|
* @event element.mouseup
|
|
6367
6398
|
*
|
|
6368
6399
|
* @type {Object}
|
|
6369
|
-
* @property {
|
|
6400
|
+
* @property {Base} element
|
|
6370
6401
|
* @property {SVGElement} gfx
|
|
6371
6402
|
* @property {Event} originalEvent
|
|
6372
6403
|
*/
|
|
@@ -6378,7 +6409,7 @@
|
|
|
6378
6409
|
* @event element.contextmenu
|
|
6379
6410
|
*
|
|
6380
6411
|
* @type {Object}
|
|
6381
|
-
* @property {
|
|
6412
|
+
* @property {Base} element
|
|
6382
6413
|
* @property {SVGElement} gfx
|
|
6383
6414
|
* @property {Event} originalEvent
|
|
6384
6415
|
*/
|
|
@@ -6392,10 +6423,10 @@
|
|
|
6392
6423
|
* Returns the surrounding bbox for all elements in
|
|
6393
6424
|
* the array or the element primitive.
|
|
6394
6425
|
*
|
|
6395
|
-
* @param {
|
|
6426
|
+
* @param {Base|Base[]} elements
|
|
6396
6427
|
* @param {boolean} [stopRecursion=false]
|
|
6397
6428
|
*
|
|
6398
|
-
* @return {
|
|
6429
|
+
* @return {Rect}
|
|
6399
6430
|
*/
|
|
6400
6431
|
function getBBox(elements, stopRecursion) {
|
|
6401
6432
|
|
|
@@ -6466,6 +6497,12 @@
|
|
|
6466
6497
|
|
|
6467
6498
|
var LOW_PRIORITY$2 = 500;
|
|
6468
6499
|
|
|
6500
|
+
/**
|
|
6501
|
+
* @typedef {import('../../model').Base} Base
|
|
6502
|
+
*
|
|
6503
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6504
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
6505
|
+
*/
|
|
6469
6506
|
|
|
6470
6507
|
/**
|
|
6471
6508
|
* @class
|
|
@@ -6475,9 +6512,8 @@
|
|
|
6475
6512
|
*
|
|
6476
6513
|
* @param {EventBus} eventBus
|
|
6477
6514
|
* @param {Styles} styles
|
|
6478
|
-
* @param {ElementRegistry} elementRegistry
|
|
6479
6515
|
*/
|
|
6480
|
-
function Outline(eventBus, styles
|
|
6516
|
+
function Outline(eventBus, styles) {
|
|
6481
6517
|
|
|
6482
6518
|
this.offset = 6;
|
|
6483
6519
|
|
|
@@ -6535,8 +6571,8 @@
|
|
|
6535
6571
|
* Updates the outline of a shape respecting the dimension of the
|
|
6536
6572
|
* element and an outline offset.
|
|
6537
6573
|
*
|
|
6538
|
-
* @param
|
|
6539
|
-
* @param
|
|
6574
|
+
* @param {SVGElement} outline
|
|
6575
|
+
* @param {Base} element
|
|
6540
6576
|
*/
|
|
6541
6577
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6542
6578
|
|
|
@@ -6554,8 +6590,8 @@
|
|
|
6554
6590
|
* Updates the outline of a connection respecting the bounding box of
|
|
6555
6591
|
* the connection and an outline offset.
|
|
6556
6592
|
*
|
|
6557
|
-
* @param
|
|
6558
|
-
* @param
|
|
6593
|
+
* @param {SVGElement} outline
|
|
6594
|
+
* @param {Base} element
|
|
6559
6595
|
*/
|
|
6560
6596
|
Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
|
6561
6597
|
|
|
@@ -6578,13 +6614,17 @@
|
|
|
6578
6614
|
outline: [ 'type', Outline ]
|
|
6579
6615
|
};
|
|
6580
6616
|
|
|
6617
|
+
/**
|
|
6618
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6619
|
+
*/
|
|
6620
|
+
|
|
6581
6621
|
/**
|
|
6582
6622
|
* A service that offers the current selection in a diagram.
|
|
6583
6623
|
* Offers the api to control the selection, too.
|
|
6584
6624
|
*
|
|
6585
6625
|
* @class
|
|
6586
6626
|
*
|
|
6587
|
-
* @param {EventBus} eventBus
|
|
6627
|
+
* @param {EventBus} eventBus
|
|
6588
6628
|
*/
|
|
6589
6629
|
function Selection(eventBus, canvas) {
|
|
6590
6630
|
|
|
@@ -6640,8 +6680,8 @@
|
|
|
6640
6680
|
*
|
|
6641
6681
|
* @method Selection#select
|
|
6642
6682
|
*
|
|
6643
|
-
* @param
|
|
6644
|
-
* @param
|
|
6683
|
+
* @param {Object|Object[]} elements element or array of elements to be selected
|
|
6684
|
+
* @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
|
|
6645
6685
|
*/
|
|
6646
6686
|
Selection.prototype.select = function(elements, add) {
|
|
6647
6687
|
var selectedElements = this._selectedElements,
|
|
@@ -6680,6 +6720,12 @@
|
|
|
6680
6720
|
this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
|
6681
6721
|
};
|
|
6682
6722
|
|
|
6723
|
+
/**
|
|
6724
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6725
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6726
|
+
* @typedef {import('./Selection').default} Selection
|
|
6727
|
+
*/
|
|
6728
|
+
|
|
6683
6729
|
var MARKER_HOVER = 'hover',
|
|
6684
6730
|
MARKER_SELECTED = 'selected';
|
|
6685
6731
|
|
|
@@ -6696,6 +6742,7 @@
|
|
|
6696
6742
|
*
|
|
6697
6743
|
* @param {Canvas} canvas
|
|
6698
6744
|
* @param {EventBus} eventBus
|
|
6745
|
+
* @param {Selection} selection
|
|
6699
6746
|
*/
|
|
6700
6747
|
function SelectionVisuals(canvas, eventBus, selection) {
|
|
6701
6748
|
this._canvas = canvas;
|
|
@@ -6801,6 +6848,19 @@
|
|
|
6801
6848
|
};
|
|
6802
6849
|
}
|
|
6803
6850
|
|
|
6851
|
+
/**
|
|
6852
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6853
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
6854
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6855
|
+
* @typedef {import('./Selection').default} Selection
|
|
6856
|
+
*/
|
|
6857
|
+
|
|
6858
|
+
/**
|
|
6859
|
+
* @param {EventBus} eventBus
|
|
6860
|
+
* @param {Selection} selection
|
|
6861
|
+
* @param {Canvas} canvas
|
|
6862
|
+
* @param {ElementRegistry} elementRegistry
|
|
6863
|
+
*/
|
|
6804
6864
|
function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
|
6805
6865
|
|
|
6806
6866
|
// Select elements on create
|
|
@@ -6921,9 +6981,8 @@
|
|
|
6921
6981
|
/**
|
|
6922
6982
|
* Util that provides unique IDs.
|
|
6923
6983
|
*
|
|
6924
|
-
* @class
|
|
6984
|
+
* @class
|
|
6925
6985
|
* @constructor
|
|
6926
|
-
* @memberOf djs.util
|
|
6927
6986
|
*
|
|
6928
6987
|
* The ids can be customized via a given prefix and contain a random value to avoid collisions.
|
|
6929
6988
|
*
|
|
@@ -6938,8 +6997,6 @@
|
|
|
6938
6997
|
/**
|
|
6939
6998
|
* Returns a next unique ID.
|
|
6940
6999
|
*
|
|
6941
|
-
* @method djs.util.IdGenerator#next
|
|
6942
|
-
*
|
|
6943
7000
|
* @returns {string} the id
|
|
6944
7001
|
*/
|
|
6945
7002
|
IdGenerator.prototype.next = function() {
|
|
@@ -6951,6 +7008,18 @@
|
|
|
6951
7008
|
|
|
6952
7009
|
var LOW_PRIORITY$1 = 500;
|
|
6953
7010
|
|
|
7011
|
+
/**
|
|
7012
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7013
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7014
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7015
|
+
*
|
|
7016
|
+
* @typedef {import('./Overlays').Overlay} Overlay
|
|
7017
|
+
* @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
|
|
7018
|
+
* @typedef {import('./Overlays').OverlayContainer} OverlayContainer
|
|
7019
|
+
* @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
|
|
7020
|
+
* @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
|
|
7021
|
+
* @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
|
|
7022
|
+
*/
|
|
6954
7023
|
|
|
6955
7024
|
/**
|
|
6956
7025
|
* A service that allows users to attach overlays to diagram elements.
|
|
@@ -6960,6 +7029,7 @@
|
|
|
6960
7029
|
* @example
|
|
6961
7030
|
*
|
|
6962
7031
|
* // add a pink badge on the top left of the shape
|
|
7032
|
+
*
|
|
6963
7033
|
* overlays.add(someShape, {
|
|
6964
7034
|
* position: {
|
|
6965
7035
|
* top: -5,
|
|
@@ -7011,19 +7081,21 @@
|
|
|
7011
7081
|
* }
|
|
7012
7082
|
* }
|
|
7013
7083
|
*
|
|
7014
|
-
* @param {
|
|
7084
|
+
* @param {OverlaysConfig} config
|
|
7015
7085
|
* @param {EventBus} eventBus
|
|
7016
7086
|
* @param {Canvas} canvas
|
|
7017
7087
|
* @param {ElementRegistry} elementRegistry
|
|
7018
7088
|
*/
|
|
7019
7089
|
function Overlays(config, eventBus, canvas, elementRegistry) {
|
|
7020
|
-
|
|
7021
7090
|
this._eventBus = eventBus;
|
|
7022
7091
|
this._canvas = canvas;
|
|
7023
7092
|
this._elementRegistry = elementRegistry;
|
|
7024
7093
|
|
|
7025
7094
|
this._ids = ids;
|
|
7026
7095
|
|
|
7096
|
+
/**
|
|
7097
|
+
* @type {OverlaysConfigDefault}
|
|
7098
|
+
*/
|
|
7027
7099
|
this._overlayDefaults = assign$1({
|
|
7028
7100
|
|
|
7029
7101
|
// no show constraints
|
|
@@ -7034,16 +7106,18 @@
|
|
|
7034
7106
|
}, config && config.defaults);
|
|
7035
7107
|
|
|
7036
7108
|
/**
|
|
7037
|
-
*
|
|
7109
|
+
* @type {Map<string, Overlay>}
|
|
7038
7110
|
*/
|
|
7039
7111
|
this._overlays = {};
|
|
7040
7112
|
|
|
7041
7113
|
/**
|
|
7042
|
-
*
|
|
7114
|
+
* @type {OverlayContainer[]}
|
|
7043
7115
|
*/
|
|
7044
7116
|
this._overlayContainers = [];
|
|
7045
7117
|
|
|
7046
|
-
|
|
7118
|
+
/**
|
|
7119
|
+
* @type {HTMLElement}
|
|
7120
|
+
*/
|
|
7047
7121
|
this._overlayRoot = createRoot(canvas.getContainer());
|
|
7048
7122
|
|
|
7049
7123
|
this._init();
|
|
@@ -7059,12 +7133,12 @@
|
|
|
7059
7133
|
|
|
7060
7134
|
|
|
7061
7135
|
/**
|
|
7062
|
-
* Returns the overlay with the specified
|
|
7136
|
+
* Returns the overlay with the specified ID or a list of overlays
|
|
7063
7137
|
* for an element with a given type.
|
|
7064
7138
|
*
|
|
7065
7139
|
* @example
|
|
7066
7140
|
*
|
|
7067
|
-
* // return the single overlay with the given
|
|
7141
|
+
* // return the single overlay with the given ID
|
|
7068
7142
|
* overlays.get('some-id');
|
|
7069
7143
|
*
|
|
7070
7144
|
* // return all overlays for the shape
|
|
@@ -7073,16 +7147,12 @@
|
|
|
7073
7147
|
* // return all overlays on shape with type 'badge'
|
|
7074
7148
|
* overlays.get({ element: someShape, type: 'badge' });
|
|
7075
7149
|
*
|
|
7076
|
-
* // shape can also be specified as
|
|
7150
|
+
* // shape can also be specified as ID
|
|
7077
7151
|
* overlays.get({ element: 'element-id', type: 'badge' });
|
|
7078
7152
|
*
|
|
7153
|
+
* @param {OverlaysFilter} search The filter to be used to find the overlay(s).
|
|
7079
7154
|
*
|
|
7080
|
-
* @
|
|
7081
|
-
* @param {string} [search.id]
|
|
7082
|
-
* @param {string|djs.model.Base} [search.element]
|
|
7083
|
-
* @param {string} [search.type]
|
|
7084
|
-
*
|
|
7085
|
-
* @return {Object|Array<Object>} the overlay(s)
|
|
7155
|
+
* @return {Overlay|Overlay[]} The overlay(s).
|
|
7086
7156
|
*/
|
|
7087
7157
|
Overlays.prototype.get = function(search) {
|
|
7088
7158
|
|
|
@@ -7114,27 +7184,13 @@
|
|
|
7114
7184
|
};
|
|
7115
7185
|
|
|
7116
7186
|
/**
|
|
7117
|
-
* Adds
|
|
7118
|
-
*
|
|
7119
|
-
* @param {string|djs.model.Base} element attach overlay to this shape
|
|
7120
|
-
* @param {string} [type] optional type to assign to the overlay
|
|
7121
|
-
* @param {Object} overlay the overlay configuration
|
|
7187
|
+
* Adds an HTML overlay to an element.
|
|
7122
7188
|
*
|
|
7123
|
-
* @param {string
|
|
7124
|
-
* @param {
|
|
7125
|
-
* @param {
|
|
7126
|
-
* @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
|
|
7127
|
-
* @param {Object} overlay.position where to attach the overlay
|
|
7128
|
-
* @param {number} [overlay.position.left] relative to element bbox left attachment
|
|
7129
|
-
* @param {number} [overlay.position.top] relative to element bbox top attachment
|
|
7130
|
-
* @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
|
|
7131
|
-
* @param {number} [overlay.position.right] relative to element bbox right attachment
|
|
7132
|
-
* @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
|
|
7133
|
-
* diagram zoom
|
|
7134
|
-
* @param {number} [overlay.scale.min]
|
|
7135
|
-
* @param {number} [overlay.scale.max]
|
|
7189
|
+
* @param {Base|string} element The element to add the overlay to.
|
|
7190
|
+
* @param {string} [type] An optional type that can be used to filter.
|
|
7191
|
+
* @param {OverlayAttrs} overlay The overlay.
|
|
7136
7192
|
*
|
|
7137
|
-
* @return {string}
|
|
7193
|
+
* @return {string} The overlay's ID that can be used to get or remove it.
|
|
7138
7194
|
*/
|
|
7139
7195
|
Overlays.prototype.add = function(element, type, overlay) {
|
|
7140
7196
|
|
|
@@ -7175,11 +7231,11 @@
|
|
|
7175
7231
|
|
|
7176
7232
|
|
|
7177
7233
|
/**
|
|
7178
|
-
* Remove an overlay with the given
|
|
7234
|
+
* Remove an overlay with the given ID or all overlays matching the given filter.
|
|
7179
7235
|
*
|
|
7180
7236
|
* @see Overlays#get for filter options.
|
|
7181
7237
|
*
|
|
7182
|
-
* @param {
|
|
7238
|
+
* @param {OverlaysFilter} filter The filter to be used to find the overlay.
|
|
7183
7239
|
*/
|
|
7184
7240
|
Overlays.prototype.remove = function(filter) {
|
|
7185
7241
|
|
|
@@ -7215,19 +7271,32 @@
|
|
|
7215
7271
|
|
|
7216
7272
|
};
|
|
7217
7273
|
|
|
7274
|
+
/**
|
|
7275
|
+
* Checks whether overlays are shown.
|
|
7276
|
+
*
|
|
7277
|
+
* @returns {boolean} Whether overlays are shown.
|
|
7278
|
+
*/
|
|
7218
7279
|
Overlays.prototype.isShown = function() {
|
|
7219
7280
|
return this._overlayRoot.style.display !== 'none';
|
|
7220
7281
|
};
|
|
7221
7282
|
|
|
7283
|
+
/**
|
|
7284
|
+
* Show all overlays.
|
|
7285
|
+
*/
|
|
7222
7286
|
Overlays.prototype.show = function() {
|
|
7223
7287
|
setVisible(this._overlayRoot);
|
|
7224
7288
|
};
|
|
7225
7289
|
|
|
7226
|
-
|
|
7290
|
+
/**
|
|
7291
|
+
* Hide all overlays.
|
|
7292
|
+
*/
|
|
7227
7293
|
Overlays.prototype.hide = function() {
|
|
7228
7294
|
setVisible(this._overlayRoot, false);
|
|
7229
7295
|
};
|
|
7230
7296
|
|
|
7297
|
+
/**
|
|
7298
|
+
* Remove all overlays and their container.
|
|
7299
|
+
*/
|
|
7231
7300
|
Overlays.prototype.clear = function() {
|
|
7232
7301
|
this._overlays = {};
|
|
7233
7302
|
|
|
@@ -7603,6 +7672,13 @@
|
|
|
7603
7672
|
overlays: [ 'type', Overlays ]
|
|
7604
7673
|
};
|
|
7605
7674
|
|
|
7675
|
+
/**
|
|
7676
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7677
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7678
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7679
|
+
* @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
|
|
7680
|
+
*/
|
|
7681
|
+
|
|
7606
7682
|
/**
|
|
7607
7683
|
* Adds change support to the diagram, including
|
|
7608
7684
|
*
|
|
@@ -7672,32 +7748,41 @@
|
|
|
7672
7748
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7673
7749
|
};
|
|
7674
7750
|
|
|
7751
|
+
/**
|
|
7752
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
7753
|
+
* @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
|
|
7754
|
+
* @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
|
|
7755
|
+
*/
|
|
7756
|
+
|
|
7675
7757
|
var DEFAULT_PRIORITY$1 = 1000;
|
|
7676
7758
|
|
|
7677
7759
|
/**
|
|
7678
|
-
* A utility that can be used to plug
|
|
7760
|
+
* A utility that can be used to plug into the command execution for
|
|
7679
7761
|
* extension and/or validation.
|
|
7680
7762
|
*
|
|
7763
|
+
* @class
|
|
7764
|
+
* @constructor
|
|
7765
|
+
*
|
|
7681
7766
|
* @param {EventBus} eventBus
|
|
7682
7767
|
*
|
|
7683
7768
|
* @example
|
|
7684
7769
|
*
|
|
7685
|
-
* import inherits from 'inherits-browser';
|
|
7686
|
-
*
|
|
7687
7770
|
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7688
7771
|
*
|
|
7689
|
-
*
|
|
7690
|
-
*
|
|
7772
|
+
* class CommandLogger extends CommandInterceptor {
|
|
7773
|
+
* constructor(eventBus) {
|
|
7774
|
+
* super(eventBus);
|
|
7691
7775
|
*
|
|
7692
|
-
* this.preExecute(
|
|
7693
|
-
* console.log('
|
|
7776
|
+
* this.preExecute('shape.create', (event) => {
|
|
7777
|
+
* console.log('commandStack.shape-create.preExecute', event);
|
|
7694
7778
|
* });
|
|
7695
7779
|
* }
|
|
7696
|
-
*
|
|
7697
|
-
* inherits(CommandLogger, CommandInterceptor);
|
|
7698
|
-
*
|
|
7699
7780
|
*/
|
|
7700
7781
|
function CommandInterceptor(eventBus) {
|
|
7782
|
+
|
|
7783
|
+
/**
|
|
7784
|
+
* @type {EventBus}
|
|
7785
|
+
*/
|
|
7701
7786
|
this._eventBus = eventBus;
|
|
7702
7787
|
}
|
|
7703
7788
|
|
|
@@ -7710,16 +7795,15 @@
|
|
|
7710
7795
|
}
|
|
7711
7796
|
|
|
7712
7797
|
/**
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
*/
|
|
7798
|
+
* Intercept a command during one of the phases.
|
|
7799
|
+
*
|
|
7800
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7801
|
+
* @param {string} [hook] Phase during which to intercept command.
|
|
7802
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7803
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7804
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7805
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7806
|
+
*/
|
|
7723
7807
|
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7724
7808
|
|
|
7725
7809
|
if (isFunction(hook) || isNumber(hook)) {
|
|
@@ -7775,24 +7859,19 @@
|
|
|
7775
7859
|
];
|
|
7776
7860
|
|
|
7777
7861
|
/*
|
|
7778
|
-
*
|
|
7779
|
-
*
|
|
7780
|
-
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7781
|
-
* which will in term forward to CommandInterceptor#on.
|
|
7862
|
+
* Add prototype methods for each phase of command execution (e.g. execute,
|
|
7863
|
+
* revert).
|
|
7782
7864
|
*/
|
|
7783
7865
|
forEach$1(hooks, function(hook) {
|
|
7784
7866
|
|
|
7785
7867
|
/**
|
|
7786
|
-
*
|
|
7868
|
+
* Add prototype method for a specific phase of command execution.
|
|
7787
7869
|
*
|
|
7788
|
-
*
|
|
7789
|
-
*
|
|
7790
|
-
* @param {
|
|
7791
|
-
* @param {
|
|
7792
|
-
* @param {
|
|
7793
|
-
* @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
|
|
7794
|
-
* listener instead
|
|
7795
|
-
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7870
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7871
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7872
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7873
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7874
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7796
7875
|
*/
|
|
7797
7876
|
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7798
7877
|
|
|
@@ -7808,12 +7887,18 @@
|
|
|
7808
7887
|
};
|
|
7809
7888
|
});
|
|
7810
7889
|
|
|
7890
|
+
/**
|
|
7891
|
+
* @typedef {import('didi').Injector} Injector
|
|
7892
|
+
*
|
|
7893
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7894
|
+
*/
|
|
7895
|
+
|
|
7811
7896
|
/**
|
|
7812
7897
|
* A modeling behavior that ensures we set the correct root element
|
|
7813
7898
|
* as we undo and redo commands.
|
|
7814
7899
|
*
|
|
7815
7900
|
* @param {Canvas} canvas
|
|
7816
|
-
* @param {
|
|
7901
|
+
* @param {Injector} injector
|
|
7817
7902
|
*/
|
|
7818
7903
|
function RootElementsBehavior(canvas, injector) {
|
|
7819
7904
|
|
|
@@ -7847,111 +7932,10 @@
|
|
|
7847
7932
|
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7848
7933
|
};
|
|
7849
7934
|
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
(function (module, exports) {
|
|
7855
|
-
(function(root, factory) {
|
|
7856
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7857
|
-
{
|
|
7858
|
-
// For Node.js.
|
|
7859
|
-
module.exports = factory(root);
|
|
7860
|
-
}
|
|
7861
|
-
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
|
|
7862
|
-
|
|
7863
|
-
if (root.CSS && root.CSS.escape) {
|
|
7864
|
-
return root.CSS.escape;
|
|
7865
|
-
}
|
|
7866
|
-
|
|
7867
|
-
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7868
|
-
var cssEscape = function(value) {
|
|
7869
|
-
if (arguments.length == 0) {
|
|
7870
|
-
throw new TypeError('`CSS.escape` requires an argument.');
|
|
7871
|
-
}
|
|
7872
|
-
var string = String(value);
|
|
7873
|
-
var length = string.length;
|
|
7874
|
-
var index = -1;
|
|
7875
|
-
var codeUnit;
|
|
7876
|
-
var result = '';
|
|
7877
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
7878
|
-
while (++index < length) {
|
|
7879
|
-
codeUnit = string.charCodeAt(index);
|
|
7880
|
-
// Note: there’s no need to special-case astral symbols, surrogate
|
|
7881
|
-
// pairs, or lone surrogates.
|
|
7882
|
-
|
|
7883
|
-
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
7884
|
-
// (U+FFFD).
|
|
7885
|
-
if (codeUnit == 0x0000) {
|
|
7886
|
-
result += '\uFFFD';
|
|
7887
|
-
continue;
|
|
7888
|
-
}
|
|
7889
|
-
|
|
7890
|
-
if (
|
|
7891
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
7892
|
-
// U+007F, […]
|
|
7893
|
-
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
|
7894
|
-
// If the character is the first character and is in the range [0-9]
|
|
7895
|
-
// (U+0030 to U+0039), […]
|
|
7896
|
-
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
|
7897
|
-
// If the character is the second character and is in the range [0-9]
|
|
7898
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
7899
|
-
(
|
|
7900
|
-
index == 1 &&
|
|
7901
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
|
7902
|
-
firstCodeUnit == 0x002D
|
|
7903
|
-
)
|
|
7904
|
-
) {
|
|
7905
|
-
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
7906
|
-
result += '\\' + codeUnit.toString(16) + ' ';
|
|
7907
|
-
continue;
|
|
7908
|
-
}
|
|
7909
|
-
|
|
7910
|
-
if (
|
|
7911
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
7912
|
-
// there is no second character, […]
|
|
7913
|
-
index == 0 &&
|
|
7914
|
-
length == 1 &&
|
|
7915
|
-
codeUnit == 0x002D
|
|
7916
|
-
) {
|
|
7917
|
-
result += '\\' + string.charAt(index);
|
|
7918
|
-
continue;
|
|
7919
|
-
}
|
|
7920
|
-
|
|
7921
|
-
// If the character is not handled by one of the above rules and is
|
|
7922
|
-
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
7923
|
-
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
7924
|
-
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
7925
|
-
if (
|
|
7926
|
-
codeUnit >= 0x0080 ||
|
|
7927
|
-
codeUnit == 0x002D ||
|
|
7928
|
-
codeUnit == 0x005F ||
|
|
7929
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
|
7930
|
-
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
|
7931
|
-
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
|
7932
|
-
) {
|
|
7933
|
-
// the character itself
|
|
7934
|
-
result += string.charAt(index);
|
|
7935
|
-
continue;
|
|
7936
|
-
}
|
|
7937
|
-
|
|
7938
|
-
// Otherwise, the escaped character.
|
|
7939
|
-
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
7940
|
-
result += '\\' + string.charAt(index);
|
|
7941
|
-
|
|
7942
|
-
}
|
|
7943
|
-
return result;
|
|
7944
|
-
};
|
|
7945
|
-
|
|
7946
|
-
if (!root.CSS) {
|
|
7947
|
-
root.CSS = {};
|
|
7948
|
-
}
|
|
7949
|
-
|
|
7950
|
-
root.CSS.escape = cssEscape;
|
|
7951
|
-
return cssEscape;
|
|
7952
|
-
|
|
7953
|
-
}));
|
|
7954
|
-
} (css_escape));
|
|
7935
|
+
/**
|
|
7936
|
+
* @param {string} str
|
|
7937
|
+
* @returns {string}
|
|
7938
|
+
*/
|
|
7955
7939
|
|
|
7956
7940
|
var HTML_ESCAPE_MAP = {
|
|
7957
7941
|
'&': '&',
|
|
@@ -9086,6 +9070,11 @@
|
|
|
9086
9070
|
return value;
|
|
9087
9071
|
}
|
|
9088
9072
|
|
|
9073
|
+
/**
|
|
9074
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
9075
|
+
* @typedef {import('./Styles').default} Styles
|
|
9076
|
+
*/
|
|
9077
|
+
|
|
9089
9078
|
// apply default renderer with lowest possible priority
|
|
9090
9079
|
// so that it only kicks in if noone else could render
|
|
9091
9080
|
var DEFAULT_RENDER_PRIORITY = 1;
|
|
@@ -9203,9 +9192,9 @@
|
|
|
9203
9192
|
/**
|
|
9204
9193
|
* Builds a style definition from a className, a list of traits and an object of additional attributes.
|
|
9205
9194
|
*
|
|
9206
|
-
* @param
|
|
9207
|
-
* @param
|
|
9208
|
-
* @param
|
|
9195
|
+
* @param {string} className
|
|
9196
|
+
* @param {Array<string>} traits
|
|
9197
|
+
* @param {Object} additionalAttrs
|
|
9209
9198
|
*
|
|
9210
9199
|
* @return {Object} the style defintion
|
|
9211
9200
|
*/
|
|
@@ -9218,8 +9207,8 @@
|
|
|
9218
9207
|
/**
|
|
9219
9208
|
* Builds a style definition from a list of traits and an object of additional attributes.
|
|
9220
9209
|
*
|
|
9221
|
-
* @param
|
|
9222
|
-
* @param
|
|
9210
|
+
* @param {Array<string>} traits
|
|
9211
|
+
* @param {Object} additionalAttrs
|
|
9223
9212
|
*
|
|
9224
9213
|
* @return {Object} the style defintion
|
|
9225
9214
|
*/
|
|
@@ -9256,8 +9245,8 @@
|
|
|
9256
9245
|
/**
|
|
9257
9246
|
* Failsafe remove an element from a collection
|
|
9258
9247
|
*
|
|
9259
|
-
* @param
|
|
9260
|
-
* @param
|
|
9248
|
+
* @param {Array<Object>} [collection]
|
|
9249
|
+
* @param {Object} [element]
|
|
9261
9250
|
*
|
|
9262
9251
|
* @return {number} the previous index of the element
|
|
9263
9252
|
*/
|
|
@@ -9327,6 +9316,27 @@
|
|
|
9327
9316
|
}
|
|
9328
9317
|
}
|
|
9329
9318
|
|
|
9319
|
+
/**
|
|
9320
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
9321
|
+
* @typedef {import('.').RootLike} RootLike
|
|
9322
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
9323
|
+
*
|
|
9324
|
+
* @typedef {import('./Canvas').CanvasConfig} CanvasConfig
|
|
9325
|
+
* @typedef {import('./Canvas').CanvasLayer} CanvasLayer
|
|
9326
|
+
* @typedef {import('./Canvas').CanvasLayers} CanvasLayers
|
|
9327
|
+
* @typedef {import('./Canvas').CanvasPlane} CanvasPlane
|
|
9328
|
+
* @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
|
|
9329
|
+
*
|
|
9330
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
9331
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
9332
|
+
* @typedef {import('./GraphicsFactory').default} GraphicsFactory
|
|
9333
|
+
*
|
|
9334
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
9335
|
+
* @typedef {import('../util/Types').Point} Point
|
|
9336
|
+
* @typedef {import('../util/Types').Rect} Rect
|
|
9337
|
+
* @typedef {import('../util/Types').RectTRBL} RectTRBL
|
|
9338
|
+
*/
|
|
9339
|
+
|
|
9330
9340
|
function round(number, resolution) {
|
|
9331
9341
|
return Math.round(number * resolution) / resolution;
|
|
9332
9342
|
}
|
|
@@ -9347,7 +9357,8 @@
|
|
|
9347
9357
|
* Creates a HTML container element for a SVG element with
|
|
9348
9358
|
* the given configuration
|
|
9349
9359
|
*
|
|
9350
|
-
* @param
|
|
9360
|
+
* @param {CanvasConfig} options
|
|
9361
|
+
*
|
|
9351
9362
|
* @return {HTMLElement} the container element
|
|
9352
9363
|
*/
|
|
9353
9364
|
function createContainer(options) {
|
|
@@ -9407,21 +9418,34 @@
|
|
|
9407
9418
|
*
|
|
9408
9419
|
* @emits Canvas#canvas.init
|
|
9409
9420
|
*
|
|
9410
|
-
* @param {
|
|
9421
|
+
* @param {CanvasConfig|null} config
|
|
9411
9422
|
* @param {EventBus} eventBus
|
|
9412
9423
|
* @param {GraphicsFactory} graphicsFactory
|
|
9413
9424
|
* @param {ElementRegistry} elementRegistry
|
|
9414
9425
|
*/
|
|
9415
9426
|
function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
|
9416
|
-
|
|
9417
9427
|
this._eventBus = eventBus;
|
|
9418
9428
|
this._elementRegistry = elementRegistry;
|
|
9419
9429
|
this._graphicsFactory = graphicsFactory;
|
|
9420
9430
|
|
|
9431
|
+
/**
|
|
9432
|
+
* @type {number}
|
|
9433
|
+
*/
|
|
9421
9434
|
this._rootsIdx = 0;
|
|
9422
9435
|
|
|
9436
|
+
/**
|
|
9437
|
+
* @type {CanvasLayers}
|
|
9438
|
+
*/
|
|
9423
9439
|
this._layers = {};
|
|
9440
|
+
|
|
9441
|
+
/**
|
|
9442
|
+
* @type {CanvasPlane[]}
|
|
9443
|
+
*/
|
|
9424
9444
|
this._planes = [];
|
|
9445
|
+
|
|
9446
|
+
/**
|
|
9447
|
+
* @type {RootLike|null}
|
|
9448
|
+
*/
|
|
9425
9449
|
this._rootElement = null;
|
|
9426
9450
|
|
|
9427
9451
|
this._init(config || {});
|
|
@@ -9446,6 +9470,8 @@
|
|
|
9446
9470
|
* ...
|
|
9447
9471
|
* </svg>
|
|
9448
9472
|
* </div>
|
|
9473
|
+
*
|
|
9474
|
+
* @param {CanvasConfig} config
|
|
9449
9475
|
*/
|
|
9450
9476
|
Canvas.prototype._init = function(config) {
|
|
9451
9477
|
|
|
@@ -9467,7 +9493,7 @@
|
|
|
9467
9493
|
this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
|
|
9468
9494
|
}
|
|
9469
9495
|
|
|
9470
|
-
eventBus.on('diagram.init',
|
|
9496
|
+
eventBus.on('diagram.init', () => {
|
|
9471
9497
|
|
|
9472
9498
|
/**
|
|
9473
9499
|
* An event indicating that the canvas is ready to be drawn on.
|
|
@@ -9485,7 +9511,7 @@
|
|
|
9485
9511
|
viewport: viewport
|
|
9486
9512
|
});
|
|
9487
9513
|
|
|
9488
|
-
}
|
|
9514
|
+
});
|
|
9489
9515
|
|
|
9490
9516
|
// reset viewbox on shape changes to
|
|
9491
9517
|
// recompute the viewbox
|
|
@@ -9496,15 +9522,15 @@
|
|
|
9496
9522
|
'connection.removed',
|
|
9497
9523
|
'elements.changed',
|
|
9498
9524
|
'root.set'
|
|
9499
|
-
],
|
|
9525
|
+
], () => {
|
|
9500
9526
|
delete this._cachedViewbox;
|
|
9501
|
-
}
|
|
9527
|
+
});
|
|
9502
9528
|
|
|
9503
9529
|
eventBus.on('diagram.destroy', 500, this._destroy, this);
|
|
9504
9530
|
eventBus.on('diagram.clear', 500, this._clear, this);
|
|
9505
9531
|
};
|
|
9506
9532
|
|
|
9507
|
-
Canvas.prototype._destroy = function(
|
|
9533
|
+
Canvas.prototype._destroy = function() {
|
|
9508
9534
|
this._eventBus.fire('canvas.destroy', {
|
|
9509
9535
|
svg: this._svg,
|
|
9510
9536
|
viewport: this._viewport
|
|
@@ -9551,7 +9577,7 @@
|
|
|
9551
9577
|
* Returns the default layer on which
|
|
9552
9578
|
* all elements are drawn.
|
|
9553
9579
|
*
|
|
9554
|
-
* @
|
|
9580
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9555
9581
|
*/
|
|
9556
9582
|
Canvas.prototype.getDefaultLayer = function() {
|
|
9557
9583
|
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
@@ -9567,10 +9593,10 @@
|
|
|
9567
9593
|
* A layer with a certain index is always created above all
|
|
9568
9594
|
* existing layers with the same index.
|
|
9569
9595
|
*
|
|
9570
|
-
* @param {string} name
|
|
9571
|
-
* @param {number} index
|
|
9596
|
+
* @param {string} name The name of the layer.
|
|
9597
|
+
* @param {number} [index] The index of the layer.
|
|
9572
9598
|
*
|
|
9573
|
-
* @
|
|
9599
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9574
9600
|
*/
|
|
9575
9601
|
Canvas.prototype.getLayer = function(name, index) {
|
|
9576
9602
|
|
|
@@ -9599,8 +9625,9 @@
|
|
|
9599
9625
|
*
|
|
9600
9626
|
* This is used to determine the node a layer should be inserted at.
|
|
9601
9627
|
*
|
|
9602
|
-
* @param {
|
|
9603
|
-
*
|
|
9628
|
+
* @param {number} index
|
|
9629
|
+
*
|
|
9630
|
+
* @return {number}
|
|
9604
9631
|
*/
|
|
9605
9632
|
Canvas.prototype._getChildIndex = function(index) {
|
|
9606
9633
|
return reduce(this._layers, function(childIndex, layer) {
|
|
@@ -9618,7 +9645,7 @@
|
|
|
9618
9645
|
* @param {string} name
|
|
9619
9646
|
* @param {number} [index=0]
|
|
9620
9647
|
*
|
|
9621
|
-
* @return {
|
|
9648
|
+
* @return {CanvasLayer}
|
|
9622
9649
|
*/
|
|
9623
9650
|
Canvas.prototype._createLayer = function(name, index) {
|
|
9624
9651
|
|
|
@@ -9639,8 +9666,9 @@
|
|
|
9639
9666
|
/**
|
|
9640
9667
|
* Shows a given layer.
|
|
9641
9668
|
*
|
|
9642
|
-
* @param {
|
|
9643
|
-
*
|
|
9669
|
+
* @param {string} layer The name of the layer.
|
|
9670
|
+
*
|
|
9671
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9644
9672
|
*/
|
|
9645
9673
|
Canvas.prototype.showLayer = function(name) {
|
|
9646
9674
|
|
|
@@ -9674,8 +9702,9 @@
|
|
|
9674
9702
|
/**
|
|
9675
9703
|
* Hides a given layer.
|
|
9676
9704
|
*
|
|
9677
|
-
* @param {
|
|
9678
|
-
*
|
|
9705
|
+
* @param {string} layer The name of the layer.
|
|
9706
|
+
*
|
|
9707
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9679
9708
|
*/
|
|
9680
9709
|
Canvas.prototype.hideLayer = function(name) {
|
|
9681
9710
|
|
|
@@ -9717,7 +9746,7 @@
|
|
|
9717
9746
|
/**
|
|
9718
9747
|
* Returns the currently active layer. Can be null.
|
|
9719
9748
|
*
|
|
9720
|
-
* @
|
|
9749
|
+
* @return {CanvasLayer|null} The active layer of `null`.
|
|
9721
9750
|
*/
|
|
9722
9751
|
Canvas.prototype.getActiveLayer = function() {
|
|
9723
9752
|
const plane = this._findPlaneForRoot(this.getRootElement());
|
|
@@ -9733,9 +9762,9 @@
|
|
|
9733
9762
|
/**
|
|
9734
9763
|
* Returns the plane which contains the given element.
|
|
9735
9764
|
*
|
|
9736
|
-
* @param {string
|
|
9765
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9737
9766
|
*
|
|
9738
|
-
* @return {
|
|
9767
|
+
* @return {RootLike|undefined} The root of the element.
|
|
9739
9768
|
*/
|
|
9740
9769
|
Canvas.prototype.findRoot = function(element) {
|
|
9741
9770
|
if (typeof element === 'string') {
|
|
@@ -9756,7 +9785,7 @@
|
|
|
9756
9785
|
/**
|
|
9757
9786
|
* Return a list of all root elements on the diagram.
|
|
9758
9787
|
*
|
|
9759
|
-
* @return {
|
|
9788
|
+
* @return {(RootLike)[]} The list of root elements.
|
|
9760
9789
|
*/
|
|
9761
9790
|
Canvas.prototype.getRootElements = function() {
|
|
9762
9791
|
return this._planes.map(function(plane) {
|
|
@@ -9775,7 +9804,7 @@
|
|
|
9775
9804
|
* Returns the html element that encloses the
|
|
9776
9805
|
* drawing canvas.
|
|
9777
9806
|
*
|
|
9778
|
-
* @return {
|
|
9807
|
+
* @return {HTMLElement} The HTML element of the container.
|
|
9779
9808
|
*/
|
|
9780
9809
|
Canvas.prototype.getContainer = function() {
|
|
9781
9810
|
return this._container;
|
|
@@ -9815,8 +9844,8 @@
|
|
|
9815
9844
|
*
|
|
9816
9845
|
* @event element.marker.update
|
|
9817
9846
|
* @type {Object}
|
|
9818
|
-
* @property {
|
|
9819
|
-
* @property {
|
|
9847
|
+
* @property {Base} element the shape
|
|
9848
|
+
* @property {SVGElement} gfx the graphical representation of the shape
|
|
9820
9849
|
* @property {string} marker
|
|
9821
9850
|
* @property {boolean} add true if the marker was added, false if it got removed
|
|
9822
9851
|
*/
|
|
@@ -9831,14 +9860,15 @@
|
|
|
9831
9860
|
* integrate extension into the marker life-cycle, too.
|
|
9832
9861
|
*
|
|
9833
9862
|
* @example
|
|
9863
|
+
*
|
|
9834
9864
|
* canvas.addMarker('foo', 'some-marker');
|
|
9835
9865
|
*
|
|
9836
9866
|
* const fooGfx = canvas.getGraphics('foo');
|
|
9837
9867
|
*
|
|
9838
9868
|
* fooGfx; // <g class="... some-marker"> ... </g>
|
|
9839
9869
|
*
|
|
9840
|
-
* @param {string
|
|
9841
|
-
* @param {string} marker
|
|
9870
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9871
|
+
* @param {string} marker The marker.
|
|
9842
9872
|
*/
|
|
9843
9873
|
Canvas.prototype.addMarker = function(element, marker) {
|
|
9844
9874
|
this._updateMarker(element, marker, true);
|
|
@@ -9851,18 +9881,18 @@
|
|
|
9851
9881
|
* Fires the element.marker.update event, making it possible to
|
|
9852
9882
|
* integrate extension into the marker life-cycle, too.
|
|
9853
9883
|
*
|
|
9854
|
-
* @param
|
|
9855
|
-
* @param
|
|
9884
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9885
|
+
* @param {string} marker The marker.
|
|
9856
9886
|
*/
|
|
9857
9887
|
Canvas.prototype.removeMarker = function(element, marker) {
|
|
9858
9888
|
this._updateMarker(element, marker, false);
|
|
9859
9889
|
};
|
|
9860
9890
|
|
|
9861
9891
|
/**
|
|
9862
|
-
* Check
|
|
9892
|
+
* Check whether an element has a given marker.
|
|
9863
9893
|
*
|
|
9864
|
-
* @param
|
|
9865
|
-
* @param
|
|
9894
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9895
|
+
* @param {string} marker The marker.
|
|
9866
9896
|
*/
|
|
9867
9897
|
Canvas.prototype.hasMarker = function(element, marker) {
|
|
9868
9898
|
if (!element.id) {
|
|
@@ -9880,8 +9910,8 @@
|
|
|
9880
9910
|
* Fires the element.marker.update event, making it possible to
|
|
9881
9911
|
* integrate extension into the marker life-cycle, too.
|
|
9882
9912
|
*
|
|
9883
|
-
* @param
|
|
9884
|
-
* @param
|
|
9913
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9914
|
+
* @param {string} marker The marker.
|
|
9885
9915
|
*/
|
|
9886
9916
|
Canvas.prototype.toggleMarker = function(element, marker) {
|
|
9887
9917
|
if (this.hasMarker(element, marker)) {
|
|
@@ -9904,7 +9934,7 @@
|
|
|
9904
9934
|
* root elements can be null. This is used for applications that want to manage
|
|
9905
9935
|
* root elements themselves.
|
|
9906
9936
|
*
|
|
9907
|
-
* @
|
|
9937
|
+
* @return {RootLike} The current root element.
|
|
9908
9938
|
*/
|
|
9909
9939
|
Canvas.prototype.getRootElement = function() {
|
|
9910
9940
|
const rootElement = this._rootElement;
|
|
@@ -9920,11 +9950,10 @@
|
|
|
9920
9950
|
/**
|
|
9921
9951
|
* Adds a given root element and returns it.
|
|
9922
9952
|
*
|
|
9923
|
-
* @param {
|
|
9953
|
+
* @param {ShapeLike} [rootElement] The root element to be added.
|
|
9924
9954
|
*
|
|
9925
|
-
* @return {
|
|
9955
|
+
* @return {RootLike} The added root element or an implicit root element.
|
|
9926
9956
|
*/
|
|
9927
|
-
|
|
9928
9957
|
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9929
9958
|
const idx = this._rootsIdx++;
|
|
9930
9959
|
|
|
@@ -9955,11 +9984,11 @@
|
|
|
9955
9984
|
};
|
|
9956
9985
|
|
|
9957
9986
|
/**
|
|
9958
|
-
* Removes a given
|
|
9987
|
+
* Removes a given root element and returns it.
|
|
9959
9988
|
*
|
|
9960
|
-
* @param {
|
|
9989
|
+
* @param {ShapeLike|string} rootElement The root element or its ID.
|
|
9961
9990
|
*
|
|
9962
|
-
* @return {
|
|
9991
|
+
* @return {ShapeLike|undefined} The removed root element.
|
|
9963
9992
|
*/
|
|
9964
9993
|
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
9965
9994
|
|
|
@@ -9993,15 +10022,13 @@
|
|
|
9993
10022
|
};
|
|
9994
10023
|
|
|
9995
10024
|
|
|
9996
|
-
// root element handling //////////////////////
|
|
9997
|
-
|
|
9998
10025
|
/**
|
|
9999
10026
|
* Sets a given element as the new root element for the canvas
|
|
10000
10027
|
* and returns the new root element.
|
|
10001
10028
|
*
|
|
10002
|
-
* @param {
|
|
10029
|
+
* @param {RootLike} rootElement The root element to be set.
|
|
10003
10030
|
*
|
|
10004
|
-
* @return {
|
|
10031
|
+
* @return {RootLike} The set root element.
|
|
10005
10032
|
*/
|
|
10006
10033
|
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
10007
10034
|
|
|
@@ -10088,8 +10115,6 @@
|
|
|
10088
10115
|
this._eventBus.fire('root.set', { element: rootElement });
|
|
10089
10116
|
};
|
|
10090
10117
|
|
|
10091
|
-
// add functionality //////////////////////
|
|
10092
|
-
|
|
10093
10118
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
10094
10119
|
if (!element.id) {
|
|
10095
10120
|
throw new Error('element must have an id');
|
|
@@ -10130,11 +10155,11 @@
|
|
|
10130
10155
|
* Extensions may hook into these events to perform their magic.
|
|
10131
10156
|
*
|
|
10132
10157
|
* @param {string} type
|
|
10133
|
-
* @param {
|
|
10134
|
-
* @param {
|
|
10158
|
+
* @param {ConnectionLike|ShapeLike} element
|
|
10159
|
+
* @param {ShapeLike} [parent]
|
|
10135
10160
|
* @param {number} [parentIndex]
|
|
10136
10161
|
*
|
|
10137
|
-
* @return {
|
|
10162
|
+
* @return {ConnectionLike|ShapeLike} The added element.
|
|
10138
10163
|
*/
|
|
10139
10164
|
Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
|
10140
10165
|
|
|
@@ -10163,26 +10188,26 @@
|
|
|
10163
10188
|
};
|
|
10164
10189
|
|
|
10165
10190
|
/**
|
|
10166
|
-
* Adds a shape to the canvas
|
|
10191
|
+
* Adds a shape to the canvas.
|
|
10167
10192
|
*
|
|
10168
|
-
* @param {
|
|
10169
|
-
* @param {
|
|
10170
|
-
* @param {number} [parentIndex]
|
|
10193
|
+
* @param {ShapeLike} shape The shape to be added
|
|
10194
|
+
* @param {ShapeLike} [parent] The shape's parent.
|
|
10195
|
+
* @param {number} [parentIndex] The index at which to add the shape to the parent's children.
|
|
10171
10196
|
*
|
|
10172
|
-
* @return {
|
|
10197
|
+
* @return {ShapeLike} The added shape.
|
|
10173
10198
|
*/
|
|
10174
10199
|
Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
|
10175
10200
|
return this._addElement('shape', shape, parent, parentIndex);
|
|
10176
10201
|
};
|
|
10177
10202
|
|
|
10178
10203
|
/**
|
|
10179
|
-
* Adds a connection to the canvas
|
|
10204
|
+
* Adds a connection to the canvas.
|
|
10180
10205
|
*
|
|
10181
|
-
* @param {
|
|
10182
|
-
* @param {
|
|
10183
|
-
* @param {number} [parentIndex]
|
|
10206
|
+
* @param {ConnectionLike} connection The connection to be added.
|
|
10207
|
+
* @param {ShapeLike} [parent] The connection's parent.
|
|
10208
|
+
* @param {number} [parentIndex] The index at which to add the connection to the parent's children.
|
|
10184
10209
|
*
|
|
10185
|
-
* @return {
|
|
10210
|
+
* @return {ConnectionLike} The added connection.
|
|
10186
10211
|
*/
|
|
10187
10212
|
Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
|
10188
10213
|
return this._addElement('connection', connection, parent, parentIndex);
|
|
@@ -10223,11 +10248,14 @@
|
|
|
10223
10248
|
|
|
10224
10249
|
|
|
10225
10250
|
/**
|
|
10226
|
-
* Removes a shape from the canvas
|
|
10251
|
+
* Removes a shape from the canvas.
|
|
10252
|
+
*
|
|
10253
|
+
* @fires ShapeRemoveEvent
|
|
10254
|
+
* @fires ShapeRemovedEvent
|
|
10227
10255
|
*
|
|
10228
|
-
* @param {string
|
|
10256
|
+
* @param {ShapeLike|string} shape The shape or its ID.
|
|
10229
10257
|
*
|
|
10230
|
-
* @return {
|
|
10258
|
+
* @return {ShapeLike} The removed shape.
|
|
10231
10259
|
*/
|
|
10232
10260
|
Canvas.prototype.removeShape = function(shape) {
|
|
10233
10261
|
|
|
@@ -10236,10 +10264,10 @@
|
|
|
10236
10264
|
*
|
|
10237
10265
|
* @memberOf Canvas
|
|
10238
10266
|
*
|
|
10239
|
-
* @event
|
|
10267
|
+
* @event ShapeRemoveEvent
|
|
10240
10268
|
* @type {Object}
|
|
10241
|
-
* @property {
|
|
10242
|
-
* @property {
|
|
10269
|
+
* @property {ShapeLike} element The shape.
|
|
10270
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10243
10271
|
*/
|
|
10244
10272
|
|
|
10245
10273
|
/**
|
|
@@ -10247,21 +10275,24 @@
|
|
|
10247
10275
|
*
|
|
10248
10276
|
* @memberOf Canvas
|
|
10249
10277
|
*
|
|
10250
|
-
* @event
|
|
10278
|
+
* @event ShapeRemoved
|
|
10251
10279
|
* @type {Object}
|
|
10252
|
-
* @property {
|
|
10253
|
-
* @property {
|
|
10280
|
+
* @property {ShapeLike} element The shape.
|
|
10281
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10254
10282
|
*/
|
|
10255
10283
|
return this._removeElement(shape, 'shape');
|
|
10256
10284
|
};
|
|
10257
10285
|
|
|
10258
10286
|
|
|
10259
10287
|
/**
|
|
10260
|
-
* Removes a connection from the canvas
|
|
10288
|
+
* Removes a connection from the canvas.
|
|
10261
10289
|
*
|
|
10262
|
-
* @
|
|
10290
|
+
* @fires ConnectionRemoveEvent
|
|
10291
|
+
* @fires ConnectionRemovedEvent
|
|
10263
10292
|
*
|
|
10264
|
-
* @
|
|
10293
|
+
* @param {ConnectionLike|string} connection The connection or its ID.
|
|
10294
|
+
*
|
|
10295
|
+
* @return {ConnectionLike} The removed connection.
|
|
10265
10296
|
*/
|
|
10266
10297
|
Canvas.prototype.removeConnection = function(connection) {
|
|
10267
10298
|
|
|
@@ -10270,10 +10301,10 @@
|
|
|
10270
10301
|
*
|
|
10271
10302
|
* @memberOf Canvas
|
|
10272
10303
|
*
|
|
10273
|
-
* @event
|
|
10304
|
+
* @event ConnectionRemoveEvent
|
|
10274
10305
|
* @type {Object}
|
|
10275
|
-
* @property {
|
|
10276
|
-
* @property {
|
|
10306
|
+
* @property {ConnectionLike} element The connection.
|
|
10307
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10277
10308
|
*/
|
|
10278
10309
|
|
|
10279
10310
|
/**
|
|
@@ -10283,20 +10314,20 @@
|
|
|
10283
10314
|
*
|
|
10284
10315
|
* @event connection.removed
|
|
10285
10316
|
* @type {Object}
|
|
10286
|
-
* @property {
|
|
10287
|
-
* @property {
|
|
10317
|
+
* @property {ConnectionLike} element The connection.
|
|
10318
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10288
10319
|
*/
|
|
10289
10320
|
return this._removeElement(connection, 'connection');
|
|
10290
10321
|
};
|
|
10291
10322
|
|
|
10292
10323
|
|
|
10293
10324
|
/**
|
|
10294
|
-
*
|
|
10325
|
+
* Returns the graphical element of an element.
|
|
10295
10326
|
*
|
|
10296
|
-
* @param {string
|
|
10297
|
-
* @param {boolean} [secondary=false]
|
|
10327
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
10328
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical element.
|
|
10298
10329
|
*
|
|
10299
|
-
* @return {SVGElement}
|
|
10330
|
+
* @return {SVGElement} The graphical element.
|
|
10300
10331
|
*/
|
|
10301
10332
|
Canvas.prototype.getGraphics = function(element, secondary) {
|
|
10302
10333
|
return this._elementRegistry.getGraphics(element, secondary);
|
|
@@ -10368,13 +10399,9 @@
|
|
|
10368
10399
|
* height: zoomedAndScrolledViewbox.outer.height
|
|
10369
10400
|
* });
|
|
10370
10401
|
*
|
|
10371
|
-
* @param
|
|
10372
|
-
* @param {number} box.x the top left X coordinate of the canvas visible in view box
|
|
10373
|
-
* @param {number} box.y the top left Y coordinate of the canvas visible in view box
|
|
10374
|
-
* @param {number} box.width the visible width
|
|
10375
|
-
* @param {number} box.height
|
|
10402
|
+
* @param {Rect} [box] The viewbox to be set.
|
|
10376
10403
|
*
|
|
10377
|
-
* @return {
|
|
10404
|
+
* @return {CanvasViewbox} The set viewbox.
|
|
10378
10405
|
*/
|
|
10379
10406
|
Canvas.prototype.viewbox = function(box) {
|
|
10380
10407
|
|
|
@@ -10443,10 +10470,9 @@
|
|
|
10443
10470
|
/**
|
|
10444
10471
|
* Gets or sets the scroll of the canvas.
|
|
10445
10472
|
*
|
|
10446
|
-
* @param {
|
|
10473
|
+
* @param {Point} [delta] The scroll to be set.
|
|
10447
10474
|
*
|
|
10448
|
-
* @
|
|
10449
|
-
* @param {number} [delta.dy]
|
|
10475
|
+
* @return {Point}
|
|
10450
10476
|
*/
|
|
10451
10477
|
Canvas.prototype.scroll = function(delta) {
|
|
10452
10478
|
|
|
@@ -10470,9 +10496,8 @@
|
|
|
10470
10496
|
* Scrolls the viewbox to contain the given element.
|
|
10471
10497
|
* Optionally specify a padding to be applied to the edges.
|
|
10472
10498
|
*
|
|
10473
|
-
* @param {
|
|
10474
|
-
* @param {
|
|
10475
|
-
*
|
|
10499
|
+
* @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
|
|
10500
|
+
* @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
|
|
10476
10501
|
*/
|
|
10477
10502
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
10478
10503
|
let defaultPadding = 100;
|
|
@@ -10540,17 +10565,17 @@
|
|
|
10540
10565
|
};
|
|
10541
10566
|
|
|
10542
10567
|
/**
|
|
10543
|
-
* Gets or sets the current zoom of the canvas, optionally zooming
|
|
10544
|
-
*
|
|
10568
|
+
* Gets or sets the current zoom of the canvas, optionally zooming to the
|
|
10569
|
+
* specified position.
|
|
10545
10570
|
*
|
|
10546
|
-
* The getter may return a cached zoom level. Call it with `false` as
|
|
10547
|
-
*
|
|
10571
|
+
* The getter may return a cached zoom level. Call it with `false` as the first
|
|
10572
|
+
* argument to force recomputation of the current level.
|
|
10548
10573
|
*
|
|
10549
|
-
* @param {string
|
|
10550
|
-
*
|
|
10551
|
-
* @param {
|
|
10574
|
+
* @param {number|string} [newScale] The new zoom level, either a number,
|
|
10575
|
+
* i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
|
|
10576
|
+
* @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
|
|
10552
10577
|
*
|
|
10553
|
-
* @return {number}
|
|
10578
|
+
* @return {number} The set zoom level.
|
|
10554
10579
|
*/
|
|
10555
10580
|
Canvas.prototype.zoom = function(newScale, center) {
|
|
10556
10581
|
|
|
@@ -10673,9 +10698,9 @@
|
|
|
10673
10698
|
|
|
10674
10699
|
|
|
10675
10700
|
/**
|
|
10676
|
-
* Returns the size of the canvas
|
|
10701
|
+
* Returns the size of the canvas.
|
|
10677
10702
|
*
|
|
10678
|
-
* @return {Dimensions}
|
|
10703
|
+
* @return {Dimensions} The size of the canvas.
|
|
10679
10704
|
*/
|
|
10680
10705
|
Canvas.prototype.getSize = function() {
|
|
10681
10706
|
return {
|
|
@@ -10686,14 +10711,14 @@
|
|
|
10686
10711
|
|
|
10687
10712
|
|
|
10688
10713
|
/**
|
|
10689
|
-
*
|
|
10714
|
+
* Returns the absolute bounding box of an element.
|
|
10715
|
+
*
|
|
10716
|
+
* The absolute bounding box may be used to display overlays in the callers
|
|
10717
|
+
* (browser) coordinate system rather than the zoomed in/out canvas coordinates.
|
|
10690
10718
|
*
|
|
10691
|
-
*
|
|
10692
|
-
* callers (browser) coordinate system rather than the zoomed in/out
|
|
10693
|
-
* canvas coordinates.
|
|
10719
|
+
* @param {ShapeLike|ConnectionLike} element The element.
|
|
10694
10720
|
*
|
|
10695
|
-
* @
|
|
10696
|
-
* @return {Bounds} the absolute bounding box
|
|
10721
|
+
* @return {Rect} The element's absolute bounding box.
|
|
10697
10722
|
*/
|
|
10698
10723
|
Canvas.prototype.getAbsoluteBBox = function(element) {
|
|
10699
10724
|
const vbox = this.viewbox();
|
|
@@ -10728,8 +10753,7 @@
|
|
|
10728
10753
|
};
|
|
10729
10754
|
|
|
10730
10755
|
/**
|
|
10731
|
-
* Fires an event
|
|
10732
|
-
* canvas resizing
|
|
10756
|
+
* Fires an event so other modules can react to the canvas resizing.
|
|
10733
10757
|
*/
|
|
10734
10758
|
Canvas.prototype.resized = function() {
|
|
10735
10759
|
|
|
@@ -10741,11 +10765,21 @@
|
|
|
10741
10765
|
|
|
10742
10766
|
var ELEMENT_ID = 'data-element-id';
|
|
10743
10767
|
|
|
10768
|
+
/**
|
|
10769
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
10770
|
+
*
|
|
10771
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
10772
|
+
*
|
|
10773
|
+
* @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
|
|
10774
|
+
*/
|
|
10744
10775
|
|
|
10745
10776
|
/**
|
|
10777
|
+
* A registry that keeps track of all shapes in the diagram.
|
|
10778
|
+
*
|
|
10746
10779
|
* @class
|
|
10780
|
+
* @constructor
|
|
10747
10781
|
*
|
|
10748
|
-
*
|
|
10782
|
+
* @param {EventBus} eventBus
|
|
10749
10783
|
*/
|
|
10750
10784
|
function ElementRegistry(eventBus) {
|
|
10751
10785
|
this._elements = {};
|
|
@@ -10756,11 +10790,11 @@
|
|
|
10756
10790
|
ElementRegistry.$inject = [ 'eventBus' ];
|
|
10757
10791
|
|
|
10758
10792
|
/**
|
|
10759
|
-
*
|
|
10793
|
+
* Add an element and its graphical representation(s) to the registry.
|
|
10760
10794
|
*
|
|
10761
|
-
* @param {
|
|
10762
|
-
* @param {SVGElement} gfx
|
|
10763
|
-
* @param {SVGElement} [secondaryGfx]
|
|
10795
|
+
* @param {ElementLike} element The element to be added.
|
|
10796
|
+
* @param {SVGElement} gfx The primary graphical representation.
|
|
10797
|
+
* @param {SVGElement} [secondaryGfx] The secondary graphical representation.
|
|
10764
10798
|
*/
|
|
10765
10799
|
ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
|
10766
10800
|
|
|
@@ -10779,9 +10813,9 @@
|
|
|
10779
10813
|
};
|
|
10780
10814
|
|
|
10781
10815
|
/**
|
|
10782
|
-
*
|
|
10816
|
+
* Remove an element from the registry.
|
|
10783
10817
|
*
|
|
10784
|
-
* @param {string
|
|
10818
|
+
* @param {ElementLike|string} element
|
|
10785
10819
|
*/
|
|
10786
10820
|
ElementRegistry.prototype.remove = function(element) {
|
|
10787
10821
|
var elements = this._elements,
|
|
@@ -10802,10 +10836,10 @@
|
|
|
10802
10836
|
};
|
|
10803
10837
|
|
|
10804
10838
|
/**
|
|
10805
|
-
* Update
|
|
10839
|
+
* Update an elements ID.
|
|
10806
10840
|
*
|
|
10807
|
-
* @param {string
|
|
10808
|
-
* @param {string} newId
|
|
10841
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10842
|
+
* @param {string} newId The new ID.
|
|
10809
10843
|
*/
|
|
10810
10844
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
10811
10845
|
|
|
@@ -10831,11 +10865,11 @@
|
|
|
10831
10865
|
};
|
|
10832
10866
|
|
|
10833
10867
|
/**
|
|
10834
|
-
* Update the
|
|
10868
|
+
* Update the graphical representation of an element.
|
|
10835
10869
|
*
|
|
10836
|
-
* @param {string
|
|
10837
|
-
* @param {SVGElement} gfx
|
|
10838
|
-
* @param {boolean} [secondary=false]
|
|
10870
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10871
|
+
* @param {SVGElement} gfx The new graphical representation.
|
|
10872
|
+
* @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
|
|
10839
10873
|
*/
|
|
10840
10874
|
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
10841
10875
|
var id = filter.id || filter;
|
|
@@ -10856,17 +10890,17 @@
|
|
|
10856
10890
|
};
|
|
10857
10891
|
|
|
10858
10892
|
/**
|
|
10859
|
-
*
|
|
10893
|
+
* Get the element with the given ID or graphical representation.
|
|
10860
10894
|
*
|
|
10861
10895
|
* @example
|
|
10862
10896
|
*
|
|
10863
10897
|
* elementRegistry.get('SomeElementId_1');
|
|
10864
|
-
* elementRegistry.get(gfx);
|
|
10865
10898
|
*
|
|
10899
|
+
* elementRegistry.get(gfx);
|
|
10866
10900
|
*
|
|
10867
|
-
* @param {string|SVGElement} filter
|
|
10901
|
+
* @param {string|SVGElement} filter The elements ID or graphical representation.
|
|
10868
10902
|
*
|
|
10869
|
-
* @return {
|
|
10903
|
+
* @return {ElementLike|undefined} The element.
|
|
10870
10904
|
*/
|
|
10871
10905
|
ElementRegistry.prototype.get = function(filter) {
|
|
10872
10906
|
var id;
|
|
@@ -10884,9 +10918,9 @@
|
|
|
10884
10918
|
/**
|
|
10885
10919
|
* Return all elements that match a given filter function.
|
|
10886
10920
|
*
|
|
10887
|
-
* @param {
|
|
10921
|
+
* @param {ElementRegistryCallback} fn The filter function.
|
|
10888
10922
|
*
|
|
10889
|
-
* @return {
|
|
10923
|
+
* @return {ElementLike[]} The matching elements.
|
|
10890
10924
|
*/
|
|
10891
10925
|
ElementRegistry.prototype.filter = function(fn) {
|
|
10892
10926
|
|
|
@@ -10902,11 +10936,11 @@
|
|
|
10902
10936
|
};
|
|
10903
10937
|
|
|
10904
10938
|
/**
|
|
10905
|
-
* Return the first element that
|
|
10939
|
+
* Return the first element that matches the given filter function.
|
|
10906
10940
|
*
|
|
10907
|
-
* @param {Function} fn
|
|
10941
|
+
* @param {Function} fn The filter function.
|
|
10908
10942
|
*
|
|
10909
|
-
* @return {
|
|
10943
|
+
* @return {ElementLike|undefined} The matching element.
|
|
10910
10944
|
*/
|
|
10911
10945
|
ElementRegistry.prototype.find = function(fn) {
|
|
10912
10946
|
var map = this._elements,
|
|
@@ -10925,18 +10959,18 @@
|
|
|
10925
10959
|
};
|
|
10926
10960
|
|
|
10927
10961
|
/**
|
|
10928
|
-
*
|
|
10962
|
+
* Get all elements.
|
|
10929
10963
|
*
|
|
10930
|
-
* @return {
|
|
10964
|
+
* @return {ElementLike[]} All elements.
|
|
10931
10965
|
*/
|
|
10932
10966
|
ElementRegistry.prototype.getAll = function() {
|
|
10933
10967
|
return this.filter(function(e) { return e; });
|
|
10934
10968
|
};
|
|
10935
10969
|
|
|
10936
10970
|
/**
|
|
10937
|
-
*
|
|
10971
|
+
* Execute a given function for each element.
|
|
10938
10972
|
*
|
|
10939
|
-
* @param {Function} fn
|
|
10973
|
+
* @param {Function} fn The function to execute.
|
|
10940
10974
|
*/
|
|
10941
10975
|
ElementRegistry.prototype.forEach = function(fn) {
|
|
10942
10976
|
|
|
@@ -10952,19 +10986,20 @@
|
|
|
10952
10986
|
};
|
|
10953
10987
|
|
|
10954
10988
|
/**
|
|
10955
|
-
* Return the graphical representation of an element
|
|
10989
|
+
* Return the graphical representation of an element.
|
|
10956
10990
|
*
|
|
10957
10991
|
* @example
|
|
10992
|
+
*
|
|
10958
10993
|
* elementRegistry.getGraphics('SomeElementId_1');
|
|
10994
|
+
*
|
|
10959
10995
|
* elementRegistry.getGraphics(rootElement); // <g ...>
|
|
10960
10996
|
*
|
|
10961
10997
|
* elementRegistry.getGraphics(rootElement, true); // <svg ...>
|
|
10962
10998
|
*
|
|
10999
|
+
* @param {ElementLike|string} filter The element or its ID.
|
|
11000
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
|
|
10963
11001
|
*
|
|
10964
|
-
* @
|
|
10965
|
-
* @param {boolean} [secondary=false] whether to return the secondary connected element
|
|
10966
|
-
*
|
|
10967
|
-
* @return {SVGElement}
|
|
11002
|
+
* @return {SVGElement} The graphical representation.
|
|
10968
11003
|
*/
|
|
10969
11004
|
ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
|
10970
11005
|
var id = filter.id || filter;
|
|
@@ -10974,12 +11009,11 @@
|
|
|
10974
11009
|
};
|
|
10975
11010
|
|
|
10976
11011
|
/**
|
|
10977
|
-
* Validate
|
|
10978
|
-
* with an exception.
|
|
11012
|
+
* Validate an ID and throw an error if invalid.
|
|
10979
11013
|
*
|
|
10980
11014
|
* @param {string} id
|
|
10981
11015
|
*
|
|
10982
|
-
* @throws {Error}
|
|
11016
|
+
* @throws {Error} Error indicating that the ID is invalid or already assigned.
|
|
10983
11017
|
*/
|
|
10984
11018
|
ElementRegistry.prototype._validateId = function(id) {
|
|
10985
11019
|
if (!id) {
|
|
@@ -11319,14 +11353,6 @@
|
|
|
11319
11353
|
outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
|
11320
11354
|
incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
|
|
11321
11355
|
|
|
11322
|
-
/**
|
|
11323
|
-
* @namespace djs.model
|
|
11324
|
-
*/
|
|
11325
|
-
|
|
11326
|
-
/**
|
|
11327
|
-
* @memberOf djs.model
|
|
11328
|
-
*/
|
|
11329
|
-
|
|
11330
11356
|
/**
|
|
11331
11357
|
* The basic graphical representation
|
|
11332
11358
|
*
|
|
@@ -11523,21 +11549,47 @@
|
|
|
11523
11549
|
};
|
|
11524
11550
|
|
|
11525
11551
|
/**
|
|
11526
|
-
* Creates a
|
|
11552
|
+
* Creates a model element of the given type.
|
|
11527
11553
|
*
|
|
11528
11554
|
* @method create
|
|
11529
11555
|
*
|
|
11530
11556
|
* @example
|
|
11531
11557
|
*
|
|
11532
|
-
*
|
|
11533
|
-
*
|
|
11558
|
+
* import * as Model from 'diagram-js/lib/model';
|
|
11559
|
+
*
|
|
11560
|
+
* const connection = Model.create('connection', {
|
|
11561
|
+
* waypoints: [
|
|
11562
|
+
* { x: 100, y: 100 },
|
|
11563
|
+
* { x: 200, y: 100 }
|
|
11564
|
+
* ]
|
|
11565
|
+
* });
|
|
11566
|
+
*
|
|
11567
|
+
* const label = Model.create('label', {
|
|
11568
|
+
* x: 100,
|
|
11569
|
+
* y: 100,
|
|
11570
|
+
* width: 100,
|
|
11571
|
+
* height: 100,
|
|
11572
|
+
* labelTarget: shape
|
|
11573
|
+
* });
|
|
11574
|
+
*
|
|
11575
|
+
* const root = Model.create('root', {
|
|
11576
|
+
* x: 100,
|
|
11577
|
+
* y: 100,
|
|
11578
|
+
* width: 100,
|
|
11579
|
+
* height: 100
|
|
11580
|
+
* });
|
|
11534
11581
|
*
|
|
11535
|
-
*
|
|
11582
|
+
* const shape = Model.create('shape', {
|
|
11583
|
+
* x: 100,
|
|
11584
|
+
* y: 100,
|
|
11585
|
+
* width: 100,
|
|
11586
|
+
* height: 100
|
|
11587
|
+
* });
|
|
11536
11588
|
*
|
|
11537
|
-
* @param
|
|
11538
|
-
* @param
|
|
11589
|
+
* @param {string} type The type of model element to be created.
|
|
11590
|
+
* @param {Object} attrs Attributes to create the model element with.
|
|
11539
11591
|
*
|
|
11540
|
-
* @return {
|
|
11592
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11541
11593
|
*/
|
|
11542
11594
|
function create(type, attrs) {
|
|
11543
11595
|
var Type = types$7[type];
|
|
@@ -11548,36 +11600,78 @@
|
|
|
11548
11600
|
}
|
|
11549
11601
|
|
|
11550
11602
|
/**
|
|
11551
|
-
*
|
|
11603
|
+
* @typedef {import('../model/index').Base} Base
|
|
11604
|
+
* @typedef {import('../model/index').Connection} Connection
|
|
11605
|
+
* @typedef {import('../model/index').Label} Label
|
|
11606
|
+
* @typedef {import('../model/index').Root} Root
|
|
11607
|
+
* @typedef {import('../model/index').Shape} Shape
|
|
11608
|
+
* @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
|
|
11609
|
+
* @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
|
|
11610
|
+
* @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
|
|
11611
|
+
* @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
|
|
11612
|
+
*/
|
|
11613
|
+
|
|
11614
|
+
/**
|
|
11615
|
+
* A factory for model elements.
|
|
11616
|
+
*
|
|
11617
|
+
* @class
|
|
11618
|
+
* @constructor
|
|
11552
11619
|
*/
|
|
11553
11620
|
function ElementFactory() {
|
|
11554
11621
|
this._uid = 12;
|
|
11555
11622
|
}
|
|
11556
11623
|
|
|
11557
|
-
|
|
11624
|
+
/**
|
|
11625
|
+
* Create a root element.
|
|
11626
|
+
*
|
|
11627
|
+
* @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
|
|
11628
|
+
*
|
|
11629
|
+
* @return {Root} The created root element.
|
|
11630
|
+
*/
|
|
11558
11631
|
ElementFactory.prototype.createRoot = function(attrs) {
|
|
11559
11632
|
return this.create('root', attrs);
|
|
11560
11633
|
};
|
|
11561
11634
|
|
|
11635
|
+
/**
|
|
11636
|
+
* Create a label.
|
|
11637
|
+
*
|
|
11638
|
+
* @param {ModelAttrsLabel} attrs The attributes of the label to be created.
|
|
11639
|
+
*
|
|
11640
|
+
* @return {Label} The created label.
|
|
11641
|
+
*/
|
|
11562
11642
|
ElementFactory.prototype.createLabel = function(attrs) {
|
|
11563
11643
|
return this.create('label', attrs);
|
|
11564
11644
|
};
|
|
11565
11645
|
|
|
11646
|
+
/**
|
|
11647
|
+
* Create a shape.
|
|
11648
|
+
*
|
|
11649
|
+
* @param {ModelAttrsShape} attrs The attributes of the shape to be created.
|
|
11650
|
+
*
|
|
11651
|
+
* @return {Shape} The created shape.
|
|
11652
|
+
*/
|
|
11566
11653
|
ElementFactory.prototype.createShape = function(attrs) {
|
|
11567
11654
|
return this.create('shape', attrs);
|
|
11568
11655
|
};
|
|
11569
11656
|
|
|
11657
|
+
/**
|
|
11658
|
+
* Create a connection.
|
|
11659
|
+
*
|
|
11660
|
+
* @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
|
|
11661
|
+
*
|
|
11662
|
+
* @return {Connection} The created connection.
|
|
11663
|
+
*/
|
|
11570
11664
|
ElementFactory.prototype.createConnection = function(attrs) {
|
|
11571
11665
|
return this.create('connection', attrs);
|
|
11572
11666
|
};
|
|
11573
11667
|
|
|
11574
11668
|
/**
|
|
11575
|
-
* Create a model element
|
|
11576
|
-
* a number of pre-set attributes.
|
|
11669
|
+
* Create a model element of the given type with the given attributes.
|
|
11577
11670
|
*
|
|
11578
|
-
* @param
|
|
11579
|
-
* @param
|
|
11580
|
-
*
|
|
11671
|
+
* @param {string} type The type of the model element.
|
|
11672
|
+
* @param {Object} attrs The attributes of the model element.
|
|
11673
|
+
*
|
|
11674
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11581
11675
|
*/
|
|
11582
11676
|
ElementFactory.prototype.create = function(type, attrs) {
|
|
11583
11677
|
|
|
@@ -11596,6 +11690,16 @@
|
|
|
11596
11690
|
|
|
11597
11691
|
var slice = Array.prototype.slice;
|
|
11598
11692
|
|
|
11693
|
+
/**
|
|
11694
|
+
* @typedef {import('./EventBus').Event} Event
|
|
11695
|
+
* @typedef {import('./EventBus').EventCallback} EventCallback
|
|
11696
|
+
*
|
|
11697
|
+
* @typedef {Object} EventListener
|
|
11698
|
+
* @property {Function} callback
|
|
11699
|
+
* @property {EventListener|null} next
|
|
11700
|
+
* @property {number} priority
|
|
11701
|
+
*/
|
|
11702
|
+
|
|
11599
11703
|
/**
|
|
11600
11704
|
* A general purpose event bus.
|
|
11601
11705
|
*
|
|
@@ -11700,10 +11804,10 @@
|
|
|
11700
11804
|
*
|
|
11701
11805
|
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
11702
11806
|
*
|
|
11703
|
-
* @param {string|
|
|
11704
|
-
* @param {number} [priority=1000]
|
|
11705
|
-
* @param {
|
|
11706
|
-
* @param {
|
|
11807
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
11808
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11809
|
+
* @param {EventCallback} callback The callback.
|
|
11810
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11707
11811
|
*/
|
|
11708
11812
|
EventBus.prototype.on = function(events, priority, callback, that) {
|
|
11709
11813
|
|
|
@@ -11743,12 +11847,12 @@
|
|
|
11743
11847
|
|
|
11744
11848
|
|
|
11745
11849
|
/**
|
|
11746
|
-
* Register an event listener that is
|
|
11850
|
+
* Register an event listener that is called only once.
|
|
11747
11851
|
*
|
|
11748
|
-
* @param {string} event
|
|
11749
|
-
* @param {number} [priority=1000]
|
|
11750
|
-
* @param {
|
|
11751
|
-
* @param {
|
|
11852
|
+
* @param {string} event The event to listen to.
|
|
11853
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11854
|
+
* @param {EventCallback} callback The callback.
|
|
11855
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11752
11856
|
*/
|
|
11753
11857
|
EventBus.prototype.once = function(event, priority, callback, that) {
|
|
11754
11858
|
var self = this;
|
|
@@ -11787,8 +11891,8 @@
|
|
|
11787
11891
|
*
|
|
11788
11892
|
* If no callback is given, all listeners for a given event name are being removed.
|
|
11789
11893
|
*
|
|
11790
|
-
* @param {string|
|
|
11791
|
-
* @param {
|
|
11894
|
+
* @param {string|string[]} events The events.
|
|
11895
|
+
* @param {EventCallback} [callback] The callback.
|
|
11792
11896
|
*/
|
|
11793
11897
|
EventBus.prototype.off = function(events, callback) {
|
|
11794
11898
|
|
|
@@ -11804,11 +11908,11 @@
|
|
|
11804
11908
|
|
|
11805
11909
|
|
|
11806
11910
|
/**
|
|
11807
|
-
* Create an
|
|
11911
|
+
* Create an event recognized be the event bus.
|
|
11808
11912
|
*
|
|
11809
|
-
* @param {Object} data
|
|
11913
|
+
* @param {Object} data Event data.
|
|
11810
11914
|
*
|
|
11811
|
-
* @return {
|
|
11915
|
+
* @return {Event} An event that will be recognized by the event bus.
|
|
11812
11916
|
*/
|
|
11813
11917
|
EventBus.prototype.createEvent = function(data) {
|
|
11814
11918
|
var event = new InternalEvent();
|
|
@@ -11820,7 +11924,7 @@
|
|
|
11820
11924
|
|
|
11821
11925
|
|
|
11822
11926
|
/**
|
|
11823
|
-
* Fires
|
|
11927
|
+
* Fires an event.
|
|
11824
11928
|
*
|
|
11825
11929
|
* @example
|
|
11826
11930
|
*
|
|
@@ -11842,12 +11946,11 @@
|
|
|
11842
11946
|
*
|
|
11843
11947
|
* events.fire({ type: 'foo' }, 'I am bar!');
|
|
11844
11948
|
*
|
|
11845
|
-
* @param {string} [
|
|
11846
|
-
* @param {Object} [
|
|
11847
|
-
* @param {
|
|
11949
|
+
* @param {string} [type] The event type.
|
|
11950
|
+
* @param {Object} [data] The event or event data.
|
|
11951
|
+
* @param {...*} additional Additional arguments the callback will be called with.
|
|
11848
11952
|
*
|
|
11849
|
-
* @return {
|
|
11850
|
-
* default action was prevented by listeners
|
|
11953
|
+
* @return {*} The return value. Will be set to `false` if the default was prevented.
|
|
11851
11954
|
*/
|
|
11852
11955
|
EventBus.prototype.fire = function(type, data) {
|
|
11853
11956
|
var event,
|
|
@@ -11912,7 +12015,13 @@
|
|
|
11912
12015
|
return returnValue;
|
|
11913
12016
|
};
|
|
11914
12017
|
|
|
11915
|
-
|
|
12018
|
+
/**
|
|
12019
|
+
* Handle an error by firing an event.
|
|
12020
|
+
*
|
|
12021
|
+
* @param {Error} error The error to be handled.
|
|
12022
|
+
*
|
|
12023
|
+
* @return {boolean} Whether the error was handled.
|
|
12024
|
+
*/
|
|
11916
12025
|
EventBus.prototype.handleError = function(error) {
|
|
11917
12026
|
return this.fire('error', { error: error }) === false;
|
|
11918
12027
|
};
|
|
@@ -11975,7 +12084,7 @@
|
|
|
11975
12084
|
return returnValue;
|
|
11976
12085
|
};
|
|
11977
12086
|
|
|
11978
|
-
|
|
12087
|
+
/**
|
|
11979
12088
|
* Add new listener with a certain priority to the list
|
|
11980
12089
|
* of listeners (for the given event).
|
|
11981
12090
|
*
|
|
@@ -11989,7 +12098,7 @@
|
|
|
11989
12098
|
* * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
|
|
11990
12099
|
*
|
|
11991
12100
|
* @param {string} event
|
|
11992
|
-
* @param {
|
|
12101
|
+
* @param {EventListener} listener
|
|
11993
12102
|
*/
|
|
11994
12103
|
EventBus.prototype._addListener = function(event, newListener) {
|
|
11995
12104
|
|
|
@@ -12095,9 +12204,9 @@
|
|
|
12095
12204
|
* Invoke function. Be fast...
|
|
12096
12205
|
*
|
|
12097
12206
|
* @param {Function} fn
|
|
12098
|
-
* @param {
|
|
12207
|
+
* @param {*[]} args
|
|
12099
12208
|
*
|
|
12100
|
-
* @return {
|
|
12209
|
+
* @return {*}
|
|
12101
12210
|
*/
|
|
12102
12211
|
function invokeFunction(fn, args) {
|
|
12103
12212
|
return fn.apply(null, args);
|
|
@@ -12111,11 +12220,11 @@
|
|
|
12111
12220
|
*/
|
|
12112
12221
|
|
|
12113
12222
|
/**
|
|
12114
|
-
* Returns the visual part of a diagram element
|
|
12223
|
+
* Returns the visual part of a diagram element.
|
|
12115
12224
|
*
|
|
12116
|
-
* @param {
|
|
12225
|
+
* @param {SVGElement} gfx
|
|
12117
12226
|
*
|
|
12118
|
-
* @return {
|
|
12227
|
+
* @return {SVGElement}
|
|
12119
12228
|
*/
|
|
12120
12229
|
function getVisual(gfx) {
|
|
12121
12230
|
return gfx.childNodes[0];
|
|
@@ -12124,15 +12233,28 @@
|
|
|
12124
12233
|
/**
|
|
12125
12234
|
* Returns the children for a given diagram element.
|
|
12126
12235
|
*
|
|
12127
|
-
* @param {
|
|
12128
|
-
* @return {
|
|
12236
|
+
* @param {SVGElement} gfx
|
|
12237
|
+
* @return {SVGElement}
|
|
12129
12238
|
*/
|
|
12130
12239
|
function getChildren(gfx) {
|
|
12131
12240
|
return gfx.parentNode.childNodes[1];
|
|
12132
12241
|
}
|
|
12133
12242
|
|
|
12134
12243
|
/**
|
|
12135
|
-
*
|
|
12244
|
+
* @typedef {import('../model').ModelType} ModelType
|
|
12245
|
+
* @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
|
|
12246
|
+
* @typedef {import('../model').ModelTypeShape} ModelTypeShape
|
|
12247
|
+
*
|
|
12248
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
12249
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
12250
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
12251
|
+
*
|
|
12252
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
12253
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
12254
|
+
*/
|
|
12255
|
+
|
|
12256
|
+
/**
|
|
12257
|
+
* A factory that creates graphical elements.
|
|
12136
12258
|
*
|
|
12137
12259
|
* @param {EventBus} eventBus
|
|
12138
12260
|
* @param {ElementRegistry} elementRegistry
|
|
@@ -12200,7 +12322,7 @@
|
|
|
12200
12322
|
* </g>
|
|
12201
12323
|
*
|
|
12202
12324
|
* @param {string} type the type of the element, i.e. shape | connection
|
|
12203
|
-
* @param {SVGElement}
|
|
12325
|
+
* @param {SVGElement} childrenGfx
|
|
12204
12326
|
* @param {number} [parentIndex] position to create container in parent
|
|
12205
12327
|
* @param {boolean} [isFrame] is frame element
|
|
12206
12328
|
*
|
|
@@ -12238,11 +12360,25 @@
|
|
|
12238
12360
|
return gfx;
|
|
12239
12361
|
};
|
|
12240
12362
|
|
|
12363
|
+
/**
|
|
12364
|
+
* Create a graphical element.
|
|
12365
|
+
*
|
|
12366
|
+
* @param {ModelType} type The type of the element.
|
|
12367
|
+
* @param {ElementLike} element The element.
|
|
12368
|
+
* @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
|
|
12369
|
+
*
|
|
12370
|
+
* @return {SVGElement} The graphical element.
|
|
12371
|
+
*/
|
|
12241
12372
|
GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
|
12242
12373
|
var childrenGfx = this._getChildrenContainer(element.parent);
|
|
12243
12374
|
return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
|
12244
12375
|
};
|
|
12245
12376
|
|
|
12377
|
+
/**
|
|
12378
|
+
* Update the containments of the given elements.
|
|
12379
|
+
*
|
|
12380
|
+
* @param {ElementLike[]} elements The elements.
|
|
12381
|
+
*/
|
|
12246
12382
|
GraphicsFactory.prototype.updateContainments = function(elements) {
|
|
12247
12383
|
|
|
12248
12384
|
var self = this,
|
|
@@ -12278,30 +12414,63 @@
|
|
|
12278
12414
|
});
|
|
12279
12415
|
};
|
|
12280
12416
|
|
|
12417
|
+
/**
|
|
12418
|
+
* Draw a shape.
|
|
12419
|
+
*
|
|
12420
|
+
* @param {SVGElement} visual The graphical element.
|
|
12421
|
+
* @param {ShapeLike} element The shape.
|
|
12422
|
+
*/
|
|
12281
12423
|
GraphicsFactory.prototype.drawShape = function(visual, element) {
|
|
12282
12424
|
var eventBus = this._eventBus;
|
|
12283
12425
|
|
|
12284
12426
|
return eventBus.fire('render.shape', { gfx: visual, element: element });
|
|
12285
12427
|
};
|
|
12286
12428
|
|
|
12429
|
+
/**
|
|
12430
|
+
* Get the path of a shape.
|
|
12431
|
+
*
|
|
12432
|
+
* @param {ShapeLike} element The shape.
|
|
12433
|
+
*
|
|
12434
|
+
* @return {string} The path of the shape.
|
|
12435
|
+
*/
|
|
12287
12436
|
GraphicsFactory.prototype.getShapePath = function(element) {
|
|
12288
12437
|
var eventBus = this._eventBus;
|
|
12289
12438
|
|
|
12290
12439
|
return eventBus.fire('render.getShapePath', element);
|
|
12291
12440
|
};
|
|
12292
12441
|
|
|
12442
|
+
/**
|
|
12443
|
+
* Draw a connection.
|
|
12444
|
+
*
|
|
12445
|
+
* @param {SVGElement} visual The graphical element.
|
|
12446
|
+
* @param {ConnectionLike} element The connection.
|
|
12447
|
+
*/
|
|
12293
12448
|
GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
|
12294
12449
|
var eventBus = this._eventBus;
|
|
12295
12450
|
|
|
12296
12451
|
return eventBus.fire('render.connection', { gfx: visual, element: element });
|
|
12297
12452
|
};
|
|
12298
12453
|
|
|
12299
|
-
|
|
12454
|
+
/**
|
|
12455
|
+
* Get the path of a connection.
|
|
12456
|
+
*
|
|
12457
|
+
* @param {ConnectionLike} element The connection.
|
|
12458
|
+
*
|
|
12459
|
+
* @return {string} The path of the connection.
|
|
12460
|
+
*/
|
|
12461
|
+
GraphicsFactory.prototype.getConnectionPath = function(connection) {
|
|
12300
12462
|
var eventBus = this._eventBus;
|
|
12301
12463
|
|
|
12302
|
-
return eventBus.fire('render.getConnectionPath',
|
|
12464
|
+
return eventBus.fire('render.getConnectionPath', connection);
|
|
12303
12465
|
};
|
|
12304
12466
|
|
|
12467
|
+
/**
|
|
12468
|
+
* Update an elements graphical representation.
|
|
12469
|
+
*
|
|
12470
|
+
* @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
|
|
12471
|
+
* @param {ElementLike} element The element.
|
|
12472
|
+
* @param {SVGElement} gfx The graphical representation.
|
|
12473
|
+
*/
|
|
12305
12474
|
GraphicsFactory.prototype.update = function(type, element, gfx) {
|
|
12306
12475
|
|
|
12307
12476
|
// do NOT update root element
|
|
@@ -12331,6 +12500,11 @@
|
|
|
12331
12500
|
}
|
|
12332
12501
|
};
|
|
12333
12502
|
|
|
12503
|
+
/**
|
|
12504
|
+
* Remove a graphical element.
|
|
12505
|
+
*
|
|
12506
|
+
* @param {ElementLike} element The element.
|
|
12507
|
+
*/
|
|
12334
12508
|
GraphicsFactory.prototype.remove = function(element) {
|
|
12335
12509
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12336
12510
|
|
|
@@ -12364,13 +12538,17 @@
|
|
|
12364
12538
|
};
|
|
12365
12539
|
|
|
12366
12540
|
/**
|
|
12367
|
-
* @typedef {
|
|
12541
|
+
* @typedef {import('didi').InjectionContext} InjectionContext
|
|
12542
|
+
* @typedef {import('didi').LocalsMap} LocalsMap
|
|
12543
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
12544
|
+
*
|
|
12545
|
+
* @typedef {import('./Diagram').DiagramOptions} DiagramOptions
|
|
12368
12546
|
*/
|
|
12369
12547
|
|
|
12370
12548
|
/**
|
|
12371
12549
|
* Bootstrap an injector from a list of modules, instantiating a number of default components
|
|
12372
12550
|
*
|
|
12373
|
-
* @param {
|
|
12551
|
+
* @param {ModuleDeclaration[]} modules
|
|
12374
12552
|
*
|
|
12375
12553
|
* @return {Injector} a injector to use to access the components
|
|
12376
12554
|
*/
|
|
@@ -12385,7 +12563,8 @@
|
|
|
12385
12563
|
/**
|
|
12386
12564
|
* Creates an injector from passed options.
|
|
12387
12565
|
*
|
|
12388
|
-
* @param {
|
|
12566
|
+
* @param {DiagramOptions} [options]
|
|
12567
|
+
*
|
|
12389
12568
|
* @return {Injector}
|
|
12390
12569
|
*/
|
|
12391
12570
|
function createInjector(options) {
|
|
@@ -12408,8 +12587,7 @@
|
|
|
12408
12587
|
*
|
|
12409
12588
|
* To register extensions with the diagram, pass them as Array<Module> to the constructor.
|
|
12410
12589
|
*
|
|
12411
|
-
* @class
|
|
12412
|
-
* @memberOf djs
|
|
12590
|
+
* @class
|
|
12413
12591
|
* @constructor
|
|
12414
12592
|
*
|
|
12415
12593
|
* @example
|
|
@@ -12447,9 +12625,9 @@
|
|
|
12447
12625
|
*
|
|
12448
12626
|
* // 'shape ... was added to the diagram' logged to console
|
|
12449
12627
|
*
|
|
12450
|
-
* @param {
|
|
12451
|
-
* @param {
|
|
12452
|
-
* @param {Injector} [injector]
|
|
12628
|
+
* @param {DiagramOptions} [options]
|
|
12629
|
+
* @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
|
|
12630
|
+
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
|
|
12453
12631
|
*/
|
|
12454
12632
|
function Diagram(options, injector) {
|
|
12455
12633
|
|
|
@@ -12459,22 +12637,23 @@
|
|
|
12459
12637
|
// API
|
|
12460
12638
|
|
|
12461
12639
|
/**
|
|
12462
|
-
* Resolves a diagram service
|
|
12640
|
+
* Resolves a diagram service.
|
|
12463
12641
|
*
|
|
12464
12642
|
* @method Diagram#get
|
|
12465
12643
|
*
|
|
12466
|
-
* @param {string} name
|
|
12467
|
-
* @param {boolean} [strict=true]
|
|
12644
|
+
* @param {string} name The name of the service to get.
|
|
12645
|
+
* @param {boolean} [strict=true] If false, resolve missing services to null.
|
|
12468
12646
|
*/
|
|
12469
12647
|
this.get = injector.get;
|
|
12470
12648
|
|
|
12471
12649
|
/**
|
|
12472
|
-
* Executes a function
|
|
12650
|
+
* Executes a function with its dependencies injected.
|
|
12473
12651
|
*
|
|
12474
12652
|
* @method Diagram#invoke
|
|
12475
12653
|
*
|
|
12476
|
-
* @param {Function
|
|
12477
|
-
* @param {
|
|
12654
|
+
* @param {Function} fn The function to be executed.
|
|
12655
|
+
* @param {InjectionContext} [context] The context.
|
|
12656
|
+
* @param {LocalsMap} [locals] The locals.
|
|
12478
12657
|
*/
|
|
12479
12658
|
this.invoke = injector.invoke;
|
|
12480
12659
|
|