bpmn-js 18.1.1 → 18.1.2

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-modeler v18.1.1
2
+ * bpmn-js - bpmn-modeler v18.1.2
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: 2024-11-21
11
+ * Date: 2024-12-20
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -4919,6 +4919,7 @@
4919
4919
  * deferUpdate?: boolean;
4920
4920
  * width?: number;
4921
4921
  * height?: number;
4922
+ * autoFocus?: boolean;
4922
4923
  * } } CanvasConfig
4923
4924
  * @typedef { {
4924
4925
  * group: SVGElement;
@@ -5105,18 +5106,20 @@
5105
5106
 
5106
5107
  attr$1(svg, 'tabindex', 0);
5107
5108
 
5108
- eventBus.on('element.hover', () => {
5109
+ config.autoFocus && eventBus.on('element.hover', () => {
5109
5110
  this.restoreFocus();
5110
5111
  });
5111
5112
 
5113
+ eventBus.on('element.mousedown', 500, (event) => {
5114
+ this.focus();
5115
+ });
5116
+
5112
5117
  svg.addEventListener('focusin', () => {
5113
- this._focused = true;
5114
- eventBus.fire('canvas.focus.changed', { focused: true });
5118
+ this._setFocused(true);
5115
5119
  });
5116
5120
 
5117
5121
  svg.addEventListener('focusout', () => {
5118
- this._focused = false;
5119
- eventBus.fire('canvas.focus.changed', { focused: false });
5122
+ this._setFocused(false);
5120
5123
  });
5121
5124
 
5122
5125
  append(container, svg);
@@ -5186,6 +5189,17 @@
5186
5189
  delete this._viewport;
5187
5190
  };
5188
5191
 
5192
+ Canvas.prototype._setFocused = function(focused) {
5193
+
5194
+ if (focused == this._focused) {
5195
+ return;
5196
+ }
5197
+
5198
+ this._focused = focused;
5199
+
5200
+ this._eventBus.fire('canvas.focus.changed', { focused });
5201
+ };
5202
+
5189
5203
  Canvas.prototype._clear = function() {
5190
5204
 
5191
5205
  const allElements = this._elementRegistry.getAll();
@@ -5210,10 +5224,12 @@
5210
5224
  };
5211
5225
 
5212
5226
  /**
5213
- * Sets focus on the canvas SVG element.
5214
- */
5227
+ * Sets focus on the canvas SVG element.
5228
+ */
5215
5229
  Canvas.prototype.focus = function() {
5216
5230
  this._svg.focus({ preventScroll: true });
5231
+
5232
+ this._setFocused(true);
5217
5233
  };
5218
5234
 
5219
5235
  /**
@@ -25940,12 +25956,19 @@
25940
25956
 
25941
25957
  var context;
25942
25958
 
25959
+ function handleMousedown(event) {
25960
+ return handleStart(event.originalEvent);
25961
+ }
25943
25962
 
25944
25963
  // listen for move on element mouse down;
25945
25964
  // allow others to hook into the event before us though
25946
25965
  // (dragging / element moving will do this)
25947
- eventBus.on('element.mousedown', 500, function(e) {
25948
- return handleStart(e.originalEvent);
25966
+ eventBus.on('canvas.focus.changed', function(event) {
25967
+ if (event.focused) {
25968
+ eventBus.on('element.mousedown', 500, handleMousedown);
25969
+ } else {
25970
+ eventBus.off('element.mousedown', handleMousedown);
25971
+ }
25949
25972
  });
25950
25973
 
25951
25974
 
@@ -26133,8 +26156,8 @@
26133
26156
 
26134
26157
  var self = this;
26135
26158
 
26136
- eventBus.on('canvas.init', function(e) {
26137
- self._init(config.enabled !== false);
26159
+ eventBus.on('canvas.focus.changed', function(event) {
26160
+ self._init(event.focused && config.enabled !== false);
26138
26161
  });
26139
26162
  }
26140
26163
 
@@ -26181,8 +26204,7 @@
26181
26204
 
26182
26205
  ZoomScroll.prototype._handleWheel = function handleWheel(event) {
26183
26206
 
26184
- // event is already handled by '.djs-scrollable'
26185
- if (closest(event.target, '.djs-scrollable', true)) {
26207
+ if (!this._canvas.isFocused()) {
26186
26208
  return;
26187
26209
  }
26188
26210