bpmn-js 17.9.2 → 17.11.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.
Files changed (39) hide show
  1. package/README.md +2 -0
  2. package/dist/assets/diagram-js.css +51 -46
  3. package/dist/bpmn-modeler.development.js +611 -273
  4. package/dist/bpmn-modeler.production.min.js +37 -37
  5. package/dist/bpmn-navigated-viewer.development.js +43 -21
  6. package/dist/bpmn-navigated-viewer.production.min.js +2 -2
  7. package/dist/bpmn-viewer.development.js +43 -21
  8. package/dist/bpmn-viewer.production.min.js +2 -2
  9. package/lib/draw/BpmnRenderer.d.ts +8 -6
  10. package/lib/draw/BpmnRenderer.js +19 -17
  11. package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +1 -1
  12. package/lib/features/align-elements/AlignElementsContextPadProvider.js +1 -1
  13. package/lib/features/append-preview/AppendPreview.d.ts +2 -2
  14. package/lib/features/append-preview/AppendPreview.js +2 -2
  15. package/lib/features/auto-place/BpmnAutoPlace.d.ts +3 -1
  16. package/lib/features/auto-place/BpmnAutoPlace.js +5 -3
  17. package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +9 -4
  18. package/lib/features/auto-place/BpmnAutoPlaceUtil.js +14 -13
  19. package/lib/features/context-pad/ContextPadProvider.d.ts +3 -14
  20. package/lib/features/context-pad/ContextPadProvider.js +3 -1
  21. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +3 -1
  22. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.js +6 -3
  23. package/lib/features/label-editing/LabelEditingPreview.js +2 -1
  24. package/lib/features/modeling/BpmnLayouter.d.ts +13 -9
  25. package/lib/features/modeling/BpmnLayouter.js +10 -3
  26. package/lib/features/modeling/Modeling.d.ts +1 -1
  27. package/lib/features/modeling/Modeling.js +1 -1
  28. package/lib/features/modeling/behavior/ResizeBehavior.js +25 -19
  29. package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.d.ts +16 -0
  30. package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.js +67 -0
  31. package/lib/features/modeling/behavior/index.js +5 -2
  32. package/lib/features/modeling/util/ModelingUtil.d.ts +3 -1
  33. package/lib/features/modeling/util/ModelingUtil.js +38 -4
  34. package/lib/features/outline/OutlineProvider.d.ts +5 -0
  35. package/lib/features/outline/OutlineProvider.js +10 -0
  36. package/lib/features/outline/OutlineUtil.d.ts +5 -0
  37. package/lib/features/outline/OutlineUtil.js +4 -0
  38. package/lib/features/search/BpmnSearchProvider.js +114 -47
  39. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v17.9.2
2
+ * bpmn-js - bpmn-modeler v17.11.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: 2024-08-05
11
+ * Date: 2024-09-12
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -94,9 +94,9 @@
94
94
  *
95
95
  * @param {Seed} seed
96
96
  */
97
- function Ids(seed) {
98
- if (!(this instanceof Ids)) {
99
- return new Ids(seed);
97
+ function Ids$1(seed) {
98
+ if (!(this instanceof Ids$1)) {
99
+ return new Ids$1(seed);
100
100
  }
101
101
  seed = seed || [128, 36, 1];
102
102
  this._seed = seed.length ? hat_1.rack(seed[0], seed[1], seed[2]) : seed;
@@ -109,7 +109,7 @@
109
109
  *
110
110
  * @return {String} id
111
111
  */
112
- Ids.prototype.next = function (element) {
112
+ Ids$1.prototype.next = function (element) {
113
113
  return this._seed(element || true);
114
114
  };
115
115
 
@@ -120,7 +120,7 @@
120
120
  *
121
121
  * @return {String} id
122
122
  */
123
- Ids.prototype.nextPrefixed = function (prefix, element) {
123
+ Ids$1.prototype.nextPrefixed = function (prefix, element) {
124
124
  var id;
125
125
  do {
126
126
  id = prefix + this.next(true);
@@ -139,7 +139,7 @@
139
139
  * @param {String} id
140
140
  * @param {String} [element] element the id is claimed by
141
141
  */
142
- Ids.prototype.claim = function (id, element) {
142
+ Ids$1.prototype.claim = function (id, element) {
143
143
  this._seed.set(id, element || true);
144
144
  };
145
145
 
@@ -149,7 +149,7 @@
149
149
  * @param {String} id
150
150
  * @return {Boolean}
151
151
  */
152
- Ids.prototype.assigned = function (id) {
152
+ Ids$1.prototype.assigned = function (id) {
153
153
  return this._seed.get(id) || false;
154
154
  };
155
155
 
@@ -158,14 +158,14 @@
158
158
  *
159
159
  * @param {String} id the id to unclaim
160
160
  */
161
- Ids.prototype.unclaim = function (id) {
161
+ Ids$1.prototype.unclaim = function (id) {
162
162
  delete this._seed.hats[id];
163
163
  };
164
164
 
165
165
  /**
166
166
  * Clear all claimed ids.
167
167
  */
168
- Ids.prototype.clear = function () {
168
+ Ids$1.prototype.clear = function () {
169
169
  var hats = this._seed.hats,
170
170
  id;
171
171
  for (id in hats) {
@@ -5432,6 +5432,8 @@
5432
5432
  element = this._elementRegistry.get(element);
5433
5433
  }
5434
5434
 
5435
+ element.markers = element.markers || new Set();
5436
+
5435
5437
  // we need to access all
5436
5438
  container = this._elementRegistry._elements[element.id];
5437
5439
 
@@ -5444,8 +5446,10 @@
5444
5446
 
5445
5447
  // invoke either addClass or removeClass based on mode
5446
5448
  if (add) {
5449
+ element.markers.add(marker);
5447
5450
  classes(gfx).add(marker);
5448
5451
  } else {
5452
+ element.markers.delete(marker);
5449
5453
  classes(gfx).remove(marker);
5450
5454
  }
5451
5455
  }
@@ -5513,9 +5517,11 @@
5513
5517
  element = this._elementRegistry.get(element);
5514
5518
  }
5515
5519
 
5516
- const gfx = this.getGraphics(element);
5520
+ if (!element.markers) {
5521
+ return false;
5522
+ }
5517
5523
 
5518
- return classes(gfx).has(marker);
5524
+ return element.markers.has(marker);
5519
5525
  };
5520
5526
 
5521
5527
  /**
@@ -17873,7 +17879,7 @@
17873
17879
 
17874
17880
  // attach ids to moddle to be able to track and validated ids in the BPMN 2.0
17875
17881
  // XML document tree
17876
- moddle.ids = new Ids([ 32, 36, 1 ]);
17882
+ moddle.ids = new Ids$1([ 32, 36, 1 ]);
17877
17883
 
17878
17884
  return moddle;
17879
17885
  };
@@ -18491,7 +18497,7 @@
18491
18497
  return has$1(overrides, 'height') ? overrides.height : bounds.height;
18492
18498
  }
18493
18499
 
18494
- var markerIds = new Ids();
18500
+ var markerIds = new Ids$1();
18495
18501
 
18496
18502
  var ELEMENT_LABEL_DISTANCE$1 = 10,
18497
18503
  INNER_OUTER_DIST = 3,
@@ -18519,6 +18525,8 @@
18519
18525
 
18520
18526
  /**
18521
18527
  * @typedef { import('../model/Types').Element } Element
18528
+ * @typedef { import('../model/Types').Shape } Shape
18529
+ * @typedef { import('../model/Types').Connection } Connection
18522
18530
  */
18523
18531
 
18524
18532
  /**
@@ -20692,57 +20700,57 @@
20692
20700
  * Draw shape into parentGfx.
20693
20701
  *
20694
20702
  * @param {SVGElement} parentGfx
20695
- * @param {Element} element
20703
+ * @param {Shape} shape
20696
20704
  * @param {Attrs} [attrs]
20697
20705
  *
20698
20706
  * @return {SVGElement} mainGfx
20699
20707
  */
20700
- BpmnRenderer.prototype.drawShape = function(parentGfx, element, attrs = {}) {
20701
- var { type } = element;
20708
+ BpmnRenderer.prototype.drawShape = function(parentGfx, shape, attrs = {}) {
20709
+ var { type } = shape;
20702
20710
 
20703
20711
  var handler = this._renderer(type);
20704
20712
 
20705
- return handler(parentGfx, element, attrs);
20713
+ return handler(parentGfx, shape, attrs);
20706
20714
  };
20707
20715
 
20708
20716
  /**
20709
20717
  * Draw connection into parentGfx.
20710
20718
  *
20711
20719
  * @param {SVGElement} parentGfx
20712
- * @param {Element} element
20720
+ * @param {Connection} connection
20713
20721
  * @param {Attrs} [attrs]
20714
20722
  *
20715
20723
  * @return {SVGElement} mainGfx
20716
20724
  */
20717
- BpmnRenderer.prototype.drawConnection = function(parentGfx, element, attrs = {}) {
20718
- var { type } = element;
20725
+ BpmnRenderer.prototype.drawConnection = function(parentGfx, connection, attrs = {}) {
20726
+ var { type } = connection;
20719
20727
 
20720
20728
  var handler = this._renderer(type);
20721
20729
 
20722
- return handler(parentGfx, element, attrs);
20730
+ return handler(parentGfx, connection, attrs);
20723
20731
  };
20724
20732
 
20725
20733
  /**
20726
20734
  * Get shape path.
20727
20735
  *
20728
- * @param {Element} element
20736
+ * @param {Shape} shape
20729
20737
  *
20730
20738
  * @return {string} path
20731
20739
  */
20732
- BpmnRenderer.prototype.getShapePath = function(element) {
20733
- if (is$1(element, 'bpmn:Event')) {
20734
- return getCirclePath(element);
20740
+ BpmnRenderer.prototype.getShapePath = function(shape) {
20741
+ if (is$1(shape, 'bpmn:Event')) {
20742
+ return getCirclePath(shape);
20735
20743
  }
20736
20744
 
20737
- if (is$1(element, 'bpmn:Activity')) {
20738
- return getRoundRectPath(element, TASK_BORDER_RADIUS);
20745
+ if (is$1(shape, 'bpmn:Activity')) {
20746
+ return getRoundRectPath(shape, TASK_BORDER_RADIUS);
20739
20747
  }
20740
20748
 
20741
- if (is$1(element, 'bpmn:Gateway')) {
20742
- return getDiamondPath(element);
20749
+ if (is$1(shape, 'bpmn:Gateway')) {
20750
+ return getDiamondPath(shape);
20743
20751
  }
20744
20752
 
20745
- return getRectPath(element);
20753
+ return getRectPath(shape);
20746
20754
  };
20747
20755
 
20748
20756
  /**
@@ -24359,6 +24367,10 @@
24359
24367
  const DATA_OBJECT_REFERENCE_OUTLINE_PATH = 'M44.7648 11.3263L36.9892 2.64074C36.0451 1.58628 34.5651 0.988708 33.1904 0.988708H5.98667C3.22688 0.988708 0.989624 3.34892 0.989624 6.26039V55.0235C0.989624 57.9349 3.22688 60.2952 5.98667 60.2952H40.966C43.7257 60.2952 45.963 57.9349 45.963 55.0235V14.9459C45.963 13.5998 45.6407 12.3048 44.7648 11.3263Z';
24360
24368
  const DATA_STORE_REFERENCE_OUTLINE_PATH = 'M1.03845 48.1347C1.03845 49.3511 1.07295 50.758 1.38342 52.064C1.69949 53.3938 2.32428 54.7154 3.56383 55.6428C6.02533 57.4841 10.1161 58.7685 14.8212 59.6067C19.5772 60.4538 25.1388 60.8738 30.6831 60.8738C36.2276 60.8738 41.7891 60.4538 46.545 59.6067C51.2504 58.7687 55.3412 57.4842 57.8028 55.6429C59.0424 54.7156 59.6673 53.3938 59.9834 52.064C60.2938 50.7579 60.3285 49.351 60.3285 48.1344V13.8415C60.3285 12.6249 60.2938 11.218 59.9834 9.91171C59.6673 8.58194 59.0423 7.2602 57.8027 6.33294C55.341 4.49168 51.2503 3.20723 46.545 2.36914C41.7891 1.522 36.2276 1.10204 30.6831 1.10205C25.1388 1.10206 19.5772 1.52206 14.8213 2.36923C10.1162 3.20734 6.02543 4.49183 3.5639 6.33314C2.32433 7.26038 1.69951 8.58206 1.38343 9.91181C1.07295 11.2179 1.03845 12.6247 1.03845 13.8411V48.1347Z';
24361
24369
 
24370
+ /**
24371
+ * @typedef { import('diagram-js/lib/util/Types').Dimensions} Dimensions
24372
+ */
24373
+
24362
24374
  /**
24363
24375
  * @type {Dimensions}
24364
24376
  */
@@ -24385,6 +24397,16 @@
24385
24397
  });
24386
24398
  }
24387
24399
 
24400
+ /**
24401
+ * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').default } BaseOutlineProvider
24402
+ *
24403
+ * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').Outline } Outline
24404
+ *
24405
+ * @typedef { import('diagram-js/lib/draw/Styles').default } Styles
24406
+ *
24407
+ * @typedef { import('diagram-js/lib/model/Types').Element } Element
24408
+ */
24409
+
24388
24410
  const DEFAULT_OFFSET = 5;
24389
24411
 
24390
24412
  /**
@@ -26946,6 +26968,133 @@
26946
26968
  alignElements: [ 'type', AlignElements$1 ]
26947
26969
  };
26948
26970
 
26971
+ const Ids = new IdGenerator();
26972
+
26973
+
26974
+ /**
26975
+ * @typedef { {
26976
+ * promise: Promise<unknown>,
26977
+ * executionId: number
26978
+ * } } ScheduledTask
26979
+ */
26980
+
26981
+ /**
26982
+ * A utility that allows you to schedule async tasks.
26983
+ *
26984
+ * @class
26985
+ * @constructor
26986
+ *
26987
+ * @param { import('../core/EventBus').default } eventBus
26988
+ */
26989
+ function Scheduler(eventBus) {
26990
+
26991
+ /**
26992
+ * @type { Record<string, ScheduledTask> }
26993
+ */
26994
+ this._scheduled = {};
26995
+
26996
+ eventBus.on('diagram.destroy', () => {
26997
+ Object.keys(this._scheduled).forEach(id => {
26998
+ this.cancel(id);
26999
+ });
27000
+ });
27001
+ }
27002
+
27003
+ Scheduler.$inject = [ 'eventBus' ];
27004
+
27005
+ /**
27006
+ * Schedule execution of a task in the next tick.
27007
+ *
27008
+ * Call with an id to ensure only the latest call will be executed.
27009
+ *
27010
+ * @template T
27011
+
27012
+ * @param {(...args: any[]) => T} taskFn function to be executed
27013
+ * @param {string} [id] identifying the task to ensure uniqueness
27014
+ *
27015
+ * @return Promise<T> result of the executed task
27016
+ */
27017
+ Scheduler.prototype.schedule = function(taskFn, id = Ids.next()) {
27018
+
27019
+ this.cancel(id);
27020
+
27021
+ const newScheduled = this._schedule(taskFn, id);
27022
+
27023
+ this._scheduled[id] = newScheduled;
27024
+
27025
+ return newScheduled.promise;
27026
+ };
27027
+
27028
+ Scheduler.prototype._schedule = function(taskFn, id) {
27029
+
27030
+ const {
27031
+ promise,
27032
+ resolve,
27033
+ reject
27034
+ } = defer();
27035
+
27036
+ const executionId = requestAnimationFrame(() => {
27037
+ try {
27038
+ resolve(taskFn());
27039
+ } catch (error) {
27040
+ reject(error);
27041
+ }
27042
+ });
27043
+
27044
+ return {
27045
+ executionId,
27046
+ promise
27047
+ };
27048
+ };
27049
+
27050
+ /**
27051
+ * Cancel a previously scheduled task.
27052
+ *
27053
+ * @param {string} id
27054
+ */
27055
+ Scheduler.prototype.cancel = function(id) {
27056
+
27057
+ const scheduled = this._scheduled[id];
27058
+
27059
+ if (scheduled) {
27060
+ this._cancel(scheduled);
27061
+
27062
+ this._scheduled[id] = null;
27063
+ }
27064
+ };
27065
+
27066
+ Scheduler.prototype._cancel = function(scheduled) {
27067
+ cancelAnimationFrame(scheduled.executionId);
27068
+ };
27069
+
27070
+ /**
27071
+ * @return { {
27072
+ * promise: Promise,
27073
+ * resolve: Function,
27074
+ * reject: Function
27075
+ * } }
27076
+ */
27077
+ function defer() {
27078
+
27079
+ let resolve;
27080
+ let reject;
27081
+
27082
+ const promise = new Promise((_resolve, _reject) => {
27083
+ resolve = _resolve;
27084
+ reject = _reject;
27085
+ });
27086
+
27087
+ return {
27088
+ promise,
27089
+ resolve,
27090
+ reject
27091
+ };
27092
+ }
27093
+
27094
+ var SchedulerModule = {
27095
+ scheduler: [ 'type', Scheduler ]
27096
+ };
27097
+
26949
27098
  var MARKER_HIDDEN$1 = 'djs-element-hidden';
26950
27099
 
26951
27100
  /**
@@ -26957,6 +27106,7 @@
26957
27106
  * @typedef {import('../../core/Canvas').default} Canvas
26958
27107
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
26959
27108
  * @typedef {import('../../core/EventBus').default} EventBus
27109
+ * @typedef {import('../../scheduler/Scheduler').default} Scheduler
26960
27110
  *
26961
27111
  * @typedef {import('./ContextPadProvider').default} ContextPadProvider
26962
27112
  * @typedef {import('./ContextPadProvider').ContextPadEntries} ContextPadEntries
@@ -26982,12 +27132,14 @@
26982
27132
  * @param {Canvas} canvas
26983
27133
  * @param {ElementRegistry} elementRegistry
26984
27134
  * @param {EventBus} eventBus
27135
+ * @param {Scheduler} scheduler
26985
27136
  */
26986
- function ContextPad(canvas, elementRegistry, eventBus) {
27137
+ function ContextPad(canvas, elementRegistry, eventBus, scheduler) {
26987
27138
 
26988
27139
  this._canvas = canvas;
26989
27140
  this._elementRegistry = elementRegistry;
26990
27141
  this._eventBus = eventBus;
27142
+ this._scheduler = scheduler;
26991
27143
 
26992
27144
  this._current = null;
26993
27145
 
@@ -26997,7 +27149,8 @@
26997
27149
  ContextPad.$inject = [
26998
27150
  'canvas',
26999
27151
  'elementRegistry',
27000
- 'eventBus'
27152
+ 'eventBus',
27153
+ 'scheduler'
27001
27154
  ];
27002
27155
 
27003
27156
 
@@ -27032,12 +27185,12 @@
27032
27185
  return;
27033
27186
  }
27034
27187
 
27035
- var { target } = current;
27188
+ var target = current.target;
27036
27189
 
27037
27190
  var targets = isArray$3(target) ? target : [ target ];
27038
27191
 
27039
27192
  var targetsChanged = targets.filter(function(element) {
27040
- return includes$7(elements, element);
27193
+ return elements.includes(element);
27041
27194
  });
27042
27195
 
27043
27196
  if (targetsChanged.length) {
@@ -27058,11 +27211,25 @@
27058
27211
  }
27059
27212
  });
27060
27213
 
27061
- this._eventBus.on('canvas.viewbox.changed', () => {
27062
- this._updatePosition();
27214
+ this._eventBus.on('canvas.viewbox.changed', function() {
27215
+ self._updatePosition();
27063
27216
  });
27064
27217
 
27065
27218
  this._eventBus.on('element.marker.update', function(event) {
27219
+ if (!self.isOpen()) {
27220
+ return;
27221
+ }
27222
+
27223
+ var element = event.element;
27224
+
27225
+ var current = self._current;
27226
+
27227
+ var targets = isArray$3(current.target) ? current.target : [ current.target ];
27228
+
27229
+ if (!targets.includes(element)) {
27230
+ return;
27231
+ }
27232
+
27066
27233
  self._updateVisibility();
27067
27234
  });
27068
27235
 
@@ -27070,7 +27237,7 @@
27070
27237
  };
27071
27238
 
27072
27239
  ContextPad.prototype._createContainer = function() {
27073
- const container = domify$1('<div class="djs-context-pad-parent"></div>');
27240
+ var container = domify$1('<div class="djs-context-pad-parent"></div>');
27074
27241
 
27075
27242
  this._canvas.getContainer().appendChild(container);
27076
27243
 
@@ -27154,6 +27321,7 @@
27154
27321
  * @param {boolean} [autoActivate=false]
27155
27322
  */
27156
27323
  ContextPad.prototype.trigger = function(action, event, autoActivate) {
27324
+ var self = this;
27157
27325
 
27158
27326
  var entry,
27159
27327
  originalEvent,
@@ -27167,8 +27335,8 @@
27167
27335
  originalEvent = event.originalEvent || event;
27168
27336
 
27169
27337
  if (action === 'mouseover') {
27170
- this._timeout = setTimeout(() => {
27171
- this._mouseout = this.triggerEntry(entry, 'hover', originalEvent, autoActivate);
27338
+ this._timeout = setTimeout(function() {
27339
+ self._mouseout = self.triggerEntry(entry, 'hover', originalEvent, autoActivate);
27172
27340
  }, HOVER_DELAY);
27173
27341
 
27174
27342
  return;
@@ -27429,7 +27597,7 @@
27429
27597
  return (
27430
27598
  target.length === currentTarget.length &&
27431
27599
  every(target, function(element) {
27432
- return includes$7(currentTarget, element);
27600
+ return currentTarget.includes(element);
27433
27601
  })
27434
27602
  );
27435
27603
  } else {
@@ -27489,12 +27657,12 @@
27489
27657
  */
27490
27658
  ContextPad.prototype._getPosition = function(target) {
27491
27659
  if (!isArray$3(target) && isConnection(target)) {
27492
- const viewbox = this._canvas.viewbox();
27660
+ var viewbox = this._canvas.viewbox();
27493
27661
 
27494
- const lastWaypoint = getLastWaypoint(target);
27662
+ var lastWaypoint = getLastWaypoint(target);
27495
27663
 
27496
- const x = lastWaypoint.x * viewbox.scale - viewbox.x * viewbox.scale,
27497
- y = lastWaypoint.y * viewbox.scale - viewbox.y * viewbox.scale;
27664
+ var x = lastWaypoint.x * viewbox.scale - viewbox.x * viewbox.scale,
27665
+ y = lastWaypoint.y * viewbox.scale - viewbox.y * viewbox.scale;
27498
27666
 
27499
27667
  return {
27500
27668
  left: x + CONTEXT_PAD_MARGIN * this._canvas.zoom(),
@@ -27518,29 +27686,34 @@
27518
27686
  * Update context pad position.
27519
27687
  */
27520
27688
  ContextPad.prototype._updatePosition = function() {
27521
- if (!this.isOpen()) {
27522
- return;
27523
- }
27524
27689
 
27525
- var html = this._current.html;
27690
+ const updateFn = () => {
27691
+ if (!this.isOpen()) {
27692
+ return;
27693
+ }
27526
27694
 
27527
- var position = this._getPosition(this._current.target);
27695
+ var html = this._current.html;
27528
27696
 
27529
- if ('x' in position && 'y' in position) {
27530
- html.style.left = position.x + 'px';
27531
- html.style.top = position.y + 'px';
27532
- } else {
27533
- [
27534
- 'top',
27535
- 'right',
27536
- 'bottom',
27537
- 'left'
27538
- ].forEach(function(key) {
27539
- if (key in position) {
27540
- html.style[ key ] = position[ key ] + 'px';
27541
- }
27542
- });
27543
- }
27697
+ var position = this._getPosition(this._current.target);
27698
+
27699
+ if ('x' in position && 'y' in position) {
27700
+ html.style.left = position.x + 'px';
27701
+ html.style.top = position.y + 'px';
27702
+ } else {
27703
+ [
27704
+ 'top',
27705
+ 'right',
27706
+ 'bottom',
27707
+ 'left'
27708
+ ].forEach(function(key) {
27709
+ if (key in position) {
27710
+ html.style[ key ] = position[ key ] + 'px';
27711
+ }
27712
+ });
27713
+ }
27714
+ };
27715
+
27716
+ this._scheduler.schedule(updateFn, 'ContextPad#_updatePosition');
27544
27717
  };
27545
27718
 
27546
27719
  /**
@@ -27548,25 +27721,30 @@
27548
27721
  * using the `djs-element-hidden` or `djs-label-hidden` markers.
27549
27722
  */
27550
27723
  ContextPad.prototype._updateVisibility = function() {
27551
- if (!this.isOpen()) {
27552
- return;
27553
- }
27554
27724
 
27555
- var self = this;
27725
+ const updateFn = () => {
27726
+ if (!this.isOpen()) {
27727
+ return;
27728
+ }
27556
27729
 
27557
- var target = this._current.target;
27730
+ var self = this;
27558
27731
 
27559
- var targets = isArray$3(target) ? target : [ target ];
27732
+ var target = this._current.target;
27560
27733
 
27561
- var isHidden = targets.some(function(target) {
27562
- return self._canvas.hasMarker(target, MARKER_HIDDEN$1);
27563
- });
27734
+ var targets = isArray$3(target) ? target : [ target ];
27564
27735
 
27565
- if (isHidden) {
27566
- self.hide();
27567
- } else {
27568
- self.show();
27569
- }
27736
+ var isHidden = targets.some(function(target) {
27737
+ return self._canvas.hasMarker(target, MARKER_HIDDEN$1);
27738
+ });
27739
+
27740
+ if (isHidden) {
27741
+ self.hide();
27742
+ } else {
27743
+ self.show();
27744
+ }
27745
+ };
27746
+
27747
+ this._scheduler.schedule(updateFn, 'ContextPad#_updateVisibility');
27570
27748
  };
27571
27749
 
27572
27750
  /**
@@ -27577,13 +27755,15 @@
27577
27755
  * @returns {Rect & RectTRBL}
27578
27756
  */
27579
27757
  ContextPad.prototype._getTargetBounds = function(target) {
27758
+ var self = this;
27759
+
27580
27760
  var elements = isArray$3(target) ? target : [ target ];
27581
27761
 
27582
- var elementsGfx = elements.map((element) => {
27583
- return this._canvas.getGraphics(element);
27762
+ var elementsGfx = elements.map(function(element) {
27763
+ return self._canvas.getGraphics(element);
27584
27764
  });
27585
27765
 
27586
- return elementsGfx.reduce((bounds, elementGfx) => {
27766
+ return elementsGfx.reduce(function(bounds, elementGfx) {
27587
27767
  const elementBounds = elementGfx.getBoundingClientRect();
27588
27768
 
27589
27769
  bounds.top = Math.min(bounds.top, elementBounds.top);
@@ -27618,16 +27798,6 @@
27618
27798
  });
27619
27799
  }
27620
27800
 
27621
- /**
27622
- * @param {any[]} array
27623
- * @param {any} item
27624
- *
27625
- * @return {boolean}
27626
- */
27627
- function includes$7(array, item) {
27628
- return array.indexOf(item) !== -1;
27629
- }
27630
-
27631
27801
  function getLastWaypoint(connection) {
27632
27802
  return connection.waypoints[connection.waypoints.length - 1];
27633
27803
  }
@@ -27654,6 +27824,7 @@
27654
27824
  var ContextPadModule$1 = {
27655
27825
  __depends__: [
27656
27826
  InteractionEventsModule$1,
27827
+ SchedulerModule,
27657
27828
  OverlaysModule
27658
27829
  ],
27659
27830
  contextPad: [ 'type', ContextPad ]
@@ -28898,7 +29069,7 @@
28898
29069
  *
28899
29070
  * @typedef {import('../../model/Types').Element} Element
28900
29071
  * @typedef {import('diagram-js/lib/features/context-pad/ContextPad').ContextPadEntries} ContextPadEntries
28901
- * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default} ContextPadProvider
29072
+ * @typedef {import('diagram-js/lib/features/context-pad/ContextPadProvider').default<Element>} ContextPadProvider
28902
29073
  */
28903
29074
 
28904
29075
  var LOW_PRIORITY$l = 900;
@@ -29673,6 +29844,7 @@
29673
29844
  };
29674
29845
 
29675
29846
  /**
29847
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
29676
29848
  * @typedef {import('../../../model/Types').Element} Element
29677
29849
  */
29678
29850
 
@@ -29703,26 +29875,56 @@
29703
29875
  * Determines if the local modeling direction is vertical or horizontal.
29704
29876
  *
29705
29877
  * @param {Element} element
29878
+ * @param {ElementRegistry} [elementRegistry] - provide to consider parent diagram direction
29706
29879
  *
29707
29880
  * @return {boolean} false for vertical pools, lanes and their children. true otherwise
29708
29881
  */
29709
- function isDirectionHorizontal(element) {
29882
+ function isDirectionHorizontal(element, elementRegistry) {
29883
+
29884
+ var parent = getParent(element, 'bpmn:Process');
29885
+ if (parent) {
29886
+ return true;
29887
+ }
29710
29888
 
29711
29889
  var types = [ 'bpmn:Participant', 'bpmn:Lane' ];
29712
29890
 
29713
- var parent = getParent(element, types);
29891
+ parent = getParent(element, types);
29714
29892
  if (parent) {
29715
29893
  return isHorizontal$3(parent);
29716
29894
  } else if (isAny(element, types)) {
29717
29895
  return isHorizontal$3(element);
29718
29896
  }
29719
29897
 
29720
- return true;
29898
+ var process;
29899
+ for (process = getBusinessObject(element); process; process = process.$parent) {
29900
+ if (is$1(process, 'bpmn:Process')) {
29901
+ break;
29902
+ }
29903
+ }
29904
+
29905
+ if (!elementRegistry) {
29906
+ return true;
29907
+ }
29908
+
29909
+ // The direction may be specified in another diagram. We ignore that there
29910
+ // could be multiple diagrams with contradicting properties based on the
29911
+ // assumption that such BPMN files are unusual.
29912
+ var pool = elementRegistry.find(function(shape) {
29913
+ var businessObject = getBusinessObject(shape);
29914
+ return businessObject && businessObject.get('processRef') === process;
29915
+ });
29916
+
29917
+ if (!pool) {
29918
+ return true;
29919
+ }
29920
+
29921
+ return isHorizontal$3(pool);
29721
29922
  }
29722
29923
 
29723
29924
  /**
29724
29925
  * @typedef {import('../../model/Types').Shape} Shape
29725
29926
  *
29927
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
29726
29928
  * @typedef {import('diagram-js/lib/util/Types').Point} Point
29727
29929
  * @typedef {import('diagram-js/lib/util/Types').DirectionTRBL} DirectionTRBL
29728
29930
  */
@@ -29733,21 +29935,24 @@
29733
29935
  *
29734
29936
  * @param {Shape} source
29735
29937
  * @param {Shape} element
29938
+ * @param {ElementRegistry} elementRegistry
29736
29939
  *
29737
29940
  * @return {Point}
29738
29941
  */
29739
- function getNewShapePosition(source, element) {
29942
+ function getNewShapePosition(source, element, elementRegistry) {
29943
+
29944
+ var placeHorizontally = isDirectionHorizontal(source, elementRegistry);
29740
29945
 
29741
29946
  if (is$1(element, 'bpmn:TextAnnotation')) {
29742
- return getTextAnnotationPosition(source, element);
29947
+ return getTextAnnotationPosition(source, element, placeHorizontally);
29743
29948
  }
29744
29949
 
29745
29950
  if (isAny(element, [ 'bpmn:DataObjectReference', 'bpmn:DataStoreReference' ])) {
29746
- return getDataElementPosition(source, element);
29951
+ return getDataElementPosition(source, element, placeHorizontally);
29747
29952
  }
29748
29953
 
29749
29954
  if (is$1(element, 'bpmn:FlowNode')) {
29750
- return getFlowNodePosition(source, element);
29955
+ return getFlowNodePosition(source, element, placeHorizontally);
29751
29956
  }
29752
29957
  }
29753
29958
 
@@ -29757,16 +29962,15 @@
29757
29962
  *
29758
29963
  * @param {Shape} source
29759
29964
  * @param {Shape} element
29965
+ * @param {boolean} placeHorizontally Whether to place the new element horizontally
29760
29966
  *
29761
29967
  * @return {Point}
29762
29968
  */
29763
- function getFlowNodePosition(source, element) {
29969
+ function getFlowNodePosition(source, element, placeHorizontally) {
29764
29970
 
29765
29971
  var sourceTrbl = asTRBL(source);
29766
29972
  var sourceMid = getMid(source);
29767
29973
 
29768
- var placeHorizontally = isDirectionHorizontal(source);
29769
-
29770
29974
  var placement = placeHorizontally ? {
29771
29975
  directionHint: 'e',
29772
29976
  minDistance: 80,
@@ -29848,15 +30052,14 @@
29848
30052
  *
29849
30053
  * @param {Shape} source
29850
30054
  * @param {Shape} element
30055
+ * @param {boolean} placeHorizontally Whether to place the new element horizontally
29851
30056
  *
29852
30057
  * @return {Point}
29853
30058
  */
29854
- function getTextAnnotationPosition(source, element) {
30059
+ function getTextAnnotationPosition(source, element, placeHorizontally) {
29855
30060
 
29856
30061
  var sourceTrbl = asTRBL(source);
29857
30062
 
29858
- var placeHorizontally = isDirectionHorizontal(source);
29859
-
29860
30063
  var position = placeHorizontally ? {
29861
30064
  x: sourceTrbl.right + element.width / 2,
29862
30065
  y: sourceTrbl.top - 50 - element.height / 2
@@ -29896,15 +30099,14 @@
29896
30099
  *
29897
30100
  * @param {Shape} source
29898
30101
  * @param {Shape} element
30102
+ * @param {boolean} placeHorizontally Whether to place the new element horizontally
29899
30103
  *
29900
30104
  * @return {Point}
29901
30105
  */
29902
- function getDataElementPosition(source, element) {
30106
+ function getDataElementPosition(source, element, placeHorizontally) {
29903
30107
 
29904
30108
  var sourceTrbl = asTRBL(source);
29905
30109
 
29906
- var placeHorizontally = isDirectionHorizontal(source);
29907
-
29908
30110
  var position = placeHorizontally ? {
29909
30111
  x: sourceTrbl.right - 10 + element.width / 2,
29910
30112
  y: sourceTrbl.bottom + 40 + element.width / 2
@@ -29928,23 +30130,25 @@
29928
30130
 
29929
30131
  /**
29930
30132
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
30133
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
29931
30134
  */
29932
30135
 
29933
30136
  /**
29934
30137
  * BPMN auto-place behavior.
29935
30138
  *
29936
30139
  * @param {EventBus} eventBus
30140
+ * @param {ElementRegistry} elementRegistry
29937
30141
  */
29938
- function AutoPlace(eventBus) {
30142
+ function AutoPlace(eventBus, elementRegistry) {
29939
30143
  eventBus.on('autoPlace', function(context) {
29940
30144
  var shape = context.shape,
29941
30145
  source = context.source;
29942
30146
 
29943
- return getNewShapePosition(source, shape);
30147
+ return getNewShapePosition(source, shape, elementRegistry);
29944
30148
  });
29945
30149
  }
29946
30150
 
29947
- AutoPlace.$inject = [ 'eventBus' ];
30151
+ AutoPlace.$inject = [ 'eventBus', 'elementRegistry' ];
29948
30152
 
29949
30153
  var AutoPlaceModule = {
29950
30154
  __depends__: [ AutoPlaceModule$1 ],
@@ -34937,7 +35141,7 @@
34937
35141
  const source = context.source,
34938
35142
  target = context.target;
34939
35143
 
34940
- if (isCompensationBoundaryEvent(source) && isForCompensation$1(target)) {
35144
+ if (isCompensationBoundaryEvent$1(source) && isForCompensation$2(target)) {
34941
35145
  removeIsForCompensationProperty(target);
34942
35146
  }
34943
35147
  }
@@ -34950,7 +35154,7 @@
34950
35154
  source = context.source,
34951
35155
  target = context.target;
34952
35156
 
34953
- if (isCompensationBoundaryEvent(source) && isForCompensationAllowed(target)) {
35157
+ if (isCompensationBoundaryEvent$1(source) && isForCompensationAllowed(target)) {
34954
35158
  addIsForCompensationProperty(target);
34955
35159
  removeExistingAssociations(source, [ connection ]);
34956
35160
  }
@@ -34966,12 +35170,12 @@
34966
35170
  const source = oldSource;
34967
35171
 
34968
35172
  // oldTarget perspective
34969
- if (isForCompensation$1(oldTarget)) {
35173
+ if (isForCompensation$2(oldTarget)) {
34970
35174
  removeIsForCompensationProperty(oldTarget);
34971
35175
  }
34972
35176
 
34973
35177
  // newTarget perspective
34974
- if (isCompensationBoundaryEvent(source) && isForCompensationAllowed(newTarget)) {
35178
+ if (isCompensationBoundaryEvent$1(source) && isForCompensationAllowed(newTarget)) {
34975
35179
  addIsForCompensationProperty(newTarget);
34976
35180
  }
34977
35181
  }
@@ -34980,7 +35184,7 @@
34980
35184
  function handlePropertiesUpdate(context) {
34981
35185
  const { element } = context;
34982
35186
 
34983
- if (isForCompensation$1(element)) {
35187
+ if (isForCompensation$2(element)) {
34984
35188
  removeDisallowedConnections(element);
34985
35189
  removeAttachments(element);
34986
35190
  } else if (isForCompensationAllowed(element)) {
@@ -34999,12 +35203,12 @@
34999
35203
  } = context;
35000
35204
 
35001
35205
  // from compensate boundary event
35002
- if (isCompensationBoundaryEvent(context.oldShape) &&
35206
+ if (isCompensationBoundaryEvent$1(context.oldShape) &&
35003
35207
  newData.eventDefinitionType !== 'bpmn:CompensateEventDefinition' ||
35004
35208
  newData.type !== 'bpmn:BoundaryEvent'
35005
35209
  ) {
35006
35210
  const targetConnection = oldShape.outgoing.find(
35007
- ({ target }) => isForCompensation$1(target)
35211
+ ({ target }) => isForCompensation$2(target)
35008
35212
  );
35009
35213
 
35010
35214
  if (targetConnection && targetConnection.target) {
@@ -35014,7 +35218,7 @@
35014
35218
 
35015
35219
  // to compensate boundary event
35016
35220
  else if (
35017
- !isCompensationBoundaryEvent(context.oldShape) &&
35221
+ !isCompensationBoundaryEvent$1(context.oldShape) &&
35018
35222
  newData.eventDefinitionType === 'bpmn:CompensateEventDefinition' &&
35019
35223
  newData.type === 'bpmn:BoundaryEvent'
35020
35224
  ) {
@@ -35064,7 +35268,7 @@
35064
35268
  function removeExistingAssociations(boundaryEvent, ignoredAssociations) {
35065
35269
  const associations = boundaryEvent.outgoing.filter(connection => is$1(connection, 'bpmn:Association'));
35066
35270
  const associationsToRemove = associations.filter(association => {
35067
- return isForCompensation$1(association.target) && !ignoredAssociations.includes(association);
35271
+ return isForCompensation$2(association.target) && !ignoredAssociations.includes(association);
35068
35272
  });
35069
35273
 
35070
35274
  // remove existing associations
@@ -35083,7 +35287,7 @@
35083
35287
 
35084
35288
  function removeIncomingCompensationAssociations(element) {
35085
35289
  const compensationAssociations = element.incoming.filter(
35086
- connection => isCompensationBoundaryEvent(connection.source)
35290
+ connection => isCompensationBoundaryEvent$1(connection.source)
35087
35291
  );
35088
35292
 
35089
35293
  modeling.removeElements(compensationAssociations);
@@ -35108,12 +35312,12 @@
35108
35312
 
35109
35313
  // helpers //////////
35110
35314
 
35111
- function isForCompensation$1(element) {
35315
+ function isForCompensation$2(element) {
35112
35316
  const bo = getBusinessObject(element);
35113
35317
  return bo && bo.get('isForCompensation');
35114
35318
  }
35115
35319
 
35116
- function isCompensationBoundaryEvent(element) {
35320
+ function isCompensationBoundaryEvent$1(element) {
35117
35321
  return element && is$1(element, 'bpmn:BoundaryEvent') &&
35118
35322
  hasEventDefinition$2(element, 'bpmn:CompensateEventDefinition');
35119
35323
  }
@@ -39456,10 +39660,25 @@
39456
39660
 
39457
39661
  var otherTrbl = asTRBL(other);
39458
39662
 
39459
- if (/n/.test(resizeDirection)) {
39460
- if (isHorizontalLane && otherTrbl.top < (laneTrbl.top - 10)) {
39663
+ // lane flags
39664
+ if (isHorizontalLane) {
39665
+ if (otherTrbl.top < (laneTrbl.top - 10)) {
39666
+ isFirst = false;
39667
+ }
39668
+ if (otherTrbl.bottom > (laneTrbl.bottom + 10)) {
39669
+ isLast = false;
39670
+ }
39671
+ }
39672
+ else {
39673
+ if (otherTrbl.left < (laneTrbl.left - 10)) {
39461
39674
  isFirst = false;
39462
39675
  }
39676
+ if (otherTrbl.right > (laneTrbl.right + 10)) {
39677
+ isLast = false;
39678
+ }
39679
+ }
39680
+
39681
+ if (/n/.test(resizeDirection)) {
39463
39682
 
39464
39683
  // max top size (based on next element)
39465
39684
  if (balanced && abs$2(laneTrbl.top - otherTrbl.bottom) < 10) {
@@ -39474,10 +39693,6 @@
39474
39693
 
39475
39694
  if (/e/.test(resizeDirection)) {
39476
39695
 
39477
- if (!isHorizontalLane && otherTrbl.right > (laneTrbl.right + 10)) {
39478
- isLast = false;
39479
- }
39480
-
39481
39696
  // max right size (based on previous element)
39482
39697
  if (balanced && abs$2(laneTrbl.right - otherTrbl.left) < 10) {
39483
39698
  addMin(maxTrbl, 'right', otherTrbl.right - minDimensions.width);
@@ -39491,10 +39706,6 @@
39491
39706
 
39492
39707
  if (/s/.test(resizeDirection)) {
39493
39708
 
39494
- if (isHorizontalLane && otherTrbl.bottom > (laneTrbl.bottom + 10)) {
39495
- isLast = false;
39496
- }
39497
-
39498
39709
  // max bottom size (based on previous element)
39499
39710
  if (balanced && abs$2(laneTrbl.bottom - otherTrbl.top) < 10) {
39500
39711
  addMin(maxTrbl, 'bottom', otherTrbl.bottom - minDimensions.height);
@@ -39508,10 +39719,6 @@
39508
39719
 
39509
39720
  if (/w/.test(resizeDirection)) {
39510
39721
 
39511
- if (!isHorizontalLane && otherTrbl.left < (laneTrbl.left - 10)) {
39512
- isFirst = false;
39513
- }
39514
-
39515
39722
  // max left size (based on next element)
39516
39723
  if (balanced && abs$2(laneTrbl.left - otherTrbl.right) < 10) {
39517
39724
  addMax(maxTrbl, 'left', otherTrbl.left + minDimensions.width);
@@ -39535,23 +39742,26 @@
39535
39742
 
39536
39743
  var flowElementTrbl = asTRBL(flowElement);
39537
39744
 
39538
- if (isFirst && /n/.test(resizeDirection)) {
39745
+ // vertical lane will resize from top with respect to flow element irrespective of first or last lane
39746
+ if (/n/.test(resizeDirection) && (!isHorizontalLane || isFirst)) {
39539
39747
  addMin(minTrbl, 'top', flowElementTrbl.top - padding.top);
39540
39748
  }
39541
39749
 
39542
- if (isLast && /e/.test(resizeDirection)) {
39750
+ // horizonal lane will resize from right with respect to flow element irrespective of first or last lane
39751
+ if (/e/.test(resizeDirection) && (isHorizontalLane || isLast)) {
39543
39752
  addMax(minTrbl, 'right', flowElementTrbl.right + padding.right);
39544
39753
  }
39545
39754
 
39546
- if (isLast && /s/.test(resizeDirection)) {
39755
+ // vertical lane will resize from bottom with respect to flow element irrespective of first or last lane
39756
+ if (/s/.test(resizeDirection) && (!isHorizontalLane || isLast)) {
39547
39757
  addMax(minTrbl, 'bottom', flowElementTrbl.bottom + padding.bottom);
39548
39758
  }
39549
39759
 
39550
- if (isFirst && /w/.test(resizeDirection)) {
39760
+ // horizonal lane will resize from left with respect to flow element irrespective of first or last lane
39761
+ if (/w/.test(resizeDirection) && (isHorizontalLane || isFirst)) {
39551
39762
  addMin(minTrbl, 'left', flowElementTrbl.left - padding.left);
39552
39763
  }
39553
39764
  });
39554
-
39555
39765
  return {
39556
39766
  min: minTrbl,
39557
39767
  max: maxTrbl
@@ -41125,6 +41335,66 @@
41125
41335
  };
41126
41336
  }
41127
41337
 
41338
+ /**
41339
+ * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
41340
+ * @typedef {import('../../rules/BpmnRules').default} BpmnRules
41341
+ * @typedef {import('../Modeling').default} Modeling
41342
+ */
41343
+
41344
+
41345
+ /**
41346
+ * A behavior that sets the property of Compensation Activity after paste operation
41347
+ *
41348
+ * @param {EventBus} eventBus
41349
+ * @param {Modeling} modeling
41350
+ */
41351
+ function SetCompensationActivityAfterPasteBehavior(eventBus, modeling) {
41352
+
41353
+ CommandInterceptor.call(this, eventBus);
41354
+
41355
+ this.postExecuted('elements.create', function(event) {
41356
+ const context = event.context,
41357
+ elements = context.elements;
41358
+
41359
+ // check if compensation activity is connected to compensation boundary event
41360
+ for (const element of elements) {
41361
+ if (isForCompensation$1(element) && !isConnectedToCompensationBoundaryEvent(element)) {
41362
+ modeling.updateProperties(element, { isForCompensation: undefined });
41363
+ }
41364
+ }
41365
+ });
41366
+ }
41367
+
41368
+ e$2(SetCompensationActivityAfterPasteBehavior, CommandInterceptor);
41369
+
41370
+ SetCompensationActivityAfterPasteBehavior.$inject = [
41371
+ 'eventBus',
41372
+ 'modeling'
41373
+ ];
41374
+
41375
+
41376
+ // helpers //////////////////////
41377
+
41378
+ function isForCompensation$1(element) {
41379
+ const bo = getBusinessObject(element);
41380
+ return bo && bo.isForCompensation;
41381
+ }
41382
+
41383
+ function isCompensationBoundaryEvent(element) {
41384
+ return element && is$1(element, 'bpmn:BoundaryEvent') &&
41385
+ hasEventDefinition$2(element, 'bpmn:CompensateEventDefinition');
41386
+ }
41387
+
41388
+ function isConnectedToCompensationBoundaryEvent(element) {
41389
+ const compensationAssociations = element.incoming.filter(
41390
+ connection => isCompensationBoundaryEvent(connection.source)
41391
+ );
41392
+ if (compensationAssociations.length > 0) {
41393
+ return true;
41394
+ }
41395
+ return false;
41396
+ }
41397
+
41128
41398
  /**
41129
41399
  * @type { import('didi').ModuleDeclaration }
41130
41400
  */
@@ -41169,7 +41439,8 @@
41169
41439
  'toggleElementCollapseBehaviour',
41170
41440
  'unclaimIdBehavior',
41171
41441
  'updateFlowNodeRefsBehavior',
41172
- 'unsetDefaultFlowBehavior'
41442
+ 'unsetDefaultFlowBehavior',
41443
+ 'setCompensationActivityAfterPasteBehavior'
41173
41444
  ],
41174
41445
  adaptiveLabelPositioningBehavior: [ 'type', AdaptiveLabelPositioningBehavior ],
41175
41446
  appendBehavior: [ 'type', AppendBehavior ],
@@ -41210,7 +41481,8 @@
41210
41481
  toggleElementCollapseBehaviour : [ 'type', ToggleElementCollapseBehaviour ],
41211
41482
  unclaimIdBehavior: [ 'type', UnclaimIdBehavior ],
41212
41483
  unsetDefaultFlowBehavior: [ 'type', DeleteSequenceFlowBehavior ],
41213
- updateFlowNodeRefsBehavior: [ 'type', UpdateFlowNodeRefsBehavior ]
41484
+ updateFlowNodeRefsBehavior: [ 'type', UpdateFlowNodeRefsBehavior ],
41485
+ setCompensationActivityAfterPasteBehavior: [ 'type', SetCompensationActivityAfterPasteBehavior ]
41214
41486
  };
41215
41487
 
41216
41488
  /**
@@ -52778,7 +53050,7 @@
52778
53050
  /**
52779
53051
  * @param {Element} source
52780
53052
  * @param {Element} target
52781
- * @param {Partial<Connection>} attrs
53053
+ * @param {Partial<Connection>} [attrs]
52782
53054
  * @param {ModelingHints} [hints]
52783
53055
  *
52784
53056
  * @return {T}
@@ -53753,6 +54025,8 @@
53753
54025
  }
53754
54026
 
53755
54027
  /**
54028
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
54029
+ *
53756
54030
  * @typedef {import('diagram-js/lib/util/Types').Point} Point
53757
54031
  *
53758
54032
  * @typedef {import('../../model/Types').Connection} Connection
@@ -53835,7 +54109,9 @@
53835
54109
  left: 'l'
53836
54110
  };
53837
54111
 
53838
- function BpmnLayouter() {}
54112
+ function BpmnLayouter(elementRegistry) {
54113
+ this._elementRegistry = elementRegistry;
54114
+ }
53839
54115
 
53840
54116
  e$2(BpmnLayouter, BaseLayouter);
53841
54117
 
@@ -53856,7 +54132,8 @@
53856
54132
  target = hints.target || connection.target,
53857
54133
  waypoints = hints.waypoints || connection.waypoints,
53858
54134
  connectionStart = hints.connectionStart,
53859
- connectionEnd = hints.connectionEnd;
54135
+ connectionEnd = hints.connectionEnd,
54136
+ elementRegistry = this._elementRegistry;
53860
54137
 
53861
54138
  var manhattanOptions,
53862
54139
  updatedWaypoints;
@@ -53877,7 +54154,7 @@
53877
54154
  }
53878
54155
  }
53879
54156
 
53880
- var layout = isDirectionHorizontal(source) ? PREFERRED_LAYOUTS_HORIZONTAL : PREFERRED_LAYOUTS_VERTICAL;
54157
+ var layout = isDirectionHorizontal(source, elementRegistry) ? PREFERRED_LAYOUTS_HORIZONTAL : PREFERRED_LAYOUTS_VERTICAL;
53881
54158
 
53882
54159
  if (is$1(connection, 'bpmn:MessageFlow')) {
53883
54160
  manhattanOptions = getMessageFlowManhattanOptions(source, target, layout);
@@ -54208,6 +54485,8 @@
54208
54485
  }
54209
54486
  }
54210
54487
 
54488
+ BpmnLayouter.$inject = [ 'elementRegistry' ];
54489
+
54211
54490
  /**
54212
54491
  * @typedef {import('../core/ElementRegistry').default} ElementRegistry
54213
54492
  * @typedef {import('../core/GraphicsFactory').default} GraphicsFactory
@@ -54335,7 +54614,7 @@
54335
54614
  * @typedef {import('diagram-js/lib/layout/ConnectionDocking').default} ConnectionDocking
54336
54615
  * @typedef {import('../modeling/ElementFactory').default} ElementFactory
54337
54616
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
54338
- * @typedef {import('diagram-js/lib/layout/ManhattanLayout').default} ManhattanLayout
54617
+ * @typedef {import('../modeling/BpmnLayouter').default} BpmnLayouter
54339
54618
  * @typedef {import('diagram-js/lib/features/rules/Rules').default} Rules
54340
54619
  *
54341
54620
  * @typedef {import('../../model/Types').Shape} Shape
@@ -54348,7 +54627,7 @@
54348
54627
  * @param {ConnectionDocking} connectionDocking
54349
54628
  * @param {ElementFactory} elementFactory
54350
54629
  * @param {EventBus} eventBus
54351
- * @param {ManhattanLayout} layouter
54630
+ * @param {BpmnLayouter} layouter
54352
54631
  * @param {Rules} rules
54353
54632
  */
54354
54633
  function AppendPreview(complexPreview, connectionDocking, elementFactory, eventBus, layouter, rules) {
@@ -56740,6 +57019,7 @@
56740
57019
  * @typedef {import('diagram-js/lib/features/context-pad/ContextPad').default} ContextPad
56741
57020
  * @typedef {import('../modeling/Modeling').default} Modeling
56742
57021
  * @typedef {import('../modeling/ElementFactory').default} ElementFactory
57022
+ * @typedef {import('../append-preview/AppendPreview').default} AppendPreview
56743
57023
  * @typedef {import('diagram-js/lib/features/connect/Connect').default} Connect
56744
57024
  * @typedef {import('diagram-js/lib/features/create/Create').default} Create
56745
57025
  * @typedef {import('diagram-js/lib/features/popup-menu/PopupMenu').default} PopupMenu
@@ -56774,6 +57054,7 @@
56774
57054
  * @param {Canvas} canvas
56775
57055
  * @param {Rules} rules
56776
57056
  * @param {Translate} translate
57057
+ * @param {AppendPreview} appendPreview
56777
57058
  */
56778
57059
  function ContextPadProvider(
56779
57060
  config, injector, eventBus,
@@ -58786,6 +59067,7 @@
58786
59067
 
58787
59068
  /**
58788
59069
  * @typedef {import('diagram-js/lib/core/EventBus').default} EventBus
59070
+ * @typedef {import('diagram-js/lib/core/ElementRegistry').default} ElementRegistry
58789
59071
  * @typedef {import('diagram-js/lib/features/grid-snapping/GridSnapping').default} GridSnapping
58790
59072
  *
58791
59073
  * @typedef {import('diagram-js/lib/util/Types').Axis} Axis
@@ -58796,14 +59078,15 @@
58796
59078
  /**
58797
59079
  * @param {EventBus} eventBus
58798
59080
  * @param {GridSnapping} gridSnapping
59081
+ * @param {ElementRegistry} elementRegistry
58799
59082
  */
58800
- function GridSnappingAutoPlaceBehavior(eventBus, gridSnapping) {
59083
+ function GridSnappingAutoPlaceBehavior(eventBus, gridSnapping, elementRegistry) {
58801
59084
  eventBus.on('autoPlace', HIGH_PRIORITY$5, function(context) {
58802
59085
  var source = context.source,
58803
59086
  sourceMid = getMid(source),
58804
59087
  shape = context.shape;
58805
59088
 
58806
- var position = getNewShapePosition(source, shape);
59089
+ var position = getNewShapePosition(source, shape, elementRegistry);
58807
59090
 
58808
59091
  [ 'x', 'y' ].forEach(function(axis) {
58809
59092
  var options = {};
@@ -58840,7 +59123,8 @@
58840
59123
 
58841
59124
  GridSnappingAutoPlaceBehavior.$inject = [
58842
59125
  'eventBus',
58843
- 'gridSnapping'
59126
+ 'gridSnapping',
59127
+ 'elementRegistry'
58844
59128
  ];
58845
59129
 
58846
59130
  // helpers //////////
@@ -60697,7 +60981,8 @@
60697
60981
  } else if (is$1(element, 'bpmn:Task') ||
60698
60982
  is$1(element, 'bpmn:CallActivity') ||
60699
60983
  is$1(element, 'bpmn:SubProcess') ||
60700
- is$1(element, 'bpmn:Participant')) {
60984
+ is$1(element, 'bpmn:Participant') ||
60985
+ is$1(element, 'bpmn:Lane')) {
60701
60986
  canvas.addMarker(element, MARKER_LABEL_HIDDEN);
60702
60987
  }
60703
60988
  });
@@ -64484,12 +64769,9 @@
64484
64769
  /**
64485
64770
  * @typedef {import('../../core/Canvas').default} Canvas
64486
64771
  * @typedef {import('../../core/EventBus').default} EventBus
64487
- * @typedef {import('../overlays/Overlays').default} Overlays
64488
64772
  * @typedef {import('../selection/Selection').default} Selection
64489
64773
  * @typedef {import('../../i18n/translate/translate.js').default} Translate
64490
64774
  *
64491
- * @typedef {import('../overlays/Overlays').OverlayAttrs} OverlayAttrs
64492
- *
64493
64775
  * @typedef {import('../../util/Types').Dimensions} Dimensions
64494
64776
  *
64495
64777
  * @typedef {import('./SearchPadProvider').default} SearchPadProvider
@@ -64502,18 +64784,20 @@
64502
64784
  *
64503
64785
  * @param {Canvas} canvas
64504
64786
  * @param {EventBus} eventBus
64505
- * @param {Overlays} overlays
64506
64787
  * @param {Selection} selection
64507
64788
  * @param {Translate} translate
64508
64789
  */
64509
- function SearchPad(canvas, eventBus, overlays, selection, translate) {
64790
+ function SearchPad(canvas, eventBus, selection, translate) {
64510
64791
  this._open = false;
64511
64792
  this._results = [];
64512
64793
  this._eventMaps = [];
64513
64794
 
64795
+ this._cachedRootElement = null;
64796
+ this._cachedSelection = null;
64797
+ this._cachedViewbox = null;
64798
+
64514
64799
  this._canvas = canvas;
64515
64800
  this._eventBus = eventBus;
64516
- this._overlays = overlays;
64517
64801
  this._selection = selection;
64518
64802
  this._translate = translate;
64519
64803
 
@@ -64525,15 +64809,19 @@
64525
64809
  // attach search pad
64526
64810
  this._canvas.getContainer().appendChild(this._container);
64527
64811
 
64528
- // cleanup on destroy
64529
- eventBus.on([ 'canvas.destroy', 'diagram.destroy' ], this.close, this);
64812
+ // cleanup whenever appropriate
64813
+ eventBus.on([
64814
+ 'canvas.destroy',
64815
+ 'diagram.destroy',
64816
+ 'drag.init',
64817
+ 'elements.changed'
64818
+ ], this.close, this);
64530
64819
  }
64531
64820
 
64532
64821
 
64533
64822
  SearchPad.$inject = [
64534
64823
  'canvas',
64535
64824
  'eventBus',
64536
- 'overlays',
64537
64825
  'selection',
64538
64826
  'translate'
64539
64827
  ];
@@ -64555,7 +64843,7 @@
64555
64843
 
64556
64844
  // close search on clicking anywhere outside
64557
64845
  listen(document, 'html', 'click', function(e) {
64558
- self.close();
64846
+ self.close(false);
64559
64847
  });
64560
64848
 
64561
64849
  // stop event from propagating and closing search
@@ -64601,7 +64889,7 @@
64601
64889
  if (isKey('Enter', e)) {
64602
64890
  var selected = self._getCurrentResult();
64603
64891
 
64604
- return selected ? self._select(selected) : self.close();
64892
+ return selected ? self._select(selected) : self.close(false);
64605
64893
  }
64606
64894
 
64607
64895
  if (isKey('ArrowUp', e)) {
@@ -64650,6 +64938,10 @@
64650
64938
 
64651
64939
  var searchResults = this._searchProvider.find(pattern);
64652
64940
 
64941
+ searchResults = searchResults.filter(function(searchResult) {
64942
+ return !self._canvas.getRootElements().includes(searchResult.element);
64943
+ });
64944
+
64653
64945
  if (!searchResults.length) {
64654
64946
  return;
64655
64947
  }
@@ -64721,8 +65013,6 @@
64721
65013
 
64722
65014
  this._results = [];
64723
65015
 
64724
- this._resetOverlay();
64725
-
64726
65016
  this._eventBus.fire('searchPad.cleared');
64727
65017
  };
64728
65018
 
@@ -64791,10 +65081,15 @@
64791
65081
  return;
64792
65082
  }
64793
65083
 
65084
+ this._cachedRootElement = this._canvas.getRootElement();
65085
+ this._cachedSelection = this._selection.get();
65086
+ this._cachedViewbox = this._canvas.viewbox();
65087
+
64794
65088
  this._bindEvents();
64795
65089
 
64796
65090
  this._open = true;
64797
65091
 
65092
+ classes$1(this._canvas.getContainer()).add('djs-search-open');
64798
65093
  classes$1(this._container).add('open');
64799
65094
 
64800
65095
  this._searchInput.focus();
@@ -64806,15 +65101,36 @@
64806
65101
  /**
64807
65102
  * Close search pad.
64808
65103
  */
64809
- SearchPad.prototype.close = function() {
65104
+ SearchPad.prototype.close = function(restoreCached = true) {
64810
65105
  if (!this.isOpen()) {
64811
65106
  return;
64812
65107
  }
64813
65108
 
65109
+ if (restoreCached) {
65110
+ if (this._cachedRootElement) {
65111
+ this._canvas.setRootElement(this._cachedRootElement);
65112
+ }
65113
+
65114
+ if (this._cachedSelection) {
65115
+ this._selection.select(this._cachedSelection);
65116
+ }
65117
+
65118
+ if (this._cachedViewbox) {
65119
+ this._canvas.viewbox(this._cachedViewbox);
65120
+ }
65121
+
65122
+ this._eventBus.fire('searchPad.restored');
65123
+ }
65124
+
65125
+ this._cachedRootElement = null;
65126
+ this._cachedSelection = null;
65127
+ this._cachedViewbox = null;
65128
+
64814
65129
  this._unbindEvents();
64815
65130
 
64816
65131
  this._open = false;
64817
65132
 
65133
+ classes$1(this._canvas.getContainer()).remove('djs-search-open');
64818
65134
  classes$1(this._container).remove('open');
64819
65135
 
64820
65136
  this._clearResults();
@@ -64822,8 +65138,6 @@
64822
65138
  this._searchInput.value = '';
64823
65139
  this._searchInput.blur();
64824
65140
 
64825
- this._resetOverlay();
64826
-
64827
65141
  this._eventBus.fire('searchPad.closed');
64828
65142
  };
64829
65143
 
@@ -64867,9 +65181,11 @@
64867
65181
 
64868
65182
  classes$1(node).add(SearchPad.RESULT_SELECTED_CLASS);
64869
65183
 
64870
- this._resetOverlay(element);
65184
+ this._canvas.zoom(1);
64871
65185
 
64872
- this._canvas.scrollToElement(element, { top: 400 });
65186
+ this._canvas.scrollToElement(element, {
65187
+ top: 300
65188
+ });
64873
65189
 
64874
65190
  this._selection.select(element);
64875
65191
 
@@ -64886,9 +65202,10 @@
64886
65202
  var id = attr$1(node, SearchPad.RESULT_ID_ATTRIBUTE);
64887
65203
  var element = this._results[id].element;
64888
65204
 
64889
- this.close();
65205
+ this._cachedSelection = null;
65206
+ this._cachedViewbox = null;
64890
65207
 
64891
- this._resetOverlay();
65208
+ this.close(false);
64892
65209
 
64893
65210
  this._canvas.scrollToElement(element, { top: 400 });
64894
65211
 
@@ -64898,24 +65215,6 @@
64898
65215
  };
64899
65216
 
64900
65217
 
64901
- /**
64902
- * Reset overlay removes and, optionally, set
64903
- * overlay to a new element.
64904
- *
64905
- * @param {HTMLElement} element
64906
- */
64907
- SearchPad.prototype._resetOverlay = function(element) {
64908
- if (this._overlayId) {
64909
- this._overlays.remove(this._overlayId);
64910
- }
64911
-
64912
- if (element) {
64913
- var box = getBBox(element);
64914
- var overlay = constructOverlay(box);
64915
- this._overlayId = this._overlays.add(element, overlay);
64916
- }
64917
- };
64918
-
64919
65218
  SearchPad.prototype._getBoxHtml = function() {
64920
65219
  const box = domify$1(SearchPad.BOX_HTML);
64921
65220
  const input = query(SearchPad.INPUT_SELECTOR, box);
@@ -64928,39 +65227,6 @@
64928
65227
  };
64929
65228
 
64930
65229
 
64931
- /**
64932
- * Construct overlay object for the given bounding box.
64933
- *
64934
- * @param {Dimensions} box
64935
- *
64936
- * @return {OverlayAttrs}
64937
- */
64938
- function constructOverlay(box) {
64939
-
64940
- var offset = 6;
64941
- var w = box.width + offset * 2;
64942
- var h = box.height + offset * 2;
64943
-
64944
- var styles = {
64945
- width: w + 'px',
64946
- height: h + 'px'
64947
- };
64948
-
64949
- var html = domify$1('<div class="' + SearchPad.OVERLAY_CLASS + '"></div>');
64950
-
64951
- assign(html, styles);
64952
-
64953
- return {
64954
- position: {
64955
- bottom: h - offset,
64956
- right: w - offset
64957
- },
64958
- show: true,
64959
- html: html
64960
- };
64961
- }
64962
-
64963
-
64964
65230
  /**
64965
65231
  * Creates and appends child node from result tokens and HTML template.
64966
65232
  *
@@ -64988,7 +65254,7 @@
64988
65254
 
64989
65255
  tokens.forEach(function(t) {
64990
65256
  if (t.matched) {
64991
- htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + escapeHTML(t.matched) + '</strong>';
65257
+ htmlText += '<b class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + escapeHTML(t.matched) + '</b>';
64992
65258
  } else {
64993
65259
  htmlText += escapeHTML(t.normal);
64994
65260
  }
@@ -65009,15 +65275,17 @@
65009
65275
  SearchPad.RESULT_SELECTED_SELECTOR = '.' + SearchPad.RESULT_SELECTED_CLASS;
65010
65276
  SearchPad.RESULT_ID_ATTRIBUTE = 'data-result-id';
65011
65277
  SearchPad.RESULT_HIGHLIGHT_CLASS = 'djs-search-highlight';
65012
- SearchPad.OVERLAY_CLASS = 'djs-search-overlay';
65013
65278
 
65014
65279
  SearchPad.BOX_HTML =
65015
- '<div class="djs-search-container djs-draggable djs-scrollable">' +
65016
- '<div class="djs-search-input">' +
65017
- '<input type="text"/>' +
65018
- '</div>' +
65019
- '<div class="djs-search-results"></div>' +
65020
- '</div>';
65280
+ `<div class="djs-search-container djs-scrollable">
65281
+ <div class="djs-search-input">
65282
+ <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
65283
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>
65284
+ </svg>
65285
+ <input type="text" spellcheck="false" />
65286
+ </div>
65287
+ <div class="djs-search-results" />
65288
+ </div>` ;
65021
65289
 
65022
65290
  SearchPad.RESULT_HTML =
65023
65291
  '<div class="djs-search-result"></div>';
@@ -65080,48 +65348,114 @@
65080
65348
  var rootElements = this._canvas.getRootElements();
65081
65349
 
65082
65350
  var elements = this._elementRegistry.filter(function(element) {
65083
- if (element.labelTarget) {
65084
- return false;
65085
- }
65086
- return true;
65351
+ return !isLabel(element) && !rootElements.includes(element);
65087
65352
  });
65088
65353
 
65089
- // do not include root element
65090
- elements = filter(elements, function(element) {
65091
- return !rootElements.includes(element);
65092
- });
65354
+ return elements
65355
+ .reduce(function(results, element) {
65356
+ var label = getLabel(element);
65093
65357
 
65094
- elements = map$1(elements, function(element) {
65095
- return {
65096
- primaryTokens: matchAndSplit(getLabel(element), pattern),
65097
- secondaryTokens: matchAndSplit(element.id, pattern),
65098
- element: element
65099
- };
65100
- });
65358
+ var primaryTokens = findMatches(label, pattern),
65359
+ secondaryTokens = findMatches(element.id, pattern);
65101
65360
 
65102
- // exclude non-matched elements
65103
- elements = filter(elements, function(element) {
65104
- return hasMatched(element.primaryTokens) || hasMatched(element.secondaryTokens);
65105
- });
65106
-
65107
- elements = sortBy(elements, function(element) {
65108
- return getLabel(element.element) + element.element.id;
65109
- });
65361
+ if (hasMatch(primaryTokens) || hasMatch(secondaryTokens)) {
65362
+ return [
65363
+ ...results,
65364
+ {
65365
+ primaryTokens,
65366
+ secondaryTokens,
65367
+ element
65368
+ }
65369
+ ];
65370
+ }
65110
65371
 
65111
- return elements;
65372
+ return results;
65373
+ }, [])
65374
+ .sort(function(a, b) {
65375
+ return compareTokens(a.primaryTokens, b.primaryTokens)
65376
+ || compareTokens(a.secondaryTokens, b.secondaryTokens)
65377
+ || compareStrings(getLabel(a.element), getLabel(b.element))
65378
+ || compareStrings(a.element.id, b.element.id);
65379
+ })
65380
+ .map(function(result) {
65381
+ return {
65382
+ element: result.element,
65383
+ primaryTokens: result.primaryTokens.map(function(token) {
65384
+ return omit(token, [ 'index' ]);
65385
+ }),
65386
+ secondaryTokens: result.secondaryTokens.map(function(token) {
65387
+ return omit(token, [ 'index' ]);
65388
+ })
65389
+ };
65390
+ });
65112
65391
  };
65113
65392
 
65393
+ /**
65394
+ * @param {Token} token
65395
+ *
65396
+ * @return {boolean}
65397
+ */
65398
+ function isMatch(token) {
65399
+ return 'matched' in token;
65400
+ }
65401
+
65114
65402
  /**
65115
65403
  * @param {Token[]} tokens
65116
65404
  *
65117
65405
  * @return {boolean}
65118
65406
  */
65119
- function hasMatched(tokens) {
65120
- var matched = filter(tokens, function(token) {
65121
- return !!token.matched;
65122
- });
65407
+ function hasMatch(tokens) {
65408
+ return tokens.find(isMatch);
65409
+ }
65410
+
65411
+ /**
65412
+ * Compares two token arrays.
65413
+ *
65414
+ * @param {Token[]} tokensA
65415
+ * @param {Token[]} tokensB
65416
+ *
65417
+ * @returns {number}
65418
+ */
65419
+ function compareTokens(tokensA, tokensB) {
65420
+ const tokensAHasMatch = hasMatch(tokensA),
65421
+ tokensBHasMatch = hasMatch(tokensB);
65422
+
65423
+ if (tokensAHasMatch && !tokensBHasMatch) {
65424
+ return -1;
65425
+ }
65426
+
65427
+ if (!tokensAHasMatch && tokensBHasMatch) {
65428
+ return 1;
65429
+ }
65430
+
65431
+ if (!tokensAHasMatch && !tokensBHasMatch) {
65432
+ return 0;
65433
+ }
65434
+
65435
+ const tokensAFirstMatch = tokensA.find(isMatch),
65436
+ tokensBFirstMatch = tokensB.find(isMatch);
65123
65437
 
65124
- return matched.length > 0;
65438
+ if (tokensAFirstMatch.index < tokensBFirstMatch.index) {
65439
+ return -1;
65440
+ }
65441
+
65442
+ if (tokensAFirstMatch.index > tokensBFirstMatch.index) {
65443
+ return 1;
65444
+ }
65445
+
65446
+ return 0;
65447
+ }
65448
+
65449
+ /**
65450
+ * Compares two strings.
65451
+ *
65452
+ * @param {string} a
65453
+ * @param {string} b
65454
+ *
65455
+ * @returns {number}
65456
+ */
65457
+ function compareStrings(a, b) {
65458
+ return a.localeCompare(b);
65125
65459
  }
65126
65460
 
65127
65461
  /**
@@ -65130,7 +65464,7 @@
65130
65464
  *
65131
65465
  * @return {Token[]}
65132
65466
  */
65133
- function matchAndSplit(text, pattern) {
65467
+ function findMatches(text, pattern) {
65134
65468
  var tokens = [],
65135
65469
  originalText = text;
65136
65470
 
@@ -65141,27 +65475,31 @@
65141
65475
  text = text.toLowerCase();
65142
65476
  pattern = pattern.toLowerCase();
65143
65477
 
65144
- var i = text.indexOf(pattern);
65478
+ var index = text.indexOf(pattern);
65145
65479
 
65146
- if (i > -1) {
65147
- if (i !== 0) {
65480
+ if (index > -1) {
65481
+ if (index !== 0) {
65148
65482
  tokens.push({
65149
- normal: originalText.substr(0, i)
65483
+ normal: originalText.slice(0, index),
65484
+ index: 0
65150
65485
  });
65151
65486
  }
65152
65487
 
65153
65488
  tokens.push({
65154
- matched: originalText.substr(i, pattern.length)
65489
+ matched: originalText.slice(index, index + pattern.length),
65490
+ index: index
65155
65491
  });
65156
65492
 
65157
- if (pattern.length + i < text.length) {
65493
+ if (pattern.length + index < text.length) {
65158
65494
  tokens.push({
65159
- normal: originalText.substr(pattern.length + i, text.length)
65495
+ normal: originalText.slice(index + pattern.length),
65496
+ index: index + pattern.length
65160
65497
  });
65161
65498
  }
65162
65499
  } else {
65163
65500
  tokens.push({
65164
- normal: originalText
65501
+ normal: originalText,
65502
+ index: 0
65165
65503
  });
65166
65504
  }
65167
65505