bpmn-js 8.7.3 → 8.8.3
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.
- package/CHANGELOG.md +22 -1
- package/dist/assets/diagram-js.css +2 -0
- package/dist/bpmn-modeler.development.js +407 -127
- package/dist/bpmn-modeler.production.min.js +8 -8
- package/dist/bpmn-navigated-viewer.development.js +326 -62
- package/dist/bpmn-navigated-viewer.production.min.js +5 -5
- package/dist/bpmn-viewer.development.js +299 -58
- package/dist/bpmn-viewer.production.min.js +5 -5
- package/lib/draw/PathMap.js +2 -2
- package/lib/features/copy-paste/ModdleCopy.js +19 -2
- package/lib/features/modeling/behavior/DropOnFlowBehavior.js +2 -2
- package/lib/features/modeling/behavior/ResizeBehavior.js +129 -3
- package/lib/features/modeling/behavior/util/ResizeUtil.js +1 -132
- package/package.json +2 -2
- package/test/util/MockEvents.js +10 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* bpmn-js - bpmn-navigated-viewer v8.
|
|
2
|
+
* bpmn-js - bpmn-navigated-viewer v8.8.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2014-present, camunda Services GmbH
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Source Code: https://github.com/bpmn-io/bpmn-js
|
|
10
10
|
*
|
|
11
|
-
* Date: 2021-
|
|
11
|
+
* Date: 2021-12-03
|
|
12
12
|
*/
|
|
13
13
|
(function (global, factory) {
|
|
14
14
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -389,13 +389,14 @@
|
|
|
389
389
|
eventBus.on([ 'render.shape', 'render.connection' ], renderPriority, function(evt, context) {
|
|
390
390
|
var type = evt.type,
|
|
391
391
|
element = context.element,
|
|
392
|
-
visuals = context.gfx
|
|
392
|
+
visuals = context.gfx,
|
|
393
|
+
attrs = context.attrs;
|
|
393
394
|
|
|
394
395
|
if (self.canRender(element)) {
|
|
395
396
|
if (type === 'render.shape') {
|
|
396
|
-
return self.drawShape(visuals, element);
|
|
397
|
+
return self.drawShape(visuals, element, attrs);
|
|
397
398
|
} else {
|
|
398
|
-
return self.drawConnection(visuals, element);
|
|
399
|
+
return self.drawConnection(visuals, element, attrs);
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
});
|
|
@@ -4978,8 +4979,8 @@
|
|
|
4978
4979
|
|
|
4979
4980
|
// helpers //////////////////////
|
|
4980
4981
|
|
|
4981
|
-
// copied from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
|
|
4982
|
-
var tokenRegex = /\{([^}]+)\}/g,
|
|
4982
|
+
// copied and adjusted from https://github.com/adobe-webplatform/Snap.svg/blob/master/src/svg.js
|
|
4983
|
+
var tokenRegex = /\{([^{}]+)\}/g,
|
|
4983
4984
|
objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties
|
|
4984
4985
|
|
|
4985
4986
|
function replacer(all, key, obj) {
|
|
@@ -6296,9 +6297,10 @@
|
|
|
6296
6297
|
*
|
|
6297
6298
|
* @param {EventBus} eventBus the event bus
|
|
6298
6299
|
*/
|
|
6299
|
-
function Selection(eventBus) {
|
|
6300
|
+
function Selection(eventBus, canvas) {
|
|
6300
6301
|
|
|
6301
6302
|
this._eventBus = eventBus;
|
|
6303
|
+
this._canvas = canvas;
|
|
6302
6304
|
|
|
6303
6305
|
this._selectedElements = [];
|
|
6304
6306
|
|
|
@@ -6309,12 +6311,12 @@
|
|
|
6309
6311
|
self.deselect(element);
|
|
6310
6312
|
});
|
|
6311
6313
|
|
|
6312
|
-
eventBus.on([ 'diagram.clear' ], function(e) {
|
|
6314
|
+
eventBus.on([ 'diagram.clear', 'plane.set' ], function(e) {
|
|
6313
6315
|
self.select(null);
|
|
6314
6316
|
});
|
|
6315
6317
|
}
|
|
6316
6318
|
|
|
6317
|
-
Selection.$inject = [ 'eventBus' ];
|
|
6319
|
+
Selection.$inject = [ 'eventBus', 'canvas' ];
|
|
6318
6320
|
|
|
6319
6321
|
|
|
6320
6322
|
Selection.prototype.deselect = function(element) {
|
|
@@ -6360,6 +6362,14 @@
|
|
|
6360
6362
|
elements = elements ? [ elements ] : [];
|
|
6361
6363
|
}
|
|
6362
6364
|
|
|
6365
|
+
var canvas = this._canvas;
|
|
6366
|
+
|
|
6367
|
+
elements = elements.filter(function(element) {
|
|
6368
|
+
var plane = canvas.findPlane(element);
|
|
6369
|
+
|
|
6370
|
+
return plane === canvas.getActivePlane();
|
|
6371
|
+
});
|
|
6372
|
+
|
|
6363
6373
|
// selection may be cleared by passing an empty array or null
|
|
6364
6374
|
// to the method
|
|
6365
6375
|
if (add) {
|
|
@@ -7028,6 +7038,13 @@
|
|
|
7028
7038
|
classes(htmlContainer).add('djs-overlay-' + overlay.type);
|
|
7029
7039
|
}
|
|
7030
7040
|
|
|
7041
|
+
var plane = this._canvas.findPlane(element);
|
|
7042
|
+
var activePlane = this._canvas.getActivePlane();
|
|
7043
|
+
overlay.plane = plane;
|
|
7044
|
+
if (plane !== activePlane) {
|
|
7045
|
+
setVisible(htmlContainer, false);
|
|
7046
|
+
}
|
|
7047
|
+
|
|
7031
7048
|
overlay.htmlContainer = htmlContainer;
|
|
7032
7049
|
|
|
7033
7050
|
overlayContainer.overlays.push(overlay);
|
|
@@ -7042,22 +7059,26 @@
|
|
|
7042
7059
|
|
|
7043
7060
|
Overlays.prototype._updateOverlayVisibilty = function(overlay, viewbox) {
|
|
7044
7061
|
var show = overlay.show,
|
|
7062
|
+
plane = overlay.plane,
|
|
7045
7063
|
minZoom = show && show.minZoom,
|
|
7046
7064
|
maxZoom = show && show.maxZoom,
|
|
7047
7065
|
htmlContainer = overlay.htmlContainer,
|
|
7066
|
+
activePlane = this._canvas.getActivePlane(),
|
|
7048
7067
|
visible = true;
|
|
7049
7068
|
|
|
7050
|
-
if (
|
|
7069
|
+
if (plane !== activePlane) {
|
|
7070
|
+
visible = false;
|
|
7071
|
+
} else if (show) {
|
|
7051
7072
|
if (
|
|
7052
7073
|
(isDefined(minZoom) && minZoom > viewbox.scale) ||
|
|
7053
7074
|
(isDefined(maxZoom) && maxZoom < viewbox.scale)
|
|
7054
7075
|
) {
|
|
7055
7076
|
visible = false;
|
|
7056
7077
|
}
|
|
7057
|
-
|
|
7058
|
-
setVisible(htmlContainer, visible);
|
|
7059
7078
|
}
|
|
7060
7079
|
|
|
7080
|
+
setVisible(htmlContainer, visible);
|
|
7081
|
+
|
|
7061
7082
|
this._updateOverlayScale(overlay, viewbox);
|
|
7062
7083
|
};
|
|
7063
7084
|
|
|
@@ -7181,6 +7202,12 @@
|
|
|
7181
7202
|
});
|
|
7182
7203
|
|
|
7183
7204
|
|
|
7205
|
+
eventBus.on('plane.set', function(e) {
|
|
7206
|
+
forEach(self._overlays, function(el) {
|
|
7207
|
+
setVisible(el.htmlContainer, el.plane === e.plane);
|
|
7208
|
+
});
|
|
7209
|
+
});
|
|
7210
|
+
|
|
7184
7211
|
// clear overlays with diagram
|
|
7185
7212
|
|
|
7186
7213
|
eventBus.on('diagram.clear', this.clear, this);
|
|
@@ -7584,7 +7611,7 @@
|
|
|
7584
7611
|
return true;
|
|
7585
7612
|
};
|
|
7586
7613
|
|
|
7587
|
-
DefaultRenderer.prototype.drawShape = function drawShape(visuals, element) {
|
|
7614
|
+
DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
|
|
7588
7615
|
var rect = create$1('rect');
|
|
7589
7616
|
|
|
7590
7617
|
attr$1(rect, {
|
|
@@ -7595,9 +7622,9 @@
|
|
|
7595
7622
|
});
|
|
7596
7623
|
|
|
7597
7624
|
if (isFrameElement(element)) {
|
|
7598
|
-
attr$1(rect, this.FRAME_STYLE);
|
|
7625
|
+
attr$1(rect, assign({}, this.FRAME_STYLE, attrs || {}));
|
|
7599
7626
|
} else {
|
|
7600
|
-
attr$1(rect, this.SHAPE_STYLE);
|
|
7627
|
+
attr$1(rect, assign({}, this.SHAPE_STYLE, attrs || {}));
|
|
7601
7628
|
}
|
|
7602
7629
|
|
|
7603
7630
|
append(visuals, rect);
|
|
@@ -7605,9 +7632,9 @@
|
|
|
7605
7632
|
return rect;
|
|
7606
7633
|
};
|
|
7607
7634
|
|
|
7608
|
-
DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection) {
|
|
7635
|
+
DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
|
|
7609
7636
|
|
|
7610
|
-
var line = createLine(connection.waypoints, this.CONNECTION_STYLE);
|
|
7637
|
+
var line = createLine(connection.waypoints, assign({}, this.CONNECTION_STYLE, attrs || {}));
|
|
7611
7638
|
append(visuals, line);
|
|
7612
7639
|
|
|
7613
7640
|
return line;
|
|
@@ -7806,6 +7833,14 @@
|
|
|
7806
7833
|
return isNumber(number) ? number + 'px' : number;
|
|
7807
7834
|
}
|
|
7808
7835
|
|
|
7836
|
+
function findRoot(element) {
|
|
7837
|
+
while (element.parent) {
|
|
7838
|
+
element = element.parent;
|
|
7839
|
+
}
|
|
7840
|
+
|
|
7841
|
+
return element;
|
|
7842
|
+
}
|
|
7843
|
+
|
|
7809
7844
|
/**
|
|
7810
7845
|
* Creates a HTML container element for a SVG element with
|
|
7811
7846
|
* the given configuration
|
|
@@ -7851,6 +7886,11 @@
|
|
|
7851
7886
|
}
|
|
7852
7887
|
|
|
7853
7888
|
var BASE_LAYER = 'base';
|
|
7889
|
+
var HIDDEN_MARKER = 'djs-element-hidden';
|
|
7890
|
+
|
|
7891
|
+
// render plane contents behind utility layers
|
|
7892
|
+
var PLANE_LAYER_INDEX = 0;
|
|
7893
|
+
var UTILITY_LAYER_INDEX = 1;
|
|
7854
7894
|
|
|
7855
7895
|
|
|
7856
7896
|
var REQUIRED_MODEL_ATTRS = {
|
|
@@ -7887,23 +7927,23 @@
|
|
|
7887
7927
|
'elementRegistry'
|
|
7888
7928
|
];
|
|
7889
7929
|
|
|
7930
|
+
/**
|
|
7931
|
+
* Creates a <svg> element that is wrapped into a <div>.
|
|
7932
|
+
* This way we are always able to correctly figure out the size of the svg element
|
|
7933
|
+
* by querying the parent node.
|
|
7934
|
+
|
|
7935
|
+
* (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
|
|
7890
7936
|
|
|
7937
|
+
* <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
|
|
7938
|
+
* <svg width="100%" height="100%">
|
|
7939
|
+
* ...
|
|
7940
|
+
* </svg>
|
|
7941
|
+
* </div>
|
|
7942
|
+
*/
|
|
7891
7943
|
Canvas.prototype._init = function(config) {
|
|
7892
7944
|
|
|
7893
7945
|
var eventBus = this._eventBus;
|
|
7894
7946
|
|
|
7895
|
-
// Creates a <svg> element that is wrapped into a <div>.
|
|
7896
|
-
// This way we are always able to correctly figure out the size of the svg element
|
|
7897
|
-
// by querying the parent node.
|
|
7898
|
-
//
|
|
7899
|
-
// (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
|
|
7900
|
-
//
|
|
7901
|
-
// <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
|
|
7902
|
-
// <svg width="100%" height="100%">
|
|
7903
|
-
// ...
|
|
7904
|
-
// </svg>
|
|
7905
|
-
// </div>
|
|
7906
|
-
|
|
7907
7947
|
// html container
|
|
7908
7948
|
var container = this._container = createContainer(config);
|
|
7909
7949
|
|
|
@@ -7915,6 +7955,7 @@
|
|
|
7915
7955
|
var viewport = this._viewport = createGroup(svg, 'viewport');
|
|
7916
7956
|
|
|
7917
7957
|
this._layers = {};
|
|
7958
|
+
this._planes = {};
|
|
7918
7959
|
|
|
7919
7960
|
// debounce canvas.viewbox.changed events
|
|
7920
7961
|
// for smoother diagram interaction
|
|
@@ -7949,7 +7990,8 @@
|
|
|
7949
7990
|
'connection.added',
|
|
7950
7991
|
'shape.removed',
|
|
7951
7992
|
'connection.removed',
|
|
7952
|
-
'elements.changed'
|
|
7993
|
+
'elements.changed',
|
|
7994
|
+
'plane.set'
|
|
7953
7995
|
], function() {
|
|
7954
7996
|
delete this._cachedViewbox;
|
|
7955
7997
|
}, this);
|
|
@@ -7973,7 +8015,8 @@
|
|
|
7973
8015
|
delete this._svg;
|
|
7974
8016
|
delete this._container;
|
|
7975
8017
|
delete this._layers;
|
|
7976
|
-
delete this.
|
|
8018
|
+
delete this._planes;
|
|
8019
|
+
delete this._activePlane;
|
|
7977
8020
|
delete this._viewport;
|
|
7978
8021
|
};
|
|
7979
8022
|
|
|
@@ -7988,12 +8031,16 @@
|
|
|
7988
8031
|
var type = getType(element);
|
|
7989
8032
|
|
|
7990
8033
|
if (type === 'root') {
|
|
7991
|
-
self.
|
|
8034
|
+
self.setRootElementForPlane(null, self.findPlane(element), true);
|
|
7992
8035
|
} else {
|
|
7993
8036
|
self._removeElement(element, type);
|
|
7994
8037
|
}
|
|
7995
8038
|
});
|
|
7996
8039
|
|
|
8040
|
+
// remove all planes
|
|
8041
|
+
this._activePlane = null;
|
|
8042
|
+
this._planes = {};
|
|
8043
|
+
|
|
7997
8044
|
// force recomputation of view box
|
|
7998
8045
|
delete this._cachedViewbox;
|
|
7999
8046
|
};
|
|
@@ -8005,7 +8052,7 @@
|
|
|
8005
8052
|
* @returns {SVGElement}
|
|
8006
8053
|
*/
|
|
8007
8054
|
Canvas.prototype.getDefaultLayer = function() {
|
|
8008
|
-
return this.getLayer(BASE_LAYER,
|
|
8055
|
+
return this.getLayer(BASE_LAYER, PLANE_LAYER_INDEX);
|
|
8009
8056
|
};
|
|
8010
8057
|
|
|
8011
8058
|
/**
|
|
@@ -8054,8 +8101,8 @@
|
|
|
8054
8101
|
*/
|
|
8055
8102
|
Canvas.prototype._createLayer = function(name, index) {
|
|
8056
8103
|
|
|
8057
|
-
if (
|
|
8058
|
-
index =
|
|
8104
|
+
if (typeof index === 'undefined') {
|
|
8105
|
+
index = UTILITY_LAYER_INDEX;
|
|
8059
8106
|
}
|
|
8060
8107
|
|
|
8061
8108
|
var childIndex = reduce(this._layers, function(childIndex, layer) {
|
|
@@ -8073,6 +8120,140 @@
|
|
|
8073
8120
|
|
|
8074
8121
|
};
|
|
8075
8122
|
|
|
8123
|
+
/**
|
|
8124
|
+
* Returns a plane that is used to draw elements on it.
|
|
8125
|
+
*
|
|
8126
|
+
* @param {string} name
|
|
8127
|
+
*
|
|
8128
|
+
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8129
|
+
*/
|
|
8130
|
+
Canvas.prototype.getPlane = function(name) {
|
|
8131
|
+
if (!name) {
|
|
8132
|
+
throw new Error('must specify a name');
|
|
8133
|
+
}
|
|
8134
|
+
|
|
8135
|
+
return this._planes[name];
|
|
8136
|
+
};
|
|
8137
|
+
|
|
8138
|
+
/**
|
|
8139
|
+
* Creates a plane that is used to draw elements on it. If no
|
|
8140
|
+
* root element is provided, an implicit root will be used.
|
|
8141
|
+
*
|
|
8142
|
+
* @param {string} name
|
|
8143
|
+
* @param {Object|djs.model.Root} [rootElement] optional root element
|
|
8144
|
+
*
|
|
8145
|
+
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8146
|
+
*/
|
|
8147
|
+
Canvas.prototype.createPlane = function(name, rootElement) {
|
|
8148
|
+
if (!name) {
|
|
8149
|
+
throw new Error('must specify a name');
|
|
8150
|
+
}
|
|
8151
|
+
|
|
8152
|
+
if (this._planes[name]) {
|
|
8153
|
+
throw new Error('plane ' + name + ' already exists');
|
|
8154
|
+
}
|
|
8155
|
+
|
|
8156
|
+
if (!rootElement) {
|
|
8157
|
+
rootElement = {
|
|
8158
|
+
id: '__implicitroot' + name,
|
|
8159
|
+
children: [],
|
|
8160
|
+
isImplicit: true
|
|
8161
|
+
};
|
|
8162
|
+
}
|
|
8163
|
+
|
|
8164
|
+
var svgLayer = this.getLayer(name, PLANE_LAYER_INDEX);
|
|
8165
|
+
classes$1(svgLayer).add(HIDDEN_MARKER);
|
|
8166
|
+
|
|
8167
|
+
var plane = this._planes[name] = {
|
|
8168
|
+
layer: svgLayer,
|
|
8169
|
+
name: name,
|
|
8170
|
+
rootElement: null
|
|
8171
|
+
};
|
|
8172
|
+
|
|
8173
|
+
this.setRootElementForPlane(rootElement, plane);
|
|
8174
|
+
|
|
8175
|
+
return plane;
|
|
8176
|
+
};
|
|
8177
|
+
|
|
8178
|
+
/**
|
|
8179
|
+
* Sets the active plane and hides the previously active plane.
|
|
8180
|
+
*
|
|
8181
|
+
* @param {string|Object} plane
|
|
8182
|
+
*
|
|
8183
|
+
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8184
|
+
*/
|
|
8185
|
+
Canvas.prototype.setActivePlane = function(plane) {
|
|
8186
|
+
if (!plane) {
|
|
8187
|
+
throw new Error('must specify a plane');
|
|
8188
|
+
}
|
|
8189
|
+
|
|
8190
|
+
if (typeof plane === 'string') {
|
|
8191
|
+
plane = this.getPlane(plane);
|
|
8192
|
+
}
|
|
8193
|
+
|
|
8194
|
+
// hide previous Plane
|
|
8195
|
+
if (this._activePlane) {
|
|
8196
|
+
classes$1(this._activePlane.layer).add(HIDDEN_MARKER);
|
|
8197
|
+
}
|
|
8198
|
+
|
|
8199
|
+
this._activePlane = plane;
|
|
8200
|
+
|
|
8201
|
+
// show current Plane
|
|
8202
|
+
classes$1(plane.layer).remove(HIDDEN_MARKER);
|
|
8203
|
+
|
|
8204
|
+
if (plane.rootElement) {
|
|
8205
|
+
this._elementRegistry.updateGraphics(plane.rootElement, this._svg, true);
|
|
8206
|
+
}
|
|
8207
|
+
|
|
8208
|
+
this._eventBus.fire('plane.set', { plane: plane });
|
|
8209
|
+
|
|
8210
|
+
return plane;
|
|
8211
|
+
};
|
|
8212
|
+
|
|
8213
|
+
/**
|
|
8214
|
+
* Returns the currently active layer
|
|
8215
|
+
*
|
|
8216
|
+
* @returns {SVGElement}
|
|
8217
|
+
*/
|
|
8218
|
+
|
|
8219
|
+
Canvas.prototype.getActiveLayer = function() {
|
|
8220
|
+
return this.getActivePlane().layer;
|
|
8221
|
+
};
|
|
8222
|
+
|
|
8223
|
+
/**
|
|
8224
|
+
* Returns the currently active plane.
|
|
8225
|
+
*
|
|
8226
|
+
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8227
|
+
*/
|
|
8228
|
+
Canvas.prototype.getActivePlane = function() {
|
|
8229
|
+
var plane = this._activePlane;
|
|
8230
|
+
if (!plane) {
|
|
8231
|
+
plane = this.createPlane(BASE_LAYER);
|
|
8232
|
+
this.setActivePlane(BASE_LAYER);
|
|
8233
|
+
}
|
|
8234
|
+
|
|
8235
|
+
return plane;
|
|
8236
|
+
};
|
|
8237
|
+
|
|
8238
|
+
/**
|
|
8239
|
+
* Returns the plane which contains the given element.
|
|
8240
|
+
*
|
|
8241
|
+
* @param {string|djs.model.Base} element
|
|
8242
|
+
*
|
|
8243
|
+
* @return {Object} plane descriptor with { layer, rootElement, name }
|
|
8244
|
+
*/
|
|
8245
|
+
Canvas.prototype.findPlane = function(element) {
|
|
8246
|
+
if (typeof element === 'string') {
|
|
8247
|
+
element = this._elementRegistry.get(element);
|
|
8248
|
+
}
|
|
8249
|
+
|
|
8250
|
+
var root = findRoot(element);
|
|
8251
|
+
|
|
8252
|
+
return find(this._planes, function(plane) {
|
|
8253
|
+
return plane.rootElement === root;
|
|
8254
|
+
});
|
|
8255
|
+
};
|
|
8256
|
+
|
|
8076
8257
|
/**
|
|
8077
8258
|
* Returns the html element that encloses the
|
|
8078
8259
|
* drawing canvas.
|
|
@@ -8194,11 +8375,9 @@
|
|
|
8194
8375
|
};
|
|
8195
8376
|
|
|
8196
8377
|
Canvas.prototype.getRootElement = function() {
|
|
8197
|
-
|
|
8198
|
-
this.setRootElement({ id: '__implicitroot', children: [] });
|
|
8199
|
-
}
|
|
8378
|
+
var plane = this.getActivePlane();
|
|
8200
8379
|
|
|
8201
|
-
return
|
|
8380
|
+
return plane.rootElement;
|
|
8202
8381
|
};
|
|
8203
8382
|
|
|
8204
8383
|
|
|
@@ -8215,12 +8394,41 @@
|
|
|
8215
8394
|
* @return {Object|djs.model.Root} new root element
|
|
8216
8395
|
*/
|
|
8217
8396
|
Canvas.prototype.setRootElement = function(element, override) {
|
|
8397
|
+
var activePlane = this._activePlane;
|
|
8398
|
+
|
|
8399
|
+
if (activePlane) {
|
|
8400
|
+
return this.setRootElementForPlane(element, activePlane, override);
|
|
8401
|
+
} else {
|
|
8402
|
+
var basePlane = this.createPlane(BASE_LAYER, element);
|
|
8403
|
+
|
|
8404
|
+
this.setActivePlane(basePlane);
|
|
8405
|
+
|
|
8406
|
+
return basePlane.rootElement;
|
|
8407
|
+
}
|
|
8408
|
+
};
|
|
8409
|
+
|
|
8410
|
+
|
|
8411
|
+
/**
|
|
8412
|
+
* Sets a given element as the new root element for the canvas
|
|
8413
|
+
* and returns the new root element.
|
|
8414
|
+
*
|
|
8415
|
+
* @param {Object|djs.model.Root} element
|
|
8416
|
+
* @param {Object|djs.model.Root} plane
|
|
8417
|
+
* @param {boolean} [override] whether to override the current root element, if any
|
|
8418
|
+
*
|
|
8419
|
+
* @return {Object|djs.model.Root} new root element
|
|
8420
|
+
*/
|
|
8421
|
+
Canvas.prototype.setRootElementForPlane = function(element, plane, override) {
|
|
8422
|
+
|
|
8423
|
+
if (typeof plane === 'string') {
|
|
8424
|
+
plane = this.getPlane(plane);
|
|
8425
|
+
}
|
|
8218
8426
|
|
|
8219
8427
|
if (element) {
|
|
8220
8428
|
this._ensureValid('root', element);
|
|
8221
8429
|
}
|
|
8222
8430
|
|
|
8223
|
-
var currentRoot =
|
|
8431
|
+
var currentRoot = plane.rootElement,
|
|
8224
8432
|
elementRegistry = this._elementRegistry,
|
|
8225
8433
|
eventBus = this._eventBus;
|
|
8226
8434
|
|
|
@@ -8237,23 +8445,26 @@
|
|
|
8237
8445
|
}
|
|
8238
8446
|
|
|
8239
8447
|
if (element) {
|
|
8240
|
-
var gfx =
|
|
8448
|
+
var gfx = plane.layer;
|
|
8241
8449
|
|
|
8242
8450
|
// resemble element add event sequence
|
|
8243
8451
|
eventBus.fire('root.add', { element: element });
|
|
8244
8452
|
|
|
8245
|
-
elementRegistry.add(element, gfx
|
|
8453
|
+
elementRegistry.add(element, gfx);
|
|
8246
8454
|
|
|
8247
8455
|
eventBus.fire('root.added', { element: element, gfx: gfx });
|
|
8456
|
+
|
|
8457
|
+
// associate SVG with root element when active
|
|
8458
|
+
if (plane === this._activePlane) {
|
|
8459
|
+
this._elementRegistry.updateGraphics(element, this._svg, true);
|
|
8460
|
+
}
|
|
8248
8461
|
}
|
|
8249
8462
|
|
|
8250
|
-
|
|
8463
|
+
plane.rootElement = element;
|
|
8251
8464
|
|
|
8252
8465
|
return element;
|
|
8253
8466
|
};
|
|
8254
8467
|
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
8468
|
// add functionality //////////////////////
|
|
8258
8469
|
|
|
8259
8470
|
Canvas.prototype._ensureValid = function(type, element) {
|
|
@@ -8559,9 +8770,10 @@
|
|
|
8559
8770
|
if (!box) {
|
|
8560
8771
|
|
|
8561
8772
|
// compute the inner box based on the
|
|
8562
|
-
// diagrams
|
|
8773
|
+
// diagrams active plane. This allows us to exclude
|
|
8563
8774
|
// external components, such as overlays
|
|
8564
|
-
|
|
8775
|
+
|
|
8776
|
+
innerBox = (this._activePlane && this._activePlane.layer.getBBox()) || {};
|
|
8565
8777
|
|
|
8566
8778
|
transform = transform$1(viewport);
|
|
8567
8779
|
matrix = transform ? transform.matrix : createMatrix();
|
|
@@ -8577,10 +8789,10 @@
|
|
|
8577
8789
|
height: outerBox.height / scale,
|
|
8578
8790
|
scale: scale,
|
|
8579
8791
|
inner: {
|
|
8580
|
-
width: innerBox.width,
|
|
8581
|
-
height: innerBox.height,
|
|
8582
|
-
x: innerBox.x,
|
|
8583
|
-
y: innerBox.y
|
|
8792
|
+
width: innerBox.width || 0,
|
|
8793
|
+
height: innerBox.height || 0,
|
|
8794
|
+
x: innerBox.x || 0,
|
|
8795
|
+
y: innerBox.y || 0
|
|
8584
8796
|
},
|
|
8585
8797
|
outer: outerBox
|
|
8586
8798
|
};
|
|
@@ -8639,6 +8851,13 @@
|
|
|
8639
8851
|
*/
|
|
8640
8852
|
Canvas.prototype.scrollToElement = function(element, padding) {
|
|
8641
8853
|
var defaultPadding = 100;
|
|
8854
|
+
|
|
8855
|
+
// switch to correct Plane
|
|
8856
|
+
var targetPlane = this.findPlane(element);
|
|
8857
|
+
if (targetPlane !== this._activePlane) {
|
|
8858
|
+
this.setActivePlane(targetPlane);
|
|
8859
|
+
}
|
|
8860
|
+
|
|
8642
8861
|
if (!padding) {
|
|
8643
8862
|
padding = {};
|
|
8644
8863
|
}
|
|
@@ -8659,7 +8878,7 @@
|
|
|
8659
8878
|
zoom = this.zoom(),
|
|
8660
8879
|
dx, dy;
|
|
8661
8880
|
|
|
8662
|
-
//
|
|
8881
|
+
// shrink viewboxBounds with padding
|
|
8663
8882
|
viewboxBounds.y += padding.top / zoom;
|
|
8664
8883
|
viewboxBounds.x += padding.left / zoom;
|
|
8665
8884
|
viewboxBounds.width -= (padding.right + padding.left) / zoom;
|
|
@@ -8981,6 +9200,29 @@
|
|
|
8981
9200
|
this.add(element, gfx, secondaryGfx);
|
|
8982
9201
|
};
|
|
8983
9202
|
|
|
9203
|
+
/**
|
|
9204
|
+
* Update the graphics of an element
|
|
9205
|
+
*
|
|
9206
|
+
* @param {djs.model.Base} element
|
|
9207
|
+
* @param {SVGElement} gfx
|
|
9208
|
+
* @param {boolean} [secondary=false] whether to update the secondary connected element
|
|
9209
|
+
*/
|
|
9210
|
+
ElementRegistry.prototype.updateGraphics = function(filter, gfx, secondary) {
|
|
9211
|
+
var id = filter.id || filter;
|
|
9212
|
+
|
|
9213
|
+
var container = this._elements[id];
|
|
9214
|
+
|
|
9215
|
+
if (secondary) {
|
|
9216
|
+
container.secondaryGfx = gfx;
|
|
9217
|
+
} else {
|
|
9218
|
+
container.gfx = gfx;
|
|
9219
|
+
}
|
|
9220
|
+
|
|
9221
|
+
attr$1(gfx, ELEMENT_ID, id);
|
|
9222
|
+
|
|
9223
|
+
return gfx;
|
|
9224
|
+
};
|
|
9225
|
+
|
|
8984
9226
|
/**
|
|
8985
9227
|
* Return the model element for a given id or graphics.
|
|
8986
9228
|
*
|
|
@@ -10088,12 +10330,11 @@
|
|
|
10088
10330
|
if (returnValue === false) {
|
|
10089
10331
|
event.preventDefault();
|
|
10090
10332
|
}
|
|
10091
|
-
} catch (
|
|
10092
|
-
if (!this.handleError(
|
|
10093
|
-
console.error('unhandled error in event listener');
|
|
10094
|
-
console.error(e.stack);
|
|
10333
|
+
} catch (error) {
|
|
10334
|
+
if (!this.handleError(error)) {
|
|
10335
|
+
console.error('unhandled error in event listener', error);
|
|
10095
10336
|
|
|
10096
|
-
throw
|
|
10337
|
+
throw error;
|
|
10097
10338
|
}
|
|
10098
10339
|
}
|
|
10099
10340
|
|
|
@@ -19700,8 +19941,9 @@
|
|
|
19700
19941
|
var KEYDOWN_EVENT = 'keyboard.keydown',
|
|
19701
19942
|
KEYUP_EVENT = 'keyboard.keyup';
|
|
19702
19943
|
|
|
19703
|
-
var
|
|
19944
|
+
var HANDLE_MODIFIER_ATTRIBUTE = 'input-handle-modified-keys';
|
|
19704
19945
|
|
|
19946
|
+
var DEFAULT_PRIORITY = 1000;
|
|
19705
19947
|
|
|
19706
19948
|
/**
|
|
19707
19949
|
* A keyboard abstraction that may be activated and
|
|
@@ -19772,10 +20014,9 @@
|
|
|
19772
20014
|
};
|
|
19773
20015
|
|
|
19774
20016
|
Keyboard.prototype._keyHandler = function(event, type) {
|
|
19775
|
-
var
|
|
19776
|
-
eventBusResult;
|
|
20017
|
+
var eventBusResult;
|
|
19777
20018
|
|
|
19778
|
-
if (
|
|
20019
|
+
if (this._isEventIgnored(event)) {
|
|
19779
20020
|
return;
|
|
19780
20021
|
}
|
|
19781
20022
|
|
|
@@ -19790,6 +20031,29 @@
|
|
|
19790
20031
|
}
|
|
19791
20032
|
};
|
|
19792
20033
|
|
|
20034
|
+
Keyboard.prototype._isEventIgnored = function(event) {
|
|
20035
|
+
return isInput(event.target) && this._isModifiedKeyIgnored(event);
|
|
20036
|
+
};
|
|
20037
|
+
|
|
20038
|
+
Keyboard.prototype._isModifiedKeyIgnored = function(event) {
|
|
20039
|
+
if (!isCmd(event)) {
|
|
20040
|
+
return true;
|
|
20041
|
+
}
|
|
20042
|
+
|
|
20043
|
+
var allowedModifiers = this._getAllowedModifiers(event.target);
|
|
20044
|
+
return !allowedModifiers.includes(event.key);
|
|
20045
|
+
};
|
|
20046
|
+
|
|
20047
|
+
Keyboard.prototype._getAllowedModifiers = function(element) {
|
|
20048
|
+
var modifierContainer = closest(element, '[' + HANDLE_MODIFIER_ATTRIBUTE + ']', true);
|
|
20049
|
+
|
|
20050
|
+
if (!modifierContainer || (this._node && !this._node.contains(modifierContainer))) {
|
|
20051
|
+
return [];
|
|
20052
|
+
}
|
|
20053
|
+
|
|
20054
|
+
return modifierContainer.getAttribute(HANDLE_MODIFIER_ATTRIBUTE).split(',');
|
|
20055
|
+
};
|
|
20056
|
+
|
|
19793
20057
|
Keyboard.prototype.bind = function(node) {
|
|
19794
20058
|
|
|
19795
20059
|
// make sure that the keyboard is only bound once to the DOM
|