camunda-bpmn-js 1.4.0 → 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.
@@ -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
@@ -4236,6 +4249,10 @@
4236
4249
  return getRectPath(element);
4237
4250
  };
4238
4251
 
4252
+ /**
4253
+ * @typedef {import('../util/Types').Dimensions} Dimensions
4254
+ */
4255
+
4239
4256
  var DEFAULT_BOX_PADDING = 0;
4240
4257
 
4241
4258
  var DEFAULT_LABEL_SIZE$1 = {
@@ -4309,7 +4326,8 @@
4309
4326
  *
4310
4327
  * Alters the lines passed.
4311
4328
  *
4312
- * @param {Array<string>} lines
4329
+ * @param {string[]} lines
4330
+ *
4313
4331
  * @return {Object} the line descriptor, an object { width, height, text }
4314
4332
  */
4315
4333
  function layoutNext(lines, maxWidth, fakeText) {
@@ -4354,8 +4372,9 @@
4354
4372
  * Shortens a line based on spacing and hyphens.
4355
4373
  * Returns the shortened result on success.
4356
4374
  *
4357
- * @param {string} line
4358
- * @param {number} maxLength the maximum characters of the string
4375
+ * @param {string} line
4376
+ * @param {number} maxLength the maximum characters of the string
4377
+ *
4359
4378
  * @return {string} the shortened string
4360
4379
  */
4361
4380
  function semanticShorten(line, maxLength) {
@@ -5195,6 +5214,10 @@
5195
5214
  pathMap: [ 'type', PathMap ]
5196
5215
  };
5197
5216
 
5217
+ /**
5218
+ * @typedef {import('./').Replacements} Replacements
5219
+ */
5220
+
5198
5221
  /**
5199
5222
  * A simple translation stub to be used for multi-language support
5200
5223
  * in diagrams. Can be easily replaced with a more sophisticated
@@ -5209,7 +5232,7 @@
5209
5232
  * }
5210
5233
  *
5211
5234
  * @param {string} template to interpolate
5212
- * @param {Object} [replacements] a map with substitutes
5235
+ * @param {Replacements} [replacements] a map with substitutes
5213
5236
  *
5214
5237
  * @return {string} the translated string
5215
5238
  */
@@ -5362,8 +5385,6 @@
5362
5385
  }, size);
5363
5386
  }
5364
5387
 
5365
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5366
-
5367
5388
  function getDefaultExportFromCjs (x) {
5368
5389
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5369
5390
  }
@@ -5380,9 +5401,9 @@
5380
5401
  /**
5381
5402
  * Convert the given bounds to a { top, left, bottom, right } descriptor.
5382
5403
  *
5383
- * @param {Bounds|Point} bounds
5404
+ * @param {Point|Rect} bounds
5384
5405
  *
5385
- * @return {Object}
5406
+ * @return {RectTRBL}
5386
5407
  */
5387
5408
  function asTRBL(bounds) {
5388
5409
  return {
@@ -5397,9 +5418,9 @@
5397
5418
  /**
5398
5419
  * Convert a { top, left, bottom, right } to an objects bounds.
5399
5420
  *
5400
- * @param {Object} trbl
5421
+ * @param {RectTRBL} trbl
5401
5422
  *
5402
- * @return {Bounds}
5423
+ * @return {Rect}
5403
5424
  */
5404
5425
  function asBounds(trbl) {
5405
5426
  return {
@@ -5414,7 +5435,7 @@
5414
5435
  /**
5415
5436
  * Get the mid of the given bounds or point.
5416
5437
  *
5417
- * @param {Bounds|Point} bounds
5438
+ * @param {Point|Rect} bounds
5418
5439
  *
5419
5440
  * @return {Point}
5420
5441
  */
@@ -5429,7 +5450,7 @@
5429
5450
  /**
5430
5451
  * Get the mid of the given Connection.
5431
5452
  *
5432
- * @param {djs.Base.Connection} connection
5453
+ * @param {Connection} connection
5433
5454
  *
5434
5455
  * @return {Point}
5435
5456
  */
@@ -5488,7 +5509,7 @@
5488
5509
  /**
5489
5510
  * Get the mid of the given Element.
5490
5511
  *
5491
- * @param {djs.Base.Connection} connection
5512
+ * @param {Connection} connection
5492
5513
  *
5493
5514
  * @return {Point}
5494
5515
  */
@@ -5915,6 +5936,14 @@
5915
5936
  return isPrimaryButton(event) && originalEvent.shiftKey;
5916
5937
  }
5917
5938
 
5939
+ /**
5940
+ * @typedef {import('../../model').Base} Base
5941
+ *
5942
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
5943
+ * @typedef {import('../../core/EventBus').default} EventBus
5944
+ * @typedef {import('../../draw/Styles').default} Styles
5945
+ */
5946
+
5918
5947
  function allowAll(event) { return true; }
5919
5948
 
5920
5949
  function allowPrimaryAndAuxiliary(event) {
@@ -5944,6 +5973,8 @@
5944
5973
  * prevents the original DOM operation.
5945
5974
  *
5946
5975
  * @param {EventBus} eventBus
5976
+ * @param {ElementRegistry} elementRegistry
5977
+ * @param {Styles} styles
5947
5978
  */
5948
5979
  function InteractionEvents(eventBus, elementRegistry, styles) {
5949
5980
 
@@ -5953,8 +5984,8 @@
5953
5984
  * Fire an interaction event.
5954
5985
  *
5955
5986
  * @param {string} type local event name, e.g. element.click.
5956
- * @param {DOMEvent} event native event
5957
- * @param {djs.model.Base} [element] the diagram element to emit the event on;
5987
+ * @param {MouseEvent|TouchEvent} event native event
5988
+ * @param {Base} [element] the diagram element to emit the event on;
5958
5989
  * defaults to the event target
5959
5990
  */
5960
5991
  function fire(type, event, element) {
@@ -6036,8 +6067,8 @@
6036
6067
  * on the target shape or connection.
6037
6068
  *
6038
6069
  * @param {string} eventName the name of the triggered DOM event
6039
- * @param {MouseEvent} event
6040
- * @param {djs.model.Base} targetElement
6070
+ * @param {MouseEvent|TouchEvent} event
6071
+ * @param {Base} targetElement
6041
6072
  */
6042
6073
  function triggerMouseEvent(eventName, event, targetElement) {
6043
6074
 
@@ -6203,7 +6234,7 @@
6203
6234
  /**
6204
6235
  * Create default hit for the given element.
6205
6236
  *
6206
- * @param {djs.model.Base} element
6237
+ * @param {Base} element
6207
6238
  * @param {SVGElement} gfx
6208
6239
  *
6209
6240
  * @return {SVGElement} created hit
@@ -6275,8 +6306,8 @@
6275
6306
  /**
6276
6307
  * Update default hit of the element.
6277
6308
  *
6278
- * @param {djs.model.Base} element
6279
- * @param {SVGElement} gfx
6309
+ * @param {Base} element
6310
+ * @param {SVGElement} gfx
6280
6311
  *
6281
6312
  * @return {SVGElement} updated hit
6282
6313
  */
@@ -6324,7 +6355,7 @@
6324
6355
  * @event element.hover
6325
6356
  *
6326
6357
  * @type {Object}
6327
- * @property {djs.model.Base} element
6358
+ * @property {Base} element
6328
6359
  * @property {SVGElement} gfx
6329
6360
  * @property {Event} originalEvent
6330
6361
  */
@@ -6335,7 +6366,7 @@
6335
6366
  * @event element.out
6336
6367
  *
6337
6368
  * @type {Object}
6338
- * @property {djs.model.Base} element
6369
+ * @property {Base} element
6339
6370
  * @property {SVGElement} gfx
6340
6371
  * @property {Event} originalEvent
6341
6372
  */
@@ -6346,7 +6377,7 @@
6346
6377
  * @event element.click
6347
6378
  *
6348
6379
  * @type {Object}
6349
- * @property {djs.model.Base} element
6380
+ * @property {Base} element
6350
6381
  * @property {SVGElement} gfx
6351
6382
  * @property {Event} originalEvent
6352
6383
  */
@@ -6357,7 +6388,7 @@
6357
6388
  * @event element.dblclick
6358
6389
  *
6359
6390
  * @type {Object}
6360
- * @property {djs.model.Base} element
6391
+ * @property {Base} element
6361
6392
  * @property {SVGElement} gfx
6362
6393
  * @property {Event} originalEvent
6363
6394
  */
@@ -6368,7 +6399,7 @@
6368
6399
  * @event element.mousedown
6369
6400
  *
6370
6401
  * @type {Object}
6371
- * @property {djs.model.Base} element
6402
+ * @property {Base} element
6372
6403
  * @property {SVGElement} gfx
6373
6404
  * @property {Event} originalEvent
6374
6405
  */
@@ -6379,7 +6410,7 @@
6379
6410
  * @event element.mouseup
6380
6411
  *
6381
6412
  * @type {Object}
6382
- * @property {djs.model.Base} element
6413
+ * @property {Base} element
6383
6414
  * @property {SVGElement} gfx
6384
6415
  * @property {Event} originalEvent
6385
6416
  */
@@ -6391,7 +6422,7 @@
6391
6422
  * @event element.contextmenu
6392
6423
  *
6393
6424
  * @type {Object}
6394
- * @property {djs.model.Base} element
6425
+ * @property {Base} element
6395
6426
  * @property {SVGElement} gfx
6396
6427
  * @property {Event} originalEvent
6397
6428
  */
@@ -6405,10 +6436,10 @@
6405
6436
  * Returns the surrounding bbox for all elements in
6406
6437
  * the array or the element primitive.
6407
6438
  *
6408
- * @param {Array<djs.model.Shape>|djs.model.Shape} elements
6439
+ * @param {Base|Base[]} elements
6409
6440
  * @param {boolean} [stopRecursion=false]
6410
6441
  *
6411
- * @return {Bounds}
6442
+ * @return {Rect}
6412
6443
  */
6413
6444
  function getBBox(elements, stopRecursion) {
6414
6445
 
@@ -6479,6 +6510,12 @@
6479
6510
 
6480
6511
  var LOW_PRIORITY$3 = 500;
6481
6512
 
6513
+ /**
6514
+ * @typedef {import('../../model').Base} Base
6515
+ *
6516
+ * @typedef {import('../../core/EventBus').default} EventBus
6517
+ * @typedef {import('../../draw/Styles').default} Styles
6518
+ */
6482
6519
 
6483
6520
  /**
6484
6521
  * @class
@@ -6488,9 +6525,8 @@
6488
6525
  *
6489
6526
  * @param {EventBus} eventBus
6490
6527
  * @param {Styles} styles
6491
- * @param {ElementRegistry} elementRegistry
6492
6528
  */
6493
- function Outline(eventBus, styles, elementRegistry) {
6529
+ function Outline(eventBus, styles) {
6494
6530
 
6495
6531
  this.offset = 6;
6496
6532
 
@@ -6548,8 +6584,8 @@
6548
6584
  * Updates the outline of a shape respecting the dimension of the
6549
6585
  * element and an outline offset.
6550
6586
  *
6551
- * @param {SVGElement} outline
6552
- * @param {djs.model.Base} element
6587
+ * @param {SVGElement} outline
6588
+ * @param {Base} element
6553
6589
  */
6554
6590
  Outline.prototype.updateShapeOutline = function(outline, element) {
6555
6591
 
@@ -6567,8 +6603,8 @@
6567
6603
  * Updates the outline of a connection respecting the bounding box of
6568
6604
  * the connection and an outline offset.
6569
6605
  *
6570
- * @param {SVGElement} outline
6571
- * @param {djs.model.Base} element
6606
+ * @param {SVGElement} outline
6607
+ * @param {Base} element
6572
6608
  */
6573
6609
  Outline.prototype.updateConnectionOutline = function(outline, connection) {
6574
6610
 
@@ -6591,13 +6627,17 @@
6591
6627
  outline: [ 'type', Outline ]
6592
6628
  };
6593
6629
 
6630
+ /**
6631
+ * @typedef {import('../../core/EventBus').default} EventBus
6632
+ */
6633
+
6594
6634
  /**
6595
6635
  * A service that offers the current selection in a diagram.
6596
6636
  * Offers the api to control the selection, too.
6597
6637
  *
6598
6638
  * @class
6599
6639
  *
6600
- * @param {EventBus} eventBus the event bus
6640
+ * @param {EventBus} eventBus
6601
6641
  */
6602
6642
  function Selection(eventBus, canvas) {
6603
6643
 
@@ -6653,8 +6693,8 @@
6653
6693
  *
6654
6694
  * @method Selection#select
6655
6695
  *
6656
- * @param {Object|Object[]} elements element or array of elements to be selected
6657
- * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
6696
+ * @param {Object|Object[]} elements element or array of elements to be selected
6697
+ * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
6658
6698
  */
6659
6699
  Selection.prototype.select = function(elements, add) {
6660
6700
  var selectedElements = this._selectedElements,
@@ -6693,6 +6733,12 @@
6693
6733
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
6694
6734
  };
6695
6735
 
6736
+ /**
6737
+ * @typedef {import('../../core/Canvas').default} Canvas
6738
+ * @typedef {import('../../core/EventBus').default} EventBus
6739
+ * @typedef {import('./Selection').default} Selection
6740
+ */
6741
+
6696
6742
  var MARKER_HOVER = 'hover',
6697
6743
  MARKER_SELECTED = 'selected';
6698
6744
 
@@ -6709,6 +6755,7 @@
6709
6755
  *
6710
6756
  * @param {Canvas} canvas
6711
6757
  * @param {EventBus} eventBus
6758
+ * @param {Selection} selection
6712
6759
  */
6713
6760
  function SelectionVisuals(canvas, eventBus, selection) {
6714
6761
  this._canvas = canvas;
@@ -6814,6 +6861,19 @@
6814
6861
  };
6815
6862
  }
6816
6863
 
6864
+ /**
6865
+ * @typedef {import('../../core/Canvas').default} Canvas
6866
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
6867
+ * @typedef {import('../../core/EventBus').default} EventBus
6868
+ * @typedef {import('./Selection').default} Selection
6869
+ */
6870
+
6871
+ /**
6872
+ * @param {EventBus} eventBus
6873
+ * @param {Selection} selection
6874
+ * @param {Canvas} canvas
6875
+ * @param {ElementRegistry} elementRegistry
6876
+ */
6817
6877
  function SelectionBehavior(eventBus, selection, canvas, elementRegistry) {
6818
6878
 
6819
6879
  // Select elements on create
@@ -6934,9 +6994,8 @@
6934
6994
  /**
6935
6995
  * Util that provides unique IDs.
6936
6996
  *
6937
- * @class djs.util.IdGenerator
6997
+ * @class
6938
6998
  * @constructor
6939
- * @memberOf djs.util
6940
6999
  *
6941
7000
  * The ids can be customized via a given prefix and contain a random value to avoid collisions.
6942
7001
  *
@@ -6951,8 +7010,6 @@
6951
7010
  /**
6952
7011
  * Returns a next unique ID.
6953
7012
  *
6954
- * @method djs.util.IdGenerator#next
6955
- *
6956
7013
  * @returns {string} the id
6957
7014
  */
6958
7015
  IdGenerator.prototype.next = function() {
@@ -6964,6 +7021,18 @@
6964
7021
 
6965
7022
  var LOW_PRIORITY$2 = 500;
6966
7023
 
7024
+ /**
7025
+ * @typedef {import('../../core/Canvas').default} Canvas
7026
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7027
+ * @typedef {import('../../core/EventBus').default} EventBus
7028
+ *
7029
+ * @typedef {import('./Overlays').Overlay} Overlay
7030
+ * @typedef {import('./Overlays').OverlayAttrs} OverlayAttrs
7031
+ * @typedef {import('./Overlays').OverlayContainer} OverlayContainer
7032
+ * @typedef {import('./Overlays').OverlaysConfig} OverlaysConfig
7033
+ * @typedef {import('./Overlays').OverlaysConfigDefault} OverlaysConfigDefault
7034
+ * @typedef {import('./Overlays').OverlaysFilter} OverlaysFilter
7035
+ */
6967
7036
 
6968
7037
  /**
6969
7038
  * A service that allows users to attach overlays to diagram elements.
@@ -6973,6 +7042,7 @@
6973
7042
  * @example
6974
7043
  *
6975
7044
  * // add a pink badge on the top left of the shape
7045
+ *
6976
7046
  * overlays.add(someShape, {
6977
7047
  * position: {
6978
7048
  * top: -5,
@@ -7024,19 +7094,21 @@
7024
7094
  * }
7025
7095
  * }
7026
7096
  *
7027
- * @param {Object} config
7097
+ * @param {OverlaysConfig} config
7028
7098
  * @param {EventBus} eventBus
7029
7099
  * @param {Canvas} canvas
7030
7100
  * @param {ElementRegistry} elementRegistry
7031
7101
  */
7032
7102
  function Overlays(config, eventBus, canvas, elementRegistry) {
7033
-
7034
7103
  this._eventBus = eventBus;
7035
7104
  this._canvas = canvas;
7036
7105
  this._elementRegistry = elementRegistry;
7037
7106
 
7038
7107
  this._ids = ids;
7039
7108
 
7109
+ /**
7110
+ * @type {OverlaysConfigDefault}
7111
+ */
7040
7112
  this._overlayDefaults = assign$1({
7041
7113
 
7042
7114
  // no show constraints
@@ -7047,16 +7119,18 @@
7047
7119
  }, config && config.defaults);
7048
7120
 
7049
7121
  /**
7050
- * Mapping overlayId -> overlay
7122
+ * @type {Map<string, Overlay>}
7051
7123
  */
7052
7124
  this._overlays = {};
7053
7125
 
7054
7126
  /**
7055
- * Mapping elementId -> overlay container
7127
+ * @type {OverlayContainer[]}
7056
7128
  */
7057
7129
  this._overlayContainers = [];
7058
7130
 
7059
- // root html element for all overlays
7131
+ /**
7132
+ * @type {HTMLElement}
7133
+ */
7060
7134
  this._overlayRoot = createRoot(canvas.getContainer());
7061
7135
 
7062
7136
  this._init();
@@ -7072,12 +7146,12 @@
7072
7146
 
7073
7147
 
7074
7148
  /**
7075
- * Returns the overlay with the specified id or a list of overlays
7149
+ * Returns the overlay with the specified ID or a list of overlays
7076
7150
  * for an element with a given type.
7077
7151
  *
7078
7152
  * @example
7079
7153
  *
7080
- * // return the single overlay with the given id
7154
+ * // return the single overlay with the given ID
7081
7155
  * overlays.get('some-id');
7082
7156
  *
7083
7157
  * // return all overlays for the shape
@@ -7086,16 +7160,12 @@
7086
7160
  * // return all overlays on shape with type 'badge'
7087
7161
  * overlays.get({ element: someShape, type: 'badge' });
7088
7162
  *
7089
- * // shape can also be specified as id
7163
+ * // shape can also be specified as ID
7090
7164
  * overlays.get({ element: 'element-id', type: 'badge' });
7091
7165
  *
7166
+ * @param {OverlaysFilter} search The filter to be used to find the overlay(s).
7092
7167
  *
7093
- * @param {Object} search
7094
- * @param {string} [search.id]
7095
- * @param {string|djs.model.Base} [search.element]
7096
- * @param {string} [search.type]
7097
- *
7098
- * @return {Object|Array<Object>} the overlay(s)
7168
+ * @return {Overlay|Overlay[]} The overlay(s).
7099
7169
  */
7100
7170
  Overlays.prototype.get = function(search) {
7101
7171
 
@@ -7127,27 +7197,13 @@
7127
7197
  };
7128
7198
 
7129
7199
  /**
7130
- * Adds a HTML overlay to an element.
7200
+ * Adds an HTML overlay to an element.
7131
7201
  *
7132
- * @param {string|djs.model.Base} element attach overlay to this shape
7133
- * @param {string} [type] optional type to assign to the overlay
7134
- * @param {Object} overlay the overlay configuration
7202
+ * @param {Base|string} element The element to add the overlay to.
7203
+ * @param {string} [type] An optional type that can be used to filter.
7204
+ * @param {OverlayAttrs} overlay The overlay.
7135
7205
  *
7136
- * @param {string|DOMElement} overlay.html html element to use as an overlay
7137
- * @param {Object} [overlay.show] show configuration
7138
- * @param {number} [overlay.show.minZoom] minimal zoom level to show the overlay
7139
- * @param {number} [overlay.show.maxZoom] maximum zoom level to show the overlay
7140
- * @param {Object} overlay.position where to attach the overlay
7141
- * @param {number} [overlay.position.left] relative to element bbox left attachment
7142
- * @param {number} [overlay.position.top] relative to element bbox top attachment
7143
- * @param {number} [overlay.position.bottom] relative to element bbox bottom attachment
7144
- * @param {number} [overlay.position.right] relative to element bbox right attachment
7145
- * @param {boolean|Object} [overlay.scale=true] false to preserve the same size regardless of
7146
- * diagram zoom
7147
- * @param {number} [overlay.scale.min]
7148
- * @param {number} [overlay.scale.max]
7149
- *
7150
- * @return {string} id that may be used to reference the overlay for update or removal
7206
+ * @return {string} The overlay's ID that can be used to get or remove it.
7151
7207
  */
7152
7208
  Overlays.prototype.add = function(element, type, overlay) {
7153
7209
 
@@ -7188,11 +7244,11 @@
7188
7244
 
7189
7245
 
7190
7246
  /**
7191
- * Remove an overlay with the given id or all overlays matching the given filter.
7247
+ * Remove an overlay with the given ID or all overlays matching the given filter.
7192
7248
  *
7193
7249
  * @see Overlays#get for filter options.
7194
7250
  *
7195
- * @param {string|object} [filter]
7251
+ * @param {OverlaysFilter} filter The filter to be used to find the overlay.
7196
7252
  */
7197
7253
  Overlays.prototype.remove = function(filter) {
7198
7254
 
@@ -7228,19 +7284,32 @@
7228
7284
 
7229
7285
  };
7230
7286
 
7287
+ /**
7288
+ * Checks whether overlays are shown.
7289
+ *
7290
+ * @returns {boolean} Whether overlays are shown.
7291
+ */
7231
7292
  Overlays.prototype.isShown = function() {
7232
7293
  return this._overlayRoot.style.display !== 'none';
7233
7294
  };
7234
7295
 
7296
+ /**
7297
+ * Show all overlays.
7298
+ */
7235
7299
  Overlays.prototype.show = function() {
7236
7300
  setVisible(this._overlayRoot);
7237
7301
  };
7238
7302
 
7239
-
7303
+ /**
7304
+ * Hide all overlays.
7305
+ */
7240
7306
  Overlays.prototype.hide = function() {
7241
7307
  setVisible(this._overlayRoot, false);
7242
7308
  };
7243
7309
 
7310
+ /**
7311
+ * Remove all overlays and their container.
7312
+ */
7244
7313
  Overlays.prototype.clear = function() {
7245
7314
  this._overlays = {};
7246
7315
 
@@ -7616,6 +7685,13 @@
7616
7685
  overlays: [ 'type', Overlays ]
7617
7686
  };
7618
7687
 
7688
+ /**
7689
+ * @typedef {import('../../core/Canvas').default} Canvas
7690
+ * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
7691
+ * @typedef {import('../../core/EventBus').default} EventBus
7692
+ * @typedef {import('../../core/GraphicsFactory').default} GraphicsFactory
7693
+ */
7694
+
7619
7695
  /**
7620
7696
  * Adds change support to the diagram, including
7621
7697
  *
@@ -7685,32 +7761,41 @@
7685
7761
  changeSupport: [ 'type', ChangeSupport ]
7686
7762
  };
7687
7763
 
7764
+ /**
7765
+ * @typedef {import('../core/EventBus').default} EventBus
7766
+ * @typedef {import(./CommandInterceptor).HandlerFunction} HandlerFunction
7767
+ * @typedef {import(./CommandInterceptor).ComposeHandlerFunction} ComposeHandlerFunction
7768
+ */
7769
+
7688
7770
  var DEFAULT_PRIORITY$2 = 1000;
7689
7771
 
7690
7772
  /**
7691
- * A utility that can be used to plug-in into the command execution for
7773
+ * A utility that can be used to plug into the command execution for
7692
7774
  * extension and/or validation.
7693
7775
  *
7776
+ * @class
7777
+ * @constructor
7778
+ *
7694
7779
  * @param {EventBus} eventBus
7695
7780
  *
7696
7781
  * @example
7697
7782
  *
7698
- * import inherits from 'inherits-browser';
7699
- *
7700
7783
  * import CommandInterceptor from 'diagram-js/lib/command/CommandInterceptor';
7701
7784
  *
7702
- * function CommandLogger(eventBus) {
7703
- * CommandInterceptor.call(this, eventBus);
7785
+ * class CommandLogger extends CommandInterceptor {
7786
+ * constructor(eventBus) {
7787
+ * super(eventBus);
7704
7788
  *
7705
- * this.preExecute(function(event) {
7706
- * console.log('command pre-execute', event);
7789
+ * this.preExecute('shape.create', (event) => {
7790
+ * console.log('commandStack.shape-create.preExecute', event);
7707
7791
  * });
7708
7792
  * }
7709
- *
7710
- * inherits(CommandLogger, CommandInterceptor);
7711
- *
7712
7793
  */
7713
7794
  function CommandInterceptor(eventBus) {
7795
+
7796
+ /**
7797
+ * @type {EventBus}
7798
+ */
7714
7799
  this._eventBus = eventBus;
7715
7800
  }
7716
7801
 
@@ -7723,16 +7808,15 @@
7723
7808
  }
7724
7809
 
7725
7810
  /**
7726
- * Register an interceptor for a command execution
7727
- *
7728
- * @param {string|Array<string>} [events] list of commands to register on
7729
- * @param {string} [hook] command hook, i.e. preExecute, executed to listen on
7730
- * @param {number} [priority] the priority on which to hook into the execution
7731
- * @param {Function} handlerFn interceptor to be invoked with (event)
7732
- * @param {boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
7733
- * listener instead
7734
- * @param {Object} [that] Pass context (`this`) to the handler function
7735
- */
7811
+ * Intercept a command during one of the phases.
7812
+ *
7813
+ * @param {string|string[]} [events] One or more commands to intercept.
7814
+ * @param {string} [hook] Phase during which to intercept command.
7815
+ * @param {number} [priority] Priority with which command will be intercepted.
7816
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7817
+ * @param {boolean} [unwrap] Whether the event should be unwrapped.
7818
+ * @param {*} [that] `this` value the callback will be called with.
7819
+ */
7736
7820
  CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap, that) {
7737
7821
 
7738
7822
  if (isFunction(hook) || isNumber(hook)) {
@@ -7788,24 +7872,19 @@
7788
7872
  ];
7789
7873
 
7790
7874
  /*
7791
- * Install hook shortcuts
7792
- *
7793
- * This will generate the CommandInterceptor#(preExecute|...|reverted) methods
7794
- * which will in term forward to CommandInterceptor#on.
7875
+ * Add prototype methods for each phase of command execution (e.g. execute,
7876
+ * revert).
7795
7877
  */
7796
7878
  forEach$1(hooks, function(hook) {
7797
7879
 
7798
7880
  /**
7799
- * {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
7800
- *
7801
- * A named hook for plugging into the command execution
7881
+ * Add prototype method for a specific phase of command execution.
7802
7882
  *
7803
- * @param {string|Array<string>} [events] list of commands to register on
7804
- * @param {number} [priority] the priority on which to hook into the execution
7805
- * @param {Function} handlerFn interceptor to be invoked with (event)
7806
- * @param {boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
7807
- * listener instead
7808
- * @param {Object} [that] Pass context (`this`) to the handler function
7883
+ * @param {string|string[]} [events] One or more commands to intercept.
7884
+ * @param {number} [priority] Priority with which command will be intercepted.
7885
+ * @param {ComposeHandlerFunction|HandlerFunction} handlerFn Callback.
7886
+ * @param {boolean} [unwrap] Whether the event should be unwrapped.
7887
+ * @param {*} [that] `this` value the callback will be called with.
7809
7888
  */
7810
7889
  CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap, that) {
7811
7890
 
@@ -7821,12 +7900,18 @@
7821
7900
  };
7822
7901
  });
7823
7902
 
7903
+ /**
7904
+ * @typedef {import('didi').Injector} Injector
7905
+ *
7906
+ * @typedef {import('../../core/Canvas').default} Canvas
7907
+ */
7908
+
7824
7909
  /**
7825
7910
  * A modeling behavior that ensures we set the correct root element
7826
7911
  * as we undo and redo commands.
7827
7912
  *
7828
7913
  * @param {Canvas} canvas
7829
- * @param {didi.Injector} injector
7914
+ * @param {Injector} injector
7830
7915
  */
7831
7916
  function RootElementsBehavior(canvas, injector) {
7832
7917
 
@@ -7860,111 +7945,10 @@
7860
7945
  rootElementsBehavior: [ 'type', RootElementsBehavior ]
7861
7946
  };
7862
7947
 
7863
- var css_escape = {exports: {}};
7864
-
7865
- /*! https://mths.be/cssescape v1.5.1 by @mathias | MIT license */
7866
-
7867
- (function (module, exports) {
7868
- (function(root, factory) {
7869
- // https://github.com/umdjs/umd/blob/master/returnExports.js
7870
- {
7871
- // For Node.js.
7872
- module.exports = factory(root);
7873
- }
7874
- }(typeof commonjsGlobal != 'undefined' ? commonjsGlobal : commonjsGlobal, function(root) {
7875
-
7876
- if (root.CSS && root.CSS.escape) {
7877
- return root.CSS.escape;
7878
- }
7879
-
7880
- // https://drafts.csswg.org/cssom/#serialize-an-identifier
7881
- var cssEscape = function(value) {
7882
- if (arguments.length == 0) {
7883
- throw new TypeError('`CSS.escape` requires an argument.');
7884
- }
7885
- var string = String(value);
7886
- var length = string.length;
7887
- var index = -1;
7888
- var codeUnit;
7889
- var result = '';
7890
- var firstCodeUnit = string.charCodeAt(0);
7891
- while (++index < length) {
7892
- codeUnit = string.charCodeAt(index);
7893
- // Note: there’s no need to special-case astral symbols, surrogate
7894
- // pairs, or lone surrogates.
7895
-
7896
- // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
7897
- // (U+FFFD).
7898
- if (codeUnit == 0x0000) {
7899
- result += '\uFFFD';
7900
- continue;
7901
- }
7902
-
7903
- if (
7904
- // If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
7905
- // U+007F, […]
7906
- (codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
7907
- // If the character is the first character and is in the range [0-9]
7908
- // (U+0030 to U+0039), […]
7909
- (index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
7910
- // If the character is the second character and is in the range [0-9]
7911
- // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
7912
- (
7913
- index == 1 &&
7914
- codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
7915
- firstCodeUnit == 0x002D
7916
- )
7917
- ) {
7918
- // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
7919
- result += '\\' + codeUnit.toString(16) + ' ';
7920
- continue;
7921
- }
7922
-
7923
- if (
7924
- // If the character is the first character and is a `-` (U+002D), and
7925
- // there is no second character, […]
7926
- index == 0 &&
7927
- length == 1 &&
7928
- codeUnit == 0x002D
7929
- ) {
7930
- result += '\\' + string.charAt(index);
7931
- continue;
7932
- }
7933
-
7934
- // If the character is not handled by one of the above rules and is
7935
- // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
7936
- // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
7937
- // U+005A), or [a-z] (U+0061 to U+007A), […]
7938
- if (
7939
- codeUnit >= 0x0080 ||
7940
- codeUnit == 0x002D ||
7941
- codeUnit == 0x005F ||
7942
- codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
7943
- codeUnit >= 0x0041 && codeUnit <= 0x005A ||
7944
- codeUnit >= 0x0061 && codeUnit <= 0x007A
7945
- ) {
7946
- // the character itself
7947
- result += string.charAt(index);
7948
- continue;
7949
- }
7950
-
7951
- // Otherwise, the escaped character.
7952
- // https://drafts.csswg.org/cssom/#escape-a-character
7953
- result += '\\' + string.charAt(index);
7954
-
7955
- }
7956
- return result;
7957
- };
7958
-
7959
- if (!root.CSS) {
7960
- root.CSS = {};
7961
- }
7962
-
7963
- root.CSS.escape = cssEscape;
7964
- return cssEscape;
7965
-
7966
- }));
7967
- } (css_escape));
7948
+ /**
7949
+ * @param {string} str
7950
+ * @returns {string}
7951
+ */
7968
7952
 
7969
7953
  var HTML_ESCAPE_MAP = {
7970
7954
  '&': '&amp;',
@@ -9099,6 +9083,11 @@
9099
9083
  return value;
9100
9084
  }
9101
9085
 
9086
+ /**
9087
+ * @typedef {import('../core/EventBus').default} EventBus
9088
+ * @typedef {import('./Styles').default} Styles
9089
+ */
9090
+
9102
9091
  // apply default renderer with lowest possible priority
9103
9092
  // so that it only kicks in if noone else could render
9104
9093
  var DEFAULT_RENDER_PRIORITY = 1;
@@ -9216,9 +9205,9 @@
9216
9205
  /**
9217
9206
  * Builds a style definition from a className, a list of traits and an object of additional attributes.
9218
9207
  *
9219
- * @param {string} className
9220
- * @param {Array<string>} traits
9221
- * @param {Object} additionalAttrs
9208
+ * @param {string} className
9209
+ * @param {Array<string>} traits
9210
+ * @param {Object} additionalAttrs
9222
9211
  *
9223
9212
  * @return {Object} the style defintion
9224
9213
  */
@@ -9231,8 +9220,8 @@
9231
9220
  /**
9232
9221
  * Builds a style definition from a list of traits and an object of additional attributes.
9233
9222
  *
9234
- * @param {Array<string>} traits
9235
- * @param {Object} additionalAttrs
9223
+ * @param {Array<string>} traits
9224
+ * @param {Object} additionalAttrs
9236
9225
  *
9237
9226
  * @return {Object} the style defintion
9238
9227
  */
@@ -9269,8 +9258,8 @@
9269
9258
  /**
9270
9259
  * Failsafe remove an element from a collection
9271
9260
  *
9272
- * @param {Array<Object>} [collection]
9273
- * @param {Object} [element]
9261
+ * @param {Array<Object>} [collection]
9262
+ * @param {Object} [element]
9274
9263
  *
9275
9264
  * @return {number} the previous index of the element
9276
9265
  */
@@ -9340,6 +9329,27 @@
9340
9329
  }
9341
9330
  }
9342
9331
 
9332
+ /**
9333
+ * @typedef {import('.').ConnectionLike} ConnectionLike
9334
+ * @typedef {import('.').RootLike} RootLike
9335
+ * @typedef {import('.').ShapeLike} ShapeLike
9336
+ *
9337
+ * @typedef {import('./Canvas').CanvasConfig} CanvasConfig
9338
+ * @typedef {import('./Canvas').CanvasLayer} CanvasLayer
9339
+ * @typedef {import('./Canvas').CanvasLayers} CanvasLayers
9340
+ * @typedef {import('./Canvas').CanvasPlane} CanvasPlane
9341
+ * @typedef {import('./Canvas').CanvasViewbox} CanvasViewbox
9342
+ *
9343
+ * @typedef {import('./ElementRegistry').default} ElementRegistry
9344
+ * @typedef {import('./EventBus').default} EventBus
9345
+ * @typedef {import('./GraphicsFactory').default} GraphicsFactory
9346
+ *
9347
+ * @typedef {import('../util/Types').Dimensions} Dimensions
9348
+ * @typedef {import('../util/Types').Point} Point
9349
+ * @typedef {import('../util/Types').Rect} Rect
9350
+ * @typedef {import('../util/Types').RectTRBL} RectTRBL
9351
+ */
9352
+
9343
9353
  function round(number, resolution) {
9344
9354
  return Math.round(number * resolution) / resolution;
9345
9355
  }
@@ -9360,7 +9370,8 @@
9360
9370
  * Creates a HTML container element for a SVG element with
9361
9371
  * the given configuration
9362
9372
  *
9363
- * @param {Object} options
9373
+ * @param {CanvasConfig} options
9374
+ *
9364
9375
  * @return {HTMLElement} the container element
9365
9376
  */
9366
9377
  function createContainer(options) {
@@ -9420,21 +9431,34 @@
9420
9431
  *
9421
9432
  * @emits Canvas#canvas.init
9422
9433
  *
9423
- * @param {Object} config
9434
+ * @param {CanvasConfig|null} config
9424
9435
  * @param {EventBus} eventBus
9425
9436
  * @param {GraphicsFactory} graphicsFactory
9426
9437
  * @param {ElementRegistry} elementRegistry
9427
9438
  */
9428
9439
  function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
9429
-
9430
9440
  this._eventBus = eventBus;
9431
9441
  this._elementRegistry = elementRegistry;
9432
9442
  this._graphicsFactory = graphicsFactory;
9433
9443
 
9444
+ /**
9445
+ * @type {number}
9446
+ */
9434
9447
  this._rootsIdx = 0;
9435
9448
 
9449
+ /**
9450
+ * @type {CanvasLayers}
9451
+ */
9436
9452
  this._layers = {};
9453
+
9454
+ /**
9455
+ * @type {CanvasPlane[]}
9456
+ */
9437
9457
  this._planes = [];
9458
+
9459
+ /**
9460
+ * @type {RootLike|null}
9461
+ */
9438
9462
  this._rootElement = null;
9439
9463
 
9440
9464
  this._init(config || {});
@@ -9459,6 +9483,8 @@
9459
9483
  * ...
9460
9484
  * </svg>
9461
9485
  * </div>
9486
+ *
9487
+ * @param {CanvasConfig} config
9462
9488
  */
9463
9489
  Canvas.prototype._init = function(config) {
9464
9490
 
@@ -9480,7 +9506,7 @@
9480
9506
  this._viewboxChanged = debounce(bind$2(this._viewboxChanged, this), 300);
9481
9507
  }
9482
9508
 
9483
- eventBus.on('diagram.init', function() {
9509
+ eventBus.on('diagram.init', () => {
9484
9510
 
9485
9511
  /**
9486
9512
  * An event indicating that the canvas is ready to be drawn on.
@@ -9498,7 +9524,7 @@
9498
9524
  viewport: viewport
9499
9525
  });
9500
9526
 
9501
- }, this);
9527
+ });
9502
9528
 
9503
9529
  // reset viewbox on shape changes to
9504
9530
  // recompute the viewbox
@@ -9509,15 +9535,15 @@
9509
9535
  'connection.removed',
9510
9536
  'elements.changed',
9511
9537
  'root.set'
9512
- ], function() {
9538
+ ], () => {
9513
9539
  delete this._cachedViewbox;
9514
- }, this);
9540
+ });
9515
9541
 
9516
9542
  eventBus.on('diagram.destroy', 500, this._destroy, this);
9517
9543
  eventBus.on('diagram.clear', 500, this._clear, this);
9518
9544
  };
9519
9545
 
9520
- Canvas.prototype._destroy = function(emit) {
9546
+ Canvas.prototype._destroy = function() {
9521
9547
  this._eventBus.fire('canvas.destroy', {
9522
9548
  svg: this._svg,
9523
9549
  viewport: this._viewport
@@ -9564,7 +9590,7 @@
9564
9590
  * Returns the default layer on which
9565
9591
  * all elements are drawn.
9566
9592
  *
9567
- * @returns {SVGElement}
9593
+ * @return {SVGElement} The SVG element of the layer.
9568
9594
  */
9569
9595
  Canvas.prototype.getDefaultLayer = function() {
9570
9596
  return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
@@ -9580,10 +9606,10 @@
9580
9606
  * A layer with a certain index is always created above all
9581
9607
  * existing layers with the same index.
9582
9608
  *
9583
- * @param {string} name
9584
- * @param {number} index
9609
+ * @param {string} name The name of the layer.
9610
+ * @param {number} [index] The index of the layer.
9585
9611
  *
9586
- * @returns {SVGElement}
9612
+ * @return {SVGElement} The SVG element of the layer.
9587
9613
  */
9588
9614
  Canvas.prototype.getLayer = function(name, index) {
9589
9615
 
@@ -9612,8 +9638,9 @@
9612
9638
  *
9613
9639
  * This is used to determine the node a layer should be inserted at.
9614
9640
  *
9615
- * @param {Number} index
9616
- * @returns {Number}
9641
+ * @param {number} index
9642
+ *
9643
+ * @return {number}
9617
9644
  */
9618
9645
  Canvas.prototype._getChildIndex = function(index) {
9619
9646
  return reduce(this._layers, function(childIndex, layer) {
@@ -9631,7 +9658,7 @@
9631
9658
  * @param {string} name
9632
9659
  * @param {number} [index=0]
9633
9660
  *
9634
- * @return {Object} layer descriptor with { index, group: SVGGroup }
9661
+ * @return {CanvasLayer}
9635
9662
  */
9636
9663
  Canvas.prototype._createLayer = function(name, index) {
9637
9664
 
@@ -9652,8 +9679,9 @@
9652
9679
  /**
9653
9680
  * Shows a given layer.
9654
9681
  *
9655
- * @param {String} layer
9656
- * @returns {SVGElement}
9682
+ * @param {string} layer The name of the layer.
9683
+ *
9684
+ * @return {SVGElement} The SVG element of the layer.
9657
9685
  */
9658
9686
  Canvas.prototype.showLayer = function(name) {
9659
9687
 
@@ -9687,8 +9715,9 @@
9687
9715
  /**
9688
9716
  * Hides a given layer.
9689
9717
  *
9690
- * @param {String} layer
9691
- * @returns {SVGElement}
9718
+ * @param {string} layer The name of the layer.
9719
+ *
9720
+ * @return {SVGElement} The SVG element of the layer.
9692
9721
  */
9693
9722
  Canvas.prototype.hideLayer = function(name) {
9694
9723
 
@@ -9730,7 +9759,7 @@
9730
9759
  /**
9731
9760
  * Returns the currently active layer. Can be null.
9732
9761
  *
9733
- * @returns {SVGElement|null}
9762
+ * @return {CanvasLayer|null} The active layer of `null`.
9734
9763
  */
9735
9764
  Canvas.prototype.getActiveLayer = function() {
9736
9765
  const plane = this._findPlaneForRoot(this.getRootElement());
@@ -9746,9 +9775,9 @@
9746
9775
  /**
9747
9776
  * Returns the plane which contains the given element.
9748
9777
  *
9749
- * @param {string|djs.model.Base} element
9778
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9750
9779
  *
9751
- * @return {djs.model.Base} root for element
9780
+ * @return {RootLike|undefined} The root of the element.
9752
9781
  */
9753
9782
  Canvas.prototype.findRoot = function(element) {
9754
9783
  if (typeof element === 'string') {
@@ -9769,7 +9798,7 @@
9769
9798
  /**
9770
9799
  * Return a list of all root elements on the diagram.
9771
9800
  *
9772
- * @return {djs.model.Root[]}
9801
+ * @return {(RootLike)[]} The list of root elements.
9773
9802
  */
9774
9803
  Canvas.prototype.getRootElements = function() {
9775
9804
  return this._planes.map(function(plane) {
@@ -9788,7 +9817,7 @@
9788
9817
  * Returns the html element that encloses the
9789
9818
  * drawing canvas.
9790
9819
  *
9791
- * @return {DOMNode}
9820
+ * @return {HTMLElement} The HTML element of the container.
9792
9821
  */
9793
9822
  Canvas.prototype.getContainer = function() {
9794
9823
  return this._container;
@@ -9828,8 +9857,8 @@
9828
9857
  *
9829
9858
  * @event element.marker.update
9830
9859
  * @type {Object}
9831
- * @property {djs.model.Element} element the shape
9832
- * @property {Object} gfx the graphical representation of the shape
9860
+ * @property {Base} element the shape
9861
+ * @property {SVGElement} gfx the graphical representation of the shape
9833
9862
  * @property {string} marker
9834
9863
  * @property {boolean} add true if the marker was added, false if it got removed
9835
9864
  */
@@ -9844,14 +9873,15 @@
9844
9873
  * integrate extension into the marker life-cycle, too.
9845
9874
  *
9846
9875
  * @example
9876
+ *
9847
9877
  * canvas.addMarker('foo', 'some-marker');
9848
9878
  *
9849
9879
  * const fooGfx = canvas.getGraphics('foo');
9850
9880
  *
9851
9881
  * fooGfx; // <g class="... some-marker"> ... </g>
9852
9882
  *
9853
- * @param {string|djs.model.Base} element
9854
- * @param {string} marker
9883
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9884
+ * @param {string} marker The marker.
9855
9885
  */
9856
9886
  Canvas.prototype.addMarker = function(element, marker) {
9857
9887
  this._updateMarker(element, marker, true);
@@ -9864,18 +9894,18 @@
9864
9894
  * Fires the element.marker.update event, making it possible to
9865
9895
  * integrate extension into the marker life-cycle, too.
9866
9896
  *
9867
- * @param {string|djs.model.Base} element
9868
- * @param {string} marker
9897
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9898
+ * @param {string} marker The marker.
9869
9899
  */
9870
9900
  Canvas.prototype.removeMarker = function(element, marker) {
9871
9901
  this._updateMarker(element, marker, false);
9872
9902
  };
9873
9903
 
9874
9904
  /**
9875
- * Check the existence of a marker on element.
9905
+ * Check whether an element has a given marker.
9876
9906
  *
9877
- * @param {string|djs.model.Base} element
9878
- * @param {string} marker
9907
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9908
+ * @param {string} marker The marker.
9879
9909
  */
9880
9910
  Canvas.prototype.hasMarker = function(element, marker) {
9881
9911
  if (!element.id) {
@@ -9893,8 +9923,8 @@
9893
9923
  * Fires the element.marker.update event, making it possible to
9894
9924
  * integrate extension into the marker life-cycle, too.
9895
9925
  *
9896
- * @param {string|djs.model.Base} element
9897
- * @param {string} marker
9926
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
9927
+ * @param {string} marker The marker.
9898
9928
  */
9899
9929
  Canvas.prototype.toggleMarker = function(element, marker) {
9900
9930
  if (this.hasMarker(element, marker)) {
@@ -9917,7 +9947,7 @@
9917
9947
  * root elements can be null. This is used for applications that want to manage
9918
9948
  * root elements themselves.
9919
9949
  *
9920
- * @returns {Object|djs.model.Root|null} rootElement.
9950
+ * @return {RootLike} The current root element.
9921
9951
  */
9922
9952
  Canvas.prototype.getRootElement = function() {
9923
9953
  const rootElement = this._rootElement;
@@ -9933,11 +9963,10 @@
9933
9963
  /**
9934
9964
  * Adds a given root element and returns it.
9935
9965
  *
9936
- * @param {Object|djs.model.Root} rootElement
9966
+ * @param {ShapeLike} [rootElement] The root element to be added.
9937
9967
  *
9938
- * @return {Object|djs.model.Root} rootElement
9968
+ * @return {RootLike} The added root element or an implicit root element.
9939
9969
  */
9940
-
9941
9970
  Canvas.prototype.addRootElement = function(rootElement) {
9942
9971
  const idx = this._rootsIdx++;
9943
9972
 
@@ -9968,11 +9997,11 @@
9968
9997
  };
9969
9998
 
9970
9999
  /**
9971
- * Removes a given rootElement and returns it.
10000
+ * Removes a given root element and returns it.
9972
10001
  *
9973
- * @param {djs.model.Root|String} rootElement
10002
+ * @param {ShapeLike|string} rootElement The root element or its ID.
9974
10003
  *
9975
- * @return {Object|djs.model.Root} rootElement
10004
+ * @return {ShapeLike|undefined} The removed root element.
9976
10005
  */
9977
10006
  Canvas.prototype.removeRootElement = function(rootElement) {
9978
10007
 
@@ -10006,15 +10035,13 @@
10006
10035
  };
10007
10036
 
10008
10037
 
10009
- // root element handling //////////////////////
10010
-
10011
10038
  /**
10012
10039
  * Sets a given element as the new root element for the canvas
10013
10040
  * and returns the new root element.
10014
10041
  *
10015
- * @param {Object|djs.model.Root} rootElement
10042
+ * @param {RootLike} rootElement The root element to be set.
10016
10043
  *
10017
- * @return {Object|djs.model.Root} new root element
10044
+ * @return {RootLike} The set root element.
10018
10045
  */
10019
10046
  Canvas.prototype.setRootElement = function(rootElement, override) {
10020
10047
 
@@ -10101,8 +10128,6 @@
10101
10128
  this._eventBus.fire('root.set', { element: rootElement });
10102
10129
  };
10103
10130
 
10104
- // add functionality //////////////////////
10105
-
10106
10131
  Canvas.prototype._ensureValid = function(type, element) {
10107
10132
  if (!element.id) {
10108
10133
  throw new Error('element must have an id');
@@ -10143,11 +10168,11 @@
10143
10168
  * Extensions may hook into these events to perform their magic.
10144
10169
  *
10145
10170
  * @param {string} type
10146
- * @param {Object|djs.model.Base} element
10147
- * @param {Object|djs.model.Base} [parent]
10171
+ * @param {ConnectionLike|ShapeLike} element
10172
+ * @param {ShapeLike} [parent]
10148
10173
  * @param {number} [parentIndex]
10149
10174
  *
10150
- * @return {Object|djs.model.Base} the added element
10175
+ * @return {ConnectionLike|ShapeLike} The added element.
10151
10176
  */
10152
10177
  Canvas.prototype._addElement = function(type, element, parent, parentIndex) {
10153
10178
 
@@ -10176,26 +10201,26 @@
10176
10201
  };
10177
10202
 
10178
10203
  /**
10179
- * Adds a shape to the canvas
10204
+ * Adds a shape to the canvas.
10180
10205
  *
10181
- * @param {Object|djs.model.Shape} shape to add to the diagram
10182
- * @param {djs.model.Base} [parent]
10183
- * @param {number} [parentIndex]
10206
+ * @param {ShapeLike} shape The shape to be added
10207
+ * @param {ShapeLike} [parent] The shape's parent.
10208
+ * @param {number} [parentIndex] The index at which to add the shape to the parent's children.
10184
10209
  *
10185
- * @return {djs.model.Shape} the added shape
10210
+ * @return {ShapeLike} The added shape.
10186
10211
  */
10187
10212
  Canvas.prototype.addShape = function(shape, parent, parentIndex) {
10188
10213
  return this._addElement('shape', shape, parent, parentIndex);
10189
10214
  };
10190
10215
 
10191
10216
  /**
10192
- * Adds a connection to the canvas
10217
+ * Adds a connection to the canvas.
10193
10218
  *
10194
- * @param {Object|djs.model.Connection} connection to add to the diagram
10195
- * @param {djs.model.Base} [parent]
10196
- * @param {number} [parentIndex]
10219
+ * @param {ConnectionLike} connection The connection to be added.
10220
+ * @param {ShapeLike} [parent] The connection's parent.
10221
+ * @param {number} [parentIndex] The index at which to add the connection to the parent's children.
10197
10222
  *
10198
- * @return {djs.model.Connection} the added connection
10223
+ * @return {ConnectionLike} The added connection.
10199
10224
  */
10200
10225
  Canvas.prototype.addConnection = function(connection, parent, parentIndex) {
10201
10226
  return this._addElement('connection', connection, parent, parentIndex);
@@ -10236,11 +10261,14 @@
10236
10261
 
10237
10262
 
10238
10263
  /**
10239
- * Removes a shape from the canvas
10264
+ * Removes a shape from the canvas.
10265
+ *
10266
+ * @fires ShapeRemoveEvent
10267
+ * @fires ShapeRemovedEvent
10240
10268
  *
10241
- * @param {string|djs.model.Shape} shape or shape id to be removed
10269
+ * @param {ShapeLike|string} shape The shape or its ID.
10242
10270
  *
10243
- * @return {djs.model.Shape} the removed shape
10271
+ * @return {ShapeLike} The removed shape.
10244
10272
  */
10245
10273
  Canvas.prototype.removeShape = function(shape) {
10246
10274
 
@@ -10249,10 +10277,10 @@
10249
10277
  *
10250
10278
  * @memberOf Canvas
10251
10279
  *
10252
- * @event shape.remove
10280
+ * @event ShapeRemoveEvent
10253
10281
  * @type {Object}
10254
- * @property {djs.model.Shape} element the shape descriptor
10255
- * @property {Object} gfx the graphical representation of the shape
10282
+ * @property {ShapeLike} element The shape.
10283
+ * @property {SVGElement} gfx The graphical element.
10256
10284
  */
10257
10285
 
10258
10286
  /**
@@ -10260,21 +10288,24 @@
10260
10288
  *
10261
10289
  * @memberOf Canvas
10262
10290
  *
10263
- * @event shape.removed
10291
+ * @event ShapeRemoved
10264
10292
  * @type {Object}
10265
- * @property {djs.model.Shape} element the shape descriptor
10266
- * @property {Object} gfx the graphical representation of the shape
10293
+ * @property {ShapeLike} element The shape.
10294
+ * @property {SVGElement} gfx The graphical element.
10267
10295
  */
10268
10296
  return this._removeElement(shape, 'shape');
10269
10297
  };
10270
10298
 
10271
10299
 
10272
10300
  /**
10273
- * Removes a connection from the canvas
10301
+ * Removes a connection from the canvas.
10274
10302
  *
10275
- * @param {string|djs.model.Connection} connection or connection id to be removed
10303
+ * @fires ConnectionRemoveEvent
10304
+ * @fires ConnectionRemovedEvent
10276
10305
  *
10277
- * @return {djs.model.Connection} the removed connection
10306
+ * @param {ConnectionLike|string} connection The connection or its ID.
10307
+ *
10308
+ * @return {ConnectionLike} The removed connection.
10278
10309
  */
10279
10310
  Canvas.prototype.removeConnection = function(connection) {
10280
10311
 
@@ -10283,10 +10314,10 @@
10283
10314
  *
10284
10315
  * @memberOf Canvas
10285
10316
  *
10286
- * @event connection.remove
10317
+ * @event ConnectionRemoveEvent
10287
10318
  * @type {Object}
10288
- * @property {djs.model.Connection} element the connection descriptor
10289
- * @property {Object} gfx the graphical representation of the connection
10319
+ * @property {ConnectionLike} element The connection.
10320
+ * @property {SVGElement} gfx The graphical element.
10290
10321
  */
10291
10322
 
10292
10323
  /**
@@ -10296,20 +10327,20 @@
10296
10327
  *
10297
10328
  * @event connection.removed
10298
10329
  * @type {Object}
10299
- * @property {djs.model.Connection} element the connection descriptor
10300
- * @property {Object} gfx the graphical representation of the connection
10330
+ * @property {ConnectionLike} element The connection.
10331
+ * @property {SVGElement} gfx The graphical element.
10301
10332
  */
10302
10333
  return this._removeElement(connection, 'connection');
10303
10334
  };
10304
10335
 
10305
10336
 
10306
10337
  /**
10307
- * Return the graphical object underlaying a certain diagram element
10338
+ * Returns the graphical element of an element.
10308
10339
  *
10309
- * @param {string|djs.model.Base} element descriptor of the element
10310
- * @param {boolean} [secondary=false] whether to return the secondary connected element
10340
+ * @param {ShapeLike|ConnectionLike|string} element The element or its ID.
10341
+ * @param {boolean} [secondary=false] Whether to return the secondary graphical element.
10311
10342
  *
10312
- * @return {SVGElement}
10343
+ * @return {SVGElement} The graphical element.
10313
10344
  */
10314
10345
  Canvas.prototype.getGraphics = function(element, secondary) {
10315
10346
  return this._elementRegistry.getGraphics(element, secondary);
@@ -10381,13 +10412,9 @@
10381
10412
  * height: zoomedAndScrolledViewbox.outer.height
10382
10413
  * });
10383
10414
  *
10384
- * @param {Object} [box] the new view box to set
10385
- * @param {number} box.x the top left X coordinate of the canvas visible in view box
10386
- * @param {number} box.y the top left Y coordinate of the canvas visible in view box
10387
- * @param {number} box.width the visible width
10388
- * @param {number} box.height
10415
+ * @param {Rect} [box] The viewbox to be set.
10389
10416
  *
10390
- * @return {Object} the current view box
10417
+ * @return {CanvasViewbox} The set viewbox.
10391
10418
  */
10392
10419
  Canvas.prototype.viewbox = function(box) {
10393
10420
 
@@ -10456,10 +10483,9 @@
10456
10483
  /**
10457
10484
  * Gets or sets the scroll of the canvas.
10458
10485
  *
10459
- * @param {Object} [delta] the new scroll to apply.
10486
+ * @param {Point} [delta] The scroll to be set.
10460
10487
  *
10461
- * @param {number} [delta.dx]
10462
- * @param {number} [delta.dy]
10488
+ * @return {Point}
10463
10489
  */
10464
10490
  Canvas.prototype.scroll = function(delta) {
10465
10491
 
@@ -10483,9 +10509,8 @@
10483
10509
  * Scrolls the viewbox to contain the given element.
10484
10510
  * Optionally specify a padding to be applied to the edges.
10485
10511
  *
10486
- * @param {Object|String} [element] the element to scroll to.
10487
- * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
10488
- *
10512
+ * @param {ShapeLike|ConnectionLike|string} element The element to scroll to or its ID.
10513
+ * @param {RectTRBL|number} [padding=100] The padding to be applied. Can also specify top, bottom, left and right.
10489
10514
  */
10490
10515
  Canvas.prototype.scrollToElement = function(element, padding) {
10491
10516
  let defaultPadding = 100;
@@ -10553,17 +10578,17 @@
10553
10578
  };
10554
10579
 
10555
10580
  /**
10556
- * Gets or sets the current zoom of the canvas, optionally zooming
10557
- * to the specified position.
10581
+ * Gets or sets the current zoom of the canvas, optionally zooming to the
10582
+ * specified position.
10558
10583
  *
10559
- * The getter may return a cached zoom level. Call it with `false` as
10560
- * the first argument to force recomputation of the current level.
10584
+ * The getter may return a cached zoom level. Call it with `false` as the first
10585
+ * argument to force recomputation of the current level.
10561
10586
  *
10562
- * @param {string|number} [newScale] the new zoom level, either a number, i.e. 0.9,
10563
- * or `fit-viewport` to adjust the size to fit the current viewport
10564
- * @param {string|Point} [center] the reference point { x: .., y: ..} to zoom to, 'auto' to zoom into mid or null
10587
+ * @param {number|string} [newScale] The new zoom level, either a number,
10588
+ * i.e. 0.9, or `fit-viewport` to adjust the size to fit the current viewport.
10589
+ * @param {Point} [center] The reference point { x: ..., y: ...} to zoom to.
10565
10590
  *
10566
- * @return {number} the current scale
10591
+ * @return {number} The set zoom level.
10567
10592
  */
10568
10593
  Canvas.prototype.zoom = function(newScale, center) {
10569
10594
 
@@ -10686,9 +10711,9 @@
10686
10711
 
10687
10712
 
10688
10713
  /**
10689
- * Returns the size of the canvas
10714
+ * Returns the size of the canvas.
10690
10715
  *
10691
- * @return {Dimensions}
10716
+ * @return {Dimensions} The size of the canvas.
10692
10717
  */
10693
10718
  Canvas.prototype.getSize = function() {
10694
10719
  return {
@@ -10699,14 +10724,14 @@
10699
10724
 
10700
10725
 
10701
10726
  /**
10702
- * Return the absolute bounding box for the given element
10727
+ * Returns the absolute bounding box of an element.
10728
+ *
10729
+ * The absolute bounding box may be used to display overlays in the callers
10730
+ * (browser) coordinate system rather than the zoomed in/out canvas coordinates.
10703
10731
  *
10704
- * The absolute bounding box may be used to display overlays in the
10705
- * callers (browser) coordinate system rather than the zoomed in/out
10706
- * canvas coordinates.
10732
+ * @param {ShapeLike|ConnectionLike} element The element.
10707
10733
  *
10708
- * @param {ElementDescriptor} element
10709
- * @return {Bounds} the absolute bounding box
10734
+ * @return {Rect} The element's absolute bounding box.
10710
10735
  */
10711
10736
  Canvas.prototype.getAbsoluteBBox = function(element) {
10712
10737
  const vbox = this.viewbox();
@@ -10741,8 +10766,7 @@
10741
10766
  };
10742
10767
 
10743
10768
  /**
10744
- * Fires an event in order other modules can react to the
10745
- * canvas resizing
10769
+ * Fires an event so other modules can react to the canvas resizing.
10746
10770
  */
10747
10771
  Canvas.prototype.resized = function() {
10748
10772
 
@@ -10754,11 +10778,21 @@
10754
10778
 
10755
10779
  var ELEMENT_ID = 'data-element-id';
10756
10780
 
10781
+ /**
10782
+ * @typedef {import('.').ElementLike} ElementLike
10783
+ *
10784
+ * @typedef {import('./EventBus').default} EventBus
10785
+ *
10786
+ * @typedef {import('./ElementRegistry').ElementRegistryCallback} ElementRegistryCallback
10787
+ */
10757
10788
 
10758
10789
  /**
10790
+ * A registry that keeps track of all shapes in the diagram.
10791
+ *
10759
10792
  * @class
10793
+ * @constructor
10760
10794
  *
10761
- * A registry that keeps track of all shapes in the diagram.
10795
+ * @param {EventBus} eventBus
10762
10796
  */
10763
10797
  function ElementRegistry(eventBus) {
10764
10798
  this._elements = {};
@@ -10769,11 +10803,11 @@
10769
10803
  ElementRegistry.$inject = [ 'eventBus' ];
10770
10804
 
10771
10805
  /**
10772
- * Register a pair of (element, gfx, (secondaryGfx)).
10806
+ * Add an element and its graphical representation(s) to the registry.
10773
10807
  *
10774
- * @param {djs.model.Base} element
10775
- * @param {SVGElement} gfx
10776
- * @param {SVGElement} [secondaryGfx] optional other element to register, too
10808
+ * @param {ElementLike} element The element to be added.
10809
+ * @param {SVGElement} gfx The primary graphical representation.
10810
+ * @param {SVGElement} [secondaryGfx] The secondary graphical representation.
10777
10811
  */
10778
10812
  ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
10779
10813
 
@@ -10792,9 +10826,9 @@
10792
10826
  };
10793
10827
 
10794
10828
  /**
10795
- * Removes an element from the registry.
10829
+ * Remove an element from the registry.
10796
10830
  *
10797
- * @param {string|djs.model.Base} element
10831
+ * @param {ElementLike|string} element
10798
10832
  */
10799
10833
  ElementRegistry.prototype.remove = function(element) {
10800
10834
  var elements = this._elements,
@@ -10815,10 +10849,10 @@
10815
10849
  };
10816
10850
 
10817
10851
  /**
10818
- * Update the id of an element
10852
+ * Update an elements ID.
10819
10853
  *
10820
- * @param {string|djs.model.Base} element
10821
- * @param {string} newId
10854
+ * @param {ElementLike|string} element The element or its ID.
10855
+ * @param {string} newId The new ID.
10822
10856
  */
10823
10857
  ElementRegistry.prototype.updateId = function(element, newId) {
10824
10858
 
@@ -10844,11 +10878,11 @@
10844
10878
  };
10845
10879
 
10846
10880
  /**
10847
- * Update the graphics of an element
10881
+ * Update the graphical representation of an element.
10848
10882
  *
10849
- * @param {string|djs.model.Base} element
10850
- * @param {SVGElement} gfx
10851
- * @param {boolean} [secondary=false] whether to update the secondary connected element
10883
+ * @param {ElementLike|string} element The element or its ID.
10884
+ * @param {SVGElement} gfx The new graphical representation.
10885
+ * @param {boolean} [secondary=false] Whether to update the secondary graphical representation.
10852
10886
  */
10853
10887
  ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
10854
10888
  var id = filter.id || filter;
@@ -10869,17 +10903,17 @@
10869
10903
  };
10870
10904
 
10871
10905
  /**
10872
- * Return the model element for a given id or graphics.
10906
+ * Get the element with the given ID or graphical representation.
10873
10907
  *
10874
10908
  * @example
10875
10909
  *
10876
10910
  * elementRegistry.get('SomeElementId_1');
10877
- * elementRegistry.get(gfx);
10878
10911
  *
10912
+ * elementRegistry.get(gfx);
10879
10913
  *
10880
- * @param {string|SVGElement} filter for selecting the element
10914
+ * @param {string|SVGElement} filter The elements ID or graphical representation.
10881
10915
  *
10882
- * @return {djs.model.Base}
10916
+ * @return {ElementLike|undefined} The element.
10883
10917
  */
10884
10918
  ElementRegistry.prototype.get = function(filter) {
10885
10919
  var id;
@@ -10897,9 +10931,9 @@
10897
10931
  /**
10898
10932
  * Return all elements that match a given filter function.
10899
10933
  *
10900
- * @param {Function} fn
10934
+ * @param {ElementRegistryCallback} fn The filter function.
10901
10935
  *
10902
- * @return {Array<djs.model.Base>}
10936
+ * @return {ElementLike[]} The matching elements.
10903
10937
  */
10904
10938
  ElementRegistry.prototype.filter = function(fn) {
10905
10939
 
@@ -10915,11 +10949,11 @@
10915
10949
  };
10916
10950
 
10917
10951
  /**
10918
- * Return the first element that satisfies the provided testing function.
10952
+ * Return the first element that matches the given filter function.
10919
10953
  *
10920
- * @param {Function} fn
10954
+ * @param {Function} fn The filter function.
10921
10955
  *
10922
- * @return {djs.model.Base}
10956
+ * @return {ElementLike|undefined} The matching element.
10923
10957
  */
10924
10958
  ElementRegistry.prototype.find = function(fn) {
10925
10959
  var map = this._elements,
@@ -10938,18 +10972,18 @@
10938
10972
  };
10939
10973
 
10940
10974
  /**
10941
- * Return all rendered model elements.
10975
+ * Get all elements.
10942
10976
  *
10943
- * @return {Array<djs.model.Base>}
10977
+ * @return {ElementLike[]} All elements.
10944
10978
  */
10945
10979
  ElementRegistry.prototype.getAll = function() {
10946
10980
  return this.filter(function(e) { return e; });
10947
10981
  };
10948
10982
 
10949
10983
  /**
10950
- * Iterate over all diagram elements.
10984
+ * Execute a given function for each element.
10951
10985
  *
10952
- * @param {Function} fn
10986
+ * @param {Function} fn The function to execute.
10953
10987
  */
10954
10988
  ElementRegistry.prototype.forEach = function(fn) {
10955
10989
 
@@ -10965,19 +10999,20 @@
10965
10999
  };
10966
11000
 
10967
11001
  /**
10968
- * Return the graphical representation of an element or its id.
11002
+ * Return the graphical representation of an element.
10969
11003
  *
10970
11004
  * @example
11005
+ *
10971
11006
  * elementRegistry.getGraphics('SomeElementId_1');
11007
+ *
10972
11008
  * elementRegistry.getGraphics(rootElement); // <g ...>
10973
11009
  *
10974
11010
  * elementRegistry.getGraphics(rootElement, true); // <svg ...>
10975
11011
  *
11012
+ * @param {ElementLike|string} filter The element or its ID.
11013
+ * @param {boolean} [secondary=false] Whether to return the secondary graphical representation.
10976
11014
  *
10977
- * @param {string|djs.model.Base} filter
10978
- * @param {boolean} [secondary=false] whether to return the secondary connected element
10979
- *
10980
- * @return {SVGElement}
11015
+ * @return {SVGElement} The graphical representation.
10981
11016
  */
10982
11017
  ElementRegistry.prototype.getGraphics = function(filter, secondary) {
10983
11018
  var id = filter.id || filter;
@@ -10987,12 +11022,11 @@
10987
11022
  };
10988
11023
 
10989
11024
  /**
10990
- * Validate the suitability of the given id and signals a problem
10991
- * with an exception.
11025
+ * Validate an ID and throw an error if invalid.
10992
11026
  *
10993
11027
  * @param {string} id
10994
11028
  *
10995
- * @throws {Error} if id is empty or already assigned
11029
+ * @throws {Error} Error indicating that the ID is invalid or already assigned.
10996
11030
  */
10997
11031
  ElementRegistry.prototype._validateId = function(id) {
10998
11032
  if (!id) {
@@ -11332,14 +11366,6 @@
11332
11366
  outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
11333
11367
  incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
11334
11368
 
11335
- /**
11336
- * @namespace djs.model
11337
- */
11338
-
11339
- /**
11340
- * @memberOf djs.model
11341
- */
11342
-
11343
11369
  /**
11344
11370
  * The basic graphical representation
11345
11371
  *
@@ -11536,21 +11562,47 @@
11536
11562
  };
11537
11563
 
11538
11564
  /**
11539
- * Creates a new model element of the specified type
11565
+ * Creates a model element of the given type.
11540
11566
  *
11541
11567
  * @method create
11542
11568
  *
11543
11569
  * @example
11544
11570
  *
11545
- * var shape1 = Model.create('shape', { x: 10, y: 10, width: 100, height: 100 });
11546
- * var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
11571
+ * import * as Model from 'diagram-js/lib/model';
11547
11572
  *
11548
- * var connection = Model.create('connection', { waypoints: [ { x: 110, y: 55 }, {x: 210, y: 55 } ] });
11573
+ * const connection = Model.create('connection', {
11574
+ * waypoints: [
11575
+ * { x: 100, y: 100 },
11576
+ * { x: 200, y: 100 }
11577
+ * ]
11578
+ * });
11549
11579
  *
11550
- * @param {string} type lower-cased model name
11551
- * @param {Object} attrs attributes to initialize the new model instance with
11580
+ * const label = Model.create('label', {
11581
+ * x: 100,
11582
+ * y: 100,
11583
+ * width: 100,
11584
+ * height: 100,
11585
+ * labelTarget: shape
11586
+ * });
11587
+ *
11588
+ * const root = Model.create('root', {
11589
+ * x: 100,
11590
+ * y: 100,
11591
+ * width: 100,
11592
+ * height: 100
11593
+ * });
11552
11594
  *
11553
- * @return {Base} the new model instance
11595
+ * const shape = Model.create('shape', {
11596
+ * x: 100,
11597
+ * y: 100,
11598
+ * width: 100,
11599
+ * height: 100
11600
+ * });
11601
+ *
11602
+ * @param {string} type The type of model element to be created.
11603
+ * @param {Object} attrs Attributes to create the model element with.
11604
+ *
11605
+ * @return {Connection|Label|Root|Shape} The created model element.
11554
11606
  */
11555
11607
  function create(type, attrs) {
11556
11608
  var Type = types$6[type];
@@ -11561,36 +11613,78 @@
11561
11613
  }
11562
11614
 
11563
11615
  /**
11564
- * A factory for diagram-js shapes
11616
+ * @typedef {import('../model/index').Base} Base
11617
+ * @typedef {import('../model/index').Connection} Connection
11618
+ * @typedef {import('../model/index').Label} Label
11619
+ * @typedef {import('../model/index').Root} Root
11620
+ * @typedef {import('../model/index').Shape} Shape
11621
+ * @typedef {import('../model/index').ModelAttrsConnection} ModelAttrsConnection
11622
+ * @typedef {import('../model/index').ModelAttrsLabel} ModelAttrsLabel
11623
+ * @typedef {import('../model/index').ModelAttrsRoot} ModelAttrsRoot
11624
+ * @typedef {import('../model/index').ModelAttrsShape} ModelAttrsShape
11625
+ */
11626
+
11627
+ /**
11628
+ * A factory for model elements.
11629
+ *
11630
+ * @class
11631
+ * @constructor
11565
11632
  */
11566
11633
  function ElementFactory() {
11567
11634
  this._uid = 12;
11568
11635
  }
11569
11636
 
11570
-
11637
+ /**
11638
+ * Create a root element.
11639
+ *
11640
+ * @param {ModelAttrsRoot} attrs The attributes of the root element to be created.
11641
+ *
11642
+ * @return {Root} The created root element.
11643
+ */
11571
11644
  ElementFactory.prototype.createRoot = function(attrs) {
11572
11645
  return this.create('root', attrs);
11573
11646
  };
11574
11647
 
11648
+ /**
11649
+ * Create a label.
11650
+ *
11651
+ * @param {ModelAttrsLabel} attrs The attributes of the label to be created.
11652
+ *
11653
+ * @return {Label} The created label.
11654
+ */
11575
11655
  ElementFactory.prototype.createLabel = function(attrs) {
11576
11656
  return this.create('label', attrs);
11577
11657
  };
11578
11658
 
11659
+ /**
11660
+ * Create a shape.
11661
+ *
11662
+ * @param {ModelAttrsShape} attrs The attributes of the shape to be created.
11663
+ *
11664
+ * @return {Shape} The created shape.
11665
+ */
11579
11666
  ElementFactory.prototype.createShape = function(attrs) {
11580
11667
  return this.create('shape', attrs);
11581
11668
  };
11582
11669
 
11670
+ /**
11671
+ * Create a connection.
11672
+ *
11673
+ * @param {ModelAttrsConnection} attrs The attributes of the connection to be created.
11674
+ *
11675
+ * @return {Connection} The created connection.
11676
+ */
11583
11677
  ElementFactory.prototype.createConnection = function(attrs) {
11584
11678
  return this.create('connection', attrs);
11585
11679
  };
11586
11680
 
11587
11681
  /**
11588
- * Create a model element with the given type and
11589
- * a number of pre-set attributes.
11682
+ * Create a model element of the given type with the given attributes.
11590
11683
  *
11591
- * @param {string} type
11592
- * @param {Object} attrs
11593
- * @return {djs.model.Base} the newly created model instance
11684
+ * @param {string} type The type of the model element.
11685
+ * @param {Object} attrs The attributes of the model element.
11686
+ *
11687
+ * @return {Connection|Label|Root|Shape} The created model element.
11594
11688
  */
11595
11689
  ElementFactory.prototype.create = function(type, attrs) {
11596
11690
 
@@ -11609,6 +11703,16 @@
11609
11703
 
11610
11704
  var slice = Array.prototype.slice;
11611
11705
 
11706
+ /**
11707
+ * @typedef {import('./EventBus').Event} Event
11708
+ * @typedef {import('./EventBus').EventCallback} EventCallback
11709
+ *
11710
+ * @typedef {Object} EventListener
11711
+ * @property {Function} callback
11712
+ * @property {EventListener|null} next
11713
+ * @property {number} priority
11714
+ */
11715
+
11612
11716
  /**
11613
11717
  * A general purpose event bus.
11614
11718
  *
@@ -11713,10 +11817,10 @@
11713
11817
  *
11714
11818
  * Returning anything but `undefined` from a listener will stop the listener propagation.
11715
11819
  *
11716
- * @param {string|Array<string>} events
11717
- * @param {number} [priority=1000] the priority in which this listener is called, larger is higher
11718
- * @param {Function} callback
11719
- * @param {Object} [that] Pass context (`this`) to the callback
11820
+ * @param {string|string[]} events The event(s) to listen to.
11821
+ * @param {number} [priority=1000] The priority with which to listen.
11822
+ * @param {EventCallback} callback The callback.
11823
+ * @param {*} [that] Value of `this` the callback will be called with.
11720
11824
  */
11721
11825
  EventBus.prototype.on = function(events, priority, callback, that) {
11722
11826
 
@@ -11756,12 +11860,12 @@
11756
11860
 
11757
11861
 
11758
11862
  /**
11759
- * Register an event listener that is executed only once.
11863
+ * Register an event listener that is called only once.
11760
11864
  *
11761
- * @param {string} event the event name to register for
11762
- * @param {number} [priority=1000] the priority in which this listener is called, larger is higher
11763
- * @param {Function} callback the callback to execute
11764
- * @param {Object} [that] Pass context (`this`) to the callback
11865
+ * @param {string} event The event to listen to.
11866
+ * @param {number} [priority=1000] The priority with which to listen.
11867
+ * @param {EventCallback} callback The callback.
11868
+ * @param {*} [that] Value of `this` the callback will be called with.
11765
11869
  */
11766
11870
  EventBus.prototype.once = function(event, priority, callback, that) {
11767
11871
  var self = this;
@@ -11800,8 +11904,8 @@
11800
11904
  *
11801
11905
  * If no callback is given, all listeners for a given event name are being removed.
11802
11906
  *
11803
- * @param {string|Array<string>} events
11804
- * @param {Function} [callback]
11907
+ * @param {string|string[]} events The events.
11908
+ * @param {EventCallback} [callback] The callback.
11805
11909
  */
11806
11910
  EventBus.prototype.off = function(events, callback) {
11807
11911
 
@@ -11817,11 +11921,11 @@
11817
11921
 
11818
11922
 
11819
11923
  /**
11820
- * Create an EventBus event.
11924
+ * Create an event recognized be the event bus.
11821
11925
  *
11822
- * @param {Object} data
11926
+ * @param {Object} data Event data.
11823
11927
  *
11824
- * @return {Object} event, recognized by the eventBus
11928
+ * @return {Event} An event that will be recognized by the event bus.
11825
11929
  */
11826
11930
  EventBus.prototype.createEvent = function(data) {
11827
11931
  var event = new InternalEvent();
@@ -11833,7 +11937,7 @@
11833
11937
 
11834
11938
 
11835
11939
  /**
11836
- * Fires a named event.
11940
+ * Fires an event.
11837
11941
  *
11838
11942
  * @example
11839
11943
  *
@@ -11855,12 +11959,11 @@
11855
11959
  *
11856
11960
  * events.fire({ type: 'foo' }, 'I am bar!');
11857
11961
  *
11858
- * @param {string} [name] the optional event name
11859
- * @param {Object} [event] the event object
11860
- * @param {...Object} additional arguments to be passed to the callback functions
11962
+ * @param {string} [type] The event type.
11963
+ * @param {Object} [data] The event or event data.
11964
+ * @param {...*} additional Additional arguments the callback will be called with.
11861
11965
  *
11862
- * @return {boolean} the events return value, if specified or false if the
11863
- * default action was prevented by listeners
11966
+ * @return {*} The return value. Will be set to `false` if the default was prevented.
11864
11967
  */
11865
11968
  EventBus.prototype.fire = function(type, data) {
11866
11969
  var event,
@@ -11925,7 +12028,13 @@
11925
12028
  return returnValue;
11926
12029
  };
11927
12030
 
11928
-
12031
+ /**
12032
+ * Handle an error by firing an event.
12033
+ *
12034
+ * @param {Error} error The error to be handled.
12035
+ *
12036
+ * @return {boolean} Whether the error was handled.
12037
+ */
11929
12038
  EventBus.prototype.handleError = function(error) {
11930
12039
  return this.fire('error', { error: error }) === false;
11931
12040
  };
@@ -11988,7 +12097,7 @@
11988
12097
  return returnValue;
11989
12098
  };
11990
12099
 
11991
- /*
12100
+ /**
11992
12101
  * Add new listener with a certain priority to the list
11993
12102
  * of listeners (for the given event).
11994
12103
  *
@@ -12002,7 +12111,7 @@
12002
12111
  * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
12003
12112
  *
12004
12113
  * @param {string} event
12005
- * @param {Object} listener { priority, callback }
12114
+ * @param {EventListener} listener
12006
12115
  */
12007
12116
  EventBus.prototype._addListener = function(event, newListener) {
12008
12117
 
@@ -12108,9 +12217,9 @@
12108
12217
  * Invoke function. Be fast...
12109
12218
  *
12110
12219
  * @param {Function} fn
12111
- * @param {Array<Object>} args
12220
+ * @param {*[]} args
12112
12221
  *
12113
- * @return {Any}
12222
+ * @return {*}
12114
12223
  */
12115
12224
  function invokeFunction(fn, args) {
12116
12225
  return fn.apply(null, args);
@@ -12124,11 +12233,11 @@
12124
12233
  */
12125
12234
 
12126
12235
  /**
12127
- * Returns the visual part of a diagram element
12236
+ * Returns the visual part of a diagram element.
12128
12237
  *
12129
- * @param {Snap<SVGElement>} gfx
12238
+ * @param {SVGElement} gfx
12130
12239
  *
12131
- * @return {Snap<SVGElement>}
12240
+ * @return {SVGElement}
12132
12241
  */
12133
12242
  function getVisual(gfx) {
12134
12243
  return gfx.childNodes[0];
@@ -12137,15 +12246,28 @@
12137
12246
  /**
12138
12247
  * Returns the children for a given diagram element.
12139
12248
  *
12140
- * @param {Snap<SVGElement>} gfx
12141
- * @return {Snap<SVGElement>}
12249
+ * @param {SVGElement} gfx
12250
+ * @return {SVGElement}
12142
12251
  */
12143
12252
  function getChildren(gfx) {
12144
12253
  return gfx.parentNode.childNodes[1];
12145
12254
  }
12146
12255
 
12147
12256
  /**
12148
- * A factory that creates graphical elements
12257
+ * @typedef {import('../model').ModelType} ModelType
12258
+ * @typedef {import('../model').ModelTypeConnection} ModelTypeConnection
12259
+ * @typedef {import('../model').ModelTypeShape} ModelTypeShape
12260
+ *
12261
+ * @typedef {import('.').ConnectionLike} ConnectionLike
12262
+ * @typedef {import('.').ElementLike} ElementLike
12263
+ * @typedef {import('.').ShapeLike} ShapeLike
12264
+ *
12265
+ * @typedef {import('./ElementRegistry').default} ElementRegistry
12266
+ * @typedef {import('./EventBus').default} EventBus
12267
+ */
12268
+
12269
+ /**
12270
+ * A factory that creates graphical elements.
12149
12271
  *
12150
12272
  * @param {EventBus} eventBus
12151
12273
  * @param {ElementRegistry} elementRegistry
@@ -12213,7 +12335,7 @@
12213
12335
  * </g>
12214
12336
  *
12215
12337
  * @param {string} type the type of the element, i.e. shape | connection
12216
- * @param {SVGElement} [childrenGfx]
12338
+ * @param {SVGElement} childrenGfx
12217
12339
  * @param {number} [parentIndex] position to create container in parent
12218
12340
  * @param {boolean} [isFrame] is frame element
12219
12341
  *
@@ -12251,11 +12373,25 @@
12251
12373
  return gfx;
12252
12374
  };
12253
12375
 
12376
+ /**
12377
+ * Create a graphical element.
12378
+ *
12379
+ * @param {ModelType} type The type of the element.
12380
+ * @param {ElementLike} element The element.
12381
+ * @param {number} [parentIndex] The index at which to add the graphical element to its parent's children.
12382
+ *
12383
+ * @return {SVGElement} The graphical element.
12384
+ */
12254
12385
  GraphicsFactory.prototype.create = function(type, element, parentIndex) {
12255
12386
  var childrenGfx = this._getChildrenContainer(element.parent);
12256
12387
  return this._createContainer(type, childrenGfx, parentIndex, isFrameElement(element));
12257
12388
  };
12258
12389
 
12390
+ /**
12391
+ * Update the containments of the given elements.
12392
+ *
12393
+ * @param {ElementLike[]} elements The elements.
12394
+ */
12259
12395
  GraphicsFactory.prototype.updateContainments = function(elements) {
12260
12396
 
12261
12397
  var self = this,
@@ -12291,30 +12427,63 @@
12291
12427
  });
12292
12428
  };
12293
12429
 
12430
+ /**
12431
+ * Draw a shape.
12432
+ *
12433
+ * @param {SVGElement} visual The graphical element.
12434
+ * @param {ShapeLike} element The shape.
12435
+ */
12294
12436
  GraphicsFactory.prototype.drawShape = function(visual, element) {
12295
12437
  var eventBus = this._eventBus;
12296
12438
 
12297
12439
  return eventBus.fire('render.shape', { gfx: visual, element: element });
12298
12440
  };
12299
12441
 
12442
+ /**
12443
+ * Get the path of a shape.
12444
+ *
12445
+ * @param {ShapeLike} element The shape.
12446
+ *
12447
+ * @return {string} The path of the shape.
12448
+ */
12300
12449
  GraphicsFactory.prototype.getShapePath = function(element) {
12301
12450
  var eventBus = this._eventBus;
12302
12451
 
12303
12452
  return eventBus.fire('render.getShapePath', element);
12304
12453
  };
12305
12454
 
12455
+ /**
12456
+ * Draw a connection.
12457
+ *
12458
+ * @param {SVGElement} visual The graphical element.
12459
+ * @param {ConnectionLike} element The connection.
12460
+ */
12306
12461
  GraphicsFactory.prototype.drawConnection = function(visual, element) {
12307
12462
  var eventBus = this._eventBus;
12308
12463
 
12309
12464
  return eventBus.fire('render.connection', { gfx: visual, element: element });
12310
12465
  };
12311
12466
 
12312
- GraphicsFactory.prototype.getConnectionPath = function(waypoints) {
12467
+ /**
12468
+ * Get the path of a connection.
12469
+ *
12470
+ * @param {ConnectionLike} element The connection.
12471
+ *
12472
+ * @return {string} The path of the connection.
12473
+ */
12474
+ GraphicsFactory.prototype.getConnectionPath = function(connection) {
12313
12475
  var eventBus = this._eventBus;
12314
12476
 
12315
- return eventBus.fire('render.getConnectionPath', waypoints);
12477
+ return eventBus.fire('render.getConnectionPath', connection);
12316
12478
  };
12317
12479
 
12480
+ /**
12481
+ * Update an elements graphical representation.
12482
+ *
12483
+ * @param {ModelTypeShape|ModelTypeConnection} type The type of the element.
12484
+ * @param {ElementLike} element The element.
12485
+ * @param {SVGElement} gfx The graphical representation.
12486
+ */
12318
12487
  GraphicsFactory.prototype.update = function(type, element, gfx) {
12319
12488
 
12320
12489
  // do NOT update root element
@@ -12344,6 +12513,11 @@
12344
12513
  }
12345
12514
  };
12346
12515
 
12516
+ /**
12517
+ * Remove a graphical element.
12518
+ *
12519
+ * @param {ElementLike} element The element.
12520
+ */
12347
12521
  GraphicsFactory.prototype.remove = function(element) {
12348
12522
  var gfx = this._elementRegistry.getGraphics(element);
12349
12523
 
@@ -12377,13 +12551,17 @@
12377
12551
  };
12378
12552
 
12379
12553
  /**
12380
- * @typedef { import('didi').ModuleDeclaration } Module
12554
+ * @typedef {import('didi').InjectionContext} InjectionContext
12555
+ * @typedef {import('didi').LocalsMap} LocalsMap
12556
+ * @typedef {import('didi').ModuleDeclaration} ModuleDeclaration
12557
+ *
12558
+ * @typedef {import('./Diagram').DiagramOptions} DiagramOptions
12381
12559
  */
12382
12560
 
12383
12561
  /**
12384
12562
  * Bootstrap an injector from a list of modules, instantiating a number of default components
12385
12563
  *
12386
- * @param {Array<Module>} modules
12564
+ * @param {ModuleDeclaration[]} modules
12387
12565
  *
12388
12566
  * @return {Injector} a injector to use to access the components
12389
12567
  */
@@ -12398,7 +12576,8 @@
12398
12576
  /**
12399
12577
  * Creates an injector from passed options.
12400
12578
  *
12401
- * @param {Object} options
12579
+ * @param {DiagramOptions} [options]
12580
+ *
12402
12581
  * @return {Injector}
12403
12582
  */
12404
12583
  function createInjector(options) {
@@ -12421,8 +12600,7 @@
12421
12600
  *
12422
12601
  * To register extensions with the diagram, pass them as Array<Module> to the constructor.
12423
12602
  *
12424
- * @class djs.Diagram
12425
- * @memberOf djs
12603
+ * @class
12426
12604
  * @constructor
12427
12605
  *
12428
12606
  * @example
@@ -12460,9 +12638,9 @@
12460
12638
  *
12461
12639
  * // 'shape ... was added to the diagram' logged to console
12462
12640
  *
12463
- * @param {Object} options
12464
- * @param {Array<Module>} [options.modules] external modules to instantiate with the diagram
12465
- * @param {Injector} [injector] an (optional) injector to bootstrap the diagram with
12641
+ * @param {DiagramOptions} [options]
12642
+ * @param {ModuleDeclaration[]} [options.modules] External modules to instantiate with the diagram.
12643
+ * @param {Injector} [injector] An (optional) injector to bootstrap the diagram with.
12466
12644
  */
12467
12645
  function Diagram(options, injector) {
12468
12646
 
@@ -12472,22 +12650,23 @@
12472
12650
  // API
12473
12651
 
12474
12652
  /**
12475
- * Resolves a diagram service
12653
+ * Resolves a diagram service.
12476
12654
  *
12477
12655
  * @method Diagram#get
12478
12656
  *
12479
- * @param {string} name the name of the diagram service to be retrieved
12480
- * @param {boolean} [strict=true] if false, resolve missing services to null
12657
+ * @param {string} name The name of the service to get.
12658
+ * @param {boolean} [strict=true] If false, resolve missing services to null.
12481
12659
  */
12482
12660
  this.get = injector.get;
12483
12661
 
12484
12662
  /**
12485
- * Executes a function into which diagram services are injected
12663
+ * Executes a function with its dependencies injected.
12486
12664
  *
12487
12665
  * @method Diagram#invoke
12488
12666
  *
12489
- * @param {Function|Object[]} fn the function to resolve
12490
- * @param {Object} locals a number of locals to use to resolve certain dependencies
12667
+ * @param {Function} fn The function to be executed.
12668
+ * @param {InjectionContext} [context] The context.
12669
+ * @param {LocalsMap} [locals] The locals.
12491
12670
  */
12492
12671
  this.invoke = injector.invoke;
12493
12672
 
@@ -21674,10 +21853,10 @@
21674
21853
  // default moddle extensions the viewer is composed of
21675
21854
  Viewer.prototype._moddleExtensions = {};
21676
21855
 
21677
- var KEYS_COPY = [ 'c', 'C', 'KeyC' ];
21678
- var KEYS_PASTE = [ 'v', 'V', 'KeyV' ];
21679
- var KEYS_REDO = [ 'y', 'Y', 'KeyY' ];
21680
- var KEYS_UNDO = [ 'z', 'Z', 'KeyZ' ];
21856
+ var KEYS_COPY = [ 'c', 'C' ];
21857
+ var KEYS_PASTE = [ 'v', 'V' ];
21858
+ var KEYS_REDO = [ 'y', 'Y' ];
21859
+ var KEYS_UNDO = [ 'z', 'Z' ];
21681
21860
 
21682
21861
  /**
21683
21862
  * Returns true if event was triggered with any modifier
@@ -21740,6 +21919,10 @@
21740
21919
  );
21741
21920
  }
21742
21921
 
21922
+ /**
21923
+ * @typedef {import('../../core/EventBus').default} EventBus
21924
+ */
21925
+
21743
21926
  var KEYDOWN_EVENT = 'keyboard.keydown',
21744
21927
  KEYUP_EVENT = 'keyboard.keyup';
21745
21928
 
@@ -21768,7 +21951,7 @@
21768
21951
  * A default binding for the keyboard may be specified via the
21769
21952
  * `keyboard.bindTo` configuration option.
21770
21953
  *
21771
- * @param {Config} config
21954
+ * @param {Object} config
21772
21955
  * @param {EventBus} eventBus
21773
21956
  */
21774
21957
  function Keyboard(config, eventBus) {
@@ -22099,6 +22282,11 @@
22099
22282
  keyboardBindings: [ 'type', KeyboardBindings ]
22100
22283
  };
22101
22284
 
22285
+ /**
22286
+ * @typedef {import('../../core/Canvas').default} Canvas
22287
+ * @typedef {import('../../features/keyboard/Keyboard').default} Keyboard
22288
+ */
22289
+
22102
22290
  var DEFAULT_CONFIG = {
22103
22291
  moveSpeed: 50,
22104
22292
  moveSpeedAccelerated: 200
@@ -22271,6 +22459,11 @@
22271
22459
  };
22272
22460
  }
22273
22461
 
22462
+ /**
22463
+ * @typedef {import('../../core/Canvas').default} Canvas
22464
+ * @typedef {import('../../core/EventBus').default} EventBus
22465
+ */
22466
+
22274
22467
  var THRESHOLD = 15;
22275
22468
 
22276
22469
 
@@ -22390,8 +22583,9 @@
22390
22583
  };
22391
22584
 
22392
22585
  /**
22393
- * Get the logarithm of x with base 10
22394
- * @param {Integer} value
22586
+ * Get the logarithm of x with base 10.
22587
+ *
22588
+ * @param {number} x
22395
22589
  */
22396
22590
  function log10(x) {
22397
22591
  return Math.log(x) / Math.log(10);
@@ -22418,6 +22612,11 @@
22418
22612
  return Math.max(range.min, Math.min(range.max, scale));
22419
22613
  }
22420
22614
 
22615
+ /**
22616
+ * @typedef {import('../../core/Canvas').default} Canvas
22617
+ * @typedef {import('../../core/EventBus').default} EventBus
22618
+ */
22619
+
22421
22620
  var sign = Math.sign || function(n) {
22422
22621
  return n >= 0 ? 1 : -1;
22423
22622
  };
@@ -22608,7 +22807,7 @@
22608
22807
  /**
22609
22808
  * Toggle the zoom scroll ability via mouse wheel.
22610
22809
  *
22611
- * @param {boolean} [newEnabled] new enabled state
22810
+ * @param {boolean} [newEnabled] new enabled state
22612
22811
  */
22613
22812
  ZoomScroll.prototype.toggle = function toggle(newEnabled) {
22614
22813