camunda-bpmn-js 1.3.1 → 1.5.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 +2355 -950
- package/dist/base-modeler.production.min.js +32 -33
- package/dist/base-navigated-viewer.development.js +699 -484
- package/dist/base-navigated-viewer.production.min.js +1 -3
- package/dist/base-viewer.development.js +671 -476
- package/dist/base-viewer.production.min.js +1 -3
- package/dist/camunda-cloud-modeler.development.js +7758 -2531
- package/dist/camunda-cloud-modeler.production.min.js +36 -37
- package/dist/camunda-cloud-navigated-viewer.development.js +699 -484
- package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -3
- package/dist/camunda-cloud-viewer.development.js +671 -476
- package/dist/camunda-cloud-viewer.production.min.js +1 -3
- package/dist/camunda-platform-modeler.development.js +6811 -2288
- package/dist/camunda-platform-modeler.production.min.js +35 -36
- package/dist/camunda-platform-navigated-viewer.development.js +699 -484
- package/dist/camunda-platform-navigated-viewer.production.min.js +1 -3
- package/dist/camunda-platform-viewer.development.js +671 -476
- package/dist/camunda-platform-viewer.production.min.js +1 -3
- package/lib/camunda-cloud/Modeler.js +8 -1
- package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesAppendProvider.js +162 -0
- package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesCreateProvider.js +114 -0
- package/lib/camunda-cloud/features/create-append-anything/index.js +11 -0
- package/lib/camunda-platform/Modeler.js +6 -1
- package/package.json +8 -6
|
@@ -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
|
|
@@ -2481,7 +2494,11 @@
|
|
|
2481
2494
|
...shapeStyle({
|
|
2482
2495
|
fill: fill,
|
|
2483
2496
|
stroke: stroke,
|
|
2484
|
-
strokeWidth: 1
|
|
2497
|
+
strokeWidth: 1,
|
|
2498
|
+
|
|
2499
|
+
// fix for safari / chrome / firefox bug not correctly
|
|
2500
|
+
// resetting stroke dash array
|
|
2501
|
+
strokeDasharray: [ 10000, 1 ]
|
|
2485
2502
|
})
|
|
2486
2503
|
});
|
|
2487
2504
|
|
|
@@ -2497,7 +2514,11 @@
|
|
|
2497
2514
|
...shapeStyle({
|
|
2498
2515
|
fill: fill,
|
|
2499
2516
|
stroke: stroke,
|
|
2500
|
-
strokeWidth: 1
|
|
2517
|
+
strokeWidth: 1,
|
|
2518
|
+
|
|
2519
|
+
// fix for safari / chrome / firefox bug not correctly
|
|
2520
|
+
// resetting stroke dash array
|
|
2521
|
+
strokeDasharray: [ 10000, 1 ]
|
|
2501
2522
|
})
|
|
2502
2523
|
});
|
|
2503
2524
|
|
|
@@ -2513,7 +2534,11 @@
|
|
|
2513
2534
|
...lineStyle({
|
|
2514
2535
|
fill: 'none',
|
|
2515
2536
|
stroke: stroke,
|
|
2516
|
-
strokeWidth: 1.5
|
|
2537
|
+
strokeWidth: 1.5,
|
|
2538
|
+
|
|
2539
|
+
// fix for safari / chrome / firefox bug not correctly
|
|
2540
|
+
// resetting stroke dash array
|
|
2541
|
+
strokeDasharray: [ 10000, 1 ]
|
|
2517
2542
|
})
|
|
2518
2543
|
});
|
|
2519
2544
|
|
|
@@ -2530,7 +2555,11 @@
|
|
|
2530
2555
|
...lineStyle({
|
|
2531
2556
|
fill: 'none',
|
|
2532
2557
|
stroke: stroke,
|
|
2533
|
-
strokeWidth: 1.5
|
|
2558
|
+
strokeWidth: 1.5,
|
|
2559
|
+
|
|
2560
|
+
// fix for safari / chrome / firefox bug not correctly
|
|
2561
|
+
// resetting stroke dash array
|
|
2562
|
+
strokeDasharray: [ 10000, 1 ]
|
|
2534
2563
|
})
|
|
2535
2564
|
});
|
|
2536
2565
|
|
|
@@ -4220,6 +4249,10 @@
|
|
|
4220
4249
|
return getRectPath(element);
|
|
4221
4250
|
};
|
|
4222
4251
|
|
|
4252
|
+
/**
|
|
4253
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
4254
|
+
*/
|
|
4255
|
+
|
|
4223
4256
|
var DEFAULT_BOX_PADDING = 0;
|
|
4224
4257
|
|
|
4225
4258
|
var DEFAULT_LABEL_SIZE$1 = {
|
|
@@ -4293,7 +4326,8 @@
|
|
|
4293
4326
|
*
|
|
4294
4327
|
* Alters the lines passed.
|
|
4295
4328
|
*
|
|
4296
|
-
* @param
|
|
4329
|
+
* @param {string[]} lines
|
|
4330
|
+
*
|
|
4297
4331
|
* @return {Object} the line descriptor, an object { width, height, text }
|
|
4298
4332
|
*/
|
|
4299
4333
|
function layoutNext(lines, maxWidth, fakeText) {
|
|
@@ -4338,8 +4372,9 @@
|
|
|
4338
4372
|
* Shortens a line based on spacing and hyphens.
|
|
4339
4373
|
* Returns the shortened result on success.
|
|
4340
4374
|
*
|
|
4341
|
-
* @param
|
|
4342
|
-
* @param
|
|
4375
|
+
* @param {string} line
|
|
4376
|
+
* @param {number} maxLength the maximum characters of the string
|
|
4377
|
+
*
|
|
4343
4378
|
* @return {string} the shortened string
|
|
4344
4379
|
*/
|
|
4345
4380
|
function semanticShorten(line, maxLength) {
|
|
@@ -5179,6 +5214,10 @@
|
|
|
5179
5214
|
pathMap: [ 'type', PathMap ]
|
|
5180
5215
|
};
|
|
5181
5216
|
|
|
5217
|
+
/**
|
|
5218
|
+
* @typedef {import('./').Replacements} Replacements
|
|
5219
|
+
*/
|
|
5220
|
+
|
|
5182
5221
|
/**
|
|
5183
5222
|
* A simple translation stub to be used for multi-language support
|
|
5184
5223
|
* in diagrams. Can be easily replaced with a more sophisticated
|
|
@@ -5193,7 +5232,7 @@
|
|
|
5193
5232
|
* }
|
|
5194
5233
|
*
|
|
5195
5234
|
* @param {string} template to interpolate
|
|
5196
|
-
* @param {
|
|
5235
|
+
* @param {Replacements} [replacements] a map with substitutes
|
|
5197
5236
|
*
|
|
5198
5237
|
* @return {string} the translated string
|
|
5199
5238
|
*/
|
|
@@ -5350,8 +5389,6 @@
|
|
|
5350
5389
|
return element && !!element.labelTarget;
|
|
5351
5390
|
}
|
|
5352
5391
|
|
|
5353
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5354
|
-
|
|
5355
5392
|
function getDefaultExportFromCjs (x) {
|
|
5356
5393
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5357
5394
|
}
|
|
@@ -5368,9 +5405,9 @@
|
|
|
5368
5405
|
/**
|
|
5369
5406
|
* Convert the given bounds to a { top, left, bottom, right } descriptor.
|
|
5370
5407
|
*
|
|
5371
|
-
* @param {
|
|
5408
|
+
* @param {Point|Rect} bounds
|
|
5372
5409
|
*
|
|
5373
|
-
* @return {
|
|
5410
|
+
* @return {RectTRBL}
|
|
5374
5411
|
*/
|
|
5375
5412
|
function asTRBL(bounds) {
|
|
5376
5413
|
return {
|
|
@@ -5385,9 +5422,9 @@
|
|
|
5385
5422
|
/**
|
|
5386
5423
|
* Convert a { top, left, bottom, right } to an objects bounds.
|
|
5387
5424
|
*
|
|
5388
|
-
* @param {
|
|
5425
|
+
* @param {RectTRBL} trbl
|
|
5389
5426
|
*
|
|
5390
|
-
* @return {
|
|
5427
|
+
* @return {Rect}
|
|
5391
5428
|
*/
|
|
5392
5429
|
function asBounds(trbl) {
|
|
5393
5430
|
return {
|
|
@@ -5402,7 +5439,7 @@
|
|
|
5402
5439
|
/**
|
|
5403
5440
|
* Get the mid of the given bounds or point.
|
|
5404
5441
|
*
|
|
5405
|
-
* @param {
|
|
5442
|
+
* @param {Point|Rect} bounds
|
|
5406
5443
|
*
|
|
5407
5444
|
* @return {Point}
|
|
5408
5445
|
*/
|
|
@@ -5417,7 +5454,7 @@
|
|
|
5417
5454
|
/**
|
|
5418
5455
|
* Get the mid of the given Connection.
|
|
5419
5456
|
*
|
|
5420
|
-
* @param {
|
|
5457
|
+
* @param {Connection} connection
|
|
5421
5458
|
*
|
|
5422
5459
|
* @return {Point}
|
|
5423
5460
|
*/
|
|
@@ -5476,7 +5513,7 @@
|
|
|
5476
5513
|
/**
|
|
5477
5514
|
* Get the mid of the given Element.
|
|
5478
5515
|
*
|
|
5479
|
-
* @param {
|
|
5516
|
+
* @param {Connection} connection
|
|
5480
5517
|
*
|
|
5481
5518
|
* @return {Point}
|
|
5482
5519
|
*/
|
|
@@ -5886,6 +5923,14 @@
|
|
|
5886
5923
|
return isPrimaryButton(event) && originalEvent.shiftKey;
|
|
5887
5924
|
}
|
|
5888
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
|
+
|
|
5889
5934
|
function allowAll(event) { return true; }
|
|
5890
5935
|
|
|
5891
5936
|
function allowPrimaryAndAuxiliary(event) {
|
|
@@ -5915,6 +5960,8 @@
|
|
|
5915
5960
|
* prevents the original DOM operation.
|
|
5916
5961
|
*
|
|
5917
5962
|
* @param {EventBus} eventBus
|
|
5963
|
+
* @param {ElementRegistry} elementRegistry
|
|
5964
|
+
* @param {Styles} styles
|
|
5918
5965
|
*/
|
|
5919
5966
|
function InteractionEvents(eventBus, elementRegistry, styles) {
|
|
5920
5967
|
|
|
@@ -5924,8 +5971,8 @@
|
|
|
5924
5971
|
* Fire an interaction event.
|
|
5925
5972
|
*
|
|
5926
5973
|
* @param {string} type local event name, e.g. element.click.
|
|
5927
|
-
* @param {
|
|
5928
|
-
* @param {
|
|
5974
|
+
* @param {MouseEvent|TouchEvent} event native event
|
|
5975
|
+
* @param {Base} [element] the diagram element to emit the event on;
|
|
5929
5976
|
* defaults to the event target
|
|
5930
5977
|
*/
|
|
5931
5978
|
function fire(type, event, element) {
|
|
@@ -6007,8 +6054,8 @@
|
|
|
6007
6054
|
* on the target shape or connection.
|
|
6008
6055
|
*
|
|
6009
6056
|
* @param {string} eventName the name of the triggered DOM event
|
|
6010
|
-
* @param {MouseEvent} event
|
|
6011
|
-
* @param {
|
|
6057
|
+
* @param {MouseEvent|TouchEvent} event
|
|
6058
|
+
* @param {Base} targetElement
|
|
6012
6059
|
*/
|
|
6013
6060
|
function triggerMouseEvent(eventName, event, targetElement) {
|
|
6014
6061
|
|
|
@@ -6174,7 +6221,7 @@
|
|
|
6174
6221
|
/**
|
|
6175
6222
|
* Create default hit for the given element.
|
|
6176
6223
|
*
|
|
6177
|
-
* @param {
|
|
6224
|
+
* @param {Base} element
|
|
6178
6225
|
* @param {SVGElement} gfx
|
|
6179
6226
|
*
|
|
6180
6227
|
* @return {SVGElement} created hit
|
|
@@ -6246,8 +6293,8 @@
|
|
|
6246
6293
|
/**
|
|
6247
6294
|
* Update default hit of the element.
|
|
6248
6295
|
*
|
|
6249
|
-
* @param
|
|
6250
|
-
* @param
|
|
6296
|
+
* @param {Base} element
|
|
6297
|
+
* @param {SVGElement} gfx
|
|
6251
6298
|
*
|
|
6252
6299
|
* @return {SVGElement} updated hit
|
|
6253
6300
|
*/
|
|
@@ -6295,7 +6342,7 @@
|
|
|
6295
6342
|
* @event element.hover
|
|
6296
6343
|
*
|
|
6297
6344
|
* @type {Object}
|
|
6298
|
-
* @property {
|
|
6345
|
+
* @property {Base} element
|
|
6299
6346
|
* @property {SVGElement} gfx
|
|
6300
6347
|
* @property {Event} originalEvent
|
|
6301
6348
|
*/
|
|
@@ -6306,7 +6353,7 @@
|
|
|
6306
6353
|
* @event element.out
|
|
6307
6354
|
*
|
|
6308
6355
|
* @type {Object}
|
|
6309
|
-
* @property {
|
|
6356
|
+
* @property {Base} element
|
|
6310
6357
|
* @property {SVGElement} gfx
|
|
6311
6358
|
* @property {Event} originalEvent
|
|
6312
6359
|
*/
|
|
@@ -6317,7 +6364,7 @@
|
|
|
6317
6364
|
* @event element.click
|
|
6318
6365
|
*
|
|
6319
6366
|
* @type {Object}
|
|
6320
|
-
* @property {
|
|
6367
|
+
* @property {Base} element
|
|
6321
6368
|
* @property {SVGElement} gfx
|
|
6322
6369
|
* @property {Event} originalEvent
|
|
6323
6370
|
*/
|
|
@@ -6328,7 +6375,7 @@
|
|
|
6328
6375
|
* @event element.dblclick
|
|
6329
6376
|
*
|
|
6330
6377
|
* @type {Object}
|
|
6331
|
-
* @property {
|
|
6378
|
+
* @property {Base} element
|
|
6332
6379
|
* @property {SVGElement} gfx
|
|
6333
6380
|
* @property {Event} originalEvent
|
|
6334
6381
|
*/
|
|
@@ -6339,7 +6386,7 @@
|
|
|
6339
6386
|
* @event element.mousedown
|
|
6340
6387
|
*
|
|
6341
6388
|
* @type {Object}
|
|
6342
|
-
* @property {
|
|
6389
|
+
* @property {Base} element
|
|
6343
6390
|
* @property {SVGElement} gfx
|
|
6344
6391
|
* @property {Event} originalEvent
|
|
6345
6392
|
*/
|
|
@@ -6350,7 +6397,7 @@
|
|
|
6350
6397
|
* @event element.mouseup
|
|
6351
6398
|
*
|
|
6352
6399
|
* @type {Object}
|
|
6353
|
-
* @property {
|
|
6400
|
+
* @property {Base} element
|
|
6354
6401
|
* @property {SVGElement} gfx
|
|
6355
6402
|
* @property {Event} originalEvent
|
|
6356
6403
|
*/
|
|
@@ -6362,7 +6409,7 @@
|
|
|
6362
6409
|
* @event element.contextmenu
|
|
6363
6410
|
*
|
|
6364
6411
|
* @type {Object}
|
|
6365
|
-
* @property {
|
|
6412
|
+
* @property {Base} element
|
|
6366
6413
|
* @property {SVGElement} gfx
|
|
6367
6414
|
* @property {Event} originalEvent
|
|
6368
6415
|
*/
|
|
@@ -6376,10 +6423,10 @@
|
|
|
6376
6423
|
* Returns the surrounding bbox for all elements in
|
|
6377
6424
|
* the array or the element primitive.
|
|
6378
6425
|
*
|
|
6379
|
-
* @param {
|
|
6426
|
+
* @param {Base|Base[]} elements
|
|
6380
6427
|
* @param {boolean} [stopRecursion=false]
|
|
6381
6428
|
*
|
|
6382
|
-
* @return {
|
|
6429
|
+
* @return {Rect}
|
|
6383
6430
|
*/
|
|
6384
6431
|
function getBBox(elements, stopRecursion) {
|
|
6385
6432
|
|
|
@@ -6450,6 +6497,12 @@
|
|
|
6450
6497
|
|
|
6451
6498
|
var LOW_PRIORITY$2 = 500;
|
|
6452
6499
|
|
|
6500
|
+
/**
|
|
6501
|
+
* @typedef {import('../../model').Base} Base
|
|
6502
|
+
*
|
|
6503
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6504
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
6505
|
+
*/
|
|
6453
6506
|
|
|
6454
6507
|
/**
|
|
6455
6508
|
* @class
|
|
@@ -6459,9 +6512,8 @@
|
|
|
6459
6512
|
*
|
|
6460
6513
|
* @param {EventBus} eventBus
|
|
6461
6514
|
* @param {Styles} styles
|
|
6462
|
-
* @param {ElementRegistry} elementRegistry
|
|
6463
6515
|
*/
|
|
6464
|
-
function Outline(eventBus, styles
|
|
6516
|
+
function Outline(eventBus, styles) {
|
|
6465
6517
|
|
|
6466
6518
|
this.offset = 6;
|
|
6467
6519
|
|
|
@@ -6519,8 +6571,8 @@
|
|
|
6519
6571
|
* Updates the outline of a shape respecting the dimension of the
|
|
6520
6572
|
* element and an outline offset.
|
|
6521
6573
|
*
|
|
6522
|
-
* @param
|
|
6523
|
-
* @param
|
|
6574
|
+
* @param {SVGElement} outline
|
|
6575
|
+
* @param {Base} element
|
|
6524
6576
|
*/
|
|
6525
6577
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6526
6578
|
|
|
@@ -6538,8 +6590,8 @@
|
|
|
6538
6590
|
* Updates the outline of a connection respecting the bounding box of
|
|
6539
6591
|
* the connection and an outline offset.
|
|
6540
6592
|
*
|
|
6541
|
-
* @param
|
|
6542
|
-
* @param
|
|
6593
|
+
* @param {SVGElement} outline
|
|
6594
|
+
* @param {Base} element
|
|
6543
6595
|
*/
|
|
6544
6596
|
Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
|
6545
6597
|
|
|
@@ -6562,13 +6614,17 @@
|
|
|
6562
6614
|
outline: [ 'type', Outline ]
|
|
6563
6615
|
};
|
|
6564
6616
|
|
|
6617
|
+
/**
|
|
6618
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6619
|
+
*/
|
|
6620
|
+
|
|
6565
6621
|
/**
|
|
6566
6622
|
* A service that offers the current selection in a diagram.
|
|
6567
6623
|
* Offers the api to control the selection, too.
|
|
6568
6624
|
*
|
|
6569
6625
|
* @class
|
|
6570
6626
|
*
|
|
6571
|
-
* @param {EventBus} eventBus
|
|
6627
|
+
* @param {EventBus} eventBus
|
|
6572
6628
|
*/
|
|
6573
6629
|
function Selection(eventBus, canvas) {
|
|
6574
6630
|
|
|
@@ -6624,8 +6680,8 @@
|
|
|
6624
6680
|
*
|
|
6625
6681
|
* @method Selection#select
|
|
6626
6682
|
*
|
|
6627
|
-
* @param
|
|
6628
|
-
* @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
|
|
6629
6685
|
*/
|
|
6630
6686
|
Selection.prototype.select = function(elements, add) {
|
|
6631
6687
|
var selectedElements = this._selectedElements,
|
|
@@ -6664,6 +6720,12 @@
|
|
|
6664
6720
|
this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
|
6665
6721
|
};
|
|
6666
6722
|
|
|
6723
|
+
/**
|
|
6724
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6725
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6726
|
+
* @typedef {import('./Selection').default} Selection
|
|
6727
|
+
*/
|
|
6728
|
+
|
|
6667
6729
|
var MARKER_HOVER = 'hover',
|
|
6668
6730
|
MARKER_SELECTED = 'selected';
|
|
6669
6731
|
|
|
@@ -6680,6 +6742,7 @@
|
|
|
6680
6742
|
*
|
|
6681
6743
|
* @param {Canvas} canvas
|
|
6682
6744
|
* @param {EventBus} eventBus
|
|
6745
|
+
* @param {Selection} selection
|
|
6683
6746
|
*/
|
|
6684
6747
|
function SelectionVisuals(canvas, eventBus, selection) {
|
|
6685
6748
|
this._canvas = canvas;
|
|
@@ -6785,6 +6848,19 @@
|
|
|
6785
6848
|
};
|
|
6786
6849
|
}
|
|
6787
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
|
+
*/
|
|
6788
6864
|
function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
|
6789
6865
|
|
|
6790
6866
|
// Select elements on create
|
|
@@ -6905,9 +6981,8 @@
|
|
|
6905
6981
|
/**
|
|
6906
6982
|
* Util that provides unique IDs.
|
|
6907
6983
|
*
|
|
6908
|
-
* @class
|
|
6984
|
+
* @class
|
|
6909
6985
|
* @constructor
|
|
6910
|
-
* @memberOf djs.util
|
|
6911
6986
|
*
|
|
6912
6987
|
* The ids can be customized via a given prefix and contain a random value to avoid collisions.
|
|
6913
6988
|
*
|
|
@@ -6922,8 +6997,6 @@
|
|
|
6922
6997
|
/**
|
|
6923
6998
|
* Returns a next unique ID.
|
|
6924
6999
|
*
|
|
6925
|
-
* @method djs.util.IdGenerator#next
|
|
6926
|
-
*
|
|
6927
7000
|
* @returns {string} the id
|
|
6928
7001
|
*/
|
|
6929
7002
|
IdGenerator.prototype.next = function() {
|
|
@@ -6935,6 +7008,18 @@
|
|
|
6935
7008
|
|
|
6936
7009
|
var LOW_PRIORITY$1 = 500;
|
|
6937
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
|
+
*/
|
|
6938
7023
|
|
|
6939
7024
|
/**
|
|
6940
7025
|
* A service that allows users to attach overlays to diagram elements.
|
|
@@ -6944,6 +7029,7 @@
|
|
|
6944
7029
|
* @example
|
|
6945
7030
|
*
|
|
6946
7031
|
* // add a pink badge on the top left of the shape
|
|
7032
|
+
*
|
|
6947
7033
|
* overlays.add(someShape, {
|
|
6948
7034
|
* position: {
|
|
6949
7035
|
* top: -5,
|
|
@@ -6995,19 +7081,21 @@
|
|
|
6995
7081
|
* }
|
|
6996
7082
|
* }
|
|
6997
7083
|
*
|
|
6998
|
-
* @param {
|
|
7084
|
+
* @param {OverlaysConfig} config
|
|
6999
7085
|
* @param {EventBus} eventBus
|
|
7000
7086
|
* @param {Canvas} canvas
|
|
7001
7087
|
* @param {ElementRegistry} elementRegistry
|
|
7002
7088
|
*/
|
|
7003
7089
|
function Overlays(config, eventBus, canvas, elementRegistry) {
|
|
7004
|
-
|
|
7005
7090
|
this._eventBus = eventBus;
|
|
7006
7091
|
this._canvas = canvas;
|
|
7007
7092
|
this._elementRegistry = elementRegistry;
|
|
7008
7093
|
|
|
7009
7094
|
this._ids = ids;
|
|
7010
7095
|
|
|
7096
|
+
/**
|
|
7097
|
+
* @type {OverlaysConfigDefault}
|
|
7098
|
+
*/
|
|
7011
7099
|
this._overlayDefaults = assign$1({
|
|
7012
7100
|
|
|
7013
7101
|
// no show constraints
|
|
@@ -7018,16 +7106,18 @@
|
|
|
7018
7106
|
}, config && config.defaults);
|
|
7019
7107
|
|
|
7020
7108
|
/**
|
|
7021
|
-
*
|
|
7109
|
+
* @type {Map<string, Overlay>}
|
|
7022
7110
|
*/
|
|
7023
7111
|
this._overlays = {};
|
|
7024
7112
|
|
|
7025
7113
|
/**
|
|
7026
|
-
*
|
|
7114
|
+
* @type {OverlayContainer[]}
|
|
7027
7115
|
*/
|
|
7028
7116
|
this._overlayContainers = [];
|
|
7029
7117
|
|
|
7030
|
-
|
|
7118
|
+
/**
|
|
7119
|
+
* @type {HTMLElement}
|
|
7120
|
+
*/
|
|
7031
7121
|
this._overlayRoot = createRoot(canvas.getContainer());
|
|
7032
7122
|
|
|
7033
7123
|
this._init();
|
|
@@ -7043,12 +7133,12 @@
|
|
|
7043
7133
|
|
|
7044
7134
|
|
|
7045
7135
|
/**
|
|
7046
|
-
* Returns the overlay with the specified
|
|
7136
|
+
* Returns the overlay with the specified ID or a list of overlays
|
|
7047
7137
|
* for an element with a given type.
|
|
7048
7138
|
*
|
|
7049
7139
|
* @example
|
|
7050
7140
|
*
|
|
7051
|
-
* // return the single overlay with the given
|
|
7141
|
+
* // return the single overlay with the given ID
|
|
7052
7142
|
* overlays.get('some-id');
|
|
7053
7143
|
*
|
|
7054
7144
|
* // return all overlays for the shape
|
|
@@ -7057,16 +7147,12 @@
|
|
|
7057
7147
|
* // return all overlays on shape with type 'badge'
|
|
7058
7148
|
* overlays.get({ element: someShape, type: 'badge' });
|
|
7059
7149
|
*
|
|
7060
|
-
* // shape can also be specified as
|
|
7150
|
+
* // shape can also be specified as ID
|
|
7061
7151
|
* overlays.get({ element: 'element-id', type: 'badge' });
|
|
7062
7152
|
*
|
|
7153
|
+
* @param {OverlaysFilter} search The filter to be used to find the overlay(s).
|
|
7063
7154
|
*
|
|
7064
|
-
* @
|
|
7065
|
-
* @param {string} [search.id]
|
|
7066
|
-
* @param {string|djs.model.Base} [search.element]
|
|
7067
|
-
* @param {string} [search.type]
|
|
7068
|
-
*
|
|
7069
|
-
* @return {Object|Array<Object>} the overlay(s)
|
|
7155
|
+
* @return {Overlay|Overlay[]} The overlay(s).
|
|
7070
7156
|
*/
|
|
7071
7157
|
Overlays.prototype.get = function(search) {
|
|
7072
7158
|
|
|
@@ -7098,27 +7184,13 @@
|
|
|
7098
7184
|
};
|
|
7099
7185
|
|
|
7100
7186
|
/**
|
|
7101
|
-
* Adds
|
|
7187
|
+
* Adds an HTML overlay to an element.
|
|
7102
7188
|
*
|
|
7103
|
-
* @param {string
|
|
7104
|
-
* @param {string}
|
|
7105
|
-
* @param {
|
|
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.
|
|
7106
7192
|
*
|
|
7107
|
-
* @
|
|
7108
|
-
* @param {Object} [overlay.show] show configuration
|
|
7109
|
-
* @param {number} [overlay.show.minZoom] minimal zoom level to show the overlay
|
|
7110
|
-
* @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
|
|
7111
|
-
* @param {Object} overlay.position where to attach the overlay
|
|
7112
|
-
* @param {number} [overlay.position.left] relative to element bbox left attachment
|
|
7113
|
-
* @param {number} [overlay.position.top] relative to element bbox top attachment
|
|
7114
|
-
* @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
|
|
7115
|
-
* @param {number} [overlay.position.right] relative to element bbox right attachment
|
|
7116
|
-
* @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
|
|
7117
|
-
* diagram zoom
|
|
7118
|
-
* @param {number} [overlay.scale.min]
|
|
7119
|
-
* @param {number} [overlay.scale.max]
|
|
7120
|
-
*
|
|
7121
|
-
* @return {string} id that may be used to reference the overlay for update or removal
|
|
7193
|
+
* @return {string} The overlay's ID that can be used to get or remove it.
|
|
7122
7194
|
*/
|
|
7123
7195
|
Overlays.prototype.add = function(element, type, overlay) {
|
|
7124
7196
|
|
|
@@ -7159,11 +7231,11 @@
|
|
|
7159
7231
|
|
|
7160
7232
|
|
|
7161
7233
|
/**
|
|
7162
|
-
* Remove an overlay with the given
|
|
7234
|
+
* Remove an overlay with the given ID or all overlays matching the given filter.
|
|
7163
7235
|
*
|
|
7164
7236
|
* @see Overlays#get for filter options.
|
|
7165
7237
|
*
|
|
7166
|
-
* @param {
|
|
7238
|
+
* @param {OverlaysFilter} filter The filter to be used to find the overlay.
|
|
7167
7239
|
*/
|
|
7168
7240
|
Overlays.prototype.remove = function(filter) {
|
|
7169
7241
|
|
|
@@ -7199,19 +7271,32 @@
|
|
|
7199
7271
|
|
|
7200
7272
|
};
|
|
7201
7273
|
|
|
7274
|
+
/**
|
|
7275
|
+
* Checks whether overlays are shown.
|
|
7276
|
+
*
|
|
7277
|
+
* @returns {boolean} Whether overlays are shown.
|
|
7278
|
+
*/
|
|
7202
7279
|
Overlays.prototype.isShown = function() {
|
|
7203
7280
|
return this._overlayRoot.style.display !== 'none';
|
|
7204
7281
|
};
|
|
7205
7282
|
|
|
7283
|
+
/**
|
|
7284
|
+
* Show all overlays.
|
|
7285
|
+
*/
|
|
7206
7286
|
Overlays.prototype.show = function() {
|
|
7207
7287
|
setVisible(this._overlayRoot);
|
|
7208
7288
|
};
|
|
7209
7289
|
|
|
7210
|
-
|
|
7290
|
+
/**
|
|
7291
|
+
* Hide all overlays.
|
|
7292
|
+
*/
|
|
7211
7293
|
Overlays.prototype.hide = function() {
|
|
7212
7294
|
setVisible(this._overlayRoot, false);
|
|
7213
7295
|
};
|
|
7214
7296
|
|
|
7297
|
+
/**
|
|
7298
|
+
* Remove all overlays and their container.
|
|
7299
|
+
*/
|
|
7215
7300
|
Overlays.prototype.clear = function() {
|
|
7216
7301
|
this._overlays = {};
|
|
7217
7302
|
|
|
@@ -7587,6 +7672,13 @@
|
|
|
7587
7672
|
overlays: [ 'type', Overlays ]
|
|
7588
7673
|
};
|
|
7589
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
|
+
|
|
7590
7682
|
/**
|
|
7591
7683
|
* Adds change support to the diagram, including
|
|
7592
7684
|
*
|
|
@@ -7656,32 +7748,41 @@
|
|
|
7656
7748
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7657
7749
|
};
|
|
7658
7750
|
|
|
7751
|
+
/**
|
|
7752
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
7753
|
+
* @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
|
|
7754
|
+
* @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
|
|
7755
|
+
*/
|
|
7756
|
+
|
|
7659
7757
|
var DEFAULT_PRIORITY$1 = 1000;
|
|
7660
7758
|
|
|
7661
7759
|
/**
|
|
7662
|
-
* A utility that can be used to plug
|
|
7760
|
+
* A utility that can be used to plug into the command execution for
|
|
7663
7761
|
* extension and/or validation.
|
|
7664
7762
|
*
|
|
7763
|
+
* @class
|
|
7764
|
+
* @constructor
|
|
7765
|
+
*
|
|
7665
7766
|
* @param {EventBus} eventBus
|
|
7666
7767
|
*
|
|
7667
7768
|
* @example
|
|
7668
7769
|
*
|
|
7669
|
-
* import inherits from 'inherits-browser';
|
|
7670
|
-
*
|
|
7671
7770
|
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7672
7771
|
*
|
|
7673
|
-
*
|
|
7674
|
-
*
|
|
7772
|
+
* class CommandLogger extends CommandInterceptor {
|
|
7773
|
+
* constructor(eventBus) {
|
|
7774
|
+
* super(eventBus);
|
|
7675
7775
|
*
|
|
7676
|
-
* this.preExecute(
|
|
7677
|
-
* console.log('
|
|
7776
|
+
* this.preExecute('shape.create', (event) => {
|
|
7777
|
+
* console.log('commandStack.shape-create.preExecute', event);
|
|
7678
7778
|
* });
|
|
7679
7779
|
* }
|
|
7680
|
-
*
|
|
7681
|
-
* inherits(CommandLogger, CommandInterceptor);
|
|
7682
|
-
*
|
|
7683
7780
|
*/
|
|
7684
7781
|
function CommandInterceptor(eventBus) {
|
|
7782
|
+
|
|
7783
|
+
/**
|
|
7784
|
+
* @type {EventBus}
|
|
7785
|
+
*/
|
|
7685
7786
|
this._eventBus = eventBus;
|
|
7686
7787
|
}
|
|
7687
7788
|
|
|
@@ -7694,16 +7795,15 @@
|
|
|
7694
7795
|
}
|
|
7695
7796
|
|
|
7696
7797
|
/**
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
*/
|
|
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
|
+
*/
|
|
7707
7807
|
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7708
7808
|
|
|
7709
7809
|
if (isFunction(hook) || isNumber(hook)) {
|
|
@@ -7759,24 +7859,19 @@
|
|
|
7759
7859
|
];
|
|
7760
7860
|
|
|
7761
7861
|
/*
|
|
7762
|
-
*
|
|
7763
|
-
*
|
|
7764
|
-
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7765
|
-
* which will in term forward to CommandInterceptor#on.
|
|
7862
|
+
* Add prototype methods for each phase of command execution (e.g. execute,
|
|
7863
|
+
* revert).
|
|
7766
7864
|
*/
|
|
7767
7865
|
forEach$1(hooks, function(hook) {
|
|
7768
7866
|
|
|
7769
7867
|
/**
|
|
7770
|
-
*
|
|
7771
|
-
*
|
|
7772
|
-
* A named hook for plugging into the command execution
|
|
7868
|
+
* Add prototype method for a specific phase of command execution.
|
|
7773
7869
|
*
|
|
7774
|
-
* @param {string|
|
|
7775
|
-
* @param {number} [priority]
|
|
7776
|
-
* @param {
|
|
7777
|
-
* @param {boolean} [unwrap
|
|
7778
|
-
*
|
|
7779
|
-
* @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.
|
|
7780
7875
|
*/
|
|
7781
7876
|
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7782
7877
|
|
|
@@ -7792,12 +7887,18 @@
|
|
|
7792
7887
|
};
|
|
7793
7888
|
});
|
|
7794
7889
|
|
|
7890
|
+
/**
|
|
7891
|
+
* @typedef {import('didi').Injector} Injector
|
|
7892
|
+
*
|
|
7893
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7894
|
+
*/
|
|
7895
|
+
|
|
7795
7896
|
/**
|
|
7796
7897
|
* A modeling behavior that ensures we set the correct root element
|
|
7797
7898
|
* as we undo and redo commands.
|
|
7798
7899
|
*
|
|
7799
7900
|
* @param {Canvas} canvas
|
|
7800
|
-
* @param {
|
|
7901
|
+
* @param {Injector} injector
|
|
7801
7902
|
*/
|
|
7802
7903
|
function RootElementsBehavior(canvas, injector) {
|
|
7803
7904
|
|
|
@@ -7831,111 +7932,10 @@
|
|
|
7831
7932
|
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7832
7933
|
};
|
|
7833
7934
|
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
(function (module, exports) {
|
|
7839
|
-
(function(root, factory) {
|
|
7840
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7841
|
-
{
|
|
7842
|
-
// For Node.js.
|
|
7843
|
-
module.exports = factory(root);
|
|
7844
|
-
}
|
|
7845
|
-
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
|
|
7846
|
-
|
|
7847
|
-
if (root.CSS && root.CSS.escape) {
|
|
7848
|
-
return root.CSS.escape;
|
|
7849
|
-
}
|
|
7850
|
-
|
|
7851
|
-
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7852
|
-
var cssEscape = function(value) {
|
|
7853
|
-
if (arguments.length == 0) {
|
|
7854
|
-
throw new TypeError('`CSS.escape` requires an argument.');
|
|
7855
|
-
}
|
|
7856
|
-
var string = String(value);
|
|
7857
|
-
var length = string.length;
|
|
7858
|
-
var index = -1;
|
|
7859
|
-
var codeUnit;
|
|
7860
|
-
var result = '';
|
|
7861
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
7862
|
-
while (++index < length) {
|
|
7863
|
-
codeUnit = string.charCodeAt(index);
|
|
7864
|
-
// Note: there’s no need to special-case astral symbols, surrogate
|
|
7865
|
-
// pairs, or lone surrogates.
|
|
7866
|
-
|
|
7867
|
-
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
7868
|
-
// (U+FFFD).
|
|
7869
|
-
if (codeUnit == 0x0000) {
|
|
7870
|
-
result += '\uFFFD';
|
|
7871
|
-
continue;
|
|
7872
|
-
}
|
|
7873
|
-
|
|
7874
|
-
if (
|
|
7875
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
7876
|
-
// U+007F, […]
|
|
7877
|
-
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
|
7878
|
-
// If the character is the first character and is in the range [0-9]
|
|
7879
|
-
// (U+0030 to U+0039), […]
|
|
7880
|
-
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
|
7881
|
-
// If the character is the second character and is in the range [0-9]
|
|
7882
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
7883
|
-
(
|
|
7884
|
-
index == 1 &&
|
|
7885
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
|
7886
|
-
firstCodeUnit == 0x002D
|
|
7887
|
-
)
|
|
7888
|
-
) {
|
|
7889
|
-
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
7890
|
-
result += '\\' + codeUnit.toString(16) + ' ';
|
|
7891
|
-
continue;
|
|
7892
|
-
}
|
|
7893
|
-
|
|
7894
|
-
if (
|
|
7895
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
7896
|
-
// there is no second character, […]
|
|
7897
|
-
index == 0 &&
|
|
7898
|
-
length == 1 &&
|
|
7899
|
-
codeUnit == 0x002D
|
|
7900
|
-
) {
|
|
7901
|
-
result += '\\' + string.charAt(index);
|
|
7902
|
-
continue;
|
|
7903
|
-
}
|
|
7904
|
-
|
|
7905
|
-
// If the character is not handled by one of the above rules and is
|
|
7906
|
-
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
7907
|
-
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
7908
|
-
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
7909
|
-
if (
|
|
7910
|
-
codeUnit >= 0x0080 ||
|
|
7911
|
-
codeUnit == 0x002D ||
|
|
7912
|
-
codeUnit == 0x005F ||
|
|
7913
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
|
7914
|
-
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
|
7915
|
-
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
|
7916
|
-
) {
|
|
7917
|
-
// the character itself
|
|
7918
|
-
result += string.charAt(index);
|
|
7919
|
-
continue;
|
|
7920
|
-
}
|
|
7921
|
-
|
|
7922
|
-
// Otherwise, the escaped character.
|
|
7923
|
-
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
7924
|
-
result += '\\' + string.charAt(index);
|
|
7925
|
-
|
|
7926
|
-
}
|
|
7927
|
-
return result;
|
|
7928
|
-
};
|
|
7929
|
-
|
|
7930
|
-
if (!root.CSS) {
|
|
7931
|
-
root.CSS = {};
|
|
7932
|
-
}
|
|
7933
|
-
|
|
7934
|
-
root.CSS.escape = cssEscape;
|
|
7935
|
-
return cssEscape;
|
|
7936
|
-
|
|
7937
|
-
}));
|
|
7938
|
-
} (css_escape));
|
|
7935
|
+
/**
|
|
7936
|
+
* @param {string} str
|
|
7937
|
+
* @returns {string}
|
|
7938
|
+
*/
|
|
7939
7939
|
|
|
7940
7940
|
var HTML_ESCAPE_MAP = {
|
|
7941
7941
|
'&': '&',
|
|
@@ -9070,6 +9070,11 @@
|
|
|
9070
9070
|
return value;
|
|
9071
9071
|
}
|
|
9072
9072
|
|
|
9073
|
+
/**
|
|
9074
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
9075
|
+
* @typedef {import('./Styles').default} Styles
|
|
9076
|
+
*/
|
|
9077
|
+
|
|
9073
9078
|
// apply default renderer with lowest possible priority
|
|
9074
9079
|
// so that it only kicks in if noone else could render
|
|
9075
9080
|
var DEFAULT_RENDER_PRIORITY = 1;
|
|
@@ -9187,9 +9192,9 @@
|
|
|
9187
9192
|
/**
|
|
9188
9193
|
* Builds a style definition from a className, a list of traits and an object of additional attributes.
|
|
9189
9194
|
*
|
|
9190
|
-
* @param
|
|
9191
|
-
* @param
|
|
9192
|
-
* @param
|
|
9195
|
+
* @param {string} className
|
|
9196
|
+
* @param {Array<string>} traits
|
|
9197
|
+
* @param {Object} additionalAttrs
|
|
9193
9198
|
*
|
|
9194
9199
|
* @return {Object} the style defintion
|
|
9195
9200
|
*/
|
|
@@ -9202,8 +9207,8 @@
|
|
|
9202
9207
|
/**
|
|
9203
9208
|
* Builds a style definition from a list of traits and an object of additional attributes.
|
|
9204
9209
|
*
|
|
9205
|
-
* @param
|
|
9206
|
-
* @param
|
|
9210
|
+
* @param {Array<string>} traits
|
|
9211
|
+
* @param {Object} additionalAttrs
|
|
9207
9212
|
*
|
|
9208
9213
|
* @return {Object} the style defintion
|
|
9209
9214
|
*/
|
|
@@ -9240,8 +9245,8 @@
|
|
|
9240
9245
|
/**
|
|
9241
9246
|
* Failsafe remove an element from a collection
|
|
9242
9247
|
*
|
|
9243
|
-
* @param
|
|
9244
|
-
* @param
|
|
9248
|
+
* @param {Array<Object>} [collection]
|
|
9249
|
+
* @param {Object} [element]
|
|
9245
9250
|
*
|
|
9246
9251
|
* @return {number} the previous index of the element
|
|
9247
9252
|
*/
|
|
@@ -9311,6 +9316,27 @@
|
|
|
9311
9316
|
}
|
|
9312
9317
|
}
|
|
9313
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
|
+
|
|
9314
9340
|
function round(number, resolution) {
|
|
9315
9341
|
return Math.round(number * resolution) / resolution;
|
|
9316
9342
|
}
|
|
@@ -9331,7 +9357,8 @@
|
|
|
9331
9357
|
* Creates a HTML container element for a SVG element with
|
|
9332
9358
|
* the given configuration
|
|
9333
9359
|
*
|
|
9334
|
-
* @param
|
|
9360
|
+
* @param {CanvasConfig} options
|
|
9361
|
+
*
|
|
9335
9362
|
* @return {HTMLElement} the container element
|
|
9336
9363
|
*/
|
|
9337
9364
|
function createContainer(options) {
|
|
@@ -9391,21 +9418,34 @@
|
|
|
9391
9418
|
*
|
|
9392
9419
|
* @emits Canvas#canvas.init
|
|
9393
9420
|
*
|
|
9394
|
-
* @param {
|
|
9421
|
+
* @param {CanvasConfig|null} config
|
|
9395
9422
|
* @param {EventBus} eventBus
|
|
9396
9423
|
* @param {GraphicsFactory} graphicsFactory
|
|
9397
9424
|
* @param {ElementRegistry} elementRegistry
|
|
9398
9425
|
*/
|
|
9399
9426
|
function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
|
9400
|
-
|
|
9401
9427
|
this._eventBus = eventBus;
|
|
9402
9428
|
this._elementRegistry = elementRegistry;
|
|
9403
9429
|
this._graphicsFactory = graphicsFactory;
|
|
9404
9430
|
|
|
9431
|
+
/**
|
|
9432
|
+
* @type {number}
|
|
9433
|
+
*/
|
|
9405
9434
|
this._rootsIdx = 0;
|
|
9406
9435
|
|
|
9436
|
+
/**
|
|
9437
|
+
* @type {CanvasLayers}
|
|
9438
|
+
*/
|
|
9407
9439
|
this._layers = {};
|
|
9440
|
+
|
|
9441
|
+
/**
|
|
9442
|
+
* @type {CanvasPlane[]}
|
|
9443
|
+
*/
|
|
9408
9444
|
this._planes = [];
|
|
9445
|
+
|
|
9446
|
+
/**
|
|
9447
|
+
* @type {RootLike|null}
|
|
9448
|
+
*/
|
|
9409
9449
|
this._rootElement = null;
|
|
9410
9450
|
|
|
9411
9451
|
this._init(config || {});
|
|
@@ -9430,6 +9470,8 @@
|
|
|
9430
9470
|
* ...
|
|
9431
9471
|
* </svg>
|
|
9432
9472
|
* </div>
|
|
9473
|
+
*
|
|
9474
|
+
* @param {CanvasConfig} config
|
|
9433
9475
|
*/
|
|
9434
9476
|
Canvas.prototype._init = function(config) {
|
|
9435
9477
|
|
|
@@ -9451,7 +9493,7 @@
|
|
|
9451
9493
|
this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
|
|
9452
9494
|
}
|
|
9453
9495
|
|
|
9454
|
-
eventBus.on('diagram.init',
|
|
9496
|
+
eventBus.on('diagram.init', () => {
|
|
9455
9497
|
|
|
9456
9498
|
/**
|
|
9457
9499
|
* An event indicating that the canvas is ready to be drawn on.
|
|
@@ -9469,7 +9511,7 @@
|
|
|
9469
9511
|
viewport: viewport
|
|
9470
9512
|
});
|
|
9471
9513
|
|
|
9472
|
-
}
|
|
9514
|
+
});
|
|
9473
9515
|
|
|
9474
9516
|
// reset viewbox on shape changes to
|
|
9475
9517
|
// recompute the viewbox
|
|
@@ -9480,15 +9522,15 @@
|
|
|
9480
9522
|
'connection.removed',
|
|
9481
9523
|
'elements.changed',
|
|
9482
9524
|
'root.set'
|
|
9483
|
-
],
|
|
9525
|
+
], () => {
|
|
9484
9526
|
delete this._cachedViewbox;
|
|
9485
|
-
}
|
|
9527
|
+
});
|
|
9486
9528
|
|
|
9487
9529
|
eventBus.on('diagram.destroy', 500, this._destroy, this);
|
|
9488
9530
|
eventBus.on('diagram.clear', 500, this._clear, this);
|
|
9489
9531
|
};
|
|
9490
9532
|
|
|
9491
|
-
Canvas.prototype._destroy = function(
|
|
9533
|
+
Canvas.prototype._destroy = function() {
|
|
9492
9534
|
this._eventBus.fire('canvas.destroy', {
|
|
9493
9535
|
svg: this._svg,
|
|
9494
9536
|
viewport: this._viewport
|
|
@@ -9535,7 +9577,7 @@
|
|
|
9535
9577
|
* Returns the default layer on which
|
|
9536
9578
|
* all elements are drawn.
|
|
9537
9579
|
*
|
|
9538
|
-
* @
|
|
9580
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9539
9581
|
*/
|
|
9540
9582
|
Canvas.prototype.getDefaultLayer = function() {
|
|
9541
9583
|
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
@@ -9551,10 +9593,10 @@
|
|
|
9551
9593
|
* A layer with a certain index is always created above all
|
|
9552
9594
|
* existing layers with the same index.
|
|
9553
9595
|
*
|
|
9554
|
-
* @param {string} name
|
|
9555
|
-
* @param {number} index
|
|
9596
|
+
* @param {string} name The name of the layer.
|
|
9597
|
+
* @param {number} [index] The index of the layer.
|
|
9556
9598
|
*
|
|
9557
|
-
* @
|
|
9599
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9558
9600
|
*/
|
|
9559
9601
|
Canvas.prototype.getLayer = function(name, index) {
|
|
9560
9602
|
|
|
@@ -9583,8 +9625,9 @@
|
|
|
9583
9625
|
*
|
|
9584
9626
|
* This is used to determine the node a layer should be inserted at.
|
|
9585
9627
|
*
|
|
9586
|
-
* @param {
|
|
9587
|
-
*
|
|
9628
|
+
* @param {number} index
|
|
9629
|
+
*
|
|
9630
|
+
* @return {number}
|
|
9588
9631
|
*/
|
|
9589
9632
|
Canvas.prototype._getChildIndex = function(index) {
|
|
9590
9633
|
return reduce(this._layers, function(childIndex, layer) {
|
|
@@ -9602,7 +9645,7 @@
|
|
|
9602
9645
|
* @param {string} name
|
|
9603
9646
|
* @param {number} [index=0]
|
|
9604
9647
|
*
|
|
9605
|
-
* @return {
|
|
9648
|
+
* @return {CanvasLayer}
|
|
9606
9649
|
*/
|
|
9607
9650
|
Canvas.prototype._createLayer = function(name, index) {
|
|
9608
9651
|
|
|
@@ -9623,8 +9666,9 @@
|
|
|
9623
9666
|
/**
|
|
9624
9667
|
* Shows a given layer.
|
|
9625
9668
|
*
|
|
9626
|
-
* @param {
|
|
9627
|
-
*
|
|
9669
|
+
* @param {string} layer The name of the layer.
|
|
9670
|
+
*
|
|
9671
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9628
9672
|
*/
|
|
9629
9673
|
Canvas.prototype.showLayer = function(name) {
|
|
9630
9674
|
|
|
@@ -9658,8 +9702,9 @@
|
|
|
9658
9702
|
/**
|
|
9659
9703
|
* Hides a given layer.
|
|
9660
9704
|
*
|
|
9661
|
-
* @param {
|
|
9662
|
-
*
|
|
9705
|
+
* @param {string} layer The name of the layer.
|
|
9706
|
+
*
|
|
9707
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9663
9708
|
*/
|
|
9664
9709
|
Canvas.prototype.hideLayer = function(name) {
|
|
9665
9710
|
|
|
@@ -9701,7 +9746,7 @@
|
|
|
9701
9746
|
/**
|
|
9702
9747
|
* Returns the currently active layer. Can be null.
|
|
9703
9748
|
*
|
|
9704
|
-
* @
|
|
9749
|
+
* @return {CanvasLayer|null} The active layer of `null`.
|
|
9705
9750
|
*/
|
|
9706
9751
|
Canvas.prototype.getActiveLayer = function() {
|
|
9707
9752
|
const plane = this._findPlaneForRoot(this.getRootElement());
|
|
@@ -9717,9 +9762,9 @@
|
|
|
9717
9762
|
/**
|
|
9718
9763
|
* Returns the plane which contains the given element.
|
|
9719
9764
|
*
|
|
9720
|
-
* @param {string
|
|
9765
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9721
9766
|
*
|
|
9722
|
-
* @return {
|
|
9767
|
+
* @return {RootLike|undefined} The root of the element.
|
|
9723
9768
|
*/
|
|
9724
9769
|
Canvas.prototype.findRoot = function(element) {
|
|
9725
9770
|
if (typeof element === 'string') {
|
|
@@ -9740,7 +9785,7 @@
|
|
|
9740
9785
|
/**
|
|
9741
9786
|
* Return a list of all root elements on the diagram.
|
|
9742
9787
|
*
|
|
9743
|
-
* @return {
|
|
9788
|
+
* @return {(RootLike)[]} The list of root elements.
|
|
9744
9789
|
*/
|
|
9745
9790
|
Canvas.prototype.getRootElements = function() {
|
|
9746
9791
|
return this._planes.map(function(plane) {
|
|
@@ -9759,7 +9804,7 @@
|
|
|
9759
9804
|
* Returns the html element that encloses the
|
|
9760
9805
|
* drawing canvas.
|
|
9761
9806
|
*
|
|
9762
|
-
* @return {
|
|
9807
|
+
* @return {HTMLElement} The HTML element of the container.
|
|
9763
9808
|
*/
|
|
9764
9809
|
Canvas.prototype.getContainer = function() {
|
|
9765
9810
|
return this._container;
|
|
@@ -9799,8 +9844,8 @@
|
|
|
9799
9844
|
*
|
|
9800
9845
|
* @event element.marker.update
|
|
9801
9846
|
* @type {Object}
|
|
9802
|
-
* @property {
|
|
9803
|
-
* @property {
|
|
9847
|
+
* @property {Base} element the shape
|
|
9848
|
+
* @property {SVGElement} gfx the graphical representation of the shape
|
|
9804
9849
|
* @property {string} marker
|
|
9805
9850
|
* @property {boolean} add true if the marker was added, false if it got removed
|
|
9806
9851
|
*/
|
|
@@ -9815,14 +9860,15 @@
|
|
|
9815
9860
|
* integrate extension into the marker life-cycle, too.
|
|
9816
9861
|
*
|
|
9817
9862
|
* @example
|
|
9863
|
+
*
|
|
9818
9864
|
* canvas.addMarker('foo', 'some-marker');
|
|
9819
9865
|
*
|
|
9820
9866
|
* const fooGfx = canvas.getGraphics('foo');
|
|
9821
9867
|
*
|
|
9822
9868
|
* fooGfx; // <g class="... some-marker"> ... </g>
|
|
9823
9869
|
*
|
|
9824
|
-
* @param {string
|
|
9825
|
-
* @param {string} marker
|
|
9870
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9871
|
+
* @param {string} marker The marker.
|
|
9826
9872
|
*/
|
|
9827
9873
|
Canvas.prototype.addMarker = function(element, marker) {
|
|
9828
9874
|
this._updateMarker(element, marker, true);
|
|
@@ -9835,18 +9881,18 @@
|
|
|
9835
9881
|
* Fires the element.marker.update event, making it possible to
|
|
9836
9882
|
* integrate extension into the marker life-cycle, too.
|
|
9837
9883
|
*
|
|
9838
|
-
* @param
|
|
9839
|
-
* @param
|
|
9884
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9885
|
+
* @param {string} marker The marker.
|
|
9840
9886
|
*/
|
|
9841
9887
|
Canvas.prototype.removeMarker = function(element, marker) {
|
|
9842
9888
|
this._updateMarker(element, marker, false);
|
|
9843
9889
|
};
|
|
9844
9890
|
|
|
9845
9891
|
/**
|
|
9846
|
-
* Check
|
|
9892
|
+
* Check whether an element has a given marker.
|
|
9847
9893
|
*
|
|
9848
|
-
* @param
|
|
9849
|
-
* @param
|
|
9894
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9895
|
+
* @param {string} marker The marker.
|
|
9850
9896
|
*/
|
|
9851
9897
|
Canvas.prototype.hasMarker = function(element, marker) {
|
|
9852
9898
|
if (!element.id) {
|
|
@@ -9864,8 +9910,8 @@
|
|
|
9864
9910
|
* Fires the element.marker.update event, making it possible to
|
|
9865
9911
|
* integrate extension into the marker life-cycle, too.
|
|
9866
9912
|
*
|
|
9867
|
-
* @param
|
|
9868
|
-
* @param
|
|
9913
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9914
|
+
* @param {string} marker The marker.
|
|
9869
9915
|
*/
|
|
9870
9916
|
Canvas.prototype.toggleMarker = function(element, marker) {
|
|
9871
9917
|
if (this.hasMarker(element, marker)) {
|
|
@@ -9888,7 +9934,7 @@
|
|
|
9888
9934
|
* root elements can be null. This is used for applications that want to manage
|
|
9889
9935
|
* root elements themselves.
|
|
9890
9936
|
*
|
|
9891
|
-
* @
|
|
9937
|
+
* @return {RootLike} The current root element.
|
|
9892
9938
|
*/
|
|
9893
9939
|
Canvas.prototype.getRootElement = function() {
|
|
9894
9940
|
const rootElement = this._rootElement;
|
|
@@ -9904,11 +9950,10 @@
|
|
|
9904
9950
|
/**
|
|
9905
9951
|
* Adds a given root element and returns it.
|
|
9906
9952
|
*
|
|
9907
|
-
* @param {
|
|
9953
|
+
* @param {ShapeLike} [rootElement] The root element to be added.
|
|
9908
9954
|
*
|
|
9909
|
-
* @return {
|
|
9955
|
+
* @return {RootLike} The added root element or an implicit root element.
|
|
9910
9956
|
*/
|
|
9911
|
-
|
|
9912
9957
|
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9913
9958
|
const idx = this._rootsIdx++;
|
|
9914
9959
|
|
|
@@ -9939,11 +9984,11 @@
|
|
|
9939
9984
|
};
|
|
9940
9985
|
|
|
9941
9986
|
/**
|
|
9942
|
-
* Removes a given
|
|
9987
|
+
* Removes a given root element and returns it.
|
|
9943
9988
|
*
|
|
9944
|
-
* @param {
|
|
9989
|
+
* @param {ShapeLike|string} rootElement The root element or its ID.
|
|
9945
9990
|
*
|
|
9946
|
-
* @return {
|
|
9991
|
+
* @return {ShapeLike|undefined} The removed root element.
|
|
9947
9992
|
*/
|
|
9948
9993
|
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
9949
9994
|
|
|
@@ -9977,15 +10022,13 @@
|
|
|
9977
10022
|
};
|
|
9978
10023
|
|
|
9979
10024
|
|
|
9980
|
-
// root element handling //////////////////////
|
|
9981
|
-
|
|
9982
10025
|
/**
|
|
9983
10026
|
* Sets a given element as the new root element for the canvas
|
|
9984
10027
|
* and returns the new root element.
|
|
9985
10028
|
*
|
|
9986
|
-
* @param {
|
|
10029
|
+
* @param {RootLike} rootElement The root element to be set.
|
|
9987
10030
|
*
|
|
9988
|
-
* @return {
|
|
10031
|
+
* @return {RootLike} The set root element.
|
|
9989
10032
|
*/
|
|
9990
10033
|
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
9991
10034
|
|
|
@@ -10072,8 +10115,6 @@
|
|
|
10072
10115
|
this._eventBus.fire('root.set', { element: rootElement });
|
|
10073
10116
|
};
|
|
10074
10117
|
|
|
10075
|
-
// add functionality //////////////////////
|
|
10076
|
-
|
|
10077
10118
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
10078
10119
|
if (!element.id) {
|
|
10079
10120
|
throw new Error('element must have an id');
|
|
@@ -10114,11 +10155,11 @@
|
|
|
10114
10155
|
* Extensions may hook into these events to perform their magic.
|
|
10115
10156
|
*
|
|
10116
10157
|
* @param {string} type
|
|
10117
|
-
* @param {
|
|
10118
|
-
* @param {
|
|
10158
|
+
* @param {ConnectionLike|ShapeLike} element
|
|
10159
|
+
* @param {ShapeLike} [parent]
|
|
10119
10160
|
* @param {number} [parentIndex]
|
|
10120
10161
|
*
|
|
10121
|
-
* @return {
|
|
10162
|
+
* @return {ConnectionLike|ShapeLike} The added element.
|
|
10122
10163
|
*/
|
|
10123
10164
|
Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
|
10124
10165
|
|
|
@@ -10147,26 +10188,26 @@
|
|
|
10147
10188
|
};
|
|
10148
10189
|
|
|
10149
10190
|
/**
|
|
10150
|
-
* Adds a shape to the canvas
|
|
10191
|
+
* Adds a shape to the canvas.
|
|
10151
10192
|
*
|
|
10152
|
-
* @param {
|
|
10153
|
-
* @param {
|
|
10154
|
-
* @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.
|
|
10155
10196
|
*
|
|
10156
|
-
* @return {
|
|
10197
|
+
* @return {ShapeLike} The added shape.
|
|
10157
10198
|
*/
|
|
10158
10199
|
Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
|
10159
10200
|
return this._addElement('shape', shape, parent, parentIndex);
|
|
10160
10201
|
};
|
|
10161
10202
|
|
|
10162
10203
|
/**
|
|
10163
|
-
* Adds a connection to the canvas
|
|
10204
|
+
* Adds a connection to the canvas.
|
|
10164
10205
|
*
|
|
10165
|
-
* @param {
|
|
10166
|
-
* @param {
|
|
10167
|
-
* @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.
|
|
10168
10209
|
*
|
|
10169
|
-
* @return {
|
|
10210
|
+
* @return {ConnectionLike} The added connection.
|
|
10170
10211
|
*/
|
|
10171
10212
|
Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
|
10172
10213
|
return this._addElement('connection', connection, parent, parentIndex);
|
|
@@ -10207,11 +10248,14 @@
|
|
|
10207
10248
|
|
|
10208
10249
|
|
|
10209
10250
|
/**
|
|
10210
|
-
* Removes a shape from the canvas
|
|
10251
|
+
* Removes a shape from the canvas.
|
|
10211
10252
|
*
|
|
10212
|
-
* @
|
|
10253
|
+
* @fires ShapeRemoveEvent
|
|
10254
|
+
* @fires ShapeRemovedEvent
|
|
10213
10255
|
*
|
|
10214
|
-
* @
|
|
10256
|
+
* @param {ShapeLike|string} shape The shape or its ID.
|
|
10257
|
+
*
|
|
10258
|
+
* @return {ShapeLike} The removed shape.
|
|
10215
10259
|
*/
|
|
10216
10260
|
Canvas.prototype.removeShape = function(shape) {
|
|
10217
10261
|
|
|
@@ -10220,10 +10264,10 @@
|
|
|
10220
10264
|
*
|
|
10221
10265
|
* @memberOf Canvas
|
|
10222
10266
|
*
|
|
10223
|
-
* @event
|
|
10267
|
+
* @event ShapeRemoveEvent
|
|
10224
10268
|
* @type {Object}
|
|
10225
|
-
* @property {
|
|
10226
|
-
* @property {
|
|
10269
|
+
* @property {ShapeLike} element The shape.
|
|
10270
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10227
10271
|
*/
|
|
10228
10272
|
|
|
10229
10273
|
/**
|
|
@@ -10231,21 +10275,24 @@
|
|
|
10231
10275
|
*
|
|
10232
10276
|
* @memberOf Canvas
|
|
10233
10277
|
*
|
|
10234
|
-
* @event
|
|
10278
|
+
* @event ShapeRemoved
|
|
10235
10279
|
* @type {Object}
|
|
10236
|
-
* @property {
|
|
10237
|
-
* @property {
|
|
10280
|
+
* @property {ShapeLike} element The shape.
|
|
10281
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10238
10282
|
*/
|
|
10239
10283
|
return this._removeElement(shape, 'shape');
|
|
10240
10284
|
};
|
|
10241
10285
|
|
|
10242
10286
|
|
|
10243
10287
|
/**
|
|
10244
|
-
* Removes a connection from the canvas
|
|
10288
|
+
* Removes a connection from the canvas.
|
|
10289
|
+
*
|
|
10290
|
+
* @fires ConnectionRemoveEvent
|
|
10291
|
+
* @fires ConnectionRemovedEvent
|
|
10245
10292
|
*
|
|
10246
|
-
* @param {string
|
|
10293
|
+
* @param {ConnectionLike|string} connection The connection or its ID.
|
|
10247
10294
|
*
|
|
10248
|
-
* @return {
|
|
10295
|
+
* @return {ConnectionLike} The removed connection.
|
|
10249
10296
|
*/
|
|
10250
10297
|
Canvas.prototype.removeConnection = function(connection) {
|
|
10251
10298
|
|
|
@@ -10254,10 +10301,10 @@
|
|
|
10254
10301
|
*
|
|
10255
10302
|
* @memberOf Canvas
|
|
10256
10303
|
*
|
|
10257
|
-
* @event
|
|
10304
|
+
* @event ConnectionRemoveEvent
|
|
10258
10305
|
* @type {Object}
|
|
10259
|
-
* @property {
|
|
10260
|
-
* @property {
|
|
10306
|
+
* @property {ConnectionLike} element The connection.
|
|
10307
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10261
10308
|
*/
|
|
10262
10309
|
|
|
10263
10310
|
/**
|
|
@@ -10267,20 +10314,20 @@
|
|
|
10267
10314
|
*
|
|
10268
10315
|
* @event connection.removed
|
|
10269
10316
|
* @type {Object}
|
|
10270
|
-
* @property {
|
|
10271
|
-
* @property {
|
|
10317
|
+
* @property {ConnectionLike} element The connection.
|
|
10318
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10272
10319
|
*/
|
|
10273
10320
|
return this._removeElement(connection, 'connection');
|
|
10274
10321
|
};
|
|
10275
10322
|
|
|
10276
10323
|
|
|
10277
10324
|
/**
|
|
10278
|
-
*
|
|
10325
|
+
* Returns the graphical element of an element.
|
|
10279
10326
|
*
|
|
10280
|
-
* @param {string
|
|
10281
|
-
* @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.
|
|
10282
10329
|
*
|
|
10283
|
-
* @return {SVGElement}
|
|
10330
|
+
* @return {SVGElement} The graphical element.
|
|
10284
10331
|
*/
|
|
10285
10332
|
Canvas.prototype.getGraphics = function(element, secondary) {
|
|
10286
10333
|
return this._elementRegistry.getGraphics(element, secondary);
|
|
@@ -10352,13 +10399,9 @@
|
|
|
10352
10399
|
* height: zoomedAndScrolledViewbox.outer.height
|
|
10353
10400
|
* });
|
|
10354
10401
|
*
|
|
10355
|
-
* @param
|
|
10356
|
-
* @param {number} box.x the top left X coordinate of the canvas visible in view box
|
|
10357
|
-
* @param {number} box.y the top left Y coordinate of the canvas visible in view box
|
|
10358
|
-
* @param {number} box.width the visible width
|
|
10359
|
-
* @param {number} box.height
|
|
10402
|
+
* @param {Rect} [box] The viewbox to be set.
|
|
10360
10403
|
*
|
|
10361
|
-
* @return {
|
|
10404
|
+
* @return {CanvasViewbox} The set viewbox.
|
|
10362
10405
|
*/
|
|
10363
10406
|
Canvas.prototype.viewbox = function(box) {
|
|
10364
10407
|
|
|
@@ -10427,10 +10470,9 @@
|
|
|
10427
10470
|
/**
|
|
10428
10471
|
* Gets or sets the scroll of the canvas.
|
|
10429
10472
|
*
|
|
10430
|
-
* @param {
|
|
10473
|
+
* @param {Point} [delta] The scroll to be set.
|
|
10431
10474
|
*
|
|
10432
|
-
* @
|
|
10433
|
-
* @param {number} [delta.dy]
|
|
10475
|
+
* @return {Point}
|
|
10434
10476
|
*/
|
|
10435
10477
|
Canvas.prototype.scroll = function(delta) {
|
|
10436
10478
|
|
|
@@ -10454,9 +10496,8 @@
|
|
|
10454
10496
|
* Scrolls the viewbox to contain the given element.
|
|
10455
10497
|
* Optionally specify a padding to be applied to the edges.
|
|
10456
10498
|
*
|
|
10457
|
-
* @param {
|
|
10458
|
-
* @param {
|
|
10459
|
-
*
|
|
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.
|
|
10460
10501
|
*/
|
|
10461
10502
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
10462
10503
|
let defaultPadding = 100;
|
|
@@ -10524,17 +10565,17 @@
|
|
|
10524
10565
|
};
|
|
10525
10566
|
|
|
10526
10567
|
/**
|
|
10527
|
-
* Gets or sets the current zoom of the canvas, optionally zooming
|
|
10528
|
-
*
|
|
10568
|
+
* Gets or sets the current zoom of the canvas, optionally zooming to the
|
|
10569
|
+
* specified position.
|
|
10529
10570
|
*
|
|
10530
|
-
* The getter may return a cached zoom level. Call it with `false` as
|
|
10531
|
-
*
|
|
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.
|
|
10532
10573
|
*
|
|
10533
|
-
* @param {string
|
|
10534
|
-
*
|
|
10535
|
-
* @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.
|
|
10536
10577
|
*
|
|
10537
|
-
* @return {number}
|
|
10578
|
+
* @return {number} The set zoom level.
|
|
10538
10579
|
*/
|
|
10539
10580
|
Canvas.prototype.zoom = function(newScale, center) {
|
|
10540
10581
|
|
|
@@ -10657,9 +10698,9 @@
|
|
|
10657
10698
|
|
|
10658
10699
|
|
|
10659
10700
|
/**
|
|
10660
|
-
* Returns the size of the canvas
|
|
10701
|
+
* Returns the size of the canvas.
|
|
10661
10702
|
*
|
|
10662
|
-
* @return {Dimensions}
|
|
10703
|
+
* @return {Dimensions} The size of the canvas.
|
|
10663
10704
|
*/
|
|
10664
10705
|
Canvas.prototype.getSize = function() {
|
|
10665
10706
|
return {
|
|
@@ -10670,14 +10711,14 @@
|
|
|
10670
10711
|
|
|
10671
10712
|
|
|
10672
10713
|
/**
|
|
10673
|
-
*
|
|
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.
|
|
10674
10718
|
*
|
|
10675
|
-
*
|
|
10676
|
-
* callers (browser) coordinate system rather than the zoomed in/out
|
|
10677
|
-
* canvas coordinates.
|
|
10719
|
+
* @param {ShapeLike|ConnectionLike} element The element.
|
|
10678
10720
|
*
|
|
10679
|
-
* @
|
|
10680
|
-
* @return {Bounds} the absolute bounding box
|
|
10721
|
+
* @return {Rect} The element's absolute bounding box.
|
|
10681
10722
|
*/
|
|
10682
10723
|
Canvas.prototype.getAbsoluteBBox = function(element) {
|
|
10683
10724
|
const vbox = this.viewbox();
|
|
@@ -10712,8 +10753,7 @@
|
|
|
10712
10753
|
};
|
|
10713
10754
|
|
|
10714
10755
|
/**
|
|
10715
|
-
* Fires an event
|
|
10716
|
-
* canvas resizing
|
|
10756
|
+
* Fires an event so other modules can react to the canvas resizing.
|
|
10717
10757
|
*/
|
|
10718
10758
|
Canvas.prototype.resized = function() {
|
|
10719
10759
|
|
|
@@ -10725,11 +10765,21 @@
|
|
|
10725
10765
|
|
|
10726
10766
|
var ELEMENT_ID = 'data-element-id';
|
|
10727
10767
|
|
|
10768
|
+
/**
|
|
10769
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
10770
|
+
*
|
|
10771
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
10772
|
+
*
|
|
10773
|
+
* @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
|
|
10774
|
+
*/
|
|
10728
10775
|
|
|
10729
10776
|
/**
|
|
10777
|
+
* A registry that keeps track of all shapes in the diagram.
|
|
10778
|
+
*
|
|
10730
10779
|
* @class
|
|
10780
|
+
* @constructor
|
|
10731
10781
|
*
|
|
10732
|
-
*
|
|
10782
|
+
* @param {EventBus} eventBus
|
|
10733
10783
|
*/
|
|
10734
10784
|
function ElementRegistry(eventBus) {
|
|
10735
10785
|
this._elements = {};
|
|
@@ -10740,11 +10790,11 @@
|
|
|
10740
10790
|
ElementRegistry.$inject = [ 'eventBus' ];
|
|
10741
10791
|
|
|
10742
10792
|
/**
|
|
10743
|
-
*
|
|
10793
|
+
* Add an element and its graphical representation(s) to the registry.
|
|
10744
10794
|
*
|
|
10745
|
-
* @param {
|
|
10746
|
-
* @param {SVGElement} gfx
|
|
10747
|
-
* @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.
|
|
10748
10798
|
*/
|
|
10749
10799
|
ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
|
10750
10800
|
|
|
@@ -10763,9 +10813,9 @@
|
|
|
10763
10813
|
};
|
|
10764
10814
|
|
|
10765
10815
|
/**
|
|
10766
|
-
*
|
|
10816
|
+
* Remove an element from the registry.
|
|
10767
10817
|
*
|
|
10768
|
-
* @param {string
|
|
10818
|
+
* @param {ElementLike|string} element
|
|
10769
10819
|
*/
|
|
10770
10820
|
ElementRegistry.prototype.remove = function(element) {
|
|
10771
10821
|
var elements = this._elements,
|
|
@@ -10786,10 +10836,10 @@
|
|
|
10786
10836
|
};
|
|
10787
10837
|
|
|
10788
10838
|
/**
|
|
10789
|
-
* Update
|
|
10839
|
+
* Update an elements ID.
|
|
10790
10840
|
*
|
|
10791
|
-
* @param {string
|
|
10792
|
-
* @param {string} newId
|
|
10841
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10842
|
+
* @param {string} newId The new ID.
|
|
10793
10843
|
*/
|
|
10794
10844
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
10795
10845
|
|
|
@@ -10815,11 +10865,11 @@
|
|
|
10815
10865
|
};
|
|
10816
10866
|
|
|
10817
10867
|
/**
|
|
10818
|
-
* Update the
|
|
10868
|
+
* Update the graphical representation of an element.
|
|
10819
10869
|
*
|
|
10820
|
-
* @param {string
|
|
10821
|
-
* @param {SVGElement} gfx
|
|
10822
|
-
* @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.
|
|
10823
10873
|
*/
|
|
10824
10874
|
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
10825
10875
|
var id = filter.id || filter;
|
|
@@ -10840,17 +10890,17 @@
|
|
|
10840
10890
|
};
|
|
10841
10891
|
|
|
10842
10892
|
/**
|
|
10843
|
-
*
|
|
10893
|
+
* Get the element with the given ID or graphical representation.
|
|
10844
10894
|
*
|
|
10845
10895
|
* @example
|
|
10846
10896
|
*
|
|
10847
10897
|
* elementRegistry.get('SomeElementId_1');
|
|
10848
|
-
* elementRegistry.get(gfx);
|
|
10849
10898
|
*
|
|
10899
|
+
* elementRegistry.get(gfx);
|
|
10850
10900
|
*
|
|
10851
|
-
* @param {string|SVGElement} filter
|
|
10901
|
+
* @param {string|SVGElement} filter The elements ID or graphical representation.
|
|
10852
10902
|
*
|
|
10853
|
-
* @return {
|
|
10903
|
+
* @return {ElementLike|undefined} The element.
|
|
10854
10904
|
*/
|
|
10855
10905
|
ElementRegistry.prototype.get = function(filter) {
|
|
10856
10906
|
var id;
|
|
@@ -10868,9 +10918,9 @@
|
|
|
10868
10918
|
/**
|
|
10869
10919
|
* Return all elements that match a given filter function.
|
|
10870
10920
|
*
|
|
10871
|
-
* @param {
|
|
10921
|
+
* @param {ElementRegistryCallback} fn The filter function.
|
|
10872
10922
|
*
|
|
10873
|
-
* @return {
|
|
10923
|
+
* @return {ElementLike[]} The matching elements.
|
|
10874
10924
|
*/
|
|
10875
10925
|
ElementRegistry.prototype.filter = function(fn) {
|
|
10876
10926
|
|
|
@@ -10886,11 +10936,11 @@
|
|
|
10886
10936
|
};
|
|
10887
10937
|
|
|
10888
10938
|
/**
|
|
10889
|
-
* Return the first element that
|
|
10939
|
+
* Return the first element that matches the given filter function.
|
|
10890
10940
|
*
|
|
10891
|
-
* @param {Function} fn
|
|
10941
|
+
* @param {Function} fn The filter function.
|
|
10892
10942
|
*
|
|
10893
|
-
* @return {
|
|
10943
|
+
* @return {ElementLike|undefined} The matching element.
|
|
10894
10944
|
*/
|
|
10895
10945
|
ElementRegistry.prototype.find = function(fn) {
|
|
10896
10946
|
var map = this._elements,
|
|
@@ -10909,18 +10959,18 @@
|
|
|
10909
10959
|
};
|
|
10910
10960
|
|
|
10911
10961
|
/**
|
|
10912
|
-
*
|
|
10962
|
+
* Get all elements.
|
|
10913
10963
|
*
|
|
10914
|
-
* @return {
|
|
10964
|
+
* @return {ElementLike[]} All elements.
|
|
10915
10965
|
*/
|
|
10916
10966
|
ElementRegistry.prototype.getAll = function() {
|
|
10917
10967
|
return this.filter(function(e) { return e; });
|
|
10918
10968
|
};
|
|
10919
10969
|
|
|
10920
10970
|
/**
|
|
10921
|
-
*
|
|
10971
|
+
* Execute a given function for each element.
|
|
10922
10972
|
*
|
|
10923
|
-
* @param {Function} fn
|
|
10973
|
+
* @param {Function} fn The function to execute.
|
|
10924
10974
|
*/
|
|
10925
10975
|
ElementRegistry.prototype.forEach = function(fn) {
|
|
10926
10976
|
|
|
@@ -10936,19 +10986,20 @@
|
|
|
10936
10986
|
};
|
|
10937
10987
|
|
|
10938
10988
|
/**
|
|
10939
|
-
* Return the graphical representation of an element
|
|
10989
|
+
* Return the graphical representation of an element.
|
|
10940
10990
|
*
|
|
10941
10991
|
* @example
|
|
10992
|
+
*
|
|
10942
10993
|
* elementRegistry.getGraphics('SomeElementId_1');
|
|
10994
|
+
*
|
|
10943
10995
|
* elementRegistry.getGraphics(rootElement); // <g ...>
|
|
10944
10996
|
*
|
|
10945
10997
|
* elementRegistry.getGraphics(rootElement, true); // <svg ...>
|
|
10946
10998
|
*
|
|
10999
|
+
* @param {ElementLike|string} filter The element or its ID.
|
|
11000
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
|
|
10947
11001
|
*
|
|
10948
|
-
* @
|
|
10949
|
-
* @param {boolean} [secondary=false] whether to return the secondary connected element
|
|
10950
|
-
*
|
|
10951
|
-
* @return {SVGElement}
|
|
11002
|
+
* @return {SVGElement} The graphical representation.
|
|
10952
11003
|
*/
|
|
10953
11004
|
ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
|
10954
11005
|
var id = filter.id || filter;
|
|
@@ -10958,12 +11009,11 @@
|
|
|
10958
11009
|
};
|
|
10959
11010
|
|
|
10960
11011
|
/**
|
|
10961
|
-
* Validate
|
|
10962
|
-
* with an exception.
|
|
11012
|
+
* Validate an ID and throw an error if invalid.
|
|
10963
11013
|
*
|
|
10964
11014
|
* @param {string} id
|
|
10965
11015
|
*
|
|
10966
|
-
* @throws {Error}
|
|
11016
|
+
* @throws {Error} Error indicating that the ID is invalid or already assigned.
|
|
10967
11017
|
*/
|
|
10968
11018
|
ElementRegistry.prototype._validateId = function(id) {
|
|
10969
11019
|
if (!id) {
|
|
@@ -11303,14 +11353,6 @@
|
|
|
11303
11353
|
outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
|
11304
11354
|
incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
|
|
11305
11355
|
|
|
11306
|
-
/**
|
|
11307
|
-
* @namespace djs.model
|
|
11308
|
-
*/
|
|
11309
|
-
|
|
11310
|
-
/**
|
|
11311
|
-
* @memberOf djs.model
|
|
11312
|
-
*/
|
|
11313
|
-
|
|
11314
11356
|
/**
|
|
11315
11357
|
* The basic graphical representation
|
|
11316
11358
|
*
|
|
@@ -11507,21 +11549,47 @@
|
|
|
11507
11549
|
};
|
|
11508
11550
|
|
|
11509
11551
|
/**
|
|
11510
|
-
* Creates a
|
|
11552
|
+
* Creates a model element of the given type.
|
|
11511
11553
|
*
|
|
11512
11554
|
* @method create
|
|
11513
11555
|
*
|
|
11514
11556
|
* @example
|
|
11515
11557
|
*
|
|
11516
|
-
*
|
|
11517
|
-
*
|
|
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
|
+
* });
|
|
11518
11581
|
*
|
|
11519
|
-
*
|
|
11582
|
+
* const shape = Model.create('shape', {
|
|
11583
|
+
* x: 100,
|
|
11584
|
+
* y: 100,
|
|
11585
|
+
* width: 100,
|
|
11586
|
+
* height: 100
|
|
11587
|
+
* });
|
|
11520
11588
|
*
|
|
11521
|
-
* @param
|
|
11522
|
-
* @param
|
|
11589
|
+
* @param {string} type The type of model element to be created.
|
|
11590
|
+
* @param {Object} attrs Attributes to create the model element with.
|
|
11523
11591
|
*
|
|
11524
|
-
* @return {
|
|
11592
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11525
11593
|
*/
|
|
11526
11594
|
function create(type, attrs) {
|
|
11527
11595
|
var Type = types$7[type];
|
|
@@ -11532,36 +11600,78 @@
|
|
|
11532
11600
|
}
|
|
11533
11601
|
|
|
11534
11602
|
/**
|
|
11535
|
-
*
|
|
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
|
|
11536
11619
|
*/
|
|
11537
11620
|
function ElementFactory() {
|
|
11538
11621
|
this._uid = 12;
|
|
11539
11622
|
}
|
|
11540
11623
|
|
|
11541
|
-
|
|
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
|
+
*/
|
|
11542
11631
|
ElementFactory.prototype.createRoot = function(attrs) {
|
|
11543
11632
|
return this.create('root', attrs);
|
|
11544
11633
|
};
|
|
11545
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
|
+
*/
|
|
11546
11642
|
ElementFactory.prototype.createLabel = function(attrs) {
|
|
11547
11643
|
return this.create('label', attrs);
|
|
11548
11644
|
};
|
|
11549
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
|
+
*/
|
|
11550
11653
|
ElementFactory.prototype.createShape = function(attrs) {
|
|
11551
11654
|
return this.create('shape', attrs);
|
|
11552
11655
|
};
|
|
11553
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
|
+
*/
|
|
11554
11664
|
ElementFactory.prototype.createConnection = function(attrs) {
|
|
11555
11665
|
return this.create('connection', attrs);
|
|
11556
11666
|
};
|
|
11557
11667
|
|
|
11558
11668
|
/**
|
|
11559
|
-
* Create a model element
|
|
11560
|
-
* a number of pre-set attributes.
|
|
11669
|
+
* Create a model element of the given type with the given attributes.
|
|
11561
11670
|
*
|
|
11562
|
-
* @param
|
|
11563
|
-
* @param
|
|
11564
|
-
*
|
|
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.
|
|
11565
11675
|
*/
|
|
11566
11676
|
ElementFactory.prototype.create = function(type, attrs) {
|
|
11567
11677
|
|
|
@@ -11580,6 +11690,16 @@
|
|
|
11580
11690
|
|
|
11581
11691
|
var slice = Array.prototype.slice;
|
|
11582
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
|
+
|
|
11583
11703
|
/**
|
|
11584
11704
|
* A general purpose event bus.
|
|
11585
11705
|
*
|
|
@@ -11684,10 +11804,10 @@
|
|
|
11684
11804
|
*
|
|
11685
11805
|
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
11686
11806
|
*
|
|
11687
|
-
* @param {string|
|
|
11688
|
-
* @param {number} [priority=1000]
|
|
11689
|
-
* @param {
|
|
11690
|
-
* @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.
|
|
11691
11811
|
*/
|
|
11692
11812
|
EventBus.prototype.on = function(events, priority, callback, that) {
|
|
11693
11813
|
|
|
@@ -11727,12 +11847,12 @@
|
|
|
11727
11847
|
|
|
11728
11848
|
|
|
11729
11849
|
/**
|
|
11730
|
-
* Register an event listener that is
|
|
11850
|
+
* Register an event listener that is called only once.
|
|
11731
11851
|
*
|
|
11732
|
-
* @param {string} event
|
|
11733
|
-
* @param {number} [priority=1000]
|
|
11734
|
-
* @param {
|
|
11735
|
-
* @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.
|
|
11736
11856
|
*/
|
|
11737
11857
|
EventBus.prototype.once = function(event, priority, callback, that) {
|
|
11738
11858
|
var self = this;
|
|
@@ -11771,8 +11891,8 @@
|
|
|
11771
11891
|
*
|
|
11772
11892
|
* If no callback is given, all listeners for a given event name are being removed.
|
|
11773
11893
|
*
|
|
11774
|
-
* @param {string|
|
|
11775
|
-
* @param {
|
|
11894
|
+
* @param {string|string[]} events The events.
|
|
11895
|
+
* @param {EventCallback} [callback] The callback.
|
|
11776
11896
|
*/
|
|
11777
11897
|
EventBus.prototype.off = function(events, callback) {
|
|
11778
11898
|
|
|
@@ -11788,11 +11908,11 @@
|
|
|
11788
11908
|
|
|
11789
11909
|
|
|
11790
11910
|
/**
|
|
11791
|
-
* Create an
|
|
11911
|
+
* Create an event recognized be the event bus.
|
|
11792
11912
|
*
|
|
11793
|
-
* @param {Object} data
|
|
11913
|
+
* @param {Object} data Event data.
|
|
11794
11914
|
*
|
|
11795
|
-
* @return {
|
|
11915
|
+
* @return {Event} An event that will be recognized by the event bus.
|
|
11796
11916
|
*/
|
|
11797
11917
|
EventBus.prototype.createEvent = function(data) {
|
|
11798
11918
|
var event = new InternalEvent();
|
|
@@ -11804,7 +11924,7 @@
|
|
|
11804
11924
|
|
|
11805
11925
|
|
|
11806
11926
|
/**
|
|
11807
|
-
* Fires
|
|
11927
|
+
* Fires an event.
|
|
11808
11928
|
*
|
|
11809
11929
|
* @example
|
|
11810
11930
|
*
|
|
@@ -11826,12 +11946,11 @@
|
|
|
11826
11946
|
*
|
|
11827
11947
|
* events.fire({ type: 'foo' }, 'I am bar!');
|
|
11828
11948
|
*
|
|
11829
|
-
* @param {string} [
|
|
11830
|
-
* @param {Object} [
|
|
11831
|
-
* @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.
|
|
11832
11952
|
*
|
|
11833
|
-
* @return {
|
|
11834
|
-
* default action was prevented by listeners
|
|
11953
|
+
* @return {*} The return value. Will be set to `false` if the default was prevented.
|
|
11835
11954
|
*/
|
|
11836
11955
|
EventBus.prototype.fire = function(type, data) {
|
|
11837
11956
|
var event,
|
|
@@ -11896,7 +12015,13 @@
|
|
|
11896
12015
|
return returnValue;
|
|
11897
12016
|
};
|
|
11898
12017
|
|
|
11899
|
-
|
|
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
|
+
*/
|
|
11900
12025
|
EventBus.prototype.handleError = function(error) {
|
|
11901
12026
|
return this.fire('error', { error: error }) === false;
|
|
11902
12027
|
};
|
|
@@ -11959,7 +12084,7 @@
|
|
|
11959
12084
|
return returnValue;
|
|
11960
12085
|
};
|
|
11961
12086
|
|
|
11962
|
-
|
|
12087
|
+
/**
|
|
11963
12088
|
* Add new listener with a certain priority to the list
|
|
11964
12089
|
* of listeners (for the given event).
|
|
11965
12090
|
*
|
|
@@ -11973,7 +12098,7 @@
|
|
|
11973
12098
|
* * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
|
|
11974
12099
|
*
|
|
11975
12100
|
* @param {string} event
|
|
11976
|
-
* @param {
|
|
12101
|
+
* @param {EventListener} listener
|
|
11977
12102
|
*/
|
|
11978
12103
|
EventBus.prototype._addListener = function(event, newListener) {
|
|
11979
12104
|
|
|
@@ -12079,9 +12204,9 @@
|
|
|
12079
12204
|
* Invoke function. Be fast...
|
|
12080
12205
|
*
|
|
12081
12206
|
* @param {Function} fn
|
|
12082
|
-
* @param {
|
|
12207
|
+
* @param {*[]} args
|
|
12083
12208
|
*
|
|
12084
|
-
* @return {
|
|
12209
|
+
* @return {*}
|
|
12085
12210
|
*/
|
|
12086
12211
|
function invokeFunction(fn, args) {
|
|
12087
12212
|
return fn.apply(null, args);
|
|
@@ -12095,11 +12220,11 @@
|
|
|
12095
12220
|
*/
|
|
12096
12221
|
|
|
12097
12222
|
/**
|
|
12098
|
-
* Returns the visual part of a diagram element
|
|
12223
|
+
* Returns the visual part of a diagram element.
|
|
12099
12224
|
*
|
|
12100
|
-
* @param {
|
|
12225
|
+
* @param {SVGElement} gfx
|
|
12101
12226
|
*
|
|
12102
|
-
* @return {
|
|
12227
|
+
* @return {SVGElement}
|
|
12103
12228
|
*/
|
|
12104
12229
|
function getVisual(gfx) {
|
|
12105
12230
|
return gfx.childNodes[0];
|
|
@@ -12108,15 +12233,28 @@
|
|
|
12108
12233
|
/**
|
|
12109
12234
|
* Returns the children for a given diagram element.
|
|
12110
12235
|
*
|
|
12111
|
-
* @param {
|
|
12112
|
-
* @return {
|
|
12236
|
+
* @param {SVGElement} gfx
|
|
12237
|
+
* @return {SVGElement}
|
|
12113
12238
|
*/
|
|
12114
12239
|
function getChildren(gfx) {
|
|
12115
12240
|
return gfx.parentNode.childNodes[1];
|
|
12116
12241
|
}
|
|
12117
12242
|
|
|
12118
12243
|
/**
|
|
12119
|
-
*
|
|
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.
|
|
12120
12258
|
*
|
|
12121
12259
|
* @param {EventBus} eventBus
|
|
12122
12260
|
* @param {ElementRegistry} elementRegistry
|
|
@@ -12184,7 +12322,7 @@
|
|
|
12184
12322
|
* </g>
|
|
12185
12323
|
*
|
|
12186
12324
|
* @param {string} type the type of the element, i.e. shape | connection
|
|
12187
|
-
* @param {SVGElement}
|
|
12325
|
+
* @param {SVGElement} childrenGfx
|
|
12188
12326
|
* @param {number} [parentIndex] position to create container in parent
|
|
12189
12327
|
* @param {boolean} [isFrame] is frame element
|
|
12190
12328
|
*
|
|
@@ -12222,11 +12360,25 @@
|
|
|
12222
12360
|
return gfx;
|
|
12223
12361
|
};
|
|
12224
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
|
+
*/
|
|
12225
12372
|
GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
|
12226
12373
|
var childrenGfx = this._getChildrenContainer(element.parent);
|
|
12227
12374
|
return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
|
12228
12375
|
};
|
|
12229
12376
|
|
|
12377
|
+
/**
|
|
12378
|
+
* Update the containments of the given elements.
|
|
12379
|
+
*
|
|
12380
|
+
* @param {ElementLike[]} elements The elements.
|
|
12381
|
+
*/
|
|
12230
12382
|
GraphicsFactory.prototype.updateContainments = function(elements) {
|
|
12231
12383
|
|
|
12232
12384
|
var self = this,
|
|
@@ -12262,30 +12414,63 @@
|
|
|
12262
12414
|
});
|
|
12263
12415
|
};
|
|
12264
12416
|
|
|
12417
|
+
/**
|
|
12418
|
+
* Draw a shape.
|
|
12419
|
+
*
|
|
12420
|
+
* @param {SVGElement} visual The graphical element.
|
|
12421
|
+
* @param {ShapeLike} element The shape.
|
|
12422
|
+
*/
|
|
12265
12423
|
GraphicsFactory.prototype.drawShape = function(visual, element) {
|
|
12266
12424
|
var eventBus = this._eventBus;
|
|
12267
12425
|
|
|
12268
12426
|
return eventBus.fire('render.shape', { gfx: visual, element: element });
|
|
12269
12427
|
};
|
|
12270
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
|
+
*/
|
|
12271
12436
|
GraphicsFactory.prototype.getShapePath = function(element) {
|
|
12272
12437
|
var eventBus = this._eventBus;
|
|
12273
12438
|
|
|
12274
12439
|
return eventBus.fire('render.getShapePath', element);
|
|
12275
12440
|
};
|
|
12276
12441
|
|
|
12442
|
+
/**
|
|
12443
|
+
* Draw a connection.
|
|
12444
|
+
*
|
|
12445
|
+
* @param {SVGElement} visual The graphical element.
|
|
12446
|
+
* @param {ConnectionLike} element The connection.
|
|
12447
|
+
*/
|
|
12277
12448
|
GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
|
12278
12449
|
var eventBus = this._eventBus;
|
|
12279
12450
|
|
|
12280
12451
|
return eventBus.fire('render.connection', { gfx: visual, element: element });
|
|
12281
12452
|
};
|
|
12282
12453
|
|
|
12283
|
-
|
|
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) {
|
|
12284
12462
|
var eventBus = this._eventBus;
|
|
12285
12463
|
|
|
12286
|
-
return eventBus.fire('render.getConnectionPath',
|
|
12464
|
+
return eventBus.fire('render.getConnectionPath', connection);
|
|
12287
12465
|
};
|
|
12288
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
|
+
*/
|
|
12289
12474
|
GraphicsFactory.prototype.update = function(type, element, gfx) {
|
|
12290
12475
|
|
|
12291
12476
|
// do NOT update root element
|
|
@@ -12315,6 +12500,11 @@
|
|
|
12315
12500
|
}
|
|
12316
12501
|
};
|
|
12317
12502
|
|
|
12503
|
+
/**
|
|
12504
|
+
* Remove a graphical element.
|
|
12505
|
+
*
|
|
12506
|
+
* @param {ElementLike} element The element.
|
|
12507
|
+
*/
|
|
12318
12508
|
GraphicsFactory.prototype.remove = function(element) {
|
|
12319
12509
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12320
12510
|
|
|
@@ -12348,13 +12538,17 @@
|
|
|
12348
12538
|
};
|
|
12349
12539
|
|
|
12350
12540
|
/**
|
|
12351
|
-
* @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
|
|
12352
12546
|
*/
|
|
12353
12547
|
|
|
12354
12548
|
/**
|
|
12355
12549
|
* Bootstrap an injector from a list of modules, instantiating a number of default components
|
|
12356
12550
|
*
|
|
12357
|
-
* @param {
|
|
12551
|
+
* @param {ModuleDeclaration[]} modules
|
|
12358
12552
|
*
|
|
12359
12553
|
* @return {Injector} a injector to use to access the components
|
|
12360
12554
|
*/
|
|
@@ -12369,7 +12563,8 @@
|
|
|
12369
12563
|
/**
|
|
12370
12564
|
* Creates an injector from passed options.
|
|
12371
12565
|
*
|
|
12372
|
-
* @param {
|
|
12566
|
+
* @param {DiagramOptions} [options]
|
|
12567
|
+
*
|
|
12373
12568
|
* @return {Injector}
|
|
12374
12569
|
*/
|
|
12375
12570
|
function createInjector(options) {
|
|
@@ -12392,8 +12587,7 @@
|
|
|
12392
12587
|
*
|
|
12393
12588
|
* To register extensions with the diagram, pass them as Array<Module> to the constructor.
|
|
12394
12589
|
*
|
|
12395
|
-
* @class
|
|
12396
|
-
* @memberOf djs
|
|
12590
|
+
* @class
|
|
12397
12591
|
* @constructor
|
|
12398
12592
|
*
|
|
12399
12593
|
* @example
|
|
@@ -12431,9 +12625,9 @@
|
|
|
12431
12625
|
*
|
|
12432
12626
|
* // 'shape ... was added to the diagram' logged to console
|
|
12433
12627
|
*
|
|
12434
|
-
* @param {
|
|
12435
|
-
* @param {
|
|
12436
|
-
* @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.
|
|
12437
12631
|
*/
|
|
12438
12632
|
function Diagram(options, injector) {
|
|
12439
12633
|
|
|
@@ -12443,22 +12637,23 @@
|
|
|
12443
12637
|
// API
|
|
12444
12638
|
|
|
12445
12639
|
/**
|
|
12446
|
-
* Resolves a diagram service
|
|
12640
|
+
* Resolves a diagram service.
|
|
12447
12641
|
*
|
|
12448
12642
|
* @method Diagram#get
|
|
12449
12643
|
*
|
|
12450
|
-
* @param {string} name
|
|
12451
|
-
* @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.
|
|
12452
12646
|
*/
|
|
12453
12647
|
this.get = injector.get;
|
|
12454
12648
|
|
|
12455
12649
|
/**
|
|
12456
|
-
* Executes a function
|
|
12650
|
+
* Executes a function with its dependencies injected.
|
|
12457
12651
|
*
|
|
12458
12652
|
* @method Diagram#invoke
|
|
12459
12653
|
*
|
|
12460
|
-
* @param {Function
|
|
12461
|
-
* @param {
|
|
12654
|
+
* @param {Function} fn The function to be executed.
|
|
12655
|
+
* @param {InjectionContext} [context] The context.
|
|
12656
|
+
* @param {LocalsMap} [locals] The locals.
|
|
12462
12657
|
*/
|
|
12463
12658
|
this.invoke = injector.invoke;
|
|
12464
12659
|
|