bpmn-js 18.1.0 → 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-navigated-viewer v18.1.0
2
+ * bpmn-js - bpmn-navigated-viewer 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-20
11
+ * Date: 2024-12-20
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -10340,6 +10340,7 @@
10340
10340
  * deferUpdate?: boolean;
10341
10341
  * width?: number;
10342
10342
  * height?: number;
10343
+ * autoFocus?: boolean;
10343
10344
  * } } CanvasConfig
10344
10345
  * @typedef { {
10345
10346
  * group: SVGElement;
@@ -10526,18 +10527,20 @@
10526
10527
 
10527
10528
  attr(svg, 'tabindex', 0);
10528
10529
 
10529
- eventBus.on('element.hover', () => {
10530
+ config.autoFocus && eventBus.on('element.hover', () => {
10530
10531
  this.restoreFocus();
10531
10532
  });
10532
10533
 
10534
+ eventBus.on('element.mousedown', 500, (event) => {
10535
+ this.focus();
10536
+ });
10537
+
10533
10538
  svg.addEventListener('focusin', () => {
10534
- this._focused = true;
10535
- eventBus.fire('canvas.focus.changed', { focused: true });
10539
+ this._setFocused(true);
10536
10540
  });
10537
10541
 
10538
10542
  svg.addEventListener('focusout', () => {
10539
- this._focused = false;
10540
- eventBus.fire('canvas.focus.changed', { focused: false });
10543
+ this._setFocused(false);
10541
10544
  });
10542
10545
 
10543
10546
  append(container, svg);
@@ -10607,6 +10610,17 @@
10607
10610
  delete this._viewport;
10608
10611
  };
10609
10612
 
10613
+ Canvas.prototype._setFocused = function(focused) {
10614
+
10615
+ if (focused == this._focused) {
10616
+ return;
10617
+ }
10618
+
10619
+ this._focused = focused;
10620
+
10621
+ this._eventBus.fire('canvas.focus.changed', { focused });
10622
+ };
10623
+
10610
10624
  Canvas.prototype._clear = function() {
10611
10625
 
10612
10626
  const allElements = this._elementRegistry.getAll();
@@ -10631,10 +10645,12 @@
10631
10645
  };
10632
10646
 
10633
10647
  /**
10634
- * Sets focus on the canvas SVG element.
10635
- */
10648
+ * Sets focus on the canvas SVG element.
10649
+ */
10636
10650
  Canvas.prototype.focus = function() {
10637
10651
  this._svg.focus({ preventScroll: true });
10652
+
10653
+ this._setFocused(true);
10638
10654
  };
10639
10655
 
10640
10656
  /**
@@ -23945,12 +23961,19 @@
23945
23961
 
23946
23962
  var context;
23947
23963
 
23964
+ function handleMousedown(event) {
23965
+ return handleStart(event.originalEvent);
23966
+ }
23948
23967
 
23949
23968
  // listen for move on element mouse down;
23950
23969
  // allow others to hook into the event before us though
23951
23970
  // (dragging / element moving will do this)
23952
- eventBus.on('element.mousedown', 500, function(e) {
23953
- return handleStart(e.originalEvent);
23971
+ eventBus.on('canvas.focus.changed', function(event) {
23972
+ if (event.focused) {
23973
+ eventBus.on('element.mousedown', 500, handleMousedown);
23974
+ } else {
23975
+ eventBus.off('element.mousedown', handleMousedown);
23976
+ }
23954
23977
  });
23955
23978
 
23956
23979
 
@@ -24138,8 +24161,8 @@
24138
24161
 
24139
24162
  var self = this;
24140
24163
 
24141
- eventBus.on('canvas.init', function(e) {
24142
- self._init(config.enabled !== false);
24164
+ eventBus.on('canvas.focus.changed', function(event) {
24165
+ self._init(event.focused && config.enabled !== false);
24143
24166
  });
24144
24167
  }
24145
24168
 
@@ -24186,8 +24209,7 @@
24186
24209
 
24187
24210
  ZoomScroll.prototype._handleWheel = function handleWheel(event) {
24188
24211
 
24189
- // event is already handled by '.djs-scrollable'
24190
- if (closest(event.target, '.djs-scrollable', true)) {
24212
+ if (!this._canvas.isFocused()) {
24191
24213
  return;
24192
24214
  }
24193
24215