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
|
*/
|
|
@@ -5899,6 +5936,14 @@
|
|
|
5899
5936
|
return isPrimaryButton(event) && originalEvent.shiftKey;
|
|
5900
5937
|
}
|
|
5901
5938
|
|
|
5939
|
+
/**
|
|
5940
|
+
* @typedef {import('../../model').Base} Base
|
|
5941
|
+
*
|
|
5942
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
5943
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
5944
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
5945
|
+
*/
|
|
5946
|
+
|
|
5902
5947
|
function allowAll(event) { return true; }
|
|
5903
5948
|
|
|
5904
5949
|
function allowPrimaryAndAuxiliary(event) {
|
|
@@ -5928,6 +5973,8 @@
|
|
|
5928
5973
|
* prevents the original DOM operation.
|
|
5929
5974
|
*
|
|
5930
5975
|
* @param {EventBus} eventBus
|
|
5976
|
+
* @param {ElementRegistry} elementRegistry
|
|
5977
|
+
* @param {Styles} styles
|
|
5931
5978
|
*/
|
|
5932
5979
|
function InteractionEvents(eventBus, elementRegistry, styles) {
|
|
5933
5980
|
|
|
@@ -5937,8 +5984,8 @@
|
|
|
5937
5984
|
* Fire an interaction event.
|
|
5938
5985
|
*
|
|
5939
5986
|
* @param {string} type local event name, e.g. element.click.
|
|
5940
|
-
* @param {
|
|
5941
|
-
* @param {
|
|
5987
|
+
* @param {MouseEvent|TouchEvent} event native event
|
|
5988
|
+
* @param {Base} [element] the diagram element to emit the event on;
|
|
5942
5989
|
* defaults to the event target
|
|
5943
5990
|
*/
|
|
5944
5991
|
function fire(type, event, element) {
|
|
@@ -6020,8 +6067,8 @@
|
|
|
6020
6067
|
* on the target shape or connection.
|
|
6021
6068
|
*
|
|
6022
6069
|
* @param {string} eventName the name of the triggered DOM event
|
|
6023
|
-
* @param {MouseEvent} event
|
|
6024
|
-
* @param {
|
|
6070
|
+
* @param {MouseEvent|TouchEvent} event
|
|
6071
|
+
* @param {Base} targetElement
|
|
6025
6072
|
*/
|
|
6026
6073
|
function triggerMouseEvent(eventName, event, targetElement) {
|
|
6027
6074
|
|
|
@@ -6187,7 +6234,7 @@
|
|
|
6187
6234
|
/**
|
|
6188
6235
|
* Create default hit for the given element.
|
|
6189
6236
|
*
|
|
6190
|
-
* @param {
|
|
6237
|
+
* @param {Base} element
|
|
6191
6238
|
* @param {SVGElement} gfx
|
|
6192
6239
|
*
|
|
6193
6240
|
* @return {SVGElement} created hit
|
|
@@ -6259,8 +6306,8 @@
|
|
|
6259
6306
|
/**
|
|
6260
6307
|
* Update default hit of the element.
|
|
6261
6308
|
*
|
|
6262
|
-
* @param
|
|
6263
|
-
* @param
|
|
6309
|
+
* @param {Base} element
|
|
6310
|
+
* @param {SVGElement} gfx
|
|
6264
6311
|
*
|
|
6265
6312
|
* @return {SVGElement} updated hit
|
|
6266
6313
|
*/
|
|
@@ -6308,7 +6355,7 @@
|
|
|
6308
6355
|
* @event element.hover
|
|
6309
6356
|
*
|
|
6310
6357
|
* @type {Object}
|
|
6311
|
-
* @property {
|
|
6358
|
+
* @property {Base} element
|
|
6312
6359
|
* @property {SVGElement} gfx
|
|
6313
6360
|
* @property {Event} originalEvent
|
|
6314
6361
|
*/
|
|
@@ -6319,7 +6366,7 @@
|
|
|
6319
6366
|
* @event element.out
|
|
6320
6367
|
*
|
|
6321
6368
|
* @type {Object}
|
|
6322
|
-
* @property {
|
|
6369
|
+
* @property {Base} element
|
|
6323
6370
|
* @property {SVGElement} gfx
|
|
6324
6371
|
* @property {Event} originalEvent
|
|
6325
6372
|
*/
|
|
@@ -6330,7 +6377,7 @@
|
|
|
6330
6377
|
* @event element.click
|
|
6331
6378
|
*
|
|
6332
6379
|
* @type {Object}
|
|
6333
|
-
* @property {
|
|
6380
|
+
* @property {Base} element
|
|
6334
6381
|
* @property {SVGElement} gfx
|
|
6335
6382
|
* @property {Event} originalEvent
|
|
6336
6383
|
*/
|
|
@@ -6341,7 +6388,7 @@
|
|
|
6341
6388
|
* @event element.dblclick
|
|
6342
6389
|
*
|
|
6343
6390
|
* @type {Object}
|
|
6344
|
-
* @property {
|
|
6391
|
+
* @property {Base} element
|
|
6345
6392
|
* @property {SVGElement} gfx
|
|
6346
6393
|
* @property {Event} originalEvent
|
|
6347
6394
|
*/
|
|
@@ -6352,7 +6399,7 @@
|
|
|
6352
6399
|
* @event element.mousedown
|
|
6353
6400
|
*
|
|
6354
6401
|
* @type {Object}
|
|
6355
|
-
* @property {
|
|
6402
|
+
* @property {Base} element
|
|
6356
6403
|
* @property {SVGElement} gfx
|
|
6357
6404
|
* @property {Event} originalEvent
|
|
6358
6405
|
*/
|
|
@@ -6363,7 +6410,7 @@
|
|
|
6363
6410
|
* @event element.mouseup
|
|
6364
6411
|
*
|
|
6365
6412
|
* @type {Object}
|
|
6366
|
-
* @property {
|
|
6413
|
+
* @property {Base} element
|
|
6367
6414
|
* @property {SVGElement} gfx
|
|
6368
6415
|
* @property {Event} originalEvent
|
|
6369
6416
|
*/
|
|
@@ -6375,7 +6422,7 @@
|
|
|
6375
6422
|
* @event element.contextmenu
|
|
6376
6423
|
*
|
|
6377
6424
|
* @type {Object}
|
|
6378
|
-
* @property {
|
|
6425
|
+
* @property {Base} element
|
|
6379
6426
|
* @property {SVGElement} gfx
|
|
6380
6427
|
* @property {Event} originalEvent
|
|
6381
6428
|
*/
|
|
@@ -6389,10 +6436,10 @@
|
|
|
6389
6436
|
* Returns the surrounding bbox for all elements in
|
|
6390
6437
|
* the array or the element primitive.
|
|
6391
6438
|
*
|
|
6392
|
-
* @param {
|
|
6439
|
+
* @param {Base|Base[]} elements
|
|
6393
6440
|
* @param {boolean} [stopRecursion=false]
|
|
6394
6441
|
*
|
|
6395
|
-
* @return {
|
|
6442
|
+
* @return {Rect}
|
|
6396
6443
|
*/
|
|
6397
6444
|
function getBBox(elements, stopRecursion) {
|
|
6398
6445
|
|
|
@@ -6463,6 +6510,12 @@
|
|
|
6463
6510
|
|
|
6464
6511
|
var LOW_PRIORITY$3 = 500;
|
|
6465
6512
|
|
|
6513
|
+
/**
|
|
6514
|
+
* @typedef {import('../../model').Base} Base
|
|
6515
|
+
*
|
|
6516
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6517
|
+
* @typedef {import('../../draw/Styles').default} Styles
|
|
6518
|
+
*/
|
|
6466
6519
|
|
|
6467
6520
|
/**
|
|
6468
6521
|
* @class
|
|
@@ -6472,9 +6525,8 @@
|
|
|
6472
6525
|
*
|
|
6473
6526
|
* @param {EventBus} eventBus
|
|
6474
6527
|
* @param {Styles} styles
|
|
6475
|
-
* @param {ElementRegistry} elementRegistry
|
|
6476
6528
|
*/
|
|
6477
|
-
function Outline(eventBus, styles
|
|
6529
|
+
function Outline(eventBus, styles) {
|
|
6478
6530
|
|
|
6479
6531
|
this.offset = 6;
|
|
6480
6532
|
|
|
@@ -6532,8 +6584,8 @@
|
|
|
6532
6584
|
* Updates the outline of a shape respecting the dimension of the
|
|
6533
6585
|
* element and an outline offset.
|
|
6534
6586
|
*
|
|
6535
|
-
* @param
|
|
6536
|
-
* @param
|
|
6587
|
+
* @param {SVGElement} outline
|
|
6588
|
+
* @param {Base} element
|
|
6537
6589
|
*/
|
|
6538
6590
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6539
6591
|
|
|
@@ -6551,8 +6603,8 @@
|
|
|
6551
6603
|
* Updates the outline of a connection respecting the bounding box of
|
|
6552
6604
|
* the connection and an outline offset.
|
|
6553
6605
|
*
|
|
6554
|
-
* @param
|
|
6555
|
-
* @param
|
|
6606
|
+
* @param {SVGElement} outline
|
|
6607
|
+
* @param {Base} element
|
|
6556
6608
|
*/
|
|
6557
6609
|
Outline.prototype.updateConnectionOutline = function(outline, connection) {
|
|
6558
6610
|
|
|
@@ -6575,13 +6627,17 @@
|
|
|
6575
6627
|
outline: [ 'type', Outline ]
|
|
6576
6628
|
};
|
|
6577
6629
|
|
|
6630
|
+
/**
|
|
6631
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6632
|
+
*/
|
|
6633
|
+
|
|
6578
6634
|
/**
|
|
6579
6635
|
* A service that offers the current selection in a diagram.
|
|
6580
6636
|
* Offers the api to control the selection, too.
|
|
6581
6637
|
*
|
|
6582
6638
|
* @class
|
|
6583
6639
|
*
|
|
6584
|
-
* @param {EventBus} eventBus
|
|
6640
|
+
* @param {EventBus} eventBus
|
|
6585
6641
|
*/
|
|
6586
6642
|
function Selection(eventBus, canvas) {
|
|
6587
6643
|
|
|
@@ -6637,8 +6693,8 @@
|
|
|
6637
6693
|
*
|
|
6638
6694
|
* @method Selection#select
|
|
6639
6695
|
*
|
|
6640
|
-
* @param
|
|
6641
|
-
* @param
|
|
6696
|
+
* @param {Object|Object[]} elements element or array of elements to be selected
|
|
6697
|
+
* @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
|
|
6642
6698
|
*/
|
|
6643
6699
|
Selection.prototype.select = function(elements, add) {
|
|
6644
6700
|
var selectedElements = this._selectedElements,
|
|
@@ -6677,6 +6733,12 @@
|
|
|
6677
6733
|
this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
|
|
6678
6734
|
};
|
|
6679
6735
|
|
|
6736
|
+
/**
|
|
6737
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6738
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6739
|
+
* @typedef {import('./Selection').default} Selection
|
|
6740
|
+
*/
|
|
6741
|
+
|
|
6680
6742
|
var MARKER_HOVER = 'hover',
|
|
6681
6743
|
MARKER_SELECTED = 'selected';
|
|
6682
6744
|
|
|
@@ -6693,6 +6755,7 @@
|
|
|
6693
6755
|
*
|
|
6694
6756
|
* @param {Canvas} canvas
|
|
6695
6757
|
* @param {EventBus} eventBus
|
|
6758
|
+
* @param {Selection} selection
|
|
6696
6759
|
*/
|
|
6697
6760
|
function SelectionVisuals(canvas, eventBus, selection) {
|
|
6698
6761
|
this._canvas = canvas;
|
|
@@ -6798,6 +6861,19 @@
|
|
|
6798
6861
|
};
|
|
6799
6862
|
}
|
|
6800
6863
|
|
|
6864
|
+
/**
|
|
6865
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
6866
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
6867
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
6868
|
+
* @typedef {import('./Selection').default} Selection
|
|
6869
|
+
*/
|
|
6870
|
+
|
|
6871
|
+
/**
|
|
6872
|
+
* @param {EventBus} eventBus
|
|
6873
|
+
* @param {Selection} selection
|
|
6874
|
+
* @param {Canvas} canvas
|
|
6875
|
+
* @param {ElementRegistry} elementRegistry
|
|
6876
|
+
*/
|
|
6801
6877
|
function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
|
|
6802
6878
|
|
|
6803
6879
|
// Select elements on create
|
|
@@ -6918,9 +6994,8 @@
|
|
|
6918
6994
|
/**
|
|
6919
6995
|
* Util that provides unique IDs.
|
|
6920
6996
|
*
|
|
6921
|
-
* @class
|
|
6997
|
+
* @class
|
|
6922
6998
|
* @constructor
|
|
6923
|
-
* @memberOf djs.util
|
|
6924
6999
|
*
|
|
6925
7000
|
* The ids can be customized via a given prefix and contain a random value to avoid collisions.
|
|
6926
7001
|
*
|
|
@@ -6935,8 +7010,6 @@
|
|
|
6935
7010
|
/**
|
|
6936
7011
|
* Returns a next unique ID.
|
|
6937
7012
|
*
|
|
6938
|
-
* @method djs.util.IdGenerator#next
|
|
6939
|
-
*
|
|
6940
7013
|
* @returns {string} the id
|
|
6941
7014
|
*/
|
|
6942
7015
|
IdGenerator.prototype.next = function() {
|
|
@@ -6948,6 +7021,18 @@
|
|
|
6948
7021
|
|
|
6949
7022
|
var LOW_PRIORITY$2 = 500;
|
|
6950
7023
|
|
|
7024
|
+
/**
|
|
7025
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7026
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7027
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7028
|
+
*
|
|
7029
|
+
* @typedef {import('./Overlays').Overlay} Overlay
|
|
7030
|
+
* @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
|
|
7031
|
+
* @typedef {import('./Overlays').OverlayContainer} OverlayContainer
|
|
7032
|
+
* @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
|
|
7033
|
+
* @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
|
|
7034
|
+
* @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
|
|
7035
|
+
*/
|
|
6951
7036
|
|
|
6952
7037
|
/**
|
|
6953
7038
|
* A service that allows users to attach overlays to diagram elements.
|
|
@@ -6957,6 +7042,7 @@
|
|
|
6957
7042
|
* @example
|
|
6958
7043
|
*
|
|
6959
7044
|
* // add a pink badge on the top left of the shape
|
|
7045
|
+
*
|
|
6960
7046
|
* overlays.add(someShape, {
|
|
6961
7047
|
* position: {
|
|
6962
7048
|
* top: -5,
|
|
@@ -7008,19 +7094,21 @@
|
|
|
7008
7094
|
* }
|
|
7009
7095
|
* }
|
|
7010
7096
|
*
|
|
7011
|
-
* @param {
|
|
7097
|
+
* @param {OverlaysConfig} config
|
|
7012
7098
|
* @param {EventBus} eventBus
|
|
7013
7099
|
* @param {Canvas} canvas
|
|
7014
7100
|
* @param {ElementRegistry} elementRegistry
|
|
7015
7101
|
*/
|
|
7016
7102
|
function Overlays(config, eventBus, canvas, elementRegistry) {
|
|
7017
|
-
|
|
7018
7103
|
this._eventBus = eventBus;
|
|
7019
7104
|
this._canvas = canvas;
|
|
7020
7105
|
this._elementRegistry = elementRegistry;
|
|
7021
7106
|
|
|
7022
7107
|
this._ids = ids;
|
|
7023
7108
|
|
|
7109
|
+
/**
|
|
7110
|
+
* @type {OverlaysConfigDefault}
|
|
7111
|
+
*/
|
|
7024
7112
|
this._overlayDefaults = assign$1({
|
|
7025
7113
|
|
|
7026
7114
|
// no show constraints
|
|
@@ -7031,16 +7119,18 @@
|
|
|
7031
7119
|
}, config && config.defaults);
|
|
7032
7120
|
|
|
7033
7121
|
/**
|
|
7034
|
-
*
|
|
7122
|
+
* @type {Map<string, Overlay>}
|
|
7035
7123
|
*/
|
|
7036
7124
|
this._overlays = {};
|
|
7037
7125
|
|
|
7038
7126
|
/**
|
|
7039
|
-
*
|
|
7127
|
+
* @type {OverlayContainer[]}
|
|
7040
7128
|
*/
|
|
7041
7129
|
this._overlayContainers = [];
|
|
7042
7130
|
|
|
7043
|
-
|
|
7131
|
+
/**
|
|
7132
|
+
* @type {HTMLElement}
|
|
7133
|
+
*/
|
|
7044
7134
|
this._overlayRoot = createRoot(canvas.getContainer());
|
|
7045
7135
|
|
|
7046
7136
|
this._init();
|
|
@@ -7056,12 +7146,12 @@
|
|
|
7056
7146
|
|
|
7057
7147
|
|
|
7058
7148
|
/**
|
|
7059
|
-
* Returns the overlay with the specified
|
|
7149
|
+
* Returns the overlay with the specified ID or a list of overlays
|
|
7060
7150
|
* for an element with a given type.
|
|
7061
7151
|
*
|
|
7062
7152
|
* @example
|
|
7063
7153
|
*
|
|
7064
|
-
* // return the single overlay with the given
|
|
7154
|
+
* // return the single overlay with the given ID
|
|
7065
7155
|
* overlays.get('some-id');
|
|
7066
7156
|
*
|
|
7067
7157
|
* // return all overlays for the shape
|
|
@@ -7070,16 +7160,12 @@
|
|
|
7070
7160
|
* // return all overlays on shape with type 'badge'
|
|
7071
7161
|
* overlays.get({ element: someShape, type: 'badge' });
|
|
7072
7162
|
*
|
|
7073
|
-
* // shape can also be specified as
|
|
7163
|
+
* // shape can also be specified as ID
|
|
7074
7164
|
* overlays.get({ element: 'element-id', type: 'badge' });
|
|
7075
7165
|
*
|
|
7166
|
+
* @param {OverlaysFilter} search The filter to be used to find the overlay(s).
|
|
7076
7167
|
*
|
|
7077
|
-
* @
|
|
7078
|
-
* @param {string} [search.id]
|
|
7079
|
-
* @param {string|djs.model.Base} [search.element]
|
|
7080
|
-
* @param {string} [search.type]
|
|
7081
|
-
*
|
|
7082
|
-
* @return {Object|Array<Object>} the overlay(s)
|
|
7168
|
+
* @return {Overlay|Overlay[]} The overlay(s).
|
|
7083
7169
|
*/
|
|
7084
7170
|
Overlays.prototype.get = function(search) {
|
|
7085
7171
|
|
|
@@ -7111,27 +7197,13 @@
|
|
|
7111
7197
|
};
|
|
7112
7198
|
|
|
7113
7199
|
/**
|
|
7114
|
-
* Adds
|
|
7115
|
-
*
|
|
7116
|
-
* @param {string|djs.model.Base} element attach overlay to this shape
|
|
7117
|
-
* @param {string} [type] optional type to assign to the overlay
|
|
7118
|
-
* @param {Object} overlay the overlay configuration
|
|
7200
|
+
* Adds an HTML overlay to an element.
|
|
7119
7201
|
*
|
|
7120
|
-
* @param {string
|
|
7121
|
-
* @param {
|
|
7122
|
-
* @param {
|
|
7123
|
-
* @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
|
|
7124
|
-
* @param {Object} overlay.position where to attach the overlay
|
|
7125
|
-
* @param {number} [overlay.position.left] relative to element bbox left attachment
|
|
7126
|
-
* @param {number} [overlay.position.top] relative to element bbox top attachment
|
|
7127
|
-
* @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
|
|
7128
|
-
* @param {number} [overlay.position.right] relative to element bbox right attachment
|
|
7129
|
-
* @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
|
|
7130
|
-
* diagram zoom
|
|
7131
|
-
* @param {number} [overlay.scale.min]
|
|
7132
|
-
* @param {number} [overlay.scale.max]
|
|
7202
|
+
* @param {Base|string} element The element to add the overlay to.
|
|
7203
|
+
* @param {string} [type] An optional type that can be used to filter.
|
|
7204
|
+
* @param {OverlayAttrs} overlay The overlay.
|
|
7133
7205
|
*
|
|
7134
|
-
* @return {string}
|
|
7206
|
+
* @return {string} The overlay's ID that can be used to get or remove it.
|
|
7135
7207
|
*/
|
|
7136
7208
|
Overlays.prototype.add = function(element, type, overlay) {
|
|
7137
7209
|
|
|
@@ -7172,11 +7244,11 @@
|
|
|
7172
7244
|
|
|
7173
7245
|
|
|
7174
7246
|
/**
|
|
7175
|
-
* Remove an overlay with the given
|
|
7247
|
+
* Remove an overlay with the given ID or all overlays matching the given filter.
|
|
7176
7248
|
*
|
|
7177
7249
|
* @see Overlays#get for filter options.
|
|
7178
7250
|
*
|
|
7179
|
-
* @param {
|
|
7251
|
+
* @param {OverlaysFilter} filter The filter to be used to find the overlay.
|
|
7180
7252
|
*/
|
|
7181
7253
|
Overlays.prototype.remove = function(filter) {
|
|
7182
7254
|
|
|
@@ -7212,19 +7284,32 @@
|
|
|
7212
7284
|
|
|
7213
7285
|
};
|
|
7214
7286
|
|
|
7287
|
+
/**
|
|
7288
|
+
* Checks whether overlays are shown.
|
|
7289
|
+
*
|
|
7290
|
+
* @returns {boolean} Whether overlays are shown.
|
|
7291
|
+
*/
|
|
7215
7292
|
Overlays.prototype.isShown = function() {
|
|
7216
7293
|
return this._overlayRoot.style.display !== 'none';
|
|
7217
7294
|
};
|
|
7218
7295
|
|
|
7296
|
+
/**
|
|
7297
|
+
* Show all overlays.
|
|
7298
|
+
*/
|
|
7219
7299
|
Overlays.prototype.show = function() {
|
|
7220
7300
|
setVisible(this._overlayRoot);
|
|
7221
7301
|
};
|
|
7222
7302
|
|
|
7223
|
-
|
|
7303
|
+
/**
|
|
7304
|
+
* Hide all overlays.
|
|
7305
|
+
*/
|
|
7224
7306
|
Overlays.prototype.hide = function() {
|
|
7225
7307
|
setVisible(this._overlayRoot, false);
|
|
7226
7308
|
};
|
|
7227
7309
|
|
|
7310
|
+
/**
|
|
7311
|
+
* Remove all overlays and their container.
|
|
7312
|
+
*/
|
|
7228
7313
|
Overlays.prototype.clear = function() {
|
|
7229
7314
|
this._overlays = {};
|
|
7230
7315
|
|
|
@@ -7600,6 +7685,13 @@
|
|
|
7600
7685
|
overlays: [ 'type', Overlays ]
|
|
7601
7686
|
};
|
|
7602
7687
|
|
|
7688
|
+
/**
|
|
7689
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7690
|
+
* @typedef {import('../../core/ElementRegistry').default} ElementRegistry
|
|
7691
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
7692
|
+
* @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
|
|
7693
|
+
*/
|
|
7694
|
+
|
|
7603
7695
|
/**
|
|
7604
7696
|
* Adds change support to the diagram, including
|
|
7605
7697
|
*
|
|
@@ -7669,32 +7761,41 @@
|
|
|
7669
7761
|
changeSupport: [ 'type', ChangeSupport ]
|
|
7670
7762
|
};
|
|
7671
7763
|
|
|
7764
|
+
/**
|
|
7765
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
7766
|
+
* @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
|
|
7767
|
+
* @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
|
|
7768
|
+
*/
|
|
7769
|
+
|
|
7672
7770
|
var DEFAULT_PRIORITY$2 = 1000;
|
|
7673
7771
|
|
|
7674
7772
|
/**
|
|
7675
|
-
* A utility that can be used to plug
|
|
7773
|
+
* A utility that can be used to plug into the command execution for
|
|
7676
7774
|
* extension and/or validation.
|
|
7677
7775
|
*
|
|
7776
|
+
* @class
|
|
7777
|
+
* @constructor
|
|
7778
|
+
*
|
|
7678
7779
|
* @param {EventBus} eventBus
|
|
7679
7780
|
*
|
|
7680
7781
|
* @example
|
|
7681
7782
|
*
|
|
7682
|
-
* import inherits from 'inherits-browser';
|
|
7683
|
-
*
|
|
7684
7783
|
* import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
|
|
7685
7784
|
*
|
|
7686
|
-
*
|
|
7687
|
-
*
|
|
7785
|
+
* class CommandLogger extends CommandInterceptor {
|
|
7786
|
+
* constructor(eventBus) {
|
|
7787
|
+
* super(eventBus);
|
|
7688
7788
|
*
|
|
7689
|
-
* this.preExecute(
|
|
7690
|
-
* console.log('
|
|
7789
|
+
* this.preExecute('shape.create', (event) => {
|
|
7790
|
+
* console.log('commandStack.shape-create.preExecute', event);
|
|
7691
7791
|
* });
|
|
7692
7792
|
* }
|
|
7693
|
-
*
|
|
7694
|
-
* inherits(CommandLogger, CommandInterceptor);
|
|
7695
|
-
*
|
|
7696
7793
|
*/
|
|
7697
7794
|
function CommandInterceptor(eventBus) {
|
|
7795
|
+
|
|
7796
|
+
/**
|
|
7797
|
+
* @type {EventBus}
|
|
7798
|
+
*/
|
|
7698
7799
|
this._eventBus = eventBus;
|
|
7699
7800
|
}
|
|
7700
7801
|
|
|
@@ -7707,16 +7808,15 @@
|
|
|
7707
7808
|
}
|
|
7708
7809
|
|
|
7709
7810
|
/**
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
*/
|
|
7811
|
+
* Intercept a command during one of the phases.
|
|
7812
|
+
*
|
|
7813
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7814
|
+
* @param {string} [hook] Phase during which to intercept command.
|
|
7815
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7816
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7817
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7818
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7819
|
+
*/
|
|
7720
7820
|
CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
|
|
7721
7821
|
|
|
7722
7822
|
if (isFunction(hook) || isNumber(hook)) {
|
|
@@ -7772,24 +7872,19 @@
|
|
|
7772
7872
|
];
|
|
7773
7873
|
|
|
7774
7874
|
/*
|
|
7775
|
-
*
|
|
7776
|
-
*
|
|
7777
|
-
* This will generate the CommandInterceptor#(preExecute|...|reverted) methods
|
|
7778
|
-
* which will in term forward to CommandInterceptor#on.
|
|
7875
|
+
* Add prototype methods for each phase of command execution (e.g. execute,
|
|
7876
|
+
* revert).
|
|
7779
7877
|
*/
|
|
7780
7878
|
forEach$1(hooks, function(hook) {
|
|
7781
7879
|
|
|
7782
7880
|
/**
|
|
7783
|
-
*
|
|
7784
|
-
*
|
|
7785
|
-
* A named hook for plugging into the command execution
|
|
7881
|
+
* Add prototype method for a specific phase of command execution.
|
|
7786
7882
|
*
|
|
7787
|
-
* @param {string|
|
|
7788
|
-
* @param {number} [priority]
|
|
7789
|
-
* @param {
|
|
7790
|
-
* @param {boolean} [unwrap
|
|
7791
|
-
*
|
|
7792
|
-
* @param {Object} [that] Pass context (`this`) to the handler function
|
|
7883
|
+
* @param {string|string[]} [events] One or more commands to intercept.
|
|
7884
|
+
* @param {number} [priority] Priority with which command will be intercepted.
|
|
7885
|
+
* @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
|
|
7886
|
+
* @param {boolean} [unwrap] Whether the event should be unwrapped.
|
|
7887
|
+
* @param {*} [that] `this` value the callback will be called with.
|
|
7793
7888
|
*/
|
|
7794
7889
|
CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
|
|
7795
7890
|
|
|
@@ -7805,12 +7900,18 @@
|
|
|
7805
7900
|
};
|
|
7806
7901
|
});
|
|
7807
7902
|
|
|
7903
|
+
/**
|
|
7904
|
+
* @typedef {import('didi').Injector} Injector
|
|
7905
|
+
*
|
|
7906
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
7907
|
+
*/
|
|
7908
|
+
|
|
7808
7909
|
/**
|
|
7809
7910
|
* A modeling behavior that ensures we set the correct root element
|
|
7810
7911
|
* as we undo and redo commands.
|
|
7811
7912
|
*
|
|
7812
7913
|
* @param {Canvas} canvas
|
|
7813
|
-
* @param {
|
|
7914
|
+
* @param {Injector} injector
|
|
7814
7915
|
*/
|
|
7815
7916
|
function RootElementsBehavior(canvas, injector) {
|
|
7816
7917
|
|
|
@@ -7844,111 +7945,10 @@
|
|
|
7844
7945
|
rootElementsBehavior: [ 'type', RootElementsBehavior ]
|
|
7845
7946
|
};
|
|
7846
7947
|
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
(function (module, exports) {
|
|
7852
|
-
(function(root, factory) {
|
|
7853
|
-
// https://github.com/umdjs/umd/blob/master/returnExports.js
|
|
7854
|
-
{
|
|
7855
|
-
// For Node.js.
|
|
7856
|
-
module.exports = factory(root);
|
|
7857
|
-
}
|
|
7858
|
-
}(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
|
|
7859
|
-
|
|
7860
|
-
if (root.CSS && root.CSS.escape) {
|
|
7861
|
-
return root.CSS.escape;
|
|
7862
|
-
}
|
|
7863
|
-
|
|
7864
|
-
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7865
|
-
var cssEscape = function(value) {
|
|
7866
|
-
if (arguments.length == 0) {
|
|
7867
|
-
throw new TypeError('`CSS.escape` requires an argument.');
|
|
7868
|
-
}
|
|
7869
|
-
var string = String(value);
|
|
7870
|
-
var length = string.length;
|
|
7871
|
-
var index = -1;
|
|
7872
|
-
var codeUnit;
|
|
7873
|
-
var result = '';
|
|
7874
|
-
var firstCodeUnit = string.charCodeAt(0);
|
|
7875
|
-
while (++index < length) {
|
|
7876
|
-
codeUnit = string.charCodeAt(index);
|
|
7877
|
-
// Note: there’s no need to special-case astral symbols, surrogate
|
|
7878
|
-
// pairs, or lone surrogates.
|
|
7879
|
-
|
|
7880
|
-
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
7881
|
-
// (U+FFFD).
|
|
7882
|
-
if (codeUnit == 0x0000) {
|
|
7883
|
-
result += '\uFFFD';
|
|
7884
|
-
continue;
|
|
7885
|
-
}
|
|
7886
|
-
|
|
7887
|
-
if (
|
|
7888
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
7889
|
-
// U+007F, […]
|
|
7890
|
-
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
|
7891
|
-
// If the character is the first character and is in the range [0-9]
|
|
7892
|
-
// (U+0030 to U+0039), […]
|
|
7893
|
-
(index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
|
7894
|
-
// If the character is the second character and is in the range [0-9]
|
|
7895
|
-
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
7896
|
-
(
|
|
7897
|
-
index == 1 &&
|
|
7898
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
|
7899
|
-
firstCodeUnit == 0x002D
|
|
7900
|
-
)
|
|
7901
|
-
) {
|
|
7902
|
-
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
7903
|
-
result += '\\' + codeUnit.toString(16) + ' ';
|
|
7904
|
-
continue;
|
|
7905
|
-
}
|
|
7906
|
-
|
|
7907
|
-
if (
|
|
7908
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
7909
|
-
// there is no second character, […]
|
|
7910
|
-
index == 0 &&
|
|
7911
|
-
length == 1 &&
|
|
7912
|
-
codeUnit == 0x002D
|
|
7913
|
-
) {
|
|
7914
|
-
result += '\\' + string.charAt(index);
|
|
7915
|
-
continue;
|
|
7916
|
-
}
|
|
7917
|
-
|
|
7918
|
-
// If the character is not handled by one of the above rules and is
|
|
7919
|
-
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
7920
|
-
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
7921
|
-
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
7922
|
-
if (
|
|
7923
|
-
codeUnit >= 0x0080 ||
|
|
7924
|
-
codeUnit == 0x002D ||
|
|
7925
|
-
codeUnit == 0x005F ||
|
|
7926
|
-
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
|
7927
|
-
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
|
7928
|
-
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
|
7929
|
-
) {
|
|
7930
|
-
// the character itself
|
|
7931
|
-
result += string.charAt(index);
|
|
7932
|
-
continue;
|
|
7933
|
-
}
|
|
7934
|
-
|
|
7935
|
-
// Otherwise, the escaped character.
|
|
7936
|
-
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
7937
|
-
result += '\\' + string.charAt(index);
|
|
7938
|
-
|
|
7939
|
-
}
|
|
7940
|
-
return result;
|
|
7941
|
-
};
|
|
7942
|
-
|
|
7943
|
-
if (!root.CSS) {
|
|
7944
|
-
root.CSS = {};
|
|
7945
|
-
}
|
|
7946
|
-
|
|
7947
|
-
root.CSS.escape = cssEscape;
|
|
7948
|
-
return cssEscape;
|
|
7949
|
-
|
|
7950
|
-
}));
|
|
7951
|
-
} (css_escape));
|
|
7948
|
+
/**
|
|
7949
|
+
* @param {string} str
|
|
7950
|
+
* @returns {string}
|
|
7951
|
+
*/
|
|
7952
7952
|
|
|
7953
7953
|
var HTML_ESCAPE_MAP = {
|
|
7954
7954
|
'&': '&',
|
|
@@ -9083,6 +9083,11 @@
|
|
|
9083
9083
|
return value;
|
|
9084
9084
|
}
|
|
9085
9085
|
|
|
9086
|
+
/**
|
|
9087
|
+
* @typedef {import('../core/EventBus').default} EventBus
|
|
9088
|
+
* @typedef {import('./Styles').default} Styles
|
|
9089
|
+
*/
|
|
9090
|
+
|
|
9086
9091
|
// apply default renderer with lowest possible priority
|
|
9087
9092
|
// so that it only kicks in if noone else could render
|
|
9088
9093
|
var DEFAULT_RENDER_PRIORITY = 1;
|
|
@@ -9200,9 +9205,9 @@
|
|
|
9200
9205
|
/**
|
|
9201
9206
|
* Builds a style definition from a className, a list of traits and an object of additional attributes.
|
|
9202
9207
|
*
|
|
9203
|
-
* @param
|
|
9204
|
-
* @param
|
|
9205
|
-
* @param
|
|
9208
|
+
* @param {string} className
|
|
9209
|
+
* @param {Array<string>} traits
|
|
9210
|
+
* @param {Object} additionalAttrs
|
|
9206
9211
|
*
|
|
9207
9212
|
* @return {Object} the style defintion
|
|
9208
9213
|
*/
|
|
@@ -9215,8 +9220,8 @@
|
|
|
9215
9220
|
/**
|
|
9216
9221
|
* Builds a style definition from a list of traits and an object of additional attributes.
|
|
9217
9222
|
*
|
|
9218
|
-
* @param
|
|
9219
|
-
* @param
|
|
9223
|
+
* @param {Array<string>} traits
|
|
9224
|
+
* @param {Object} additionalAttrs
|
|
9220
9225
|
*
|
|
9221
9226
|
* @return {Object} the style defintion
|
|
9222
9227
|
*/
|
|
@@ -9253,8 +9258,8 @@
|
|
|
9253
9258
|
/**
|
|
9254
9259
|
* Failsafe remove an element from a collection
|
|
9255
9260
|
*
|
|
9256
|
-
* @param
|
|
9257
|
-
* @param
|
|
9261
|
+
* @param {Array<Object>} [collection]
|
|
9262
|
+
* @param {Object} [element]
|
|
9258
9263
|
*
|
|
9259
9264
|
* @return {number} the previous index of the element
|
|
9260
9265
|
*/
|
|
@@ -9324,6 +9329,27 @@
|
|
|
9324
9329
|
}
|
|
9325
9330
|
}
|
|
9326
9331
|
|
|
9332
|
+
/**
|
|
9333
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
9334
|
+
* @typedef {import('.').RootLike} RootLike
|
|
9335
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
9336
|
+
*
|
|
9337
|
+
* @typedef {import('./Canvas').CanvasConfig} CanvasConfig
|
|
9338
|
+
* @typedef {import('./Canvas').CanvasLayer} CanvasLayer
|
|
9339
|
+
* @typedef {import('./Canvas').CanvasLayers} CanvasLayers
|
|
9340
|
+
* @typedef {import('./Canvas').CanvasPlane} CanvasPlane
|
|
9341
|
+
* @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
|
|
9342
|
+
*
|
|
9343
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
9344
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
9345
|
+
* @typedef {import('./GraphicsFactory').default} GraphicsFactory
|
|
9346
|
+
*
|
|
9347
|
+
* @typedef {import('../util/Types').Dimensions} Dimensions
|
|
9348
|
+
* @typedef {import('../util/Types').Point} Point
|
|
9349
|
+
* @typedef {import('../util/Types').Rect} Rect
|
|
9350
|
+
* @typedef {import('../util/Types').RectTRBL} RectTRBL
|
|
9351
|
+
*/
|
|
9352
|
+
|
|
9327
9353
|
function round(number, resolution) {
|
|
9328
9354
|
return Math.round(number * resolution) / resolution;
|
|
9329
9355
|
}
|
|
@@ -9344,7 +9370,8 @@
|
|
|
9344
9370
|
* Creates a HTML container element for a SVG element with
|
|
9345
9371
|
* the given configuration
|
|
9346
9372
|
*
|
|
9347
|
-
* @param
|
|
9373
|
+
* @param {CanvasConfig} options
|
|
9374
|
+
*
|
|
9348
9375
|
* @return {HTMLElement} the container element
|
|
9349
9376
|
*/
|
|
9350
9377
|
function createContainer(options) {
|
|
@@ -9404,21 +9431,34 @@
|
|
|
9404
9431
|
*
|
|
9405
9432
|
* @emits Canvas#canvas.init
|
|
9406
9433
|
*
|
|
9407
|
-
* @param {
|
|
9434
|
+
* @param {CanvasConfig|null} config
|
|
9408
9435
|
* @param {EventBus} eventBus
|
|
9409
9436
|
* @param {GraphicsFactory} graphicsFactory
|
|
9410
9437
|
* @param {ElementRegistry} elementRegistry
|
|
9411
9438
|
*/
|
|
9412
9439
|
function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
|
|
9413
|
-
|
|
9414
9440
|
this._eventBus = eventBus;
|
|
9415
9441
|
this._elementRegistry = elementRegistry;
|
|
9416
9442
|
this._graphicsFactory = graphicsFactory;
|
|
9417
9443
|
|
|
9444
|
+
/**
|
|
9445
|
+
* @type {number}
|
|
9446
|
+
*/
|
|
9418
9447
|
this._rootsIdx = 0;
|
|
9419
9448
|
|
|
9449
|
+
/**
|
|
9450
|
+
* @type {CanvasLayers}
|
|
9451
|
+
*/
|
|
9420
9452
|
this._layers = {};
|
|
9453
|
+
|
|
9454
|
+
/**
|
|
9455
|
+
* @type {CanvasPlane[]}
|
|
9456
|
+
*/
|
|
9421
9457
|
this._planes = [];
|
|
9458
|
+
|
|
9459
|
+
/**
|
|
9460
|
+
* @type {RootLike|null}
|
|
9461
|
+
*/
|
|
9422
9462
|
this._rootElement = null;
|
|
9423
9463
|
|
|
9424
9464
|
this._init(config || {});
|
|
@@ -9443,6 +9483,8 @@
|
|
|
9443
9483
|
* ...
|
|
9444
9484
|
* </svg>
|
|
9445
9485
|
* </div>
|
|
9486
|
+
*
|
|
9487
|
+
* @param {CanvasConfig} config
|
|
9446
9488
|
*/
|
|
9447
9489
|
Canvas.prototype._init = function(config) {
|
|
9448
9490
|
|
|
@@ -9464,7 +9506,7 @@
|
|
|
9464
9506
|
this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
|
|
9465
9507
|
}
|
|
9466
9508
|
|
|
9467
|
-
eventBus.on('diagram.init',
|
|
9509
|
+
eventBus.on('diagram.init', () => {
|
|
9468
9510
|
|
|
9469
9511
|
/**
|
|
9470
9512
|
* An event indicating that the canvas is ready to be drawn on.
|
|
@@ -9482,7 +9524,7 @@
|
|
|
9482
9524
|
viewport: viewport
|
|
9483
9525
|
});
|
|
9484
9526
|
|
|
9485
|
-
}
|
|
9527
|
+
});
|
|
9486
9528
|
|
|
9487
9529
|
// reset viewbox on shape changes to
|
|
9488
9530
|
// recompute the viewbox
|
|
@@ -9493,15 +9535,15 @@
|
|
|
9493
9535
|
'connection.removed',
|
|
9494
9536
|
'elements.changed',
|
|
9495
9537
|
'root.set'
|
|
9496
|
-
],
|
|
9538
|
+
], () => {
|
|
9497
9539
|
delete this._cachedViewbox;
|
|
9498
|
-
}
|
|
9540
|
+
});
|
|
9499
9541
|
|
|
9500
9542
|
eventBus.on('diagram.destroy', 500, this._destroy, this);
|
|
9501
9543
|
eventBus.on('diagram.clear', 500, this._clear, this);
|
|
9502
9544
|
};
|
|
9503
9545
|
|
|
9504
|
-
Canvas.prototype._destroy = function(
|
|
9546
|
+
Canvas.prototype._destroy = function() {
|
|
9505
9547
|
this._eventBus.fire('canvas.destroy', {
|
|
9506
9548
|
svg: this._svg,
|
|
9507
9549
|
viewport: this._viewport
|
|
@@ -9548,7 +9590,7 @@
|
|
|
9548
9590
|
* Returns the default layer on which
|
|
9549
9591
|
* all elements are drawn.
|
|
9550
9592
|
*
|
|
9551
|
-
* @
|
|
9593
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9552
9594
|
*/
|
|
9553
9595
|
Canvas.prototype.getDefaultLayer = function() {
|
|
9554
9596
|
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
@@ -9564,10 +9606,10 @@
|
|
|
9564
9606
|
* A layer with a certain index is always created above all
|
|
9565
9607
|
* existing layers with the same index.
|
|
9566
9608
|
*
|
|
9567
|
-
* @param {string} name
|
|
9568
|
-
* @param {number} index
|
|
9609
|
+
* @param {string} name The name of the layer.
|
|
9610
|
+
* @param {number} [index] The index of the layer.
|
|
9569
9611
|
*
|
|
9570
|
-
* @
|
|
9612
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9571
9613
|
*/
|
|
9572
9614
|
Canvas.prototype.getLayer = function(name, index) {
|
|
9573
9615
|
|
|
@@ -9596,8 +9638,9 @@
|
|
|
9596
9638
|
*
|
|
9597
9639
|
* This is used to determine the node a layer should be inserted at.
|
|
9598
9640
|
*
|
|
9599
|
-
* @param {
|
|
9600
|
-
*
|
|
9641
|
+
* @param {number} index
|
|
9642
|
+
*
|
|
9643
|
+
* @return {number}
|
|
9601
9644
|
*/
|
|
9602
9645
|
Canvas.prototype._getChildIndex = function(index) {
|
|
9603
9646
|
return reduce(this._layers, function(childIndex, layer) {
|
|
@@ -9615,7 +9658,7 @@
|
|
|
9615
9658
|
* @param {string} name
|
|
9616
9659
|
* @param {number} [index=0]
|
|
9617
9660
|
*
|
|
9618
|
-
* @return {
|
|
9661
|
+
* @return {CanvasLayer}
|
|
9619
9662
|
*/
|
|
9620
9663
|
Canvas.prototype._createLayer = function(name, index) {
|
|
9621
9664
|
|
|
@@ -9636,8 +9679,9 @@
|
|
|
9636
9679
|
/**
|
|
9637
9680
|
* Shows a given layer.
|
|
9638
9681
|
*
|
|
9639
|
-
* @param {
|
|
9640
|
-
*
|
|
9682
|
+
* @param {string} layer The name of the layer.
|
|
9683
|
+
*
|
|
9684
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9641
9685
|
*/
|
|
9642
9686
|
Canvas.prototype.showLayer = function(name) {
|
|
9643
9687
|
|
|
@@ -9671,8 +9715,9 @@
|
|
|
9671
9715
|
/**
|
|
9672
9716
|
* Hides a given layer.
|
|
9673
9717
|
*
|
|
9674
|
-
* @param {
|
|
9675
|
-
*
|
|
9718
|
+
* @param {string} layer The name of the layer.
|
|
9719
|
+
*
|
|
9720
|
+
* @return {SVGElement} The SVG element of the layer.
|
|
9676
9721
|
*/
|
|
9677
9722
|
Canvas.prototype.hideLayer = function(name) {
|
|
9678
9723
|
|
|
@@ -9714,7 +9759,7 @@
|
|
|
9714
9759
|
/**
|
|
9715
9760
|
* Returns the currently active layer. Can be null.
|
|
9716
9761
|
*
|
|
9717
|
-
* @
|
|
9762
|
+
* @return {CanvasLayer|null} The active layer of `null`.
|
|
9718
9763
|
*/
|
|
9719
9764
|
Canvas.prototype.getActiveLayer = function() {
|
|
9720
9765
|
const plane = this._findPlaneForRoot(this.getRootElement());
|
|
@@ -9730,9 +9775,9 @@
|
|
|
9730
9775
|
/**
|
|
9731
9776
|
* Returns the plane which contains the given element.
|
|
9732
9777
|
*
|
|
9733
|
-
* @param {string
|
|
9778
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9734
9779
|
*
|
|
9735
|
-
* @return {
|
|
9780
|
+
* @return {RootLike|undefined} The root of the element.
|
|
9736
9781
|
*/
|
|
9737
9782
|
Canvas.prototype.findRoot = function(element) {
|
|
9738
9783
|
if (typeof element === 'string') {
|
|
@@ -9753,7 +9798,7 @@
|
|
|
9753
9798
|
/**
|
|
9754
9799
|
* Return a list of all root elements on the diagram.
|
|
9755
9800
|
*
|
|
9756
|
-
* @return {
|
|
9801
|
+
* @return {(RootLike)[]} The list of root elements.
|
|
9757
9802
|
*/
|
|
9758
9803
|
Canvas.prototype.getRootElements = function() {
|
|
9759
9804
|
return this._planes.map(function(plane) {
|
|
@@ -9772,7 +9817,7 @@
|
|
|
9772
9817
|
* Returns the html element that encloses the
|
|
9773
9818
|
* drawing canvas.
|
|
9774
9819
|
*
|
|
9775
|
-
* @return {
|
|
9820
|
+
* @return {HTMLElement} The HTML element of the container.
|
|
9776
9821
|
*/
|
|
9777
9822
|
Canvas.prototype.getContainer = function() {
|
|
9778
9823
|
return this._container;
|
|
@@ -9812,8 +9857,8 @@
|
|
|
9812
9857
|
*
|
|
9813
9858
|
* @event element.marker.update
|
|
9814
9859
|
* @type {Object}
|
|
9815
|
-
* @property {
|
|
9816
|
-
* @property {
|
|
9860
|
+
* @property {Base} element the shape
|
|
9861
|
+
* @property {SVGElement} gfx the graphical representation of the shape
|
|
9817
9862
|
* @property {string} marker
|
|
9818
9863
|
* @property {boolean} add true if the marker was added, false if it got removed
|
|
9819
9864
|
*/
|
|
@@ -9828,14 +9873,15 @@
|
|
|
9828
9873
|
* integrate extension into the marker life-cycle, too.
|
|
9829
9874
|
*
|
|
9830
9875
|
* @example
|
|
9876
|
+
*
|
|
9831
9877
|
* canvas.addMarker('foo', 'some-marker');
|
|
9832
9878
|
*
|
|
9833
9879
|
* const fooGfx = canvas.getGraphics('foo');
|
|
9834
9880
|
*
|
|
9835
9881
|
* fooGfx; // <g class="... some-marker"> ... </g>
|
|
9836
9882
|
*
|
|
9837
|
-
* @param {string
|
|
9838
|
-
* @param {string} marker
|
|
9883
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9884
|
+
* @param {string} marker The marker.
|
|
9839
9885
|
*/
|
|
9840
9886
|
Canvas.prototype.addMarker = function(element, marker) {
|
|
9841
9887
|
this._updateMarker(element, marker, true);
|
|
@@ -9848,18 +9894,18 @@
|
|
|
9848
9894
|
* Fires the element.marker.update event, making it possible to
|
|
9849
9895
|
* integrate extension into the marker life-cycle, too.
|
|
9850
9896
|
*
|
|
9851
|
-
* @param
|
|
9852
|
-
* @param
|
|
9897
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9898
|
+
* @param {string} marker The marker.
|
|
9853
9899
|
*/
|
|
9854
9900
|
Canvas.prototype.removeMarker = function(element, marker) {
|
|
9855
9901
|
this._updateMarker(element, marker, false);
|
|
9856
9902
|
};
|
|
9857
9903
|
|
|
9858
9904
|
/**
|
|
9859
|
-
* Check
|
|
9905
|
+
* Check whether an element has a given marker.
|
|
9860
9906
|
*
|
|
9861
|
-
* @param
|
|
9862
|
-
* @param
|
|
9907
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9908
|
+
* @param {string} marker The marker.
|
|
9863
9909
|
*/
|
|
9864
9910
|
Canvas.prototype.hasMarker = function(element, marker) {
|
|
9865
9911
|
if (!element.id) {
|
|
@@ -9877,8 +9923,8 @@
|
|
|
9877
9923
|
* Fires the element.marker.update event, making it possible to
|
|
9878
9924
|
* integrate extension into the marker life-cycle, too.
|
|
9879
9925
|
*
|
|
9880
|
-
* @param
|
|
9881
|
-
* @param
|
|
9926
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
9927
|
+
* @param {string} marker The marker.
|
|
9882
9928
|
*/
|
|
9883
9929
|
Canvas.prototype.toggleMarker = function(element, marker) {
|
|
9884
9930
|
if (this.hasMarker(element, marker)) {
|
|
@@ -9901,7 +9947,7 @@
|
|
|
9901
9947
|
* root elements can be null. This is used for applications that want to manage
|
|
9902
9948
|
* root elements themselves.
|
|
9903
9949
|
*
|
|
9904
|
-
* @
|
|
9950
|
+
* @return {RootLike} The current root element.
|
|
9905
9951
|
*/
|
|
9906
9952
|
Canvas.prototype.getRootElement = function() {
|
|
9907
9953
|
const rootElement = this._rootElement;
|
|
@@ -9917,11 +9963,10 @@
|
|
|
9917
9963
|
/**
|
|
9918
9964
|
* Adds a given root element and returns it.
|
|
9919
9965
|
*
|
|
9920
|
-
* @param {
|
|
9966
|
+
* @param {ShapeLike} [rootElement] The root element to be added.
|
|
9921
9967
|
*
|
|
9922
|
-
* @return {
|
|
9968
|
+
* @return {RootLike} The added root element or an implicit root element.
|
|
9923
9969
|
*/
|
|
9924
|
-
|
|
9925
9970
|
Canvas.prototype.addRootElement = function(rootElement) {
|
|
9926
9971
|
const idx = this._rootsIdx++;
|
|
9927
9972
|
|
|
@@ -9952,11 +9997,11 @@
|
|
|
9952
9997
|
};
|
|
9953
9998
|
|
|
9954
9999
|
/**
|
|
9955
|
-
* Removes a given
|
|
10000
|
+
* Removes a given root element and returns it.
|
|
9956
10001
|
*
|
|
9957
|
-
* @param {
|
|
10002
|
+
* @param {ShapeLike|string} rootElement The root element or its ID.
|
|
9958
10003
|
*
|
|
9959
|
-
* @return {
|
|
10004
|
+
* @return {ShapeLike|undefined} The removed root element.
|
|
9960
10005
|
*/
|
|
9961
10006
|
Canvas.prototype.removeRootElement = function(rootElement) {
|
|
9962
10007
|
|
|
@@ -9990,15 +10035,13 @@
|
|
|
9990
10035
|
};
|
|
9991
10036
|
|
|
9992
10037
|
|
|
9993
|
-
// root element handling //////////////////////
|
|
9994
|
-
|
|
9995
10038
|
/**
|
|
9996
10039
|
* Sets a given element as the new root element for the canvas
|
|
9997
10040
|
* and returns the new root element.
|
|
9998
10041
|
*
|
|
9999
|
-
* @param {
|
|
10042
|
+
* @param {RootLike} rootElement The root element to be set.
|
|
10000
10043
|
*
|
|
10001
|
-
* @return {
|
|
10044
|
+
* @return {RootLike} The set root element.
|
|
10002
10045
|
*/
|
|
10003
10046
|
Canvas.prototype.setRootElement = function(rootElement, override) {
|
|
10004
10047
|
|
|
@@ -10085,8 +10128,6 @@
|
|
|
10085
10128
|
this._eventBus.fire('root.set', { element: rootElement });
|
|
10086
10129
|
};
|
|
10087
10130
|
|
|
10088
|
-
// add functionality //////////////////////
|
|
10089
|
-
|
|
10090
10131
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
10091
10132
|
if (!element.id) {
|
|
10092
10133
|
throw new Error('element must have an id');
|
|
@@ -10127,11 +10168,11 @@
|
|
|
10127
10168
|
* Extensions may hook into these events to perform their magic.
|
|
10128
10169
|
*
|
|
10129
10170
|
* @param {string} type
|
|
10130
|
-
* @param {
|
|
10131
|
-
* @param {
|
|
10171
|
+
* @param {ConnectionLike|ShapeLike} element
|
|
10172
|
+
* @param {ShapeLike} [parent]
|
|
10132
10173
|
* @param {number} [parentIndex]
|
|
10133
10174
|
*
|
|
10134
|
-
* @return {
|
|
10175
|
+
* @return {ConnectionLike|ShapeLike} The added element.
|
|
10135
10176
|
*/
|
|
10136
10177
|
Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
|
|
10137
10178
|
|
|
@@ -10160,26 +10201,26 @@
|
|
|
10160
10201
|
};
|
|
10161
10202
|
|
|
10162
10203
|
/**
|
|
10163
|
-
* Adds a shape to the canvas
|
|
10204
|
+
* Adds a shape to the canvas.
|
|
10164
10205
|
*
|
|
10165
|
-
* @param {
|
|
10166
|
-
* @param {
|
|
10167
|
-
* @param {number} [parentIndex]
|
|
10206
|
+
* @param {ShapeLike} shape The shape to be added
|
|
10207
|
+
* @param {ShapeLike} [parent] The shape's parent.
|
|
10208
|
+
* @param {number} [parentIndex] The index at which to add the shape to the parent's children.
|
|
10168
10209
|
*
|
|
10169
|
-
* @return {
|
|
10210
|
+
* @return {ShapeLike} The added shape.
|
|
10170
10211
|
*/
|
|
10171
10212
|
Canvas.prototype.addShape = function(shape, parent, parentIndex) {
|
|
10172
10213
|
return this._addElement('shape', shape, parent, parentIndex);
|
|
10173
10214
|
};
|
|
10174
10215
|
|
|
10175
10216
|
/**
|
|
10176
|
-
* Adds a connection to the canvas
|
|
10217
|
+
* Adds a connection to the canvas.
|
|
10177
10218
|
*
|
|
10178
|
-
* @param {
|
|
10179
|
-
* @param {
|
|
10180
|
-
* @param {number} [parentIndex]
|
|
10219
|
+
* @param {ConnectionLike} connection The connection to be added.
|
|
10220
|
+
* @param {ShapeLike} [parent] The connection's parent.
|
|
10221
|
+
* @param {number} [parentIndex] The index at which to add the connection to the parent's children.
|
|
10181
10222
|
*
|
|
10182
|
-
* @return {
|
|
10223
|
+
* @return {ConnectionLike} The added connection.
|
|
10183
10224
|
*/
|
|
10184
10225
|
Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
|
|
10185
10226
|
return this._addElement('connection', connection, parent, parentIndex);
|
|
@@ -10220,11 +10261,14 @@
|
|
|
10220
10261
|
|
|
10221
10262
|
|
|
10222
10263
|
/**
|
|
10223
|
-
* Removes a shape from the canvas
|
|
10264
|
+
* Removes a shape from the canvas.
|
|
10224
10265
|
*
|
|
10225
|
-
* @
|
|
10266
|
+
* @fires ShapeRemoveEvent
|
|
10267
|
+
* @fires ShapeRemovedEvent
|
|
10226
10268
|
*
|
|
10227
|
-
* @
|
|
10269
|
+
* @param {ShapeLike|string} shape The shape or its ID.
|
|
10270
|
+
*
|
|
10271
|
+
* @return {ShapeLike} The removed shape.
|
|
10228
10272
|
*/
|
|
10229
10273
|
Canvas.prototype.removeShape = function(shape) {
|
|
10230
10274
|
|
|
@@ -10233,10 +10277,10 @@
|
|
|
10233
10277
|
*
|
|
10234
10278
|
* @memberOf Canvas
|
|
10235
10279
|
*
|
|
10236
|
-
* @event
|
|
10280
|
+
* @event ShapeRemoveEvent
|
|
10237
10281
|
* @type {Object}
|
|
10238
|
-
* @property {
|
|
10239
|
-
* @property {
|
|
10282
|
+
* @property {ShapeLike} element The shape.
|
|
10283
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10240
10284
|
*/
|
|
10241
10285
|
|
|
10242
10286
|
/**
|
|
@@ -10244,21 +10288,24 @@
|
|
|
10244
10288
|
*
|
|
10245
10289
|
* @memberOf Canvas
|
|
10246
10290
|
*
|
|
10247
|
-
* @event
|
|
10291
|
+
* @event ShapeRemoved
|
|
10248
10292
|
* @type {Object}
|
|
10249
|
-
* @property {
|
|
10250
|
-
* @property {
|
|
10293
|
+
* @property {ShapeLike} element The shape.
|
|
10294
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10251
10295
|
*/
|
|
10252
10296
|
return this._removeElement(shape, 'shape');
|
|
10253
10297
|
};
|
|
10254
10298
|
|
|
10255
10299
|
|
|
10256
10300
|
/**
|
|
10257
|
-
* Removes a connection from the canvas
|
|
10301
|
+
* Removes a connection from the canvas.
|
|
10302
|
+
*
|
|
10303
|
+
* @fires ConnectionRemoveEvent
|
|
10304
|
+
* @fires ConnectionRemovedEvent
|
|
10258
10305
|
*
|
|
10259
|
-
* @param {string
|
|
10306
|
+
* @param {ConnectionLike|string} connection The connection or its ID.
|
|
10260
10307
|
*
|
|
10261
|
-
* @return {
|
|
10308
|
+
* @return {ConnectionLike} The removed connection.
|
|
10262
10309
|
*/
|
|
10263
10310
|
Canvas.prototype.removeConnection = function(connection) {
|
|
10264
10311
|
|
|
@@ -10267,10 +10314,10 @@
|
|
|
10267
10314
|
*
|
|
10268
10315
|
* @memberOf Canvas
|
|
10269
10316
|
*
|
|
10270
|
-
* @event
|
|
10317
|
+
* @event ConnectionRemoveEvent
|
|
10271
10318
|
* @type {Object}
|
|
10272
|
-
* @property {
|
|
10273
|
-
* @property {
|
|
10319
|
+
* @property {ConnectionLike} element The connection.
|
|
10320
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10274
10321
|
*/
|
|
10275
10322
|
|
|
10276
10323
|
/**
|
|
@@ -10280,20 +10327,20 @@
|
|
|
10280
10327
|
*
|
|
10281
10328
|
* @event connection.removed
|
|
10282
10329
|
* @type {Object}
|
|
10283
|
-
* @property {
|
|
10284
|
-
* @property {
|
|
10330
|
+
* @property {ConnectionLike} element The connection.
|
|
10331
|
+
* @property {SVGElement} gfx The graphical element.
|
|
10285
10332
|
*/
|
|
10286
10333
|
return this._removeElement(connection, 'connection');
|
|
10287
10334
|
};
|
|
10288
10335
|
|
|
10289
10336
|
|
|
10290
10337
|
/**
|
|
10291
|
-
*
|
|
10338
|
+
* Returns the graphical element of an element.
|
|
10292
10339
|
*
|
|
10293
|
-
* @param {string
|
|
10294
|
-
* @param {boolean} [secondary=false]
|
|
10340
|
+
* @param {ShapeLike|ConnectionLike|string} element The element or its ID.
|
|
10341
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical element.
|
|
10295
10342
|
*
|
|
10296
|
-
* @return {SVGElement}
|
|
10343
|
+
* @return {SVGElement} The graphical element.
|
|
10297
10344
|
*/
|
|
10298
10345
|
Canvas.prototype.getGraphics = function(element, secondary) {
|
|
10299
10346
|
return this._elementRegistry.getGraphics(element, secondary);
|
|
@@ -10365,13 +10412,9 @@
|
|
|
10365
10412
|
* height: zoomedAndScrolledViewbox.outer.height
|
|
10366
10413
|
* });
|
|
10367
10414
|
*
|
|
10368
|
-
* @param
|
|
10369
|
-
* @param {number} box.x the top left X coordinate of the canvas visible in view box
|
|
10370
|
-
* @param {number} box.y the top left Y coordinate of the canvas visible in view box
|
|
10371
|
-
* @param {number} box.width the visible width
|
|
10372
|
-
* @param {number} box.height
|
|
10415
|
+
* @param {Rect} [box] The viewbox to be set.
|
|
10373
10416
|
*
|
|
10374
|
-
* @return {
|
|
10417
|
+
* @return {CanvasViewbox} The set viewbox.
|
|
10375
10418
|
*/
|
|
10376
10419
|
Canvas.prototype.viewbox = function(box) {
|
|
10377
10420
|
|
|
@@ -10440,10 +10483,9 @@
|
|
|
10440
10483
|
/**
|
|
10441
10484
|
* Gets or sets the scroll of the canvas.
|
|
10442
10485
|
*
|
|
10443
|
-
* @param {
|
|
10486
|
+
* @param {Point} [delta] The scroll to be set.
|
|
10444
10487
|
*
|
|
10445
|
-
* @
|
|
10446
|
-
* @param {number} [delta.dy]
|
|
10488
|
+
* @return {Point}
|
|
10447
10489
|
*/
|
|
10448
10490
|
Canvas.prototype.scroll = function(delta) {
|
|
10449
10491
|
|
|
@@ -10467,9 +10509,8 @@
|
|
|
10467
10509
|
* Scrolls the viewbox to contain the given element.
|
|
10468
10510
|
* Optionally specify a padding to be applied to the edges.
|
|
10469
10511
|
*
|
|
10470
|
-
* @param {
|
|
10471
|
-
* @param {
|
|
10472
|
-
*
|
|
10512
|
+
* @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
|
|
10513
|
+
* @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
|
|
10473
10514
|
*/
|
|
10474
10515
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
10475
10516
|
let defaultPadding = 100;
|
|
@@ -10537,17 +10578,17 @@
|
|
|
10537
10578
|
};
|
|
10538
10579
|
|
|
10539
10580
|
/**
|
|
10540
|
-
* Gets or sets the current zoom of the canvas, optionally zooming
|
|
10541
|
-
*
|
|
10581
|
+
* Gets or sets the current zoom of the canvas, optionally zooming to the
|
|
10582
|
+
* specified position.
|
|
10542
10583
|
*
|
|
10543
|
-
* The getter may return a cached zoom level. Call it with `false` as
|
|
10544
|
-
*
|
|
10584
|
+
* The getter may return a cached zoom level. Call it with `false` as the first
|
|
10585
|
+
* argument to force recomputation of the current level.
|
|
10545
10586
|
*
|
|
10546
|
-
* @param {string
|
|
10547
|
-
*
|
|
10548
|
-
* @param {
|
|
10587
|
+
* @param {number|string} [newScale] The new zoom level, either a number,
|
|
10588
|
+
* i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
|
|
10589
|
+
* @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
|
|
10549
10590
|
*
|
|
10550
|
-
* @return {number}
|
|
10591
|
+
* @return {number} The set zoom level.
|
|
10551
10592
|
*/
|
|
10552
10593
|
Canvas.prototype.zoom = function(newScale, center) {
|
|
10553
10594
|
|
|
@@ -10670,9 +10711,9 @@
|
|
|
10670
10711
|
|
|
10671
10712
|
|
|
10672
10713
|
/**
|
|
10673
|
-
* Returns the size of the canvas
|
|
10714
|
+
* Returns the size of the canvas.
|
|
10674
10715
|
*
|
|
10675
|
-
* @return {Dimensions}
|
|
10716
|
+
* @return {Dimensions} The size of the canvas.
|
|
10676
10717
|
*/
|
|
10677
10718
|
Canvas.prototype.getSize = function() {
|
|
10678
10719
|
return {
|
|
@@ -10683,14 +10724,14 @@
|
|
|
10683
10724
|
|
|
10684
10725
|
|
|
10685
10726
|
/**
|
|
10686
|
-
*
|
|
10727
|
+
* Returns the absolute bounding box of an element.
|
|
10728
|
+
*
|
|
10729
|
+
* The absolute bounding box may be used to display overlays in the callers
|
|
10730
|
+
* (browser) coordinate system rather than the zoomed in/out canvas coordinates.
|
|
10687
10731
|
*
|
|
10688
|
-
*
|
|
10689
|
-
* callers (browser) coordinate system rather than the zoomed in/out
|
|
10690
|
-
* canvas coordinates.
|
|
10732
|
+
* @param {ShapeLike|ConnectionLike} element The element.
|
|
10691
10733
|
*
|
|
10692
|
-
* @
|
|
10693
|
-
* @return {Bounds} the absolute bounding box
|
|
10734
|
+
* @return {Rect} The element's absolute bounding box.
|
|
10694
10735
|
*/
|
|
10695
10736
|
Canvas.prototype.getAbsoluteBBox = function(element) {
|
|
10696
10737
|
const vbox = this.viewbox();
|
|
@@ -10725,8 +10766,7 @@
|
|
|
10725
10766
|
};
|
|
10726
10767
|
|
|
10727
10768
|
/**
|
|
10728
|
-
* Fires an event
|
|
10729
|
-
* canvas resizing
|
|
10769
|
+
* Fires an event so other modules can react to the canvas resizing.
|
|
10730
10770
|
*/
|
|
10731
10771
|
Canvas.prototype.resized = function() {
|
|
10732
10772
|
|
|
@@ -10738,11 +10778,21 @@
|
|
|
10738
10778
|
|
|
10739
10779
|
var ELEMENT_ID = 'data-element-id';
|
|
10740
10780
|
|
|
10781
|
+
/**
|
|
10782
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
10783
|
+
*
|
|
10784
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
10785
|
+
*
|
|
10786
|
+
* @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
|
|
10787
|
+
*/
|
|
10741
10788
|
|
|
10742
10789
|
/**
|
|
10790
|
+
* A registry that keeps track of all shapes in the diagram.
|
|
10791
|
+
*
|
|
10743
10792
|
* @class
|
|
10793
|
+
* @constructor
|
|
10744
10794
|
*
|
|
10745
|
-
*
|
|
10795
|
+
* @param {EventBus} eventBus
|
|
10746
10796
|
*/
|
|
10747
10797
|
function ElementRegistry(eventBus) {
|
|
10748
10798
|
this._elements = {};
|
|
@@ -10753,11 +10803,11 @@
|
|
|
10753
10803
|
ElementRegistry.$inject = [ 'eventBus' ];
|
|
10754
10804
|
|
|
10755
10805
|
/**
|
|
10756
|
-
*
|
|
10806
|
+
* Add an element and its graphical representation(s) to the registry.
|
|
10757
10807
|
*
|
|
10758
|
-
* @param {
|
|
10759
|
-
* @param {SVGElement} gfx
|
|
10760
|
-
* @param {SVGElement} [secondaryGfx]
|
|
10808
|
+
* @param {ElementLike} element The element to be added.
|
|
10809
|
+
* @param {SVGElement} gfx The primary graphical representation.
|
|
10810
|
+
* @param {SVGElement} [secondaryGfx] The secondary graphical representation.
|
|
10761
10811
|
*/
|
|
10762
10812
|
ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
|
|
10763
10813
|
|
|
@@ -10776,9 +10826,9 @@
|
|
|
10776
10826
|
};
|
|
10777
10827
|
|
|
10778
10828
|
/**
|
|
10779
|
-
*
|
|
10829
|
+
* Remove an element from the registry.
|
|
10780
10830
|
*
|
|
10781
|
-
* @param {string
|
|
10831
|
+
* @param {ElementLike|string} element
|
|
10782
10832
|
*/
|
|
10783
10833
|
ElementRegistry.prototype.remove = function(element) {
|
|
10784
10834
|
var elements = this._elements,
|
|
@@ -10799,10 +10849,10 @@
|
|
|
10799
10849
|
};
|
|
10800
10850
|
|
|
10801
10851
|
/**
|
|
10802
|
-
* Update
|
|
10852
|
+
* Update an elements ID.
|
|
10803
10853
|
*
|
|
10804
|
-
* @param {string
|
|
10805
|
-
* @param {string} newId
|
|
10854
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10855
|
+
* @param {string} newId The new ID.
|
|
10806
10856
|
*/
|
|
10807
10857
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
10808
10858
|
|
|
@@ -10828,11 +10878,11 @@
|
|
|
10828
10878
|
};
|
|
10829
10879
|
|
|
10830
10880
|
/**
|
|
10831
|
-
* Update the
|
|
10881
|
+
* Update the graphical representation of an element.
|
|
10832
10882
|
*
|
|
10833
|
-
* @param {string
|
|
10834
|
-
* @param {SVGElement} gfx
|
|
10835
|
-
* @param {boolean} [secondary=false]
|
|
10883
|
+
* @param {ElementLike|string} element The element or its ID.
|
|
10884
|
+
* @param {SVGElement} gfx The new graphical representation.
|
|
10885
|
+
* @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
|
|
10836
10886
|
*/
|
|
10837
10887
|
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
10838
10888
|
var id = filter.id || filter;
|
|
@@ -10853,17 +10903,17 @@
|
|
|
10853
10903
|
};
|
|
10854
10904
|
|
|
10855
10905
|
/**
|
|
10856
|
-
*
|
|
10906
|
+
* Get the element with the given ID or graphical representation.
|
|
10857
10907
|
*
|
|
10858
10908
|
* @example
|
|
10859
10909
|
*
|
|
10860
10910
|
* elementRegistry.get('SomeElementId_1');
|
|
10861
|
-
* elementRegistry.get(gfx);
|
|
10862
10911
|
*
|
|
10912
|
+
* elementRegistry.get(gfx);
|
|
10863
10913
|
*
|
|
10864
|
-
* @param {string|SVGElement} filter
|
|
10914
|
+
* @param {string|SVGElement} filter The elements ID or graphical representation.
|
|
10865
10915
|
*
|
|
10866
|
-
* @return {
|
|
10916
|
+
* @return {ElementLike|undefined} The element.
|
|
10867
10917
|
*/
|
|
10868
10918
|
ElementRegistry.prototype.get = function(filter) {
|
|
10869
10919
|
var id;
|
|
@@ -10881,9 +10931,9 @@
|
|
|
10881
10931
|
/**
|
|
10882
10932
|
* Return all elements that match a given filter function.
|
|
10883
10933
|
*
|
|
10884
|
-
* @param {
|
|
10934
|
+
* @param {ElementRegistryCallback} fn The filter function.
|
|
10885
10935
|
*
|
|
10886
|
-
* @return {
|
|
10936
|
+
* @return {ElementLike[]} The matching elements.
|
|
10887
10937
|
*/
|
|
10888
10938
|
ElementRegistry.prototype.filter = function(fn) {
|
|
10889
10939
|
|
|
@@ -10899,11 +10949,11 @@
|
|
|
10899
10949
|
};
|
|
10900
10950
|
|
|
10901
10951
|
/**
|
|
10902
|
-
* Return the first element that
|
|
10952
|
+
* Return the first element that matches the given filter function.
|
|
10903
10953
|
*
|
|
10904
|
-
* @param {Function} fn
|
|
10954
|
+
* @param {Function} fn The filter function.
|
|
10905
10955
|
*
|
|
10906
|
-
* @return {
|
|
10956
|
+
* @return {ElementLike|undefined} The matching element.
|
|
10907
10957
|
*/
|
|
10908
10958
|
ElementRegistry.prototype.find = function(fn) {
|
|
10909
10959
|
var map = this._elements,
|
|
@@ -10922,18 +10972,18 @@
|
|
|
10922
10972
|
};
|
|
10923
10973
|
|
|
10924
10974
|
/**
|
|
10925
|
-
*
|
|
10975
|
+
* Get all elements.
|
|
10926
10976
|
*
|
|
10927
|
-
* @return {
|
|
10977
|
+
* @return {ElementLike[]} All elements.
|
|
10928
10978
|
*/
|
|
10929
10979
|
ElementRegistry.prototype.getAll = function() {
|
|
10930
10980
|
return this.filter(function(e) { return e; });
|
|
10931
10981
|
};
|
|
10932
10982
|
|
|
10933
10983
|
/**
|
|
10934
|
-
*
|
|
10984
|
+
* Execute a given function for each element.
|
|
10935
10985
|
*
|
|
10936
|
-
* @param {Function} fn
|
|
10986
|
+
* @param {Function} fn The function to execute.
|
|
10937
10987
|
*/
|
|
10938
10988
|
ElementRegistry.prototype.forEach = function(fn) {
|
|
10939
10989
|
|
|
@@ -10949,19 +10999,20 @@
|
|
|
10949
10999
|
};
|
|
10950
11000
|
|
|
10951
11001
|
/**
|
|
10952
|
-
* Return the graphical representation of an element
|
|
11002
|
+
* Return the graphical representation of an element.
|
|
10953
11003
|
*
|
|
10954
11004
|
* @example
|
|
11005
|
+
*
|
|
10955
11006
|
* elementRegistry.getGraphics('SomeElementId_1');
|
|
11007
|
+
*
|
|
10956
11008
|
* elementRegistry.getGraphics(rootElement); // <g ...>
|
|
10957
11009
|
*
|
|
10958
11010
|
* elementRegistry.getGraphics(rootElement, true); // <svg ...>
|
|
10959
11011
|
*
|
|
11012
|
+
* @param {ElementLike|string} filter The element or its ID.
|
|
11013
|
+
* @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
|
|
10960
11014
|
*
|
|
10961
|
-
* @
|
|
10962
|
-
* @param {boolean} [secondary=false] whether to return the secondary connected element
|
|
10963
|
-
*
|
|
10964
|
-
* @return {SVGElement}
|
|
11015
|
+
* @return {SVGElement} The graphical representation.
|
|
10965
11016
|
*/
|
|
10966
11017
|
ElementRegistry.prototype.getGraphics = function(filter, secondary) {
|
|
10967
11018
|
var id = filter.id || filter;
|
|
@@ -10971,12 +11022,11 @@
|
|
|
10971
11022
|
};
|
|
10972
11023
|
|
|
10973
11024
|
/**
|
|
10974
|
-
* Validate
|
|
10975
|
-
* with an exception.
|
|
11025
|
+
* Validate an ID and throw an error if invalid.
|
|
10976
11026
|
*
|
|
10977
11027
|
* @param {string} id
|
|
10978
11028
|
*
|
|
10979
|
-
* @throws {Error}
|
|
11029
|
+
* @throws {Error} Error indicating that the ID is invalid or already assigned.
|
|
10980
11030
|
*/
|
|
10981
11031
|
ElementRegistry.prototype._validateId = function(id) {
|
|
10982
11032
|
if (!id) {
|
|
@@ -11316,14 +11366,6 @@
|
|
|
11316
11366
|
outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
|
|
11317
11367
|
incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
|
|
11318
11368
|
|
|
11319
|
-
/**
|
|
11320
|
-
* @namespace djs.model
|
|
11321
|
-
*/
|
|
11322
|
-
|
|
11323
|
-
/**
|
|
11324
|
-
* @memberOf djs.model
|
|
11325
|
-
*/
|
|
11326
|
-
|
|
11327
11369
|
/**
|
|
11328
11370
|
* The basic graphical representation
|
|
11329
11371
|
*
|
|
@@ -11520,21 +11562,47 @@
|
|
|
11520
11562
|
};
|
|
11521
11563
|
|
|
11522
11564
|
/**
|
|
11523
|
-
* Creates a
|
|
11565
|
+
* Creates a model element of the given type.
|
|
11524
11566
|
*
|
|
11525
11567
|
* @method create
|
|
11526
11568
|
*
|
|
11527
11569
|
* @example
|
|
11528
11570
|
*
|
|
11529
|
-
*
|
|
11530
|
-
* var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
|
|
11571
|
+
* import * as Model from 'diagram-js/lib/model';
|
|
11531
11572
|
*
|
|
11532
|
-
*
|
|
11573
|
+
* const connection = Model.create('connection', {
|
|
11574
|
+
* waypoints: [
|
|
11575
|
+
* { x: 100, y: 100 },
|
|
11576
|
+
* { x: 200, y: 100 }
|
|
11577
|
+
* ]
|
|
11578
|
+
* });
|
|
11533
11579
|
*
|
|
11534
|
-
*
|
|
11535
|
-
*
|
|
11580
|
+
* const label = Model.create('label', {
|
|
11581
|
+
* x: 100,
|
|
11582
|
+
* y: 100,
|
|
11583
|
+
* width: 100,
|
|
11584
|
+
* height: 100,
|
|
11585
|
+
* labelTarget: shape
|
|
11586
|
+
* });
|
|
11587
|
+
*
|
|
11588
|
+
* const root = Model.create('root', {
|
|
11589
|
+
* x: 100,
|
|
11590
|
+
* y: 100,
|
|
11591
|
+
* width: 100,
|
|
11592
|
+
* height: 100
|
|
11593
|
+
* });
|
|
11536
11594
|
*
|
|
11537
|
-
*
|
|
11595
|
+
* const shape = Model.create('shape', {
|
|
11596
|
+
* x: 100,
|
|
11597
|
+
* y: 100,
|
|
11598
|
+
* width: 100,
|
|
11599
|
+
* height: 100
|
|
11600
|
+
* });
|
|
11601
|
+
*
|
|
11602
|
+
* @param {string} type The type of model element to be created.
|
|
11603
|
+
* @param {Object} attrs Attributes to create the model element with.
|
|
11604
|
+
*
|
|
11605
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11538
11606
|
*/
|
|
11539
11607
|
function create(type, attrs) {
|
|
11540
11608
|
var Type = types$7[type];
|
|
@@ -11545,36 +11613,78 @@
|
|
|
11545
11613
|
}
|
|
11546
11614
|
|
|
11547
11615
|
/**
|
|
11548
|
-
*
|
|
11616
|
+
* @typedef {import('../model/index').Base} Base
|
|
11617
|
+
* @typedef {import('../model/index').Connection} Connection
|
|
11618
|
+
* @typedef {import('../model/index').Label} Label
|
|
11619
|
+
* @typedef {import('../model/index').Root} Root
|
|
11620
|
+
* @typedef {import('../model/index').Shape} Shape
|
|
11621
|
+
* @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
|
|
11622
|
+
* @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
|
|
11623
|
+
* @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
|
|
11624
|
+
* @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
|
|
11625
|
+
*/
|
|
11626
|
+
|
|
11627
|
+
/**
|
|
11628
|
+
* A factory for model elements.
|
|
11629
|
+
*
|
|
11630
|
+
* @class
|
|
11631
|
+
* @constructor
|
|
11549
11632
|
*/
|
|
11550
11633
|
function ElementFactory() {
|
|
11551
11634
|
this._uid = 12;
|
|
11552
11635
|
}
|
|
11553
11636
|
|
|
11554
|
-
|
|
11637
|
+
/**
|
|
11638
|
+
* Create a root element.
|
|
11639
|
+
*
|
|
11640
|
+
* @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
|
|
11641
|
+
*
|
|
11642
|
+
* @return {Root} The created root element.
|
|
11643
|
+
*/
|
|
11555
11644
|
ElementFactory.prototype.createRoot = function(attrs) {
|
|
11556
11645
|
return this.create('root', attrs);
|
|
11557
11646
|
};
|
|
11558
11647
|
|
|
11648
|
+
/**
|
|
11649
|
+
* Create a label.
|
|
11650
|
+
*
|
|
11651
|
+
* @param {ModelAttrsLabel} attrs The attributes of the label to be created.
|
|
11652
|
+
*
|
|
11653
|
+
* @return {Label} The created label.
|
|
11654
|
+
*/
|
|
11559
11655
|
ElementFactory.prototype.createLabel = function(attrs) {
|
|
11560
11656
|
return this.create('label', attrs);
|
|
11561
11657
|
};
|
|
11562
11658
|
|
|
11659
|
+
/**
|
|
11660
|
+
* Create a shape.
|
|
11661
|
+
*
|
|
11662
|
+
* @param {ModelAttrsShape} attrs The attributes of the shape to be created.
|
|
11663
|
+
*
|
|
11664
|
+
* @return {Shape} The created shape.
|
|
11665
|
+
*/
|
|
11563
11666
|
ElementFactory.prototype.createShape = function(attrs) {
|
|
11564
11667
|
return this.create('shape', attrs);
|
|
11565
11668
|
};
|
|
11566
11669
|
|
|
11670
|
+
/**
|
|
11671
|
+
* Create a connection.
|
|
11672
|
+
*
|
|
11673
|
+
* @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
|
|
11674
|
+
*
|
|
11675
|
+
* @return {Connection} The created connection.
|
|
11676
|
+
*/
|
|
11567
11677
|
ElementFactory.prototype.createConnection = function(attrs) {
|
|
11568
11678
|
return this.create('connection', attrs);
|
|
11569
11679
|
};
|
|
11570
11680
|
|
|
11571
11681
|
/**
|
|
11572
|
-
* Create a model element
|
|
11573
|
-
* a number of pre-set attributes.
|
|
11682
|
+
* Create a model element of the given type with the given attributes.
|
|
11574
11683
|
*
|
|
11575
|
-
* @param
|
|
11576
|
-
* @param
|
|
11577
|
-
*
|
|
11684
|
+
* @param {string} type The type of the model element.
|
|
11685
|
+
* @param {Object} attrs The attributes of the model element.
|
|
11686
|
+
*
|
|
11687
|
+
* @return {Connection|Label|Root|Shape} The created model element.
|
|
11578
11688
|
*/
|
|
11579
11689
|
ElementFactory.prototype.create = function(type, attrs) {
|
|
11580
11690
|
|
|
@@ -11593,6 +11703,16 @@
|
|
|
11593
11703
|
|
|
11594
11704
|
var slice = Array.prototype.slice;
|
|
11595
11705
|
|
|
11706
|
+
/**
|
|
11707
|
+
* @typedef {import('./EventBus').Event} Event
|
|
11708
|
+
* @typedef {import('./EventBus').EventCallback} EventCallback
|
|
11709
|
+
*
|
|
11710
|
+
* @typedef {Object} EventListener
|
|
11711
|
+
* @property {Function} callback
|
|
11712
|
+
* @property {EventListener|null} next
|
|
11713
|
+
* @property {number} priority
|
|
11714
|
+
*/
|
|
11715
|
+
|
|
11596
11716
|
/**
|
|
11597
11717
|
* A general purpose event bus.
|
|
11598
11718
|
*
|
|
@@ -11697,10 +11817,10 @@
|
|
|
11697
11817
|
*
|
|
11698
11818
|
* Returning anything but `undefined` from a listener will stop the listener propagation.
|
|
11699
11819
|
*
|
|
11700
|
-
* @param {string|
|
|
11701
|
-
* @param {number} [priority=1000]
|
|
11702
|
-
* @param {
|
|
11703
|
-
* @param {
|
|
11820
|
+
* @param {string|string[]} events The event(s) to listen to.
|
|
11821
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11822
|
+
* @param {EventCallback} callback The callback.
|
|
11823
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11704
11824
|
*/
|
|
11705
11825
|
EventBus.prototype.on = function(events, priority, callback, that) {
|
|
11706
11826
|
|
|
@@ -11740,12 +11860,12 @@
|
|
|
11740
11860
|
|
|
11741
11861
|
|
|
11742
11862
|
/**
|
|
11743
|
-
* Register an event listener that is
|
|
11863
|
+
* Register an event listener that is called only once.
|
|
11744
11864
|
*
|
|
11745
|
-
* @param {string} event
|
|
11746
|
-
* @param {number} [priority=1000]
|
|
11747
|
-
* @param {
|
|
11748
|
-
* @param {
|
|
11865
|
+
* @param {string} event The event to listen to.
|
|
11866
|
+
* @param {number} [priority=1000] The priority with which to listen.
|
|
11867
|
+
* @param {EventCallback} callback The callback.
|
|
11868
|
+
* @param {*} [that] Value of `this` the callback will be called with.
|
|
11749
11869
|
*/
|
|
11750
11870
|
EventBus.prototype.once = function(event, priority, callback, that) {
|
|
11751
11871
|
var self = this;
|
|
@@ -11784,8 +11904,8 @@
|
|
|
11784
11904
|
*
|
|
11785
11905
|
* If no callback is given, all listeners for a given event name are being removed.
|
|
11786
11906
|
*
|
|
11787
|
-
* @param {string|
|
|
11788
|
-
* @param {
|
|
11907
|
+
* @param {string|string[]} events The events.
|
|
11908
|
+
* @param {EventCallback} [callback] The callback.
|
|
11789
11909
|
*/
|
|
11790
11910
|
EventBus.prototype.off = function(events, callback) {
|
|
11791
11911
|
|
|
@@ -11801,11 +11921,11 @@
|
|
|
11801
11921
|
|
|
11802
11922
|
|
|
11803
11923
|
/**
|
|
11804
|
-
* Create an
|
|
11924
|
+
* Create an event recognized be the event bus.
|
|
11805
11925
|
*
|
|
11806
|
-
* @param {Object} data
|
|
11926
|
+
* @param {Object} data Event data.
|
|
11807
11927
|
*
|
|
11808
|
-
* @return {
|
|
11928
|
+
* @return {Event} An event that will be recognized by the event bus.
|
|
11809
11929
|
*/
|
|
11810
11930
|
EventBus.prototype.createEvent = function(data) {
|
|
11811
11931
|
var event = new InternalEvent();
|
|
@@ -11817,7 +11937,7 @@
|
|
|
11817
11937
|
|
|
11818
11938
|
|
|
11819
11939
|
/**
|
|
11820
|
-
* Fires
|
|
11940
|
+
* Fires an event.
|
|
11821
11941
|
*
|
|
11822
11942
|
* @example
|
|
11823
11943
|
*
|
|
@@ -11839,12 +11959,11 @@
|
|
|
11839
11959
|
*
|
|
11840
11960
|
* events.fire({ type: 'foo' }, 'I am bar!');
|
|
11841
11961
|
*
|
|
11842
|
-
* @param {string} [
|
|
11843
|
-
* @param {Object} [
|
|
11844
|
-
* @param {
|
|
11962
|
+
* @param {string} [type] The event type.
|
|
11963
|
+
* @param {Object} [data] The event or event data.
|
|
11964
|
+
* @param {...*} additional Additional arguments the callback will be called with.
|
|
11845
11965
|
*
|
|
11846
|
-
* @return {
|
|
11847
|
-
* default action was prevented by listeners
|
|
11966
|
+
* @return {*} The return value. Will be set to `false` if the default was prevented.
|
|
11848
11967
|
*/
|
|
11849
11968
|
EventBus.prototype.fire = function(type, data) {
|
|
11850
11969
|
var event,
|
|
@@ -11909,7 +12028,13 @@
|
|
|
11909
12028
|
return returnValue;
|
|
11910
12029
|
};
|
|
11911
12030
|
|
|
11912
|
-
|
|
12031
|
+
/**
|
|
12032
|
+
* Handle an error by firing an event.
|
|
12033
|
+
*
|
|
12034
|
+
* @param {Error} error The error to be handled.
|
|
12035
|
+
*
|
|
12036
|
+
* @return {boolean} Whether the error was handled.
|
|
12037
|
+
*/
|
|
11913
12038
|
EventBus.prototype.handleError = function(error) {
|
|
11914
12039
|
return this.fire('error', { error: error }) === false;
|
|
11915
12040
|
};
|
|
@@ -11972,7 +12097,7 @@
|
|
|
11972
12097
|
return returnValue;
|
|
11973
12098
|
};
|
|
11974
12099
|
|
|
11975
|
-
|
|
12100
|
+
/**
|
|
11976
12101
|
* Add new listener with a certain priority to the list
|
|
11977
12102
|
* of listeners (for the given event).
|
|
11978
12103
|
*
|
|
@@ -11986,7 +12111,7 @@
|
|
|
11986
12111
|
* * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
|
|
11987
12112
|
*
|
|
11988
12113
|
* @param {string} event
|
|
11989
|
-
* @param {
|
|
12114
|
+
* @param {EventListener} listener
|
|
11990
12115
|
*/
|
|
11991
12116
|
EventBus.prototype._addListener = function(event, newListener) {
|
|
11992
12117
|
|
|
@@ -12092,9 +12217,9 @@
|
|
|
12092
12217
|
* Invoke function. Be fast...
|
|
12093
12218
|
*
|
|
12094
12219
|
* @param {Function} fn
|
|
12095
|
-
* @param {
|
|
12220
|
+
* @param {*[]} args
|
|
12096
12221
|
*
|
|
12097
|
-
* @return {
|
|
12222
|
+
* @return {*}
|
|
12098
12223
|
*/
|
|
12099
12224
|
function invokeFunction(fn, args) {
|
|
12100
12225
|
return fn.apply(null, args);
|
|
@@ -12108,11 +12233,11 @@
|
|
|
12108
12233
|
*/
|
|
12109
12234
|
|
|
12110
12235
|
/**
|
|
12111
|
-
* Returns the visual part of a diagram element
|
|
12236
|
+
* Returns the visual part of a diagram element.
|
|
12112
12237
|
*
|
|
12113
|
-
* @param {
|
|
12238
|
+
* @param {SVGElement} gfx
|
|
12114
12239
|
*
|
|
12115
|
-
* @return {
|
|
12240
|
+
* @return {SVGElement}
|
|
12116
12241
|
*/
|
|
12117
12242
|
function getVisual(gfx) {
|
|
12118
12243
|
return gfx.childNodes[0];
|
|
@@ -12121,15 +12246,28 @@
|
|
|
12121
12246
|
/**
|
|
12122
12247
|
* Returns the children for a given diagram element.
|
|
12123
12248
|
*
|
|
12124
|
-
* @param {
|
|
12125
|
-
* @return {
|
|
12249
|
+
* @param {SVGElement} gfx
|
|
12250
|
+
* @return {SVGElement}
|
|
12126
12251
|
*/
|
|
12127
12252
|
function getChildren(gfx) {
|
|
12128
12253
|
return gfx.parentNode.childNodes[1];
|
|
12129
12254
|
}
|
|
12130
12255
|
|
|
12131
12256
|
/**
|
|
12132
|
-
*
|
|
12257
|
+
* @typedef {import('../model').ModelType} ModelType
|
|
12258
|
+
* @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
|
|
12259
|
+
* @typedef {import('../model').ModelTypeShape} ModelTypeShape
|
|
12260
|
+
*
|
|
12261
|
+
* @typedef {import('.').ConnectionLike} ConnectionLike
|
|
12262
|
+
* @typedef {import('.').ElementLike} ElementLike
|
|
12263
|
+
* @typedef {import('.').ShapeLike} ShapeLike
|
|
12264
|
+
*
|
|
12265
|
+
* @typedef {import('./ElementRegistry').default} ElementRegistry
|
|
12266
|
+
* @typedef {import('./EventBus').default} EventBus
|
|
12267
|
+
*/
|
|
12268
|
+
|
|
12269
|
+
/**
|
|
12270
|
+
* A factory that creates graphical elements.
|
|
12133
12271
|
*
|
|
12134
12272
|
* @param {EventBus} eventBus
|
|
12135
12273
|
* @param {ElementRegistry} elementRegistry
|
|
@@ -12197,7 +12335,7 @@
|
|
|
12197
12335
|
* </g>
|
|
12198
12336
|
*
|
|
12199
12337
|
* @param {string} type the type of the element, i.e. shape | connection
|
|
12200
|
-
* @param {SVGElement}
|
|
12338
|
+
* @param {SVGElement} childrenGfx
|
|
12201
12339
|
* @param {number} [parentIndex] position to create container in parent
|
|
12202
12340
|
* @param {boolean} [isFrame] is frame element
|
|
12203
12341
|
*
|
|
@@ -12235,11 +12373,25 @@
|
|
|
12235
12373
|
return gfx;
|
|
12236
12374
|
};
|
|
12237
12375
|
|
|
12376
|
+
/**
|
|
12377
|
+
* Create a graphical element.
|
|
12378
|
+
*
|
|
12379
|
+
* @param {ModelType} type The type of the element.
|
|
12380
|
+
* @param {ElementLike} element The element.
|
|
12381
|
+
* @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
|
|
12382
|
+
*
|
|
12383
|
+
* @return {SVGElement} The graphical element.
|
|
12384
|
+
*/
|
|
12238
12385
|
GraphicsFactory.prototype.create = function(type, element, parentIndex) {
|
|
12239
12386
|
var childrenGfx = this._getChildrenContainer(element.parent);
|
|
12240
12387
|
return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
|
|
12241
12388
|
};
|
|
12242
12389
|
|
|
12390
|
+
/**
|
|
12391
|
+
* Update the containments of the given elements.
|
|
12392
|
+
*
|
|
12393
|
+
* @param {ElementLike[]} elements The elements.
|
|
12394
|
+
*/
|
|
12243
12395
|
GraphicsFactory.prototype.updateContainments = function(elements) {
|
|
12244
12396
|
|
|
12245
12397
|
var self = this,
|
|
@@ -12275,30 +12427,63 @@
|
|
|
12275
12427
|
});
|
|
12276
12428
|
};
|
|
12277
12429
|
|
|
12430
|
+
/**
|
|
12431
|
+
* Draw a shape.
|
|
12432
|
+
*
|
|
12433
|
+
* @param {SVGElement} visual The graphical element.
|
|
12434
|
+
* @param {ShapeLike} element The shape.
|
|
12435
|
+
*/
|
|
12278
12436
|
GraphicsFactory.prototype.drawShape = function(visual, element) {
|
|
12279
12437
|
var eventBus = this._eventBus;
|
|
12280
12438
|
|
|
12281
12439
|
return eventBus.fire('render.shape', { gfx: visual, element: element });
|
|
12282
12440
|
};
|
|
12283
12441
|
|
|
12442
|
+
/**
|
|
12443
|
+
* Get the path of a shape.
|
|
12444
|
+
*
|
|
12445
|
+
* @param {ShapeLike} element The shape.
|
|
12446
|
+
*
|
|
12447
|
+
* @return {string} The path of the shape.
|
|
12448
|
+
*/
|
|
12284
12449
|
GraphicsFactory.prototype.getShapePath = function(element) {
|
|
12285
12450
|
var eventBus = this._eventBus;
|
|
12286
12451
|
|
|
12287
12452
|
return eventBus.fire('render.getShapePath', element);
|
|
12288
12453
|
};
|
|
12289
12454
|
|
|
12455
|
+
/**
|
|
12456
|
+
* Draw a connection.
|
|
12457
|
+
*
|
|
12458
|
+
* @param {SVGElement} visual The graphical element.
|
|
12459
|
+
* @param {ConnectionLike} element The connection.
|
|
12460
|
+
*/
|
|
12290
12461
|
GraphicsFactory.prototype.drawConnection = function(visual, element) {
|
|
12291
12462
|
var eventBus = this._eventBus;
|
|
12292
12463
|
|
|
12293
12464
|
return eventBus.fire('render.connection', { gfx: visual, element: element });
|
|
12294
12465
|
};
|
|
12295
12466
|
|
|
12296
|
-
|
|
12467
|
+
/**
|
|
12468
|
+
* Get the path of a connection.
|
|
12469
|
+
*
|
|
12470
|
+
* @param {ConnectionLike} element The connection.
|
|
12471
|
+
*
|
|
12472
|
+
* @return {string} The path of the connection.
|
|
12473
|
+
*/
|
|
12474
|
+
GraphicsFactory.prototype.getConnectionPath = function(connection) {
|
|
12297
12475
|
var eventBus = this._eventBus;
|
|
12298
12476
|
|
|
12299
|
-
return eventBus.fire('render.getConnectionPath',
|
|
12477
|
+
return eventBus.fire('render.getConnectionPath', connection);
|
|
12300
12478
|
};
|
|
12301
12479
|
|
|
12480
|
+
/**
|
|
12481
|
+
* Update an elements graphical representation.
|
|
12482
|
+
*
|
|
12483
|
+
* @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
|
|
12484
|
+
* @param {ElementLike} element The element.
|
|
12485
|
+
* @param {SVGElement} gfx The graphical representation.
|
|
12486
|
+
*/
|
|
12302
12487
|
GraphicsFactory.prototype.update = function(type, element, gfx) {
|
|
12303
12488
|
|
|
12304
12489
|
// do NOT update root element
|
|
@@ -12328,6 +12513,11 @@
|
|
|
12328
12513
|
}
|
|
12329
12514
|
};
|
|
12330
12515
|
|
|
12516
|
+
/**
|
|
12517
|
+
* Remove a graphical element.
|
|
12518
|
+
*
|
|
12519
|
+
* @param {ElementLike} element The element.
|
|
12520
|
+
*/
|
|
12331
12521
|
GraphicsFactory.prototype.remove = function(element) {
|
|
12332
12522
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12333
12523
|
|
|
@@ -12361,13 +12551,17 @@
|
|
|
12361
12551
|
};
|
|
12362
12552
|
|
|
12363
12553
|
/**
|
|
12364
|
-
* @typedef {
|
|
12554
|
+
* @typedef {import('didi').InjectionContext} InjectionContext
|
|
12555
|
+
* @typedef {import('didi').LocalsMap} LocalsMap
|
|
12556
|
+
* @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
|
|
12557
|
+
*
|
|
12558
|
+
* @typedef {import('./Diagram').DiagramOptions} DiagramOptions
|
|
12365
12559
|
*/
|
|
12366
12560
|
|
|
12367
12561
|
/**
|
|
12368
12562
|
* Bootstrap an injector from a list of modules, instantiating a number of default components
|
|
12369
12563
|
*
|
|
12370
|
-
* @param {
|
|
12564
|
+
* @param {ModuleDeclaration[]} modules
|
|
12371
12565
|
*
|
|
12372
12566
|
* @return {Injector} a injector to use to access the components
|
|
12373
12567
|
*/
|
|
@@ -12382,7 +12576,8 @@
|
|
|
12382
12576
|
/**
|
|
12383
12577
|
* Creates an injector from passed options.
|
|
12384
12578
|
*
|
|
12385
|
-
* @param {
|
|
12579
|
+
* @param {DiagramOptions} [options]
|
|
12580
|
+
*
|
|
12386
12581
|
* @return {Injector}
|
|
12387
12582
|
*/
|
|
12388
12583
|
function createInjector(options) {
|
|
@@ -12405,8 +12600,7 @@
|
|
|
12405
12600
|
*
|
|
12406
12601
|
* To register extensions with the diagram, pass them as Array<Module> to the constructor.
|
|
12407
12602
|
*
|
|
12408
|
-
* @class
|
|
12409
|
-
* @memberOf djs
|
|
12603
|
+
* @class
|
|
12410
12604
|
* @constructor
|
|
12411
12605
|
*
|
|
12412
12606
|
* @example
|
|
@@ -12444,9 +12638,9 @@
|
|
|
12444
12638
|
*
|
|
12445
12639
|
* // 'shape ... was added to the diagram' logged to console
|
|
12446
12640
|
*
|
|
12447
|
-
* @param {
|
|
12448
|
-
* @param {
|
|
12449
|
-
* @param {Injector} [injector]
|
|
12641
|
+
* @param {DiagramOptions} [options]
|
|
12642
|
+
* @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
|
|
12643
|
+
* @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
|
|
12450
12644
|
*/
|
|
12451
12645
|
function Diagram(options, injector) {
|
|
12452
12646
|
|
|
@@ -12456,22 +12650,23 @@
|
|
|
12456
12650
|
// API
|
|
12457
12651
|
|
|
12458
12652
|
/**
|
|
12459
|
-
* Resolves a diagram service
|
|
12653
|
+
* Resolves a diagram service.
|
|
12460
12654
|
*
|
|
12461
12655
|
* @method Diagram#get
|
|
12462
12656
|
*
|
|
12463
|
-
* @param {string} name
|
|
12464
|
-
* @param {boolean} [strict=true]
|
|
12657
|
+
* @param {string} name The name of the service to get.
|
|
12658
|
+
* @param {boolean} [strict=true] If false, resolve missing services to null.
|
|
12465
12659
|
*/
|
|
12466
12660
|
this.get = injector.get;
|
|
12467
12661
|
|
|
12468
12662
|
/**
|
|
12469
|
-
* Executes a function
|
|
12663
|
+
* Executes a function with its dependencies injected.
|
|
12470
12664
|
*
|
|
12471
12665
|
* @method Diagram#invoke
|
|
12472
12666
|
*
|
|
12473
|
-
* @param {Function
|
|
12474
|
-
* @param {
|
|
12667
|
+
* @param {Function} fn The function to be executed.
|
|
12668
|
+
* @param {InjectionContext} [context] The context.
|
|
12669
|
+
* @param {LocalsMap} [locals] The locals.
|
|
12475
12670
|
*/
|
|
12476
12671
|
this.invoke = injector.invoke;
|
|
12477
12672
|
|
|
@@ -21658,10 +21853,10 @@
|
|
|
21658
21853
|
// default moddle extensions the viewer is composed of
|
|
21659
21854
|
Viewer.prototype._moddleExtensions = {};
|
|
21660
21855
|
|
|
21661
|
-
var KEYS_COPY = [ 'c', 'C'
|
|
21662
|
-
var KEYS_PASTE = [ 'v', 'V'
|
|
21663
|
-
var KEYS_REDO = [ 'y', 'Y'
|
|
21664
|
-
var KEYS_UNDO = [ 'z', 'Z'
|
|
21856
|
+
var KEYS_COPY = [ 'c', 'C' ];
|
|
21857
|
+
var KEYS_PASTE = [ 'v', 'V' ];
|
|
21858
|
+
var KEYS_REDO = [ 'y', 'Y' ];
|
|
21859
|
+
var KEYS_UNDO = [ 'z', 'Z' ];
|
|
21665
21860
|
|
|
21666
21861
|
/**
|
|
21667
21862
|
* Returns true if event was triggered with any modifier
|
|
@@ -21724,6 +21919,10 @@
|
|
|
21724
21919
|
);
|
|
21725
21920
|
}
|
|
21726
21921
|
|
|
21922
|
+
/**
|
|
21923
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
21924
|
+
*/
|
|
21925
|
+
|
|
21727
21926
|
var KEYDOWN_EVENT = 'keyboard.keydown',
|
|
21728
21927
|
KEYUP_EVENT = 'keyboard.keyup';
|
|
21729
21928
|
|
|
@@ -21752,7 +21951,7 @@
|
|
|
21752
21951
|
* A default binding for the keyboard may be specified via the
|
|
21753
21952
|
* `keyboard.bindTo` configuration option.
|
|
21754
21953
|
*
|
|
21755
|
-
* @param {
|
|
21954
|
+
* @param {Object} config
|
|
21756
21955
|
* @param {EventBus} eventBus
|
|
21757
21956
|
*/
|
|
21758
21957
|
function Keyboard(config, eventBus) {
|
|
@@ -22083,6 +22282,11 @@
|
|
|
22083
22282
|
keyboardBindings: [ 'type', KeyboardBindings ]
|
|
22084
22283
|
};
|
|
22085
22284
|
|
|
22285
|
+
/**
|
|
22286
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
22287
|
+
* @typedef {import('../../features/keyboard/Keyboard').default} Keyboard
|
|
22288
|
+
*/
|
|
22289
|
+
|
|
22086
22290
|
var DEFAULT_CONFIG = {
|
|
22087
22291
|
moveSpeed: 50,
|
|
22088
22292
|
moveSpeedAccelerated: 200
|
|
@@ -22255,6 +22459,11 @@
|
|
|
22255
22459
|
};
|
|
22256
22460
|
}
|
|
22257
22461
|
|
|
22462
|
+
/**
|
|
22463
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
22464
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
22465
|
+
*/
|
|
22466
|
+
|
|
22258
22467
|
var THRESHOLD = 15;
|
|
22259
22468
|
|
|
22260
22469
|
|
|
@@ -22374,8 +22583,9 @@
|
|
|
22374
22583
|
};
|
|
22375
22584
|
|
|
22376
22585
|
/**
|
|
22377
|
-
* Get the logarithm of x with base 10
|
|
22378
|
-
*
|
|
22586
|
+
* Get the logarithm of x with base 10.
|
|
22587
|
+
*
|
|
22588
|
+
* @param {number} x
|
|
22379
22589
|
*/
|
|
22380
22590
|
function log10(x) {
|
|
22381
22591
|
return Math.log(x) / Math.log(10);
|
|
@@ -22402,6 +22612,11 @@
|
|
|
22402
22612
|
return Math.max(range.min, Math.min(range.max, scale));
|
|
22403
22613
|
}
|
|
22404
22614
|
|
|
22615
|
+
/**
|
|
22616
|
+
* @typedef {import('../../core/Canvas').default} Canvas
|
|
22617
|
+
* @typedef {import('../../core/EventBus').default} EventBus
|
|
22618
|
+
*/
|
|
22619
|
+
|
|
22405
22620
|
var sign = Math.sign || function(n) {
|
|
22406
22621
|
return n >= 0 ? 1 : -1;
|
|
22407
22622
|
};
|
|
@@ -22592,7 +22807,7 @@
|
|
|
22592
22807
|
/**
|
|
22593
22808
|
* Toggle the zoom scroll ability via mouse wheel.
|
|
22594
22809
|
*
|
|
22595
|
-
* @param
|
|
22810
|
+
* @param {boolean} [newEnabled] new enabled state
|
|
22596
22811
|
*/
|
|
22597
22812
|
ZoomScroll.prototype.toggle = function toggle(newEnabled) {
|
|
22598
22813
|
|