camunda-bpmn-js 3.7.0 → 3.9.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.
@@ -7220,6 +7220,92 @@
7220
7220
  interactionEvents: [ 'type', InteractionEvents ]
7221
7221
  };
7222
7222
 
7223
+ /**
7224
+ * Returns the surrounding bbox for all elements in
7225
+ * the array or the element primitive.
7226
+ *
7227
+ * @param {Element|Element[]} elements
7228
+ * @param {boolean} [stopRecursion=false]
7229
+ *
7230
+ * @return {Rect}
7231
+ */
7232
+ function getBBox(elements, stopRecursion) {
7233
+
7234
+ stopRecursion = !!stopRecursion;
7235
+ if (!isArray$2(elements)) {
7236
+ elements = [ elements ];
7237
+ }
7238
+
7239
+ var minX,
7240
+ minY,
7241
+ maxX,
7242
+ maxY;
7243
+
7244
+ forEach$1(elements, function(element) {
7245
+
7246
+ // If element is a connection the bbox must be computed first
7247
+ var bbox = element;
7248
+ if (element.waypoints && !stopRecursion) {
7249
+ bbox = getBBox(element.waypoints, true);
7250
+ }
7251
+
7252
+ var x = bbox.x,
7253
+ y = bbox.y,
7254
+ height = bbox.height || 0,
7255
+ width = bbox.width || 0;
7256
+
7257
+ if (x < minX || minX === undefined) {
7258
+ minX = x;
7259
+ }
7260
+ if (y < minY || minY === undefined) {
7261
+ minY = y;
7262
+ }
7263
+
7264
+ if ((x + width) > maxX || maxX === undefined) {
7265
+ maxX = x + width;
7266
+ }
7267
+ if ((y + height) > maxY || maxY === undefined) {
7268
+ maxY = y + height;
7269
+ }
7270
+ });
7271
+
7272
+ return {
7273
+ x: minX,
7274
+ y: minY,
7275
+ height: maxY - minY,
7276
+ width: maxX - minX
7277
+ };
7278
+ }
7279
+
7280
+ /**
7281
+ * Get the element's type
7282
+ *
7283
+ * @param {Element} element
7284
+ *
7285
+ * @return {'connection' | 'shape' | 'root'}
7286
+ */
7287
+ function getType(element) {
7288
+
7289
+ if ('waypoints' in element) {
7290
+ return 'connection';
7291
+ }
7292
+
7293
+ if ('x' in element) {
7294
+ return 'shape';
7295
+ }
7296
+
7297
+ return 'root';
7298
+ }
7299
+
7300
+ /**
7301
+ * @param {Element} element
7302
+ *
7303
+ * @return {boolean}
7304
+ */
7305
+ function isFrameElement(element) {
7306
+ return !!(element && element.isFrame);
7307
+ }
7308
+
7223
7309
  var LOW_PRIORITY$2 = 500;
7224
7310
 
7225
7311
  var DEFAULT_PRIORITY$2 = 1000;
@@ -7281,6 +7367,19 @@
7281
7367
  }
7282
7368
  });
7283
7369
 
7370
+ eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
7371
+ var element = event.element,
7372
+ gfx = event.gfx;
7373
+
7374
+ var outline = query('.djs-outline', gfx);
7375
+
7376
+ if (!outline) {
7377
+ outline = createOutline(gfx, element);
7378
+ append(gfx, outline);
7379
+ }
7380
+
7381
+ self.updateConnectionOutline(outline, element);
7382
+ });
7284
7383
  }
7285
7384
 
7286
7385
 
@@ -7312,6 +7411,25 @@
7312
7411
  }
7313
7412
  };
7314
7413
 
7414
+ /**
7415
+ * Updates the outline of a connection respecting the bounding box of
7416
+ * the connection and an outline offset.
7417
+ * Register an outline provider with the given priority.
7418
+ *
7419
+ * @param {SVGElement} outline
7420
+ * @param {Element} connection
7421
+ **/
7422
+ Outline.prototype.updateConnectionOutline = function(outline, connection) {
7423
+ var bbox = getBBox(connection);
7424
+
7425
+ attr$1(outline, {
7426
+ x: bbox.x - this.offset,
7427
+ y: bbox.y - this.offset,
7428
+ width: bbox.width + this.offset * 2,
7429
+ height: bbox.height + this.offset * 2
7430
+ });
7431
+ };
7432
+
7315
7433
  /**
7316
7434
  * Register an outline provider with the given priority.
7317
7435
  *
@@ -7496,92 +7614,6 @@
7496
7614
  this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
7497
7615
  };
7498
7616
 
7499
- /**
7500
- * Returns the surrounding bbox for all elements in
7501
- * the array or the element primitive.
7502
- *
7503
- * @param {Element|Element[]} elements
7504
- * @param {boolean} [stopRecursion=false]
7505
- *
7506
- * @return {Rect}
7507
- */
7508
- function getBBox(elements, stopRecursion) {
7509
-
7510
- stopRecursion = !!stopRecursion;
7511
- if (!isArray$2(elements)) {
7512
- elements = [ elements ];
7513
- }
7514
-
7515
- var minX,
7516
- minY,
7517
- maxX,
7518
- maxY;
7519
-
7520
- forEach$1(elements, function(element) {
7521
-
7522
- // If element is a connection the bbox must be computed first
7523
- var bbox = element;
7524
- if (element.waypoints && !stopRecursion) {
7525
- bbox = getBBox(element.waypoints, true);
7526
- }
7527
-
7528
- var x = bbox.x,
7529
- y = bbox.y,
7530
- height = bbox.height || 0,
7531
- width = bbox.width || 0;
7532
-
7533
- if (x < minX || minX === undefined) {
7534
- minX = x;
7535
- }
7536
- if (y < minY || minY === undefined) {
7537
- minY = y;
7538
- }
7539
-
7540
- if ((x + width) > maxX || maxX === undefined) {
7541
- maxX = x + width;
7542
- }
7543
- if ((y + height) > maxY || maxY === undefined) {
7544
- maxY = y + height;
7545
- }
7546
- });
7547
-
7548
- return {
7549
- x: minX,
7550
- y: minY,
7551
- height: maxY - minY,
7552
- width: maxX - minX
7553
- };
7554
- }
7555
-
7556
- /**
7557
- * Get the element's type
7558
- *
7559
- * @param {Element} element
7560
- *
7561
- * @return {'connection' | 'shape' | 'root'}
7562
- */
7563
- function getType(element) {
7564
-
7565
- if ('waypoints' in element) {
7566
- return 'connection';
7567
- }
7568
-
7569
- if ('x' in element) {
7570
- return 'shape';
7571
- }
7572
-
7573
- return 'root';
7574
- }
7575
-
7576
- /**
7577
- * @param {Element} element
7578
- *
7579
- * @return {boolean}
7580
- */
7581
- function isFrameElement(element) {
7582
- return !!(element && element.isFrame);
7583
- }
7584
-
7585
7617
  /**
7586
7618
  * @typedef {import('../../core/Canvas').default} Canvas
7587
7619
  * @typedef {import('../../core/EventBus').default} EventBus