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.
Files changed (25) hide show
  1. package/README.md +1 -1
  2. package/dist/base-modeler.development.js +2355 -950
  3. package/dist/base-modeler.production.min.js +32 -33
  4. package/dist/base-navigated-viewer.development.js +699 -484
  5. package/dist/base-navigated-viewer.production.min.js +1 -3
  6. package/dist/base-viewer.development.js +671 -476
  7. package/dist/base-viewer.production.min.js +1 -3
  8. package/dist/camunda-cloud-modeler.development.js +7758 -2531
  9. package/dist/camunda-cloud-modeler.production.min.js +36 -37
  10. package/dist/camunda-cloud-navigated-viewer.development.js +699 -484
  11. package/dist/camunda-cloud-navigated-viewer.production.min.js +1 -3
  12. package/dist/camunda-cloud-viewer.development.js +671 -476
  13. package/dist/camunda-cloud-viewer.production.min.js +1 -3
  14. package/dist/camunda-platform-modeler.development.js +6811 -2288
  15. package/dist/camunda-platform-modeler.production.min.js +35 -36
  16. package/dist/camunda-platform-navigated-viewer.development.js +699 -484
  17. package/dist/camunda-platform-navigated-viewer.production.min.js +1 -3
  18. package/dist/camunda-platform-viewer.development.js +671 -476
  19. package/dist/camunda-platform-viewer.production.min.js +1 -3
  20. package/lib/camunda-cloud/Modeler.js +8 -1
  21. package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesAppendProvider.js +162 -0
  22. package/lib/camunda-cloud/features/create-append-anything/ElementTemplatesCreateProvider.js +114 -0
  23. package/lib/camunda-cloud/features/create-append-anything/index.js +11 -0
  24. package/lib/camunda-platform/Modeler.js +6 -1
  25. 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
- * Should check whether *this* renderer can render
477
- * the element/connection.
484
+ * Checks whether an element can be rendered.
478
485
  *
479
- * @param {element} element
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
- * Provides the shape's snap svg element to be drawn on the `canvas`.
493
+ * Draws a shape.
487
494
  *
488
- * @param {djs.Graphics} visuals
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 {Snap.svg} [returns a Snap.svg paper element ]
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
- * Provides the shape's snap svg element to be drawn on the `canvas`.
503
+ * Draws a connection.
497
504
  *
498
- * @param {djs.Graphics} visuals
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 {Snap.svg} [returns a Snap.svg paper element ]
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 a shape that represents it's visual bounds.
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} svg path
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 a connection that represents it's visual bounds.
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} svg path
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
- * @param { [ string, ...any[] ][] } elements
1335
+ * @typedef {(string|number)[]} Component
1336
+ *
1337
+ * @typedef {import('../util/Types').Point} Point
1338
+ */
1339
+
1340
+ /**
1341
+ * @param {Component[]} elements
1329
1342
  *
1330
- * @return { string }
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 { { x: number, y: number }[] } points
1411
- * @param { any } [attrs]
1412
- * @param { number } [radius]
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 { SVGElement } gfx
1438
- * @param { { x: number, y: number }[]} points
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 {<SVGElement>} element
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 {Array<string>} lines
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 {string} line
4342
- * @param {number} maxLength the maximum characters of the string
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 {Object} [replacements] a map with substitutes
5235
+ * @param {Replacements} [replacements] a map with substitutes
5197
5236
  *
5198
5237
  * @return {string} the translated string
5199
5238
  */
@@ -5350,8 +5389,6 @@
5350
5389
  return element && !!element.labelTarget;
5351
5390
  }
5352
5391
 
5353
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5354
-
5355
5392
  function getDefaultExportFromCjs (x) {
5356
5393
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5357
5394
  }
@@ -5368,9 +5405,9 @@
5368
5405
  /**
5369
5406
  * Convert the given bounds to a { top, left, bottom, right } descriptor.
5370
5407
  *
5371
- * @param {Bounds|Point} bounds
5408
+ * @param {Point|Rect} bounds
5372
5409
  *
5373
- * @return {Object}
5410
+ * @return {RectTRBL}
5374
5411
  */
5375
5412
  function asTRBL(bounds) {
5376
5413
  return {
@@ -5385,9 +5422,9 @@
5385
5422
  /**
5386
5423
  * Convert a { top, left, bottom, right } to an objects bounds.
5387
5424
  *
5388
- * @param {Object} trbl
5425
+ * @param {RectTRBL} trbl
5389
5426
  *
5390
- * @return {Bounds}
5427
+ * @return {Rect}
5391
5428
  */
5392
5429
  function asBounds(trbl) {
5393
5430
  return {
@@ -5402,7 +5439,7 @@
5402
5439
  /**
5403
5440
  * Get the mid of the given bounds or point.
5404
5441
  *
5405
- * @param {Bounds|Point} bounds
5442
+ * @param {Point|Rect} bounds
5406
5443
  *
5407
5444
  * @return {Point}
5408
5445
  */
@@ -5417,7 +5454,7 @@
5417
5454
  /**
5418
5455
  * Get the mid of the given Connection.
5419
5456
  *
5420
- * @param {djs.Base.Connection} connection
5457
+ * @param {Connection} connection
5421
5458
  *
5422
5459
  * @return {Point}
5423
5460
  */
@@ -5476,7 +5513,7 @@
5476
5513
  /**
5477
5514
  * Get the mid of the given Element.
5478
5515
  *
5479
- * @param {djs.Base.Connection} connection
5516
+ * @param {Connection} connection
5480
5517
  *
5481
5518
  * @return {Point}
5482
5519
  */
@@ -5903,6 +5940,14 @@
5903
5940
  return isPrimaryButton(event) && originalEvent.shiftKey;
5904
5941
  }
5905
5942
 
5943
+ /**
5944
+ * @typedef {import('../../model').Base} Base
5945
+ *
5946
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
5947
+ * @typedef {import('../../core/EventBus').default} EventBus
5948
+ * @typedef {import('../../draw/Styles').default} Styles
5949
+ */
5950
+
5906
5951
  function allowAll(event) { return true; }
5907
5952
 
5908
5953
  function allowPrimaryAndAuxiliary(event) {
@@ -5932,6 +5977,8 @@
5932
5977
  * prevents the original DOM operation.
5933
5978
  *
5934
5979
  * @param {EventBus} eventBus
5980
+ * @param {ElementRegistry} elementRegistry
5981
+ * @param {Styles} styles
5935
5982
  */
5936
5983
  function InteractionEvents(eventBus, elementRegistry, styles) {
5937
5984
 
@@ -5941,8 +5988,8 @@
5941
5988
  * Fire an interaction event.
5942
5989
  *
5943
5990
  * @param {string} type local event name, e.g. element.click.
5944
- * @param {DOMEvent} event native event
5945
- * @param {djs.model.Base} [element] the diagram element to emit the event on;
5991
+ * @param {MouseEvent|TouchEvent} event native event
5992
+ * @param {Base} [element] the diagram element to emit the event on;
5946
5993
  * defaults to the event target
5947
5994
  */
5948
5995
  function fire(type, event, element) {
@@ -6024,8 +6071,8 @@
6024
6071
  * on the target shape or connection.
6025
6072
  *
6026
6073
  * @param {string} eventName the name of the triggered DOM event
6027
- * @param {MouseEvent} event
6028
- * @param {djs.model.Base} targetElement
6074
+ * @param {MouseEvent|TouchEvent} event
6075
+ * @param {Base} targetElement
6029
6076
  */
6030
6077
  function triggerMouseEvent(eventName, event, targetElement) {
6031
6078
 
@@ -6191,7 +6238,7 @@
6191
6238
  /**
6192
6239
  * Create default hit for the given element.
6193
6240
  *
6194
- * @param {djs.model.Base} element
6241
+ * @param {Base} element
6195
6242
  * @param {SVGElement} gfx
6196
6243
  *
6197
6244
  * @return {SVGElement} created hit
@@ -6263,8 +6310,8 @@
6263
6310
  /**
6264
6311
  * Update default hit of the element.
6265
6312
  *
6266
- * @param {djs.model.Base} element
6267
- * @param {SVGElement} gfx
6313
+ * @param {Base} element
6314
+ * @param {SVGElement} gfx
6268
6315
  *
6269
6316
  * @return {SVGElement} updated hit
6270
6317
  */
@@ -6312,7 +6359,7 @@
6312
6359
  * @event element.hover
6313
6360
  *
6314
6361
  * @type {Object}
6315
- * @property {djs.model.Base} element
6362
+ * @property {Base} element
6316
6363
  * @property {SVGElement} gfx
6317
6364
  * @property {Event} originalEvent
6318
6365
  */
@@ -6323,7 +6370,7 @@
6323
6370
  * @event element.out
6324
6371
  *
6325
6372
  * @type {Object}
6326
- * @property {djs.model.Base} element
6373
+ * @property {Base} element
6327
6374
  * @property {SVGElement} gfx
6328
6375
  * @property {Event} originalEvent
6329
6376
  */
@@ -6334,7 +6381,7 @@
6334
6381
  * @event element.click
6335
6382
  *
6336
6383
  * @type {Object}
6337
- * @property {djs.model.Base} element
6384
+ * @property {Base} element
6338
6385
  * @property {SVGElement} gfx
6339
6386
  * @property {Event} originalEvent
6340
6387
  */
@@ -6345,7 +6392,7 @@
6345
6392
  * @event element.dblclick
6346
6393
  *
6347
6394
  * @type {Object}
6348
- * @property {djs.model.Base} element
6395
+ * @property {Base} element
6349
6396
  * @property {SVGElement} gfx
6350
6397
  * @property {Event} originalEvent
6351
6398
  */
@@ -6356,7 +6403,7 @@
6356
6403
  * @event element.mousedown
6357
6404
  *
6358
6405
  * @type {Object}
6359
- * @property {djs.model.Base} element
6406
+ * @property {Base} element
6360
6407
  * @property {SVGElement} gfx
6361
6408
  * @property {Event} originalEvent
6362
6409
  */
@@ -6367,7 +6414,7 @@
6367
6414
  * @event element.mouseup
6368
6415
  *
6369
6416
  * @type {Object}
6370
- * @property {djs.model.Base} element
6417
+ * @property {Base} element
6371
6418
  * @property {SVGElement} gfx
6372
6419
  * @property {Event} originalEvent
6373
6420
  */
@@ -6379,7 +6426,7 @@
6379
6426
  * @event element.contextmenu
6380
6427
  *
6381
6428
  * @type {Object}
6382
- * @property {djs.model.Base} element
6429
+ * @property {Base} element
6383
6430
  * @property {SVGElement} gfx
6384
6431
  * @property {Event} originalEvent
6385
6432
  */
@@ -6393,10 +6440,10 @@
6393
6440
  * Returns the surrounding bbox for all elements in
6394
6441
  * the array or the element primitive.
6395
6442
  *
6396
- * @param {Array<djs.model.Shape>|djs.model.Shape} elements
6443
+ * @param {Base|Base[]} elements
6397
6444
  * @param {boolean} [stopRecursion=false]
6398
6445
  *
6399
- * @return {Bounds}
6446
+ * @return {Rect}
6400
6447
  */
6401
6448
  function getBBox(elements, stopRecursion) {
6402
6449
 
@@ -6467,6 +6514,12 @@
6467
6514
 
6468
6515
  var LOW_PRIORITY$3 = 500;
6469
6516
 
6517
+ /**
6518
+ * @typedef {import('../../model').Base} Base
6519
+ *
6520
+ * @typedef {import('../../core/EventBus').default} EventBus
6521
+ * @typedef {import('../../draw/Styles').default} Styles
6522
+ */
6470
6523
 
6471
6524
  /**
6472
6525
  * @class
@@ -6476,9 +6529,8 @@
6476
6529
  *
6477
6530
  * @param {EventBus} eventBus
6478
6531
  * @param {Styles} styles
6479
- * @param {ElementRegistry} elementRegistry
6480
6532
  */
6481
- function Outline(eventBus, styles, elementRegistry) {
6533
+ function Outline(eventBus, styles) {
6482
6534
 
6483
6535
  this.offset = 6;
6484
6536
 
@@ -6536,8 +6588,8 @@
6536
6588
  * Updates the outline of a shape respecting the dimension of the
6537
6589
  * element and an outline offset.
6538
6590
  *
6539
- * @param {SVGElement} outline
6540
- * @param {djs.model.Base} element
6591
+ * @param {SVGElement} outline
6592
+ * @param {Base} element
6541
6593
  */
6542
6594
  Outline.prototype.updateShapeOutline = function(outline, element) {
6543
6595
 
@@ -6555,8 +6607,8 @@
6555
6607
  * Updates the outline of a connection respecting the bounding box of
6556
6608
  * the connection and an outline offset.
6557
6609
  *
6558
- * @param {SVGElement} outline
6559
- * @param {djs.model.Base} element
6610
+ * @param {SVGElement} outline
6611
+ * @param {Base} element
6560
6612
  */
6561
6613
  Outline.prototype.updateConnectionOutline = function(outline, connection) {
6562
6614
 
@@ -6579,13 +6631,17 @@
6579
6631
  outline: [ 'type', Outline ]
6580
6632
  };
6581
6633
 
6634
+ /**
6635
+ * @typedef {import('../../core/EventBus').default} EventBus
6636
+ */
6637
+
6582
6638
  /**
6583
6639
  * A service that offers the current selection in a diagram.
6584
6640
  * Offers the api to control the selection, too.
6585
6641
  *
6586
6642
  * @class
6587
6643
  *
6588
- * @param {EventBus} eventBus the event bus
6644
+ * @param {EventBus} eventBus
6589
6645
  */
6590
6646
  function Selection(eventBus, canvas) {
6591
6647
 
@@ -6641,8 +6697,8 @@
6641
6697
  *
6642
6698
  * @method Selection#select
6643
6699
  *
6644
- * @param {Object|Object[]} elements element or array of elements to be selected
6645
- * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
6700
+ * @param {Object|Object[]} elements element or array of elements to be selected
6701
+ * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
6646
6702
  */
6647
6703
  Selection.prototype.select = function(elements, add) {
6648
6704
  var selectedElements = this._selectedElements,
@@ -6681,6 +6737,12 @@
6681
6737
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
6682
6738
  };
6683
6739
 
6740
+ /**
6741
+ * @typedef {import('../../core/Canvas').default} Canvas
6742
+ * @typedef {import('../../core/EventBus').default} EventBus
6743
+ * @typedef {import('./Selection').default} Selection
6744
+ */
6745
+
6684
6746
  var MARKER_HOVER = 'hover',
6685
6747
  MARKER_SELECTED = 'selected';
6686
6748
 
@@ -6697,6 +6759,7 @@
6697
6759
  *
6698
6760
  * @param {Canvas} canvas
6699
6761
  * @param {EventBus} eventBus
6762
+ * @param {Selection} selection
6700
6763
  */
6701
6764
  function SelectionVisuals(canvas, eventBus, selection) {
6702
6765
  this._canvas = canvas;
@@ -6802,6 +6865,19 @@
6802
6865
  };
6803
6866
  }
6804
6867
 
6868
+ /**
6869
+ * @typedef {import('../../core/Canvas').default} Canvas
6870
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
6871
+ * @typedef {import('../../core/EventBus').default} EventBus
6872
+ * @typedef {import('./Selection').default} Selection
6873
+ */
6874
+
6875
+ /**
6876
+ * @param {EventBus} eventBus
6877
+ * @param {Selection} selection
6878
+ * @param {Canvas} canvas
6879
+ * @param {ElementRegistry} elementRegistry
6880
+ */
6805
6881
  function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
6806
6882
 
6807
6883
  // Select elements on create
@@ -6922,9 +6998,8 @@
6922
6998
  /**
6923
6999
  * Util that provides unique IDs.
6924
7000
  *
6925
- * @class djs.util.IdGenerator
7001
+ * @class
6926
7002
  * @constructor
6927
- * @memberOf djs.util
6928
7003
  *
6929
7004
  * The ids can be customized via a given prefix and contain a random value to avoid collisions.
6930
7005
  *
@@ -6939,8 +7014,6 @@
6939
7014
  /**
6940
7015
  * Returns a next unique ID.
6941
7016
  *
6942
- * @method djs.util.IdGenerator#next
6943
- *
6944
7017
  * @returns {string} the id
6945
7018
  */
6946
7019
  IdGenerator.prototype.next = function() {
@@ -6952,6 +7025,18 @@
6952
7025
 
6953
7026
  var LOW_PRIORITY$2 = 500;
6954
7027
 
7028
+ /**
7029
+ * @typedef {import('../../core/Canvas').default} Canvas
7030
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7031
+ * @typedef {import('../../core/EventBus').default} EventBus
7032
+ *
7033
+ * @typedef {import('./Overlays').Overlay} Overlay
7034
+ * @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
7035
+ * @typedef {import('./Overlays').OverlayContainer} OverlayContainer
7036
+ * @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
7037
+ * @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
7038
+ * @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
7039
+ */
6955
7040
 
6956
7041
  /**
6957
7042
  * A service that allows users to attach overlays to diagram elements.
@@ -6961,6 +7046,7 @@
6961
7046
  * @example
6962
7047
  *
6963
7048
  * // add a pink badge on the top left of the shape
7049
+ *
6964
7050
  * overlays.add(someShape, {
6965
7051
  * position: {
6966
7052
  * top: -5,
@@ -7012,19 +7098,21 @@
7012
7098
  * }
7013
7099
  * }
7014
7100
  *
7015
- * @param {Object} config
7101
+ * @param {OverlaysConfig} config
7016
7102
  * @param {EventBus} eventBus
7017
7103
  * @param {Canvas} canvas
7018
7104
  * @param {ElementRegistry} elementRegistry
7019
7105
  */
7020
7106
  function Overlays(config, eventBus, canvas, elementRegistry) {
7021
-
7022
7107
  this._eventBus = eventBus;
7023
7108
  this._canvas = canvas;
7024
7109
  this._elementRegistry = elementRegistry;
7025
7110
 
7026
7111
  this._ids = ids;
7027
7112
 
7113
+ /**
7114
+ * @type {OverlaysConfigDefault}
7115
+ */
7028
7116
  this._overlayDefaults = assign$1({
7029
7117
 
7030
7118
  // no show constraints
@@ -7035,16 +7123,18 @@
7035
7123
  }, config && config.defaults);
7036
7124
 
7037
7125
  /**
7038
- * Mapping overlayId -> overlay
7126
+ * @type {Map<string, Overlay>}
7039
7127
  */
7040
7128
  this._overlays = {};
7041
7129
 
7042
7130
  /**
7043
- * Mapping elementId -> overlay container
7131
+ * @type {OverlayContainer[]}
7044
7132
  */
7045
7133
  this._overlayContainers = [];
7046
7134
 
7047
- // root html element for all overlays
7135
+ /**
7136
+ * @type {HTMLElement}
7137
+ */
7048
7138
  this._overlayRoot = createRoot(canvas.getContainer());
7049
7139
 
7050
7140
  this._init();
@@ -7060,12 +7150,12 @@
7060
7150
 
7061
7151
 
7062
7152
  /**
7063
- * Returns the overlay with the specified id or a list of overlays
7153
+ * Returns the overlay with the specified ID or a list of overlays
7064
7154
  * for an element with a given type.
7065
7155
  *
7066
7156
  * @example
7067
7157
  *
7068
- * // return the single overlay with the given id
7158
+ * // return the single overlay with the given ID
7069
7159
  * overlays.get('some-id');
7070
7160
  *
7071
7161
  * // return all overlays for the shape
@@ -7074,16 +7164,12 @@
7074
7164
  * // return all overlays on shape with type 'badge'
7075
7165
  * overlays.get({ element: someShape, type: 'badge' });
7076
7166
  *
7077
- * // shape can also be specified as id
7167
+ * // shape can also be specified as ID
7078
7168
  * overlays.get({ element: 'element-id', type: 'badge' });
7079
7169
  *
7170
+ * @param {OverlaysFilter} search The filter to be used to find the overlay(s).
7080
7171
  *
7081
- * @param {Object} search
7082
- * @param {string} [search.id]
7083
- * @param {string|djs.model.Base} [search.element]
7084
- * @param {string} [search.type]
7085
- *
7086
- * @return {Object|Array<Object>} the overlay(s)
7172
+ * @return {Overlay|Overlay[]} The overlay(s).
7087
7173
  */
7088
7174
  Overlays.prototype.get = function(search) {
7089
7175
 
@@ -7115,27 +7201,13 @@
7115
7201
  };
7116
7202
 
7117
7203
  /**
7118
- * Adds a HTML overlay to an element.
7119
- *
7120
- * @param {string|djs.model.Base} element attach overlay to this shape
7121
- * @param {string} [type] optional type to assign to the overlay
7122
- * @param {Object} overlay the overlay configuration
7204
+ * Adds an HTML overlay to an element.
7123
7205
  *
7124
- * @param {string|DOMElement} overlay.html html element to use as an overlay
7125
- * @param {Object} [overlay.show] show configuration
7126
- * @param {number} [overlay.show.minZoom] minimal zoom level to show the overlay
7127
- * @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
7128
- * @param {Object} overlay.position where to attach the overlay
7129
- * @param {number} [overlay.position.left] relative to element bbox left attachment
7130
- * @param {number} [overlay.position.top] relative to element bbox top attachment
7131
- * @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
7132
- * @param {number} [overlay.position.right] relative to element bbox right attachment
7133
- * @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
7134
- * diagram zoom
7135
- * @param {number} [overlay.scale.min]
7136
- * @param {number} [overlay.scale.max]
7206
+ * @param {Base|string} element The element to add the overlay to.
7207
+ * @param {string} [type] An optional type that can be used to filter.
7208
+ * @param {OverlayAttrs} overlay The overlay.
7137
7209
  *
7138
- * @return {string} id that may be used to reference the overlay for update or removal
7210
+ * @return {string} The overlay's ID that can be used to get or remove it.
7139
7211
  */
7140
7212
  Overlays.prototype.add = function(element, type, overlay) {
7141
7213
 
@@ -7176,11 +7248,11 @@
7176
7248
 
7177
7249
 
7178
7250
  /**
7179
- * Remove an overlay with the given id or all overlays matching the given filter.
7251
+ * Remove an overlay with the given ID or all overlays matching the given filter.
7180
7252
  *
7181
7253
  * @see Overlays#get for filter options.
7182
7254
  *
7183
- * @param {string|object} [filter]
7255
+ * @param {OverlaysFilter} filter The filter to be used to find the overlay.
7184
7256
  */
7185
7257
  Overlays.prototype.remove = function(filter) {
7186
7258
 
@@ -7216,19 +7288,32 @@
7216
7288
 
7217
7289
  };
7218
7290
 
7291
+ /**
7292
+ * Checks whether overlays are shown.
7293
+ *
7294
+ * @returns {boolean} Whether overlays are shown.
7295
+ */
7219
7296
  Overlays.prototype.isShown = function() {
7220
7297
  return this._overlayRoot.style.display !== 'none';
7221
7298
  };
7222
7299
 
7300
+ /**
7301
+ * Show all overlays.
7302
+ */
7223
7303
  Overlays.prototype.show = function() {
7224
7304
  setVisible(this._overlayRoot);
7225
7305
  };
7226
7306
 
7227
-
7307
+ /**
7308
+ * Hide all overlays.
7309
+ */
7228
7310
  Overlays.prototype.hide = function() {
7229
7311
  setVisible(this._overlayRoot, false);
7230
7312
  };
7231
7313
 
7314
+ /**
7315
+ * Remove all overlays and their container.
7316
+ */
7232
7317
  Overlays.prototype.clear = function() {
7233
7318
  this._overlays = {};
7234
7319
 
@@ -7604,6 +7689,13 @@
7604
7689
  overlays: [ 'type', Overlays ]
7605
7690
  };
7606
7691
 
7692
+ /**
7693
+ * @typedef {import('../../core/Canvas').default} Canvas
7694
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7695
+ * @typedef {import('../../core/EventBus').default} EventBus
7696
+ * @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
7697
+ */
7698
+
7607
7699
  /**
7608
7700
  * Adds change support to the diagram, including
7609
7701
  *
@@ -7673,32 +7765,41 @@
7673
7765
  changeSupport: [ 'type', ChangeSupport ]
7674
7766
  };
7675
7767
 
7768
+ /**
7769
+ * @typedef {import('../core/EventBus').default} EventBus
7770
+ * @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
7771
+ * @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
7772
+ */
7773
+
7676
7774
  var DEFAULT_PRIORITY$2 = 1000;
7677
7775
 
7678
7776
  /**
7679
- * A utility that can be used to plug-in into the command execution for
7777
+ * A utility that can be used to plug into the command execution for
7680
7778
  * extension and/or validation.
7681
7779
  *
7780
+ * @class
7781
+ * @constructor
7782
+ *
7682
7783
  * @param {EventBus} eventBus
7683
7784
  *
7684
7785
  * @example
7685
7786
  *
7686
- * import inherits from 'inherits-browser';
7687
- *
7688
7787
  * import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
7689
7788
  *
7690
- * function CommandLogger(eventBus) {
7691
- * CommandInterceptor.call(this, eventBus);
7789
+ * class CommandLogger extends CommandInterceptor {
7790
+ * constructor(eventBus) {
7791
+ * super(eventBus);
7692
7792
  *
7693
- * this.preExecute(function(event) {
7694
- * console.log('command pre-execute', event);
7793
+ * this.preExecute('shape.create', (event) => {
7794
+ * console.log('commandStack.shape-create.preExecute', event);
7695
7795
  * });
7696
7796
  * }
7697
- *
7698
- * inherits(CommandLogger, CommandInterceptor);
7699
- *
7700
7797
  */
7701
7798
  function CommandInterceptor(eventBus) {
7799
+
7800
+ /**
7801
+ * @type {EventBus}
7802
+ */
7702
7803
  this._eventBus = eventBus;
7703
7804
  }
7704
7805
 
@@ -7711,16 +7812,15 @@
7711
7812
  }
7712
7813
 
7713
7814
  /**
7714
- * Register an interceptor for a command execution
7715
- *
7716
- * @param {string|Array<string>} [events] list of commands to register on
7717
- * @param {string} [hook] command hook, i.e. preExecute, executed to listen on
7718
- * @param {number} [priority] the priority on which to hook into the execution
7719
- * @param {Function} handlerFn interceptor to be invoked with (event)
7720
- * @param {boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
7721
- * listener instead
7722
- * @param {Object} [that] Pass context (`this`) to the handler function
7723
- */
7815
+ * Intercept a command during one of the phases.
7816
+ *
7817
+ * @param {string|string[]} [events] One or more commands to intercept.
7818
+ * @param {string} [hook] Phase during which to intercept command.
7819
+ * @param {number} [priority] Priority with which command will be intercepted.
7820
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7821
+ * @param {boolean} [unwrap] Whether the event should be unwrapped.
7822
+ * @param {*} [that] `this` value the callback will be called with.
7823
+ */
7724
7824
  CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
7725
7825
 
7726
7826
  if (isFunction(hook) || isNumber(hook)) {
@@ -7776,24 +7876,19 @@
7776
7876
  ];
7777
7877
 
7778
7878
  /*
7779
- * Install hook shortcuts
7780
- *
7781
- * This will generate the CommandInterceptor#(preExecute|...|reverted) methods
7782
- * which will in term forward to CommandInterceptor#on.
7879
+ * Add prototype methods for each phase of command execution (e.g. execute,
7880
+ * revert).
7783
7881
  */
7784
7882
  forEach$1(hooks, function(hook) {
7785
7883
 
7786
7884
  /**
7787
- * {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
7788
- *
7789
- * A named hook for plugging into the command execution
7885
+ * Add prototype method for a specific phase of command execution.
7790
7886
  *
7791
- * @param {string|Array<string>} [events] list of commands to register on
7792
- * @param {number} [priority] the priority on which to hook into the execution
7793
- * @param {Function} handlerFn interceptor to be invoked with (event)
7794
- * @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
7795
- * listener instead
7796
- * @param {Object} [that] Pass context (`this`) to the handler function
7887
+ * @param {string|string[]} [events] One or more commands to intercept.
7888
+ * @param {number} [priority] Priority with which command will be intercepted.
7889
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7890
+ * @param {boolean} [unwrap] Whether the event should be unwrapped.
7891
+ * @param {*} [that] `this` value the callback will be called with.
7797
7892
  */
7798
7893
  CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
7799
7894
 
@@ -7809,12 +7904,18 @@
7809
7904
  };
7810
7905
  });
7811
7906
 
7907
+ /**
7908
+ * @typedef {import('didi').Injector} Injector
7909
+ *
7910
+ * @typedef {import('../../core/Canvas').default} Canvas
7911
+ */
7912
+
7812
7913
  /**
7813
7914
  * A modeling behavior that ensures we set the correct root element
7814
7915
  * as we undo and redo commands.
7815
7916
  *
7816
7917
  * @param {Canvas} canvas
7817
- * @param {didi.Injector} injector
7918
+ * @param {Injector} injector
7818
7919
  */
7819
7920
  function RootElementsBehavior(canvas, injector) {
7820
7921
 
@@ -7848,111 +7949,10 @@
7848
7949
  rootElementsBehavior: [ 'type', RootElementsBehavior ]
7849
7950
  };
7850
7951
 
7851
- var css_escape = {exports: {}};
7852
-
7853
- /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
7854
-
7855
- (function (module, exports) {
7856
- (function(root, factory) {
7857
- // https://github.com/umdjs/umd/blob/master/returnExports.js
7858
- {
7859
- // For Node.js.
7860
- module.exports = factory(root);
7861
- }
7862
- }(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
7863
-
7864
- if (root.CSS && root.CSS.escape) {
7865
- return root.CSS.escape;
7866
- }
7867
-
7868
- // https://drafts.csswg.org/cssom/#serialize-an-identifier
7869
- var cssEscape = function(value) {
7870
- if (arguments.length == 0) {
7871
- throw new TypeError('`CSS.escape` requires an argument.');
7872
- }
7873
- var string = String(value);
7874
- var length = string.length;
7875
- var index = -1;
7876
- var codeUnit;
7877
- var result = '';
7878
- var firstCodeUnit = string.charCodeAt(0);
7879
- while (++index < length) {
7880
- codeUnit = string.charCodeAt(index);
7881
- // Note: there’s no need to special-case astral symbols, surrogate
7882
- // pairs, or lone surrogates.
7883
-
7884
- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
7885
- // (U+FFFD).
7886
- if (codeUnit == 0x0000) {
7887
- result += '\uFFFD';
7888
- continue;
7889
- }
7890
-
7891
- if (
7892
- // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
7893
- // U+007F, […]
7894
- (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
7895
- // If the character is the first character and is in the range [0-9]
7896
- // (U+0030 to U+0039), […]
7897
- (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
7898
- // If the character is the second character and is in the range [0-9]
7899
- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
7900
- (
7901
- index == 1 &&
7902
- codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
7903
- firstCodeUnit == 0x002D
7904
- )
7905
- ) {
7906
- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
7907
- result += '\\' + codeUnit.toString(16) + ' ';
7908
- continue;
7909
- }
7910
-
7911
- if (
7912
- // If the character is the first character and is a `-` (U+002D), and
7913
- // there is no second character, […]
7914
- index == 0 &&
7915
- length == 1 &&
7916
- codeUnit == 0x002D
7917
- ) {
7918
- result += '\\' + string.charAt(index);
7919
- continue;
7920
- }
7921
-
7922
- // If the character is not handled by one of the above rules and is
7923
- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
7924
- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
7925
- // U+005A), or [a-z] (U+0061 to U+007A), […]
7926
- if (
7927
- codeUnit >= 0x0080 ||
7928
- codeUnit == 0x002D ||
7929
- codeUnit == 0x005F ||
7930
- codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
7931
- codeUnit >= 0x0041 && codeUnit <= 0x005A ||
7932
- codeUnit >= 0x0061 && codeUnit <= 0x007A
7933
- ) {
7934
- // the character itself
7935
- result += string.charAt(index);
7936
- continue;
7937
- }
7938
-
7939
- // Otherwise, the escaped character.
7940
- // https://drafts.csswg.org/cssom/#escape-a-character
7941
- result += '\\' + string.charAt(index);
7942
-
7943
- }
7944
- return result;
7945
- };
7946
-
7947
- if (!root.CSS) {
7948
- root.CSS = {};
7949
- }
7950
-
7951
- root.CSS.escape = cssEscape;
7952
- return cssEscape;
7953
-
7954
- }));
7955
- } (css_escape));
7952
+ /**
7953
+ * @param {string} str
7954
+ * @returns {string}
7955
+ */
7956
7956
 
7957
7957
  var HTML_ESCAPE_MAP = {
7958
7958
  '&': '&amp;',
@@ -9087,6 +9087,11 @@
9087
9087
  return value;
9088
9088
  }
9089
9089
 
9090
+ /**
9091
+ * @typedef {import('../core/EventBus').default} EventBus
9092
+ * @typedef {import('./Styles').default} Styles
9093
+ */
9094
+
9090
9095
  // apply default renderer with lowest possible priority
9091
9096
  // so that it only kicks in if noone else could render
9092
9097
  var DEFAULT_RENDER_PRIORITY = 1;
@@ -9204,9 +9209,9 @@
9204
9209
  /**
9205
9210
  * Builds a style definition from a className, a list of traits and an object of additional attributes.
9206
9211
  *
9207
- * @param {string} className
9208
- * @param {Array<string>} traits
9209
- * @param {Object} additionalAttrs
9212
+ * @param {string} className
9213
+ * @param {Array<string>} traits
9214
+ * @param {Object} additionalAttrs
9210
9215
  *
9211
9216
  * @return {Object} the style defintion
9212
9217
  */
@@ -9219,8 +9224,8 @@
9219
9224
  /**
9220
9225
  * Builds a style definition from a list of traits and an object of additional attributes.
9221
9226
  *
9222
- * @param {Array<string>} traits
9223
- * @param {Object} additionalAttrs
9227
+ * @param {Array<string>} traits
9228
+ * @param {Object} additionalAttrs
9224
9229
  *
9225
9230
  * @return {Object} the style defintion
9226
9231
  */
@@ -9257,8 +9262,8 @@
9257
9262
  /**
9258
9263
  * Failsafe remove an element from a collection
9259
9264
  *
9260
- * @param {Array<Object>} [collection]
9261
- * @param {Object} [element]
9265
+ * @param {Array<Object>} [collection]
9266
+ * @param {Object} [element]
9262
9267
  *
9263
9268
  * @return {number} the previous index of the element
9264
9269
  */
@@ -9328,6 +9333,27 @@
9328
9333
  }
9329
9334
  }
9330
9335
 
9336
+ /**
9337
+ * @typedef {import('.').ConnectionLike} ConnectionLike
9338
+ * @typedef {import('.').RootLike} RootLike
9339
+ * @typedef {import('.').ShapeLike} ShapeLike
9340
+ *
9341
+ * @typedef {import('./Canvas').CanvasConfig} CanvasConfig
9342
+ * @typedef {import('./Canvas').CanvasLayer} CanvasLayer
9343
+ * @typedef {import('./Canvas').CanvasLayers} CanvasLayers
9344
+ * @typedef {import('./Canvas').CanvasPlane} CanvasPlane
9345
+ * @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
9346
+ *
9347
+ * @typedef {import('./ElementRegistry').default} ElementRegistry
9348
+ * @typedef {import('./EventBus').default} EventBus
9349
+ * @typedef {import('./GraphicsFactory').default} GraphicsFactory
9350
+ *
9351
+ * @typedef {import('../util/Types').Dimensions} Dimensions
9352
+ * @typedef {import('../util/Types').Point} Point
9353
+ * @typedef {import('../util/Types').Rect} Rect
9354
+ * @typedef {import('../util/Types').RectTRBL} RectTRBL
9355
+ */
9356
+
9331
9357
  function round(number, resolution) {
9332
9358
  return Math.round(number * resolution) / resolution;
9333
9359
  }
@@ -9348,7 +9374,8 @@
9348
9374
  * Creates a HTML container element for a SVG element with
9349
9375
  * the given configuration
9350
9376
  *
9351
- * @param {Object} options
9377
+ * @param {CanvasConfig} options
9378
+ *
9352
9379
  * @return {HTMLElement} the container element
9353
9380
  */
9354
9381
  function createContainer(options) {
@@ -9408,21 +9435,34 @@
9408
9435
  *
9409
9436
  * @emits Canvas#canvas.init
9410
9437
  *
9411
- * @param {Object} config
9438
+ * @param {CanvasConfig|null} config
9412
9439
  * @param {EventBus} eventBus
9413
9440
  * @param {GraphicsFactory} graphicsFactory
9414
9441
  * @param {ElementRegistry} elementRegistry
9415
9442
  */
9416
9443
  function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
9417
-
9418
9444
  this._eventBus = eventBus;
9419
9445
  this._elementRegistry = elementRegistry;
9420
9446
  this._graphicsFactory = graphicsFactory;
9421
9447
 
9448
+ /**
9449
+ * @type {number}
9450
+ */
9422
9451
  this._rootsIdx = 0;
9423
9452
 
9453
+ /**
9454
+ * @type {CanvasLayers}
9455
+ */
9424
9456
  this._layers = {};
9457
+
9458
+ /**
9459
+ * @type {CanvasPlane[]}
9460
+ */
9425
9461
  this._planes = [];
9462
+
9463
+ /**
9464
+ * @type {RootLike|null}
9465
+ */
9426
9466
  this._rootElement = null;
9427
9467
 
9428
9468
  this._init(config || {});
@@ -9447,6 +9487,8 @@
9447
9487
  * ...
9448
9488
  * </svg>
9449
9489
  * </div>
9490
+ *
9491
+ * @param {CanvasConfig} config
9450
9492
  */
9451
9493
  Canvas.prototype._init = function(config) {
9452
9494
 
@@ -9468,7 +9510,7 @@
9468
9510
  this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
9469
9511
  }
9470
9512
 
9471
- eventBus.on('diagram.init', function() {
9513
+ eventBus.on('diagram.init', () => {
9472
9514
 
9473
9515
  /**
9474
9516
  * An event indicating that the canvas is ready to be drawn on.
@@ -9486,7 +9528,7 @@
9486
9528
  viewport: viewport
9487
9529
  });
9488
9530
 
9489
- }, this);
9531
+ });
9490
9532
 
9491
9533
  // reset viewbox on shape changes to
9492
9534
  // recompute the viewbox
@@ -9497,15 +9539,15 @@
9497
9539
  'connection.removed',
9498
9540
  'elements.changed',
9499
9541
  'root.set'
9500
- ], function() {
9542
+ ], () => {
9501
9543
  delete this._cachedViewbox;
9502
- }, this);
9544
+ });
9503
9545
 
9504
9546
  eventBus.on('diagram.destroy', 500, this._destroy, this);
9505
9547
  eventBus.on('diagram.clear', 500, this._clear, this);
9506
9548
  };
9507
9549
 
9508
- Canvas.prototype._destroy = function(emit) {
9550
+ Canvas.prototype._destroy = function() {
9509
9551
  this._eventBus.fire('canvas.destroy', {
9510
9552
  svg: this._svg,
9511
9553
  viewport: this._viewport
@@ -9552,7 +9594,7 @@
9552
9594
  * Returns the default layer on which
9553
9595
  * all elements are drawn.
9554
9596
  *
9555
- * @returns {SVGElement}
9597
+ * @return {SVGElement} The SVG element of the layer.
9556
9598
  */
9557
9599
  Canvas.prototype.getDefaultLayer = function() {
9558
9600
  return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
@@ -9568,10 +9610,10 @@
9568
9610
  * A layer with a certain index is always created above all
9569
9611
  * existing layers with the same index.
9570
9612
  *
9571
- * @param {string} name
9572
- * @param {number} index
9613
+ * @param {string} name The name of the layer.
9614
+ * @param {number} [index] The index of the layer.
9573
9615
  *
9574
- * @returns {SVGElement}
9616
+ * @return {SVGElement} The SVG element of the layer.
9575
9617
  */
9576
9618
  Canvas.prototype.getLayer = function(name, index) {
9577
9619
 
@@ -9600,8 +9642,9 @@
9600
9642
  *
9601
9643
  * This is used to determine the node a layer should be inserted at.
9602
9644
  *
9603
- * @param {Number} index
9604
- * @returns {Number}
9645
+ * @param {number} index
9646
+ *
9647
+ * @return {number}
9605
9648
  */
9606
9649
  Canvas.prototype._getChildIndex = function(index) {
9607
9650
  return reduce(this._layers, function(childIndex, layer) {
@@ -9619,7 +9662,7 @@
9619
9662
  * @param {string} name
9620
9663
  * @param {number} [index=0]
9621
9664
  *
9622
- * @return {Object} layer descriptor with { index, group: SVGGroup }
9665
+ * @return {CanvasLayer}
9623
9666
  */
9624
9667
  Canvas.prototype._createLayer = function(name, index) {
9625
9668
 
@@ -9640,8 +9683,9 @@
9640
9683
  /**
9641
9684
  * Shows a given layer.
9642
9685
  *
9643
- * @param {String} layer
9644
- * @returns {SVGElement}
9686
+ * @param {string} layer The name of the layer.
9687
+ *
9688
+ * @return {SVGElement} The SVG element of the layer.
9645
9689
  */
9646
9690
  Canvas.prototype.showLayer = function(name) {
9647
9691
 
@@ -9675,8 +9719,9 @@
9675
9719
  /**
9676
9720
  * Hides a given layer.
9677
9721
  *
9678
- * @param {String} layer
9679
- * @returns {SVGElement}
9722
+ * @param {string} layer The name of the layer.
9723
+ *
9724
+ * @return {SVGElement} The SVG element of the layer.
9680
9725
  */
9681
9726
  Canvas.prototype.hideLayer = function(name) {
9682
9727
 
@@ -9718,7 +9763,7 @@
9718
9763
  /**
9719
9764
  * Returns the currently active layer. Can be null.
9720
9765
  *
9721
- * @returns {SVGElement|null}
9766
+ * @return {CanvasLayer|null} The active layer of `null`.
9722
9767
  */
9723
9768
  Canvas.prototype.getActiveLayer = function() {
9724
9769
  const plane = this._findPlaneForRoot(this.getRootElement());
@@ -9734,9 +9779,9 @@
9734
9779
  /**
9735
9780
  * Returns the plane which contains the given element.
9736
9781
  *
9737
- * @param {string|djs.model.Base} element
9782
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9738
9783
  *
9739
- * @return {djs.model.Base} root for element
9784
+ * @return {RootLike|undefined} The root of the element.
9740
9785
  */
9741
9786
  Canvas.prototype.findRoot = function(element) {
9742
9787
  if (typeof element === 'string') {
@@ -9757,7 +9802,7 @@
9757
9802
  /**
9758
9803
  * Return a list of all root elements on the diagram.
9759
9804
  *
9760
- * @return {djs.model.Root[]}
9805
+ * @return {(RootLike)[]} The list of root elements.
9761
9806
  */
9762
9807
  Canvas.prototype.getRootElements = function() {
9763
9808
  return this._planes.map(function(plane) {
@@ -9776,7 +9821,7 @@
9776
9821
  * Returns the html element that encloses the
9777
9822
  * drawing canvas.
9778
9823
  *
9779
- * @return {DOMNode}
9824
+ * @return {HTMLElement} The HTML element of the container.
9780
9825
  */
9781
9826
  Canvas.prototype.getContainer = function() {
9782
9827
  return this._container;
@@ -9816,8 +9861,8 @@
9816
9861
  *
9817
9862
  * @event element.marker.update
9818
9863
  * @type {Object}
9819
- * @property {djs.model.Element} element the shape
9820
- * @property {Object} gfx the graphical representation of the shape
9864
+ * @property {Base} element the shape
9865
+ * @property {SVGElement} gfx the graphical representation of the shape
9821
9866
  * @property {string} marker
9822
9867
  * @property {boolean} add true if the marker was added, false if it got removed
9823
9868
  */
@@ -9832,14 +9877,15 @@
9832
9877
  * integrate extension into the marker life-cycle, too.
9833
9878
  *
9834
9879
  * @example
9880
+ *
9835
9881
  * canvas.addMarker('foo', 'some-marker');
9836
9882
  *
9837
9883
  * const fooGfx = canvas.getGraphics('foo');
9838
9884
  *
9839
9885
  * fooGfx; // <g class="... some-marker"> ... </g>
9840
9886
  *
9841
- * @param {string|djs.model.Base} element
9842
- * @param {string} marker
9887
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9888
+ * @param {string} marker The marker.
9843
9889
  */
9844
9890
  Canvas.prototype.addMarker = function(element, marker) {
9845
9891
  this._updateMarker(element, marker, true);
@@ -9852,18 +9898,18 @@
9852
9898
  * Fires the element.marker.update event, making it possible to
9853
9899
  * integrate extension into the marker life-cycle, too.
9854
9900
  *
9855
- * @param {string|djs.model.Base} element
9856
- * @param {string} marker
9901
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9902
+ * @param {string} marker The marker.
9857
9903
  */
9858
9904
  Canvas.prototype.removeMarker = function(element, marker) {
9859
9905
  this._updateMarker(element, marker, false);
9860
9906
  };
9861
9907
 
9862
9908
  /**
9863
- * Check the existence of a marker on element.
9909
+ * Check whether an element has a given marker.
9864
9910
  *
9865
- * @param {string|djs.model.Base} element
9866
- * @param {string} marker
9911
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9912
+ * @param {string} marker The marker.
9867
9913
  */
9868
9914
  Canvas.prototype.hasMarker = function(element, marker) {
9869
9915
  if (!element.id) {
@@ -9881,8 +9927,8 @@
9881
9927
  * Fires the element.marker.update event, making it possible to
9882
9928
  * integrate extension into the marker life-cycle, too.
9883
9929
  *
9884
- * @param {string|djs.model.Base} element
9885
- * @param {string} marker
9930
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9931
+ * @param {string} marker The marker.
9886
9932
  */
9887
9933
  Canvas.prototype.toggleMarker = function(element, marker) {
9888
9934
  if (this.hasMarker(element, marker)) {
@@ -9905,7 +9951,7 @@
9905
9951
  * root elements can be null. This is used for applications that want to manage
9906
9952
  * root elements themselves.
9907
9953
  *
9908
- * @returns {Object|djs.model.Root|null} rootElement.
9954
+ * @return {RootLike} The current root element.
9909
9955
  */
9910
9956
  Canvas.prototype.getRootElement = function() {
9911
9957
  const rootElement = this._rootElement;
@@ -9921,11 +9967,10 @@
9921
9967
  /**
9922
9968
  * Adds a given root element and returns it.
9923
9969
  *
9924
- * @param {Object|djs.model.Root} rootElement
9970
+ * @param {ShapeLike} [rootElement] The root element to be added.
9925
9971
  *
9926
- * @return {Object|djs.model.Root} rootElement
9972
+ * @return {RootLike} The added root element or an implicit root element.
9927
9973
  */
9928
-
9929
9974
  Canvas.prototype.addRootElement = function(rootElement) {
9930
9975
  const idx = this._rootsIdx++;
9931
9976
 
@@ -9956,11 +10001,11 @@
9956
10001
  };
9957
10002
 
9958
10003
  /**
9959
- * Removes a given rootElement and returns it.
10004
+ * Removes a given root element and returns it.
9960
10005
  *
9961
- * @param {djs.model.Root|String} rootElement
10006
+ * @param {ShapeLike|string} rootElement The root element or its ID.
9962
10007
  *
9963
- * @return {Object|djs.model.Root} rootElement
10008
+ * @return {ShapeLike|undefined} The removed root element.
9964
10009
  */
9965
10010
  Canvas.prototype.removeRootElement = function(rootElement) {
9966
10011
 
@@ -9994,15 +10039,13 @@
9994
10039
  };
9995
10040
 
9996
10041
 
9997
- // root element handling //////////////////////
9998
-
9999
10042
  /**
10000
10043
  * Sets a given element as the new root element for the canvas
10001
10044
  * and returns the new root element.
10002
10045
  *
10003
- * @param {Object|djs.model.Root} rootElement
10046
+ * @param {RootLike} rootElement The root element to be set.
10004
10047
  *
10005
- * @return {Object|djs.model.Root} new root element
10048
+ * @return {RootLike} The set root element.
10006
10049
  */
10007
10050
  Canvas.prototype.setRootElement = function(rootElement, override) {
10008
10051
 
@@ -10089,8 +10132,6 @@
10089
10132
  this._eventBus.fire('root.set', { element: rootElement });
10090
10133
  };
10091
10134
 
10092
- // add functionality //////////////////////
10093
-
10094
10135
  Canvas.prototype._ensureValid = function(type, element) {
10095
10136
  if (!element.id) {
10096
10137
  throw new Error('element must have an id');
@@ -10131,11 +10172,11 @@
10131
10172
  * Extensions may hook into these events to perform their magic.
10132
10173
  *
10133
10174
  * @param {string} type
10134
- * @param {Object|djs.model.Base} element
10135
- * @param {Object|djs.model.Base} [parent]
10175
+ * @param {ConnectionLike|ShapeLike} element
10176
+ * @param {ShapeLike} [parent]
10136
10177
  * @param {number} [parentIndex]
10137
10178
  *
10138
- * @return {Object|djs.model.Base} the added element
10179
+ * @return {ConnectionLike|ShapeLike} The added element.
10139
10180
  */
10140
10181
  Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
10141
10182
 
@@ -10164,26 +10205,26 @@
10164
10205
  };
10165
10206
 
10166
10207
  /**
10167
- * Adds a shape to the canvas
10208
+ * Adds a shape to the canvas.
10168
10209
  *
10169
- * @param {Object|djs.model.Shape} shape to add to the diagram
10170
- * @param {djs.model.Base} [parent]
10171
- * @param {number} [parentIndex]
10210
+ * @param {ShapeLike} shape The shape to be added
10211
+ * @param {ShapeLike} [parent] The shape's parent.
10212
+ * @param {number} [parentIndex] The index at which to add the shape to the parent's children.
10172
10213
  *
10173
- * @return {djs.model.Shape} the added shape
10214
+ * @return {ShapeLike} The added shape.
10174
10215
  */
10175
10216
  Canvas.prototype.addShape = function(shape, parent, parentIndex) {
10176
10217
  return this._addElement('shape', shape, parent, parentIndex);
10177
10218
  };
10178
10219
 
10179
10220
  /**
10180
- * Adds a connection to the canvas
10221
+ * Adds a connection to the canvas.
10181
10222
  *
10182
- * @param {Object|djs.model.Connection} connection to add to the diagram
10183
- * @param {djs.model.Base} [parent]
10184
- * @param {number} [parentIndex]
10223
+ * @param {ConnectionLike} connection The connection to be added.
10224
+ * @param {ShapeLike} [parent] The connection's parent.
10225
+ * @param {number} [parentIndex] The index at which to add the connection to the parent's children.
10185
10226
  *
10186
- * @return {djs.model.Connection} the added connection
10227
+ * @return {ConnectionLike} The added connection.
10187
10228
  */
10188
10229
  Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
10189
10230
  return this._addElement('connection', connection, parent, parentIndex);
@@ -10224,11 +10265,14 @@
10224
10265
 
10225
10266
 
10226
10267
  /**
10227
- * Removes a shape from the canvas
10268
+ * Removes a shape from the canvas.
10228
10269
  *
10229
- * @param {string|djs.model.Shape} shape or shape id to be removed
10270
+ * @fires ShapeRemoveEvent
10271
+ * @fires ShapeRemovedEvent
10230
10272
  *
10231
- * @return {djs.model.Shape} the removed shape
10273
+ * @param {ShapeLike|string} shape The shape or its ID.
10274
+ *
10275
+ * @return {ShapeLike} The removed shape.
10232
10276
  */
10233
10277
  Canvas.prototype.removeShape = function(shape) {
10234
10278
 
@@ -10237,10 +10281,10 @@
10237
10281
  *
10238
10282
  * @memberOf Canvas
10239
10283
  *
10240
- * @event shape.remove
10284
+ * @event ShapeRemoveEvent
10241
10285
  * @type {Object}
10242
- * @property {djs.model.Shape} element the shape descriptor
10243
- * @property {Object} gfx the graphical representation of the shape
10286
+ * @property {ShapeLike} element The shape.
10287
+ * @property {SVGElement} gfx The graphical element.
10244
10288
  */
10245
10289
 
10246
10290
  /**
@@ -10248,21 +10292,24 @@
10248
10292
  *
10249
10293
  * @memberOf Canvas
10250
10294
  *
10251
- * @event shape.removed
10295
+ * @event ShapeRemoved
10252
10296
  * @type {Object}
10253
- * @property {djs.model.Shape} element the shape descriptor
10254
- * @property {Object} gfx the graphical representation of the shape
10297
+ * @property {ShapeLike} element The shape.
10298
+ * @property {SVGElement} gfx The graphical element.
10255
10299
  */
10256
10300
  return this._removeElement(shape, 'shape');
10257
10301
  };
10258
10302
 
10259
10303
 
10260
10304
  /**
10261
- * Removes a connection from the canvas
10305
+ * Removes a connection from the canvas.
10306
+ *
10307
+ * @fires ConnectionRemoveEvent
10308
+ * @fires ConnectionRemovedEvent
10262
10309
  *
10263
- * @param {string|djs.model.Connection} connection or connection id to be removed
10310
+ * @param {ConnectionLike|string} connection The connection or its ID.
10264
10311
  *
10265
- * @return {djs.model.Connection} the removed connection
10312
+ * @return {ConnectionLike} The removed connection.
10266
10313
  */
10267
10314
  Canvas.prototype.removeConnection = function(connection) {
10268
10315
 
@@ -10271,10 +10318,10 @@
10271
10318
  *
10272
10319
  * @memberOf Canvas
10273
10320
  *
10274
- * @event connection.remove
10321
+ * @event ConnectionRemoveEvent
10275
10322
  * @type {Object}
10276
- * @property {djs.model.Connection} element the connection descriptor
10277
- * @property {Object} gfx the graphical representation of the connection
10323
+ * @property {ConnectionLike} element The connection.
10324
+ * @property {SVGElement} gfx The graphical element.
10278
10325
  */
10279
10326
 
10280
10327
  /**
@@ -10284,20 +10331,20 @@
10284
10331
  *
10285
10332
  * @event connection.removed
10286
10333
  * @type {Object}
10287
- * @property {djs.model.Connection} element the connection descriptor
10288
- * @property {Object} gfx the graphical representation of the connection
10334
+ * @property {ConnectionLike} element The connection.
10335
+ * @property {SVGElement} gfx The graphical element.
10289
10336
  */
10290
10337
  return this._removeElement(connection, 'connection');
10291
10338
  };
10292
10339
 
10293
10340
 
10294
10341
  /**
10295
- * Return the graphical object underlaying a certain diagram element
10342
+ * Returns the graphical element of an element.
10296
10343
  *
10297
- * @param {string|djs.model.Base} element descriptor of the element
10298
- * @param {boolean} [secondary=false] whether to return the secondary connected element
10344
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
10345
+ * @param {boolean} [secondary=false] Whether to return the secondary graphical element.
10299
10346
  *
10300
- * @return {SVGElement}
10347
+ * @return {SVGElement} The graphical element.
10301
10348
  */
10302
10349
  Canvas.prototype.getGraphics = function(element, secondary) {
10303
10350
  return this._elementRegistry.getGraphics(element, secondary);
@@ -10369,13 +10416,9 @@
10369
10416
  * height: zoomedAndScrolledViewbox.outer.height
10370
10417
  * });
10371
10418
  *
10372
- * @param {Object} [box] the new view box to set
10373
- * @param {number} box.x the top left X coordinate of the canvas visible in view box
10374
- * @param {number} box.y the top left Y coordinate of the canvas visible in view box
10375
- * @param {number} box.width the visible width
10376
- * @param {number} box.height
10419
+ * @param {Rect} [box] The viewbox to be set.
10377
10420
  *
10378
- * @return {Object} the current view box
10421
+ * @return {CanvasViewbox} The set viewbox.
10379
10422
  */
10380
10423
  Canvas.prototype.viewbox = function(box) {
10381
10424
 
@@ -10444,10 +10487,9 @@
10444
10487
  /**
10445
10488
  * Gets or sets the scroll of the canvas.
10446
10489
  *
10447
- * @param {Object} [delta] the new scroll to apply.
10490
+ * @param {Point} [delta] The scroll to be set.
10448
10491
  *
10449
- * @param {number} [delta.dx]
10450
- * @param {number} [delta.dy]
10492
+ * @return {Point}
10451
10493
  */
10452
10494
  Canvas.prototype.scroll = function(delta) {
10453
10495
 
@@ -10471,9 +10513,8 @@
10471
10513
  * Scrolls the viewbox to contain the given element.
10472
10514
  * Optionally specify a padding to be applied to the edges.
10473
10515
  *
10474
- * @param {Object|String} [element] the element to scroll to.
10475
- * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
10476
- *
10516
+ * @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
10517
+ * @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
10477
10518
  */
10478
10519
  Canvas.prototype.scrollToElement = function(element, padding) {
10479
10520
  let defaultPadding = 100;
@@ -10541,17 +10582,17 @@
10541
10582
  };
10542
10583
 
10543
10584
  /**
10544
- * Gets or sets the current zoom of the canvas, optionally zooming
10545
- * to the specified position.
10585
+ * Gets or sets the current zoom of the canvas, optionally zooming to the
10586
+ * specified position.
10546
10587
  *
10547
- * The getter may return a cached zoom level. Call it with `false` as
10548
- * the first argument to force recomputation of the current level.
10588
+ * The getter may return a cached zoom level. Call it with `false` as the first
10589
+ * argument to force recomputation of the current level.
10549
10590
  *
10550
- * @param {string|number} [newScale] the new zoom level, either a number, i.e. 0.9,
10551
- * or `fit-viewport` to adjust the size to fit the current viewport
10552
- * @param {string|Point} [center] the reference point { x: .., y: ..} to zoom to, 'auto' to zoom into mid or null
10591
+ * @param {number|string} [newScale] The new zoom level, either a number,
10592
+ * i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
10593
+ * @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
10553
10594
  *
10554
- * @return {number} the current scale
10595
+ * @return {number} The set zoom level.
10555
10596
  */
10556
10597
  Canvas.prototype.zoom = function(newScale, center) {
10557
10598
 
@@ -10674,9 +10715,9 @@
10674
10715
 
10675
10716
 
10676
10717
  /**
10677
- * Returns the size of the canvas
10718
+ * Returns the size of the canvas.
10678
10719
  *
10679
- * @return {Dimensions}
10720
+ * @return {Dimensions} The size of the canvas.
10680
10721
  */
10681
10722
  Canvas.prototype.getSize = function() {
10682
10723
  return {
@@ -10687,14 +10728,14 @@
10687
10728
 
10688
10729
 
10689
10730
  /**
10690
- * Return the absolute bounding box for the given element
10731
+ * Returns the absolute bounding box of an element.
10732
+ *
10733
+ * The absolute bounding box may be used to display overlays in the callers
10734
+ * (browser) coordinate system rather than the zoomed in/out canvas coordinates.
10691
10735
  *
10692
- * The absolute bounding box may be used to display overlays in the
10693
- * callers (browser) coordinate system rather than the zoomed in/out
10694
- * canvas coordinates.
10736
+ * @param {ShapeLike|ConnectionLike} element The element.
10695
10737
  *
10696
- * @param {ElementDescriptor} element
10697
- * @return {Bounds} the absolute bounding box
10738
+ * @return {Rect} The element's absolute bounding box.
10698
10739
  */
10699
10740
  Canvas.prototype.getAbsoluteBBox = function(element) {
10700
10741
  const vbox = this.viewbox();
@@ -10729,8 +10770,7 @@
10729
10770
  };
10730
10771
 
10731
10772
  /**
10732
- * Fires an event in order other modules can react to the
10733
- * canvas resizing
10773
+ * Fires an event so other modules can react to the canvas resizing.
10734
10774
  */
10735
10775
  Canvas.prototype.resized = function() {
10736
10776
 
@@ -10742,11 +10782,21 @@
10742
10782
 
10743
10783
  var ELEMENT_ID = 'data-element-id';
10744
10784
 
10785
+ /**
10786
+ * @typedef {import('.').ElementLike} ElementLike
10787
+ *
10788
+ * @typedef {import('./EventBus').default} EventBus
10789
+ *
10790
+ * @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
10791
+ */
10745
10792
 
10746
10793
  /**
10794
+ * A registry that keeps track of all shapes in the diagram.
10795
+ *
10747
10796
  * @class
10797
+ * @constructor
10748
10798
  *
10749
- * A registry that keeps track of all shapes in the diagram.
10799
+ * @param {EventBus} eventBus
10750
10800
  */
10751
10801
  function ElementRegistry(eventBus) {
10752
10802
  this._elements = {};
@@ -10757,11 +10807,11 @@
10757
10807
  ElementRegistry.$inject = [ 'eventBus' ];
10758
10808
 
10759
10809
  /**
10760
- * Register a pair of (element, gfx, (secondaryGfx)).
10810
+ * Add an element and its graphical representation(s) to the registry.
10761
10811
  *
10762
- * @param {djs.model.Base} element
10763
- * @param {SVGElement} gfx
10764
- * @param {SVGElement} [secondaryGfx] optional other element to register, too
10812
+ * @param {ElementLike} element The element to be added.
10813
+ * @param {SVGElement} gfx The primary graphical representation.
10814
+ * @param {SVGElement} [secondaryGfx] The secondary graphical representation.
10765
10815
  */
10766
10816
  ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
10767
10817
 
@@ -10780,9 +10830,9 @@
10780
10830
  };
10781
10831
 
10782
10832
  /**
10783
- * Removes an element from the registry.
10833
+ * Remove an element from the registry.
10784
10834
  *
10785
- * @param {string|djs.model.Base} element
10835
+ * @param {ElementLike|string} element
10786
10836
  */
10787
10837
  ElementRegistry.prototype.remove = function(element) {
10788
10838
  var elements = this._elements,
@@ -10803,10 +10853,10 @@
10803
10853
  };
10804
10854
 
10805
10855
  /**
10806
- * Update the id of an element
10856
+ * Update an elements ID.
10807
10857
  *
10808
- * @param {string|djs.model.Base} element
10809
- * @param {string} newId
10858
+ * @param {ElementLike|string} element The element or its ID.
10859
+ * @param {string} newId The new ID.
10810
10860
  */
10811
10861
  ElementRegistry.prototype.updateId = function(element, newId) {
10812
10862
 
@@ -10832,11 +10882,11 @@
10832
10882
  };
10833
10883
 
10834
10884
  /**
10835
- * Update the graphics of an element
10885
+ * Update the graphical representation of an element.
10836
10886
  *
10837
- * @param {string|djs.model.Base} element
10838
- * @param {SVGElement} gfx
10839
- * @param {boolean} [secondary=false] whether to update the secondary connected element
10887
+ * @param {ElementLike|string} element The element or its ID.
10888
+ * @param {SVGElement} gfx The new graphical representation.
10889
+ * @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
10840
10890
  */
10841
10891
  ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
10842
10892
  var id = filter.id || filter;
@@ -10857,17 +10907,17 @@
10857
10907
  };
10858
10908
 
10859
10909
  /**
10860
- * Return the model element for a given id or graphics.
10910
+ * Get the element with the given ID or graphical representation.
10861
10911
  *
10862
10912
  * @example
10863
10913
  *
10864
10914
  * elementRegistry.get('SomeElementId_1');
10865
- * elementRegistry.get(gfx);
10866
10915
  *
10916
+ * elementRegistry.get(gfx);
10867
10917
  *
10868
- * @param {string|SVGElement} filter for selecting the element
10918
+ * @param {string|SVGElement} filter The elements ID or graphical representation.
10869
10919
  *
10870
- * @return {djs.model.Base}
10920
+ * @return {ElementLike|undefined} The element.
10871
10921
  */
10872
10922
  ElementRegistry.prototype.get = function(filter) {
10873
10923
  var id;
@@ -10885,9 +10935,9 @@
10885
10935
  /**
10886
10936
  * Return all elements that match a given filter function.
10887
10937
  *
10888
- * @param {Function} fn
10938
+ * @param {ElementRegistryCallback} fn The filter function.
10889
10939
  *
10890
- * @return {Array<djs.model.Base>}
10940
+ * @return {ElementLike[]} The matching elements.
10891
10941
  */
10892
10942
  ElementRegistry.prototype.filter = function(fn) {
10893
10943
 
@@ -10903,11 +10953,11 @@
10903
10953
  };
10904
10954
 
10905
10955
  /**
10906
- * Return the first element that satisfies the provided testing function.
10956
+ * Return the first element that matches the given filter function.
10907
10957
  *
10908
- * @param {Function} fn
10958
+ * @param {Function} fn The filter function.
10909
10959
  *
10910
- * @return {djs.model.Base}
10960
+ * @return {ElementLike|undefined} The matching element.
10911
10961
  */
10912
10962
  ElementRegistry.prototype.find = function(fn) {
10913
10963
  var map = this._elements,
@@ -10926,18 +10976,18 @@
10926
10976
  };
10927
10977
 
10928
10978
  /**
10929
- * Return all rendered model elements.
10979
+ * Get all elements.
10930
10980
  *
10931
- * @return {Array<djs.model.Base>}
10981
+ * @return {ElementLike[]} All elements.
10932
10982
  */
10933
10983
  ElementRegistry.prototype.getAll = function() {
10934
10984
  return this.filter(function(e) { return e; });
10935
10985
  };
10936
10986
 
10937
10987
  /**
10938
- * Iterate over all diagram elements.
10988
+ * Execute a given function for each element.
10939
10989
  *
10940
- * @param {Function} fn
10990
+ * @param {Function} fn The function to execute.
10941
10991
  */
10942
10992
  ElementRegistry.prototype.forEach = function(fn) {
10943
10993
 
@@ -10953,19 +11003,20 @@
10953
11003
  };
10954
11004
 
10955
11005
  /**
10956
- * Return the graphical representation of an element or its id.
11006
+ * Return the graphical representation of an element.
10957
11007
  *
10958
11008
  * @example
11009
+ *
10959
11010
  * elementRegistry.getGraphics('SomeElementId_1');
11011
+ *
10960
11012
  * elementRegistry.getGraphics(rootElement); // <g ...>
10961
11013
  *
10962
11014
  * elementRegistry.getGraphics(rootElement, true); // <svg ...>
10963
11015
  *
11016
+ * @param {ElementLike|string} filter The element or its ID.
11017
+ * @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
10964
11018
  *
10965
- * @param {string|djs.model.Base} filter
10966
- * @param {boolean} [secondary=false] whether to return the secondary connected element
10967
- *
10968
- * @return {SVGElement}
11019
+ * @return {SVGElement} The graphical representation.
10969
11020
  */
10970
11021
  ElementRegistry.prototype.getGraphics = function(filter, secondary) {
10971
11022
  var id = filter.id || filter;
@@ -10975,12 +11026,11 @@
10975
11026
  };
10976
11027
 
10977
11028
  /**
10978
- * Validate the suitability of the given id and signals a problem
10979
- * with an exception.
11029
+ * Validate an ID and throw an error if invalid.
10980
11030
  *
10981
11031
  * @param {string} id
10982
11032
  *
10983
- * @throws {Error} if id is empty or already assigned
11033
+ * @throws {Error} Error indicating that the ID is invalid or already assigned.
10984
11034
  */
10985
11035
  ElementRegistry.prototype._validateId = function(id) {
10986
11036
  if (!id) {
@@ -11320,14 +11370,6 @@
11320
11370
  outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
11321
11371
  incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
11322
11372
 
11323
- /**
11324
- * @namespace djs.model
11325
- */
11326
-
11327
- /**
11328
- * @memberOf djs.model
11329
- */
11330
-
11331
11373
  /**
11332
11374
  * The basic graphical representation
11333
11375
  *
@@ -11524,21 +11566,47 @@
11524
11566
  };
11525
11567
 
11526
11568
  /**
11527
- * Creates a new model element of the specified type
11569
+ * Creates a model element of the given type.
11528
11570
  *
11529
11571
  * @method create
11530
11572
  *
11531
11573
  * @example
11532
11574
  *
11533
- * var shape1 = Model.create('shape', { x: 10, y: 10, width: 100, height: 100 });
11534
- * var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
11575
+ * import * as Model from 'diagram-js/lib/model';
11535
11576
  *
11536
- * var connection = Model.create('connection', { waypoints: [ { x: 110, y: 55 }, {x: 210, y: 55 } ] });
11577
+ * const connection = Model.create('connection', {
11578
+ * waypoints: [
11579
+ * { x: 100, y: 100 },
11580
+ * { x: 200, y: 100 }
11581
+ * ]
11582
+ * });
11537
11583
  *
11538
- * @param {string} type lower-cased model name
11539
- * @param {Object} attrs attributes to initialize the new model instance with
11584
+ * const label = Model.create('label', {
11585
+ * x: 100,
11586
+ * y: 100,
11587
+ * width: 100,
11588
+ * height: 100,
11589
+ * labelTarget: shape
11590
+ * });
11591
+ *
11592
+ * const root = Model.create('root', {
11593
+ * x: 100,
11594
+ * y: 100,
11595
+ * width: 100,
11596
+ * height: 100
11597
+ * });
11540
11598
  *
11541
- * @return {Base} the new model instance
11599
+ * const shape = Model.create('shape', {
11600
+ * x: 100,
11601
+ * y: 100,
11602
+ * width: 100,
11603
+ * height: 100
11604
+ * });
11605
+ *
11606
+ * @param {string} type The type of model element to be created.
11607
+ * @param {Object} attrs Attributes to create the model element with.
11608
+ *
11609
+ * @return {Connection|Label|Root|Shape} The created model element.
11542
11610
  */
11543
11611
  function create(type, attrs) {
11544
11612
  var Type = types$7[type];
@@ -11549,36 +11617,78 @@
11549
11617
  }
11550
11618
 
11551
11619
  /**
11552
- * A factory for diagram-js shapes
11620
+ * @typedef {import('../model/index').Base} Base
11621
+ * @typedef {import('../model/index').Connection} Connection
11622
+ * @typedef {import('../model/index').Label} Label
11623
+ * @typedef {import('../model/index').Root} Root
11624
+ * @typedef {import('../model/index').Shape} Shape
11625
+ * @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
11626
+ * @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
11627
+ * @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
11628
+ * @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
11629
+ */
11630
+
11631
+ /**
11632
+ * A factory for model elements.
11633
+ *
11634
+ * @class
11635
+ * @constructor
11553
11636
  */
11554
11637
  function ElementFactory() {
11555
11638
  this._uid = 12;
11556
11639
  }
11557
11640
 
11558
-
11641
+ /**
11642
+ * Create a root element.
11643
+ *
11644
+ * @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
11645
+ *
11646
+ * @return {Root} The created root element.
11647
+ */
11559
11648
  ElementFactory.prototype.createRoot = function(attrs) {
11560
11649
  return this.create('root', attrs);
11561
11650
  };
11562
11651
 
11652
+ /**
11653
+ * Create a label.
11654
+ *
11655
+ * @param {ModelAttrsLabel} attrs The attributes of the label to be created.
11656
+ *
11657
+ * @return {Label} The created label.
11658
+ */
11563
11659
  ElementFactory.prototype.createLabel = function(attrs) {
11564
11660
  return this.create('label', attrs);
11565
11661
  };
11566
11662
 
11663
+ /**
11664
+ * Create a shape.
11665
+ *
11666
+ * @param {ModelAttrsShape} attrs The attributes of the shape to be created.
11667
+ *
11668
+ * @return {Shape} The created shape.
11669
+ */
11567
11670
  ElementFactory.prototype.createShape = function(attrs) {
11568
11671
  return this.create('shape', attrs);
11569
11672
  };
11570
11673
 
11674
+ /**
11675
+ * Create a connection.
11676
+ *
11677
+ * @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
11678
+ *
11679
+ * @return {Connection} The created connection.
11680
+ */
11571
11681
  ElementFactory.prototype.createConnection = function(attrs) {
11572
11682
  return this.create('connection', attrs);
11573
11683
  };
11574
11684
 
11575
11685
  /**
11576
- * Create a model element with the given type and
11577
- * a number of pre-set attributes.
11686
+ * Create a model element of the given type with the given attributes.
11578
11687
  *
11579
- * @param {string} type
11580
- * @param {Object} attrs
11581
- * @return {djs.model.Base} the newly created model instance
11688
+ * @param {string} type The type of the model element.
11689
+ * @param {Object} attrs The attributes of the model element.
11690
+ *
11691
+ * @return {Connection|Label|Root|Shape} The created model element.
11582
11692
  */
11583
11693
  ElementFactory.prototype.create = function(type, attrs) {
11584
11694
 
@@ -11597,6 +11707,16 @@
11597
11707
 
11598
11708
  var slice = Array.prototype.slice;
11599
11709
 
11710
+ /**
11711
+ * @typedef {import('./EventBus').Event} Event
11712
+ * @typedef {import('./EventBus').EventCallback} EventCallback
11713
+ *
11714
+ * @typedef {Object} EventListener
11715
+ * @property {Function} callback
11716
+ * @property {EventListener|null} next
11717
+ * @property {number} priority
11718
+ */
11719
+
11600
11720
  /**
11601
11721
  * A general purpose event bus.
11602
11722
  *
@@ -11701,10 +11821,10 @@
11701
11821
  *
11702
11822
  * Returning anything but `undefined` from a listener will stop the listener propagation.
11703
11823
  *
11704
- * @param {string|Array<string>} events
11705
- * @param {number} [priority=1000] the priority in which this listener is called, larger is higher
11706
- * @param {Function} callback
11707
- * @param {Object} [that] Pass context (`this`) to the callback
11824
+ * @param {string|string[]} events The event(s) to listen to.
11825
+ * @param {number} [priority=1000] The priority with which to listen.
11826
+ * @param {EventCallback} callback The callback.
11827
+ * @param {*} [that] Value of `this` the callback will be called with.
11708
11828
  */
11709
11829
  EventBus.prototype.on = function(events, priority, callback, that) {
11710
11830
 
@@ -11744,12 +11864,12 @@
11744
11864
 
11745
11865
 
11746
11866
  /**
11747
- * Register an event listener that is executed only once.
11867
+ * Register an event listener that is called only once.
11748
11868
  *
11749
- * @param {string} event the event name to register for
11750
- * @param {number} [priority=1000] the priority in which this listener is called, larger is higher
11751
- * @param {Function} callback the callback to execute
11752
- * @param {Object} [that] Pass context (`this`) to the callback
11869
+ * @param {string} event The event to listen to.
11870
+ * @param {number} [priority=1000] The priority with which to listen.
11871
+ * @param {EventCallback} callback The callback.
11872
+ * @param {*} [that] Value of `this` the callback will be called with.
11753
11873
  */
11754
11874
  EventBus.prototype.once = function(event, priority, callback, that) {
11755
11875
  var self = this;
@@ -11788,8 +11908,8 @@
11788
11908
  *
11789
11909
  * If no callback is given, all listeners for a given event name are being removed.
11790
11910
  *
11791
- * @param {string|Array<string>} events
11792
- * @param {Function} [callback]
11911
+ * @param {string|string[]} events The events.
11912
+ * @param {EventCallback} [callback] The callback.
11793
11913
  */
11794
11914
  EventBus.prototype.off = function(events, callback) {
11795
11915
 
@@ -11805,11 +11925,11 @@
11805
11925
 
11806
11926
 
11807
11927
  /**
11808
- * Create an EventBus event.
11928
+ * Create an event recognized be the event bus.
11809
11929
  *
11810
- * @param {Object} data
11930
+ * @param {Object} data Event data.
11811
11931
  *
11812
- * @return {Object} event, recognized by the eventBus
11932
+ * @return {Event} An event that will be recognized by the event bus.
11813
11933
  */
11814
11934
  EventBus.prototype.createEvent = function(data) {
11815
11935
  var event = new InternalEvent();
@@ -11821,7 +11941,7 @@
11821
11941
 
11822
11942
 
11823
11943
  /**
11824
- * Fires a named event.
11944
+ * Fires an event.
11825
11945
  *
11826
11946
  * @example
11827
11947
  *
@@ -11843,12 +11963,11 @@
11843
11963
  *
11844
11964
  * events.fire({ type: 'foo' }, 'I am bar!');
11845
11965
  *
11846
- * @param {string} [name] the optional event name
11847
- * @param {Object} [event] the event object
11848
- * @param {...Object} additional arguments to be passed to the callback functions
11966
+ * @param {string} [type] The event type.
11967
+ * @param {Object} [data] The event or event data.
11968
+ * @param {...*} additional Additional arguments the callback will be called with.
11849
11969
  *
11850
- * @return {boolean} the events return value, if specified or false if the
11851
- * default action was prevented by listeners
11970
+ * @return {*} The return value. Will be set to `false` if the default was prevented.
11852
11971
  */
11853
11972
  EventBus.prototype.fire = function(type, data) {
11854
11973
  var event,
@@ -11913,7 +12032,13 @@
11913
12032
  return returnValue;
11914
12033
  };
11915
12034
 
11916
-
12035
+ /**
12036
+ * Handle an error by firing an event.
12037
+ *
12038
+ * @param {Error} error The error to be handled.
12039
+ *
12040
+ * @return {boolean} Whether the error was handled.
12041
+ */
11917
12042
  EventBus.prototype.handleError = function(error) {
11918
12043
  return this.fire('error', { error: error }) === false;
11919
12044
  };
@@ -11976,7 +12101,7 @@
11976
12101
  return returnValue;
11977
12102
  };
11978
12103
 
11979
- /*
12104
+ /**
11980
12105
  * Add new listener with a certain priority to the list
11981
12106
  * of listeners (for the given event).
11982
12107
  *
@@ -11990,7 +12115,7 @@
11990
12115
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
11991
12116
  *
11992
12117
  * @param {string} event
11993
- * @param {Object} listener { priority, callback }
12118
+ * @param {EventListener} listener
11994
12119
  */
11995
12120
  EventBus.prototype._addListener = function(event, newListener) {
11996
12121
 
@@ -12096,9 +12221,9 @@
12096
12221
  * Invoke function. Be fast...
12097
12222
  *
12098
12223
  * @param {Function} fn
12099
- * @param {Array<Object>} args
12224
+ * @param {*[]} args
12100
12225
  *
12101
- * @return {Any}
12226
+ * @return {*}
12102
12227
  */
12103
12228
  function invokeFunction(fn, args) {
12104
12229
  return fn.apply(null, args);
@@ -12112,11 +12237,11 @@
12112
12237
  */
12113
12238
 
12114
12239
  /**
12115
- * Returns the visual part of a diagram element
12240
+ * Returns the visual part of a diagram element.
12116
12241
  *
12117
- * @param {Snap<SVGElement>} gfx
12242
+ * @param {SVGElement} gfx
12118
12243
  *
12119
- * @return {Snap<SVGElement>}
12244
+ * @return {SVGElement}
12120
12245
  */
12121
12246
  function getVisual(gfx) {
12122
12247
  return gfx.childNodes[0];
@@ -12125,15 +12250,28 @@
12125
12250
  /**
12126
12251
  * Returns the children for a given diagram element.
12127
12252
  *
12128
- * @param {Snap<SVGElement>} gfx
12129
- * @return {Snap<SVGElement>}
12253
+ * @param {SVGElement} gfx
12254
+ * @return {SVGElement}
12130
12255
  */
12131
12256
  function getChildren(gfx) {
12132
12257
  return gfx.parentNode.childNodes[1];
12133
12258
  }
12134
12259
 
12135
12260
  /**
12136
- * A factory that creates graphical elements
12261
+ * @typedef {import('../model').ModelType} ModelType
12262
+ * @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
12263
+ * @typedef {import('../model').ModelTypeShape} ModelTypeShape
12264
+ *
12265
+ * @typedef {import('.').ConnectionLike} ConnectionLike
12266
+ * @typedef {import('.').ElementLike} ElementLike
12267
+ * @typedef {import('.').ShapeLike} ShapeLike
12268
+ *
12269
+ * @typedef {import('./ElementRegistry').default} ElementRegistry
12270
+ * @typedef {import('./EventBus').default} EventBus
12271
+ */
12272
+
12273
+ /**
12274
+ * A factory that creates graphical elements.
12137
12275
  *
12138
12276
  * @param {EventBus} eventBus
12139
12277
  * @param {ElementRegistry} elementRegistry
@@ -12201,7 +12339,7 @@
12201
12339
  * </g>
12202
12340
  *
12203
12341
  * @param {string} type the type of the element, i.e. shape | connection
12204
- * @param {SVGElement} [childrenGfx]
12342
+ * @param {SVGElement} childrenGfx
12205
12343
  * @param {number} [parentIndex] position to create container in parent
12206
12344
  * @param {boolean} [isFrame] is frame element
12207
12345
  *
@@ -12239,11 +12377,25 @@
12239
12377
  return gfx;
12240
12378
  };
12241
12379
 
12380
+ /**
12381
+ * Create a graphical element.
12382
+ *
12383
+ * @param {ModelType} type The type of the element.
12384
+ * @param {ElementLike} element The element.
12385
+ * @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
12386
+ *
12387
+ * @return {SVGElement} The graphical element.
12388
+ */
12242
12389
  GraphicsFactory.prototype.create = function(type, element, parentIndex) {
12243
12390
  var childrenGfx = this._getChildrenContainer(element.parent);
12244
12391
  return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
12245
12392
  };
12246
12393
 
12394
+ /**
12395
+ * Update the containments of the given elements.
12396
+ *
12397
+ * @param {ElementLike[]} elements The elements.
12398
+ */
12247
12399
  GraphicsFactory.prototype.updateContainments = function(elements) {
12248
12400
 
12249
12401
  var self = this,
@@ -12279,30 +12431,63 @@
12279
12431
  });
12280
12432
  };
12281
12433
 
12434
+ /**
12435
+ * Draw a shape.
12436
+ *
12437
+ * @param {SVGElement} visual The graphical element.
12438
+ * @param {ShapeLike} element The shape.
12439
+ */
12282
12440
  GraphicsFactory.prototype.drawShape = function(visual, element) {
12283
12441
  var eventBus = this._eventBus;
12284
12442
 
12285
12443
  return eventBus.fire('render.shape', { gfx: visual, element: element });
12286
12444
  };
12287
12445
 
12446
+ /**
12447
+ * Get the path of a shape.
12448
+ *
12449
+ * @param {ShapeLike} element The shape.
12450
+ *
12451
+ * @return {string} The path of the shape.
12452
+ */
12288
12453
  GraphicsFactory.prototype.getShapePath = function(element) {
12289
12454
  var eventBus = this._eventBus;
12290
12455
 
12291
12456
  return eventBus.fire('render.getShapePath', element);
12292
12457
  };
12293
12458
 
12459
+ /**
12460
+ * Draw a connection.
12461
+ *
12462
+ * @param {SVGElement} visual The graphical element.
12463
+ * @param {ConnectionLike} element The connection.
12464
+ */
12294
12465
  GraphicsFactory.prototype.drawConnection = function(visual, element) {
12295
12466
  var eventBus = this._eventBus;
12296
12467
 
12297
12468
  return eventBus.fire('render.connection', { gfx: visual, element: element });
12298
12469
  };
12299
12470
 
12300
- GraphicsFactory.prototype.getConnectionPath = function(waypoints) {
12471
+ /**
12472
+ * Get the path of a connection.
12473
+ *
12474
+ * @param {ConnectionLike} element The connection.
12475
+ *
12476
+ * @return {string} The path of the connection.
12477
+ */
12478
+ GraphicsFactory.prototype.getConnectionPath = function(connection) {
12301
12479
  var eventBus = this._eventBus;
12302
12480
 
12303
- return eventBus.fire('render.getConnectionPath', waypoints);
12481
+ return eventBus.fire('render.getConnectionPath', connection);
12304
12482
  };
12305
12483
 
12484
+ /**
12485
+ * Update an elements graphical representation.
12486
+ *
12487
+ * @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
12488
+ * @param {ElementLike} element The element.
12489
+ * @param {SVGElement} gfx The graphical representation.
12490
+ */
12306
12491
  GraphicsFactory.prototype.update = function(type, element, gfx) {
12307
12492
 
12308
12493
  // do NOT update root element
@@ -12332,6 +12517,11 @@
12332
12517
  }
12333
12518
  };
12334
12519
 
12520
+ /**
12521
+ * Remove a graphical element.
12522
+ *
12523
+ * @param {ElementLike} element The element.
12524
+ */
12335
12525
  GraphicsFactory.prototype.remove = function(element) {
12336
12526
  var gfx = this._elementRegistry.getGraphics(element);
12337
12527
 
@@ -12365,13 +12555,17 @@
12365
12555
  };
12366
12556
 
12367
12557
  /**
12368
- * @typedef { import('didi').ModuleDeclaration } Module
12558
+ * @typedef {import('didi').InjectionContext} InjectionContext
12559
+ * @typedef {import('didi').LocalsMap} LocalsMap
12560
+ * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
12561
+ *
12562
+ * @typedef {import('./Diagram').DiagramOptions} DiagramOptions
12369
12563
  */
12370
12564
 
12371
12565
  /**
12372
12566
  * Bootstrap an injector from a list of modules, instantiating a number of default components
12373
12567
  *
12374
- * @param {Array<Module>} modules
12568
+ * @param {ModuleDeclaration[]} modules
12375
12569
  *
12376
12570
  * @return {Injector} a injector to use to access the components
12377
12571
  */
@@ -12386,7 +12580,8 @@
12386
12580
  /**
12387
12581
  * Creates an injector from passed options.
12388
12582
  *
12389
- * @param {Object} options
12583
+ * @param {DiagramOptions} [options]
12584
+ *
12390
12585
  * @return {Injector}
12391
12586
  */
12392
12587
  function createInjector(options) {
@@ -12409,8 +12604,7 @@
12409
12604
  *
12410
12605
  * To register extensions with the diagram, pass them as Array<Module> to the constructor.
12411
12606
  *
12412
- * @class djs.Diagram
12413
- * @memberOf djs
12607
+ * @class
12414
12608
  * @constructor
12415
12609
  *
12416
12610
  * @example
@@ -12448,9 +12642,9 @@
12448
12642
  *
12449
12643
  * // 'shape ... was added to the diagram' logged to console
12450
12644
  *
12451
- * @param {Object} options
12452
- * @param {Array<Module>} [options.modules] external modules to instantiate with the diagram
12453
- * @param {Injector} [injector] an (optional) injector to bootstrap the diagram with
12645
+ * @param {DiagramOptions} [options]
12646
+ * @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
12647
+ * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
12454
12648
  */
12455
12649
  function Diagram(options, injector) {
12456
12650
 
@@ -12460,22 +12654,23 @@
12460
12654
  // API
12461
12655
 
12462
12656
  /**
12463
- * Resolves a diagram service
12657
+ * Resolves a diagram service.
12464
12658
  *
12465
12659
  * @method Diagram#get
12466
12660
  *
12467
- * @param {string} name the name of the diagram service to be retrieved
12468
- * @param {boolean} [strict=true] if false, resolve missing services to null
12661
+ * @param {string} name The name of the service to get.
12662
+ * @param {boolean} [strict=true] If false, resolve missing services to null.
12469
12663
  */
12470
12664
  this.get = injector.get;
12471
12665
 
12472
12666
  /**
12473
- * Executes a function into which diagram services are injected
12667
+ * Executes a function with its dependencies injected.
12474
12668
  *
12475
12669
  * @method Diagram#invoke
12476
12670
  *
12477
- * @param {Function|Object[]} fn the function to resolve
12478
- * @param {Object} locals a number of locals to use to resolve certain dependencies
12671
+ * @param {Function} fn The function to be executed.
12672
+ * @param {InjectionContext} [context] The context.
12673
+ * @param {LocalsMap} [locals] The locals.
12479
12674
  */
12480
12675
  this.invoke = injector.invoke;
12481
12676
 
@@ -21662,10 +21857,10 @@
21662
21857
  // default moddle extensions the viewer is composed of
21663
21858
  Viewer.prototype._moddleExtensions = {};
21664
21859
 
21665
- var KEYS_COPY = [ 'c', 'C', 'KeyC' ];
21666
- var KEYS_PASTE = [ 'v', 'V', 'KeyV' ];
21667
- var KEYS_REDO = [ 'y', 'Y', 'KeyY' ];
21668
- var KEYS_UNDO = [ 'z', 'Z', 'KeyZ' ];
21860
+ var KEYS_COPY = [ 'c', 'C' ];
21861
+ var KEYS_PASTE = [ 'v', 'V' ];
21862
+ var KEYS_REDO = [ 'y', 'Y' ];
21863
+ var KEYS_UNDO = [ 'z', 'Z' ];
21669
21864
 
21670
21865
  /**
21671
21866
  * Returns true if event was triggered with any modifier
@@ -21728,6 +21923,10 @@
21728
21923
  );
21729
21924
  }
21730
21925
 
21926
+ /**
21927
+ * @typedef {import('../../core/EventBus').default} EventBus
21928
+ */
21929
+
21731
21930
  var KEYDOWN_EVENT = 'keyboard.keydown',
21732
21931
  KEYUP_EVENT = 'keyboard.keyup';
21733
21932
 
@@ -21756,7 +21955,7 @@
21756
21955
  * A default binding for the keyboard may be specified via the
21757
21956
  * `keyboard.bindTo` configuration option.
21758
21957
  *
21759
- * @param {Config} config
21958
+ * @param {Object} config
21760
21959
  * @param {EventBus} eventBus
21761
21960
  */
21762
21961
  function Keyboard(config, eventBus) {
@@ -22087,6 +22286,11 @@
22087
22286
  keyboardBindings: [ 'type', KeyboardBindings ]
22088
22287
  };
22089
22288
 
22289
+ /**
22290
+ * @typedef {import('../../core/Canvas').default} Canvas
22291
+ * @typedef {import('../../features/keyboard/Keyboard').default} Keyboard
22292
+ */
22293
+
22090
22294
  var DEFAULT_CONFIG = {
22091
22295
  moveSpeed: 50,
22092
22296
  moveSpeedAccelerated: 200
@@ -22259,6 +22463,11 @@
22259
22463
  };
22260
22464
  }
22261
22465
 
22466
+ /**
22467
+ * @typedef {import('../../core/Canvas').default} Canvas
22468
+ * @typedef {import('../../core/EventBus').default} EventBus
22469
+ */
22470
+
22262
22471
  var THRESHOLD = 15;
22263
22472
 
22264
22473
 
@@ -22378,8 +22587,9 @@
22378
22587
  };
22379
22588
 
22380
22589
  /**
22381
- * Get the logarithm of x with base 10
22382
- * @param {Integer} value
22590
+ * Get the logarithm of x with base 10.
22591
+ *
22592
+ * @param {number} x
22383
22593
  */
22384
22594
  function log10(x) {
22385
22595
  return Math.log(x) / Math.log(10);
@@ -22406,6 +22616,11 @@
22406
22616
  return Math.max(range.min, Math.min(range.max, scale));
22407
22617
  }
22408
22618
 
22619
+ /**
22620
+ * @typedef {import('../../core/Canvas').default} Canvas
22621
+ * @typedef {import('../../core/EventBus').default} EventBus
22622
+ */
22623
+
22409
22624
  var sign = Math.sign || function(n) {
22410
22625
  return n >= 0 ? 1 : -1;
22411
22626
  };
@@ -22596,7 +22811,7 @@
22596
22811
  /**
22597
22812
  * Toggle the zoom scroll ability via mouse wheel.
22598
22813
  *
22599
- * @param {boolean} [newEnabled] new enabled state
22814
+ * @param {boolean} [newEnabled] new enabled state
22600
22815
  */
22601
22816
  ZoomScroll.prototype.toggle = function toggle(newEnabled) {
22602
22817