bpmn-js 18.30.1 → 18.31.1

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.30.1
2
+ * bpmn-js - bpmn-modeler v18.31.1
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: 2026-09-24
11
+ * Date: 2026-10-21
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -8411,7 +8411,7 @@
8411
8411
  function prependTo(newNode, parentNode, siblingNode) {
8412
8412
  var node = siblingNode || parentNode.firstChild;
8413
8413
 
8414
- // do not prepend node to itself to prevent IE from crashing
8414
+ // do not prepend node to itself
8415
8415
  // https://github.com/bpmn-io/bpmn-js/issues/746
8416
8416
  if (newNode === node) {
8417
8417
  return;
@@ -19184,7 +19184,7 @@
19184
19184
  bounds = label.bounds;
19185
19185
 
19186
19186
  size = {
19187
- width: Math.max(DEFAULT_LABEL_SIZE$1.width, bounds.width),
19187
+ width: bounds.width,
19188
19188
  height: bounds.height
19189
19189
  };
19190
19190
 
@@ -23327,7 +23327,18 @@
23327
23327
 
23328
23328
  text = getLabel(element);
23329
23329
 
23330
- if (text) {
23330
+ if (text && di.label && di.label.bounds && bounds.width > 0) {
23331
+
23332
+ // keep the persisted width, it may have been set by the user
23333
+ var dimensions = this._textRenderer.getDimensions(text, {
23334
+ box: bounds,
23335
+ style: this._textRenderer.getExternalStyle()
23336
+ });
23337
+
23338
+ bounds = assign$1({}, bounds, {
23339
+ height: Math.ceil(dimensions.height)
23340
+ });
23341
+ } else if (text) {
23331
23342
 
23332
23343
  // get corrected bounds from actual layouted text
23333
23344
  bounds = this._textRenderer.getExternalLabelBounds(bounds, text);
@@ -26538,6 +26549,13 @@
26538
26549
  /**
26539
26550
  * Checks if key pressed is one of provided keys.
26540
26551
  *
26552
+ * Keys are matched against the logical key (`KeyboardEvent#key`) first,
26553
+ * respecting Latin keyboard layouts such as QWERTZ or AZERTY.
26554
+ *
26555
+ * If a non-Latin layout (e.g. Cyrillic, Arabic) is active, letter keys
26556
+ * are matched by their physical location (`KeyboardEvent#code`), assuming
26557
+ * a US (QWERTY) layout. This applies to shortcuts with and without modifiers.
26558
+ *
26541
26559
  * @param {string|string[]} keys
26542
26560
  * @param {KeyboardEvent} event
26543
26561
  * @return {boolean}
@@ -26545,7 +26563,51 @@
26545
26563
  function isKey(keys, event) {
26546
26564
  keys = isArray$2(keys) ? keys : [ keys ];
26547
26565
 
26548
- return keys.indexOf(event.key) !== -1 || keys.indexOf(event.code) !== -1;
26566
+ return (
26567
+ keys.indexOf(event.key) !== -1 ||
26568
+ keys.indexOf(event.code) !== -1 ||
26569
+ keys.indexOf(getPhysicalLetter(event)) !== -1
26570
+ );
26571
+ }
26572
+
26573
+ // letters of a specific, non-Latin script; excludes letters shared with Latin
26574
+ // orthographies, e.g. U+02BC (ʼ) or U+02BB (ʻ)
26575
+ var NON_LATIN_LETTER = /^(?!\p{Script_Extensions=Latin}|\p{Script=Common})\p{Letter}$/u;
26576
+
26577
+ var NON_LETTER = /^\P{Letter}$/u;
26578
+
26579
+ /**
26580
+ * Returns the (US layout) letter of the physical key pressed,
26581
+ * if the logical key is a non-Latin letter.
26582
+ *
26583
+ * With <Shift>, some non-Latin layouts (e.g. Arabic) produce symbols on letter
26584
+ * keys. As a symbol does not reveal the layout, we additionally require the
26585
+ * legacy `KeyboardEvent#keyCode` to agree: the operating system maps it to the
26586
+ * US letter on non-Latin layouts only, but not on Latin ones (e.g. Dvorak).
26587
+ *
26588
+ * @param {KeyboardEvent} event
26589
+ *
26590
+ * @return {string|null}
26591
+ */
26592
+ function getPhysicalLetter(event) {
26593
+ var key = event.key,
26594
+ match = /^Key([A-Z])$/.exec(event.code || '');
26595
+
26596
+ if (!match || typeof key !== 'string') {
26597
+ return null;
26598
+ }
26599
+
26600
+ var letter = match[1];
26601
+
26602
+ if (NON_LATIN_LETTER.test(key)) {
26603
+ return event.shiftKey ? letter : letter.toLowerCase();
26604
+ }
26605
+
26606
+ if (event.shiftKey && NON_LETTER.test(key) && event.keyCode === letter.charCodeAt(0)) {
26607
+ return letter;
26608
+ }
26609
+
26610
+ return null;
26549
26611
  }
26550
26612
 
26551
26613
  /**
@@ -26943,7 +27005,7 @@
26943
27005
 
26944
27006
  // quirk: it has to be triggered by `=` as well to work on international keyboard layout
26945
27007
  // cf: https://github.com/bpmn-io/bpmn-js/issues/1362#issuecomment-722989754
26946
- if (isKey([ '+', 'Add', '=' ], event) && isCmd(event)) {
27008
+ if (isKey([ '+', '=' ], event) && isCmd(event)) {
26947
27009
  editorActions.trigger('stepZoom', { value: 1 });
26948
27010
 
26949
27011
  return true;
@@ -26956,7 +27018,7 @@
26956
27018
 
26957
27019
  var event = context.keyEvent;
26958
27020
 
26959
- if (isKey([ '-', 'Subtract' ], event) && isCmd(event)) {
27021
+ if (isKey('-', event) && isCmd(event)) {
26960
27022
  editorActions.trigger('stepZoom', { value: -1 });
26961
27023
 
26962
27024
  return true;
@@ -26982,7 +27044,7 @@
26982
27044
 
26983
27045
  var event = context.keyEvent;
26984
27046
 
26985
- if (isKey([ 'Backspace', 'Delete', 'Del' ], event)) {
27047
+ if (isKey([ 'Backspace', 'Delete' ], event)) {
26986
27048
  editorActions.trigger('removeSelection');
26987
27049
 
26988
27050
  return true;
@@ -27042,10 +27104,10 @@
27042
27104
  }
27043
27105
 
27044
27106
  if (keyboard.isKey([
27045
- 'ArrowLeft', 'Left',
27046
- 'ArrowUp', 'Up',
27047
- 'ArrowDown', 'Down',
27048
- 'ArrowRight', 'Right'
27107
+ 'ArrowLeft',
27108
+ 'ArrowUp',
27109
+ 'ArrowDown',
27110
+ 'ArrowRight'
27049
27111
  ], event)) {
27050
27112
 
27051
27113
  var speed = (
@@ -27058,19 +27120,15 @@
27058
27120
 
27059
27121
  switch (event.key) {
27060
27122
  case 'ArrowLeft':
27061
- case 'Left':
27062
27123
  direction = 'left';
27063
27124
  break;
27064
27125
  case 'ArrowUp':
27065
- case 'Up':
27066
27126
  direction = 'up';
27067
27127
  break;
27068
27128
  case 'ArrowRight':
27069
- case 'Right':
27070
27129
  direction = 'right';
27071
27130
  break;
27072
27131
  case 'ArrowDown':
27073
- case 'Down':
27074
27132
  direction = 'down';
27075
27133
  break;
27076
27134
  }
@@ -27249,6 +27307,12 @@
27249
27307
  }
27250
27308
  });
27251
27309
 
27310
+ eventBus.on('diagram.destroy', function() {
27311
+ if (context) {
27312
+ handleEnd();
27313
+ }
27314
+ });
27315
+
27252
27316
 
27253
27317
  function handleMove(event) {
27254
27318
 
@@ -28935,6 +28999,7 @@
28935
28999
  * @param {PopupMenuEntry} props.entry
28936
29000
  * @param {boolean} props.selected
28937
29001
  * @param {(event: MouseEvent) => void} props.onMouseEnter
29002
+ * @param {(event: MouseEvent) => void} props.onMouseMove
28938
29003
  * @param {(event: MouseEvent) => void} props.onMouseLeave
28939
29004
  * @param {(event: MouseEvent, entry?: PopupMenuEntry, action?: string) => void} props.onAction
28940
29005
  */
@@ -28944,6 +29009,7 @@
28944
29009
  entry,
28945
29010
  selected,
28946
29011
  onMouseEnter,
29012
+ onMouseMove,
28947
29013
  onMouseLeave,
28948
29014
  onAction
28949
29015
  } = props;
@@ -28970,6 +29036,7 @@
28970
29036
  aria-disabled=${ entry.disabled || undefined }
28971
29037
  onClick=${ handleClick }
28972
29038
  onMouseEnter=${ onMouseEnter }
29039
+ onMouseMove=${ onMouseMove }
28973
29040
  onMouseLeave=${ onMouseLeave }
28974
29041
  onDragStart=${ (event) => draggable && handleClick(event, 'dragstart') }
28975
29042
  draggable=${ draggable }
@@ -29039,6 +29106,7 @@
29039
29106
  * @param {PopupMenuEntry} props.selectedEntry
29040
29107
  * @param {(entry: PopupMenuEntry | null) => void} props.setSelectedEntry
29041
29108
  * @param {import('@bpmn-io/diagram-js-ui').Ref<boolean>} props.keyboardSelection
29109
+ * @param {() => void} props.onPointerInteraction
29042
29110
  * @param {string} props.idPrefix
29043
29111
  * @param {string} props.id
29044
29112
  * @param {string} [props.ariaLabel]
@@ -29051,6 +29119,7 @@
29051
29119
  setSelectedEntry,
29052
29120
  groupedEntries,
29053
29121
  keyboardSelection,
29122
+ onPointerInteraction,
29054
29123
  idPrefix,
29055
29124
  id,
29056
29125
  ariaLabel,
@@ -29081,6 +29150,13 @@
29081
29150
 
29082
29151
  const handleMouseMove = () => {
29083
29152
  keyboardSelection.current = false;
29153
+ onPointerInteraction();
29154
+ };
29155
+
29156
+ const handleEntryMouseMove = (entry) => {
29157
+ if (entry !== selectedEntry) {
29158
+ setSelectedEntry(entry);
29159
+ }
29084
29160
  };
29085
29161
 
29086
29162
  const handleEntryMouseEnter = (entry) => {
@@ -29132,6 +29208,7 @@
29132
29208
  entry=${ entry }
29133
29209
  selected=${ entry === selectedEntry }
29134
29210
  onMouseEnter=${ () => handleEntryMouseEnter(entry) }
29211
+ onMouseMove=${ () => handleEntryMouseMove(entry) }
29135
29212
  onMouseLeave=${ handleEntryMouseLeave }
29136
29213
  ...${ restProps }
29137
29214
  />
@@ -29457,6 +29534,16 @@
29457
29534
  */
29458
29535
  const keyboardSelection = A(false);
29459
29536
 
29537
+ const [ interactionMode, setInteractionMode ] = d('keyboard');
29538
+
29539
+ const handleKeyboardInteraction = q(() => {
29540
+ setInteractionMode('keyboard');
29541
+ }, []);
29542
+
29543
+ const handlePointerInteraction = q(() => {
29544
+ setInteractionMode('pointer');
29545
+ }, []);
29546
+
29460
29547
  // per instance basis to generate field IDs
29461
29548
  const idPrefix = T(() => ids$1.next(), []);
29462
29549
 
@@ -29677,6 +29764,8 @@
29677
29764
  width=${ width }
29678
29765
  scale=${ scale }
29679
29766
  navigationStack=${ navigationStack }
29767
+ interactionMode=${ interactionMode }
29768
+ onKeyboardInteraction=${ handleKeyboardInteraction }
29680
29769
  >
29681
29770
  ${ displayHeader && m$1`
29682
29771
  <${PopupMenuHeader}
@@ -29762,6 +29851,7 @@
29762
29851
  selectedEntry=${ selectedEntry }
29763
29852
  setSelectedEntry=${ setSelectedEntry }
29764
29853
  keyboardSelection=${ keyboardSelection }
29854
+ onPointerInteraction=${ handlePointerInteraction }
29765
29855
  onAction=${ handleEntryAction }
29766
29856
  idPrefix=${ idPrefix }
29767
29857
  id=${ resultsId }
@@ -29819,9 +29909,11 @@
29819
29909
  onClose,
29820
29910
  onKeydown,
29821
29911
  onKeyup,
29912
+ onKeyboardInteraction,
29822
29913
  className,
29823
29914
  children,
29824
29915
  navigationStack,
29916
+ interactionMode,
29825
29917
  position: positionGetter
29826
29918
  } = props;
29827
29919
 
@@ -29889,10 +29981,15 @@
29889
29981
  };
29890
29982
  }, []);
29891
29983
 
29984
+ const popupClassName = clsx('djs-popup', className, {
29985
+ 'djs-popup--pointer': interactionMode === 'pointer'
29986
+ });
29987
+
29892
29988
  return m$1`
29893
29989
  <div
29894
- class=${ clsx('djs-popup', className) }
29990
+ class=${ popupClassName }
29895
29991
  style=${ getPopupStyle(props) }
29992
+ onKeydownCapture=${ onKeyboardInteraction }
29896
29993
  onKeydown=${ onKeydown }
29897
29994
  onKeyup=${ onKeyup }
29898
29995
  ref=${ popupRef }
@@ -50824,6 +50921,33 @@
50824
50921
  di.set('label', undefined);
50825
50922
  }
50826
50923
  }
50924
+
50925
+ // remove BPMNLabel on external label removal
50926
+ this.executed('shape.delete', ifBpmn(function(event) {
50927
+ const context = event.context,
50928
+ labelTarget = context.labelTarget,
50929
+ di = labelTarget && getDi(labelTarget),
50930
+ diLabel = di && di.get('label');
50931
+
50932
+ if (!diLabel) {
50933
+ return;
50934
+ }
50935
+
50936
+ context.oldDiLabel = diLabel;
50937
+
50938
+ di.set('label', undefined);
50939
+ }));
50940
+
50941
+ this.reverted('shape.delete', ifBpmn(function(event) {
50942
+ const {
50943
+ labelTarget,
50944
+ oldDiLabel
50945
+ } = event.context;
50946
+
50947
+ if (oldDiLabel) {
50948
+ getDi(labelTarget).set('label', oldDiLabel);
50949
+ }
50950
+ }));
50827
50951
  }
50828
50952
 
50829
50953
  e$3(BpmnUpdater, CommandInterceptor);
@@ -58147,6 +58271,67 @@
58147
58271
  appendPreview: [ 'type', AppendPreview ]
58148
58272
  };
58149
58273
 
58274
+ /**
58275
+ * @typedef { {
58276
+ * x: number;
58277
+ * y: number;
58278
+ * width?: number;
58279
+ * height?: number;
58280
+ * maxWidth?: number;
58281
+ * maxHeight?: number;
58282
+ * minWidth?: number;
58283
+ * minHeight?: number;
58284
+ * } } TextBoxBounds
58285
+ *
58286
+ * @typedef { {
58287
+ * width?: string | number;
58288
+ * height?: string | number;
58289
+ * maxWidth?: string | number;
58290
+ * maxHeight?: string | number;
58291
+ * minWidth?: string | number;
58292
+ * minHeight?: string | number;
58293
+ * left?: string | number;
58294
+ * top?: string | number;
58295
+ * backgroundColor?: string | null;
58296
+ * position?: string;
58297
+ * overflow?: string;
58298
+ * border?: string | null;
58299
+ * wordWrap?: string;
58300
+ * textAlign?: string;
58301
+ * outline?: string;
58302
+ * transform?: string | null;
58303
+ * fontFamily?: string;
58304
+ * fontSize?: string | number;
58305
+ * fontWeight?: string | number;
58306
+ * lineHeight?: string | number;
58307
+ * padding?: string | number;
58308
+ * paddingTop?: string | number;
58309
+ * paddingRight?: string | number;
58310
+ * paddingBottom?: string | number;
58311
+ * paddingLeft?: string | number;
58312
+ * } } TextBoxStyle
58313
+ *
58314
+ * @typedef { {
58315
+ * autoResize?: boolean;
58316
+ * resizable?: boolean;
58317
+ * centerVertically?: boolean;
58318
+ * } } TextBoxOptions
58319
+ *
58320
+ * @typedef { {
58321
+ * width: number;
58322
+ * height: number;
58323
+ * dx: number;
58324
+ * dy: number;
58325
+ * } } TextBoxResizeEvent
58326
+ *
58327
+ * @typedef { {
58328
+ * container: HTMLElement;
58329
+ * keyHandler?: (event: KeyboardEvent) => void;
58330
+ * resizeHandler?: (event: TextBoxResizeEvent) => void;
58331
+ * focusoutHandler?: (event: FocusEvent) => void;
58332
+ * } } TextBoxConfig
58333
+ */
58334
+
58150
58335
  var min = Math.min,
58151
58336
  max = Math.max;
58152
58337
 
@@ -58176,11 +58361,7 @@
58176
58361
  * content
58177
58362
  * resize-handle
58178
58363
  *
58179
- * @param {object} options
58180
- * @param {DOMElement} options.container The DOM element to append the contentContainer to
58181
- * @param {Function} options.keyHandler Handler for key events
58182
- * @param {Function} options.resizeHandler Handler for resize events
58183
- * @param {Function} [options.focusoutHandler] Handler for focusout events
58364
+ * @param {TextBoxConfig} options
58184
58365
  */
58185
58366
  function TextBox(options) {
58186
58367
  this.container = options.container;
@@ -58191,7 +58372,10 @@
58191
58372
  '</div>'
58192
58373
  );
58193
58374
 
58194
- this.content = query('[contenteditable]', this.parent);
58375
+ /**
58376
+ * @type {HTMLElement}
58377
+ */
58378
+ this.content = /** @type {HTMLElement} */ (query('[contenteditable]', this.parent));
58195
58379
 
58196
58380
  this.keyHandler = options.keyHandler || function() {};
58197
58381
  this.resizeHandler = options.resizeHandler || function() {};
@@ -58205,19 +58389,12 @@
58205
58389
  /**
58206
58390
  * Create a text box with the given position, size, style and text content
58207
58391
  *
58208
- * @param {Object} bounds
58209
- * @param {Number} bounds.x absolute x position
58210
- * @param {Number} bounds.y absolute y position
58211
- * @param {Number} [bounds.width] fixed width value
58212
- * @param {Number} [bounds.height] fixed height value
58213
- * @param {Number} [bounds.maxWidth] maximum width value
58214
- * @param {Number} [bounds.maxHeight] maximum height value
58215
- * @param {Number} [bounds.minWidth] minimum width value
58216
- * @param {Number} [bounds.minHeight] minimum height value
58217
- * @param {Object} [style]
58218
- * @param {String} value text content
58392
+ * @param {TextBoxBounds} bounds
58393
+ * @param {TextBoxStyle|undefined} style
58394
+ * @param {string} value text content
58395
+ * @param {TextBoxOptions} [options]
58219
58396
  *
58220
- * @return {DOMElement} The created content DOM element
58397
+ * @return {HTMLElement} The created parent DOM element
58221
58398
  */
58222
58399
  TextBox.prototype.create = function(bounds, style, value, options) {
58223
58400
  var self = this;
@@ -58320,6 +58497,8 @@
58320
58497
 
58321
58498
  /**
58322
58499
  * Intercept paste events to remove formatting from pasted text.
58500
+ *
58501
+ * @param {ClipboardEvent} e
58323
58502
  */
58324
58503
  TextBox.prototype.handlePaste = function(e) {
58325
58504
  var options = this.options,
@@ -58350,6 +58529,9 @@
58350
58529
  }
58351
58530
  };
58352
58531
 
58532
+ /**
58533
+ * @param {string} text
58534
+ */
58353
58535
  TextBox.prototype.insertText = function(text) {
58354
58536
  text = normalizeEndOfLineSequences(text);
58355
58537
 
@@ -58565,11 +58747,17 @@
58565
58747
  };
58566
58748
 
58567
58749
 
58750
+ /**
58751
+ * @return {string}
58752
+ */
58568
58753
  TextBox.prototype.getValue = function() {
58569
58754
  return this.content.innerText.trim();
58570
58755
  };
58571
58756
 
58572
58757
 
58758
+ /**
58759
+ * @return {Range}
58760
+ */
58573
58761
  TextBox.prototype.getSelection = function() {
58574
58762
  var selection = window.getSelection(),
58575
58763
  range = selection.getRangeAt(0);
@@ -58578,6 +58766,10 @@
58578
58766
  };
58579
58767
 
58580
58768
 
58769
+ /**
58770
+ * @param {Node|null} container
58771
+ * @param {number} [offset]
58772
+ */
58581
58773
  TextBox.prototype.setSelection = function(container, offset) {
58582
58774
  var range = document.createRange();
58583
58775
 
@@ -58600,19 +58792,71 @@
58600
58792
  return string.replace(/\r\n|\r|\n/g, '\n');
58601
58793
  }
58602
58794
 
58795
+ /**
58796
+ * @typedef {import('diagram-js/lib/core/Canvas.js').default} Canvas
58797
+ * @typedef {import('diagram-js/lib/core/EventBus.js').default} EventBus
58798
+ *
58799
+ * @typedef {import('diagram-js/lib/model/Types.js').Element} Element
58800
+ *
58801
+ * @typedef {import('diagram-js/lib/util/Types.js').Rect} Rect
58802
+ *
58803
+ * @typedef {import('./TextBox.js').TextBoxBounds} TextBoxBounds
58804
+ * @typedef {import('./TextBox.js').TextBoxStyle} TextBoxStyle
58805
+ * @typedef {import('./TextBox.js').TextBoxOptions} TextBoxOptions
58806
+ * @typedef {import('./TextBox.js').TextBoxResizeEvent} TextBoxResizeEvent
58807
+ */
58808
+
58809
+ /**
58810
+ * The context returned by a {@link DirectEditingProvider} to activate
58811
+ * direct editing for an element.
58812
+ *
58813
+ * @typedef { {
58814
+ * bounds: TextBoxBounds;
58815
+ * text: string;
58816
+ * style?: TextBoxStyle;
58817
+ * options?: TextBoxOptions;
58818
+ * } } DirectEditingContext
58819
+ */
58820
+
58821
+ /**
58822
+ * A provider that enables direct editing for elements.
58823
+ *
58824
+ * @typedef { {
58825
+ * activate: (element: Element) => DirectEditingContext | null | undefined;
58826
+ * update: (element: Element, newText: string, previousText: string, bounds: Rect) => void;
58827
+ * } } DirectEditingProvider
58828
+ */
58829
+
58830
+ /**
58831
+ * @typedef { {
58832
+ * element: Element;
58833
+ * context: DirectEditingContext;
58834
+ * provider: DirectEditingProvider;
58835
+ * } } DirectEditingActive
58836
+ */
58837
+
58603
58838
  /**
58604
58839
  * A direct editing component that allows users
58605
58840
  * to edit an elements text directly in the diagram
58606
58841
  *
58607
- * @param {EventBus} eventBus the event bus
58608
- * @param {Canvas} canvas the canvas
58842
+ * @param {EventBus} eventBus
58843
+ * @param {Canvas} canvas
58609
58844
  */
58610
58845
  function DirectEditing(eventBus, canvas) {
58611
58846
 
58612
58847
  this._eventBus = eventBus;
58613
58848
  this._canvas = canvas;
58614
58849
 
58850
+ /**
58851
+ * @type {DirectEditingProvider[]}
58852
+ */
58615
58853
  this._providers = [];
58854
+
58855
+ /**
58856
+ * @type {DirectEditingActive | null}
58857
+ */
58858
+ this._active = null;
58859
+
58616
58860
  this._textbox = new TextBox({
58617
58861
  container: canvas.getContainer(),
58618
58862
  keyHandler: bind$1(this._handleKey, this),
@@ -58627,13 +58871,17 @@
58627
58871
 
58628
58872
 
58629
58873
  /**
58630
- * Register a direct editing provider
58631
-
58632
- * @param {Object} provider the provider, must expose an #activate(element) method that returns
58633
- * an activation context ({ bounds: {x, y, width, height }, text }) if
58634
- * direct editing is available for the given element.
58635
- * Additionally the provider must expose a #update(element, value) method
58636
- * to receive direct editing updates.
58874
+ * Register a direct editing provider.
58875
+ *
58876
+ * A provider must expose an `#activate(element)` method that returns
58877
+ * an activation context (`{ bounds: { x, y, width, height }, text }`) if
58878
+ * direct editing is available for the given element.
58879
+ *
58880
+ * Additionally the provider must expose an
58881
+ * `#update(element, newText, previousText, bounds)` method to receive
58882
+ * direct editing updates.
58883
+ *
58884
+ * @param {DirectEditingProvider} provider
58637
58885
  */
58638
58886
  DirectEditing.prototype.registerProvider = function(provider) {
58639
58887
  this._providers.push(provider);
@@ -58643,7 +58891,7 @@
58643
58891
  /**
58644
58892
  * Returns true if direct editing is currently active
58645
58893
  *
58646
- * @param {djs.model.Base} [element]
58894
+ * @param {Element} [element]
58647
58895
  *
58648
58896
  * @return {boolean}
58649
58897
  */
@@ -58665,10 +58913,17 @@
58665
58913
  };
58666
58914
 
58667
58915
 
58916
+ /**
58917
+ * @param {string} event
58918
+ * @param {Object} [context]
58919
+ */
58668
58920
  DirectEditing.prototype._fire = function(event, context) {
58669
58921
  this._eventBus.fire('directEditing.' + event, context || { active: this._active });
58670
58922
  };
58671
58923
 
58924
+ /**
58925
+ * Close direct editing, if it is currently active.
58926
+ */
58672
58927
  DirectEditing.prototype.close = function() {
58673
58928
  this._fire('deactivate');
58674
58929
 
@@ -58690,6 +58945,10 @@
58690
58945
  this.resizable = undefined;
58691
58946
  };
58692
58947
 
58948
+ /**
58949
+ * Complete direct editing, updating the element via the
58950
+ * active provider if the text or bounds changed.
58951
+ */
58693
58952
  DirectEditing.prototype.complete = function() {
58694
58953
 
58695
58954
  var active = this._active;
@@ -58725,11 +58984,19 @@
58725
58984
  };
58726
58985
 
58727
58986
 
58987
+ /**
58988
+ * Returns the current text value.
58989
+ *
58990
+ * @return {string}
58991
+ */
58728
58992
  DirectEditing.prototype.getValue = function() {
58729
58993
  return this._textbox.getValue();
58730
58994
  };
58731
58995
 
58732
58996
 
58997
+ /**
58998
+ * @param {KeyboardEvent} e
58999
+ */
58733
59000
  DirectEditing.prototype._handleKey = function(e) {
58734
59001
 
58735
59002
  // stop bubble
@@ -58751,11 +59018,17 @@
58751
59018
  };
58752
59019
 
58753
59020
 
59021
+ /**
59022
+ * @param {TextBoxResizeEvent} event
59023
+ */
58754
59024
  DirectEditing.prototype._handleResize = function(event) {
58755
59025
  this._fire('resize', event);
58756
59026
  };
58757
59027
 
58758
59028
 
59029
+ /**
59030
+ * @param {FocusEvent} event
59031
+ */
58759
59032
  DirectEditing.prototype._handleFocusout = function(event) {
58760
59033
 
58761
59034
  // ignore focus moves within the textbox (e.g. to the resize handle)
@@ -58770,8 +59043,9 @@
58770
59043
  /**
58771
59044
  * Activate direct editing on the given element
58772
59045
  *
58773
- * @param {Object} ElementDescriptor the descriptor for a shape or connection
58774
- * @return {Boolean} true if the activation was possible
59046
+ * @param {Element} element
59047
+ *
59048
+ * @return {boolean} true if the activation was possible
58775
59049
  */
58776
59050
  DirectEditing.prototype.activate = function(element) {
58777
59051
  if (this.isActive()) {
@@ -63117,13 +63391,9 @@
63117
63391
 
63118
63392
  var KEY_TO_DIRECTION = {
63119
63393
  ArrowLeft: LEFT,
63120
- Left: LEFT,
63121
63394
  ArrowUp: UP,
63122
- Up: UP,
63123
63395
  ArrowRight: RIGHT,
63124
- Right: RIGHT,
63125
- ArrowDown: DOWN,
63126
- Down: DOWN
63396
+ ArrowDown: DOWN
63127
63397
  };
63128
63398
 
63129
63399
  var DIRECTIONS_DELTA = {
@@ -68667,12 +68937,21 @@
68667
68937
  * @return {Shape[]}
68668
68938
  */
68669
68939
  BpmnCreateMoveSnapping.prototype.getSnapTargets = function(shape, target) {
68670
- return CreateMoveSnapping.prototype.getSnapTargets.call(this, shape, target)
68671
- .filter(function(snapTarget) {
68940
+ var snapTargets = CreateMoveSnapping.prototype.getSnapTargets.call(this, shape, target);
68672
68941
 
68673
- // do not snap to lanes
68674
- return !is(snapTarget, 'bpmn:Lane');
68675
- });
68942
+ if (shape.labelTarget && shape.labelTarget.parent && shape.labelTarget.parent !== target) {
68943
+
68944
+ // labels stay at root, so include their target's peers
68945
+ snapTargets = snapTargets.concat(
68946
+ CreateMoveSnapping.prototype.getSnapTargets.call(this, shape, shape.labelTarget.parent)
68947
+ );
68948
+ }
68949
+
68950
+ return snapTargets.filter(function(snapTarget, index) {
68951
+
68952
+ // do not snap to lanes
68953
+ return !is(snapTarget, 'bpmn:Lane') && snapTargets.indexOf(snapTarget) === index;
68954
+ });
68676
68955
  };
68677
68956
 
68678
68957
  // helpers //////////