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
|
*/
|
|
@@ -5346,8 +5385,6 @@
|
|
|
5346
5385
|
}, size);
|
|
5347
5386
|
}
|
|
5348
5387
|
|
|
5349
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5350
|
-
|
|
5351
5388
|
function getDefaultExportFromCjs (x) {
|
|
5352
5389
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
5353
5390
|
}
|
|
@@ -5364,9 +5401,9 @@
|
|
|
5364
5401
|
/**
|
|
5365
5402
|
* Convert the given bounds to a { top, left, bottom, right } descriptor.
|
|
5366
5403
|
*
|
|
5367
|
-
* @param {
|
|
5404
|
+
* @param {Point|Rect} bounds
|
|
5368
5405
|
*
|
|
5369
|
-
* @return {
|
|
5406
|
+
* @return {RectTRBL}
|
|
5370
5407
|
*/
|
|
5371
5408
|
function asTRBL(bounds) {
|
|
5372
5409
|
return {
|
|
@@ -5381,9 +5418,9 @@
|
|
|
5381
5418
|
/**
|
|
5382
5419
|
* Convert a { top, left, bottom, right } to an objects bounds.
|
|
5383
5420
|
*
|
|
5384
|
-
* @param {
|
|
5421
|
+
* @param {RectTRBL} trbl
|
|
5385
5422
|
*
|
|
5386
|
-
* @return {
|
|
5423
|
+
* @return {Rect}
|
|
5387
5424
|
*/
|
|
5388
5425
|
function asBounds(trbl) {
|
|
5389
5426
|
return {
|
|
@@ -5398,7 +5435,7 @@
|
|
|
5398
5435
|
/**
|
|
5399
5436
|
* Get the mid of the given bounds or point.
|
|
5400
5437
|
*
|
|
5401
|
-
* @param {
|
|
5438
|
+
* @param {Point|Rect} bounds
|
|
5402
5439
|
*
|
|
5403
5440
|
* @return {Point}
|
|
5404
5441
|
*/
|
|
@@ -5413,7 +5450,7 @@
|
|
|
5413
5450
|
/**
|
|
5414
5451
|
* Get the mid of the given Connection.
|
|
5415
5452
|
*
|
|
5416
|
-
* @param {
|
|
5453
|
+
* @param {Connection} connection
|
|
5417
5454
|
*
|
|
5418
5455
|
* @return {Point}
|
|
5419
5456
|
*/
|
|
@@ -5472,7 +5509,7 @@
|
|
|
5472
5509
|
/**
|
|
5473
5510
|
* Get the mid of the given Element.
|
|
5474
5511
|
*
|
|
5475
|
-
* @param {
|
|
5512
|
+
* @param {Connection} connection
|
|
5476
5513
|
*
|
|
5477
5514
|
* @return {Point}
|
|
5478
5515
|
*/
|
|
@@ -5882,6 +5919,14 @@
|
|
|
5882
5919
|
return isPrimaryButton(event) && originalEvent.shiftKey;
|
|
5883
5920
|
}
|
|
5884
5921
|
|
|
5922
|
+
/**
|
|
5923
|
+
* @typedef {import('../../model').Base} Base
|
|
5924
|
+
*
|
|
5925
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
5926
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
5927
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
5928
|
+
*/
|
|
5929
|
+
|
|
5885
5930
|
function allowAll(event) { return true; }
|
|
5886
5931
|
|
|
5887
5932
|
function allowPrimaryAndAuxiliary(event) {
|
|
@@ -5911,6 +5956,8 @@
|
|
|
5911
5956
|
* prevents the original DOM operation.
|
|
5912
5957
|
*
|
|
5913
5958
|
* @param {EventBus} eventBus
|
|
5959
|
+
* @param {ElementRegistry} elementRegistry
|
|
5960
|
+
* @param {Styles} styles
|
|
5914
5961
|
*/
|
|
5915
5962
|
function InteractionEvents(eventBus, elementRegistry, styles) {
|
|
5916
5963
|
|
|
@@ -5920,8 +5967,8 @@
|
|
|
5920
5967
|
* Fire an interaction event.
|
|
5921
5968
|
*
|
|
5922
5969
|
* @param {string} type local event name, e.g. element.click.
|
|
5923
|
-
* @param {
|
|
5924
|
-
* @param {
|
|
5970
|
+
* @param {MouseEvent|TouchEvent} event native event
|
|
5971
|
+
* @param {Base} [element] the diagram element to emit the event on;
|
|
5925
5972
|
* defaults to the event target
|
|
5926
5973
|
*/
|
|
5927
5974
|
function fire(type, event, element) {
|
|
@@ -6003,8 +6050,8 @@
|
|
|
6003
6050
|
* on the target shape or connection.
|
|
6004
6051
|
*
|
|
6005
6052
|
* @param {string} eventName the name of the triggered DOM event
|
|
6006
|
-
* @param {MouseEvent} event
|
|
6007
|
-
* @param {
|
|
6053
|
+
* @param {MouseEvent|TouchEvent} event
|
|
6054
|
+
* @param {Base} targetElement
|
|
6008
6055
|
*/
|
|
6009
6056
|
function triggerMouseEvent(eventName, event, targetElement) {
|
|
6010
6057
|
|
|
@@ -6170,7 +6217,7 @@
|
|
|
6170
6217
|
/**
|
|
6171
6218
|
* Create default hit for the given element.
|
|
6172
6219
|
*
|
|
6173
|
-
* @param {
|
|
6220
|
+
* @param {Base} element
|
|
6174
6221
|
* @param {SVGElement} gfx
|
|
6175
6222
|
*
|
|
6176
6223
|
* @return {SVGElement} created hit
|
|
@@ -6242,8 +6289,8 @@
|
|
|
6242
6289
|
/**
|
|
6243
6290
|
* Update default hit of the element.
|
|
6244
6291
|
*
|
|
6245
|
-
* @param
|
|
6246
|
-
* @param
|
|
6292
|
+
* @param {Base} element
|
|
6293
|
+
* @param {SVGElement} gfx
|
|
6247
6294
|
*
|
|
6248
6295
|
* @return {SVGElement} updated hit
|
|
6249
6296
|
*/
|
|
@@ -6291,7 +6338,7 @@
|
|
|
6291
6338
|
* @event element.hover
|
|
6292
6339
|
*
|
|
6293
6340
|
* @type {Object}
|
|
6294
|
-
* @property {
|
|
6341
|
+
* @property {Base} element
|
|
6295
6342
|
* @property {SVGElement} gfx
|
|
6296
6343
|
* @property {Event} originalEvent
|
|
6297
6344
|
*/
|
|
@@ -6302,7 +6349,7 @@
|
|
|
6302
6349
|
* @event element.out
|
|
6303
6350
|
*
|
|
6304
6351
|
* @type {Object}
|
|
6305
|
-
* @property {
|
|
6352
|
+
* @property {Base} element
|
|
6306
6353
|
* @property {SVGElement} gfx
|
|
6307
6354
|
* @property {Event} originalEvent
|
|
6308
6355
|
*/
|
|
@@ -6313,7 +6360,7 @@
|
|
|
6313
6360
|
* @event element.click
|
|
6314
6361
|
*
|
|
6315
6362
|
* @type {Object}
|
|
6316
|
-
* @property {
|
|
6363
|
+
* @property {Base} element
|
|
6317
6364
|
* @property {SVGElement} gfx
|
|
6318
6365
|
* @property {Event} originalEvent
|
|
6319
6366
|
*/
|
|
@@ -6324,7 +6371,7 @@
|
|
|
6324
6371
|
* @event element.dblclick
|
|
6325
6372
|
*
|
|
6326
6373
|
* @type {Object}
|
|
6327
|
-
* @property {
|
|
6374
|
+
* @property {Base} element
|
|
6328
6375
|
* @property {SVGElement} gfx
|
|
6329
6376
|
* @property {Event} originalEvent
|
|
6330
6377
|
*/
|
|
@@ -6335,7 +6382,7 @@
|
|
|
6335
6382
|
* @event element.mousedown
|
|
6336
6383
|
*
|
|
6337
6384
|
* @type {Object}
|
|
6338
|
-
* @property {
|
|
6385
|
+
* @property {Base} element
|
|
6339
6386
|
* @property {SVGElement} gfx
|
|
6340
6387
|
* @property {Event} originalEvent
|
|
6341
6388
|
*/
|
|
@@ -6346,7 +6393,7 @@
|
|
|
6346
6393
|
* @event element.mouseup
|
|
6347
6394
|
*
|
|
6348
6395
|
* @type {Object}
|
|
6349
|
-
* @property {
|
|
6396
|
+
* @property {Base} element
|
|
6350
6397
|
* @property {SVGElement} gfx
|
|
6351
6398
|
* @property {Event} originalEvent
|
|
6352
6399
|
*/
|
|
@@ -6358,7 +6405,7 @@
|
|
|
6358
6405
|
* @event element.contextmenu
|
|
6359
6406
|
*
|
|
6360
6407
|
* @type {Object}
|
|
6361
|
-
* @property {
|
|
6408
|
+
* @property {Base} element
|
|
6362
6409
|
* @property {SVGElement} gfx
|
|
6363
6410
|
* @property {Event} originalEvent
|
|
6364
6411
|
*/
|
|
@@ -6372,10 +6419,10 @@
|
|
|
6372
6419
|
* Returns the surrounding bbox for all elements in
|
|
6373
6420
|
* the array or the element primitive.
|
|
6374
6421
|
*
|
|
6375
|
-
* @param {
|
|
6422
|
+
* @param {Base|Base[]} elements
|
|
6376
6423
|
* @param {boolean} [stopRecursion=false]
|
|
6377
6424
|
*
|
|
6378
|
-
* @return {
|
|
6425
|
+
* @return {Rect}
|
|
6379
6426
|
*/
|
|
6380
6427
|
function getBBox(elements, stopRecursion) {
|
|
6381
6428
|
|
|
@@ -6446,6 +6493,12 @@
|
|
|
6446
6493
|
|
|
6447
6494
|
var LOW_PRIORITY$2 = 500;
|
|
6448
6495
|
|
|
6496
|
+
/**
|
|
6497
|
+
* @typedef {import('../../model').Base} Base
|
|
6498
|
+
*
|
|
6499
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6500
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
6501
|
+
*/
|
|
6449
6502
|
|
|
6450
6503
|
/**
|
|
6451
6504
|
* @class
|
|
@@ -6455,9 +6508,8 @@
|
|
|
6455
6508
|
*
|
|
6456
6509
|
* @param {EventBus} eventBus
|
|
6457
6510
|
* @param {Styles} styles
|
|
6458
|
-
* @param {ElementRegistry} elementRegistry
|
|
6459
6511
|
*/
|
|
6460
|
-
function Outline(eventBus, styles
|
|
6512
|
+
function Outline(eventBus, styles) {
|
|
6461
6513
|
|
|
6462
6514
|
this.offset = 6;
|
|
6463
6515
|
|
|
@@ -6515,8 +6567,8 @@
|
|
|
6515
6567
|
* Updates the outline of a shape respecting the dimension of the
|
|
6516
6568
|
* element and an outline offset.
|
|
6517
6569
|
*
|
|
6518
|
-
* @param
|
|
6519
|
-
* @param
|
|
6570
|
+
* @param {SVGElement} outline
|
|
6571
|
+
* @param {Base} element
|
|
6520
6572
|
*/
|
|
6521
6573
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6522
6574
|
|
|
@@ -6534,8 +6586,8 @@
|
|
|
6534
6586
|
* Updates the outline of a connection respecting the bounding box of
|
|
6535
6587
|
* the connection and an outline offset.
|
|
6536
6588
|
*
|
|
6537
|
-
* @param
|
|
6538
|
-
* @param
|
|
6589
|
+
* @param {SVGElement} outline
|
|
6590
|
+
* @param {Base} element
|
|
6539
6591
|
*/
|
|
6540
6592
|
Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
|
6541
6593
|
|
|
@@ -6558,13 +6610,17 @@
|
|
|
6558
6610
|
outline: [ 'type', Outline ]
|
|
6559
6611
|
};
|
|
6560
6612
|
|
|
6613
|
+
/**
|
|
6614
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6615
|
+
*/
|
|
6616
|
+
|
|
6561
6617
|
/**
|
|
6562
6618
|
* A service that offers the current selection in a diagram.
|
|
6563
6619
|
* Offers the api to control the selection, too.
|
|
6564
6620
|
*
|
|
6565
6621
|
* @class
|
|
6566
6622
|
*
|
|
6567
|
-
* @param {EventBus} eventBus
|
|
6623
|
+
* @param {EventBus} eventBus
|
|
6568
6624
|
*/
|
|
6569
6625
|
function Selection(eventBus, canvas) {
|
|
6570
6626
|
|
|
@@ -6620,8 +6676,8 @@
|
|
|
6620
6676
|
*
|
|
6621
6677
|
* @method Selection#select
|
|
6622
6678
|
*
|
|
6623
|
-
* @param
|
|
6624
|
-
* @param
|
|
6679
|
+
* @param {Object|Object[]} elements element or array of elements to be selected
|
|
6680
|
+
* @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
|
|
6625
6681
|
*/
|
|
6626
6682
|
Selection.prototype.select = function(elements, add) {
|
|
6627
6683
|
var selectedElements = this._selectedElements,
|
|
@@ -6660,6 +6716,12 @@
|
|
|
6660
6716
|
this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
|
6661
6717
|
};
|
|
6662
6718
|
|
|
6719
|
+
/**
|
|
6720
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6721
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6722
|
+
* @typedef {import('./Selection').default} Selection
|
|
6723
|
+
*/
|
|
6724
|
+
|
|
6663
6725
|
var MARKER_HOVER = 'hover',
|
|
6664
6726
|
MARKER_SELECTED = 'selected';
|
|
6665
6727
|
|
|
@@ -6676,6 +6738,7 @@
|
|
|
6676
6738
|
*
|
|
6677
6739
|
* @param {Canvas} canvas
|
|
6678
6740
|
* @param {EventBus} eventBus
|
|
6741
|
+
* @param {Selection} selection
|
|
6679
6742
|
*/
|
|
6680
6743
|
function SelectionVisuals(canvas, eventBus, selection) {
|
|
6681
6744
|
this._canvas = canvas;
|
|
@@ -6781,6 +6844,19 @@
|
|
|
6781
6844
|
};
|
|
6782
6845
|
}
|
|
6783
6846
|
|
|
6847
|
+
/**
|
|
6848
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6849
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
6850
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6851
|
+
* @typedef {import('./Selection').default} Selection
|
|
6852
|
+
*/
|
|
6853
|
+
|
|
6854
|
+
/**
|
|
6855
|
+
* @param {EventBus} eventBus
|
|
6856
|
+
* @param {Selection} selection
|
|
6857
|
+
* @param {Canvas} canvas
|
|
6858
|
+
* @param {ElementRegistry} elementRegistry
|
|
6859
|
+
*/
|
|
6784
6860
|
function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
|
6785
6861
|
|
|
6786
6862
|
// Select elements on create
|
|
@@ -6901,9 +6977,8 @@
|
|
|
6901
6977
|
/**
|
|
6902
6978
|
* Util that provides unique IDs.
|
|
6903
6979
|
*
|
|
6904
|
-
* @class
|
|
6980
|
+
* @class
|
|
6905
6981
|
* @constructor
|
|
6906
|
-
* @memberOf djs.util
|
|
6907
6982
|
*
|
|
6908
6983
|
* The ids can be customized via a given prefix and contain a random value to avoid collisions.
|
|
6909
6984
|
*
|
|
@@ -6918,8 +6993,6 @@
|
|
|
6918
6993
|
/**
|
|
6919
6994
|
* Returns a next unique ID.
|
|
6920
6995
|
*
|
|
6921
|
-
* @method djs.util.IdGenerator#next
|
|
6922
|
-
*
|
|
6923
6996
|
* @returns {string} the id
|
|
6924
6997
|
*/
|
|
6925
6998
|
IdGenerator.prototype.next = function() {
|
|
@@ -6931,6 +7004,18 @@
|
|
|
6931
7004
|
|
|
6932
7005
|
var LOW_PRIORITY$1 = 500;
|
|
6933
7006
|
|
|
7007
|
+
/**
|
|
7008
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7009
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7010
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7011
|
+
*
|
|
7012
|
+
* @typedef {import('./Overlays').Overlay} Overlay
|
|
7013
|
+
* @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
|
|
7014
|
+
* @typedef {import('./Overlays').OverlayContainer} OverlayContainer
|
|
7015
|
+
* @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
|
|
7016
|
+
* @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
|
|
7017
|
+
* @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
|
|
7018
|
+
*/
|
|
6934
7019
|
|
|
6935
7020
|
/**
|
|
6936
7021
|
* A service that allows users to attach overlays to diagram elements.
|
|
@@ -6940,6 +7025,7 @@
|
|
|
6940
7025
|
* @example
|
|
6941
7026
|
*
|
|
6942
7027
|
* // add a pink badge on the top left of the shape
|
|
7028
|
+
*
|
|
6943
7029
|
* overlays.add(someShape, {
|
|
6944
7030
|
* position: {
|
|
6945
7031
|
* top: -5,
|
|
@@ -6991,19 +7077,21 @@
|
|
|
6991
7077
|
* }
|
|
6992
7078
|
* }
|
|
6993
7079
|
*
|
|
6994
|
-
* @param {
|
|
7080
|
+
* @param {OverlaysConfig} config
|
|
6995
7081
|
* @param {EventBus} eventBus
|
|
6996
7082
|
* @param {Canvas} canvas
|
|
6997
7083
|
* @param {ElementRegistry} elementRegistry
|
|
6998
7084
|
*/
|
|
6999
7085
|
function Overlays(config, eventBus, canvas, elementRegistry) {
|
|
7000
|
-
|
|
7001
7086
|
this._eventBus = eventBus;
|
|
7002
7087
|
this._canvas = canvas;
|
|
7003
7088
|
this._elementRegistry = elementRegistry;
|
|
7004
7089
|
|
|
7005
7090
|
this._ids = ids;
|
|
7006
7091
|
|
|
7092
|
+
/**
|
|
7093
|
+
* @type {OverlaysConfigDefault}
|
|
7094
|
+
*/
|
|
7007
7095
|
this._overlayDefaults = assign$1({
|
|
7008
7096
|
|
|
7009
7097
|
// no show constraints
|
|
@@ -7014,16 +7102,18 @@
|
|
|
7014
7102
|
}, config && config.defaults);
|
|
7015
7103
|
|
|
7016
7104
|
/**
|
|
7017
|
-
*
|
|
7105
|
+
* @type {Map<string, Overlay>}
|
|
7018
7106
|
*/
|
|
7019
7107
|
this._overlays = {};
|
|
7020
7108
|
|
|
7021
7109
|
/**
|
|
7022
|
-
*
|
|
7110
|
+
* @type {OverlayContainer[]}
|
|
7023
7111
|
*/
|
|
7024
7112
|
this._overlayContainers = [];
|
|
7025
7113
|
|
|
7026
|
-
|
|
7114
|
+
/**
|
|
7115
|
+
* @type {HTMLElement}
|
|
7116
|
+
*/
|
|
7027
7117
|
this._overlayRoot = createRoot(canvas.getContainer());
|
|
7028
7118
|
|
|
7029
7119
|
this._init();
|
|
@@ -7039,12 +7129,12 @@
|
|
|
7039
7129
|
|
|
7040
7130
|
|
|
7041
7131
|
/**
|
|
7042
|
-
* Returns the overlay with the specified
|
|
7132
|
+
* Returns the overlay with the specified ID or a list of overlays
|
|
7043
7133
|
* for an element with a given type.
|
|
7044
7134
|
*
|
|
7045
7135
|
* @example
|
|
7046
7136
|
*
|
|
7047
|
-
* // return the single overlay with the given
|
|
7137
|
+
* // return the single overlay with the given ID
|
|
7048
7138
|
* overlays.get('some-id');
|
|
7049
7139
|
*
|
|
7050
7140
|
* // return all overlays for the shape
|
|
@@ -7053,16 +7143,12 @@
|
|
|
7053
7143
|
* // return all overlays on shape with type 'badge'
|
|
7054
7144
|
* overlays.get({ element: someShape, type: 'badge' });
|
|
7055
7145
|
*
|
|
7056
|
-
* // shape can also be specified as
|
|
7146
|
+
* // shape can also be specified as ID
|
|
7057
7147
|
* overlays.get({ element: 'element-id', type: 'badge' });
|
|
7058
7148
|
*
|
|
7149
|
+
* @param {OverlaysFilter} search The filter to be used to find the overlay(s).
|
|
7059
7150
|
*
|
|
7060
|
-
* @
|
|
7061
|
-
* @param {string} [search.id]
|
|
7062
|
-
* @param {string|djs.model.Base} [search.element]
|
|
7063
|
-
* @param {string} [search.type]
|
|
7064
|
-
*
|
|
7065
|
-
* @return {Object|Array<Object>} the overlay(s)
|
|
7151
|
+
* @return {Overlay|Overlay[]} The overlay(s).
|
|
7066
7152
|
*/
|
|
7067
7153
|
Overlays.prototype.get = function(search) {
|
|
7068
7154
|
|
|
@@ -7094,27 +7180,13 @@
|
|
|
7094
7180
|
};
|
|
7095
7181
|
|
|
7096
7182
|
/**
|
|
7097
|
-
* Adds
|
|
7183
|
+
* Adds an HTML overlay to an element.
|
|
7098
7184
|
*
|
|
7099
|
-
* @param {string
|
|
7100
|
-
* @param {string}
|
|
7101
|
-
* @param {
|
|
7185
|
+
* @param {Base|string} element The element to add the overlay to.
|
|
7186
|
+
* @param {string} [type] An optional type that can be used to filter.
|
|
7187
|
+
* @param {OverlayAttrs} overlay The overlay.
|
|
7102
7188
|
*
|
|
7103
|
-
* @
|
|
7104
|
-
* @param {Object} [overlay.show] show configuration
|
|
7105
|
-
* @param {number} [overlay.show.minZoom] minimal zoom level to show the overlay
|
|
7106
|
-
* @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
|
|
7107
|
-
* @param {Object} overlay.position where to attach the overlay
|
|
7108
|
-
* @param {number} [overlay.position.left] relative to element bbox left attachment
|
|
7109
|
-
* @param {number} [overlay.position.top] relative to element bbox top attachment
|
|
7110
|
-
* @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
|
|
7111
|
-
* @param {number} [overlay.position.right] relative to element bbox right attachment
|
|
7112
|
-
* @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
|
|
7113
|
-
* diagram zoom
|
|
7114
|
-
* @param {number} [overlay.scale.min]
|
|
7115
|
-
* @param {number} [overlay.scale.max]
|
|
7116
|
-
*
|
|
7117
|
-
* @return {string} id that may be used to reference the overlay for update or removal
|
|
7189
|
+
* @return {string} The overlay's ID that can be used to get or remove it.
|
|
7118
7190
|
*/
|
|
7119
7191
|
Overlays.prototype.add = function(element, type, overlay) {
|
|
7120
7192
|
|
|
@@ -7155,11 +7227,11 @@
|
|
|
7155
7227
|
|
|
7156
7228
|
|
|
7157
7229
|
/**
|
|
7158
|
-
* Remove an overlay with the given
|
|
7230
|
+
* Remove an overlay with the given ID or all overlays matching the given filter.
|
|
7159
7231
|
*
|
|
7160
7232
|
* @see Overlays#get for filter options.
|
|
7161
7233
|
*
|
|
7162
|
-
* @param {
|
|
7234
|
+
* @param {OverlaysFilter} filter The filter to be used to find the overlay.
|
|
7163
7235
|
*/
|
|
7164
7236
|
Overlays.prototype.remove = function(filter) {
|
|
7165
7237
|
|
|
@@ -7195,19 +7267,32 @@
|
|
|
7195
7267
|
|
|
7196
7268
|
};
|
|
7197
7269
|
|
|
7270
|
+
/**
|
|
7271
|
+
* Checks whether overlays are shown.
|
|
7272
|
+
*
|
|
7273
|
+
* @returns {boolean} Whether overlays are shown.
|
|
7274
|
+
*/
|
|
7198
7275
|
Overlays.prototype.isShown = function() {
|
|
7199
7276
|
return this._overlayRoot.style.display !== 'none';
|
|
7200
7277
|
};
|
|
7201
7278
|
|
|
7279
|
+
/**
|
|
7280
|
+
* Show all overlays.
|
|
7281
|
+
*/
|
|
7202
7282
|
Overlays.prototype.show = function() {
|
|
7203
7283
|
setVisible(this._overlayRoot);
|
|
7204
7284
|
};
|
|
7205
7285
|
|
|
7206
|
-
|
|
7286
|
+
/**
|
|
7287
|
+
* Hide all overlays.
|
|
7288
|
+
*/
|
|
7207
7289
|
Overlays.prototype.hide = function() {
|
|
7208
7290
|
setVisible(this._overlayRoot, false);
|
|
7209
7291
|
};
|
|
7210
7292
|
|
|
7293
|
+
/**
|
|
7294
|
+
* Remove all overlays and their container.
|
|
7295
|
+
*/
|
|
7211
7296
|
Overlays.prototype.clear = function() {
|
|
7212
7297
|
this._overlays = {};
|
|
7213
7298
|
|
|
@@ -7583,6 +7668,13 @@
|
|
|
7583
7668
|
overlays: [ 'type', Overlays ]
|
|
7584
7669
|
};
|
|
7585
7670
|
|
|
7671
|
+
/**
|
|
7672
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7673
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7674
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7675
|
+
* @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
|
|
7676
|
+
*/
|
|
7677
|
+
|
|
7586
7678
|
/**
|
|
7587
7679
|
* Adds change support to the diagram, including
|
|
7588
7680
|
*
|
|
@@ -7652,32 +7744,41 @@
|
|
|
7652
7744
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7653
7745
|
};
|
|
7654
7746
|
|
|
7747
|
+
/**
|
|
7748
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
7749
|
+
* @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
|
|
7750
|
+
* @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
|
|
7751
|
+
*/
|
|
7752
|
+
|
|
7655
7753
|
var DEFAULT_PRIORITY$1 = 1000;
|
|
7656
7754
|
|
|
7657
7755
|
/**
|
|
7658
|
-
* A utility that can be used to plug
|
|
7756
|
+
* A utility that can be used to plug into the command execution for
|
|
7659
7757
|
* extension and/or validation.
|
|
7660
7758
|
*
|
|
7759
|
+
* @class
|
|
7760
|
+
* @constructor
|
|
7761
|
+
*
|
|
7661
7762
|
* @param {EventBus} eventBus
|
|
7662
7763
|
*
|
|
7663
7764
|
* @example
|
|
7664
7765
|
*
|
|
7665
|
-
* import inherits from 'inherits-browser';
|
|
7666
|
-
*
|
|
7667
7766
|
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7668
7767
|
*
|
|
7669
|
-
*
|
|
7670
|
-
*
|
|
7768
|
+
* class CommandLogger extends CommandInterceptor {
|
|
7769
|
+
* constructor(eventBus) {
|
|
7770
|
+
* super(eventBus);
|
|
7671
7771
|
*
|
|
7672
|
-
* this.preExecute(
|
|
7673
|
-
* console.log('
|
|
7772
|
+
* this.preExecute('shape.create', (event) => {
|
|
7773
|
+
* console.log('commandStack.shape-create.preExecute', event);
|
|
7674
7774
|
* });
|
|
7675
7775
|
* }
|
|
7676
|
-
*
|
|
7677
|
-
* inherits(CommandLogger, CommandInterceptor);
|
|
7678
|
-
*
|
|
7679
7776
|
*/
|
|
7680
7777
|
function CommandInterceptor(eventBus) {
|
|
7778
|
+
|
|
7779
|
+
/**
|
|
7780
|
+
* @type {EventBus}
|
|
7781
|
+
*/
|
|
7681
7782
|
this._eventBus = eventBus;
|
|
7682
7783
|
}
|
|
7683
7784
|
|
|
@@ -7690,16 +7791,15 @@
|
|
|
7690
7791
|
}
|
|
7691
7792
|
|
|
7692
7793
|
/**
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
*/
|
|
7794
|
+
* Intercept a command during one of the phases.
|
|
7795
|
+
*
|
|
7796
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7797
|
+
* @param {string} [hook] Phase during which to intercept command.
|
|
7798
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7799
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7800
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7801
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7802
|
+
*/
|
|
7703
7803
|
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7704
7804
|
|
|
7705
7805
|
if (isFunction(hook) || isNumber(hook)) {
|
|
@@ -7755,24 +7855,19 @@
|
|
|
7755
7855
|
];
|
|
7756
7856
|
|
|
7757
7857
|
/*
|
|
7758
|
-
*
|
|
7759
|
-
*
|
|
7760
|
-
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7761
|
-
* which will in term forward to CommandInterceptor#on.
|
|
7858
|
+
* Add prototype methods for each phase of command execution (e.g. execute,
|
|
7859
|
+
* revert).
|
|
7762
7860
|
*/
|
|
7763
7861
|
forEach$1(hooks, function(hook) {
|
|
7764
7862
|
|
|
7765
7863
|
/**
|
|
7766
|
-
*
|
|
7767
|
-
*
|
|
7768
|
-
* A named hook for plugging into the command execution
|
|
7864
|
+
* Add prototype method for a specific phase of command execution.
|
|
7769
7865
|
*
|
|
7770
|
-
* @param {string|
|
|
7771
|
-
* @param {number} [priority]
|
|
7772
|
-
* @param {
|
|
7773
|
-
* @param {boolean} [unwrap
|
|
7774
|
-
*
|
|
7775
|
-
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7866
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7867
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7868
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7869
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7870
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7776
7871
|
*/
|
|
7777
7872
|
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7778
7873
|
|
|
@@ -7788,12 +7883,18 @@
|
|
|
7788
7883
|
};
|
|
7789
7884
|
});
|
|
7790
7885
|
|
|
7886
|
+
/**
|
|
7887
|
+
* @typedef {import('didi').Injector} Injector
|
|
7888
|
+
*
|
|
7889
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7890
|
+
*/
|
|
7891
|
+
|
|
7791
7892
|
/**
|
|
7792
7893
|
* A modeling behavior that ensures we set the correct root element
|
|
7793
7894
|
* as we undo and redo commands.
|
|
7794
7895
|
*
|
|
7795
7896
|
* @param {Canvas} canvas
|
|
7796
|
-
* @param {
|
|
7897
|
+
* @param {Injector} injector
|
|
7797
7898
|
*/
|
|
7798
7899
|
function RootElementsBehavior(canvas, injector) {
|
|
7799
7900
|
|
|
@@ -7827,111 +7928,10 @@
|
|
|
7827
7928
|
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7828
7929
|
};
|
|
7829
7930
|
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
(function (module, exports) {
|
|
7835
|
-
(function(root, factory) {
|
|
7836
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7837
|
-
{
|
|
7838
|
-
// For Node.js.
|
|
7839
|
-
module.exports = factory(root);
|
|
7840
|
-
}
|
|
7841
|
-
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
|
|
7842
|
-
|
|
7843
|
-
if (root.CSS && root.CSS.escape) {
|
|
7844
|
-
return root.CSS.escape;
|
|
7845
|
-
}
|
|
7846
|
-
|
|
7847
|
-
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7848
|
-
var cssEscape = function(value) {
|
|
7849
|
-
if (arguments.length == 0) {
|
|
7850
|
-
throw new TypeError('`CSS.escape` requires an argument.');
|
|
7851
|
-
}
|
|
7852
|
-
var string = String(value);
|
|
7853
|
-
var length = string.length;
|
|
7854
|
-
var index = -1;
|
|
7855
|
-
var codeUnit;
|
|
7856
|
-
var result = '';
|
|
7857
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
7858
|
-
while (++index < length) {
|
|
7859
|
-
codeUnit = string.charCodeAt(index);
|
|
7860
|
-
// Note: there’s no need to special-case astral symbols, surrogate
|
|
7861
|
-
// pairs, or lone surrogates.
|
|
7862
|
-
|
|
7863
|
-
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
7864
|
-
// (U+FFFD).
|
|
7865
|
-
if (codeUnit == 0x0000) {
|
|
7866
|
-
result += '\uFFFD';
|
|
7867
|
-
continue;
|
|
7868
|
-
}
|
|
7869
|
-
|
|
7870
|
-
if (
|
|
7871
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
7872
|
-
// U+007F, […]
|
|
7873
|
-
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
|
7874
|
-
// If the character is the first character and is in the range [0-9]
|
|
7875
|
-
// (U+0030 to U+0039), […]
|
|
7876
|
-
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
|
7877
|
-
// If the character is the second character and is in the range [0-9]
|
|
7878
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
7879
|
-
(
|
|
7880
|
-
index == 1 &&
|
|
7881
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
|
7882
|
-
firstCodeUnit == 0x002D
|
|
7883
|
-
)
|
|
7884
|
-
) {
|
|
7885
|
-
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
7886
|
-
result += '\\' + codeUnit.toString(16) + ' ';
|
|
7887
|
-
continue;
|
|
7888
|
-
}
|
|
7889
|
-
|
|
7890
|
-
if (
|
|
7891
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
7892
|
-
// there is no second character, […]
|
|
7893
|
-
index == 0 &&
|
|
7894
|
-
length == 1 &&
|
|
7895
|
-
codeUnit == 0x002D
|
|
7896
|
-
) {
|
|
7897
|
-
result += '\\' + string.charAt(index);
|
|
7898
|
-
continue;
|
|
7899
|
-
}
|
|
7900
|
-
|
|
7901
|
-
// If the character is not handled by one of the above rules and is
|
|
7902
|
-
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
7903
|
-
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
7904
|
-
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
7905
|
-
if (
|
|
7906
|
-
codeUnit >= 0x0080 ||
|
|
7907
|
-
codeUnit == 0x002D ||
|
|
7908
|
-
codeUnit == 0x005F ||
|
|
7909
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
|
7910
|
-
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
|
7911
|
-
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
|
7912
|
-
) {
|
|
7913
|
-
// the character itself
|
|
7914
|
-
result += string.charAt(index);
|
|
7915
|
-
continue;
|
|
7916
|
-
}
|
|
7917
|
-
|
|
7918
|
-
// Otherwise, the escaped character.
|
|
7919
|
-
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
7920
|
-
result += '\\' + string.charAt(index);
|
|
7921
|
-
|
|
7922
|
-
}
|
|
7923
|
-
return result;
|
|
7924
|
-
};
|
|
7925
|
-
|
|
7926
|
-
if (!root.CSS) {
|
|
7927
|
-
root.CSS = {};
|
|
7928
|
-
}
|
|
7929
|
-
|
|
7930
|
-
root.CSS.escape = cssEscape;
|
|
7931
|
-
return cssEscape;
|
|
7932
|
-
|
|
7933
|
-
}));
|
|
7934
|
-
} (css_escape));
|
|
7931
|
+
/**
|
|
7932
|
+
* @param {string} str
|
|
7933
|
+
* @returns {string}
|
|
7934
|
+
*/
|
|
7935
7935
|
|
|
7936
7936
|
var HTML_ESCAPE_MAP = {
|
|
7937
7937
|
'&': '&',
|
|
@@ -9066,6 +9066,11 @@
|
|
|
9066
9066
|
return value;
|
|
9067
9067
|
}
|
|
9068
9068
|
|
|
9069
|
+
/**
|
|
9070
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
9071
|
+
* @typedef {import('./Styles').default} Styles
|
|
9072
|
+
*/
|
|
9073
|
+
|
|
9069
9074
|
// apply default renderer with lowest possible priority
|
|
9070
9075
|
// so that it only kicks in if noone else could render
|
|
9071
9076
|
var DEFAULT_RENDER_PRIORITY = 1;
|
|
@@ -9183,9 +9188,9 @@
|
|
|
9183
9188
|
/**
|
|
9184
9189
|
* Builds a style definition from a className, a list of traits and an object of additional attributes.
|
|
9185
9190
|
*
|
|
9186
|
-
* @param
|
|
9187
|
-
* @param
|
|
9188
|
-
* @param
|
|
9191
|
+
* @param {string} className
|
|
9192
|
+
* @param {Array<string>} traits
|
|
9193
|
+
* @param {Object} additionalAttrs
|
|
9189
9194
|
*
|
|
9190
9195
|
* @return {Object} the style defintion
|
|
9191
9196
|
*/
|
|
@@ -9198,8 +9203,8 @@
|
|
|
9198
9203
|
/**
|
|
9199
9204
|
* Builds a style definition from a list of traits and an object of additional attributes.
|
|
9200
9205
|
*
|
|
9201
|
-
* @param
|
|
9202
|
-
* @param
|
|
9206
|
+
* @param {Array<string>} traits
|
|
9207
|
+
* @param {Object} additionalAttrs
|
|
9203
9208
|
*
|
|
9204
9209
|
* @return {Object} the style defintion
|
|
9205
9210
|
*/
|
|
@@ -9236,8 +9241,8 @@
|
|
|
9236
9241
|
/**
|
|
9237
9242
|
* Failsafe remove an element from a collection
|
|
9238
9243
|
*
|
|
9239
|
-
* @param
|
|
9240
|
-
* @param
|
|
9244
|
+
* @param {Array<Object>} [collection]
|
|
9245
|
+
* @param {Object} [element]
|
|
9241
9246
|
*
|
|
9242
9247
|
* @return {number} the previous index of the element
|
|
9243
9248
|
*/
|
|
@@ -9307,6 +9312,27 @@
|
|
|
9307
9312
|
}
|
|
9308
9313
|
}
|
|
9309
9314
|
|
|
9315
|
+
/**
|
|
9316
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
9317
|
+
* @typedef {import('.').RootLike} RootLike
|
|
9318
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
9319
|
+
*
|
|
9320
|
+
* @typedef {import('./Canvas').CanvasConfig} CanvasConfig
|
|
9321
|
+
* @typedef {import('./Canvas').CanvasLayer} CanvasLayer
|
|
9322
|
+
* @typedef {import('./Canvas').CanvasLayers} CanvasLayers
|
|
9323
|
+
* @typedef {import('./Canvas').CanvasPlane} CanvasPlane
|
|
9324
|
+
* @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
|
|
9325
|
+
*
|
|
9326
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
9327
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
9328
|
+
* @typedef {import('./GraphicsFactory').default} GraphicsFactory
|
|
9329
|
+
*
|
|
9330
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
9331
|
+
* @typedef {import('../util/Types').Point} Point
|
|
9332
|
+
* @typedef {import('../util/Types').Rect} Rect
|
|
9333
|
+
* @typedef {import('../util/Types').RectTRBL} RectTRBL
|
|
9334
|
+
*/
|
|
9335
|
+
|
|
9310
9336
|
function round(number, resolution) {
|
|
9311
9337
|
return Math.round(number * resolution) / resolution;
|
|
9312
9338
|
}
|
|
@@ -9327,7 +9353,8 @@
|
|
|
9327
9353
|
* Creates a HTML container element for a SVG element with
|
|
9328
9354
|
* the given configuration
|
|
9329
9355
|
*
|
|
9330
|
-
* @param
|
|
9356
|
+
* @param {CanvasConfig} options
|
|
9357
|
+
*
|
|
9331
9358
|
* @return {HTMLElement} the container element
|
|
9332
9359
|
*/
|
|
9333
9360
|
function createContainer(options) {
|
|
@@ -9387,21 +9414,34 @@
|
|
|
9387
9414
|
*
|
|
9388
9415
|
* @emits Canvas#canvas.init
|
|
9389
9416
|
*
|
|
9390
|
-
* @param {
|
|
9417
|
+
* @param {CanvasConfig|null} config
|
|
9391
9418
|
* @param {EventBus} eventBus
|
|
9392
9419
|
* @param {GraphicsFactory} graphicsFactory
|
|
9393
9420
|
* @param {ElementRegistry} elementRegistry
|
|
9394
9421
|
*/
|
|
9395
9422
|
function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
|
9396
|
-
|
|
9397
9423
|
this._eventBus = eventBus;
|
|
9398
9424
|
this._elementRegistry = elementRegistry;
|
|
9399
9425
|
this._graphicsFactory = graphicsFactory;
|
|
9400
9426
|
|
|
9427
|
+
/**
|
|
9428
|
+
* @type {number}
|
|
9429
|
+
*/
|
|
9401
9430
|
this._rootsIdx = 0;
|
|
9402
9431
|
|
|
9432
|
+
/**
|
|
9433
|
+
* @type {CanvasLayers}
|
|
9434
|
+
*/
|
|
9403
9435
|
this._layers = {};
|
|
9436
|
+
|
|
9437
|
+
/**
|
|
9438
|
+
* @type {CanvasPlane[]}
|
|
9439
|
+
*/
|
|
9404
9440
|
this._planes = [];
|
|
9441
|
+
|
|
9442
|
+
/**
|
|
9443
|
+
* @type {RootLike|null}
|
|
9444
|
+
*/
|
|
9405
9445
|
this._rootElement = null;
|
|
9406
9446
|
|
|
9407
9447
|
this._init(config || {});
|
|
@@ -9426,6 +9466,8 @@
|
|
|
9426
9466
|
* ...
|
|
9427
9467
|
* </svg>
|
|
9428
9468
|
* </div>
|
|
9469
|
+
*
|
|
9470
|
+
* @param {CanvasConfig} config
|
|
9429
9471
|
*/
|
|
9430
9472
|
Canvas.prototype._init = function(config) {
|
|
9431
9473
|
|
|
@@ -9447,7 +9489,7 @@
|
|
|
9447
9489
|
this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
|
|
9448
9490
|
}
|
|
9449
9491
|
|
|
9450
|
-
eventBus.on('diagram.init',
|
|
9492
|
+
eventBus.on('diagram.init', () => {
|
|
9451
9493
|
|
|
9452
9494
|
/**
|
|
9453
9495
|
* An event indicating that the canvas is ready to be drawn on.
|
|
@@ -9465,7 +9507,7 @@
|
|
|
9465
9507
|
viewport: viewport
|
|
9466
9508
|
});
|
|
9467
9509
|
|
|
9468
|
-
}
|
|
9510
|
+
});
|
|
9469
9511
|
|
|
9470
9512
|
// reset viewbox on shape changes to
|
|
9471
9513
|
// recompute the viewbox
|
|
@@ -9476,15 +9518,15 @@
|
|
|
9476
9518
|
'connection.removed',
|
|
9477
9519
|
'elements.changed',
|
|
9478
9520
|
'root.set'
|
|
9479
|
-
],
|
|
9521
|
+
], () => {
|
|
9480
9522
|
delete this._cachedViewbox;
|
|
9481
|
-
}
|
|
9523
|
+
});
|
|
9482
9524
|
|
|
9483
9525
|
eventBus.on('diagram.destroy', 500, this._destroy, this);
|
|
9484
9526
|
eventBus.on('diagram.clear', 500, this._clear, this);
|
|
9485
9527
|
};
|
|
9486
9528
|
|
|
9487
|
-
Canvas.prototype._destroy = function(
|
|
9529
|
+
Canvas.prototype._destroy = function() {
|
|
9488
9530
|
this._eventBus.fire('canvas.destroy', {
|
|
9489
9531
|
svg: this._svg,
|
|
9490
9532
|
viewport: this._viewport
|
|
@@ -9531,7 +9573,7 @@
|
|
|
9531
9573
|
* Returns the default layer on which
|
|
9532
9574
|
* all elements are drawn.
|
|
9533
9575
|
*
|
|
9534
|
-
* @
|
|
9576
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9535
9577
|
*/
|
|
9536
9578
|
Canvas.prototype.getDefaultLayer = function() {
|
|
9537
9579
|
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
@@ -9547,10 +9589,10 @@
|
|
|
9547
9589
|
* A layer with a certain index is always created above all
|
|
9548
9590
|
* existing layers with the same index.
|
|
9549
9591
|
*
|
|
9550
|
-
* @param {string} name
|
|
9551
|
-
* @param {number} index
|
|
9592
|
+
* @param {string} name The name of the layer.
|
|
9593
|
+
* @param {number} [index] The index of the layer.
|
|
9552
9594
|
*
|
|
9553
|
-
* @
|
|
9595
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9554
9596
|
*/
|
|
9555
9597
|
Canvas.prototype.getLayer = function(name, index) {
|
|
9556
9598
|
|
|
@@ -9579,8 +9621,9 @@
|
|
|
9579
9621
|
*
|
|
9580
9622
|
* This is used to determine the node a layer should be inserted at.
|
|
9581
9623
|
*
|
|
9582
|
-
* @param {
|
|
9583
|
-
*
|
|
9624
|
+
* @param {number} index
|
|
9625
|
+
*
|
|
9626
|
+
* @return {number}
|
|
9584
9627
|
*/
|
|
9585
9628
|
Canvas.prototype._getChildIndex = function(index) {
|
|
9586
9629
|
return reduce(this._layers, function(childIndex, layer) {
|
|
@@ -9598,7 +9641,7 @@
|
|
|
9598
9641
|
* @param {string} name
|
|
9599
9642
|
* @param {number} [index=0]
|
|
9600
9643
|
*
|
|
9601
|
-
* @return {
|
|
9644
|
+
* @return {CanvasLayer}
|
|
9602
9645
|
*/
|
|
9603
9646
|
Canvas.prototype._createLayer = function(name, index) {
|
|
9604
9647
|
|
|
@@ -9619,8 +9662,9 @@
|
|
|
9619
9662
|
/**
|
|
9620
9663
|
* Shows a given layer.
|
|
9621
9664
|
*
|
|
9622
|
-
* @param {
|
|
9623
|
-
*
|
|
9665
|
+
* @param {string} layer The name of the layer.
|
|
9666
|
+
*
|
|
9667
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9624
9668
|
*/
|
|
9625
9669
|
Canvas.prototype.showLayer = function(name) {
|
|
9626
9670
|
|
|
@@ -9654,8 +9698,9 @@
|
|
|
9654
9698
|
/**
|
|
9655
9699
|
* Hides a given layer.
|
|
9656
9700
|
*
|
|
9657
|
-
* @param {
|
|
9658
|
-
*
|
|
9701
|
+
* @param {string} layer The name of the layer.
|
|
9702
|
+
*
|
|
9703
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9659
9704
|
*/
|
|
9660
9705
|
Canvas.prototype.hideLayer = function(name) {
|
|
9661
9706
|
|
|
@@ -9697,7 +9742,7 @@
|
|
|
9697
9742
|
/**
|
|
9698
9743
|
* Returns the currently active layer. Can be null.
|
|
9699
9744
|
*
|
|
9700
|
-
* @
|
|
9745
|
+
* @return {CanvasLayer|null} The active layer of `null`.
|
|
9701
9746
|
*/
|
|
9702
9747
|
Canvas.prototype.getActiveLayer = function() {
|
|
9703
9748
|
const plane = this._findPlaneForRoot(this.getRootElement());
|
|
@@ -9713,9 +9758,9 @@
|
|
|
9713
9758
|
/**
|
|
9714
9759
|
* Returns the plane which contains the given element.
|
|
9715
9760
|
*
|
|
9716
|
-
* @param {string
|
|
9761
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9717
9762
|
*
|
|
9718
|
-
* @return {
|
|
9763
|
+
* @return {RootLike|undefined} The root of the element.
|
|
9719
9764
|
*/
|
|
9720
9765
|
Canvas.prototype.findRoot = function(element) {
|
|
9721
9766
|
if (typeof element === 'string') {
|
|
@@ -9736,7 +9781,7 @@
|
|
|
9736
9781
|
/**
|
|
9737
9782
|
* Return a list of all root elements on the diagram.
|
|
9738
9783
|
*
|
|
9739
|
-
* @return {
|
|
9784
|
+
* @return {(RootLike)[]} The list of root elements.
|
|
9740
9785
|
*/
|
|
9741
9786
|
Canvas.prototype.getRootElements = function() {
|
|
9742
9787
|
return this._planes.map(function(plane) {
|
|
@@ -9755,7 +9800,7 @@
|
|
|
9755
9800
|
* Returns the html element that encloses the
|
|
9756
9801
|
* drawing canvas.
|
|
9757
9802
|
*
|
|
9758
|
-
* @return {
|
|
9803
|
+
* @return {HTMLElement} The HTML element of the container.
|
|
9759
9804
|
*/
|
|
9760
9805
|
Canvas.prototype.getContainer = function() {
|
|
9761
9806
|
return this._container;
|
|
@@ -9795,8 +9840,8 @@
|
|
|
9795
9840
|
*
|
|
9796
9841
|
* @event element.marker.update
|
|
9797
9842
|
* @type {Object}
|
|
9798
|
-
* @property {
|
|
9799
|
-
* @property {
|
|
9843
|
+
* @property {Base} element the shape
|
|
9844
|
+
* @property {SVGElement} gfx the graphical representation of the shape
|
|
9800
9845
|
* @property {string} marker
|
|
9801
9846
|
* @property {boolean} add true if the marker was added, false if it got removed
|
|
9802
9847
|
*/
|
|
@@ -9811,14 +9856,15 @@
|
|
|
9811
9856
|
* integrate extension into the marker life-cycle, too.
|
|
9812
9857
|
*
|
|
9813
9858
|
* @example
|
|
9859
|
+
*
|
|
9814
9860
|
* canvas.addMarker('foo', 'some-marker');
|
|
9815
9861
|
*
|
|
9816
9862
|
* const fooGfx = canvas.getGraphics('foo');
|
|
9817
9863
|
*
|
|
9818
9864
|
* fooGfx; // <g class="... some-marker"> ... </g>
|
|
9819
9865
|
*
|
|
9820
|
-
* @param {string
|
|
9821
|
-
* @param {string} marker
|
|
9866
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9867
|
+
* @param {string} marker The marker.
|
|
9822
9868
|
*/
|
|
9823
9869
|
Canvas.prototype.addMarker = function(element, marker) {
|
|
9824
9870
|
this._updateMarker(element, marker, true);
|
|
@@ -9831,18 +9877,18 @@
|
|
|
9831
9877
|
* Fires the element.marker.update event, making it possible to
|
|
9832
9878
|
* integrate extension into the marker life-cycle, too.
|
|
9833
9879
|
*
|
|
9834
|
-
* @param
|
|
9835
|
-
* @param
|
|
9880
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9881
|
+
* @param {string} marker The marker.
|
|
9836
9882
|
*/
|
|
9837
9883
|
Canvas.prototype.removeMarker = function(element, marker) {
|
|
9838
9884
|
this._updateMarker(element, marker, false);
|
|
9839
9885
|
};
|
|
9840
9886
|
|
|
9841
9887
|
/**
|
|
9842
|
-
* Check
|
|
9888
|
+
* Check whether an element has a given marker.
|
|
9843
9889
|
*
|
|
9844
|
-
* @param
|
|
9845
|
-
* @param
|
|
9890
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9891
|
+
* @param {string} marker The marker.
|
|
9846
9892
|
*/
|
|
9847
9893
|
Canvas.prototype.hasMarker = function(element, marker) {
|
|
9848
9894
|
if (!element.id) {
|
|
@@ -9860,8 +9906,8 @@
|
|
|
9860
9906
|
* Fires the element.marker.update event, making it possible to
|
|
9861
9907
|
* integrate extension into the marker life-cycle, too.
|
|
9862
9908
|
*
|
|
9863
|
-
* @param
|
|
9864
|
-
* @param
|
|
9909
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9910
|
+
* @param {string} marker The marker.
|
|
9865
9911
|
*/
|
|
9866
9912
|
Canvas.prototype.toggleMarker = function(element, marker) {
|
|
9867
9913
|
if (this.hasMarker(element, marker)) {
|
|
@@ -9884,7 +9930,7 @@
|
|
|
9884
9930
|
* root elements can be null. This is used for applications that want to manage
|
|
9885
9931
|
* root elements themselves.
|
|
9886
9932
|
*
|
|
9887
|
-
* @
|
|
9933
|
+
* @return {RootLike} The current root element.
|
|
9888
9934
|
*/
|
|
9889
9935
|
Canvas.prototype.getRootElement = function() {
|
|
9890
9936
|
const rootElement = this._rootElement;
|
|
@@ -9900,11 +9946,10 @@
|
|
|
9900
9946
|
/**
|
|
9901
9947
|
* Adds a given root element and returns it.
|
|
9902
9948
|
*
|
|
9903
|
-
* @param {
|
|
9949
|
+
* @param {ShapeLike} [rootElement] The root element to be added.
|
|
9904
9950
|
*
|
|
9905
|
-
* @return {
|
|
9951
|
+
* @return {RootLike} The added root element or an implicit root element.
|
|
9906
9952
|
*/
|
|
9907
|
-
|
|
9908
9953
|
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9909
9954
|
const idx = this._rootsIdx++;
|
|
9910
9955
|
|
|
@@ -9935,11 +9980,11 @@
|
|
|
9935
9980
|
};
|
|
9936
9981
|
|
|
9937
9982
|
/**
|
|
9938
|
-
* Removes a given
|
|
9983
|
+
* Removes a given root element and returns it.
|
|
9939
9984
|
*
|
|
9940
|
-
* @param {
|
|
9985
|
+
* @param {ShapeLike|string} rootElement The root element or its ID.
|
|
9941
9986
|
*
|
|
9942
|
-
* @return {
|
|
9987
|
+
* @return {ShapeLike|undefined} The removed root element.
|
|
9943
9988
|
*/
|
|
9944
9989
|
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
9945
9990
|
|
|
@@ -9973,15 +10018,13 @@
|
|
|
9973
10018
|
};
|
|
9974
10019
|
|
|
9975
10020
|
|
|
9976
|
-
// root element handling //////////////////////
|
|
9977
|
-
|
|
9978
10021
|
/**
|
|
9979
10022
|
* Sets a given element as the new root element for the canvas
|
|
9980
10023
|
* and returns the new root element.
|
|
9981
10024
|
*
|
|
9982
|
-
* @param {
|
|
10025
|
+
* @param {RootLike} rootElement The root element to be set.
|
|
9983
10026
|
*
|
|
9984
|
-
* @return {
|
|
10027
|
+
* @return {RootLike} The set root element.
|
|
9985
10028
|
*/
|
|
9986
10029
|
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
9987
10030
|
|
|
@@ -10068,8 +10111,6 @@
|
|
|
10068
10111
|
this._eventBus.fire('root.set', { element: rootElement });
|
|
10069
10112
|
};
|
|
10070
10113
|
|
|
10071
|
-
// add functionality //////////////////////
|
|
10072
|
-
|
|
10073
10114
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
10074
10115
|
if (!element.id) {
|
|
10075
10116
|
throw new Error('element must have an id');
|
|
@@ -10110,11 +10151,11 @@
|
|
|
10110
10151
|
* Extensions may hook into these events to perform their magic.
|
|
10111
10152
|
*
|
|
10112
10153
|
* @param {string} type
|
|
10113
|
-
* @param {
|
|
10114
|
-
* @param {
|
|
10154
|
+
* @param {ConnectionLike|ShapeLike} element
|
|
10155
|
+
* @param {ShapeLike} [parent]
|
|
10115
10156
|
* @param {number} [parentIndex]
|
|
10116
10157
|
*
|
|
10117
|
-
* @return {
|
|
10158
|
+
* @return {ConnectionLike|ShapeLike} The added element.
|
|
10118
10159
|
*/
|
|
10119
10160
|
Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
|
10120
10161
|
|
|
@@ -10143,26 +10184,26 @@
|
|
|
10143
10184
|
};
|
|
10144
10185
|
|
|
10145
10186
|
/**
|
|
10146
|
-
* Adds a shape to the canvas
|
|
10187
|
+
* Adds a shape to the canvas.
|
|
10147
10188
|
*
|
|
10148
|
-
* @param {
|
|
10149
|
-
* @param {
|
|
10150
|
-
* @param {number} [parentIndex]
|
|
10189
|
+
* @param {ShapeLike} shape The shape to be added
|
|
10190
|
+
* @param {ShapeLike} [parent] The shape's parent.
|
|
10191
|
+
* @param {number} [parentIndex] The index at which to add the shape to the parent's children.
|
|
10151
10192
|
*
|
|
10152
|
-
* @return {
|
|
10193
|
+
* @return {ShapeLike} The added shape.
|
|
10153
10194
|
*/
|
|
10154
10195
|
Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
|
10155
10196
|
return this._addElement('shape', shape, parent, parentIndex);
|
|
10156
10197
|
};
|
|
10157
10198
|
|
|
10158
10199
|
/**
|
|
10159
|
-
* Adds a connection to the canvas
|
|
10200
|
+
* Adds a connection to the canvas.
|
|
10160
10201
|
*
|
|
10161
|
-
* @param {
|
|
10162
|
-
* @param {
|
|
10163
|
-
* @param {number} [parentIndex]
|
|
10202
|
+
* @param {ConnectionLike} connection The connection to be added.
|
|
10203
|
+
* @param {ShapeLike} [parent] The connection's parent.
|
|
10204
|
+
* @param {number} [parentIndex] The index at which to add the connection to the parent's children.
|
|
10164
10205
|
*
|
|
10165
|
-
* @return {
|
|
10206
|
+
* @return {ConnectionLike} The added connection.
|
|
10166
10207
|
*/
|
|
10167
10208
|
Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
|
10168
10209
|
return this._addElement('connection', connection, parent, parentIndex);
|
|
@@ -10203,11 +10244,14 @@
|
|
|
10203
10244
|
|
|
10204
10245
|
|
|
10205
10246
|
/**
|
|
10206
|
-
* Removes a shape from the canvas
|
|
10247
|
+
* Removes a shape from the canvas.
|
|
10207
10248
|
*
|
|
10208
|
-
* @
|
|
10249
|
+
* @fires ShapeRemoveEvent
|
|
10250
|
+
* @fires ShapeRemovedEvent
|
|
10209
10251
|
*
|
|
10210
|
-
* @
|
|
10252
|
+
* @param {ShapeLike|string} shape The shape or its ID.
|
|
10253
|
+
*
|
|
10254
|
+
* @return {ShapeLike} The removed shape.
|
|
10211
10255
|
*/
|
|
10212
10256
|
Canvas.prototype.removeShape = function(shape) {
|
|
10213
10257
|
|
|
@@ -10216,10 +10260,10 @@
|
|
|
10216
10260
|
*
|
|
10217
10261
|
* @memberOf Canvas
|
|
10218
10262
|
*
|
|
10219
|
-
* @event
|
|
10263
|
+
* @event ShapeRemoveEvent
|
|
10220
10264
|
* @type {Object}
|
|
10221
|
-
* @property {
|
|
10222
|
-
* @property {
|
|
10265
|
+
* @property {ShapeLike} element The shape.
|
|
10266
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10223
10267
|
*/
|
|
10224
10268
|
|
|
10225
10269
|
/**
|
|
@@ -10227,21 +10271,24 @@
|
|
|
10227
10271
|
*
|
|
10228
10272
|
* @memberOf Canvas
|
|
10229
10273
|
*
|
|
10230
|
-
* @event
|
|
10274
|
+
* @event ShapeRemoved
|
|
10231
10275
|
* @type {Object}
|
|
10232
|
-
* @property {
|
|
10233
|
-
* @property {
|
|
10276
|
+
* @property {ShapeLike} element The shape.
|
|
10277
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10234
10278
|
*/
|
|
10235
10279
|
return this._removeElement(shape, 'shape');
|
|
10236
10280
|
};
|
|
10237
10281
|
|
|
10238
10282
|
|
|
10239
10283
|
/**
|
|
10240
|
-
* Removes a connection from the canvas
|
|
10284
|
+
* Removes a connection from the canvas.
|
|
10285
|
+
*
|
|
10286
|
+
* @fires ConnectionRemoveEvent
|
|
10287
|
+
* @fires ConnectionRemovedEvent
|
|
10241
10288
|
*
|
|
10242
|
-
* @param {string
|
|
10289
|
+
* @param {ConnectionLike|string} connection The connection or its ID.
|
|
10243
10290
|
*
|
|
10244
|
-
* @return {
|
|
10291
|
+
* @return {ConnectionLike} The removed connection.
|
|
10245
10292
|
*/
|
|
10246
10293
|
Canvas.prototype.removeConnection = function(connection) {
|
|
10247
10294
|
|
|
@@ -10250,10 +10297,10 @@
|
|
|
10250
10297
|
*
|
|
10251
10298
|
* @memberOf Canvas
|
|
10252
10299
|
*
|
|
10253
|
-
* @event
|
|
10300
|
+
* @event ConnectionRemoveEvent
|
|
10254
10301
|
* @type {Object}
|
|
10255
|
-
* @property {
|
|
10256
|
-
* @property {
|
|
10302
|
+
* @property {ConnectionLike} element The connection.
|
|
10303
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10257
10304
|
*/
|
|
10258
10305
|
|
|
10259
10306
|
/**
|
|
@@ -10263,20 +10310,20 @@
|
|
|
10263
10310
|
*
|
|
10264
10311
|
* @event connection.removed
|
|
10265
10312
|
* @type {Object}
|
|
10266
|
-
* @property {
|
|
10267
|
-
* @property {
|
|
10313
|
+
* @property {ConnectionLike} element The connection.
|
|
10314
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10268
10315
|
*/
|
|
10269
10316
|
return this._removeElement(connection, 'connection');
|
|
10270
10317
|
};
|
|
10271
10318
|
|
|
10272
10319
|
|
|
10273
10320
|
/**
|
|
10274
|
-
*
|
|
10321
|
+
* Returns the graphical element of an element.
|
|
10275
10322
|
*
|
|
10276
|
-
* @param {string
|
|
10277
|
-
* @param {boolean} [secondary=false]
|
|
10323
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
10324
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical element.
|
|
10278
10325
|
*
|
|
10279
|
-
* @return {SVGElement}
|
|
10326
|
+
* @return {SVGElement} The graphical element.
|
|
10280
10327
|
*/
|
|
10281
10328
|
Canvas.prototype.getGraphics = function(element, secondary) {
|
|
10282
10329
|
return this._elementRegistry.getGraphics(element, secondary);
|
|
@@ -10348,13 +10395,9 @@
|
|
|
10348
10395
|
* height: zoomedAndScrolledViewbox.outer.height
|
|
10349
10396
|
* });
|
|
10350
10397
|
*
|
|
10351
|
-
* @param
|
|
10352
|
-
* @param {number} box.x the top left X coordinate of the canvas visible in view box
|
|
10353
|
-
* @param {number} box.y the top left Y coordinate of the canvas visible in view box
|
|
10354
|
-
* @param {number} box.width the visible width
|
|
10355
|
-
* @param {number} box.height
|
|
10398
|
+
* @param {Rect} [box] The viewbox to be set.
|
|
10356
10399
|
*
|
|
10357
|
-
* @return {
|
|
10400
|
+
* @return {CanvasViewbox} The set viewbox.
|
|
10358
10401
|
*/
|
|
10359
10402
|
Canvas.prototype.viewbox = function(box) {
|
|
10360
10403
|
|
|
@@ -10423,10 +10466,9 @@
|
|
|
10423
10466
|
/**
|
|
10424
10467
|
* Gets or sets the scroll of the canvas.
|
|
10425
10468
|
*
|
|
10426
|
-
* @param {
|
|
10469
|
+
* @param {Point} [delta] The scroll to be set.
|
|
10427
10470
|
*
|
|
10428
|
-
* @
|
|
10429
|
-
* @param {number} [delta.dy]
|
|
10471
|
+
* @return {Point}
|
|
10430
10472
|
*/
|
|
10431
10473
|
Canvas.prototype.scroll = function(delta) {
|
|
10432
10474
|
|
|
@@ -10450,9 +10492,8 @@
|
|
|
10450
10492
|
* Scrolls the viewbox to contain the given element.
|
|
10451
10493
|
* Optionally specify a padding to be applied to the edges.
|
|
10452
10494
|
*
|
|
10453
|
-
* @param {
|
|
10454
|
-
* @param {
|
|
10455
|
-
*
|
|
10495
|
+
* @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
|
|
10496
|
+
* @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
|
|
10456
10497
|
*/
|
|
10457
10498
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
10458
10499
|
let defaultPadding = 100;
|
|
@@ -10520,17 +10561,17 @@
|
|
|
10520
10561
|
};
|
|
10521
10562
|
|
|
10522
10563
|
/**
|
|
10523
|
-
* Gets or sets the current zoom of the canvas, optionally zooming
|
|
10524
|
-
*
|
|
10564
|
+
* Gets or sets the current zoom of the canvas, optionally zooming to the
|
|
10565
|
+
* specified position.
|
|
10525
10566
|
*
|
|
10526
|
-
* The getter may return a cached zoom level. Call it with `false` as
|
|
10527
|
-
*
|
|
10567
|
+
* The getter may return a cached zoom level. Call it with `false` as the first
|
|
10568
|
+
* argument to force recomputation of the current level.
|
|
10528
10569
|
*
|
|
10529
|
-
* @param {string
|
|
10530
|
-
*
|
|
10531
|
-
* @param {
|
|
10570
|
+
* @param {number|string} [newScale] The new zoom level, either a number,
|
|
10571
|
+
* i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
|
|
10572
|
+
* @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
|
|
10532
10573
|
*
|
|
10533
|
-
* @return {number}
|
|
10574
|
+
* @return {number} The set zoom level.
|
|
10534
10575
|
*/
|
|
10535
10576
|
Canvas.prototype.zoom = function(newScale, center) {
|
|
10536
10577
|
|
|
@@ -10653,9 +10694,9 @@
|
|
|
10653
10694
|
|
|
10654
10695
|
|
|
10655
10696
|
/**
|
|
10656
|
-
* Returns the size of the canvas
|
|
10697
|
+
* Returns the size of the canvas.
|
|
10657
10698
|
*
|
|
10658
|
-
* @return {Dimensions}
|
|
10699
|
+
* @return {Dimensions} The size of the canvas.
|
|
10659
10700
|
*/
|
|
10660
10701
|
Canvas.prototype.getSize = function() {
|
|
10661
10702
|
return {
|
|
@@ -10666,14 +10707,14 @@
|
|
|
10666
10707
|
|
|
10667
10708
|
|
|
10668
10709
|
/**
|
|
10669
|
-
*
|
|
10710
|
+
* Returns the absolute bounding box of an element.
|
|
10711
|
+
*
|
|
10712
|
+
* The absolute bounding box may be used to display overlays in the callers
|
|
10713
|
+
* (browser) coordinate system rather than the zoomed in/out canvas coordinates.
|
|
10670
10714
|
*
|
|
10671
|
-
*
|
|
10672
|
-
* callers (browser) coordinate system rather than the zoomed in/out
|
|
10673
|
-
* canvas coordinates.
|
|
10715
|
+
* @param {ShapeLike|ConnectionLike} element The element.
|
|
10674
10716
|
*
|
|
10675
|
-
* @
|
|
10676
|
-
* @return {Bounds} the absolute bounding box
|
|
10717
|
+
* @return {Rect} The element's absolute bounding box.
|
|
10677
10718
|
*/
|
|
10678
10719
|
Canvas.prototype.getAbsoluteBBox = function(element) {
|
|
10679
10720
|
const vbox = this.viewbox();
|
|
@@ -10708,8 +10749,7 @@
|
|
|
10708
10749
|
};
|
|
10709
10750
|
|
|
10710
10751
|
/**
|
|
10711
|
-
* Fires an event
|
|
10712
|
-
* canvas resizing
|
|
10752
|
+
* Fires an event so other modules can react to the canvas resizing.
|
|
10713
10753
|
*/
|
|
10714
10754
|
Canvas.prototype.resized = function() {
|
|
10715
10755
|
|
|
@@ -10721,11 +10761,21 @@
|
|
|
10721
10761
|
|
|
10722
10762
|
var ELEMENT_ID = 'data-element-id';
|
|
10723
10763
|
|
|
10764
|
+
/**
|
|
10765
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
10766
|
+
*
|
|
10767
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
10768
|
+
*
|
|
10769
|
+
* @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
|
|
10770
|
+
*/
|
|
10724
10771
|
|
|
10725
10772
|
/**
|
|
10773
|
+
* A registry that keeps track of all shapes in the diagram.
|
|
10774
|
+
*
|
|
10726
10775
|
* @class
|
|
10776
|
+
* @constructor
|
|
10727
10777
|
*
|
|
10728
|
-
*
|
|
10778
|
+
* @param {EventBus} eventBus
|
|
10729
10779
|
*/
|
|
10730
10780
|
function ElementRegistry(eventBus) {
|
|
10731
10781
|
this._elements = {};
|
|
@@ -10736,11 +10786,11 @@
|
|
|
10736
10786
|
ElementRegistry.$inject = [ 'eventBus' ];
|
|
10737
10787
|
|
|
10738
10788
|
/**
|
|
10739
|
-
*
|
|
10789
|
+
* Add an element and its graphical representation(s) to the registry.
|
|
10740
10790
|
*
|
|
10741
|
-
* @param {
|
|
10742
|
-
* @param {SVGElement} gfx
|
|
10743
|
-
* @param {SVGElement} [secondaryGfx]
|
|
10791
|
+
* @param {ElementLike} element The element to be added.
|
|
10792
|
+
* @param {SVGElement} gfx The primary graphical representation.
|
|
10793
|
+
* @param {SVGElement} [secondaryGfx] The secondary graphical representation.
|
|
10744
10794
|
*/
|
|
10745
10795
|
ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
|
10746
10796
|
|
|
@@ -10759,9 +10809,9 @@
|
|
|
10759
10809
|
};
|
|
10760
10810
|
|
|
10761
10811
|
/**
|
|
10762
|
-
*
|
|
10812
|
+
* Remove an element from the registry.
|
|
10763
10813
|
*
|
|
10764
|
-
* @param {string
|
|
10814
|
+
* @param {ElementLike|string} element
|
|
10765
10815
|
*/
|
|
10766
10816
|
ElementRegistry.prototype.remove = function(element) {
|
|
10767
10817
|
var elements = this._elements,
|
|
@@ -10782,10 +10832,10 @@
|
|
|
10782
10832
|
};
|
|
10783
10833
|
|
|
10784
10834
|
/**
|
|
10785
|
-
* Update
|
|
10835
|
+
* Update an elements ID.
|
|
10786
10836
|
*
|
|
10787
|
-
* @param {string
|
|
10788
|
-
* @param {string} newId
|
|
10837
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10838
|
+
* @param {string} newId The new ID.
|
|
10789
10839
|
*/
|
|
10790
10840
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
10791
10841
|
|
|
@@ -10811,11 +10861,11 @@
|
|
|
10811
10861
|
};
|
|
10812
10862
|
|
|
10813
10863
|
/**
|
|
10814
|
-
* Update the
|
|
10864
|
+
* Update the graphical representation of an element.
|
|
10815
10865
|
*
|
|
10816
|
-
* @param {string
|
|
10817
|
-
* @param {SVGElement} gfx
|
|
10818
|
-
* @param {boolean} [secondary=false]
|
|
10866
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10867
|
+
* @param {SVGElement} gfx The new graphical representation.
|
|
10868
|
+
* @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
|
|
10819
10869
|
*/
|
|
10820
10870
|
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
10821
10871
|
var id = filter.id || filter;
|
|
@@ -10836,17 +10886,17 @@
|
|
|
10836
10886
|
};
|
|
10837
10887
|
|
|
10838
10888
|
/**
|
|
10839
|
-
*
|
|
10889
|
+
* Get the element with the given ID or graphical representation.
|
|
10840
10890
|
*
|
|
10841
10891
|
* @example
|
|
10842
10892
|
*
|
|
10843
10893
|
* elementRegistry.get('SomeElementId_1');
|
|
10844
|
-
* elementRegistry.get(gfx);
|
|
10845
10894
|
*
|
|
10895
|
+
* elementRegistry.get(gfx);
|
|
10846
10896
|
*
|
|
10847
|
-
* @param {string|SVGElement} filter
|
|
10897
|
+
* @param {string|SVGElement} filter The elements ID or graphical representation.
|
|
10848
10898
|
*
|
|
10849
|
-
* @return {
|
|
10899
|
+
* @return {ElementLike|undefined} The element.
|
|
10850
10900
|
*/
|
|
10851
10901
|
ElementRegistry.prototype.get = function(filter) {
|
|
10852
10902
|
var id;
|
|
@@ -10864,9 +10914,9 @@
|
|
|
10864
10914
|
/**
|
|
10865
10915
|
* Return all elements that match a given filter function.
|
|
10866
10916
|
*
|
|
10867
|
-
* @param {
|
|
10917
|
+
* @param {ElementRegistryCallback} fn The filter function.
|
|
10868
10918
|
*
|
|
10869
|
-
* @return {
|
|
10919
|
+
* @return {ElementLike[]} The matching elements.
|
|
10870
10920
|
*/
|
|
10871
10921
|
ElementRegistry.prototype.filter = function(fn) {
|
|
10872
10922
|
|
|
@@ -10882,11 +10932,11 @@
|
|
|
10882
10932
|
};
|
|
10883
10933
|
|
|
10884
10934
|
/**
|
|
10885
|
-
* Return the first element that
|
|
10935
|
+
* Return the first element that matches the given filter function.
|
|
10886
10936
|
*
|
|
10887
|
-
* @param {Function} fn
|
|
10937
|
+
* @param {Function} fn The filter function.
|
|
10888
10938
|
*
|
|
10889
|
-
* @return {
|
|
10939
|
+
* @return {ElementLike|undefined} The matching element.
|
|
10890
10940
|
*/
|
|
10891
10941
|
ElementRegistry.prototype.find = function(fn) {
|
|
10892
10942
|
var map = this._elements,
|
|
@@ -10905,18 +10955,18 @@
|
|
|
10905
10955
|
};
|
|
10906
10956
|
|
|
10907
10957
|
/**
|
|
10908
|
-
*
|
|
10958
|
+
* Get all elements.
|
|
10909
10959
|
*
|
|
10910
|
-
* @return {
|
|
10960
|
+
* @return {ElementLike[]} All elements.
|
|
10911
10961
|
*/
|
|
10912
10962
|
ElementRegistry.prototype.getAll = function() {
|
|
10913
10963
|
return this.filter(function(e) { return e; });
|
|
10914
10964
|
};
|
|
10915
10965
|
|
|
10916
10966
|
/**
|
|
10917
|
-
*
|
|
10967
|
+
* Execute a given function for each element.
|
|
10918
10968
|
*
|
|
10919
|
-
* @param {Function} fn
|
|
10969
|
+
* @param {Function} fn The function to execute.
|
|
10920
10970
|
*/
|
|
10921
10971
|
ElementRegistry.prototype.forEach = function(fn) {
|
|
10922
10972
|
|
|
@@ -10932,19 +10982,20 @@
|
|
|
10932
10982
|
};
|
|
10933
10983
|
|
|
10934
10984
|
/**
|
|
10935
|
-
* Return the graphical representation of an element
|
|
10985
|
+
* Return the graphical representation of an element.
|
|
10936
10986
|
*
|
|
10937
10987
|
* @example
|
|
10988
|
+
*
|
|
10938
10989
|
* elementRegistry.getGraphics('SomeElementId_1');
|
|
10990
|
+
*
|
|
10939
10991
|
* elementRegistry.getGraphics(rootElement); // <g ...>
|
|
10940
10992
|
*
|
|
10941
10993
|
* elementRegistry.getGraphics(rootElement, true); // <svg ...>
|
|
10942
10994
|
*
|
|
10995
|
+
* @param {ElementLike|string} filter The element or its ID.
|
|
10996
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
|
|
10943
10997
|
*
|
|
10944
|
-
* @
|
|
10945
|
-
* @param {boolean} [secondary=false] whether to return the secondary connected element
|
|
10946
|
-
*
|
|
10947
|
-
* @return {SVGElement}
|
|
10998
|
+
* @return {SVGElement} The graphical representation.
|
|
10948
10999
|
*/
|
|
10949
11000
|
ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
|
10950
11001
|
var id = filter.id || filter;
|
|
@@ -10954,12 +11005,11 @@
|
|
|
10954
11005
|
};
|
|
10955
11006
|
|
|
10956
11007
|
/**
|
|
10957
|
-
* Validate
|
|
10958
|
-
* with an exception.
|
|
11008
|
+
* Validate an ID and throw an error if invalid.
|
|
10959
11009
|
*
|
|
10960
11010
|
* @param {string} id
|
|
10961
11011
|
*
|
|
10962
|
-
* @throws {Error}
|
|
11012
|
+
* @throws {Error} Error indicating that the ID is invalid or already assigned.
|
|
10963
11013
|
*/
|
|
10964
11014
|
ElementRegistry.prototype._validateId = function(id) {
|
|
10965
11015
|
if (!id) {
|
|
@@ -11299,14 +11349,6 @@
|
|
|
11299
11349
|
outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
|
11300
11350
|
incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
|
|
11301
11351
|
|
|
11302
|
-
/**
|
|
11303
|
-
* @namespace djs.model
|
|
11304
|
-
*/
|
|
11305
|
-
|
|
11306
|
-
/**
|
|
11307
|
-
* @memberOf djs.model
|
|
11308
|
-
*/
|
|
11309
|
-
|
|
11310
11352
|
/**
|
|
11311
11353
|
* The basic graphical representation
|
|
11312
11354
|
*
|
|
@@ -11503,21 +11545,47 @@
|
|
|
11503
11545
|
};
|
|
11504
11546
|
|
|
11505
11547
|
/**
|
|
11506
|
-
* Creates a
|
|
11548
|
+
* Creates a model element of the given type.
|
|
11507
11549
|
*
|
|
11508
11550
|
* @method create
|
|
11509
11551
|
*
|
|
11510
11552
|
* @example
|
|
11511
11553
|
*
|
|
11512
|
-
*
|
|
11513
|
-
*
|
|
11554
|
+
* import * as Model from 'diagram-js/lib/model';
|
|
11555
|
+
*
|
|
11556
|
+
* const connection = Model.create('connection', {
|
|
11557
|
+
* waypoints: [
|
|
11558
|
+
* { x: 100, y: 100 },
|
|
11559
|
+
* { x: 200, y: 100 }
|
|
11560
|
+
* ]
|
|
11561
|
+
* });
|
|
11562
|
+
*
|
|
11563
|
+
* const label = Model.create('label', {
|
|
11564
|
+
* x: 100,
|
|
11565
|
+
* y: 100,
|
|
11566
|
+
* width: 100,
|
|
11567
|
+
* height: 100,
|
|
11568
|
+
* labelTarget: shape
|
|
11569
|
+
* });
|
|
11570
|
+
*
|
|
11571
|
+
* const root = Model.create('root', {
|
|
11572
|
+
* x: 100,
|
|
11573
|
+
* y: 100,
|
|
11574
|
+
* width: 100,
|
|
11575
|
+
* height: 100
|
|
11576
|
+
* });
|
|
11514
11577
|
*
|
|
11515
|
-
*
|
|
11578
|
+
* const shape = Model.create('shape', {
|
|
11579
|
+
* x: 100,
|
|
11580
|
+
* y: 100,
|
|
11581
|
+
* width: 100,
|
|
11582
|
+
* height: 100
|
|
11583
|
+
* });
|
|
11516
11584
|
*
|
|
11517
|
-
* @param
|
|
11518
|
-
* @param
|
|
11585
|
+
* @param {string} type The type of model element to be created.
|
|
11586
|
+
* @param {Object} attrs Attributes to create the model element with.
|
|
11519
11587
|
*
|
|
11520
|
-
* @return {
|
|
11588
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11521
11589
|
*/
|
|
11522
11590
|
function create(type, attrs) {
|
|
11523
11591
|
var Type = types$7[type];
|
|
@@ -11528,36 +11596,78 @@
|
|
|
11528
11596
|
}
|
|
11529
11597
|
|
|
11530
11598
|
/**
|
|
11531
|
-
*
|
|
11599
|
+
* @typedef {import('../model/index').Base} Base
|
|
11600
|
+
* @typedef {import('../model/index').Connection} Connection
|
|
11601
|
+
* @typedef {import('../model/index').Label} Label
|
|
11602
|
+
* @typedef {import('../model/index').Root} Root
|
|
11603
|
+
* @typedef {import('../model/index').Shape} Shape
|
|
11604
|
+
* @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
|
|
11605
|
+
* @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
|
|
11606
|
+
* @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
|
|
11607
|
+
* @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
|
|
11608
|
+
*/
|
|
11609
|
+
|
|
11610
|
+
/**
|
|
11611
|
+
* A factory for model elements.
|
|
11612
|
+
*
|
|
11613
|
+
* @class
|
|
11614
|
+
* @constructor
|
|
11532
11615
|
*/
|
|
11533
11616
|
function ElementFactory() {
|
|
11534
11617
|
this._uid = 12;
|
|
11535
11618
|
}
|
|
11536
11619
|
|
|
11537
|
-
|
|
11620
|
+
/**
|
|
11621
|
+
* Create a root element.
|
|
11622
|
+
*
|
|
11623
|
+
* @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
|
|
11624
|
+
*
|
|
11625
|
+
* @return {Root} The created root element.
|
|
11626
|
+
*/
|
|
11538
11627
|
ElementFactory.prototype.createRoot = function(attrs) {
|
|
11539
11628
|
return this.create('root', attrs);
|
|
11540
11629
|
};
|
|
11541
11630
|
|
|
11631
|
+
/**
|
|
11632
|
+
* Create a label.
|
|
11633
|
+
*
|
|
11634
|
+
* @param {ModelAttrsLabel} attrs The attributes of the label to be created.
|
|
11635
|
+
*
|
|
11636
|
+
* @return {Label} The created label.
|
|
11637
|
+
*/
|
|
11542
11638
|
ElementFactory.prototype.createLabel = function(attrs) {
|
|
11543
11639
|
return this.create('label', attrs);
|
|
11544
11640
|
};
|
|
11545
11641
|
|
|
11642
|
+
/**
|
|
11643
|
+
* Create a shape.
|
|
11644
|
+
*
|
|
11645
|
+
* @param {ModelAttrsShape} attrs The attributes of the shape to be created.
|
|
11646
|
+
*
|
|
11647
|
+
* @return {Shape} The created shape.
|
|
11648
|
+
*/
|
|
11546
11649
|
ElementFactory.prototype.createShape = function(attrs) {
|
|
11547
11650
|
return this.create('shape', attrs);
|
|
11548
11651
|
};
|
|
11549
11652
|
|
|
11653
|
+
/**
|
|
11654
|
+
* Create a connection.
|
|
11655
|
+
*
|
|
11656
|
+
* @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
|
|
11657
|
+
*
|
|
11658
|
+
* @return {Connection} The created connection.
|
|
11659
|
+
*/
|
|
11550
11660
|
ElementFactory.prototype.createConnection = function(attrs) {
|
|
11551
11661
|
return this.create('connection', attrs);
|
|
11552
11662
|
};
|
|
11553
11663
|
|
|
11554
11664
|
/**
|
|
11555
|
-
* Create a model element
|
|
11556
|
-
* a number of pre-set attributes.
|
|
11665
|
+
* Create a model element of the given type with the given attributes.
|
|
11557
11666
|
*
|
|
11558
|
-
* @param
|
|
11559
|
-
* @param
|
|
11560
|
-
*
|
|
11667
|
+
* @param {string} type The type of the model element.
|
|
11668
|
+
* @param {Object} attrs The attributes of the model element.
|
|
11669
|
+
*
|
|
11670
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11561
11671
|
*/
|
|
11562
11672
|
ElementFactory.prototype.create = function(type, attrs) {
|
|
11563
11673
|
|
|
@@ -11576,6 +11686,16 @@
|
|
|
11576
11686
|
|
|
11577
11687
|
var slice = Array.prototype.slice;
|
|
11578
11688
|
|
|
11689
|
+
/**
|
|
11690
|
+
* @typedef {import('./EventBus').Event} Event
|
|
11691
|
+
* @typedef {import('./EventBus').EventCallback} EventCallback
|
|
11692
|
+
*
|
|
11693
|
+
* @typedef {Object} EventListener
|
|
11694
|
+
* @property {Function} callback
|
|
11695
|
+
* @property {EventListener|null} next
|
|
11696
|
+
* @property {number} priority
|
|
11697
|
+
*/
|
|
11698
|
+
|
|
11579
11699
|
/**
|
|
11580
11700
|
* A general purpose event bus.
|
|
11581
11701
|
*
|
|
@@ -11680,10 +11800,10 @@
|
|
|
11680
11800
|
*
|
|
11681
11801
|
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
11682
11802
|
*
|
|
11683
|
-
* @param {string|
|
|
11684
|
-
* @param {number} [priority=1000]
|
|
11685
|
-
* @param {
|
|
11686
|
-
* @param {
|
|
11803
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
11804
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11805
|
+
* @param {EventCallback} callback The callback.
|
|
11806
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11687
11807
|
*/
|
|
11688
11808
|
EventBus.prototype.on = function(events, priority, callback, that) {
|
|
11689
11809
|
|
|
@@ -11723,12 +11843,12 @@
|
|
|
11723
11843
|
|
|
11724
11844
|
|
|
11725
11845
|
/**
|
|
11726
|
-
* Register an event listener that is
|
|
11846
|
+
* Register an event listener that is called only once.
|
|
11727
11847
|
*
|
|
11728
|
-
* @param {string} event
|
|
11729
|
-
* @param {number} [priority=1000]
|
|
11730
|
-
* @param {
|
|
11731
|
-
* @param {
|
|
11848
|
+
* @param {string} event The event to listen to.
|
|
11849
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11850
|
+
* @param {EventCallback} callback The callback.
|
|
11851
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11732
11852
|
*/
|
|
11733
11853
|
EventBus.prototype.once = function(event, priority, callback, that) {
|
|
11734
11854
|
var self = this;
|
|
@@ -11767,8 +11887,8 @@
|
|
|
11767
11887
|
*
|
|
11768
11888
|
* If no callback is given, all listeners for a given event name are being removed.
|
|
11769
11889
|
*
|
|
11770
|
-
* @param {string|
|
|
11771
|
-
* @param {
|
|
11890
|
+
* @param {string|string[]} events The events.
|
|
11891
|
+
* @param {EventCallback} [callback] The callback.
|
|
11772
11892
|
*/
|
|
11773
11893
|
EventBus.prototype.off = function(events, callback) {
|
|
11774
11894
|
|
|
@@ -11784,11 +11904,11 @@
|
|
|
11784
11904
|
|
|
11785
11905
|
|
|
11786
11906
|
/**
|
|
11787
|
-
* Create an
|
|
11907
|
+
* Create an event recognized be the event bus.
|
|
11788
11908
|
*
|
|
11789
|
-
* @param {Object} data
|
|
11909
|
+
* @param {Object} data Event data.
|
|
11790
11910
|
*
|
|
11791
|
-
* @return {
|
|
11911
|
+
* @return {Event} An event that will be recognized by the event bus.
|
|
11792
11912
|
*/
|
|
11793
11913
|
EventBus.prototype.createEvent = function(data) {
|
|
11794
11914
|
var event = new InternalEvent();
|
|
@@ -11800,7 +11920,7 @@
|
|
|
11800
11920
|
|
|
11801
11921
|
|
|
11802
11922
|
/**
|
|
11803
|
-
* Fires
|
|
11923
|
+
* Fires an event.
|
|
11804
11924
|
*
|
|
11805
11925
|
* @example
|
|
11806
11926
|
*
|
|
@@ -11822,12 +11942,11 @@
|
|
|
11822
11942
|
*
|
|
11823
11943
|
* events.fire({ type: 'foo' }, 'I am bar!');
|
|
11824
11944
|
*
|
|
11825
|
-
* @param {string} [
|
|
11826
|
-
* @param {Object} [
|
|
11827
|
-
* @param {
|
|
11945
|
+
* @param {string} [type] The event type.
|
|
11946
|
+
* @param {Object} [data] The event or event data.
|
|
11947
|
+
* @param {...*} additional Additional arguments the callback will be called with.
|
|
11828
11948
|
*
|
|
11829
|
-
* @return {
|
|
11830
|
-
* default action was prevented by listeners
|
|
11949
|
+
* @return {*} The return value. Will be set to `false` if the default was prevented.
|
|
11831
11950
|
*/
|
|
11832
11951
|
EventBus.prototype.fire = function(type, data) {
|
|
11833
11952
|
var event,
|
|
@@ -11892,7 +12011,13 @@
|
|
|
11892
12011
|
return returnValue;
|
|
11893
12012
|
};
|
|
11894
12013
|
|
|
11895
|
-
|
|
12014
|
+
/**
|
|
12015
|
+
* Handle an error by firing an event.
|
|
12016
|
+
*
|
|
12017
|
+
* @param {Error} error The error to be handled.
|
|
12018
|
+
*
|
|
12019
|
+
* @return {boolean} Whether the error was handled.
|
|
12020
|
+
*/
|
|
11896
12021
|
EventBus.prototype.handleError = function(error) {
|
|
11897
12022
|
return this.fire('error', { error: error }) === false;
|
|
11898
12023
|
};
|
|
@@ -11955,7 +12080,7 @@
|
|
|
11955
12080
|
return returnValue;
|
|
11956
12081
|
};
|
|
11957
12082
|
|
|
11958
|
-
|
|
12083
|
+
/**
|
|
11959
12084
|
* Add new listener with a certain priority to the list
|
|
11960
12085
|
* of listeners (for the given event).
|
|
11961
12086
|
*
|
|
@@ -11969,7 +12094,7 @@
|
|
|
11969
12094
|
* * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
|
|
11970
12095
|
*
|
|
11971
12096
|
* @param {string} event
|
|
11972
|
-
* @param {
|
|
12097
|
+
* @param {EventListener} listener
|
|
11973
12098
|
*/
|
|
11974
12099
|
EventBus.prototype._addListener = function(event, newListener) {
|
|
11975
12100
|
|
|
@@ -12075,9 +12200,9 @@
|
|
|
12075
12200
|
* Invoke function. Be fast...
|
|
12076
12201
|
*
|
|
12077
12202
|
* @param {Function} fn
|
|
12078
|
-
* @param {
|
|
12203
|
+
* @param {*[]} args
|
|
12079
12204
|
*
|
|
12080
|
-
* @return {
|
|
12205
|
+
* @return {*}
|
|
12081
12206
|
*/
|
|
12082
12207
|
function invokeFunction(fn, args) {
|
|
12083
12208
|
return fn.apply(null, args);
|
|
@@ -12091,11 +12216,11 @@
|
|
|
12091
12216
|
*/
|
|
12092
12217
|
|
|
12093
12218
|
/**
|
|
12094
|
-
* Returns the visual part of a diagram element
|
|
12219
|
+
* Returns the visual part of a diagram element.
|
|
12095
12220
|
*
|
|
12096
|
-
* @param {
|
|
12221
|
+
* @param {SVGElement} gfx
|
|
12097
12222
|
*
|
|
12098
|
-
* @return {
|
|
12223
|
+
* @return {SVGElement}
|
|
12099
12224
|
*/
|
|
12100
12225
|
function getVisual(gfx) {
|
|
12101
12226
|
return gfx.childNodes[0];
|
|
@@ -12104,15 +12229,28 @@
|
|
|
12104
12229
|
/**
|
|
12105
12230
|
* Returns the children for a given diagram element.
|
|
12106
12231
|
*
|
|
12107
|
-
* @param {
|
|
12108
|
-
* @return {
|
|
12232
|
+
* @param {SVGElement} gfx
|
|
12233
|
+
* @return {SVGElement}
|
|
12109
12234
|
*/
|
|
12110
12235
|
function getChildren(gfx) {
|
|
12111
12236
|
return gfx.parentNode.childNodes[1];
|
|
12112
12237
|
}
|
|
12113
12238
|
|
|
12114
12239
|
/**
|
|
12115
|
-
*
|
|
12240
|
+
* @typedef {import('../model').ModelType} ModelType
|
|
12241
|
+
* @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
|
|
12242
|
+
* @typedef {import('../model').ModelTypeShape} ModelTypeShape
|
|
12243
|
+
*
|
|
12244
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
12245
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
12246
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
12247
|
+
*
|
|
12248
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
12249
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
12250
|
+
*/
|
|
12251
|
+
|
|
12252
|
+
/**
|
|
12253
|
+
* A factory that creates graphical elements.
|
|
12116
12254
|
*
|
|
12117
12255
|
* @param {EventBus} eventBus
|
|
12118
12256
|
* @param {ElementRegistry} elementRegistry
|
|
@@ -12180,7 +12318,7 @@
|
|
|
12180
12318
|
* </g>
|
|
12181
12319
|
*
|
|
12182
12320
|
* @param {string} type the type of the element, i.e. shape | connection
|
|
12183
|
-
* @param {SVGElement}
|
|
12321
|
+
* @param {SVGElement} childrenGfx
|
|
12184
12322
|
* @param {number} [parentIndex] position to create container in parent
|
|
12185
12323
|
* @param {boolean} [isFrame] is frame element
|
|
12186
12324
|
*
|
|
@@ -12218,11 +12356,25 @@
|
|
|
12218
12356
|
return gfx;
|
|
12219
12357
|
};
|
|
12220
12358
|
|
|
12359
|
+
/**
|
|
12360
|
+
* Create a graphical element.
|
|
12361
|
+
*
|
|
12362
|
+
* @param {ModelType} type The type of the element.
|
|
12363
|
+
* @param {ElementLike} element The element.
|
|
12364
|
+
* @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
|
|
12365
|
+
*
|
|
12366
|
+
* @return {SVGElement} The graphical element.
|
|
12367
|
+
*/
|
|
12221
12368
|
GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
|
12222
12369
|
var childrenGfx = this._getChildrenContainer(element.parent);
|
|
12223
12370
|
return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
|
12224
12371
|
};
|
|
12225
12372
|
|
|
12373
|
+
/**
|
|
12374
|
+
* Update the containments of the given elements.
|
|
12375
|
+
*
|
|
12376
|
+
* @param {ElementLike[]} elements The elements.
|
|
12377
|
+
*/
|
|
12226
12378
|
GraphicsFactory.prototype.updateContainments = function(elements) {
|
|
12227
12379
|
|
|
12228
12380
|
var self = this,
|
|
@@ -12258,30 +12410,63 @@
|
|
|
12258
12410
|
});
|
|
12259
12411
|
};
|
|
12260
12412
|
|
|
12413
|
+
/**
|
|
12414
|
+
* Draw a shape.
|
|
12415
|
+
*
|
|
12416
|
+
* @param {SVGElement} visual The graphical element.
|
|
12417
|
+
* @param {ShapeLike} element The shape.
|
|
12418
|
+
*/
|
|
12261
12419
|
GraphicsFactory.prototype.drawShape = function(visual, element) {
|
|
12262
12420
|
var eventBus = this._eventBus;
|
|
12263
12421
|
|
|
12264
12422
|
return eventBus.fire('render.shape', { gfx: visual, element: element });
|
|
12265
12423
|
};
|
|
12266
12424
|
|
|
12425
|
+
/**
|
|
12426
|
+
* Get the path of a shape.
|
|
12427
|
+
*
|
|
12428
|
+
* @param {ShapeLike} element The shape.
|
|
12429
|
+
*
|
|
12430
|
+
* @return {string} The path of the shape.
|
|
12431
|
+
*/
|
|
12267
12432
|
GraphicsFactory.prototype.getShapePath = function(element) {
|
|
12268
12433
|
var eventBus = this._eventBus;
|
|
12269
12434
|
|
|
12270
12435
|
return eventBus.fire('render.getShapePath', element);
|
|
12271
12436
|
};
|
|
12272
12437
|
|
|
12438
|
+
/**
|
|
12439
|
+
* Draw a connection.
|
|
12440
|
+
*
|
|
12441
|
+
* @param {SVGElement} visual The graphical element.
|
|
12442
|
+
* @param {ConnectionLike} element The connection.
|
|
12443
|
+
*/
|
|
12273
12444
|
GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
|
12274
12445
|
var eventBus = this._eventBus;
|
|
12275
12446
|
|
|
12276
12447
|
return eventBus.fire('render.connection', { gfx: visual, element: element });
|
|
12277
12448
|
};
|
|
12278
12449
|
|
|
12279
|
-
|
|
12450
|
+
/**
|
|
12451
|
+
* Get the path of a connection.
|
|
12452
|
+
*
|
|
12453
|
+
* @param {ConnectionLike} element The connection.
|
|
12454
|
+
*
|
|
12455
|
+
* @return {string} The path of the connection.
|
|
12456
|
+
*/
|
|
12457
|
+
GraphicsFactory.prototype.getConnectionPath = function(connection) {
|
|
12280
12458
|
var eventBus = this._eventBus;
|
|
12281
12459
|
|
|
12282
|
-
return eventBus.fire('render.getConnectionPath',
|
|
12460
|
+
return eventBus.fire('render.getConnectionPath', connection);
|
|
12283
12461
|
};
|
|
12284
12462
|
|
|
12463
|
+
/**
|
|
12464
|
+
* Update an elements graphical representation.
|
|
12465
|
+
*
|
|
12466
|
+
* @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
|
|
12467
|
+
* @param {ElementLike} element The element.
|
|
12468
|
+
* @param {SVGElement} gfx The graphical representation.
|
|
12469
|
+
*/
|
|
12285
12470
|
GraphicsFactory.prototype.update = function(type, element, gfx) {
|
|
12286
12471
|
|
|
12287
12472
|
// do NOT update root element
|
|
@@ -12311,6 +12496,11 @@
|
|
|
12311
12496
|
}
|
|
12312
12497
|
};
|
|
12313
12498
|
|
|
12499
|
+
/**
|
|
12500
|
+
* Remove a graphical element.
|
|
12501
|
+
*
|
|
12502
|
+
* @param {ElementLike} element The element.
|
|
12503
|
+
*/
|
|
12314
12504
|
GraphicsFactory.prototype.remove = function(element) {
|
|
12315
12505
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12316
12506
|
|
|
@@ -12344,13 +12534,17 @@
|
|
|
12344
12534
|
};
|
|
12345
12535
|
|
|
12346
12536
|
/**
|
|
12347
|
-
* @typedef {
|
|
12537
|
+
* @typedef {import('didi').InjectionContext} InjectionContext
|
|
12538
|
+
* @typedef {import('didi').LocalsMap} LocalsMap
|
|
12539
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
12540
|
+
*
|
|
12541
|
+
* @typedef {import('./Diagram').DiagramOptions} DiagramOptions
|
|
12348
12542
|
*/
|
|
12349
12543
|
|
|
12350
12544
|
/**
|
|
12351
12545
|
* Bootstrap an injector from a list of modules, instantiating a number of default components
|
|
12352
12546
|
*
|
|
12353
|
-
* @param {
|
|
12547
|
+
* @param {ModuleDeclaration[]} modules
|
|
12354
12548
|
*
|
|
12355
12549
|
* @return {Injector} a injector to use to access the components
|
|
12356
12550
|
*/
|
|
@@ -12365,7 +12559,8 @@
|
|
|
12365
12559
|
/**
|
|
12366
12560
|
* Creates an injector from passed options.
|
|
12367
12561
|
*
|
|
12368
|
-
* @param {
|
|
12562
|
+
* @param {DiagramOptions} [options]
|
|
12563
|
+
*
|
|
12369
12564
|
* @return {Injector}
|
|
12370
12565
|
*/
|
|
12371
12566
|
function createInjector(options) {
|
|
@@ -12388,8 +12583,7 @@
|
|
|
12388
12583
|
*
|
|
12389
12584
|
* To register extensions with the diagram, pass them as Array<Module> to the constructor.
|
|
12390
12585
|
*
|
|
12391
|
-
* @class
|
|
12392
|
-
* @memberOf djs
|
|
12586
|
+
* @class
|
|
12393
12587
|
* @constructor
|
|
12394
12588
|
*
|
|
12395
12589
|
* @example
|
|
@@ -12427,9 +12621,9 @@
|
|
|
12427
12621
|
*
|
|
12428
12622
|
* // 'shape ... was added to the diagram' logged to console
|
|
12429
12623
|
*
|
|
12430
|
-
* @param {
|
|
12431
|
-
* @param {
|
|
12432
|
-
* @param {Injector} [injector]
|
|
12624
|
+
* @param {DiagramOptions} [options]
|
|
12625
|
+
* @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
|
|
12626
|
+
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
|
|
12433
12627
|
*/
|
|
12434
12628
|
function Diagram(options, injector) {
|
|
12435
12629
|
|
|
@@ -12439,22 +12633,23 @@
|
|
|
12439
12633
|
// API
|
|
12440
12634
|
|
|
12441
12635
|
/**
|
|
12442
|
-
* Resolves a diagram service
|
|
12636
|
+
* Resolves a diagram service.
|
|
12443
12637
|
*
|
|
12444
12638
|
* @method Diagram#get
|
|
12445
12639
|
*
|
|
12446
|
-
* @param {string} name
|
|
12447
|
-
* @param {boolean} [strict=true]
|
|
12640
|
+
* @param {string} name The name of the service to get.
|
|
12641
|
+
* @param {boolean} [strict=true] If false, resolve missing services to null.
|
|
12448
12642
|
*/
|
|
12449
12643
|
this.get = injector.get;
|
|
12450
12644
|
|
|
12451
12645
|
/**
|
|
12452
|
-
* Executes a function
|
|
12646
|
+
* Executes a function with its dependencies injected.
|
|
12453
12647
|
*
|
|
12454
12648
|
* @method Diagram#invoke
|
|
12455
12649
|
*
|
|
12456
|
-
* @param {Function
|
|
12457
|
-
* @param {
|
|
12650
|
+
* @param {Function} fn The function to be executed.
|
|
12651
|
+
* @param {InjectionContext} [context] The context.
|
|
12652
|
+
* @param {LocalsMap} [locals] The locals.
|
|
12458
12653
|
*/
|
|
12459
12654
|
this.invoke = injector.invoke;
|
|
12460
12655
|
|