bpmn-js 17.11.0 → 18.0.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 (181) hide show
  1. package/dist/assets/diagram-js.css +17 -8
  2. package/dist/bpmn-modeler.development.js +1396 -1161
  3. package/dist/bpmn-modeler.production.min.js +47 -46
  4. package/dist/bpmn-navigated-viewer.development.js +305 -767
  5. package/dist/bpmn-navigated-viewer.production.min.js +5 -5
  6. package/dist/bpmn-viewer.development.js +277 -699
  7. package/dist/bpmn-viewer.production.min.js +5 -5
  8. package/lib/BaseModeler.d.ts +3 -3
  9. package/lib/BaseViewer.d.ts +8 -8
  10. package/lib/Modeler.d.ts +2 -2
  11. package/lib/Modeler.js +3 -1
  12. package/lib/NavigatedViewer.d.ts +1 -1
  13. package/lib/Viewer.d.ts +1 -1
  14. package/lib/Viewer.js +0 -2
  15. package/lib/core/index.d.ts +1 -1
  16. package/lib/draw/BpmnRenderUtil.d.ts +12 -12
  17. package/lib/draw/BpmnRenderer.d.ts +4 -4
  18. package/lib/draw/TextRenderer.d.ts +2 -2
  19. package/lib/draw/index.d.ts +4 -4
  20. package/lib/features/align-elements/AlignElementsContextPadProvider.d.ts +6 -6
  21. package/lib/features/align-elements/AlignElementsIcons.d.ts +7 -7
  22. package/lib/features/align-elements/AlignElementsMenuProvider.d.ts +6 -6
  23. package/lib/features/align-elements/BpmnAlignElements.d.ts +1 -1
  24. package/lib/features/align-elements/index.d.ts +5 -5
  25. package/lib/features/append-preview/AppendPreview.d.ts +7 -7
  26. package/lib/features/append-preview/index.d.ts +3 -3
  27. package/lib/features/auto-place/BpmnAutoPlace.d.ts +2 -2
  28. package/lib/features/auto-place/BpmnAutoPlaceUtil.d.ts +4 -4
  29. package/lib/features/auto-place/index.d.ts +3 -3
  30. package/lib/features/auto-resize/BpmnAutoResize.d.ts +3 -3
  31. package/lib/features/auto-resize/BpmnAutoResizeProvider.d.ts +3 -3
  32. package/lib/features/auto-resize/index.d.ts +3 -3
  33. package/lib/features/context-pad/ContextPadProvider.d.ts +16 -16
  34. package/lib/features/context-pad/ContextPadProvider.js +2 -6
  35. package/lib/features/context-pad/index.d.ts +3 -3
  36. package/lib/features/copy-paste/BpmnCopyPaste.d.ts +3 -3
  37. package/lib/features/copy-paste/ModdleCopy.d.ts +4 -4
  38. package/lib/features/copy-paste/index.d.ts +4 -4
  39. package/lib/features/di-ordering/BpmnDiOrdering.d.ts +2 -2
  40. package/lib/features/di-ordering/index.d.ts +2 -2
  41. package/lib/features/distribute-elements/BpmnDistributeElements.d.ts +1 -1
  42. package/lib/features/distribute-elements/DistributeElementsIcons.d.ts +2 -2
  43. package/lib/features/distribute-elements/DistributeElementsMenuProvider.d.ts +6 -6
  44. package/lib/features/distribute-elements/index.d.ts +4 -4
  45. package/lib/features/drilldown/DrilldownBreadcrumbs.d.ts +5 -5
  46. package/lib/features/drilldown/DrilldownCentering.d.ts +2 -2
  47. package/lib/features/drilldown/DrilldownOverlayBehavior.d.ts +7 -7
  48. package/lib/features/drilldown/SubprocessCompatibility.d.ts +6 -6
  49. package/lib/features/drilldown/index.d.ts +6 -6
  50. package/lib/features/editor-actions/BpmnEditorActions.d.ts +1 -1
  51. package/lib/features/editor-actions/index.d.ts +2 -2
  52. package/lib/features/grid-snapping/BpmnGridSnapping.d.ts +1 -1
  53. package/lib/features/grid-snapping/behavior/GridSnappingAutoPlaceBehavior.d.ts +4 -4
  54. package/lib/features/grid-snapping/behavior/GridSnappingLayoutConnectionBehavior.d.ts +4 -4
  55. package/lib/features/grid-snapping/behavior/GridSnappingParticipantBehavior.d.ts +3 -3
  56. package/lib/features/grid-snapping/behavior/index.d.ts +4 -4
  57. package/lib/features/grid-snapping/index.d.ts +3 -3
  58. package/lib/features/interaction-events/BpmnInteractionEvents.d.ts +4 -4
  59. package/lib/features/interaction-events/BpmnInteractionEvents.js +2 -6
  60. package/lib/features/interaction-events/index.d.ts +2 -2
  61. package/lib/features/keyboard/BpmnKeyboardBindings.d.ts +3 -3
  62. package/lib/features/keyboard/index.d.ts +3 -3
  63. package/lib/features/label-editing/LabelEditingPreview.d.ts +3 -3
  64. package/lib/features/label-editing/LabelEditingProvider.d.ts +8 -8
  65. package/lib/features/label-editing/cmd/UpdateLabelHandler.d.ts +4 -4
  66. package/lib/features/label-editing/index.d.ts +4 -4
  67. package/lib/features/modeling/BpmnFactory.d.ts +3 -3
  68. package/lib/features/modeling/BpmnLayouter.d.ts +5 -5
  69. package/lib/features/modeling/BpmnUpdater.d.ts +8 -8
  70. package/lib/features/modeling/BpmnUpdater.js +9 -28
  71. package/lib/features/modeling/ElementFactory.d.ts +11 -11
  72. package/lib/features/modeling/ElementFactory.js +1 -2
  73. package/lib/features/modeling/Modeling.d.ts +15 -15
  74. package/lib/features/modeling/Modeling.test.ts +4 -4
  75. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.d.ts +7 -8
  76. package/lib/features/modeling/behavior/AdaptiveLabelPositioningBehavior.js +7 -3
  77. package/lib/features/modeling/behavior/AppendBehavior.d.ts +1 -1
  78. package/lib/features/modeling/behavior/AssociationBehavior.d.ts +2 -2
  79. package/lib/features/modeling/behavior/AttachEventBehavior.d.ts +2 -2
  80. package/lib/features/modeling/behavior/BoundaryEventBehavior.d.ts +2 -2
  81. package/lib/features/modeling/behavior/CompensateBoundaryEventBehavior.d.ts +2 -2
  82. package/lib/features/modeling/behavior/CreateBehavior.d.ts +1 -1
  83. package/lib/features/modeling/behavior/CreateDataObjectBehavior.d.ts +2 -2
  84. package/lib/features/modeling/behavior/CreateParticipantBehavior.d.ts +3 -3
  85. package/lib/features/modeling/behavior/DataInputAssociationBehavior.d.ts +2 -2
  86. package/lib/features/modeling/behavior/DataStoreBehavior.d.ts +4 -4
  87. package/lib/features/modeling/behavior/DeleteLaneBehavior.d.ts +2 -2
  88. package/lib/features/modeling/behavior/DetachEventBehavior.d.ts +2 -2
  89. package/lib/features/modeling/behavior/DropOnFlowBehavior.d.ts +3 -3
  90. package/lib/features/modeling/behavior/EventBasedGatewayBehavior.d.ts +2 -2
  91. package/lib/features/modeling/behavior/FixHoverBehavior.d.ts +3 -3
  92. package/lib/features/modeling/behavior/GroupBehavior.d.ts +9 -9
  93. package/lib/features/modeling/behavior/ImportDockingFix.d.ts +1 -1
  94. package/lib/features/modeling/behavior/IsHorizontalFix.d.ts +1 -1
  95. package/lib/features/modeling/behavior/LabelBehavior.d.ts +6 -6
  96. package/lib/features/modeling/behavior/LayoutConnectionBehavior.d.ts +2 -2
  97. package/lib/features/modeling/behavior/MessageFlowBehavior.d.ts +2 -2
  98. package/lib/features/modeling/behavior/RemoveElementBehavior.d.ts +3 -3
  99. package/lib/features/modeling/behavior/RemoveEmbeddedLabelBoundsBehavior.d.ts +2 -2
  100. package/lib/features/modeling/behavior/RemoveParticipantBehavior.d.ts +2 -2
  101. package/lib/features/modeling/behavior/ReplaceConnectionBehavior.d.ts +4 -4
  102. package/lib/features/modeling/behavior/ReplaceElementBehaviour.d.ts +6 -6
  103. package/lib/features/modeling/behavior/ResizeBehavior.d.ts +5 -8
  104. package/lib/features/modeling/behavior/ResizeBehavior.js +3 -6
  105. package/lib/features/modeling/behavior/ResizeLaneBehavior.d.ts +2 -2
  106. package/lib/features/modeling/behavior/RootElementReferenceBehavior.d.ts +8 -8
  107. package/lib/features/modeling/behavior/SetCompensationActivityAfterPasteBehavior.d.ts +3 -3
  108. package/lib/features/modeling/behavior/SpaceToolBehavior.d.ts +2 -2
  109. package/lib/features/modeling/behavior/SubProcessPlaneBehavior.d.ts +10 -10
  110. package/lib/features/modeling/behavior/SubProcessStartEventBehavior.d.ts +2 -2
  111. package/lib/features/modeling/behavior/TextAnnotationBehavior.d.ts +1 -1
  112. package/lib/features/modeling/behavior/ToggleCollapseConnectionBehaviour.d.ts +5 -5
  113. package/lib/features/modeling/behavior/ToggleElementCollapseBehaviour.d.ts +3 -3
  114. package/lib/features/modeling/behavior/UnclaimIdBehavior.d.ts +4 -4
  115. package/lib/features/modeling/behavior/UnsetDefaultFlowBehavior.d.ts +2 -2
  116. package/lib/features/modeling/behavior/UpdateFlowNodeRefsBehavior.d.ts +2 -2
  117. package/lib/features/modeling/behavior/index.d.ts +1 -1
  118. package/lib/features/modeling/behavior/util/CategoryUtil.d.ts +6 -6
  119. package/lib/features/modeling/behavior/util/ConnectionLayoutUtil.d.ts +2 -2
  120. package/lib/features/modeling/behavior/util/LabelLayoutUtil.d.ts +4 -4
  121. package/lib/features/modeling/behavior/util/LayoutUtil.d.ts +2 -2
  122. package/lib/features/modeling/behavior/util/LineAttachmentUtil.d.ts +2 -2
  123. package/lib/features/modeling/behavior/util/LineIntersect.d.ts +1 -1
  124. package/lib/features/modeling/cmd/AddLaneHandler.d.ts +3 -3
  125. package/lib/features/modeling/cmd/AddLaneHandler.js +5 -10
  126. package/lib/features/modeling/cmd/IdClaimHandler.d.ts +2 -2
  127. package/lib/features/modeling/cmd/ResizeLaneHandler.d.ts +5 -5
  128. package/lib/features/modeling/cmd/SetColorHandler.d.ts +3 -3
  129. package/lib/features/modeling/cmd/SplitLaneHandler.d.ts +2 -2
  130. package/lib/features/modeling/cmd/UpdateCanvasRootHandler.d.ts +3 -3
  131. package/lib/features/modeling/cmd/UpdateFlowNodeRefsHandler.d.ts +3 -3
  132. package/lib/features/modeling/cmd/UpdateModdlePropertiesHandler.d.ts +4 -4
  133. package/lib/features/modeling/cmd/UpdatePropertiesHandler.d.ts +7 -7
  134. package/lib/features/modeling/cmd/UpdateSemanticParentHandler.d.ts +2 -2
  135. package/lib/features/modeling/index.d.ts +8 -8
  136. package/lib/features/modeling/util/LaneUtil.d.ts +2 -2
  137. package/lib/features/modeling/util/ModelingUtil.d.ts +2 -2
  138. package/lib/features/modeling-feedback/ModelingFeedback.d.ts +2 -2
  139. package/lib/features/modeling-feedback/index.d.ts +3 -3
  140. package/lib/features/ordering/BpmnOrderingProvider.d.ts +2 -2
  141. package/lib/features/ordering/index.d.ts +2 -2
  142. package/lib/features/outline/OutlineProvider.d.ts +4 -4
  143. package/lib/features/outline/OutlineUtil.d.ts +1 -1
  144. package/lib/features/outline/index.d.ts +3 -3
  145. package/lib/features/palette/PaletteProvider.d.ts +8 -8
  146. package/lib/features/palette/index.d.ts +3 -3
  147. package/lib/features/popup-menu/ReplaceMenuProvider.d.ts +15 -15
  148. package/lib/features/popup-menu/ReplaceMenuProvider.js +14 -16
  149. package/lib/features/popup-menu/index.d.ts +3 -3
  150. package/lib/features/popup-menu/util/TypeUtil.d.ts +2 -2
  151. package/lib/features/replace/BpmnReplace.d.ts +9 -11
  152. package/lib/features/replace/index.d.ts +2 -2
  153. package/lib/features/replace-preview/BpmnReplacePreview.d.ts +5 -5
  154. package/lib/features/replace-preview/index.d.ts +3 -3
  155. package/lib/features/rules/BpmnRules.d.ts +9 -9
  156. package/lib/features/rules/index.d.ts +3 -3
  157. package/lib/features/search/BpmnSearchProvider.d.ts +12 -7
  158. package/lib/features/search/BpmnSearchProvider.js +40 -152
  159. package/lib/features/search/index.d.ts +3 -3
  160. package/lib/features/search/index.js +3 -1
  161. package/lib/features/snapping/BpmnConnectSnapping.d.ts +5 -5
  162. package/lib/features/snapping/BpmnCreateMoveSnapping.d.ts +7 -7
  163. package/lib/features/snapping/BpmnSnappingUtil.d.ts +3 -3
  164. package/lib/features/snapping/index.d.ts +4 -4
  165. package/lib/features/space-tool/BpmnSpaceTool.d.ts +4 -4
  166. package/lib/features/space-tool/index.d.ts +2 -2
  167. package/lib/import/BpmnImporter.d.ts +11 -11
  168. package/lib/import/BpmnTreeWalker.d.ts +2 -2
  169. package/lib/import/Importer.d.ts +1 -1
  170. package/lib/import/index.d.ts +2 -2
  171. package/lib/index.d.ts +1 -0
  172. package/lib/index.js +3 -0
  173. package/lib/util/CompatibilityUtil.d.ts +1 -1
  174. package/lib/util/DiUtil.d.ts +2 -2
  175. package/lib/util/DrilldownUtil.d.ts +2 -2
  176. package/lib/util/LabelUtil.d.ts +6 -6
  177. package/lib/util/LabelUtil.js +5 -1
  178. package/lib/util/ModelUtil.d.ts +2 -2
  179. package/lib/util/PoweredByUtil.d.ts +2 -2
  180. package/package.json +23 -24
  181. package/index.js +0 -3
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-navigated-viewer v17.11.0
2
+ * bpmn-js - bpmn-navigated-viewer v18.0.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-09-12
11
+ * Date: 2024-11-06
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -821,17 +821,6 @@
821
821
  return isObject(value) && has$1(value, 'waypoints');
822
822
  }
823
823
 
824
- /**
825
- * Checks whether a value is an instance of Label.
826
- *
827
- * @param {any} value
828
- *
829
- * @return {boolean}
830
- */
831
- function isLabel(value) {
832
- return isObject(value) && has$1(value, 'labelTarget');
833
- }
834
-
835
824
  /**
836
825
  * @typedef {import('diagram-js/lib/util/Types').Point} Point
837
826
  * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
@@ -1360,26 +1349,6 @@
1360
1349
  return this.list.contains(name);
1361
1350
  };
1362
1351
 
1363
- /**
1364
- * Clear utility
1365
- */
1366
-
1367
- /**
1368
- * Removes all children from the given element
1369
- *
1370
- * @param {SVGElement} element
1371
- * @return {Element} the element (for chaining)
1372
- */
1373
- function clear$1(element) {
1374
- var child;
1375
-
1376
- while ((child = element.firstChild)) {
1377
- element.removeChild(child);
1378
- }
1379
-
1380
- return element;
1381
- }
1382
-
1383
1352
  var ns = {
1384
1353
  svg: 'http://www.w3.org/2000/svg'
1385
1354
  };
@@ -2600,16 +2569,6 @@
2600
2569
 
2601
2570
  var domify$1 = domify;
2602
2571
 
2603
- /**
2604
- * @param { HTMLElement } element
2605
- * @param { String } selector
2606
- *
2607
- * @return { boolean }
2608
- */
2609
- function matches(element, selector) {
2610
- return element && typeof element.matches === 'function' && element.matches(selector) || false;
2611
- }
2612
-
2613
2572
  function query(selector, el) {
2614
2573
  el = el || document;
2615
2574
 
@@ -5217,6 +5176,8 @@
5217
5176
 
5218
5177
  return bbox;
5219
5178
  } catch (e) {
5179
+ console.log(e);
5180
+
5220
5181
  return { width: 0, height: 0 };
5221
5182
  }
5222
5183
  }
@@ -6815,7 +6776,7 @@
6815
6776
  // document wide unique overlay ids
6816
6777
  var ids = new IdGenerator('ov');
6817
6778
 
6818
- var LOW_PRIORITY$4 = 500;
6779
+ var LOW_PRIORITY$3 = 500;
6819
6780
 
6820
6781
  /**
6821
6782
  * @typedef {import('../../core/Canvas').default} Canvas
@@ -7445,7 +7406,7 @@
7445
7406
 
7446
7407
  // move integration
7447
7408
 
7448
- eventBus.on('element.changed', LOW_PRIORITY$4, function(e) {
7409
+ eventBus.on('element.changed', LOW_PRIORITY$3, function(e) {
7449
7410
  var element = e.element;
7450
7411
 
7451
7412
  var container = self._getOverlayContainer(element, true);
@@ -7619,7 +7580,7 @@
7619
7580
  * @typedef { (context: CommandContext) => void } ComposeHandlerFunction
7620
7581
  */
7621
7582
 
7622
- var DEFAULT_PRIORITY$3 = 1000;
7583
+ var DEFAULT_PRIORITY$2 = 1000;
7623
7584
 
7624
7585
  /**
7625
7586
  * A utility that can be used to plug into the command execution for
@@ -7686,7 +7647,7 @@
7686
7647
  that = unwrap;
7687
7648
  unwrap = handlerFn;
7688
7649
  handlerFn = priority;
7689
- priority = DEFAULT_PRIORITY$3;
7650
+ priority = DEFAULT_PRIORITY$2;
7690
7651
  }
7691
7652
 
7692
7653
  if (isObject(unwrap)) {
@@ -8483,7 +8444,7 @@
8483
8444
  * @typedef {import('../../model/Types').Shape} Shape
8484
8445
  */
8485
8446
 
8486
- var LOW_PRIORITY$3 = 250;
8447
+ var LOW_PRIORITY$2 = 250;
8487
8448
  var ARROW_DOWN_SVG = '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>';
8488
8449
 
8489
8450
  var EMPTY_MARKER = 'bjs-drilldown-empty';
@@ -8508,7 +8469,7 @@
8508
8469
 
8509
8470
  var self = this;
8510
8471
 
8511
- this.executed('shape.toggleCollapse', LOW_PRIORITY$3, function(context) {
8472
+ this.executed('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8512
8473
  var shape = context.shape;
8513
8474
 
8514
8475
  // Add overlay to the collapsed shape
@@ -8520,7 +8481,7 @@
8520
8481
  }, true);
8521
8482
 
8522
8483
 
8523
- this.reverted('shape.toggleCollapse', LOW_PRIORITY$3, function(context) {
8484
+ this.reverted('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8524
8485
  var shape = context.shape;
8525
8486
 
8526
8487
  // Add overlay to the collapsed shape
@@ -8532,7 +8493,7 @@
8532
8493
  }, true);
8533
8494
 
8534
8495
 
8535
- this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$3,
8496
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8536
8497
  function(context) {
8537
8498
  var oldParent = context.oldParent,
8538
8499
  newParent = context.newParent || context.parent,
@@ -8549,7 +8510,7 @@
8549
8510
  }, true);
8550
8511
 
8551
8512
 
8552
- this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$3,
8513
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8553
8514
  function(context) {
8554
8515
  var oldParent = context.oldParent,
8555
8516
  newParent = context.newParent || context.parent,
@@ -8693,409 +8654,6 @@
8693
8654
  subprocessCompatibility: [ 'type', SubprocessCompatibility ]
8694
8655
  };
8695
8656
 
8696
- var LOW_PRIORITY$2 = 500;
8697
-
8698
- var DEFAULT_PRIORITY$2 = 1000;
8699
-
8700
- /**
8701
- * @typedef {import('../../model/Types').Element} Element
8702
- *
8703
- * @typedef {import('./OutlineProvider').default} OutlineProvider
8704
- * @typedef {import('../../core/EventBus').default} EventBus
8705
- * @typedef {import('../../draw/Styles').default} Styles
8706
- */
8707
-
8708
- /**
8709
- * @class
8710
- *
8711
- * A plugin that adds an outline to shapes and connections that may be activated and styled
8712
- * via CSS classes.
8713
- *
8714
- * @param {EventBus} eventBus
8715
- * @param {Styles} styles
8716
- */
8717
- function Outline(eventBus, styles) {
8718
-
8719
- this._eventBus = eventBus;
8720
-
8721
- this.offset = 5;
8722
-
8723
- var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
8724
-
8725
- var self = this;
8726
-
8727
- /**
8728
- * @param {SVGElement} gfx
8729
- *
8730
- * @return {SVGElement} outline
8731
- */
8732
- function createOutline(gfx) {
8733
- var outline = create$1('rect');
8734
-
8735
- attr$1(outline, assign$1({
8736
- x: 0,
8737
- y: 0,
8738
- rx: 4,
8739
- width: 100,
8740
- height: 100
8741
- }, OUTLINE_STYLE));
8742
-
8743
- return outline;
8744
- }
8745
-
8746
- // A low priortity is necessary, because outlines of labels have to be updated
8747
- // after the label bounds have been updated in the renderer.
8748
- eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$2, function(event) {
8749
- var element = event.element,
8750
- gfx = event.gfx;
8751
-
8752
- var outline = query('.djs-outline', gfx);
8753
-
8754
- if (!outline) {
8755
- outline = self.getOutline(element) || createOutline();
8756
- append(gfx, outline);
8757
- }
8758
-
8759
- self.updateShapeOutline(outline, element);
8760
- });
8761
-
8762
- eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
8763
- var element = event.element,
8764
- gfx = event.gfx;
8765
-
8766
- var outline = query('.djs-outline', gfx);
8767
-
8768
- if (!outline) {
8769
- outline = createOutline();
8770
- append(gfx, outline);
8771
- }
8772
-
8773
- self.updateConnectionOutline(outline, element);
8774
- });
8775
- }
8776
-
8777
-
8778
- /**
8779
- * Updates the outline of a shape respecting the dimension of the
8780
- * element and an outline offset.
8781
- *
8782
- * @param {SVGElement} outline
8783
- * @param {Element} element
8784
- */
8785
- Outline.prototype.updateShapeOutline = function(outline, element) {
8786
-
8787
- var updated = false;
8788
- var providers = this._getProviders();
8789
-
8790
- if (providers.length) {
8791
- forEach$1(providers, function(provider) {
8792
- updated = updated || provider.updateOutline(element, outline);
8793
- });
8794
- }
8795
-
8796
- if (!updated) {
8797
- attr$1(outline, {
8798
- x: -this.offset,
8799
- y: -this.offset,
8800
- width: element.width + this.offset * 2,
8801
- height: element.height + this.offset * 2
8802
- });
8803
- }
8804
- };
8805
-
8806
- /**
8807
- * Updates the outline of a connection respecting the bounding box of
8808
- * the connection and an outline offset.
8809
- * Register an outline provider with the given priority.
8810
- *
8811
- * @param {SVGElement} outline
8812
- * @param {Element} connection
8813
- */
8814
- Outline.prototype.updateConnectionOutline = function(outline, connection) {
8815
- var bbox = getBBox(connection);
8816
-
8817
- attr$1(outline, {
8818
- x: bbox.x - this.offset,
8819
- y: bbox.y - this.offset,
8820
- width: bbox.width + this.offset * 2,
8821
- height: bbox.height + this.offset * 2
8822
- });
8823
- };
8824
-
8825
- /**
8826
- * Register an outline provider with the given priority.
8827
- *
8828
- * @param {number} priority
8829
- * @param {OutlineProvider} provider
8830
- */
8831
- Outline.prototype.registerProvider = function(priority, provider) {
8832
- if (!provider) {
8833
- provider = priority;
8834
- priority = DEFAULT_PRIORITY$2;
8835
- }
8836
-
8837
- this._eventBus.on('outline.getProviders', priority, function(event) {
8838
- event.providers.push(provider);
8839
- });
8840
- };
8841
-
8842
- /**
8843
- * Returns the registered outline providers.
8844
- *
8845
- * @returns {OutlineProvider[]}
8846
- */
8847
- Outline.prototype._getProviders = function() {
8848
- var event = this._eventBus.createEvent({
8849
- type: 'outline.getProviders',
8850
- providers: []
8851
- });
8852
-
8853
- this._eventBus.fire(event);
8854
-
8855
- return event.providers;
8856
- };
8857
-
8858
- /**
8859
- * Returns the outline for an element.
8860
- *
8861
- * @param {Element} element
8862
- */
8863
- Outline.prototype.getOutline = function(element) {
8864
- var outline;
8865
- var providers = this._getProviders();
8866
-
8867
- forEach$1(providers, function(provider) {
8868
-
8869
- if (!isFunction(provider.getOutline)) {
8870
- return;
8871
- }
8872
-
8873
- outline = outline || provider.getOutline(element);
8874
- });
8875
-
8876
- return outline;
8877
- };
8878
-
8879
- Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
8880
-
8881
- /**
8882
- * @type { import('didi').ModuleDeclaration }
8883
- */
8884
- var OutlineModule$1 = {
8885
- __init__: [ 'outline' ],
8886
- outline: [ 'type', Outline ]
8887
- };
8888
-
8889
- 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';
8890
- 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';
8891
-
8892
- /**
8893
- * @typedef { import('diagram-js/lib/util/Types').Dimensions} Dimensions
8894
- */
8895
-
8896
- /**
8897
- * @type {Dimensions}
8898
- */
8899
- const DATA_OBJECT_REFERENCE_STANDARD_SIZE = { width: 36, height: 50 };
8900
-
8901
- /**
8902
- * @type {Dimensions}
8903
- */
8904
- const DATA_STORE_REFERENCE_STANDARD_SIZE = { width: 50, height: 50 };
8905
-
8906
- /**
8907
- * Create a path element with given attributes.
8908
- * @param {string} path
8909
- * @param {Object} attrs
8910
- * @param {Object} OUTLINE_STYLE
8911
- * @return {SVGElement}
8912
- */
8913
- function createPath(path, attrs, OUTLINE_STYLE) {
8914
- return create$1('path', {
8915
- d: path,
8916
- strokeWidth: 2,
8917
- transform: `translate(${attrs.x}, ${attrs.y})`,
8918
- ...OUTLINE_STYLE
8919
- });
8920
- }
8921
-
8922
- /**
8923
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').default } BaseOutlineProvider
8924
- *
8925
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').Outline } Outline
8926
- *
8927
- * @typedef { import('diagram-js/lib/draw/Styles').default } Styles
8928
- *
8929
- * @typedef { import('diagram-js/lib/model/Types').Element } Element
8930
- */
8931
-
8932
- const DEFAULT_OFFSET = 5;
8933
-
8934
- /**
8935
- * BPMN-specific outline provider.
8936
- *
8937
- * @implements {BaseOutlineProvider}
8938
- *
8939
- * @param {Outline} outline
8940
- * @param {Styles} styles
8941
- */
8942
- function OutlineProvider(outline, styles) {
8943
-
8944
- this._styles = styles;
8945
- outline.registerProvider(this);
8946
- }
8947
-
8948
- OutlineProvider.$inject = [
8949
- 'outline',
8950
- 'styles'
8951
- ];
8952
-
8953
- /**
8954
- * Returns outline for a given element.
8955
- *
8956
- * @param {Element} element
8957
- *
8958
- * @return {Outline}
8959
- */
8960
- OutlineProvider.prototype.getOutline = function(element) {
8961
-
8962
- const OUTLINE_STYLE = this._styles.cls('djs-outline', [ 'no-fill' ]);
8963
-
8964
- var outline;
8965
-
8966
- if (isLabel(element)) {
8967
- return;
8968
- }
8969
-
8970
- if (is$1(element, 'bpmn:Gateway')) {
8971
- outline = create$1('rect');
8972
-
8973
- assign$1(outline.style, {
8974
- 'transform-box': 'fill-box',
8975
- 'transform': 'rotate(45deg)',
8976
- 'transform-origin': 'center'
8977
- });
8978
-
8979
- attr$1(outline, assign$1({
8980
- x: 2,
8981
- y: 2,
8982
- rx: 4,
8983
- width: element.width - 4,
8984
- height: element.height - 4,
8985
- }, OUTLINE_STYLE));
8986
-
8987
- } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Group', 'bpmn:CallActivity' ])) {
8988
- outline = create$1('rect');
8989
-
8990
- attr$1(outline, assign$1({
8991
- x: -DEFAULT_OFFSET,
8992
- y: -DEFAULT_OFFSET,
8993
- rx: 14,
8994
- width: element.width + DEFAULT_OFFSET * 2,
8995
- height: element.height + DEFAULT_OFFSET * 2
8996
- }, OUTLINE_STYLE));
8997
-
8998
- } else if (is$1(element, 'bpmn:EndEvent')) {
8999
-
9000
- outline = create$1('circle');
9001
-
9002
- // Extra 1px offset needed due to increased stroke-width of end event
9003
- // which makes it bigger than other events.
9004
-
9005
- attr$1(outline, assign$1({
9006
- cx: element.width / 2,
9007
- cy: element.height / 2,
9008
- r: element.width / 2 + DEFAULT_OFFSET + 1
9009
- }, OUTLINE_STYLE));
9010
-
9011
- } else if (is$1(element, 'bpmn:Event')) {
9012
- outline = create$1('circle');
9013
-
9014
- attr$1(outline, assign$1({
9015
- cx: element.width / 2,
9016
- cy: element.height / 2,
9017
- r: element.width / 2 + DEFAULT_OFFSET
9018
- }, OUTLINE_STYLE));
9019
-
9020
- } else if (is$1(element, 'bpmn:DataObjectReference') && isStandardSize(element, 'bpmn:DataObjectReference')) {
9021
-
9022
- outline = createPath(
9023
- DATA_OBJECT_REFERENCE_OUTLINE_PATH,
9024
- { x: -6, y: -6 },
9025
- OUTLINE_STYLE
9026
- );
9027
-
9028
- } else if (is$1(element, 'bpmn:DataStoreReference') && isStandardSize(element, 'bpmn:DataStoreReference')) {
9029
-
9030
- outline = createPath(
9031
- DATA_STORE_REFERENCE_OUTLINE_PATH,
9032
- { x: -6, y: -6 },
9033
- OUTLINE_STYLE
9034
- );
9035
- }
9036
-
9037
- return outline;
9038
- };
9039
-
9040
- /**
9041
- * Updates the outline for a given element.
9042
- * Returns true if the update for the given element was handled by this provider.
9043
- *
9044
- * @param {Element} element
9045
- * @param {Outline} outline
9046
- * @returns {boolean}
9047
- */
9048
- OutlineProvider.prototype.updateOutline = function(element, outline) {
9049
-
9050
- if (isLabel(element)) {
9051
- return;
9052
- }
9053
-
9054
- if (isAny(element, [ 'bpmn:SubProcess', 'bpmn:Group' ])) {
9055
-
9056
- attr$1(outline, {
9057
- width: element.width + DEFAULT_OFFSET * 2,
9058
- height: element.height + DEFAULT_OFFSET * 2
9059
- });
9060
-
9061
- return true;
9062
-
9063
- } else if (isAny(element, [
9064
- 'bpmn:Event',
9065
- 'bpmn:Gateway',
9066
- 'bpmn:DataStoreReference',
9067
- 'bpmn:DataObjectReference'
9068
- ])) {
9069
- return true;
9070
- }
9071
-
9072
- return false;
9073
- };
9074
-
9075
-
9076
- // helpers //////////
9077
-
9078
- function isStandardSize(element, type) {
9079
- var standardSize;
9080
-
9081
- if (type === 'bpmn:DataObjectReference') {
9082
- standardSize = DATA_OBJECT_REFERENCE_STANDARD_SIZE;
9083
- } else if (type === 'bpmn:DataStoreReference') {
9084
- standardSize = DATA_STORE_REFERENCE_STANDARD_SIZE;
9085
- }
9086
-
9087
- return element.width === standardSize.width
9088
- && element.height === standardSize.height;
9089
- }
9090
-
9091
- var OutlineModule = {
9092
- __depends__: [
9093
- OutlineModule$1
9094
- ],
9095
- __init__: [ 'outlineProvider' ],
9096
- outlineProvider: [ 'type', OutlineProvider ]
9097
- };
9098
-
9099
8657
  /**
9100
8658
  * @typedef {import('../util/Types').Point} Point
9101
8659
  */
@@ -9141,7 +8699,7 @@
9141
8699
  *
9142
8700
  * @return {boolean}
9143
8701
  */
9144
- function isButton$1(event, button) {
8702
+ function isButton(event, button) {
9145
8703
  return (getOriginal(event) || event).button === button;
9146
8704
  }
9147
8705
 
@@ -9153,7 +8711,7 @@
9153
8711
  function isPrimaryButton(event) {
9154
8712
 
9155
8713
  // button === 0 -> left áka primary mouse button
9156
- return isButton$1(event, 0);
8714
+ return isButton(event, 0);
9157
8715
  }
9158
8716
 
9159
8717
  /**
@@ -9164,7 +8722,7 @@
9164
8722
  function isAuxiliaryButton(event) {
9165
8723
 
9166
8724
  // button === 1 -> auxiliary áka wheel button
9167
- return isButton$1(event, 1);
8725
+ return isButton(event, 1);
9168
8726
  }
9169
8727
 
9170
8728
  /**
@@ -9802,15 +9360,11 @@
9802
9360
  /**
9803
9361
  * @typedef {import('../../core/Canvas').default} Canvas
9804
9362
  * @typedef {import('../../core/EventBus').default} EventBus
9805
- * @typedef {import('./Selection').default} Selection
9806
9363
  */
9807
9364
 
9808
9365
  var MARKER_HOVER = 'hover',
9809
9366
  MARKER_SELECTED = 'selected';
9810
9367
 
9811
- var SELECTION_OUTLINE_PADDING = 6;
9812
-
9813
-
9814
9368
  /**
9815
9369
  * A plugin that adds a visible selection UI to shapes and connections
9816
9370
  * by appending the <code>hover</code> and <code>selected</code> classes to them.
@@ -9821,15 +9375,10 @@
9821
9375
  *
9822
9376
  * @param {Canvas} canvas
9823
9377
  * @param {EventBus} eventBus
9824
- * @param {Selection} selection
9825
9378
  */
9826
- function SelectionVisuals(canvas, eventBus, selection) {
9379
+ function SelectionVisuals(canvas, eventBus) {
9827
9380
  this._canvas = canvas;
9828
9381
 
9829
- var self = this;
9830
-
9831
- this._multiSelectionBox = null;
9832
-
9833
9382
  function addMarker(e, cls) {
9834
9383
  canvas.addMarker(e, cls);
9835
9384
  }
@@ -9870,63 +9419,14 @@
9870
9419
  select(e);
9871
9420
  }
9872
9421
  });
9873
-
9874
- self._updateSelectionOutline(newSelection);
9875
- });
9876
-
9877
-
9878
- eventBus.on('element.changed', function(event) {
9879
- if (selection.isSelected(event.element)) {
9880
- self._updateSelectionOutline(selection.get());
9881
- }
9882
9422
  });
9883
9423
  }
9884
9424
 
9885
9425
  SelectionVisuals.$inject = [
9886
9426
  'canvas',
9887
- 'eventBus',
9888
- 'selection'
9427
+ 'eventBus'
9889
9428
  ];
9890
9429
 
9891
- SelectionVisuals.prototype._updateSelectionOutline = function(selection) {
9892
- var layer = this._canvas.getLayer('selectionOutline');
9893
-
9894
- clear$1(layer);
9895
-
9896
- var enabled = selection.length > 1;
9897
-
9898
- var container = this._canvas.getContainer();
9899
-
9900
- classes$1(container)[enabled ? 'add' : 'remove']('djs-multi-select');
9901
-
9902
- if (!enabled) {
9903
- return;
9904
- }
9905
-
9906
- var bBox = addSelectionOutlinePadding(getBBox(selection));
9907
-
9908
- var rect = create$1('rect');
9909
-
9910
- attr$1(rect, assign$1({
9911
- rx: 3
9912
- }, bBox));
9913
-
9914
- classes$1(rect).add('djs-selection-outline');
9915
-
9916
- append(layer, rect);
9917
- };
9918
-
9919
- // helpers //////////
9920
-
9921
- function addSelectionOutlinePadding(bBox) {
9922
- return {
9923
- x: bBox.x - SELECTION_OUTLINE_PADDING,
9924
- y: bBox.y - SELECTION_OUTLINE_PADDING,
9925
- width: bBox.width + SELECTION_OUTLINE_PADDING * 2,
9926
- height: bBox.height + SELECTION_OUTLINE_PADDING * 2
9927
- };
9928
- }
9929
-
9930
9430
  /**
9931
9431
  * @typedef {import('../../core/Canvas').default} Canvas
9932
9432
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
@@ -10053,7 +9553,6 @@
10053
9553
  __init__: [ 'selectionVisuals', 'selectionBehavior' ],
10054
9554
  __depends__: [
10055
9555
  InteractionEventsModule,
10056
- OutlineModule$1
10057
9556
  ],
10058
9557
  selection: [ 'type', Selection ],
10059
9558
  selectionVisuals: [ 'type', SelectionVisuals ],
@@ -10982,6 +10481,11 @@
10982
10481
  */
10983
10482
  this._rootElement = null;
10984
10483
 
10484
+ /**
10485
+ * @type {boolean}
10486
+ */
10487
+ this._focused = false;
10488
+
10985
10489
  this._init(config || {});
10986
10490
  }
10987
10491
 
@@ -11008,14 +10512,33 @@
11008
10512
  * @param {CanvasConfig} config
11009
10513
  */
11010
10514
  Canvas.prototype._init = function(config) {
11011
-
11012
10515
  const eventBus = this._eventBus;
11013
10516
 
11014
10517
  // html container
11015
10518
  const container = this._container = createContainer(config);
11016
10519
 
11017
10520
  const svg = this._svg = create$1('svg');
11018
- attr$1(svg, { width: '100%', height: '100%' });
10521
+
10522
+ attr$1(svg, {
10523
+ width: '100%',
10524
+ height: '100%'
10525
+ });
10526
+
10527
+ attr(svg, 'tabindex', 0);
10528
+
10529
+ eventBus.on('element.hover', () => {
10530
+ this.restoreFocus();
10531
+ });
10532
+
10533
+ svg.addEventListener('focusin', () => {
10534
+ this._focused = true;
10535
+ eventBus.fire('canvas.focus.changed', { focused: true });
10536
+ });
10537
+
10538
+ svg.addEventListener('focusout', () => {
10539
+ this._focused = false;
10540
+ eventBus.fire('canvas.focus.changed', { focused: false });
10541
+ });
11019
10542
 
11020
10543
  append(container, svg);
11021
10544
 
@@ -11107,6 +10630,31 @@
11107
10630
  delete this._cachedViewbox;
11108
10631
  };
11109
10632
 
10633
+ /**
10634
+ * Sets focus on the canvas SVG element.
10635
+ */
10636
+ Canvas.prototype.focus = function() {
10637
+ this._svg.focus({ preventScroll: true });
10638
+ };
10639
+
10640
+ /**
10641
+ * Sets focus on the canvas SVG element if `document.body` is currently focused.
10642
+ */
10643
+ Canvas.prototype.restoreFocus = function() {
10644
+ if (document.activeElement === document.body) {
10645
+ this.focus();
10646
+ }
10647
+ };
10648
+
10649
+ /**
10650
+ * Returns true if the canvas is focused.
10651
+ *
10652
+ * @return {boolean}
10653
+ */
10654
+ Canvas.prototype.isFocused = function() {
10655
+ return this._focused;
10656
+ };
10657
+
11110
10658
  /**
11111
10659
  * Returns the default layer on which
11112
10660
  * all elements are drawn.
@@ -11946,7 +11494,7 @@
11946
11494
  Canvas.prototype.viewbox = function(box) {
11947
11495
 
11948
11496
  if (box === undefined && this._cachedViewbox) {
11949
- return this._cachedViewbox;
11497
+ return structuredClone(this._cachedViewbox);
11950
11498
  }
11951
11499
 
11952
11500
  const viewport = this._viewport,
@@ -14574,13 +14122,15 @@
14574
14122
  if (parts.length === 1) {
14575
14123
  localName = name;
14576
14124
  prefix = defaultPrefix;
14577
- } else
14125
+ }
14578
14126
 
14579
14127
  // prefix + local name
14580
- if (parts.length === 2) {
14128
+ else if (parts.length === 2) {
14581
14129
  localName = parts[1];
14582
14130
  prefix = parts[0];
14583
- } else {
14131
+ }
14132
+
14133
+ else {
14584
14134
  throw new Error('expected <prefix:localName> or <localName>, got ' + name);
14585
14135
  }
14586
14136
 
@@ -15482,7 +15032,7 @@
15482
15032
  * sub-set of reserved names (&amp;) as well as
15483
15033
  * hex (&#xaaf;) and decimal (&#1231;) encoded characters.
15484
15034
  *
15485
- * @param {string} str
15035
+ * @param {string} s
15486
15036
  *
15487
15037
  * @return {string} decoded string
15488
15038
  */
@@ -15494,10 +15044,6 @@
15494
15044
  return s;
15495
15045
  }
15496
15046
 
15497
- var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
15498
- var XSI_PREFIX = 'xsi';
15499
- var XSI_TYPE$1 = 'xsi:type';
15500
-
15501
15047
  var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
15502
15048
 
15503
15049
  function error$1(msg) {
@@ -15542,7 +15088,7 @@
15542
15088
  }
15543
15089
 
15544
15090
  function noopGetContext() {
15545
- return { 'line': 0, 'column': 0 };
15091
+ return { line: 0, column: 0 };
15546
15092
  }
15547
15093
 
15548
15094
  function throwFunc(err) {
@@ -15708,9 +15254,6 @@
15708
15254
  _nsUriToPrefix[k] = nsMap[k];
15709
15255
  }
15710
15256
 
15711
- // FORCE default mapping for schema instance
15712
- _nsUriToPrefix[XSI_URI] = XSI_PREFIX;
15713
-
15714
15257
  isNamespace = true;
15715
15258
  nsUriToPrefix = _nsUriToPrefix;
15716
15259
 
@@ -16034,23 +15577,6 @@
16034
15577
 
16035
15578
  // end: normalize ns attribute name
16036
15579
 
16037
- // normalize xsi:type ns attribute value
16038
- if (name === XSI_TYPE$1) {
16039
- w = value.indexOf(':');
16040
-
16041
- if (w !== -1) {
16042
- nsName = value.substring(0, w);
16043
-
16044
- // handle default prefixes, i.e. xs:String gracefully
16045
- nsName = nsMatrix[nsName] || nsName;
16046
- value = nsName + value.substring(w);
16047
- } else {
16048
- value = defaultAlias + ':' + value;
16049
- }
16050
- }
16051
-
16052
- // end: normalize xsi:type ns attribute value
16053
-
16054
15580
  attrs[name] = value;
16055
15581
  }
16056
15582
 
@@ -16079,23 +15605,6 @@
16079
15605
  : nsName + name.substr(w);
16080
15606
 
16081
15607
  // end: normalize ns attribute name
16082
-
16083
- // normalize xsi:type ns attribute value
16084
- if (name === XSI_TYPE$1) {
16085
- w = value.indexOf(':');
16086
-
16087
- if (w !== -1) {
16088
- nsName = value.substring(0, w);
16089
-
16090
- // handle default prefixes, i.e. xs:String gracefully
16091
- nsName = nsMatrix[nsName] || nsName;
16092
- value = nsName + value.substring(w);
16093
- } else {
16094
- value = defaultAlias + ':' + value;
16095
- }
16096
- }
16097
-
16098
- // end: normalize xsi:type ns attribute value
16099
15608
  }
16100
15609
 
16101
15610
  attrs[name] = value;
@@ -16236,11 +15745,11 @@
16236
15745
  }
16237
15746
  }
16238
15747
 
16239
- w = xml.charCodeAt(i+1);
15748
+ w = xml.charCodeAt(i + 1);
16240
15749
 
16241
15750
  // parse comments + CDATA
16242
15751
  if (w === 33) { // "!"
16243
- q = xml.charCodeAt(i+2);
15752
+ q = xml.charCodeAt(i + 2);
16244
15753
 
16245
15754
  // CDATA section
16246
15755
  if (q === 91 && xml.substr(i + 3, 6) === 'CDATA[') { // 91 == "["
@@ -16524,18 +16033,16 @@
16524
16033
  'xml': 'http://www.w3.org/XML/1998/namespace'
16525
16034
  };
16526
16035
 
16527
- var XSI_TYPE = 'xsi:type';
16036
+ var SERIALIZE_PROPERTY = 'property';
16528
16037
 
16529
- function serializeFormat(element) {
16038
+ function getSerialization(element) {
16530
16039
  return element.xml && element.xml.serialize;
16531
16040
  }
16532
16041
 
16533
- function serializeAsType(element) {
16534
- return serializeFormat(element) === XSI_TYPE;
16535
- }
16042
+ function getSerializationType(element) {
16043
+ const type = getSerialization(element);
16536
16044
 
16537
- function serializeAsProperty(element) {
16538
- return serializeFormat(element) === 'property';
16045
+ return type !== SERIALIZE_PROPERTY && (type || null);
16539
16046
  }
16540
16047
 
16541
16048
  function capitalize(str) {
@@ -16551,12 +16058,20 @@
16551
16058
  return aliasNs.prefix + ':' + capitalize(aliasNs.localName);
16552
16059
  }
16553
16060
 
16061
+ /**
16062
+ * Un-prefix a potentially prefixed type name.
16063
+ *
16064
+ * @param {NsName} nameNs
16065
+ * @param {Object} [pkg]
16066
+ *
16067
+ * @return {string}
16068
+ */
16554
16069
  function prefixedToName(nameNs, pkg) {
16555
16070
 
16556
16071
  var name = nameNs.name,
16557
16072
  localName = nameNs.localName;
16558
16073
 
16559
- var typePrefix = pkg.xml && pkg.xml.typePrefix;
16074
+ var typePrefix = pkg && pkg.xml && pkg.xml.typePrefix;
16560
16075
 
16561
16076
  if (typePrefix && localName.indexOf(typePrefix) === 0) {
16562
16077
  return nameNs.prefix + ':' + localName.slice(typePrefix.length);
@@ -16565,12 +16080,19 @@
16565
16080
  }
16566
16081
  }
16567
16082
 
16568
- function normalizeXsiTypeName(name, model) {
16083
+ function normalizeTypeName(name, nsMap, model) {
16569
16084
 
16570
- var nameNs = parseName(name);
16571
- var pkg = model.getPackage(nameNs.prefix);
16085
+ // normalize against actual NS
16086
+ const nameNs = parseName(name, nsMap.xmlns);
16087
+
16088
+ const normalizedName = `${ nsMap[nameNs.prefix] || nameNs.prefix }:${ nameNs.localName }`;
16572
16089
 
16573
- return prefixedToName(nameNs, pkg);
16090
+ const normalizedNameNs = parseName(normalizedName);
16091
+
16092
+ // determine actual type name, based on package-defined prefix
16093
+ var pkg = model.getPackage(normalizedNameNs.prefix);
16094
+
16095
+ return prefixedToName(normalizedNameNs, pkg);
16574
16096
  }
16575
16097
 
16576
16098
  function error(message) {
@@ -16859,8 +16381,9 @@
16859
16381
  } else {
16860
16382
  if (prop) {
16861
16383
  value = coerceType(prop.type, value);
16862
- } else
16863
- if (name !== 'xmlns') {
16384
+ } else if (name === 'xmlns') {
16385
+ name = ':' + name;
16386
+ } else {
16864
16387
  propNameNs = parseName(name, descriptor.ns.prefix);
16865
16388
 
16866
16389
  // check whether attribute is defined in a well-known namespace
@@ -16893,26 +16416,27 @@
16893
16416
  descriptor = getModdleDescriptor(type);
16894
16417
 
16895
16418
  var propertyName = nameNs.name,
16896
- property = descriptor.propertiesByName[propertyName],
16897
- elementTypeName,
16898
- elementType;
16419
+ property = descriptor.propertiesByName[propertyName];
16899
16420
 
16900
16421
  // search for properties by name first
16901
16422
 
16902
16423
  if (property && !property.isAttr) {
16903
16424
 
16904
- if (serializeAsType(property)) {
16905
- elementTypeName = node.attributes[XSI_TYPE];
16425
+ const serializationType = getSerializationType(property);
16906
16426
 
16907
- // xsi type is optional, if it does not exists the
16427
+ if (serializationType) {
16428
+ const elementTypeName = node.attributes[serializationType];
16429
+
16430
+ // type is optional, if it does not exists the
16908
16431
  // default type is assumed
16909
16432
  if (elementTypeName) {
16910
16433
 
16434
+ // convert the prefix used to the mapped form, but also
16911
16435
  // take possible type prefixes from XML
16912
- // into account, i.e.: xsi:type="t{ActualType}"
16913
- elementTypeName = normalizeXsiTypeName(elementTypeName, model);
16436
+ // into account, i.e.: xsi:type="t{ActualType}",
16437
+ const normalizedTypeName = normalizeTypeName(elementTypeName, node.ns, model);
16914
16438
 
16915
- elementType = model.getType(elementTypeName);
16439
+ const elementType = model.getType(normalizedTypeName);
16916
16440
 
16917
16441
  return assign$1({}, property, {
16918
16442
  effectiveType: getModdleDescriptor(elementType).name
@@ -16927,8 +16451,8 @@
16927
16451
  var pkg = model.getPackage(nameNs.prefix);
16928
16452
 
16929
16453
  if (pkg) {
16930
- elementTypeName = aliasToName(nameNs, pkg);
16931
- elementType = model.getType(elementTypeName);
16454
+ const elementTypeName = aliasToName(nameNs, pkg);
16455
+ const elementType = model.getType(elementTypeName);
16932
16456
 
16933
16457
  // search for collection members later
16934
16458
  property = find(descriptor.properties, function(p) {
@@ -17350,9 +16874,12 @@
17350
16874
  uriMap[p.uri] = p.prefix;
17351
16875
 
17352
16876
  return uriMap;
17353
- }, {
17354
- 'http://www.w3.org/XML/1998/namespace': 'xml' // add default xml ns
17355
- });
16877
+ }, Object.entries(DEFAULT_NS_MAP).reduce(function(map, [ prefix, url ]) {
16878
+ map[url] = prefix;
16879
+
16880
+ return map;
16881
+ }, model.config && model.config.nsMap || {}));
16882
+
17356
16883
  parser
17357
16884
  .ns(uriMap)
17358
16885
  .on('openTag', function(obj, decodeStr, selfClosing, getContext) {
@@ -17453,75 +16980,82 @@
17453
16980
 
17454
16981
  function Namespaces(parent) {
17455
16982
 
17456
- var prefixMap = {};
17457
- var uriMap = {};
17458
- var used = {};
16983
+ this.prefixMap = {};
16984
+ this.uriMap = {};
16985
+ this.used = {};
17459
16986
 
17460
- var wellknown = [];
17461
- var custom = [];
16987
+ this.wellknown = [];
16988
+ this.custom = [];
16989
+ this.parent = parent;
17462
16990
 
17463
- // API
16991
+ this.defaultPrefixMap = parent && parent.defaultPrefixMap || {};
16992
+ }
17464
16993
 
17465
- this.byUri = function(uri) {
17466
- return uriMap[uri] || (
17467
- parent && parent.byUri(uri)
17468
- );
17469
- };
16994
+ Namespaces.prototype.mapDefaultPrefixes = function(defaultPrefixMap) {
16995
+ this.defaultPrefixMap = defaultPrefixMap;
16996
+ };
17470
16997
 
17471
- this.add = function(ns, isWellknown) {
16998
+ Namespaces.prototype.defaultUriByPrefix = function(prefix) {
16999
+ return this.defaultPrefixMap[prefix];
17000
+ };
17472
17001
 
17473
- uriMap[ns.uri] = ns;
17002
+ Namespaces.prototype.byUri = function(uri) {
17003
+ return this.uriMap[uri] || (
17004
+ this.parent && this.parent.byUri(uri)
17005
+ );
17006
+ };
17474
17007
 
17475
- if (isWellknown) {
17476
- wellknown.push(ns);
17477
- } else {
17478
- custom.push(ns);
17479
- }
17008
+ Namespaces.prototype.add = function(ns, isWellknown) {
17480
17009
 
17481
- this.mapPrefix(ns.prefix, ns.uri);
17482
- };
17010
+ this.uriMap[ns.uri] = ns;
17483
17011
 
17484
- this.uriByPrefix = function(prefix) {
17485
- return prefixMap[prefix || 'xmlns'];
17486
- };
17012
+ if (isWellknown) {
17013
+ this.wellknown.push(ns);
17014
+ } else {
17015
+ this.custom.push(ns);
17016
+ }
17487
17017
 
17488
- this.mapPrefix = function(prefix, uri) {
17489
- prefixMap[prefix || 'xmlns'] = uri;
17490
- };
17018
+ this.mapPrefix(ns.prefix, ns.uri);
17019
+ };
17491
17020
 
17492
- this.getNSKey = function(ns) {
17493
- return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17494
- };
17021
+ Namespaces.prototype.uriByPrefix = function(prefix) {
17022
+ return this.prefixMap[prefix || 'xmlns'] || (
17023
+ this.parent && this.parent.uriByPrefix(prefix)
17024
+ );
17025
+ };
17495
17026
 
17496
- this.logUsed = function(ns) {
17027
+ Namespaces.prototype.mapPrefix = function(prefix, uri) {
17028
+ this.prefixMap[prefix || 'xmlns'] = uri;
17029
+ };
17497
17030
 
17498
- var uri = ns.uri;
17499
- var nsKey = this.getNSKey(ns);
17031
+ Namespaces.prototype.getNSKey = function(ns) {
17032
+ return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17033
+ };
17500
17034
 
17501
- used[nsKey] = this.byUri(uri);
17035
+ Namespaces.prototype.logUsed = function(ns) {
17502
17036
 
17503
- // Inform parent recursively about the usage of this NS
17504
- if (parent) {
17505
- parent.logUsed(ns);
17506
- }
17507
- };
17037
+ var uri = ns.uri;
17038
+ var nsKey = this.getNSKey(ns);
17508
17039
 
17509
- this.getUsed = function(ns) {
17040
+ this.used[nsKey] = this.byUri(uri);
17510
17041
 
17511
- function isUsed(ns) {
17512
- var nsKey = self.getNSKey(ns);
17042
+ // Inform parent recursively about the usage of this NS
17043
+ if (this.parent) {
17044
+ this.parent.logUsed(ns);
17045
+ }
17046
+ };
17513
17047
 
17514
- return used[nsKey];
17515
- }
17048
+ Namespaces.prototype.getUsed = function(ns) {
17516
17049
 
17517
- var self = this;
17050
+ var allNs = [].concat(this.wellknown, this.custom);
17518
17051
 
17519
- var allNs = [].concat(wellknown, custom);
17052
+ return allNs.filter(ns => {
17053
+ var nsKey = this.getNSKey(ns);
17520
17054
 
17521
- return allNs.filter(isUsed);
17522
- };
17055
+ return this.used[nsKey];
17056
+ });
17057
+ };
17523
17058
 
17524
- }
17525
17059
 
17526
17060
  function lower(string) {
17527
17061
  return string.charAt(0).toLowerCase() + string.slice(1);
@@ -17736,7 +17270,7 @@
17736
17270
  var isGeneric = elementDescriptor.isGeneric;
17737
17271
 
17738
17272
  if (isGeneric) {
17739
- otherAttrs = this.parseGeneric(element);
17273
+ otherAttrs = this.parseGenericNsAttributes(element);
17740
17274
  } else {
17741
17275
  otherAttrs = this.parseNsAttributes(element);
17742
17276
  }
@@ -17750,7 +17284,9 @@
17750
17284
  // compute tag name
17751
17285
  this.tagName = this.addTagName(this.ns);
17752
17286
 
17753
- if (!isGeneric) {
17287
+ if (isGeneric) {
17288
+ this.parseGenericContainments(element);
17289
+ } else {
17754
17290
  properties = getSerializableProperties(element);
17755
17291
 
17756
17292
  this.parseAttributes(filterAttributes(properties));
@@ -17813,35 +17349,29 @@
17813
17349
  }
17814
17350
  };
17815
17351
 
17816
- ElementSerializer.prototype.parseGeneric = function(element) {
17817
-
17818
- var self = this,
17819
- body = this.body;
17352
+ ElementSerializer.prototype.parseGenericNsAttributes = function(element) {
17820
17353
 
17821
- var attributes = [];
17822
-
17823
- forEach$1(element, function(val, key) {
17354
+ return Object.entries(element).filter(
17355
+ ([ key, value ]) => !key.startsWith('$') && this.parseNsAttribute(element, key, value)
17356
+ ).map(
17357
+ ([ key, value ]) => ({ name: key, value: value })
17358
+ );
17359
+ };
17824
17360
 
17825
- var nonNsAttr;
17361
+ ElementSerializer.prototype.parseGenericContainments = function(element) {
17362
+ var body = element.$body;
17826
17363
 
17827
- if (key === '$body') {
17828
- body.push(new BodySerializer().build({ type: 'String' }, val));
17829
- } else
17830
- if (key === '$children') {
17831
- forEach$1(val, function(child) {
17832
- body.push(new ElementSerializer(self).build(child));
17833
- });
17834
- } else
17835
- if (key.indexOf('$') !== 0) {
17836
- nonNsAttr = self.parseNsAttribute(element, key, val);
17364
+ if (body) {
17365
+ this.body.push(new BodySerializer().build({ type: 'String' }, body));
17366
+ }
17837
17367
 
17838
- if (nonNsAttr) {
17839
- attributes.push({ name: key, value: val });
17840
- }
17841
- }
17842
- });
17368
+ var children = element.$children;
17843
17369
 
17844
- return attributes;
17370
+ if (children) {
17371
+ forEach$1(children, child => {
17372
+ this.body.push(new ElementSerializer(this).build(child));
17373
+ });
17374
+ }
17845
17375
  };
17846
17376
 
17847
17377
  ElementSerializer.prototype.parseNsAttribute = function(element, name, value) {
@@ -17888,7 +17418,7 @@
17888
17418
  * @param {Object} element
17889
17419
  * @return {Array<Object>}
17890
17420
  */
17891
- ElementSerializer.prototype.parseNsAttributes = function(element, attrs) {
17421
+ ElementSerializer.prototype.parseNsAttributes = function(element) {
17892
17422
  var self = this;
17893
17423
 
17894
17424
  var genericAttrs = element.$attrs;
@@ -17916,21 +17446,16 @@
17916
17446
 
17917
17447
  forEach$1(attributes, function(attr) {
17918
17448
 
17919
- // do not serialize xsi:type attribute
17920
- // it is set manually based on the actual implementation type
17921
- if (attr.name === XSI_TYPE) {
17922
- return;
17923
- }
17924
-
17925
17449
  try {
17926
17450
  self.addAttribute(self.nsAttributeName(attr.name), attr.value);
17927
17451
  } catch (e) {
17928
- /* global console */
17929
17452
 
17930
- console.warn(
17931
- 'missing namespace information for ',
17932
- attr.name, '=', attr.value, 'on', element,
17933
- e);
17453
+ // eslint-disable-next-line no-undef
17454
+ typeof console !== 'undefined' && console.warn(
17455
+ `missing namespace information for <${
17456
+ attr.name
17457
+ }=${ attr.value }> on`, element, e
17458
+ );
17934
17459
  }
17935
17460
  });
17936
17461
  };
@@ -17952,13 +17477,11 @@
17952
17477
 
17953
17478
  if (p.isBody) {
17954
17479
  body.push(new BodySerializer().build(p, value[0]));
17955
- } else
17956
- if (isSimple(p.type)) {
17480
+ } else if (isSimple(p.type)) {
17957
17481
  forEach$1(value, function(v) {
17958
17482
  body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
17959
17483
  });
17960
- } else
17961
- if (isReference) {
17484
+ } else if (isReference) {
17962
17485
  forEach$1(value, function(v) {
17963
17486
  body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
17964
17487
  });
@@ -17966,17 +17489,17 @@
17966
17489
 
17967
17490
  // allow serialization via type
17968
17491
  // rather than element name
17969
- var asType = serializeAsType(p),
17970
- asProperty = serializeAsProperty(p);
17492
+ var serialization = getSerialization(p);
17971
17493
 
17972
17494
  forEach$1(value, function(v) {
17973
17495
  var serializer;
17974
17496
 
17975
- if (asType) {
17976
- serializer = new TypeSerializer(self, p);
17977
- } else
17978
- if (asProperty) {
17979
- serializer = new ElementSerializer(self, p);
17497
+ if (serialization) {
17498
+ if (serialization === SERIALIZE_PROPERTY) {
17499
+ serializer = new ElementSerializer(self, p);
17500
+ } else {
17501
+ serializer = new TypeSerializer(self, p, serialization);
17502
+ }
17980
17503
  } else {
17981
17504
  serializer = new ElementSerializer(self);
17982
17505
  }
@@ -18024,9 +17547,7 @@
18024
17547
  };
18025
17548
 
18026
17549
  ElementSerializer.prototype.logNamespaceUsed = function(ns, local) {
18027
- var element = this.element,
18028
- model = element.$model,
18029
- namespaces = this.getNamespaces(local);
17550
+ var namespaces = this.getNamespaces(local);
18030
17551
 
18031
17552
  // ns may be
18032
17553
  //
@@ -18044,7 +17565,7 @@
18044
17565
  return { localName: ns.localName };
18045
17566
  }
18046
17567
 
18047
- wellknownUri = DEFAULT_NS_MAP[prefix] || model && (model.getPackage(prefix) || {}).uri;
17568
+ wellknownUri = namespaces.defaultUriByPrefix(prefix);
18048
17569
 
18049
17570
  uri = uri || wellknownUri || namespaces.uriByPrefix(prefix);
18050
17571
 
@@ -18054,6 +17575,11 @@
18054
17575
 
18055
17576
  ns = namespaces.byUri(uri);
18056
17577
 
17578
+ // register new default prefix <xmlns> in local scope
17579
+ if (!ns && !prefix) {
17580
+ ns = this.logNamespace({ uri }, wellknownUri === uri, true);
17581
+ }
17582
+
18057
17583
  if (!ns) {
18058
17584
  newPrefix = prefix;
18059
17585
  idx = 1;
@@ -18085,8 +17611,7 @@
18085
17611
 
18086
17612
  if (!p.isMany) {
18087
17613
  value = value.id;
18088
- }
18089
- else {
17614
+ } else {
18090
17615
  var values = [];
18091
17616
  forEach$1(value, function(v) {
18092
17617
  values.push(v.id);
@@ -18190,20 +17715,25 @@
18190
17715
  /**
18191
17716
  * A serializer for types that handles serialization of data types
18192
17717
  */
18193
- function TypeSerializer(parent, propertyDescriptor) {
17718
+ function TypeSerializer(parent, propertyDescriptor, serialization) {
18194
17719
  ElementSerializer.call(this, parent, propertyDescriptor);
17720
+
17721
+ this.serialization = serialization;
18195
17722
  }
18196
17723
 
18197
17724
  inherits(TypeSerializer, ElementSerializer);
18198
17725
 
18199
17726
  TypeSerializer.prototype.parseNsAttributes = function(element) {
18200
17727
 
18201
- // extracted attributes
18202
- var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element);
17728
+ // extracted attributes with serialization attribute
17729
+ // <type=typeName> stripped; it may be later
17730
+ var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element).filter(
17731
+ attr => attr.name !== this.serialization
17732
+ );
18203
17733
 
18204
17734
  var descriptor = element.$descriptor;
18205
17735
 
18206
- // only serialize xsi:type if necessary
17736
+ // only serialize <type=typeName> if necessary
18207
17737
  if (descriptor.name === this.propertyDescriptor.type) {
18208
17738
  return attributes;
18209
17739
  }
@@ -18218,7 +17748,7 @@
18218
17748
  typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
18219
17749
 
18220
17750
  this.addAttribute(
18221
- this.nsAttributeName(XSI_TYPE),
17751
+ this.nsAttributeName(this.serialization),
18222
17752
  (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName
18223
17753
  );
18224
17754
 
@@ -18291,7 +17821,13 @@
18291
17821
  formatingWriter.append(XML_PREAMBLE);
18292
17822
  }
18293
17823
 
18294
- new ElementSerializer().build(tree).serializeTo(formatingWriter);
17824
+ var serializer = new ElementSerializer();
17825
+
17826
+ var model = tree.$model;
17827
+
17828
+ serializer.getNamespaces().mapDefaultPrefixes(getDefaultPrefixMappings(model));
17829
+
17830
+ serializer.build(tree).serializeTo(formatingWriter);
18295
17831
 
18296
17832
  if (!writer) {
18297
17833
  return internalWriter.value;
@@ -18303,6 +17839,39 @@
18303
17839
  };
18304
17840
  }
18305
17841
 
17842
+
17843
+ // helpers ///////////
17844
+
17845
+ /**
17846
+ * @param {Moddle} model
17847
+ *
17848
+ * @return { Record<string, string> } map from prefix to URI
17849
+ */
17850
+ function getDefaultPrefixMappings(model) {
17851
+
17852
+ const nsMap = model.config && model.config.nsMap || {};
17853
+
17854
+ const prefixMap = {};
17855
+
17856
+ // { prefix -> uri }
17857
+ for (const prefix in DEFAULT_NS_MAP) {
17858
+ prefixMap[prefix] = DEFAULT_NS_MAP[prefix];
17859
+ }
17860
+
17861
+ // { uri -> prefix }
17862
+ for (const uri in nsMap) {
17863
+ const prefix = nsMap[uri];
17864
+
17865
+ prefixMap[prefix] = uri;
17866
+ }
17867
+
17868
+ for (const pkg of model.getPackages()) {
17869
+ prefixMap[pkg.prefix] = pkg.uri;
17870
+ }
17871
+
17872
+ return prefixMap;
17873
+ }
17874
+
18306
17875
  /**
18307
17876
  * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
18308
17877
  *
@@ -22029,7 +21598,7 @@
22029
21598
  associations: associations
22030
21599
  };
22031
21600
 
22032
- var packages = {
21601
+ const packages = {
22033
21602
  bpmn: BpmnPackage,
22034
21603
  bpmndi: BpmnDiPackage,
22035
21604
  dc: DcPackage,
@@ -22038,8 +21607,8 @@
22038
21607
  color: BpmnInColorPackage
22039
21608
  };
22040
21609
 
22041
- function simple(additionalPackages, options) {
22042
- var pks = assign$1({}, packages, additionalPackages);
21610
+ function SimpleBpmnModdle(additionalPackages, options) {
21611
+ const pks = assign$1({}, packages, additionalPackages);
22043
21612
 
22044
21613
  return new BpmnModdle(pks, options);
22045
21614
  }
@@ -23530,7 +23099,7 @@
23530
23099
  BaseViewer.prototype._createModdle = function(options) {
23531
23100
  const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
23532
23101
 
23533
- return new simple(moddleOptions);
23102
+ return new SimpleBpmnModdle(moddleOptions);
23534
23103
  };
23535
23104
 
23536
23105
  BaseViewer.prototype._modules = [];
@@ -23692,7 +23261,6 @@
23692
23261
  Viewer.prototype._modules = [
23693
23262
  CoreModule$1,
23694
23263
  DrilldownModdule,
23695
- OutlineModule,
23696
23264
  OverlaysModule,
23697
23265
  SelectionModule,
23698
23266
  TranslateModule
@@ -23790,10 +23358,11 @@
23790
23358
  var KEYDOWN_EVENT = 'keyboard.keydown',
23791
23359
  KEYUP_EVENT = 'keyboard.keyup';
23792
23360
 
23793
- var HANDLE_MODIFIER_ATTRIBUTE = 'input-handle-modified-keys';
23794
-
23795
23361
  var DEFAULT_PRIORITY = 1000;
23796
23362
 
23363
+ var compatMessage = 'Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661';
23364
+
23365
+
23797
23366
  /**
23798
23367
  * A keyboard abstraction that may be activated and
23799
23368
  * deactivated by users at will, consuming global key events
@@ -23812,8 +23381,8 @@
23812
23381
  *
23813
23382
  * All events contain one field which is node.
23814
23383
  *
23815
- * A default binding for the keyboard may be specified via the
23816
- * `keyboard.bindTo` configuration option.
23384
+ * Specify the initial keyboard binding state via the
23385
+ * `keyboard.bind=true|false` configuration option.
23817
23386
  *
23818
23387
  * @param {Object} config
23819
23388
  * @param {EventTarget} [config.bindTo]
@@ -23822,7 +23391,8 @@
23822
23391
  function Keyboard(config, eventBus) {
23823
23392
  var self = this;
23824
23393
 
23825
- this._config = config || {};
23394
+ this._config = config = config || {};
23395
+
23826
23396
  this._eventBus = eventBus;
23827
23397
 
23828
23398
  this._keydownHandler = this._keydownHandler.bind(this);
@@ -23835,19 +23405,22 @@
23835
23405
  self.unbind();
23836
23406
  });
23837
23407
 
23838
- eventBus.on('diagram.init', function() {
23839
- self._fire('init');
23840
- });
23408
+ if (config.bindTo) {
23409
+ console.error('unsupported configuration <keyboard.bindTo>', new Error(compatMessage));
23410
+ }
23411
+
23412
+ var bind = config && config.bind !== false;
23413
+
23414
+ eventBus.on('canvas.init', function(event) {
23415
+ self._target = event.svg;
23841
23416
 
23842
- eventBus.on('attach', function() {
23843
- if (config && config.bindTo) {
23844
- self.bind(config.bindTo);
23417
+ if (bind) {
23418
+ self.bind();
23845
23419
  }
23846
- });
23847
23420
 
23848
- eventBus.on('detach', function() {
23849
- self.unbind();
23421
+ self._fire('init');
23850
23422
  });
23423
+
23851
23424
  }
23852
23425
 
23853
23426
  Keyboard.$inject = [
@@ -23882,34 +23455,7 @@
23882
23455
  };
23883
23456
 
23884
23457
  Keyboard.prototype._isEventIgnored = function(event) {
23885
- if (event.defaultPrevented) {
23886
- return true;
23887
- }
23888
-
23889
- return (
23890
- isInput(event.target) || (
23891
- isButton(event.target) && isKey([ ' ', 'Enter' ], event)
23892
- )
23893
- ) && this._isModifiedKeyIgnored(event);
23894
- };
23895
-
23896
- Keyboard.prototype._isModifiedKeyIgnored = function(event) {
23897
- if (!isCmd(event)) {
23898
- return true;
23899
- }
23900
-
23901
- var allowedModifiers = this._getAllowedModifiers(event.target);
23902
- return allowedModifiers.indexOf(event.key) === -1;
23903
- };
23904
-
23905
- Keyboard.prototype._getAllowedModifiers = function(element) {
23906
- var modifierContainer = closest(element, '[' + HANDLE_MODIFIER_ATTRIBUTE + ']', true);
23907
-
23908
- if (!modifierContainer || (this._node && !this._node.contains(modifierContainer))) {
23909
- return [];
23910
- }
23911
-
23912
- return modifierContainer.getAttribute(HANDLE_MODIFIER_ATTRIBUTE).split(',');
23458
+ return false;
23913
23459
  };
23914
23460
 
23915
23461
  /**
@@ -23919,10 +23465,14 @@
23919
23465
  */
23920
23466
  Keyboard.prototype.bind = function(node) {
23921
23467
 
23468
+ if (node) {
23469
+ console.error('unsupported argument <node>', new Error(compatMessage));
23470
+ }
23471
+
23922
23472
  // make sure that the keyboard is only bound once to the DOM
23923
23473
  this.unbind();
23924
23474
 
23925
- this._node = node;
23475
+ node = this._node = this._target;
23926
23476
 
23927
23477
  // bind key events
23928
23478
  event.bind(node, 'keydown', this._keydownHandler);
@@ -23993,18 +23543,6 @@
23993
23543
  Keyboard.prototype.isShift = isShift;
23994
23544
  Keyboard.prototype.isKey = isKey;
23995
23545
 
23996
-
23997
-
23998
- // helpers ///////
23999
-
24000
- function isInput(target) {
24001
- return target && (matches(target, 'input, textarea') || target.contentEditable === 'true');
24002
- }
24003
-
24004
- function isButton(target) {
24005
- return target && matches(target, 'button, input[type=submit], input[type=button], a[href], [aria-role=button]');
24006
- }
24007
-
24008
23546
  var LOW_PRIORITY = 500;
24009
23547
 
24010
23548