camunda-bpmn-js 4.20.2 → 5.1.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
  };
@@ -5195,6 +5164,8 @@
5195
5164
 
5196
5165
  return bbox;
5197
5166
  } catch (e) {
5167
+ console.log(e);
5168
+
5198
5169
  return { width: 0, height: 0 };
5199
5170
  }
5200
5171
  }
@@ -6793,7 +6764,7 @@
6793
6764
  // document wide unique overlay ids
6794
6765
  var ids = new IdGenerator('ov');
6795
6766
 
6796
- var LOW_PRIORITY$3 = 500;
6767
+ var LOW_PRIORITY$2 = 500;
6797
6768
 
6798
6769
  /**
6799
6770
  * @typedef {import('../../core/Canvas').default} Canvas
@@ -7423,7 +7394,7 @@
7423
7394
 
7424
7395
  // move integration
7425
7396
 
7426
- eventBus.on('element.changed', LOW_PRIORITY$3, function(e) {
7397
+ eventBus.on('element.changed', LOW_PRIORITY$2, function(e) {
7427
7398
  var element = e.element;
7428
7399
 
7429
7400
  var container = self._getOverlayContainer(element, true);
@@ -7597,7 +7568,7 @@
7597
7568
  * @typedef { (context: CommandContext) => void } ComposeHandlerFunction
7598
7569
  */
7599
7570
 
7600
- var DEFAULT_PRIORITY$2 = 1000;
7571
+ var DEFAULT_PRIORITY$1 = 1000;
7601
7572
 
7602
7573
  /**
7603
7574
  * A utility that can be used to plug into the command execution for
@@ -7664,7 +7635,7 @@
7664
7635
  that = unwrap;
7665
7636
  unwrap = handlerFn;
7666
7637
  handlerFn = priority;
7667
- priority = DEFAULT_PRIORITY$2;
7638
+ priority = DEFAULT_PRIORITY$1;
7668
7639
  }
7669
7640
 
7670
7641
  if (isObject(unwrap)) {
@@ -8461,7 +8432,7 @@
8461
8432
  * @typedef {import('../../model/Types').Shape} Shape
8462
8433
  */
8463
8434
 
8464
- var LOW_PRIORITY$2 = 250;
8435
+ var LOW_PRIORITY$1 = 250;
8465
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>';
8466
8437
 
8467
8438
  var EMPTY_MARKER = 'bjs-drilldown-empty';
@@ -8486,7 +8457,7 @@
8486
8457
 
8487
8458
  var self = this;
8488
8459
 
8489
- this.executed('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8460
+ this.executed('shape.toggleCollapse', LOW_PRIORITY$1, function(context) {
8490
8461
  var shape = context.shape;
8491
8462
 
8492
8463
  // Add overlay to the collapsed shape
@@ -8498,7 +8469,7 @@
8498
8469
  }, true);
8499
8470
 
8500
8471
 
8501
- this.reverted('shape.toggleCollapse', LOW_PRIORITY$2, function(context) {
8472
+ this.reverted('shape.toggleCollapse', LOW_PRIORITY$1, function(context) {
8502
8473
  var shape = context.shape;
8503
8474
 
8504
8475
  // Add overlay to the collapsed shape
@@ -8510,7 +8481,7 @@
8510
8481
  }, true);
8511
8482
 
8512
8483
 
8513
- this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8484
+ this.executed([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$1,
8514
8485
  function(context) {
8515
8486
  var oldParent = context.oldParent,
8516
8487
  newParent = context.newParent || context.parent,
@@ -8527,7 +8498,7 @@
8527
8498
  }, true);
8528
8499
 
8529
8500
 
8530
- this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$2,
8501
+ this.reverted([ 'shape.create', 'shape.move', 'shape.delete' ], LOW_PRIORITY$1,
8531
8502
  function(context) {
8532
8503
  var oldParent = context.oldParent,
8533
8504
  newParent = context.newParent || context.parent,
@@ -8671,409 +8642,6 @@
8671
8642
  subprocessCompatibility: [ 'type', SubprocessCompatibility ]
8672
8643
  };
8673
8644
 
8674
- var LOW_PRIORITY$1 = 500;
8675
-
8676
- var DEFAULT_PRIORITY$1 = 1000;
8677
-
8678
- /**
8679
- * @typedef {import('../../model/Types').Element} Element
8680
- *
8681
- * @typedef {import('./OutlineProvider').default} OutlineProvider
8682
- * @typedef {import('../../core/EventBus').default} EventBus
8683
- * @typedef {import('../../draw/Styles').default} Styles
8684
- */
8685
-
8686
- /**
8687
- * @class
8688
- *
8689
- * A plugin that adds an outline to shapes and connections that may be activated and styled
8690
- * via CSS classes.
8691
- *
8692
- * @param {EventBus} eventBus
8693
- * @param {Styles} styles
8694
- */
8695
- function Outline(eventBus, styles) {
8696
-
8697
- this._eventBus = eventBus;
8698
-
8699
- this.offset = 5;
8700
-
8701
- var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
8702
-
8703
- var self = this;
8704
-
8705
- /**
8706
- * @param {SVGElement} gfx
8707
- *
8708
- * @return {SVGElement} outline
8709
- */
8710
- function createOutline(gfx) {
8711
- var outline = create$1('rect');
8712
-
8713
- attr$1(outline, assign$1({
8714
- x: 0,
8715
- y: 0,
8716
- rx: 4,
8717
- width: 100,
8718
- height: 100
8719
- }, OUTLINE_STYLE));
8720
-
8721
- return outline;
8722
- }
8723
-
8724
- // A low priortity is necessary, because outlines of labels have to be updated
8725
- // after the label bounds have been updated in the renderer.
8726
- eventBus.on([ 'shape.added', 'shape.changed' ], LOW_PRIORITY$1, function(event) {
8727
- var element = event.element,
8728
- gfx = event.gfx;
8729
-
8730
- var outline = query('.djs-outline', gfx);
8731
-
8732
- if (!outline) {
8733
- outline = self.getOutline(element) || createOutline();
8734
- append(gfx, outline);
8735
- }
8736
-
8737
- self.updateShapeOutline(outline, element);
8738
- });
8739
-
8740
- eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
8741
- var element = event.element,
8742
- gfx = event.gfx;
8743
-
8744
- var outline = query('.djs-outline', gfx);
8745
-
8746
- if (!outline) {
8747
- outline = createOutline();
8748
- append(gfx, outline);
8749
- }
8750
-
8751
- self.updateConnectionOutline(outline, element);
8752
- });
8753
- }
8754
-
8755
-
8756
- /**
8757
- * Updates the outline of a shape respecting the dimension of the
8758
- * element and an outline offset.
8759
- *
8760
- * @param {SVGElement} outline
8761
- * @param {Element} element
8762
- */
8763
- Outline.prototype.updateShapeOutline = function(outline, element) {
8764
-
8765
- var updated = false;
8766
- var providers = this._getProviders();
8767
-
8768
- if (providers.length) {
8769
- forEach$1(providers, function(provider) {
8770
- updated = updated || provider.updateOutline(element, outline);
8771
- });
8772
- }
8773
-
8774
- if (!updated) {
8775
- attr$1(outline, {
8776
- x: -this.offset,
8777
- y: -this.offset,
8778
- width: element.width + this.offset * 2,
8779
- height: element.height + this.offset * 2
8780
- });
8781
- }
8782
- };
8783
-
8784
- /**
8785
- * Updates the outline of a connection respecting the bounding box of
8786
- * the connection and an outline offset.
8787
- * Register an outline provider with the given priority.
8788
- *
8789
- * @param {SVGElement} outline
8790
- * @param {Element} connection
8791
- */
8792
- Outline.prototype.updateConnectionOutline = function(outline, connection) {
8793
- var bbox = getBBox(connection);
8794
-
8795
- attr$1(outline, {
8796
- x: bbox.x - this.offset,
8797
- y: bbox.y - this.offset,
8798
- width: bbox.width + this.offset * 2,
8799
- height: bbox.height + this.offset * 2
8800
- });
8801
- };
8802
-
8803
- /**
8804
- * Register an outline provider with the given priority.
8805
- *
8806
- * @param {number} priority
8807
- * @param {OutlineProvider} provider
8808
- */
8809
- Outline.prototype.registerProvider = function(priority, provider) {
8810
- if (!provider) {
8811
- provider = priority;
8812
- priority = DEFAULT_PRIORITY$1;
8813
- }
8814
-
8815
- this._eventBus.on('outline.getProviders', priority, function(event) {
8816
- event.providers.push(provider);
8817
- });
8818
- };
8819
-
8820
- /**
8821
- * Returns the registered outline providers.
8822
- *
8823
- * @returns {OutlineProvider[]}
8824
- */
8825
- Outline.prototype._getProviders = function() {
8826
- var event = this._eventBus.createEvent({
8827
- type: 'outline.getProviders',
8828
- providers: []
8829
- });
8830
-
8831
- this._eventBus.fire(event);
8832
-
8833
- return event.providers;
8834
- };
8835
-
8836
- /**
8837
- * Returns the outline for an element.
8838
- *
8839
- * @param {Element} element
8840
- */
8841
- Outline.prototype.getOutline = function(element) {
8842
- var outline;
8843
- var providers = this._getProviders();
8844
-
8845
- forEach$1(providers, function(provider) {
8846
-
8847
- if (!isFunction(provider.getOutline)) {
8848
- return;
8849
- }
8850
-
8851
- outline = outline || provider.getOutline(element);
8852
- });
8853
-
8854
- return outline;
8855
- };
8856
-
8857
- Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ];
8858
-
8859
- /**
8860
- * @type { import('didi').ModuleDeclaration }
8861
- */
8862
- var OutlineModule$1 = {
8863
- __init__: [ 'outline' ],
8864
- outline: [ 'type', Outline ]
8865
- };
8866
-
8867
- 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';
8868
- 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';
8869
-
8870
- /**
8871
- * @typedef { import('diagram-js/lib/util/Types').Dimensions} Dimensions
8872
- */
8873
-
8874
- /**
8875
- * @type {Dimensions}
8876
- */
8877
- const DATA_OBJECT_REFERENCE_STANDARD_SIZE = { width: 36, height: 50 };
8878
-
8879
- /**
8880
- * @type {Dimensions}
8881
- */
8882
- const DATA_STORE_REFERENCE_STANDARD_SIZE = { width: 50, height: 50 };
8883
-
8884
- /**
8885
- * Create a path element with given attributes.
8886
- * @param {string} path
8887
- * @param {Object} attrs
8888
- * @param {Object} OUTLINE_STYLE
8889
- * @return {SVGElement}
8890
- */
8891
- function createPath(path, attrs, OUTLINE_STYLE) {
8892
- return create$1('path', {
8893
- d: path,
8894
- strokeWidth: 2,
8895
- transform: `translate(${attrs.x}, ${attrs.y})`,
8896
- ...OUTLINE_STYLE
8897
- });
8898
- }
8899
-
8900
- /**
8901
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').default } BaseOutlineProvider
8902
- *
8903
- * @typedef { import('diagram-js/lib/features/outline/OutlineProvider').Outline } Outline
8904
- *
8905
- * @typedef { import('diagram-js/lib/draw/Styles').default } Styles
8906
- *
8907
- * @typedef { import('diagram-js/lib/model/Types').Element } Element
8908
- */
8909
-
8910
- const DEFAULT_OFFSET = 5;
8911
-
8912
- /**
8913
- * BPMN-specific outline provider.
8914
- *
8915
- * @implements {BaseOutlineProvider}
8916
- *
8917
- * @param {Outline} outline
8918
- * @param {Styles} styles
8919
- */
8920
- function OutlineProvider(outline, styles) {
8921
-
8922
- this._styles = styles;
8923
- outline.registerProvider(this);
8924
- }
8925
-
8926
- OutlineProvider.$inject = [
8927
- 'outline',
8928
- 'styles'
8929
- ];
8930
-
8931
- /**
8932
- * Returns outline for a given element.
8933
- *
8934
- * @param {Element} element
8935
- *
8936
- * @return {Outline}
8937
- */
8938
- OutlineProvider.prototype.getOutline = function(element) {
8939
-
8940
- const OUTLINE_STYLE = this._styles.cls('djs-outline', [ 'no-fill' ]);
8941
-
8942
- var outline;
8943
-
8944
- if (isLabel(element)) {
8945
- return;
8946
- }
8947
-
8948
- if (is$1(element, 'bpmn:Gateway')) {
8949
- outline = create$1('rect');
8950
-
8951
- assign$1(outline.style, {
8952
- 'transform-box': 'fill-box',
8953
- 'transform': 'rotate(45deg)',
8954
- 'transform-origin': 'center'
8955
- });
8956
-
8957
- attr$1(outline, assign$1({
8958
- x: 2,
8959
- y: 2,
8960
- rx: 4,
8961
- width: element.width - 4,
8962
- height: element.height - 4,
8963
- }, OUTLINE_STYLE));
8964
-
8965
- } else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Group', 'bpmn:CallActivity' ])) {
8966
- outline = create$1('rect');
8967
-
8968
- attr$1(outline, assign$1({
8969
- x: -DEFAULT_OFFSET,
8970
- y: -DEFAULT_OFFSET,
8971
- rx: 14,
8972
- width: element.width + DEFAULT_OFFSET * 2,
8973
- height: element.height + DEFAULT_OFFSET * 2
8974
- }, OUTLINE_STYLE));
8975
-
8976
- } else if (is$1(element, 'bpmn:EndEvent')) {
8977
-
8978
- outline = create$1('circle');
8979
-
8980
- // Extra 1px offset needed due to increased stroke-width of end event
8981
- // which makes it bigger than other events.
8982
-
8983
- attr$1(outline, assign$1({
8984
- cx: element.width / 2,
8985
- cy: element.height / 2,
8986
- r: element.width / 2 + DEFAULT_OFFSET + 1
8987
- }, OUTLINE_STYLE));
8988
-
8989
- } else if (is$1(element, 'bpmn:Event')) {
8990
- outline = create$1('circle');
8991
-
8992
- attr$1(outline, assign$1({
8993
- cx: element.width / 2,
8994
- cy: element.height / 2,
8995
- r: element.width / 2 + DEFAULT_OFFSET
8996
- }, OUTLINE_STYLE));
8997
-
8998
- } else if (is$1(element, 'bpmn:DataObjectReference') && isStandardSize(element, 'bpmn:DataObjectReference')) {
8999
-
9000
- outline = createPath(
9001
- DATA_OBJECT_REFERENCE_OUTLINE_PATH,
9002
- { x: -6, y: -6 },
9003
- OUTLINE_STYLE
9004
- );
9005
-
9006
- } else if (is$1(element, 'bpmn:DataStoreReference') && isStandardSize(element, 'bpmn:DataStoreReference')) {
9007
-
9008
- outline = createPath(
9009
- DATA_STORE_REFERENCE_OUTLINE_PATH,
9010
- { x: -6, y: -6 },
9011
- OUTLINE_STYLE
9012
- );
9013
- }
9014
-
9015
- return outline;
9016
- };
9017
-
9018
- /**
9019
- * Updates the outline for a given element.
9020
- * Returns true if the update for the given element was handled by this provider.
9021
- *
9022
- * @param {Element} element
9023
- * @param {Outline} outline
9024
- * @returns {boolean}
9025
- */
9026
- OutlineProvider.prototype.updateOutline = function(element, outline) {
9027
-
9028
- if (isLabel(element)) {
9029
- return;
9030
- }
9031
-
9032
- if (isAny(element, [ 'bpmn:SubProcess', 'bpmn:Group' ])) {
9033
-
9034
- attr$1(outline, {
9035
- width: element.width + DEFAULT_OFFSET * 2,
9036
- height: element.height + DEFAULT_OFFSET * 2
9037
- });
9038
-
9039
- return true;
9040
-
9041
- } else if (isAny(element, [
9042
- 'bpmn:Event',
9043
- 'bpmn:Gateway',
9044
- 'bpmn:DataStoreReference',
9045
- 'bpmn:DataObjectReference'
9046
- ])) {
9047
- return true;
9048
- }
9049
-
9050
- return false;
9051
- };
9052
-
9053
-
9054
- // helpers //////////
9055
-
9056
- function isStandardSize(element, type) {
9057
- var standardSize;
9058
-
9059
- if (type === 'bpmn:DataObjectReference') {
9060
- standardSize = DATA_OBJECT_REFERENCE_STANDARD_SIZE;
9061
- } else if (type === 'bpmn:DataStoreReference') {
9062
- standardSize = DATA_STORE_REFERENCE_STANDARD_SIZE;
9063
- }
9064
-
9065
- return element.width === standardSize.width
9066
- && element.height === standardSize.height;
9067
- }
9068
-
9069
- var OutlineModule = {
9070
- __depends__: [
9071
- OutlineModule$1
9072
- ],
9073
- __init__: [ 'outlineProvider' ],
9074
- outlineProvider: [ 'type', OutlineProvider ]
9075
- };
9076
-
9077
8645
  /**
9078
8646
  * @typedef {import('../util/Types').Point} Point
9079
8647
  */
@@ -9755,15 +9323,11 @@
9755
9323
  /**
9756
9324
  * @typedef {import('../../core/Canvas').default} Canvas
9757
9325
  * @typedef {import('../../core/EventBus').default} EventBus
9758
- * @typedef {import('./Selection').default} Selection
9759
9326
  */
9760
9327
 
9761
9328
  var MARKER_HOVER = 'hover',
9762
9329
  MARKER_SELECTED = 'selected';
9763
9330
 
9764
- var SELECTION_OUTLINE_PADDING = 6;
9765
-
9766
-
9767
9331
  /**
9768
9332
  * A plugin that adds a visible selection UI to shapes and connections
9769
9333
  * by appending the <code>hover</code> and <code>selected</code> classes to them.
@@ -9774,15 +9338,10 @@
9774
9338
  *
9775
9339
  * @param {Canvas} canvas
9776
9340
  * @param {EventBus} eventBus
9777
- * @param {Selection} selection
9778
9341
  */
9779
- function SelectionVisuals(canvas, eventBus, selection) {
9342
+ function SelectionVisuals(canvas, eventBus) {
9780
9343
  this._canvas = canvas;
9781
9344
 
9782
- var self = this;
9783
-
9784
- this._multiSelectionBox = null;
9785
-
9786
9345
  function addMarker(e, cls) {
9787
9346
  canvas.addMarker(e, cls);
9788
9347
  }
@@ -9823,63 +9382,14 @@
9823
9382
  select(e);
9824
9383
  }
9825
9384
  });
9826
-
9827
- self._updateSelectionOutline(newSelection);
9828
- });
9829
-
9830
-
9831
- eventBus.on('element.changed', function(event) {
9832
- if (selection.isSelected(event.element)) {
9833
- self._updateSelectionOutline(selection.get());
9834
- }
9835
9385
  });
9836
9386
  }
9837
9387
 
9838
9388
  SelectionVisuals.$inject = [
9839
9389
  'canvas',
9840
- 'eventBus',
9841
- 'selection'
9390
+ 'eventBus'
9842
9391
  ];
9843
9392
 
9844
- SelectionVisuals.prototype._updateSelectionOutline = function(selection) {
9845
- var layer = this._canvas.getLayer('selectionOutline');
9846
-
9847
- clear$1(layer);
9848
-
9849
- var enabled = selection.length > 1;
9850
-
9851
- var container = this._canvas.getContainer();
9852
-
9853
- classes$1(container)[enabled ? 'add' : 'remove']('djs-multi-select');
9854
-
9855
- if (!enabled) {
9856
- return;
9857
- }
9858
-
9859
- var bBox = addSelectionOutlinePadding(getBBox(selection));
9860
-
9861
- var rect = create$1('rect');
9862
-
9863
- attr$1(rect, assign$1({
9864
- rx: 3
9865
- }, bBox));
9866
-
9867
- classes$1(rect).add('djs-selection-outline');
9868
-
9869
- append(layer, rect);
9870
- };
9871
-
9872
- // helpers //////////
9873
-
9874
- function addSelectionOutlinePadding(bBox) {
9875
- return {
9876
- x: bBox.x - SELECTION_OUTLINE_PADDING,
9877
- y: bBox.y - SELECTION_OUTLINE_PADDING,
9878
- width: bBox.width + SELECTION_OUTLINE_PADDING * 2,
9879
- height: bBox.height + SELECTION_OUTLINE_PADDING * 2
9880
- };
9881
- }
9882
-
9883
9393
  /**
9884
9394
  * @typedef {import('../../core/Canvas').default} Canvas
9885
9395
  * @typedef {import('../../core/ElementRegistry').default} ElementRegistry
@@ -10006,7 +9516,6 @@
10006
9516
  __init__: [ 'selectionVisuals', 'selectionBehavior' ],
10007
9517
  __depends__: [
10008
9518
  InteractionEventsModule,
10009
- OutlineModule$1
10010
9519
  ],
10011
9520
  selection: [ 'type', Selection ],
10012
9521
  selectionVisuals: [ 'type', SelectionVisuals ],
@@ -10935,6 +10444,11 @@
10935
10444
  */
10936
10445
  this._rootElement = null;
10937
10446
 
10447
+ /**
10448
+ * @type {boolean}
10449
+ */
10450
+ this._focused = false;
10451
+
10938
10452
  this._init(config || {});
10939
10453
  }
10940
10454
 
@@ -10961,14 +10475,33 @@
10961
10475
  * @param {CanvasConfig} config
10962
10476
  */
10963
10477
  Canvas.prototype._init = function(config) {
10964
-
10965
10478
  const eventBus = this._eventBus;
10966
10479
 
10967
10480
  // html container
10968
10481
  const container = this._container = createContainer(config);
10969
10482
 
10970
10483
  const svg = this._svg = create$1('svg');
10971
- attr$1(svg, { width: '100%', height: '100%' });
10484
+
10485
+ attr$1(svg, {
10486
+ width: '100%',
10487
+ height: '100%'
10488
+ });
10489
+
10490
+ attr(svg, 'tabindex', 0);
10491
+
10492
+ eventBus.on('element.hover', () => {
10493
+ this.restoreFocus();
10494
+ });
10495
+
10496
+ svg.addEventListener('focusin', () => {
10497
+ this._focused = true;
10498
+ eventBus.fire('canvas.focus.changed', { focused: true });
10499
+ });
10500
+
10501
+ svg.addEventListener('focusout', () => {
10502
+ this._focused = false;
10503
+ eventBus.fire('canvas.focus.changed', { focused: false });
10504
+ });
10972
10505
 
10973
10506
  append(container, svg);
10974
10507
 
@@ -11060,6 +10593,31 @@
11060
10593
  delete this._cachedViewbox;
11061
10594
  };
11062
10595
 
10596
+ /**
10597
+ * Sets focus on the canvas SVG element.
10598
+ */
10599
+ Canvas.prototype.focus = function() {
10600
+ this._svg.focus({ preventScroll: true });
10601
+ };
10602
+
10603
+ /**
10604
+ * Sets focus on the canvas SVG element if `document.body` is currently focused.
10605
+ */
10606
+ Canvas.prototype.restoreFocus = function() {
10607
+ if (document.activeElement === document.body) {
10608
+ this.focus();
10609
+ }
10610
+ };
10611
+
10612
+ /**
10613
+ * Returns true if the canvas is focused.
10614
+ *
10615
+ * @return {boolean}
10616
+ */
10617
+ Canvas.prototype.isFocused = function() {
10618
+ return this._focused;
10619
+ };
10620
+
11063
10621
  /**
11064
10622
  * Returns the default layer on which
11065
10623
  * all elements are drawn.
@@ -14527,13 +14085,15 @@
14527
14085
  if (parts.length === 1) {
14528
14086
  localName = name;
14529
14087
  prefix = defaultPrefix;
14530
- } else
14088
+ }
14531
14089
 
14532
14090
  // prefix + local name
14533
- if (parts.length === 2) {
14091
+ else if (parts.length === 2) {
14534
14092
  localName = parts[1];
14535
14093
  prefix = parts[0];
14536
- } else {
14094
+ }
14095
+
14096
+ else {
14537
14097
  throw new Error('expected <prefix:localName> or <localName>, got ' + name);
14538
14098
  }
14539
14099
 
@@ -15435,7 +14995,7 @@
15435
14995
  * sub-set of reserved names (&amp;) as well as
15436
14996
  * hex (&#xaaf;) and decimal (&#1231;) encoded characters.
15437
14997
  *
15438
- * @param {string} str
14998
+ * @param {string} s
15439
14999
  *
15440
15000
  * @return {string} decoded string
15441
15001
  */
@@ -15447,10 +15007,6 @@
15447
15007
  return s;
15448
15008
  }
15449
15009
 
15450
- var XSI_URI = 'http://www.w3.org/2001/XMLSchema-instance';
15451
- var XSI_PREFIX = 'xsi';
15452
- var XSI_TYPE$1 = 'xsi:type';
15453
-
15454
15010
  var NON_WHITESPACE_OUTSIDE_ROOT_NODE = 'non-whitespace outside of root node';
15455
15011
 
15456
15012
  function error$1(msg) {
@@ -15495,7 +15051,7 @@
15495
15051
  }
15496
15052
 
15497
15053
  function noopGetContext() {
15498
- return { 'line': 0, 'column': 0 };
15054
+ return { line: 0, column: 0 };
15499
15055
  }
15500
15056
 
15501
15057
  function throwFunc(err) {
@@ -15661,9 +15217,6 @@
15661
15217
  _nsUriToPrefix[k] = nsMap[k];
15662
15218
  }
15663
15219
 
15664
- // FORCE default mapping for schema instance
15665
- _nsUriToPrefix[XSI_URI] = XSI_PREFIX;
15666
-
15667
15220
  isNamespace = true;
15668
15221
  nsUriToPrefix = _nsUriToPrefix;
15669
15222
 
@@ -15987,23 +15540,6 @@
15987
15540
 
15988
15541
  // end: normalize ns attribute name
15989
15542
 
15990
- // normalize xsi:type ns attribute value
15991
- if (name === XSI_TYPE$1) {
15992
- w = value.indexOf(':');
15993
-
15994
- if (w !== -1) {
15995
- nsName = value.substring(0, w);
15996
-
15997
- // handle default prefixes, i.e. xs:String gracefully
15998
- nsName = nsMatrix[nsName] || nsName;
15999
- value = nsName + value.substring(w);
16000
- } else {
16001
- value = defaultAlias + ':' + value;
16002
- }
16003
- }
16004
-
16005
- // end: normalize xsi:type ns attribute value
16006
-
16007
15543
  attrs[name] = value;
16008
15544
  }
16009
15545
 
@@ -16032,23 +15568,6 @@
16032
15568
  : nsName + name.substr(w);
16033
15569
 
16034
15570
  // end: normalize ns attribute name
16035
-
16036
- // normalize xsi:type ns attribute value
16037
- if (name === XSI_TYPE$1) {
16038
- w = value.indexOf(':');
16039
-
16040
- if (w !== -1) {
16041
- nsName = value.substring(0, w);
16042
-
16043
- // handle default prefixes, i.e. xs:String gracefully
16044
- nsName = nsMatrix[nsName] || nsName;
16045
- value = nsName + value.substring(w);
16046
- } else {
16047
- value = defaultAlias + ':' + value;
16048
- }
16049
- }
16050
-
16051
- // end: normalize xsi:type ns attribute value
16052
15571
  }
16053
15572
 
16054
15573
  attrs[name] = value;
@@ -16189,11 +15708,11 @@
16189
15708
  }
16190
15709
  }
16191
15710
 
16192
- w = xml.charCodeAt(i+1);
15711
+ w = xml.charCodeAt(i + 1);
16193
15712
 
16194
15713
  // parse comments + CDATA
16195
15714
  if (w === 33) { // "!"
16196
- q = xml.charCodeAt(i+2);
15715
+ q = xml.charCodeAt(i + 2);
16197
15716
 
16198
15717
  // CDATA section
16199
15718
  if (q === 91 && xml.substr(i + 3, 6) === 'CDATA[') { // 91 == "["
@@ -16477,18 +15996,16 @@
16477
15996
  'xml': 'http://www.w3.org/XML/1998/namespace'
16478
15997
  };
16479
15998
 
16480
- var XSI_TYPE = 'xsi:type';
15999
+ var SERIALIZE_PROPERTY = 'property';
16481
16000
 
16482
- function serializeFormat(element) {
16001
+ function getSerialization(element) {
16483
16002
  return element.xml && element.xml.serialize;
16484
16003
  }
16485
16004
 
16486
- function serializeAsType(element) {
16487
- return serializeFormat(element) === XSI_TYPE;
16488
- }
16005
+ function getSerializationType(element) {
16006
+ const type = getSerialization(element);
16489
16007
 
16490
- function serializeAsProperty(element) {
16491
- return serializeFormat(element) === 'property';
16008
+ return type !== SERIALIZE_PROPERTY && (type || null);
16492
16009
  }
16493
16010
 
16494
16011
  function capitalize(str) {
@@ -16504,12 +16021,20 @@
16504
16021
  return aliasNs.prefix + ':' + capitalize(aliasNs.localName);
16505
16022
  }
16506
16023
 
16024
+ /**
16025
+ * Un-prefix a potentially prefixed type name.
16026
+ *
16027
+ * @param {NsName} nameNs
16028
+ * @param {Object} [pkg]
16029
+ *
16030
+ * @return {string}
16031
+ */
16507
16032
  function prefixedToName(nameNs, pkg) {
16508
16033
 
16509
16034
  var name = nameNs.name,
16510
16035
  localName = nameNs.localName;
16511
16036
 
16512
- var typePrefix = pkg.xml && pkg.xml.typePrefix;
16037
+ var typePrefix = pkg && pkg.xml && pkg.xml.typePrefix;
16513
16038
 
16514
16039
  if (typePrefix && localName.indexOf(typePrefix) === 0) {
16515
16040
  return nameNs.prefix + ':' + localName.slice(typePrefix.length);
@@ -16518,12 +16043,19 @@
16518
16043
  }
16519
16044
  }
16520
16045
 
16521
- function normalizeXsiTypeName(name, model) {
16046
+ function normalizeTypeName(name, nsMap, model) {
16522
16047
 
16523
- var nameNs = parseName(name);
16524
- var pkg = model.getPackage(nameNs.prefix);
16048
+ // normalize against actual NS
16049
+ const nameNs = parseName(name, nsMap.xmlns);
16525
16050
 
16526
- return prefixedToName(nameNs, pkg);
16051
+ const normalizedName = `${ nsMap[nameNs.prefix] || nameNs.prefix }:${ nameNs.localName }`;
16052
+
16053
+ const normalizedNameNs = parseName(normalizedName);
16054
+
16055
+ // determine actual type name, based on package-defined prefix
16056
+ var pkg = model.getPackage(normalizedNameNs.prefix);
16057
+
16058
+ return prefixedToName(normalizedNameNs, pkg);
16527
16059
  }
16528
16060
 
16529
16061
  function error(message) {
@@ -16812,8 +16344,9 @@
16812
16344
  } else {
16813
16345
  if (prop) {
16814
16346
  value = coerceType(prop.type, value);
16815
- } else
16816
- if (name !== 'xmlns') {
16347
+ } else if (name === 'xmlns') {
16348
+ name = ':' + name;
16349
+ } else {
16817
16350
  propNameNs = parseName(name, descriptor.ns.prefix);
16818
16351
 
16819
16352
  // check whether attribute is defined in a well-known namespace
@@ -16846,26 +16379,27 @@
16846
16379
  descriptor = getModdleDescriptor(type);
16847
16380
 
16848
16381
  var propertyName = nameNs.name,
16849
- property = descriptor.propertiesByName[propertyName],
16850
- elementTypeName,
16851
- elementType;
16382
+ property = descriptor.propertiesByName[propertyName];
16852
16383
 
16853
16384
  // search for properties by name first
16854
16385
 
16855
16386
  if (property && !property.isAttr) {
16856
16387
 
16857
- if (serializeAsType(property)) {
16858
- elementTypeName = node.attributes[XSI_TYPE];
16388
+ const serializationType = getSerializationType(property);
16389
+
16390
+ if (serializationType) {
16391
+ const elementTypeName = node.attributes[serializationType];
16859
16392
 
16860
- // xsi type is optional, if it does not exists the
16393
+ // type is optional, if it does not exists the
16861
16394
  // default type is assumed
16862
16395
  if (elementTypeName) {
16863
16396
 
16397
+ // convert the prefix used to the mapped form, but also
16864
16398
  // take possible type prefixes from XML
16865
- // into account, i.e.: xsi:type="t{ActualType}"
16866
- elementTypeName = normalizeXsiTypeName(elementTypeName, model);
16399
+ // into account, i.e.: xsi:type="t{ActualType}",
16400
+ const normalizedTypeName = normalizeTypeName(elementTypeName, node.ns, model);
16867
16401
 
16868
- elementType = model.getType(elementTypeName);
16402
+ const elementType = model.getType(normalizedTypeName);
16869
16403
 
16870
16404
  return assign$1({}, property, {
16871
16405
  effectiveType: getModdleDescriptor(elementType).name
@@ -16880,8 +16414,8 @@
16880
16414
  var pkg = model.getPackage(nameNs.prefix);
16881
16415
 
16882
16416
  if (pkg) {
16883
- elementTypeName = aliasToName(nameNs, pkg);
16884
- elementType = model.getType(elementTypeName);
16417
+ const elementTypeName = aliasToName(nameNs, pkg);
16418
+ const elementType = model.getType(elementTypeName);
16885
16419
 
16886
16420
  // search for collection members later
16887
16421
  property = find(descriptor.properties, function(p) {
@@ -17303,9 +16837,12 @@
17303
16837
  uriMap[p.uri] = p.prefix;
17304
16838
 
17305
16839
  return uriMap;
17306
- }, {
17307
- 'http://www.w3.org/XML/1998/namespace': 'xml' // add default xml ns
17308
- });
16840
+ }, Object.entries(DEFAULT_NS_MAP).reduce(function(map, [ prefix, url ]) {
16841
+ map[url] = prefix;
16842
+
16843
+ return map;
16844
+ }, model.config && model.config.nsMap || {}));
16845
+
17309
16846
  parser
17310
16847
  .ns(uriMap)
17311
16848
  .on('openTag', function(obj, decodeStr, selfClosing, getContext) {
@@ -17406,75 +16943,82 @@
17406
16943
 
17407
16944
  function Namespaces(parent) {
17408
16945
 
17409
- var prefixMap = {};
17410
- var uriMap = {};
17411
- var used = {};
16946
+ this.prefixMap = {};
16947
+ this.uriMap = {};
16948
+ this.used = {};
17412
16949
 
17413
- var wellknown = [];
17414
- var custom = [];
16950
+ this.wellknown = [];
16951
+ this.custom = [];
16952
+ this.parent = parent;
17415
16953
 
17416
- // API
16954
+ this.defaultPrefixMap = parent && parent.defaultPrefixMap || {};
16955
+ }
17417
16956
 
17418
- this.byUri = function(uri) {
17419
- return uriMap[uri] || (
17420
- parent && parent.byUri(uri)
17421
- );
17422
- };
16957
+ Namespaces.prototype.mapDefaultPrefixes = function(defaultPrefixMap) {
16958
+ this.defaultPrefixMap = defaultPrefixMap;
16959
+ };
17423
16960
 
17424
- this.add = function(ns, isWellknown) {
16961
+ Namespaces.prototype.defaultUriByPrefix = function(prefix) {
16962
+ return this.defaultPrefixMap[prefix];
16963
+ };
17425
16964
 
17426
- uriMap[ns.uri] = ns;
16965
+ Namespaces.prototype.byUri = function(uri) {
16966
+ return this.uriMap[uri] || (
16967
+ this.parent && this.parent.byUri(uri)
16968
+ );
16969
+ };
17427
16970
 
17428
- if (isWellknown) {
17429
- wellknown.push(ns);
17430
- } else {
17431
- custom.push(ns);
17432
- }
16971
+ Namespaces.prototype.add = function(ns, isWellknown) {
17433
16972
 
17434
- this.mapPrefix(ns.prefix, ns.uri);
17435
- };
16973
+ this.uriMap[ns.uri] = ns;
17436
16974
 
17437
- this.uriByPrefix = function(prefix) {
17438
- return prefixMap[prefix || 'xmlns'];
17439
- };
16975
+ if (isWellknown) {
16976
+ this.wellknown.push(ns);
16977
+ } else {
16978
+ this.custom.push(ns);
16979
+ }
17440
16980
 
17441
- this.mapPrefix = function(prefix, uri) {
17442
- prefixMap[prefix || 'xmlns'] = uri;
17443
- };
16981
+ this.mapPrefix(ns.prefix, ns.uri);
16982
+ };
17444
16983
 
17445
- this.getNSKey = function(ns) {
17446
- return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
17447
- };
16984
+ Namespaces.prototype.uriByPrefix = function(prefix) {
16985
+ return this.prefixMap[prefix || 'xmlns'] || (
16986
+ this.parent && this.parent.uriByPrefix(prefix)
16987
+ );
16988
+ };
17448
16989
 
17449
- this.logUsed = function(ns) {
16990
+ Namespaces.prototype.mapPrefix = function(prefix, uri) {
16991
+ this.prefixMap[prefix || 'xmlns'] = uri;
16992
+ };
17450
16993
 
17451
- var uri = ns.uri;
17452
- var nsKey = this.getNSKey(ns);
16994
+ Namespaces.prototype.getNSKey = function(ns) {
16995
+ return (ns.prefix !== undefined) ? (ns.uri + '|' + ns.prefix) : ns.uri;
16996
+ };
17453
16997
 
17454
- used[nsKey] = this.byUri(uri);
16998
+ Namespaces.prototype.logUsed = function(ns) {
17455
16999
 
17456
- // Inform parent recursively about the usage of this NS
17457
- if (parent) {
17458
- parent.logUsed(ns);
17459
- }
17460
- };
17000
+ var uri = ns.uri;
17001
+ var nsKey = this.getNSKey(ns);
17461
17002
 
17462
- this.getUsed = function(ns) {
17003
+ this.used[nsKey] = this.byUri(uri);
17463
17004
 
17464
- function isUsed(ns) {
17465
- var nsKey = self.getNSKey(ns);
17005
+ // Inform parent recursively about the usage of this NS
17006
+ if (this.parent) {
17007
+ this.parent.logUsed(ns);
17008
+ }
17009
+ };
17466
17010
 
17467
- return used[nsKey];
17468
- }
17011
+ Namespaces.prototype.getUsed = function(ns) {
17469
17012
 
17470
- var self = this;
17013
+ var allNs = [].concat(this.wellknown, this.custom);
17471
17014
 
17472
- var allNs = [].concat(wellknown, custom);
17015
+ return allNs.filter(ns => {
17016
+ var nsKey = this.getNSKey(ns);
17473
17017
 
17474
- return allNs.filter(isUsed);
17475
- };
17018
+ return this.used[nsKey];
17019
+ });
17020
+ };
17476
17021
 
17477
- }
17478
17022
 
17479
17023
  function lower(string) {
17480
17024
  return string.charAt(0).toLowerCase() + string.slice(1);
@@ -17689,7 +17233,7 @@
17689
17233
  var isGeneric = elementDescriptor.isGeneric;
17690
17234
 
17691
17235
  if (isGeneric) {
17692
- otherAttrs = this.parseGeneric(element);
17236
+ otherAttrs = this.parseGenericNsAttributes(element);
17693
17237
  } else {
17694
17238
  otherAttrs = this.parseNsAttributes(element);
17695
17239
  }
@@ -17703,7 +17247,9 @@
17703
17247
  // compute tag name
17704
17248
  this.tagName = this.addTagName(this.ns);
17705
17249
 
17706
- if (!isGeneric) {
17250
+ if (isGeneric) {
17251
+ this.parseGenericContainments(element);
17252
+ } else {
17707
17253
  properties = getSerializableProperties(element);
17708
17254
 
17709
17255
  this.parseAttributes(filterAttributes(properties));
@@ -17766,35 +17312,29 @@
17766
17312
  }
17767
17313
  };
17768
17314
 
17769
- ElementSerializer.prototype.parseGeneric = function(element) {
17315
+ ElementSerializer.prototype.parseGenericNsAttributes = function(element) {
17770
17316
 
17771
- var self = this,
17772
- body = this.body;
17773
-
17774
- var attributes = [];
17775
-
17776
- forEach$1(element, function(val, key) {
17317
+ return Object.entries(element).filter(
17318
+ ([ key, value ]) => !key.startsWith('$') && this.parseNsAttribute(element, key, value)
17319
+ ).map(
17320
+ ([ key, value ]) => ({ name: key, value: value })
17321
+ );
17322
+ };
17777
17323
 
17778
- var nonNsAttr;
17324
+ ElementSerializer.prototype.parseGenericContainments = function(element) {
17325
+ var body = element.$body;
17779
17326
 
17780
- if (key === '$body') {
17781
- body.push(new BodySerializer().build({ type: 'String' }, val));
17782
- } else
17783
- if (key === '$children') {
17784
- forEach$1(val, function(child) {
17785
- body.push(new ElementSerializer(self).build(child));
17786
- });
17787
- } else
17788
- if (key.indexOf('$') !== 0) {
17789
- nonNsAttr = self.parseNsAttribute(element, key, val);
17327
+ if (body) {
17328
+ this.body.push(new BodySerializer().build({ type: 'String' }, body));
17329
+ }
17790
17330
 
17791
- if (nonNsAttr) {
17792
- attributes.push({ name: key, value: val });
17793
- }
17794
- }
17795
- });
17331
+ var children = element.$children;
17796
17332
 
17797
- return attributes;
17333
+ if (children) {
17334
+ forEach$1(children, child => {
17335
+ this.body.push(new ElementSerializer(this).build(child));
17336
+ });
17337
+ }
17798
17338
  };
17799
17339
 
17800
17340
  ElementSerializer.prototype.parseNsAttribute = function(element, name, value) {
@@ -17841,7 +17381,7 @@
17841
17381
  * @param {Object} element
17842
17382
  * @return {Array<Object>}
17843
17383
  */
17844
- ElementSerializer.prototype.parseNsAttributes = function(element, attrs) {
17384
+ ElementSerializer.prototype.parseNsAttributes = function(element) {
17845
17385
  var self = this;
17846
17386
 
17847
17387
  var genericAttrs = element.$attrs;
@@ -17869,21 +17409,16 @@
17869
17409
 
17870
17410
  forEach$1(attributes, function(attr) {
17871
17411
 
17872
- // do not serialize xsi:type attribute
17873
- // it is set manually based on the actual implementation type
17874
- if (attr.name === XSI_TYPE) {
17875
- return;
17876
- }
17877
-
17878
17412
  try {
17879
17413
  self.addAttribute(self.nsAttributeName(attr.name), attr.value);
17880
17414
  } catch (e) {
17881
- /* global console */
17882
17415
 
17883
- console.warn(
17884
- 'missing namespace information for ',
17885
- attr.name, '=', attr.value, 'on', element,
17886
- e);
17416
+ // eslint-disable-next-line no-undef
17417
+ typeof console !== 'undefined' && console.warn(
17418
+ `missing namespace information for <${
17419
+ attr.name
17420
+ }=${ attr.value }> on`, element, e
17421
+ );
17887
17422
  }
17888
17423
  });
17889
17424
  };
@@ -17905,13 +17440,11 @@
17905
17440
 
17906
17441
  if (p.isBody) {
17907
17442
  body.push(new BodySerializer().build(p, value[0]));
17908
- } else
17909
- if (isSimple(p.type)) {
17443
+ } else if (isSimple(p.type)) {
17910
17444
  forEach$1(value, function(v) {
17911
17445
  body.push(new ValueSerializer(self.addTagName(self.nsPropertyTagName(p))).build(p, v));
17912
17446
  });
17913
- } else
17914
- if (isReference) {
17447
+ } else if (isReference) {
17915
17448
  forEach$1(value, function(v) {
17916
17449
  body.push(new ReferenceSerializer(self.addTagName(self.nsPropertyTagName(p))).build(v));
17917
17450
  });
@@ -17919,17 +17452,17 @@
17919
17452
 
17920
17453
  // allow serialization via type
17921
17454
  // rather than element name
17922
- var asType = serializeAsType(p),
17923
- asProperty = serializeAsProperty(p);
17455
+ var serialization = getSerialization(p);
17924
17456
 
17925
17457
  forEach$1(value, function(v) {
17926
17458
  var serializer;
17927
17459
 
17928
- if (asType) {
17929
- serializer = new TypeSerializer(self, p);
17930
- } else
17931
- if (asProperty) {
17932
- serializer = new ElementSerializer(self, p);
17460
+ if (serialization) {
17461
+ if (serialization === SERIALIZE_PROPERTY) {
17462
+ serializer = new ElementSerializer(self, p);
17463
+ } else {
17464
+ serializer = new TypeSerializer(self, p, serialization);
17465
+ }
17933
17466
  } else {
17934
17467
  serializer = new ElementSerializer(self);
17935
17468
  }
@@ -17977,9 +17510,7 @@
17977
17510
  };
17978
17511
 
17979
17512
  ElementSerializer.prototype.logNamespaceUsed = function(ns, local) {
17980
- var element = this.element,
17981
- model = element.$model,
17982
- namespaces = this.getNamespaces(local);
17513
+ var namespaces = this.getNamespaces(local);
17983
17514
 
17984
17515
  // ns may be
17985
17516
  //
@@ -17997,7 +17528,7 @@
17997
17528
  return { localName: ns.localName };
17998
17529
  }
17999
17530
 
18000
- wellknownUri = DEFAULT_NS_MAP[prefix] || model && (model.getPackage(prefix) || {}).uri;
17531
+ wellknownUri = namespaces.defaultUriByPrefix(prefix);
18001
17532
 
18002
17533
  uri = uri || wellknownUri || namespaces.uriByPrefix(prefix);
18003
17534
 
@@ -18007,6 +17538,11 @@
18007
17538
 
18008
17539
  ns = namespaces.byUri(uri);
18009
17540
 
17541
+ // register new default prefix <xmlns> in local scope
17542
+ if (!ns && !prefix) {
17543
+ ns = this.logNamespace({ uri }, wellknownUri === uri, true);
17544
+ }
17545
+
18010
17546
  if (!ns) {
18011
17547
  newPrefix = prefix;
18012
17548
  idx = 1;
@@ -18038,8 +17574,7 @@
18038
17574
 
18039
17575
  if (!p.isMany) {
18040
17576
  value = value.id;
18041
- }
18042
- else {
17577
+ } else {
18043
17578
  var values = [];
18044
17579
  forEach$1(value, function(v) {
18045
17580
  values.push(v.id);
@@ -18143,20 +17678,25 @@
18143
17678
  /**
18144
17679
  * A serializer for types that handles serialization of data types
18145
17680
  */
18146
- function TypeSerializer(parent, propertyDescriptor) {
17681
+ function TypeSerializer(parent, propertyDescriptor, serialization) {
18147
17682
  ElementSerializer.call(this, parent, propertyDescriptor);
17683
+
17684
+ this.serialization = serialization;
18148
17685
  }
18149
17686
 
18150
17687
  inherits(TypeSerializer, ElementSerializer);
18151
17688
 
18152
17689
  TypeSerializer.prototype.parseNsAttributes = function(element) {
18153
17690
 
18154
- // extracted attributes
18155
- var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element);
17691
+ // extracted attributes with serialization attribute
17692
+ // <type=typeName> stripped; it may be later
17693
+ var attributes = ElementSerializer.prototype.parseNsAttributes.call(this, element).filter(
17694
+ attr => attr.name !== this.serialization
17695
+ );
18156
17696
 
18157
17697
  var descriptor = element.$descriptor;
18158
17698
 
18159
- // only serialize xsi:type if necessary
17699
+ // only serialize <type=typeName> if necessary
18160
17700
  if (descriptor.name === this.propertyDescriptor.type) {
18161
17701
  return attributes;
18162
17702
  }
@@ -18171,7 +17711,7 @@
18171
17711
  typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
18172
17712
 
18173
17713
  this.addAttribute(
18174
- this.nsAttributeName(XSI_TYPE),
17714
+ this.nsAttributeName(this.serialization),
18175
17715
  (typeNs.prefix ? typeNs.prefix + ':' : '') + typePrefix + descriptor.ns.localName
18176
17716
  );
18177
17717
 
@@ -18244,7 +17784,13 @@
18244
17784
  formatingWriter.append(XML_PREAMBLE);
18245
17785
  }
18246
17786
 
18247
- new ElementSerializer().build(tree).serializeTo(formatingWriter);
17787
+ var serializer = new ElementSerializer();
17788
+
17789
+ var model = tree.$model;
17790
+
17791
+ serializer.getNamespaces().mapDefaultPrefixes(getDefaultPrefixMappings(model));
17792
+
17793
+ serializer.build(tree).serializeTo(formatingWriter);
18248
17794
 
18249
17795
  if (!writer) {
18250
17796
  return internalWriter.value;
@@ -18256,6 +17802,39 @@
18256
17802
  };
18257
17803
  }
18258
17804
 
17805
+
17806
+ // helpers ///////////
17807
+
17808
+ /**
17809
+ * @param {Moddle} model
17810
+ *
17811
+ * @return { Record<string, string> } map from prefix to URI
17812
+ */
17813
+ function getDefaultPrefixMappings(model) {
17814
+
17815
+ const nsMap = model.config && model.config.nsMap || {};
17816
+
17817
+ const prefixMap = {};
17818
+
17819
+ // { prefix -> uri }
17820
+ for (const prefix in DEFAULT_NS_MAP) {
17821
+ prefixMap[prefix] = DEFAULT_NS_MAP[prefix];
17822
+ }
17823
+
17824
+ // { uri -> prefix }
17825
+ for (const uri in nsMap) {
17826
+ const prefix = nsMap[uri];
17827
+
17828
+ prefixMap[prefix] = uri;
17829
+ }
17830
+
17831
+ for (const pkg of model.getPackages()) {
17832
+ prefixMap[pkg.prefix] = pkg.uri;
17833
+ }
17834
+
17835
+ return prefixMap;
17836
+ }
17837
+
18259
17838
  /**
18260
17839
  * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
18261
17840
  *
@@ -21982,7 +21561,7 @@
21982
21561
  associations: associations
21983
21562
  };
21984
21563
 
21985
- var packages = {
21564
+ const packages = {
21986
21565
  bpmn: BpmnPackage,
21987
21566
  bpmndi: BpmnDiPackage,
21988
21567
  dc: DcPackage,
@@ -21991,8 +21570,8 @@
21991
21570
  color: BpmnInColorPackage
21992
21571
  };
21993
21572
 
21994
- function simple(additionalPackages, options) {
21995
- var pks = assign$1({}, packages, additionalPackages);
21573
+ function SimpleBpmnModdle(additionalPackages, options) {
21574
+ const pks = assign$1({}, packages, additionalPackages);
21996
21575
 
21997
21576
  return new BpmnModdle(pks, options);
21998
21577
  }
@@ -23483,7 +23062,7 @@
23483
23062
  BaseViewer.prototype._createModdle = function(options) {
23484
23063
  const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
23485
23064
 
23486
- return new simple(moddleOptions);
23065
+ return new SimpleBpmnModdle(moddleOptions);
23487
23066
  };
23488
23067
 
23489
23068
  BaseViewer.prototype._modules = [];
@@ -23645,7 +23224,6 @@
23645
23224
  Viewer.prototype._modules = [
23646
23225
  CoreModule$1,
23647
23226
  DrilldownModdule,
23648
- OutlineModule,
23649
23227
  OverlaysModule,
23650
23228
  SelectionModule,
23651
23229
  TranslateModule