bpmn-js 8.8.2 → 8.10.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-viewer v8.8.2
2
+ * bpmn-js - bpmn-viewer v8.10.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2021-10-20
11
+ * Date: 2022-02-17
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -389,13 +389,14 @@
389
389
  eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
390
390
  var type = evt.type,
391
391
  element = context.element,
392
- visuals = context.gfx;
392
+ visuals = context.gfx,
393
+ attrs = context.attrs;
393
394
 
394
395
  if (self.canRender(element)) {
395
396
  if (type === 'render.shape') {
396
- return self.drawShape(visuals, element);
397
+ return self.drawShape(visuals, element, attrs);
397
398
  } else {
398
- return self.drawConnection(visuals, element);
399
+ return self.drawConnection(visuals, element, attrs);
399
400
  }
400
401
  }
401
402
  });
@@ -473,7 +474,6 @@
473
474
  return bo && (typeof bo.$instanceOf === 'function') && bo.$instanceOf(type);
474
475
  }
475
476
 
476
-
477
477
  /**
478
478
  * Return the business object for a given element.
479
479
  *
@@ -7041,22 +7041,26 @@
7041
7041
 
7042
7042
  Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
7043
7043
  var show = overlay.show,
7044
+ plane = overlay.plane,
7044
7045
  minZoom = show && show.minZoom,
7045
7046
  maxZoom = show && show.maxZoom,
7046
7047
  htmlContainer = overlay.htmlContainer,
7048
+ activePlane = this._canvas.getActivePlane(),
7047
7049
  visible = true;
7048
7050
 
7049
- if (show) {
7051
+ if (plane !== activePlane) {
7052
+ visible = false;
7053
+ } else if (show) {
7050
7054
  if (
7051
7055
  (isDefined(minZoom) && minZoom > viewbox.scale) ||
7052
7056
  (isDefined(maxZoom) && maxZoom < viewbox.scale)
7053
7057
  ) {
7054
7058
  visible = false;
7055
7059
  }
7056
-
7057
- setVisible(htmlContainer, visible);
7058
7060
  }
7059
7061
 
7062
+ setVisible(htmlContainer, visible);
7063
+
7060
7064
  this._updateOverlayScale(overlay, viewbox);
7061
7065
  };
7062
7066
 
@@ -7589,7 +7593,7 @@
7589
7593
  return true;
7590
7594
  };
7591
7595
 
7592
- DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
7596
+ DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
7593
7597
  var rect = create$1('rect');
7594
7598
 
7595
7599
  attr$1(rect, {
@@ -7600,9 +7604,9 @@
7600
7604
  });
7601
7605
 
7602
7606
  if (isFrameElement(element)) {
7603
- attr$1(rect, this.FRAME_STYLE);
7607
+ attr$1(rect, assign({}, this.FRAME_STYLE, attrs || {}));
7604
7608
  } else {
7605
- attr$1(rect, this.SHAPE_STYLE);
7609
+ attr$1(rect, assign({}, this.SHAPE_STYLE, attrs || {}));
7606
7610
  }
7607
7611
 
7608
7612
  append(visuals, rect);
@@ -7610,9 +7614,9 @@
7610
7614
  return rect;
7611
7615
  };
7612
7616
 
7613
- DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
7617
+ DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
7614
7618
 
7615
- var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
7619
+ var line = createLine(connection.waypoints, assign({}, this.CONNECTION_STYLE, attrs || {}));
7616
7620
  append(visuals, line);
7617
7621
 
7618
7622
  return line;
@@ -7866,6 +7870,10 @@
7866
7870
  var BASE_LAYER = 'base';
7867
7871
  var HIDDEN_MARKER = 'djs-element-hidden';
7868
7872
 
7873
+ // render plane contents behind utility layers
7874
+ var PLANE_LAYER_INDEX = 0;
7875
+ var UTILITY_LAYER_INDEX = 1;
7876
+
7869
7877
 
7870
7878
  var REQUIRED_MODEL_ATTRS = {
7871
7879
  shape: [ 'x', 'y', 'width', 'height' ],
@@ -7964,7 +7972,8 @@
7964
7972
  'connection.added',
7965
7973
  'shape.removed',
7966
7974
  'connection.removed',
7967
- 'elements.changed'
7975
+ 'elements.changed',
7976
+ 'plane.set'
7968
7977
  ], function() {
7969
7978
  delete this._cachedViewbox;
7970
7979
  }, this);
@@ -8025,7 +8034,7 @@
8025
8034
  * @returns {SVGElement}
8026
8035
  */
8027
8036
  Canvas.prototype.getDefaultLayer = function() {
8028
- return this.getLayer(BASE_LAYER);
8037
+ return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
8029
8038
  };
8030
8039
 
8031
8040
  /**
@@ -8074,8 +8083,8 @@
8074
8083
  */
8075
8084
  Canvas.prototype._createLayer = function(name, index) {
8076
8085
 
8077
- if (!index) {
8078
- index = 0;
8086
+ if (typeof index === 'undefined') {
8087
+ index = UTILITY_LAYER_INDEX;
8079
8088
  }
8080
8089
 
8081
8090
  var childIndex = reduce(this._layers, function(childIndex, layer) {
@@ -8105,9 +8114,7 @@
8105
8114
  throw new Error('must specify a name');
8106
8115
  }
8107
8116
 
8108
- var plane = this._planes[name];
8109
-
8110
- return plane;
8117
+ return this._planes[name];
8111
8118
  };
8112
8119
 
8113
8120
  /**
@@ -8136,7 +8143,7 @@
8136
8143
  };
8137
8144
  }
8138
8145
 
8139
- var svgLayer = this.getLayer(name);
8146
+ var svgLayer = this.getLayer(name, PLANE_LAYER_INDEX);
8140
8147
  classes$1(svgLayer).add(HIDDEN_MARKER);
8141
8148
 
8142
8149
  var plane = this._planes[name] = {
@@ -8745,9 +8752,10 @@
8745
8752
  if (!box) {
8746
8753
 
8747
8754
  // compute the inner box based on the
8748
- // diagrams default layer. This allows us to exclude
8755
+ // diagrams active plane. This allows us to exclude
8749
8756
  // external components, such as overlays
8750
- innerBox = this.getDefaultLayer().getBBox();
8757
+
8758
+ innerBox = (this._activePlane && this._activePlane.layer.getBBox()) || {};
8751
8759
 
8752
8760
  transform = transform$1(viewport);
8753
8761
  matrix = transform ? transform.matrix : createMatrix();
@@ -8763,10 +8771,10 @@
8763
8771
  height: outerBox.height / scale,
8764
8772
  scale: scale,
8765
8773
  inner: {
8766
- width: innerBox.width,
8767
- height: innerBox.height,
8768
- x: innerBox.x,
8769
- y: innerBox.y
8774
+ width: innerBox.width || 0,
8775
+ height: innerBox.height || 0,
8776
+ x: innerBox.x || 0,
8777
+ y: innerBox.y || 0
8770
8778
  },
8771
8779
  outer: outerBox
8772
8780
  };
@@ -8819,13 +8827,17 @@
8819
8827
  * Scrolls the viewbox to contain the given element.
8820
8828
  * Optionally specify a padding to be applied to the edges.
8821
8829
  *
8822
- * @param {Object} [element] the element to scroll to.
8830
+ * @param {Object|String} [element] the element to scroll to.
8823
8831
  * @param {Object|Number} [padding=100] the padding to be applied. Can also specify top, bottom, left and right.
8824
8832
  *
8825
8833
  */
8826
8834
  Canvas.prototype.scrollToElement = function(element, padding) {
8827
8835
  var defaultPadding = 100;
8828
8836
 
8837
+ if (typeof element === 'string') {
8838
+ element = this._elementRegistry.get(element);
8839
+ }
8840
+
8829
8841
  // switch to correct Plane
8830
8842
  var targetPlane = this.findPlane(element);
8831
8843
  if (targetPlane !== this._activePlane) {