camunda-bpmn-js 3.7.0 → 3.8.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.
@@ -7241,6 +7241,92 @@
7241
7241
  interactionEvents: [ 'type', InteractionEvents ]
7242
7242
  };
7243
7243
 
7244
+ /**
7245
+ * Returns the surrounding bbox for all elements in
7246
+ * the array or the element primitive.
7247
+ *
7248
+ * @param {Element|Element[]} elements
7249
+ * @param {boolean} [stopRecursion=false]
7250
+ *
7251
+ * @return {Rect}
7252
+ */
7253
+ function getBBox(elements, stopRecursion) {
7254
+
7255
+ stopRecursion = !!stopRecursion;
7256
+ if (!isArray$2(elements)) {
7257
+ elements = [ elements ];
7258
+ }
7259
+
7260
+ var minX,
7261
+ minY,
7262
+ maxX,
7263
+ maxY;
7264
+
7265
+ forEach$1(elements, function(element) {
7266
+
7267
+ // If element is a connection the bbox must be computed first
7268
+ var bbox = element;
7269
+ if (element.waypoints && !stopRecursion) {
7270
+ bbox = getBBox(element.waypoints, true);
7271
+ }
7272
+
7273
+ var x = bbox.x,
7274
+ y = bbox.y,
7275
+ height = bbox.height || 0,
7276
+ width = bbox.width || 0;
7277
+
7278
+ if (x < minX || minX === undefined) {
7279
+ minX = x;
7280
+ }
7281
+ if (y < minY || minY === undefined) {
7282
+ minY = y;
7283
+ }
7284
+
7285
+ if ((x + width) > maxX || maxX === undefined) {
7286
+ maxX = x + width;
7287
+ }
7288
+ if ((y + height) > maxY || maxY === undefined) {
7289
+ maxY = y + height;
7290
+ }
7291
+ });
7292
+
7293
+ return {
7294
+ x: minX,
7295
+ y: minY,
7296
+ height: maxY - minY,
7297
+ width: maxX - minX
7298
+ };
7299
+ }
7300
+
7301
+ /**
7302
+ * Get the element's type
7303
+ *
7304
+ * @param {Element} element
7305
+ *
7306
+ * @return {'connection' | 'shape' | 'root'}
7307
+ */
7308
+ function getType(element) {
7309
+
7310
+ if ('waypoints' in element) {
7311
+ return 'connection';
7312
+ }
7313
+
7314
+ if ('x' in element) {
7315
+ return 'shape';
7316
+ }
7317
+
7318
+ return 'root';
7319
+ }
7320
+
7321
+ /**
7322
+ * @param {Element} element
7323
+ *
7324
+ * @return {boolean}
7325
+ */
7326
+ function isFrameElement(element) {
7327
+ return !!(element && element.isFrame);
7328
+ }
7329
+
7244
7330
  var LOW_PRIORITY$3 = 500;
7245
7331
 
7246
7332
  var DEFAULT_PRIORITY$3 = 1000;
@@ -7302,6 +7388,19 @@
7302
7388
  }
7303
7389
  });
7304
7390
 
7391
+ eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
7392
+ var element = event.element,
7393
+ gfx = event.gfx;
7394
+
7395
+ var outline = query('.djs-outline', gfx);
7396
+
7397
+ if (!outline) {
7398
+ outline = createOutline(gfx, element);
7399
+ append(gfx, outline);
7400
+ }
7401
+
7402
+ self.updateConnectionOutline(outline, element);
7403
+ });
7305
7404
  }
7306
7405
 
7307
7406
 
@@ -7333,6 +7432,25 @@
7333
7432
  }
7334
7433
  };
7335
7434
 
7435
+ /**
7436
+ * Updates the outline of a connection respecting the bounding box of
7437
+ * the connection and an outline offset.
7438
+ * Register an outline provider with the given priority.
7439
+ *
7440
+ * @param {SVGElement} outline
7441
+ * @param {Element} connection
7442
+ **/
7443
+ Outline.prototype.updateConnectionOutline = function(outline, connection) {
7444
+ var bbox = getBBox(connection);
7445
+
7446
+ attr$1(outline, {
7447
+ x: bbox.x - this.offset,
7448
+ y: bbox.y - this.offset,
7449
+ width: bbox.width + this.offset * 2,
7450
+ height: bbox.height + this.offset * 2
7451
+ });
7452
+ };
7453
+
7336
7454
  /**
7337
7455
  * Register an outline provider with the given priority.
7338
7456
  *
@@ -7517,92 +7635,6 @@
7517
7635
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
7518
7636
  };
7519
7637
 
7520
- /**
7521
- * Returns the surrounding bbox for all elements in
7522
- * the array or the element primitive.
7523
- *
7524
- * @param {Element|Element[]} elements
7525
- * @param {boolean} [stopRecursion=false]
7526
- *
7527
- * @return {Rect}
7528
- */
7529
- function getBBox(elements, stopRecursion) {
7530
-
7531
- stopRecursion = !!stopRecursion;
7532
- if (!isArray$2(elements)) {
7533
- elements = [ elements ];
7534
- }
7535
-
7536
- var minX,
7537
- minY,
7538
- maxX,
7539
- maxY;
7540
-
7541
- forEach$1(elements, function(element) {
7542
-
7543
- // If element is a connection the bbox must be computed first
7544
- var bbox = element;
7545
- if (element.waypoints && !stopRecursion) {
7546
- bbox = getBBox(element.waypoints, true);
7547
- }
7548
-
7549
- var x = bbox.x,
7550
- y = bbox.y,
7551
- height = bbox.height || 0,
7552
- width = bbox.width || 0;
7553
-
7554
- if (x < minX || minX === undefined) {
7555
- minX = x;
7556
- }
7557
- if (y < minY || minY === undefined) {
7558
- minY = y;
7559
- }
7560
-
7561
- if ((x + width) > maxX || maxX === undefined) {
7562
- maxX = x + width;
7563
- }
7564
- if ((y + height) > maxY || maxY === undefined) {
7565
- maxY = y + height;
7566
- }
7567
- });
7568
-
7569
- return {
7570
- x: minX,
7571
- y: minY,
7572
- height: maxY - minY,
7573
- width: maxX - minX
7574
- };
7575
- }
7576
-
7577
- /**
7578
- * Get the element's type
7579
- *
7580
- * @param {Element} element
7581
- *
7582
- * @return {'connection' | 'shape' | 'root'}
7583
- */
7584
- function getType(element) {
7585
-
7586
- if ('waypoints' in element) {
7587
- return 'connection';
7588
- }
7589
-
7590
- if ('x' in element) {
7591
- return 'shape';
7592
- }
7593
-
7594
- return 'root';
7595
- }
7596
-
7597
- /**
7598
- * @param {Element} element
7599
- *
7600
- * @return {boolean}
7601
- */
7602
- function isFrameElement(element) {
7603
- return !!(element && element.isFrame);
7604
- }
7605
-
7606
7638
  /**
7607
7639
  * @typedef {import('../../core/Canvas').default} Canvas
7608
7640
  * @typedef {import('../../core/EventBus').default} EventBus