camunda-bpmn-js 4.20.2 → 5.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.
@@ -73,7 +73,7 @@
73
73
  * @return {Boolean}
74
74
  */
75
75
  function has$1(target, key) {
76
- return nativeHasOwnProperty$1.call(target, key);
76
+ return !isNil(target) && nativeHasOwnProperty$1.call(target, key);
77
77
  }
78
78
 
79
79
  /**
@@ -162,7 +162,7 @@
162
162
  * @param {Collection<T>} collection
163
163
  * @param {Matcher<T>} matcher
164
164
  *
165
- * @return {number}
165
+ * @return {number | string | undefined}
166
166
  */
167
167
  function findIndex(collection, matcher) {
168
168
 
@@ -809,17 +809,6 @@
809
809
  return isObject(value) && has$1(value, 'waypoints');
810
810
  }
811
811
 
812
- /**
813
- * Checks whether a value is an instance of Label.
814
- *
815
- * @param {any} value
816
- *
817
- * @return {boolean}
818
- */
819
- function isLabel(value) {
820
- return isObject(value) && has$1(value, 'labelTarget');
821
- }
822
-
823
812
  /**
824
813
  * @typedef {import('diagram-js/lib/util/Types').Point} Point
825
814
  * @typedef {import('diagram-js/lib/util/Types').Rect} Rect
@@ -1348,26 +1337,6 @@
1348
1337
  return this.list.contains(name);
1349
1338
  };
1350
1339
 
1351
- /**
1352
- * Clear utility
1353
- */
1354
-
1355
- /**
1356
- * Removes all children from the given element
1357
- *
1358
- * @param {SVGElement} element
1359
- * @return {Element} the element (for chaining)
1360
- */
1361
- function clear$1(element) {
1362
- var child;
1363
-
1364
- while ((child = element.firstChild)) {
1365
- element.removeChild(child);
1366
- }
1367
-
1368
- return element;
1369
- }
1370
-
1371
1340
  var ns = {
1372
1341
  svg: 'http://www.w3.org/2000/svg'
1373
1342
  };
@@ -2588,16 +2557,6 @@
2588
2557
 
2589
2558
  var domify$1 = domify;
2590
2559
 
2591
- /**
2592
- * @param { HTMLElement } element
2593
- * @param { String } selector
2594
- *
2595
- * @return { boolean }
2596
- */
2597
- function matches(element, selector) {
2598
- return element && typeof element.matches === 'function' && element.matches(selector) || false;
2599
- }
2600
-
2601
2560
  function query(selector, el) {
2602
2561
  el = el || document;
2603
2562
 
@@ -5205,6 +5164,8 @@
5205
5164
 
5206
5165
  return bbox;
5207
5166
  } catch (e) {
5167
+ console.log(e);
5168
+
5208
5169
  return { width: 0, height: 0 };
5209
5170
  }
5210
5171
  }
@@ -6803,7 +6764,7 @@
6803
6764
  // document wide unique overlay ids
6804
6765
  var ids = new IdGenerator('ov');
6805
6766
 
6806
- var LOW_PRIORITY$4 = 500;
6767
+ var LOW_PRIORITY$3 = 500;
6807
6768
 
6808
6769
  /**
6809
6770
  * @typedef {import('../../core/Canvas').default} Canvas
@@ -7433,7 +7394,7 @@
7433
7394
 
7434
7395
  // move integration
7435
7396
 
7436
- eventBus.on('element.changed', LOW_PRIORITY$4, function(e) {
7397
+ eventBus.on('element.changed', LOW_PRIORITY$3, function(e) {
7437
7398
  var element = e.element;
7438
7399
 
7439
7400
  var container = self._getOverlayContainer(element, true);
@@ -7607,7 +7568,7 @@
7607
7568
  * @typedef { (context: CommandContext) => void } ComposeHandlerFunction
7608
7569
  */
7609
7570
 
7610
- var DEFAULT_PRIORITY$3 = 1000;
7571
+ var DEFAULT_PRIORITY$2 = 1000;
7611
7572
 
7612
7573
  /**
7613
7574
  * A utility that can be used to plug into the command execution for
@@ -7674,7 +7635,7 @@
7674
7635
  that = unwrap;
7675
7636
  unwrap = handlerFn;
7676
7637
  handlerFn = priority;
7677
- priority = DEFAULT_PRIORITY$3;
7638
+ priority = DEFAULT_PRIORITY$2;
7678
7639
  }
7679
7640
 
7680
7641
  if (isObject(unwrap)) {
@@ -8471,7 +8432,7 @@
8471
8432
  * @typedef {import('../../model/Types').Shape} Shape
8472
8433
  */
8473
8434
 
8474
- var LOW_PRIORITY$3 = 250;
8435
+ var LOW_PRIORITY$2 = 250;
8475
8436
  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>';
8476
8437
 
8477
8438
  var EMPTY_MARKER = 'bjs-drilldown-empty';
@@ -8496,7 +8457,7 @@
8496
8457
 
8497
8458
  var self = this;
8498
8459
 
8499
- this.executed('shape.toggleCollapse', LOW_PRIORITY$3, function(context) {
8460
+ this.executed('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8500
8461
  var shape = context.shape;
8501
8462
 
8502
8463
  // Add overlay to the collapsed shape
@@ -8508,7 +8469,7 @@
8508
8469
  }, true);
8509
8470
 
8510
8471
 
8511
- this.reverted('shape.toggleCollapse', LOW_PRIORITY$3, function(context) {
8472
+ this.reverted('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.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$3,
8484
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8524
8485
  function(context) {
8525
8486
  var oldParent = context.oldParent,
8526
8487
  newParent = context.newParent || context.parent,
@@ -8537,7 +8498,7 @@
8537
8498
  }, true);
8538
8499
 
8539
8500
 
8540
- this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$3,
8501
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8541
8502
  function(context) {
8542
8503
  var oldParent = context.oldParent,
8543
8504
  newParent = context.newParent || context.parent,
@@ -8681,409 +8642,6 @@
8681
8642
  subprocessCompatibility: [ 'type', SubprocessCompatibility ]
8682
8643
  };
8683
8644
 
8684
- var LOW_PRIORITY$2 = 500;
8685
-
8686
- var DEFAULT_PRIORITY$2 = 1000;
8687
-
8688
- /**
8689
- * @typedef {import('../../model/Types').Element} Element
8690
- *
8691
- * @typedef {import('./OutlineProvider').default} OutlineProvider
8692
- * @typedef {import('../../core/EventBus').default} EventBus
8693
- * @typedef {import('../../draw/Styles').default} Styles
8694
- */
8695
-
8696
- /**
8697
- * @class
8698
- *
8699
- * A plugin that adds an outline to shapes and connections that may be activated and styled
8700
- * via CSS classes.
8701
- *
8702
- * @param {EventBus} eventBus
8703
- * @param {Styles} styles
8704
- */
8705
- function Outline(eventBus, styles) {
8706
-
8707
- this._eventBus = eventBus;
8708
-
8709
- this.offset = 5;
8710
-
8711
- var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
8712
-
8713
- var self = this;
8714
-
8715
- /**
8716
- * @param {SVGElement} gfx
8717
- *
8718
- * @return {SVGElement} outline
8719
- */
8720
- function createOutline(gfx) {
8721
- var outline = create$1('rect');
8722
-
8723
- attr$1(outline, assign$1({
8724
- x: 0,
8725
- y: 0,
8726
- rx: 4,
8727
- width: 100,
8728
- height: 100
8729
- }, OUTLINE_STYLE));
8730
-
8731
- return outline;
8732
- }
8733
-
8734
- // A low priortity is necessary, because outlines of labels have to be updated
8735
- // after the label bounds have been updated in the renderer.
8736
- eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$2, function(event) {
8737
- var element = event.element,
8738
- gfx = event.gfx;
8739
-
8740
- var outline = query('.djs-outline', gfx);
8741
-
8742
- if (!outline) {
8743
- outline = self.getOutline(element) || createOutline();
8744
- append(gfx, outline);
8745
- }
8746
-
8747
- self.updateShapeOutline(outline, element);
8748
- });
8749
-
8750
- eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
8751
- var element = event.element,
8752
- gfx = event.gfx;
8753
-
8754
- var outline = query('.djs-outline', gfx);
8755
-
8756
- if (!outline) {
8757
- outline = createOutline();
8758
- append(gfx, outline);
8759
- }
8760
-
8761
- self.updateConnectionOutline(outline, element);
8762
- });
8763
- }
8764
-
8765
-
8766
- /**
8767
- * Updates the outline of a shape respecting the dimension of the
8768
- * element and an outline offset.
8769
- *
8770
- * @param {SVGElement} outline
8771
- * @param {Element} element
8772
- */
8773
- Outline.prototype.updateShapeOutline = function(outline, element) {
8774
-
8775
- var updated = false;
8776
- var providers = this._getProviders();
8777
-
8778
- if (providers.length) {
8779
- forEach$1(providers, function(provider) {
8780
- updated = updated || provider.updateOutline(element, outline);
8781
- });
8782
- }
8783
-
8784
- if (!updated) {
8785
- attr$1(outline, {
8786
- x: -this.offset,
8787
- y: -this.offset,
8788
- width: element.width + this.offset * 2,
8789
- height: element.height + this.offset * 2
8790
- });
8791
- }
8792
- };
8793
-
8794
- /**
8795
- * Updates the outline of a connection respecting the bounding box of
8796
- * the connection and an outline offset.
8797
- * Register an outline provider with the given priority.
8798
- *
8799
- * @param {SVGElement} outline
8800
- * @param {Element} connection
8801
- */
8802
- Outline.prototype.updateConnectionOutline = function(outline, connection) {
8803
- var bbox = getBBox(connection);
8804
-
8805
- attr$1(outline, {
8806
- x: bbox.x - this.offset,
8807
- y: bbox.y - this.offset,
8808
- width: bbox.width + this.offset * 2,
8809
- height: bbox.height + this.offset * 2
8810
- });
8811
- };
8812
-
8813
- /**
8814
- * Register an outline provider with the given priority.
8815
- *
8816
- * @param {number} priority
8817
- * @param {OutlineProvider} provider
8818
- */
8819
- Outline.prototype.registerProvider = function(priority, provider) {
8820
- if (!provider) {
8821
- provider = priority;
8822
- priority = DEFAULT_PRIORITY$2;
8823
- }
8824
-
8825
- this._eventBus.on('outline.getProviders', priority, function(event) {
8826
- event.providers.push(provider);
8827
- });
8828
- };
8829
-
8830
- /**
8831
- * Returns the registered outline providers.
8832
- *
8833
- * @returns {OutlineProvider[]}
8834
- */
8835
- Outline.prototype._getProviders = function() {
8836
- var event = this._eventBus.createEvent({
8837
- type: 'outline.getProviders',
8838
- providers: []
8839
- });
8840
-
8841
- this._eventBus.fire(event);
8842
-
8843
- return event.providers;
8844
- };
8845
-
8846
- /**
8847
- * Returns the outline for an element.
8848
- *
8849
- * @param {Element} element
8850
- */
8851
- Outline.prototype.getOutline = function(element) {
8852
- var outline;
8853
- var providers = this._getProviders();
8854
-
8855
- forEach$1(providers, function(provider) {
8856
-
8857
- if (!isFunction(provider.getOutline)) {
8858
- return;
8859
- }
8860
-
8861
- outline = outline || provider.getOutline(element);
8862
- });
8863
-
8864
- return outline;
8865
- };
8866
-
8867
- Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
8868
-
8869
- /**
8870
- * @type { import('didi').ModuleDeclaration }
8871
- */
8872
- var OutlineModule$1 = {
8873
- __init__: [ 'outline' ],
8874
- outline: [ 'type', Outline ]
8875
- };
8876
-
8877
- 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';
8878
- 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';
8879
-
8880
- /**
8881
- * @typedef { import('diagram-js/lib/util/Types').Dimensions} Dimensions
8882
- */
8883
-
8884
- /**
8885
- * @type {Dimensions}
8886
- */
8887
- const DATA_OBJECT_REFERENCE_STANDARD_SIZE = { width: 36, height: 50 };
8888
-
8889
- /**
8890
- * @type {Dimensions}
8891
- */
8892
- const DATA_STORE_REFERENCE_STANDARD_SIZE = { width: 50, height: 50 };
8893
-
8894
- /**
8895
- * Create a path element with given attributes.
8896
- * @param {string} path
8897
- * @param {Object} attrs
8898
- * @param {Object} OUTLINE_STYLE
8899
- * @return {SVGElement}
8900
- */
8901
- function createPath(path, attrs, OUTLINE_STYLE) {
8902
- return create$1('path', {
8903
- d: path,
8904
- strokeWidth: 2,
8905
- transform: `translate(${attrs.x}, ${attrs.y})`,
8906
- ...OUTLINE_STYLE
8907
- });
8908
- }
8909
-
8910
- /**
8911
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').default } BaseOutlineProvider
8912
- *
8913
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').Outline } Outline
8914
- *
8915
- * @typedef { import('diagram-js/lib/draw/Styles').default } Styles
8916
- *
8917
- * @typedef { import('diagram-js/lib/model/Types').Element } Element
8918
- */
8919
-
8920
- const DEFAULT_OFFSET = 5;
8921
-
8922
- /**
8923
- * BPMN-specific outline provider.
8924
- *
8925
- * @implements {BaseOutlineProvider}
8926
- *
8927
- * @param {Outline} outline
8928
- * @param {Styles} styles
8929
- */
8930
- function OutlineProvider(outline, styles) {
8931
-
8932
- this._styles = styles;
8933
- outline.registerProvider(this);
8934
- }
8935
-
8936
- OutlineProvider.$inject = [
8937
- 'outline',
8938
- 'styles'
8939
- ];
8940
-
8941
- /**
8942
- * Returns outline for a given element.
8943
- *
8944
- * @param {Element} element
8945
- *
8946
- * @return {Outline}
8947
- */
8948
- OutlineProvider.prototype.getOutline = function(element) {
8949
-
8950
- const OUTLINE_STYLE = this._styles.cls('djs-outline', [ 'no-fill' ]);
8951
-
8952
- var outline;
8953
-
8954
- if (isLabel(element)) {
8955
- return;
8956
- }
8957
-
8958
- if (is$1(element, 'bpmn:Gateway')) {
8959
- outline = create$1('rect');
8960
-
8961
- assign$1(outline.style, {
8962
- 'transform-box': 'fill-box',
8963
- 'transform': 'rotate(45deg)',
8964
- 'transform-origin': 'center'
8965
- });
8966
-
8967
- attr$1(outline, assign$1({
8968
- x: 2,
8969
- y: 2,
8970
- rx: 4,
8971
- width: element.width - 4,
8972
- height: element.height - 4,
8973
- }, OUTLINE_STYLE));
8974
-
8975
- } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Group', 'bpmn:CallActivity' ])) {
8976
- outline = create$1('rect');
8977
-
8978
- attr$1(outline, assign$1({
8979
- x: -DEFAULT_OFFSET,
8980
- y: -DEFAULT_OFFSET,
8981
- rx: 14,
8982
- width: element.width + DEFAULT_OFFSET * 2,
8983
- height: element.height + DEFAULT_OFFSET * 2
8984
- }, OUTLINE_STYLE));
8985
-
8986
- } else if (is$1(element, 'bpmn:EndEvent')) {
8987
-
8988
- outline = create$1('circle');
8989
-
8990
- // Extra 1px offset needed due to increased stroke-width of end event
8991
- // which makes it bigger than other events.
8992
-
8993
- attr$1(outline, assign$1({
8994
- cx: element.width / 2,
8995
- cy: element.height / 2,
8996
- r: element.width / 2 + DEFAULT_OFFSET + 1
8997
- }, OUTLINE_STYLE));
8998
-
8999
- } else if (is$1(element, 'bpmn:Event')) {
9000
- outline = create$1('circle');
9001
-
9002
- attr$1(outline, assign$1({
9003
- cx: element.width / 2,
9004
- cy: element.height / 2,
9005
- r: element.width / 2 + DEFAULT_OFFSET
9006
- }, OUTLINE_STYLE));
9007
-
9008
- } else if (is$1(element, 'bpmn:DataObjectReference') && isStandardSize(element, 'bpmn:DataObjectReference')) {
9009
-
9010
- outline = createPath(
9011
- DATA_OBJECT_REFERENCE_OUTLINE_PATH,
9012
- { x: -6, y: -6 },
9013
- OUTLINE_STYLE
9014
- );
9015
-
9016
- } else if (is$1(element, 'bpmn:DataStoreReference') && isStandardSize(element, 'bpmn:DataStoreReference')) {
9017
-
9018
- outline = createPath(
9019
- DATA_STORE_REFERENCE_OUTLINE_PATH,
9020
- { x: -6, y: -6 },
9021
- OUTLINE_STYLE
9022
- );
9023
- }
9024
-
9025
- return outline;
9026
- };
9027
-
9028
- /**
9029
- * Updates the outline for a given element.
9030
- * Returns true if the update for the given element was handled by this provider.
9031
- *
9032
- * @param {Element} element
9033
- * @param {Outline} outline
9034
- * @returns {boolean}
9035
- */
9036
- OutlineProvider.prototype.updateOutline = function(element, outline) {
9037
-
9038
- if (isLabel(element)) {
9039
- return;
9040
- }
9041
-
9042
- if (isAny(element, [ 'bpmn:SubProcess', 'bpmn:Group' ])) {
9043
-
9044
- attr$1(outline, {
9045
- width: element.width + DEFAULT_OFFSET * 2,
9046
- height: element.height + DEFAULT_OFFSET * 2
9047
- });
9048
-
9049
- return true;
9050
-
9051
- } else if (isAny(element, [
9052
- 'bpmn:Event',
9053
- 'bpmn:Gateway',
9054
- 'bpmn:DataStoreReference',
9055
- 'bpmn:DataObjectReference'
9056
- ])) {
9057
- return true;
9058
- }
9059
-
9060
- return false;
9061
- };
9062
-
9063
-
9064
- // helpers //////////
9065
-
9066
- function isStandardSize(element, type) {
9067
- var standardSize;
9068
-
9069
- if (type === 'bpmn:DataObjectReference') {
9070
- standardSize = DATA_OBJECT_REFERENCE_STANDARD_SIZE;
9071
- } else if (type === 'bpmn:DataStoreReference') {
9072
- standardSize = DATA_STORE_REFERENCE_STANDARD_SIZE;
9073
- }
9074
-
9075
- return element.width === standardSize.width
9076
- && element.height === standardSize.height;
9077
- }
9078
-
9079
- var OutlineModule = {
9080
- __depends__: [
9081
- OutlineModule$1
9082
- ],
9083
- __init__: [ 'outlineProvider' ],
9084
- outlineProvider: [ 'type', OutlineProvider ]
9085
- };
9086
-
9087
8645
  /**
9088
8646
  * @typedef {import('../util/Types').Point} Point
9089
8647
  */
@@ -9129,7 +8687,7 @@
9129
8687
  *
9130
8688
  * @return {boolean}
9131
8689
  */
9132
- function isButton$1(event, button) {
8690
+ function isButton(event, button) {
9133
8691
  return (getOriginal(event) || event).button === button;
9134
8692
  }
9135
8693
 
@@ -9141,7 +8699,7 @@
9141
8699
  function isPrimaryButton(event) {
9142
8700
 
9143
8701
  // button === 0 -> left áka primary mouse button
9144
- return isButton$1(event, 0);
8702
+ return isButton(event, 0);
9145
8703
  }
9146
8704
 
9147
8705
  /**
@@ -9152,7 +8710,7 @@
9152
8710
  function isAuxiliaryButton(event) {
9153
8711
 
9154
8712
  // button === 1 -> auxiliary áka wheel button
9155
- return isButton$1(event, 1);
8713
+ return isButton(event, 1);
9156
8714
  }
9157
8715
 
9158
8716
  /**
@@ -9790,15 +9348,11 @@
9790
9348
  /**
9791
9349
  * @typedef {import('../../core/Canvas').default} Canvas
9792
9350
  * @typedef {import('../../core/EventBus').default} EventBus
9793
- * @typedef {import('./Selection').default} Selection
9794
9351
  */
9795
9352
 
9796
9353
  var MARKER_HOVER = 'hover',
9797
9354
  MARKER_SELECTED = 'selected';
9798
9355
 
9799
- var SELECTION_OUTLINE_PADDING = 6;
9800
-
9801
-
9802
9356
  /**
9803
9357
  * A plugin that adds a visible selection UI to shapes and connections
9804
9358
  * by appending the <code>hover</code> and <code>selected</code> classes to them.
@@ -9809,15 +9363,10 @@
9809
9363
  *
9810
9364
  * @param {Canvas} canvas
9811
9365
  * @param {EventBus} eventBus
9812
- * @param {Selection} selection
9813
9366
  */
9814
- function SelectionVisuals(canvas, eventBus, selection) {
9367
+ function SelectionVisuals(canvas, eventBus) {
9815
9368
  this._canvas = canvas;
9816
9369
 
9817
- var self = this;
9818
-
9819
- this._multiSelectionBox = null;
9820
-
9821
9370
  function addMarker(e, cls) {
9822
9371
  canvas.addMarker(e, cls);
9823
9372
  }
@@ -9858,63 +9407,14 @@
9858
9407
  select(e);
9859
9408
  }
9860
9409
  });
9861
-
9862
- self._updateSelectionOutline(newSelection);
9863
- });
9864
-
9865
-
9866
- eventBus.on('element.changed', function(event) {
9867
- if (selection.isSelected(event.element)) {
9868
- self._updateSelectionOutline(selection.get());
9869
- }
9870
9410
  });
9871
9411
  }
9872
9412
 
9873
9413
  SelectionVisuals.$inject = [
9874
9414
  'canvas',
9875
- 'eventBus',
9876
- 'selection'
9415
+ 'eventBus'
9877
9416
  ];
9878
9417
 
9879
- SelectionVisuals.prototype._updateSelectionOutline = function(selection) {
9880
- var layer = this._canvas.getLayer('selectionOutline');
9881
-
9882
- clear$1(layer);
9883
-
9884
- var enabled = selection.length > 1;
9885
-
9886
- var container = this._canvas.getContainer();
9887
-
9888
- classes$1(container)[enabled ? 'add' : 'remove']('djs-multi-select');
9889
-
9890
- if (!enabled) {
9891
- return;
9892
- }
9893
-
9894
- var bBox = addSelectionOutlinePadding(getBBox(selection));
9895
-
9896
- var rect = create$1('rect');
9897
-
9898
- attr$1(rect, assign$1({
9899
- rx: 3
9900
- }, bBox));
9901
-
9902
- classes$1(rect).add('djs-selection-outline');
9903
-
9904
- append(layer, rect);
9905
- };
9906
-
9907
- // helpers //////////
9908
-
9909
- function addSelectionOutlinePadding(bBox) {
9910
- return {
9911
- x: bBox.x - SELECTION_OUTLINE_PADDING,
9912
- y: bBox.y - SELECTION_OUTLINE_PADDING,
9913
- width: bBox.width + SELECTION_OUTLINE_PADDING * 2,
9914
- height: bBox.height + SELECTION_OUTLINE_PADDING * 2
9915
- };
9916
- }
9917
-
9918
9418
  /**
9919
9419
  * @typedef {import('../../core/Canvas').default} Canvas
9920
9420
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
@@ -10041,7 +9541,6 @@
10041
9541
  __init__: [ 'selectionVisuals', 'selectionBehavior' ],
10042
9542
  __depends__: [
10043
9543
  InteractionEventsModule,
10044
- OutlineModule$1
10045
9544
  ],
10046
9545
  selection: [ 'type', Selection ],
10047
9546
  selectionVisuals: [ 'type', SelectionVisuals ],
@@ -10970,6 +10469,11 @@
10970
10469
  */
10971
10470
  this._rootElement = null;
10972
10471
 
10472
+ /**
10473
+ * @type {boolean}
10474
+ */
10475
+ this._focused = false;
10476
+
10973
10477
  this._init(config || {});
10974
10478
  }
10975
10479
 
@@ -10996,14 +10500,33 @@
10996
10500
  * @param {CanvasConfig} config
10997
10501
  */
10998
10502
  Canvas.prototype._init = function(config) {
10999
-
11000
10503
  const eventBus = this._eventBus;
11001
10504
 
11002
10505
  // html container
11003
10506
  const container = this._container = createContainer(config);
11004
10507
 
11005
10508
  const svg = this._svg = create$1('svg');
11006
- attr$1(svg, { width: '100%', height: '100%' });
10509
+
10510
+ attr$1(svg, {
10511
+ width: '100%',
10512
+ height: '100%'
10513
+ });
10514
+
10515
+ attr(svg, 'tabindex', 0);
10516
+
10517
+ eventBus.on('element.hover', () => {
10518
+ this.restoreFocus();
10519
+ });
10520
+
10521
+ svg.addEventListener('focusin', () => {
10522
+ this._focused = true;
10523
+ eventBus.fire('canvas.focus.changed', { focused: true });
10524
+ });
10525
+
10526
+ svg.addEventListener('focusout', () => {
10527
+ this._focused = false;
10528
+ eventBus.fire('canvas.focus.changed', { focused: false });
10529
+ });
11007
10530
 
11008
10531
  append(container, svg);
11009
10532
 
@@ -11095,6 +10618,31 @@
11095
10618
  delete this._cachedViewbox;
11096
10619
  };
11097
10620
 
10621
+ /**
10622
+ * Sets focus on the canvas SVG element.
10623
+ */
10624
+ Canvas.prototype.focus = function() {
10625
+ this._svg.focus({ preventScroll: true });
10626
+ };
10627
+
10628
+ /**
10629
+ * Sets focus on the canvas SVG element if `document.body` is currently focused.
10630
+ */
10631
+ Canvas.prototype.restoreFocus = function() {
10632
+ if (document.activeElement === document.body) {
10633
+ this.focus();
10634
+ }
10635
+ };
10636
+
10637
+ /**
10638
+ * Returns true if the canvas is focused.
10639
+ *
10640
+ * @return {boolean}
10641
+ */
10642
+ Canvas.prototype.isFocused = function() {
10643
+ return this._focused;
10644
+ };
10645
+
11098
10646
  /**
11099
10647
  * Returns the default layer on which
11100
10648
  * all elements are drawn.
@@ -14562,13 +14110,15 @@
14562
14110
  if (parts.length === 1) {
14563
14111
  localName = name;
14564
14112
  prefix = defaultPrefix;
14565
- } else
14113
+ }
14566
14114
 
14567
14115
  // prefix + local name
14568
- if (parts.length === 2) {
14116
+ else if (parts.length === 2) {
14569
14117
  localName = parts[1];
14570
14118
  prefix = parts[0];
14571
- } else {
14119
+ }
14120
+
14121
+ else {
14572
14122
  throw new Error('expected <prefix:localName> or <localName>, got ' + name);
14573
14123
  }
14574
14124
 
@@ -15470,7 +15020,7 @@
15470
15020
  * sub-set of reserved names (&amp;) as well as
15471
15021
  * hex (&#xaaf;) and decimal (&#1231;) encoded characters.
15472
15022
  *
15473
- * @param {string} str
15023
+ * @param {string} s
15474
15024
  *
15475
15025
  * @return {string} decoded string
15476
15026
  */
@@ -15482,10 +15032,6 @@
15482
15032
  return s;
15483
15033
  }
15484
15034
 
15485
- var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
15486
- var XSI_PREFIX = 'xsi';
15487
- var XSI_TYPE$1 = 'xsi:type';
15488
-
15489
15035
  var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
15490
15036
 
15491
15037
  function error$1(msg) {
@@ -15530,7 +15076,7 @@
15530
15076
  }
15531
15077
 
15532
15078
  function noopGetContext() {
15533
- return { 'line': 0, 'column': 0 };
15079
+ return { line: 0, column: 0 };
15534
15080
  }
15535
15081
 
15536
15082
  function throwFunc(err) {
@@ -15696,9 +15242,6 @@
15696
15242
  _nsUriToPrefix[k] = nsMap[k];
15697
15243
  }
15698
15244
 
15699
- // FORCE default mapping for schema instance
15700
- _nsUriToPrefix[XSI_URI] = XSI_PREFIX;
15701
-
15702
15245
  isNamespace = true;
15703
15246
  nsUriToPrefix = _nsUriToPrefix;
15704
15247
 
@@ -16022,23 +15565,6 @@
16022
15565
 
16023
15566
  // end: normalize ns attribute name
16024
15567
 
16025
- // normalize xsi:type ns attribute value
16026
- if (name === XSI_TYPE$1) {
16027
- w = value.indexOf(':');
16028
-
16029
- if (w !== -1) {
16030
- nsName = value.substring(0, w);
16031
-
16032
- // handle default prefixes, i.e. xs:String gracefully
16033
- nsName = nsMatrix[nsName] || nsName;
16034
- value = nsName + value.substring(w);
16035
- } else {
16036
- value = defaultAlias + ':' + value;
16037
- }
16038
- }
16039
-
16040
- // end: normalize xsi:type ns attribute value
16041
-
16042
15568
  attrs[name] = value;
16043
15569
  }
16044
15570
 
@@ -16067,23 +15593,6 @@
16067
15593
  : nsName + name.substr(w);
16068
15594
 
16069
15595
  // end: normalize ns attribute name
16070
-
16071
- // normalize xsi:type ns attribute value
16072
- if (name === XSI_TYPE$1) {
16073
- w = value.indexOf(':');
16074
-
16075
- if (w !== -1) {
16076
- nsName = value.substring(0, w);
16077
-
16078
- // handle default prefixes, i.e. xs:String gracefully
16079
- nsName = nsMatrix[nsName] || nsName;
16080
- value = nsName + value.substring(w);
16081
- } else {
16082
- value = defaultAlias + ':' + value;
16083
- }
16084
- }
16085
-
16086
- // end: normalize xsi:type ns attribute value
16087
15596
  }
16088
15597
 
16089
15598
  attrs[name] = value;
@@ -16224,11 +15733,11 @@
16224
15733
  }
16225
15734
  }
16226
15735
 
16227
- w = xml.charCodeAt(i+1);
15736
+ w = xml.charCodeAt(i + 1);
16228
15737
 
16229
15738
  // parse comments + CDATA
16230
15739
  if (w === 33) { // "!"
16231
- q = xml.charCodeAt(i+2);
15740
+ q = xml.charCodeAt(i + 2);
16232
15741
 
16233
15742
  // CDATA section
16234
15743
  if (q === 91 && xml.substr(i + 3, 6) === 'CDATA[') { // 91 == "["
@@ -16512,18 +16021,16 @@
16512
16021
  'xml': 'http://www.w3.org/XML/1998/namespace'
16513
16022
  };
16514
16023
 
16515
- var XSI_TYPE = 'xsi:type';
16024
+ var SERIALIZE_PROPERTY = 'property';
16516
16025
 
16517
- function serializeFormat(element) {
16026
+ function getSerialization(element) {
16518
16027
  return element.xml && element.xml.serialize;
16519
16028
  }
16520
16029
 
16521
- function serializeAsType(element) {
16522
- return serializeFormat(element) === XSI_TYPE;
16523
- }
16030
+ function getSerializationType(element) {
16031
+ const type = getSerialization(element);
16524
16032
 
16525
- function serializeAsProperty(element) {
16526
- return serializeFormat(element) === 'property';
16033
+ return type !== SERIALIZE_PROPERTY && (type || null);
16527
16034
  }
16528
16035
 
16529
16036
  function capitalize(str) {
@@ -16539,12 +16046,20 @@
16539
16046
  return aliasNs.prefix + ':' + capitalize(aliasNs.localName);
16540
16047
  }
16541
16048
 
16049
+ /**
16050
+ * Un-prefix a potentially prefixed type name.
16051
+ *
16052
+ * @param {NsName} nameNs
16053
+ * @param {Object} [pkg]
16054
+ *
16055
+ * @return {string}
16056
+ */
16542
16057
  function prefixedToName(nameNs, pkg) {
16543
16058
 
16544
16059
  var name = nameNs.name,
16545
16060
  localName = nameNs.localName;
16546
16061
 
16547
- var typePrefix = pkg.xml && pkg.xml.typePrefix;
16062
+ var typePrefix = pkg && pkg.xml && pkg.xml.typePrefix;
16548
16063
 
16549
16064
  if (typePrefix && localName.indexOf(typePrefix) === 0) {
16550
16065
  return nameNs.prefix + ':' + localName.slice(typePrefix.length);
@@ -16553,12 +16068,19 @@
16553
16068
  }
16554
16069
  }
16555
16070
 
16556
- function normalizeXsiTypeName(name, model) {
16071
+ function normalizeTypeName(name, nsMap, model) {
16557
16072
 
16558
- var nameNs = parseName(name);
16559
- var pkg = model.getPackage(nameNs.prefix);
16073
+ // normalize against actual NS
16074
+ const nameNs = parseName(name, nsMap.xmlns);
16075
+
16076
+ const normalizedName = `${ nsMap[nameNs.prefix] || nameNs.prefix }:${ nameNs.localName }`;
16560
16077
 
16561
- return prefixedToName(nameNs, pkg);
16078
+ const normalizedNameNs = parseName(normalizedName);
16079
+
16080
+ // determine actual type name, based on package-defined prefix
16081
+ var pkg = model.getPackage(normalizedNameNs.prefix);
16082
+
16083
+ return prefixedToName(normalizedNameNs, pkg);
16562
16084
  }
16563
16085
 
16564
16086
  function error(message) {
@@ -16847,8 +16369,9 @@
16847
16369
  } else {
16848
16370
  if (prop) {
16849
16371
  value = coerceType(prop.type, value);
16850
- } else
16851
- if (name !== 'xmlns') {
16372
+ } else if (name === 'xmlns') {
16373
+ name = ':' + name;
16374
+ } else {
16852
16375
  propNameNs = parseName(name, descriptor.ns.prefix);
16853
16376
 
16854
16377
  // check whether attribute is defined in a well-known namespace
@@ -16881,26 +16404,27 @@
16881
16404
  descriptor = getModdleDescriptor(type);
16882
16405
 
16883
16406
  var propertyName = nameNs.name,
16884
- property = descriptor.propertiesByName[propertyName],
16885
- elementTypeName,
16886
- elementType;
16407
+ property = descriptor.propertiesByName[propertyName];
16887
16408
 
16888
16409
  // search for properties by name first
16889
16410
 
16890
16411
  if (property && !property.isAttr) {
16891
16412
 
16892
- if (serializeAsType(property)) {
16893
- elementTypeName = node.attributes[XSI_TYPE];
16413
+ const serializationType = getSerializationType(property);
16894
16414
 
16895
- // xsi type is optional, if it does not exists the
16415
+ if (serializationType) {
16416
+ const elementTypeName = node.attributes[serializationType];
16417
+
16418
+ // type is optional, if it does not exists the
16896
16419
  // default type is assumed
16897
16420
  if (elementTypeName) {
16898
16421
 
16422
+ // convert the prefix used to the mapped form, but also
16899
16423
  // take possible type prefixes from XML
16900
- // into account, i.e.: xsi:type="t{ActualType}"
16901
- elementTypeName = normalizeXsiTypeName(elementTypeName, model);
16424
+ // into account, i.e.: xsi:type="t{ActualType}",
16425
+ const normalizedTypeName = normalizeTypeName(elementTypeName, node.ns, model);
16902
16426
 
16903
- elementType = model.getType(elementTypeName);
16427
+ const elementType = model.getType(normalizedTypeName);
16904
16428
 
16905
16429
  return assign$1({}, property, {
16906
16430
  effectiveType: getModdleDescriptor(elementType).name
@@ -16915,8 +16439,8 @@
16915
16439
  var pkg = model.getPackage(nameNs.prefix);
16916
16440
 
16917
16441
  if (pkg) {
16918
- elementTypeName = aliasToName(nameNs, pkg);
16919
- elementType = model.getType(elementTypeName);
16442
+ const elementTypeName = aliasToName(nameNs, pkg);
16443
+ const elementType = model.getType(elementTypeName);
16920
16444
 
16921
16445
  // search for collection members later
16922
16446
  property = find(descriptor.properties, function(p) {
@@ -17338,9 +16862,12 @@
17338
16862
  uriMap[p.uri] = p.prefix;
17339
16863
 
17340
16864
  return uriMap;
17341
- }, {
17342
- 'http://www.w3.org/XML/1998/namespace': 'xml' // add default xml ns
17343
- });
16865
+ }, Object.entries(DEFAULT_NS_MAP).reduce(function(map, [ prefix, url ]) {
16866
+ map[url] = prefix;
16867
+
16868
+ return map;
16869
+ }, model.config && model.config.nsMap || {}));
16870
+
17344
16871
  parser
17345
16872
  .ns(uriMap)
17346
16873
  .on('openTag', function(obj, decodeStr, selfClosing, getContext) {
@@ -17441,75 +16968,82 @@
17441
16968
 
17442
16969
  function Namespaces(parent) {
17443
16970
 
17444
- var prefixMap = {};
17445
- var uriMap = {};
17446
- var used = {};
16971
+ this.prefixMap = {};
16972
+ this.uriMap = {};
16973
+ this.used = {};
17447
16974
 
17448
- var wellknown = [];
17449
- var custom = [];
16975
+ this.wellknown = [];
16976
+ this.custom = [];
16977
+ this.parent = parent;
17450
16978
 
17451
- // API
16979
+ this.defaultPrefixMap = parent && parent.defaultPrefixMap || {};
16980
+ }
17452
16981
 
17453
- this.byUri = function(uri) {
17454
- return uriMap[uri] || (
17455
- parent && parent.byUri(uri)
17456
- );
17457
- };
16982
+ Namespaces.prototype.mapDefaultPrefixes = function(defaultPrefixMap) {
16983
+ this.defaultPrefixMap = defaultPrefixMap;
16984
+ };
17458
16985
 
17459
- this.add = function(ns, isWellknown) {
16986
+ Namespaces.prototype.defaultUriByPrefix = function(prefix) {
16987
+ return this.defaultPrefixMap[prefix];
16988
+ };
17460
16989
 
17461
- uriMap[ns.uri] = ns;
16990
+ Namespaces.prototype.byUri = function(uri) {
16991
+ return this.uriMap[uri] || (
16992
+ this.parent && this.parent.byUri(uri)
16993
+ );
16994
+ };
17462
16995
 
17463
- if (isWellknown) {
17464
- wellknown.push(ns);
17465
- } else {
17466
- custom.push(ns);
17467
- }
16996
+ Namespaces.prototype.add = function(ns, isWellknown) {
17468
16997
 
17469
- this.mapPrefix(ns.prefix, ns.uri);
17470
- };
16998
+ this.uriMap[ns.uri] = ns;
17471
16999
 
17472
- this.uriByPrefix = function(prefix) {
17473
- return prefixMap[prefix || 'xmlns'];
17474
- };
17000
+ if (isWellknown) {
17001
+ this.wellknown.push(ns);
17002
+ } else {
17003
+ this.custom.push(ns);
17004
+ }
17475
17005
 
17476
- this.mapPrefix = function(prefix, uri) {
17477
- prefixMap[prefix || 'xmlns'] = uri;
17478
- };
17006
+ this.mapPrefix(ns.prefix, ns.uri);
17007
+ };
17479
17008
 
17480
- this.getNSKey = function(ns) {
17481
- return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17482
- };
17009
+ Namespaces.prototype.uriByPrefix = function(prefix) {
17010
+ return this.prefixMap[prefix || 'xmlns'] || (
17011
+ this.parent && this.parent.uriByPrefix(prefix)
17012
+ );
17013
+ };
17483
17014
 
17484
- this.logUsed = function(ns) {
17015
+ Namespaces.prototype.mapPrefix = function(prefix, uri) {
17016
+ this.prefixMap[prefix || 'xmlns'] = uri;
17017
+ };
17485
17018
 
17486
- var uri = ns.uri;
17487
- var nsKey = this.getNSKey(ns);
17019
+ Namespaces.prototype.getNSKey = function(ns) {
17020
+ return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17021
+ };
17488
17022
 
17489
- used[nsKey] = this.byUri(uri);
17023
+ Namespaces.prototype.logUsed = function(ns) {
17490
17024
 
17491
- // Inform parent recursively about the usage of this NS
17492
- if (parent) {
17493
- parent.logUsed(ns);
17494
- }
17495
- };
17025
+ var uri = ns.uri;
17026
+ var nsKey = this.getNSKey(ns);
17496
17027
 
17497
- this.getUsed = function(ns) {
17028
+ this.used[nsKey] = this.byUri(uri);
17498
17029
 
17499
- function isUsed(ns) {
17500
- var nsKey = self.getNSKey(ns);
17030
+ // Inform parent recursively about the usage of this NS
17031
+ if (this.parent) {
17032
+ this.parent.logUsed(ns);
17033
+ }
17034
+ };
17501
17035
 
17502
- return used[nsKey];
17503
- }
17036
+ Namespaces.prototype.getUsed = function(ns) {
17504
17037
 
17505
- var self = this;
17038
+ var allNs = [].concat(this.wellknown, this.custom);
17506
17039
 
17507
- var allNs = [].concat(wellknown, custom);
17040
+ return allNs.filter(ns => {
17041
+ var nsKey = this.getNSKey(ns);
17508
17042
 
17509
- return allNs.filter(isUsed);
17510
- };
17043
+ return this.used[nsKey];
17044
+ });
17045
+ };
17511
17046
 
17512
- }
17513
17047
 
17514
17048
  function lower(string) {
17515
17049
  return string.charAt(0).toLowerCase() + string.slice(1);
@@ -17724,7 +17258,7 @@
17724
17258
  var isGeneric = elementDescriptor.isGeneric;
17725
17259
 
17726
17260
  if (isGeneric) {
17727
- otherAttrs = this.parseGeneric(element);
17261
+ otherAttrs = this.parseGenericNsAttributes(element);
17728
17262
  } else {
17729
17263
  otherAttrs = this.parseNsAttributes(element);
17730
17264
  }
@@ -17738,7 +17272,9 @@
17738
17272
  // compute tag name
17739
17273
  this.tagName = this.addTagName(this.ns);
17740
17274
 
17741
- if (!isGeneric) {
17275
+ if (isGeneric) {
17276
+ this.parseGenericContainments(element);
17277
+ } else {
17742
17278
  properties = getSerializableProperties(element);
17743
17279
 
17744
17280
  this.parseAttributes(filterAttributes(properties));
@@ -17801,35 +17337,29 @@
17801
17337
  }
17802
17338
  };
17803
17339
 
17804
- ElementSerializer.prototype.parseGeneric = function(element) {
17805
-
17806
- var self = this,
17807
- body = this.body;
17340
+ ElementSerializer.prototype.parseGenericNsAttributes = function(element) {
17808
17341
 
17809
- var attributes = [];
17810
-
17811
- forEach$1(element, function(val, key) {
17342
+ return Object.entries(element).filter(
17343
+ ([ key, value ]) => !key.startsWith('$') && this.parseNsAttribute(element, key, value)
17344
+ ).map(
17345
+ ([ key, value ]) => ({ name: key, value: value })
17346
+ );
17347
+ };
17812
17348
 
17813
- var nonNsAttr;
17349
+ ElementSerializer.prototype.parseGenericContainments = function(element) {
17350
+ var body = element.$body;
17814
17351
 
17815
- if (key === '$body') {
17816
- body.push(new BodySerializer().build({ type: 'String' }, val));
17817
- } else
17818
- if (key === '$children') {
17819
- forEach$1(val, function(child) {
17820
- body.push(new ElementSerializer(self).build(child));
17821
- });
17822
- } else
17823
- if (key.indexOf('$') !== 0) {
17824
- nonNsAttr = self.parseNsAttribute(element, key, val);
17352
+ if (body) {
17353
+ this.body.push(new BodySerializer().build({ type: 'String' }, body));
17354
+ }
17825
17355
 
17826
- if (nonNsAttr) {
17827
- attributes.push({ name: key, value: val });
17828
- }
17829
- }
17830
- });
17356
+ var children = element.$children;
17831
17357
 
17832
- return attributes;
17358
+ if (children) {
17359
+ forEach$1(children, child => {
17360
+ this.body.push(new ElementSerializer(this).build(child));
17361
+ });
17362
+ }
17833
17363
  };
17834
17364
 
17835
17365
  ElementSerializer.prototype.parseNsAttribute = function(element, name, value) {
@@ -17876,7 +17406,7 @@
17876
17406
  * @param {Object} element
17877
17407
  * @return {Array<Object>}
17878
17408
  */
17879
- ElementSerializer.prototype.parseNsAttributes = function(element, attrs) {
17409
+ ElementSerializer.prototype.parseNsAttributes = function(element) {
17880
17410
  var self = this;
17881
17411
 
17882
17412
  var genericAttrs = element.$attrs;
@@ -17904,21 +17434,16 @@
17904
17434
 
17905
17435
  forEach$1(attributes, function(attr) {
17906
17436
 
17907
- // do not serialize xsi:type attribute
17908
- // it is set manually based on the actual implementation type
17909
- if (attr.name === XSI_TYPE) {
17910
- return;
17911
- }
17912
-
17913
17437
  try {
17914
17438
  self.addAttribute(self.nsAttributeName(attr.name), attr.value);
17915
17439
  } catch (e) {
17916
- /* global console */
17917
17440
 
17918
- console.warn(
17919
- 'missing namespace information for ',
17920
- attr.name, '=', attr.value, 'on', element,
17921
- e);
17441
+ // eslint-disable-next-line no-undef
17442
+ typeof console !== 'undefined' && console.warn(
17443
+ `missing namespace information for <${
17444
+ attr.name
17445
+ }=${ attr.value }> on`, element, e
17446
+ );
17922
17447
  }
17923
17448
  });
17924
17449
  };
@@ -17940,13 +17465,11 @@
17940
17465
 
17941
17466
  if (p.isBody) {
17942
17467
  body.push(new BodySerializer().build(p, value[0]));
17943
- } else
17944
- if (isSimple(p.type)) {
17468
+ } else if (isSimple(p.type)) {
17945
17469
  forEach$1(value, function(v) {
17946
17470
  body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
17947
17471
  });
17948
- } else
17949
- if (isReference) {
17472
+ } else if (isReference) {
17950
17473
  forEach$1(value, function(v) {
17951
17474
  body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
17952
17475
  });
@@ -17954,17 +17477,17 @@
17954
17477
 
17955
17478
  // allow serialization via type
17956
17479
  // rather than element name
17957
- var asType = serializeAsType(p),
17958
- asProperty = serializeAsProperty(p);
17480
+ var serialization = getSerialization(p);
17959
17481
 
17960
17482
  forEach$1(value, function(v) {
17961
17483
  var serializer;
17962
17484
 
17963
- if (asType) {
17964
- serializer = new TypeSerializer(self, p);
17965
- } else
17966
- if (asProperty) {
17967
- serializer = new ElementSerializer(self, p);
17485
+ if (serialization) {
17486
+ if (serialization === SERIALIZE_PROPERTY) {
17487
+ serializer = new ElementSerializer(self, p);
17488
+ } else {
17489
+ serializer = new TypeSerializer(self, p, serialization);
17490
+ }
17968
17491
  } else {
17969
17492
  serializer = new ElementSerializer(self);
17970
17493
  }
@@ -18012,9 +17535,7 @@
18012
17535
  };
18013
17536
 
18014
17537
  ElementSerializer.prototype.logNamespaceUsed = function(ns, local) {
18015
- var element = this.element,
18016
- model = element.$model,
18017
- namespaces = this.getNamespaces(local);
17538
+ var namespaces = this.getNamespaces(local);
18018
17539
 
18019
17540
  // ns may be
18020
17541
  //
@@ -18032,7 +17553,7 @@
18032
17553
  return { localName: ns.localName };
18033
17554
  }
18034
17555
 
18035
- wellknownUri = DEFAULT_NS_MAP[prefix] || model && (model.getPackage(prefix) || {}).uri;
17556
+ wellknownUri = namespaces.defaultUriByPrefix(prefix);
18036
17557
 
18037
17558
  uri = uri || wellknownUri || namespaces.uriByPrefix(prefix);
18038
17559
 
@@ -18042,6 +17563,11 @@
18042
17563
 
18043
17564
  ns = namespaces.byUri(uri);
18044
17565
 
17566
+ // register new default prefix <xmlns> in local scope
17567
+ if (!ns && !prefix) {
17568
+ ns = this.logNamespace({ uri }, wellknownUri === uri, true);
17569
+ }
17570
+
18045
17571
  if (!ns) {
18046
17572
  newPrefix = prefix;
18047
17573
  idx = 1;
@@ -18073,8 +17599,7 @@
18073
17599
 
18074
17600
  if (!p.isMany) {
18075
17601
  value = value.id;
18076
- }
18077
- else {
17602
+ } else {
18078
17603
  var values = [];
18079
17604
  forEach$1(value, function(v) {
18080
17605
  values.push(v.id);
@@ -18178,20 +17703,25 @@
18178
17703
  /**
18179
17704
  * A serializer for types that handles serialization of data types
18180
17705
  */
18181
- function TypeSerializer(parent, propertyDescriptor) {
17706
+ function TypeSerializer(parent, propertyDescriptor, serialization) {
18182
17707
  ElementSerializer.call(this, parent, propertyDescriptor);
17708
+
17709
+ this.serialization = serialization;
18183
17710
  }
18184
17711
 
18185
17712
  inherits(TypeSerializer, ElementSerializer);
18186
17713
 
18187
17714
  TypeSerializer.prototype.parseNsAttributes = function(element) {
18188
17715
 
18189
- // extracted attributes
18190
- var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element);
17716
+ // extracted attributes with serialization attribute
17717
+ // <type=typeName> stripped; it may be later
17718
+ var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element).filter(
17719
+ attr => attr.name !== this.serialization
17720
+ );
18191
17721
 
18192
17722
  var descriptor = element.$descriptor;
18193
17723
 
18194
- // only serialize xsi:type if necessary
17724
+ // only serialize <type=typeName> if necessary
18195
17725
  if (descriptor.name === this.propertyDescriptor.type) {
18196
17726
  return attributes;
18197
17727
  }
@@ -18206,7 +17736,7 @@
18206
17736
  typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
18207
17737
 
18208
17738
  this.addAttribute(
18209
- this.nsAttributeName(XSI_TYPE),
17739
+ this.nsAttributeName(this.serialization),
18210
17740
  (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName
18211
17741
  );
18212
17742
 
@@ -18279,7 +17809,13 @@
18279
17809
  formatingWriter.append(XML_PREAMBLE);
18280
17810
  }
18281
17811
 
18282
- new ElementSerializer().build(tree).serializeTo(formatingWriter);
17812
+ var serializer = new ElementSerializer();
17813
+
17814
+ var model = tree.$model;
17815
+
17816
+ serializer.getNamespaces().mapDefaultPrefixes(getDefaultPrefixMappings(model));
17817
+
17818
+ serializer.build(tree).serializeTo(formatingWriter);
18283
17819
 
18284
17820
  if (!writer) {
18285
17821
  return internalWriter.value;
@@ -18291,6 +17827,39 @@
18291
17827
  };
18292
17828
  }
18293
17829
 
17830
+
17831
+ // helpers ///////////
17832
+
17833
+ /**
17834
+ * @param {Moddle} model
17835
+ *
17836
+ * @return { Record<string, string> } map from prefix to URI
17837
+ */
17838
+ function getDefaultPrefixMappings(model) {
17839
+
17840
+ const nsMap = model.config && model.config.nsMap || {};
17841
+
17842
+ const prefixMap = {};
17843
+
17844
+ // { prefix -> uri }
17845
+ for (const prefix in DEFAULT_NS_MAP) {
17846
+ prefixMap[prefix] = DEFAULT_NS_MAP[prefix];
17847
+ }
17848
+
17849
+ // { uri -> prefix }
17850
+ for (const uri in nsMap) {
17851
+ const prefix = nsMap[uri];
17852
+
17853
+ prefixMap[prefix] = uri;
17854
+ }
17855
+
17856
+ for (const pkg of model.getPackages()) {
17857
+ prefixMap[pkg.prefix] = pkg.uri;
17858
+ }
17859
+
17860
+ return prefixMap;
17861
+ }
17862
+
18294
17863
  /**
18295
17864
  * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
18296
17865
  *
@@ -22017,7 +21586,7 @@
22017
21586
  associations: associations$6
22018
21587
  };
22019
21588
 
22020
- var packages = {
21589
+ const packages = {
22021
21590
  bpmn: BpmnPackage,
22022
21591
  bpmndi: BpmnDiPackage,
22023
21592
  dc: DcPackage,
@@ -22026,8 +21595,8 @@
22026
21595
  color: BpmnInColorPackage
22027
21596
  };
22028
21597
 
22029
- function simple(additionalPackages, options) {
22030
- var pks = assign$1({}, packages, additionalPackages);
21598
+ function SimpleBpmnModdle(additionalPackages, options) {
21599
+ const pks = assign$1({}, packages, additionalPackages);
22031
21600
 
22032
21601
  return new BpmnModdle(pks, options);
22033
21602
  }
@@ -23518,7 +23087,7 @@
23518
23087
  BaseViewer.prototype._createModdle = function(options) {
23519
23088
  const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
23520
23089
 
23521
- return new simple(moddleOptions);
23090
+ return new SimpleBpmnModdle(moddleOptions);
23522
23091
  };
23523
23092
 
23524
23093
  BaseViewer.prototype._modules = [];
@@ -23680,7 +23249,6 @@
23680
23249
  Viewer.prototype._modules = [
23681
23250
  CoreModule$1,
23682
23251
  DrilldownModdule,
23683
- OutlineModule,
23684
23252
  OverlaysModule,
23685
23253
  SelectionModule,
23686
23254
  TranslateModule
@@ -23778,10 +23346,11 @@
23778
23346
  var KEYDOWN_EVENT = 'keyboard.keydown',
23779
23347
  KEYUP_EVENT = 'keyboard.keyup';
23780
23348
 
23781
- var HANDLE_MODIFIER_ATTRIBUTE = 'input-handle-modified-keys';
23782
-
23783
23349
  var DEFAULT_PRIORITY = 1000;
23784
23350
 
23351
+ 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';
23352
+
23353
+
23785
23354
  /**
23786
23355
  * A keyboard abstraction that may be activated and
23787
23356
  * deactivated by users at will, consuming global key events
@@ -23800,8 +23369,8 @@
23800
23369
  *
23801
23370
  * All events contain one field which is node.
23802
23371
  *
23803
- * A default binding for the keyboard may be specified via the
23804
- * `keyboard.bindTo` configuration option.
23372
+ * Specify the initial keyboard binding state via the
23373
+ * `keyboard.bind=true|false` configuration option.
23805
23374
  *
23806
23375
  * @param {Object} config
23807
23376
  * @param {EventTarget} [config.bindTo]
@@ -23810,7 +23379,8 @@
23810
23379
  function Keyboard(config, eventBus) {
23811
23380
  var self = this;
23812
23381
 
23813
- this._config = config || {};
23382
+ this._config = config = config || {};
23383
+
23814
23384
  this._eventBus = eventBus;
23815
23385
 
23816
23386
  this._keydownHandler = this._keydownHandler.bind(this);
@@ -23823,19 +23393,22 @@
23823
23393
  self.unbind();
23824
23394
  });
23825
23395
 
23826
- eventBus.on('diagram.init', function() {
23827
- self._fire('init');
23828
- });
23396
+ if (config.bindTo) {
23397
+ console.error('unsupported configuration <keyboard.bindTo>', new Error(compatMessage));
23398
+ }
23399
+
23400
+ var bind = config && config.bind !== false;
23401
+
23402
+ eventBus.on('canvas.init', function(event) {
23403
+ self._target = event.svg;
23829
23404
 
23830
- eventBus.on('attach', function() {
23831
- if (config && config.bindTo) {
23832
- self.bind(config.bindTo);
23405
+ if (bind) {
23406
+ self.bind();
23833
23407
  }
23834
- });
23835
23408
 
23836
- eventBus.on('detach', function() {
23837
- self.unbind();
23409
+ self._fire('init');
23838
23410
  });
23411
+
23839
23412
  }
23840
23413
 
23841
23414
  Keyboard.$inject = [
@@ -23870,34 +23443,7 @@
23870
23443
  };
23871
23444
 
23872
23445
  Keyboard.prototype._isEventIgnored = function(event) {
23873
- if (event.defaultPrevented) {
23874
- return true;
23875
- }
23876
-
23877
- return (
23878
- isInput(event.target) || (
23879
- isButton(event.target) && isKey([ ' ', 'Enter' ], event)
23880
- )
23881
- ) && this._isModifiedKeyIgnored(event);
23882
- };
23883
-
23884
- Keyboard.prototype._isModifiedKeyIgnored = function(event) {
23885
- if (!isCmd(event)) {
23886
- return true;
23887
- }
23888
-
23889
- var allowedModifiers = this._getAllowedModifiers(event.target);
23890
- return allowedModifiers.indexOf(event.key) === -1;
23891
- };
23892
-
23893
- Keyboard.prototype._getAllowedModifiers = function(element) {
23894
- var modifierContainer = closest(element, '[' + HANDLE_MODIFIER_ATTRIBUTE + ']', true);
23895
-
23896
- if (!modifierContainer || (this._node && !this._node.contains(modifierContainer))) {
23897
- return [];
23898
- }
23899
-
23900
- return modifierContainer.getAttribute(HANDLE_MODIFIER_ATTRIBUTE).split(',');
23446
+ return false;
23901
23447
  };
23902
23448
 
23903
23449
  /**
@@ -23907,10 +23453,14 @@
23907
23453
  */
23908
23454
  Keyboard.prototype.bind = function(node) {
23909
23455
 
23456
+ if (node) {
23457
+ console.error('unsupported argument <node>', new Error(compatMessage));
23458
+ }
23459
+
23910
23460
  // make sure that the keyboard is only bound once to the DOM
23911
23461
  this.unbind();
23912
23462
 
23913
- this._node = node;
23463
+ node = this._node = this._target;
23914
23464
 
23915
23465
  // bind key events
23916
23466
  event.bind(node, 'keydown', this._keydownHandler);
@@ -23981,18 +23531,6 @@
23981
23531
  Keyboard.prototype.isShift = isShift;
23982
23532
  Keyboard.prototype.isKey = isKey;
23983
23533
 
23984
-
23985
-
23986
- // helpers ///////
23987
-
23988
- function isInput(target) {
23989
- return target && (matches(target, 'input, textarea') || target.contentEditable === 'true');
23990
- }
23991
-
23992
- function isButton(target) {
23993
- return target && matches(target, 'button, input[type=submit], input[type=button], a[href], [aria-role=button]');
23994
- }
23995
-
23996
23534
  var LOW_PRIORITY = 500;
23997
23535
 
23998
23536