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-modeler v18.1.0
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-20
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
 
@@ -27760,7 +27782,7 @@
27760
27782
  return originalEntries;
27761
27783
  }
27762
27784
 
27763
- if (!value) {
27785
+ if (!value.trim()) {
27764
27786
  return originalEntries.filter(({ rank = 0 }) => rank >= 0);
27765
27787
  }
27766
27788
 
@@ -28637,6 +28659,12 @@
28637
28659
  keys
28638
28660
  } = options;
28639
28661
 
28662
+ pattern = pattern.trim().toLowerCase();
28663
+
28664
+ if (!pattern) {
28665
+ throw new Error('<pattern> must not be empty');
28666
+ }
28667
+
28640
28668
  const words = pattern.trim().toLowerCase().split(/\s+/);
28641
28669
 
28642
28670
  return items.flatMap((item) => {
@@ -28764,22 +28792,33 @@
28764
28792
  }
28765
28793
 
28766
28794
  /**
28767
- * Score a token.
28795
+ * Score a token based on its characteristics
28796
+ * and the length of the matched content.
28768
28797
  *
28769
28798
  * @param { Token } token
28770
28799
  *
28771
28800
  * @returns { number }
28772
28801
  */
28773
28802
  function scoreToken(token) {
28803
+ const modifier = Math.log(token.value.length);
28804
+
28774
28805
  if (!token.match) {
28775
- return 0;
28806
+ return -0.07 * modifier;
28776
28807
  }
28777
28808
 
28778
- return token.start
28779
- ? 1.37
28780
- : token.wordStart
28781
- ? 1.13
28782
- : 1;
28809
+ return (
28810
+ token.start
28811
+ ? (
28812
+ token.end
28813
+ ? 131.9
28814
+ : 7.87
28815
+ )
28816
+ : (
28817
+ token.wordStart
28818
+ ? 2.19
28819
+ : 1
28820
+ )
28821
+ ) * modifier;
28783
28822
  }
28784
28823
 
28785
28824
  /**
@@ -28818,7 +28857,12 @@
28818
28857
  const tokens = [];
28819
28858
  const matchedWords = {};
28820
28859
 
28821
- const regexpString = words.map(escapeRegexp).flatMap(str => [ '(?<wordStart>\\b' + str + ')', str ]).join('|');
28860
+ const wordsEscaped = words.map(escapeRegexp);
28861
+
28862
+ const regexpString = [
28863
+ `(?<all>${wordsEscaped.join('\\s+')})`,
28864
+ ...wordsEscaped
28865
+ ].join('|');
28822
28866
 
28823
28867
  const regexp = new RegExp(regexpString, 'ig');
28824
28868
 
@@ -28829,6 +28873,17 @@
28829
28873
 
28830
28874
  const [ value ] = match;
28831
28875
 
28876
+ const startIndex = match.index;
28877
+ const endIndex = match.index + value.length;
28878
+
28879
+ const start = startIndex === 0;
28880
+ const end = endIndex === string.length;
28881
+
28882
+ const all = !!match.groups.all;
28883
+
28884
+ const wordStart = start || /\s/.test(string.charAt(startIndex - 1));
28885
+ const wordEnd = end || /\s/.test(string.charAt(endIndex + 1));
28886
+
28832
28887
  if (match.index > lastIndex) {
28833
28888
 
28834
28889
  // add previous token (NO match)
@@ -28843,11 +28898,18 @@
28843
28898
  value,
28844
28899
  index: match.index,
28845
28900
  match: true,
28846
- wordStart: !!match.groups.wordStart,
28847
- start: match.index === 0
28901
+ wordStart,
28902
+ wordEnd,
28903
+ start,
28904
+ end,
28905
+ all
28848
28906
  });
28849
28907
 
28850
- matchedWords[value.toLowerCase()] = true;
28908
+ const newMatchedWords = all ? words : [ value ];
28909
+
28910
+ for (const word of newMatchedWords) {
28911
+ matchedWords[word.toLowerCase()] = true;
28912
+ }
28851
28913
 
28852
28914
  lastIndex = match.index + value.length;
28853
28915
  }
@@ -65048,7 +65110,7 @@
65048
65110
  this._clearResults();
65049
65111
 
65050
65112
  // do not search on empty query
65051
- if (!pattern || pattern === '') {
65113
+ if (!pattern.trim()) {
65052
65114
  return;
65053
65115
  }
65054
65116