camunda-bpmn-js 0.23.1 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/bpmn-js.css +7 -7
- package/dist/assets/diagram-js.css +208 -46
- package/dist/base-modeler.development.js +2799 -3687
- package/dist/base-modeler.production.min.js +163 -4
- package/dist/base-navigated-viewer.development.js +470 -893
- package/dist/base-navigated-viewer.production.min.js +2 -2
- package/dist/base-viewer.development.js +455 -877
- package/dist/base-viewer.production.min.js +2 -2
- package/dist/camunda-cloud-modeler.development.js +5037 -6319
- package/dist/camunda-cloud-modeler.production.min.js +163 -4
- package/dist/camunda-cloud-navigated-viewer.development.js +729 -1392
- package/dist/camunda-cloud-navigated-viewer.production.min.js +2 -2
- package/dist/camunda-cloud-viewer.development.js +855 -1517
- package/dist/camunda-cloud-viewer.production.min.js +2 -2
- package/dist/camunda-platform-modeler.development.js +3746 -5863
- package/dist/camunda-platform-modeler.production.min.js +163 -4
- package/dist/camunda-platform-navigated-viewer.development.js +470 -893
- package/dist/camunda-platform-navigated-viewer.production.min.js +2 -2
- package/dist/camunda-platform-viewer.development.js +455 -877
- package/dist/camunda-platform-viewer.production.min.js +2 -2
- package/lib/camunda-cloud/Modeler.js +3 -1
- package/lib/camunda-cloud/features/replace/ElementTemplatesReplaceProvider.js +256 -0
- package/lib/camunda-cloud/features/replace/ReplaceOptionsUtil.js +7 -0
- package/lib/camunda-cloud/features/replace/index.js +6 -0
- package/package.json +15 -12
|
@@ -682,7 +682,7 @@
|
|
|
682
682
|
}
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
-
function ensureImported
|
|
685
|
+
function ensureImported(element, target) {
|
|
686
686
|
|
|
687
687
|
if (element.ownerDocument !== target.ownerDocument) {
|
|
688
688
|
try {
|
|
@@ -710,8 +710,8 @@
|
|
|
710
710
|
*
|
|
711
711
|
* @return {SVGElement} the appended node
|
|
712
712
|
*/
|
|
713
|
-
function appendTo
|
|
714
|
-
return target.appendChild(ensureImported
|
|
713
|
+
function appendTo(element, target) {
|
|
714
|
+
return target.appendChild(ensureImported(element, target));
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
/**
|
|
@@ -726,8 +726,8 @@
|
|
|
726
726
|
*
|
|
727
727
|
* @return {SVGElement} the element
|
|
728
728
|
*/
|
|
729
|
-
function append
|
|
730
|
-
appendTo
|
|
729
|
+
function append(target, node) {
|
|
730
|
+
appendTo(node, target);
|
|
731
731
|
return target;
|
|
732
732
|
}
|
|
733
733
|
|
|
@@ -735,9 +735,9 @@
|
|
|
735
735
|
* attribute accessor utility
|
|
736
736
|
*/
|
|
737
737
|
|
|
738
|
-
var LENGTH_ATTR
|
|
738
|
+
var LENGTH_ATTR = 2;
|
|
739
739
|
|
|
740
|
-
var CSS_PROPERTIES
|
|
740
|
+
var CSS_PROPERTIES = {
|
|
741
741
|
'alignment-baseline': 1,
|
|
742
742
|
'baseline-shift': 1,
|
|
743
743
|
'clip': 1,
|
|
@@ -761,7 +761,7 @@
|
|
|
761
761
|
'flood-opacity': 1,
|
|
762
762
|
'font': 1,
|
|
763
763
|
'font-family': 1,
|
|
764
|
-
'font-size': LENGTH_ATTR
|
|
764
|
+
'font-size': LENGTH_ATTR,
|
|
765
765
|
'font-size-adjust': 1,
|
|
766
766
|
'font-stretch': 1,
|
|
767
767
|
'font-style': 1,
|
|
@@ -791,7 +791,7 @@
|
|
|
791
791
|
'stroke-linejoin': 1,
|
|
792
792
|
'stroke-miterlimit': 1,
|
|
793
793
|
'stroke-opacity': 1,
|
|
794
|
-
'stroke-width': LENGTH_ATTR
|
|
794
|
+
'stroke-width': LENGTH_ATTR,
|
|
795
795
|
'text-anchor': 1,
|
|
796
796
|
'text-decoration': 1,
|
|
797
797
|
'text-rendering': 1,
|
|
@@ -802,23 +802,23 @@
|
|
|
802
802
|
};
|
|
803
803
|
|
|
804
804
|
|
|
805
|
-
function getAttribute
|
|
806
|
-
if (CSS_PROPERTIES
|
|
805
|
+
function getAttribute(node, name) {
|
|
806
|
+
if (CSS_PROPERTIES[name]) {
|
|
807
807
|
return node.style[name];
|
|
808
808
|
} else {
|
|
809
809
|
return node.getAttributeNS(null, name);
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
|
|
813
|
-
function setAttribute
|
|
813
|
+
function setAttribute(node, name, value) {
|
|
814
814
|
var hyphenated = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
815
815
|
|
|
816
|
-
var type = CSS_PROPERTIES
|
|
816
|
+
var type = CSS_PROPERTIES[hyphenated];
|
|
817
817
|
|
|
818
818
|
if (type) {
|
|
819
819
|
|
|
820
820
|
// append pixel unit, unless present
|
|
821
|
-
if (type === LENGTH_ATTR
|
|
821
|
+
if (type === LENGTH_ATTR && typeof value === 'number') {
|
|
822
822
|
value = String(value) + 'px';
|
|
823
823
|
}
|
|
824
824
|
|
|
@@ -828,12 +828,12 @@
|
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
function setAttributes
|
|
831
|
+
function setAttributes(node, attrs) {
|
|
832
832
|
|
|
833
833
|
var names = Object.keys(attrs), i, name;
|
|
834
834
|
|
|
835
835
|
for (i = 0, name; (name = names[i]); i++) {
|
|
836
|
-
setAttribute
|
|
836
|
+
setAttribute(node, name, attrs[name]);
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
|
|
@@ -847,15 +847,15 @@
|
|
|
847
847
|
*
|
|
848
848
|
* @return {String}
|
|
849
849
|
*/
|
|
850
|
-
function attr$
|
|
850
|
+
function attr$1(node, name, value) {
|
|
851
851
|
if (typeof name === 'string') {
|
|
852
852
|
if (value !== undefined) {
|
|
853
|
-
setAttribute
|
|
853
|
+
setAttribute(node, name, value);
|
|
854
854
|
} else {
|
|
855
|
-
return getAttribute
|
|
855
|
+
return getAttribute(node, name);
|
|
856
856
|
}
|
|
857
857
|
} else {
|
|
858
|
-
setAttributes
|
|
858
|
+
setAttributes(node, name);
|
|
859
859
|
}
|
|
860
860
|
|
|
861
861
|
return node;
|
|
@@ -871,7 +871,7 @@
|
|
|
871
871
|
* toString reference.
|
|
872
872
|
*/
|
|
873
873
|
|
|
874
|
-
const toString$
|
|
874
|
+
const toString$1 = Object.prototype.toString;
|
|
875
875
|
|
|
876
876
|
/**
|
|
877
877
|
* Wrap `el` in a `ClassList`.
|
|
@@ -881,11 +881,11 @@
|
|
|
881
881
|
* @api public
|
|
882
882
|
*/
|
|
883
883
|
|
|
884
|
-
function classes$
|
|
885
|
-
return new ClassList$
|
|
884
|
+
function classes$1(el) {
|
|
885
|
+
return new ClassList$1(el);
|
|
886
886
|
}
|
|
887
887
|
|
|
888
|
-
function ClassList$
|
|
888
|
+
function ClassList$1(el) {
|
|
889
889
|
if (!el || !el.nodeType) {
|
|
890
890
|
throw new Error('A DOM element reference is required');
|
|
891
891
|
}
|
|
@@ -901,7 +901,7 @@
|
|
|
901
901
|
* @api public
|
|
902
902
|
*/
|
|
903
903
|
|
|
904
|
-
ClassList$
|
|
904
|
+
ClassList$1.prototype.add = function(name) {
|
|
905
905
|
this.list.add(name);
|
|
906
906
|
return this;
|
|
907
907
|
};
|
|
@@ -916,8 +916,8 @@
|
|
|
916
916
|
* @api public
|
|
917
917
|
*/
|
|
918
918
|
|
|
919
|
-
ClassList$
|
|
920
|
-
if ('[object RegExp]' == toString$
|
|
919
|
+
ClassList$1.prototype.remove = function(name) {
|
|
920
|
+
if ('[object RegExp]' == toString$1.call(name)) {
|
|
921
921
|
return this.removeMatching(name);
|
|
922
922
|
}
|
|
923
923
|
|
|
@@ -933,7 +933,7 @@
|
|
|
933
933
|
* @api private
|
|
934
934
|
*/
|
|
935
935
|
|
|
936
|
-
ClassList$
|
|
936
|
+
ClassList$1.prototype.removeMatching = function(re) {
|
|
937
937
|
const arr = this.array();
|
|
938
938
|
for (let i = 0; i < arr.length; i++) {
|
|
939
939
|
if (re.test(arr[i])) {
|
|
@@ -955,7 +955,7 @@
|
|
|
955
955
|
* @api public
|
|
956
956
|
*/
|
|
957
957
|
|
|
958
|
-
ClassList$
|
|
958
|
+
ClassList$1.prototype.toggle = function(name, force) {
|
|
959
959
|
if ('undefined' !== typeof force) {
|
|
960
960
|
if (force !== this.list.toggle(name, force)) {
|
|
961
961
|
this.list.toggle(name); // toggle again to correct
|
|
@@ -973,7 +973,7 @@
|
|
|
973
973
|
* @api public
|
|
974
974
|
*/
|
|
975
975
|
|
|
976
|
-
ClassList$
|
|
976
|
+
ClassList$1.prototype.array = function() {
|
|
977
977
|
return Array.from(this.list);
|
|
978
978
|
};
|
|
979
979
|
|
|
@@ -985,12 +985,12 @@
|
|
|
985
985
|
* @api public
|
|
986
986
|
*/
|
|
987
987
|
|
|
988
|
-
ClassList$
|
|
989
|
-
ClassList$
|
|
988
|
+
ClassList$1.prototype.has =
|
|
989
|
+
ClassList$1.prototype.contains = function(name) {
|
|
990
990
|
return this.list.contains(name);
|
|
991
991
|
};
|
|
992
992
|
|
|
993
|
-
function remove$
|
|
993
|
+
function remove$2(element) {
|
|
994
994
|
var parent = element.parentNode;
|
|
995
995
|
|
|
996
996
|
if (parent) {
|
|
@@ -1010,17 +1010,17 @@
|
|
|
1010
1010
|
* @param {DOMElement} element
|
|
1011
1011
|
* @return {DOMElement} the element (for chaining)
|
|
1012
1012
|
*/
|
|
1013
|
-
function clear$
|
|
1013
|
+
function clear$1(element) {
|
|
1014
1014
|
var child;
|
|
1015
1015
|
|
|
1016
1016
|
while ((child = element.firstChild)) {
|
|
1017
|
-
remove$
|
|
1017
|
+
remove$2(child);
|
|
1018
1018
|
}
|
|
1019
1019
|
|
|
1020
1020
|
return element;
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
|
-
var ns
|
|
1023
|
+
var ns = {
|
|
1024
1024
|
svg: 'http://www.w3.org/2000/svg'
|
|
1025
1025
|
};
|
|
1026
1026
|
|
|
@@ -1028,25 +1028,25 @@
|
|
|
1028
1028
|
* DOM parsing utility
|
|
1029
1029
|
*/
|
|
1030
1030
|
|
|
1031
|
-
var SVG_START
|
|
1031
|
+
var SVG_START = '<svg xmlns="' + ns.svg + '"';
|
|
1032
1032
|
|
|
1033
|
-
function parse$
|
|
1033
|
+
function parse$1(svg) {
|
|
1034
1034
|
|
|
1035
1035
|
var unwrap = false;
|
|
1036
1036
|
|
|
1037
1037
|
// ensure we import a valid svg document
|
|
1038
1038
|
if (svg.substring(0, 4) === '<svg') {
|
|
1039
|
-
if (svg.indexOf(ns
|
|
1040
|
-
svg = SVG_START
|
|
1039
|
+
if (svg.indexOf(ns.svg) === -1) {
|
|
1040
|
+
svg = SVG_START + svg.substring(4);
|
|
1041
1041
|
}
|
|
1042
1042
|
} else {
|
|
1043
1043
|
|
|
1044
1044
|
// namespace svg
|
|
1045
|
-
svg = SVG_START
|
|
1045
|
+
svg = SVG_START + '>' + svg + '</svg>';
|
|
1046
1046
|
unwrap = true;
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
-
var parsed = parseDocument
|
|
1049
|
+
var parsed = parseDocument(svg);
|
|
1050
1050
|
|
|
1051
1051
|
if (!unwrap) {
|
|
1052
1052
|
return parsed;
|
|
@@ -1063,7 +1063,7 @@
|
|
|
1063
1063
|
return fragment;
|
|
1064
1064
|
}
|
|
1065
1065
|
|
|
1066
|
-
function parseDocument
|
|
1066
|
+
function parseDocument(svg) {
|
|
1067
1067
|
|
|
1068
1068
|
var parser;
|
|
1069
1069
|
|
|
@@ -1087,18 +1087,18 @@
|
|
|
1087
1087
|
*
|
|
1088
1088
|
* @returns {SVGElement}
|
|
1089
1089
|
*/
|
|
1090
|
-
function create$
|
|
1090
|
+
function create$1(name, attrs) {
|
|
1091
1091
|
var element;
|
|
1092
1092
|
|
|
1093
1093
|
if (name.charAt(0) === '<') {
|
|
1094
|
-
element = parse$
|
|
1094
|
+
element = parse$1(name).firstChild;
|
|
1095
1095
|
element = document.importNode(element, true);
|
|
1096
1096
|
} else {
|
|
1097
|
-
element = document.createElementNS(ns
|
|
1097
|
+
element = document.createElementNS(ns.svg, name);
|
|
1098
1098
|
}
|
|
1099
1099
|
|
|
1100
1100
|
if (attrs) {
|
|
1101
|
-
attr$
|
|
1101
|
+
attr$1(element, attrs);
|
|
1102
1102
|
}
|
|
1103
1103
|
|
|
1104
1104
|
return element;
|
|
@@ -1113,7 +1113,7 @@
|
|
|
1113
1113
|
|
|
1114
1114
|
function getNode() {
|
|
1115
1115
|
if (node === null) {
|
|
1116
|
-
node = create$
|
|
1116
|
+
node = create$1('svg');
|
|
1117
1117
|
}
|
|
1118
1118
|
|
|
1119
1119
|
return node;
|
|
@@ -1168,6 +1168,152 @@
|
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
1170
1170
|
|
|
1171
|
+
/**
|
|
1172
|
+
* Serialization util
|
|
1173
|
+
*/
|
|
1174
|
+
|
|
1175
|
+
var TEXT_ENTITIES = /([&<>]{1})/g;
|
|
1176
|
+
var ATTR_ENTITIES = /([\n\r"]{1})/g;
|
|
1177
|
+
|
|
1178
|
+
var ENTITY_REPLACEMENT = {
|
|
1179
|
+
'&': '&',
|
|
1180
|
+
'<': '<',
|
|
1181
|
+
'>': '>',
|
|
1182
|
+
'"': '\''
|
|
1183
|
+
};
|
|
1184
|
+
|
|
1185
|
+
function escape$1(str, pattern) {
|
|
1186
|
+
|
|
1187
|
+
function replaceFn(match, entity) {
|
|
1188
|
+
return ENTITY_REPLACEMENT[entity] || entity;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
return str.replace(pattern, replaceFn);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
function serialize(node, output) {
|
|
1195
|
+
|
|
1196
|
+
var i, len, attrMap, attrNode, childNodes;
|
|
1197
|
+
|
|
1198
|
+
switch (node.nodeType) {
|
|
1199
|
+
|
|
1200
|
+
// TEXT
|
|
1201
|
+
case 3:
|
|
1202
|
+
|
|
1203
|
+
// replace special XML characters
|
|
1204
|
+
output.push(escape$1(node.textContent, TEXT_ENTITIES));
|
|
1205
|
+
break;
|
|
1206
|
+
|
|
1207
|
+
// ELEMENT
|
|
1208
|
+
case 1:
|
|
1209
|
+
output.push('<', node.tagName);
|
|
1210
|
+
|
|
1211
|
+
if (node.hasAttributes()) {
|
|
1212
|
+
attrMap = node.attributes;
|
|
1213
|
+
for (i = 0, len = attrMap.length; i < len; ++i) {
|
|
1214
|
+
attrNode = attrMap.item(i);
|
|
1215
|
+
output.push(' ', attrNode.name, '="', escape$1(attrNode.value, ATTR_ENTITIES), '"');
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
if (node.hasChildNodes()) {
|
|
1220
|
+
output.push('>');
|
|
1221
|
+
childNodes = node.childNodes;
|
|
1222
|
+
for (i = 0, len = childNodes.length; i < len; ++i) {
|
|
1223
|
+
serialize(childNodes.item(i), output);
|
|
1224
|
+
}
|
|
1225
|
+
output.push('</', node.tagName, '>');
|
|
1226
|
+
} else {
|
|
1227
|
+
output.push('/>');
|
|
1228
|
+
}
|
|
1229
|
+
break;
|
|
1230
|
+
|
|
1231
|
+
// COMMENT
|
|
1232
|
+
case 8:
|
|
1233
|
+
output.push('<!--', escape$1(node.nodeValue, TEXT_ENTITIES), '-->');
|
|
1234
|
+
break;
|
|
1235
|
+
|
|
1236
|
+
// CDATA
|
|
1237
|
+
case 4:
|
|
1238
|
+
output.push('<![CDATA[', node.nodeValue, ']]>');
|
|
1239
|
+
break;
|
|
1240
|
+
|
|
1241
|
+
default:
|
|
1242
|
+
throw new Error('unable to handle node ' + node.nodeType);
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
return output;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* innerHTML like functionality for SVG elements.
|
|
1250
|
+
* based on innerSVG (https://code.google.com/p/innersvg)
|
|
1251
|
+
*/
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
function set(element, svg) {
|
|
1255
|
+
|
|
1256
|
+
var parsed = parse$1(svg);
|
|
1257
|
+
|
|
1258
|
+
// clear element contents
|
|
1259
|
+
clear$1(element);
|
|
1260
|
+
|
|
1261
|
+
if (!svg) {
|
|
1262
|
+
return;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
if (!isFragment(parsed)) {
|
|
1266
|
+
|
|
1267
|
+
// extract <svg> from parsed document
|
|
1268
|
+
parsed = parsed.documentElement;
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
var nodes = slice$1(parsed.childNodes);
|
|
1272
|
+
|
|
1273
|
+
// import + append each node
|
|
1274
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1275
|
+
appendTo(nodes[i], element);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
function get(element) {
|
|
1281
|
+
var child = element.firstChild,
|
|
1282
|
+
output = [];
|
|
1283
|
+
|
|
1284
|
+
while (child) {
|
|
1285
|
+
serialize(child, output);
|
|
1286
|
+
child = child.nextSibling;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
return output.join('');
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
function isFragment(node) {
|
|
1293
|
+
return node.nodeName === '#document-fragment';
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
function innerSVG(element, svg) {
|
|
1297
|
+
|
|
1298
|
+
if (svg !== undefined) {
|
|
1299
|
+
|
|
1300
|
+
try {
|
|
1301
|
+
set(element, svg);
|
|
1302
|
+
} catch (e) {
|
|
1303
|
+
throw new Error('error parsing SVG: ' + e.message);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
return element;
|
|
1307
|
+
} else {
|
|
1308
|
+
return get(element);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
|
|
1313
|
+
function slice$1(arr) {
|
|
1314
|
+
return Array.prototype.slice.call(arr);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1171
1317
|
/**
|
|
1172
1318
|
* transform accessor utility
|
|
1173
1319
|
*/
|
|
@@ -1230,18 +1376,18 @@
|
|
|
1230
1376
|
|
|
1231
1377
|
function createLine(points, attrs) {
|
|
1232
1378
|
|
|
1233
|
-
var line = create$
|
|
1234
|
-
attr$
|
|
1379
|
+
var line = create$1('polyline');
|
|
1380
|
+
attr$1(line, { points: toSVGPoints(points) });
|
|
1235
1381
|
|
|
1236
1382
|
if (attrs) {
|
|
1237
|
-
attr$
|
|
1383
|
+
attr$1(line, attrs);
|
|
1238
1384
|
}
|
|
1239
1385
|
|
|
1240
1386
|
return line;
|
|
1241
1387
|
}
|
|
1242
1388
|
|
|
1243
1389
|
function updateLine(gfx, points) {
|
|
1244
|
-
attr$
|
|
1390
|
+
attr$1(gfx, { points: toSVGPoints(points) });
|
|
1245
1391
|
|
|
1246
1392
|
return gfx;
|
|
1247
1393
|
}
|
|
@@ -1510,7 +1656,7 @@
|
|
|
1510
1656
|
* @param {String} [val]
|
|
1511
1657
|
* @api public
|
|
1512
1658
|
*/
|
|
1513
|
-
function attr
|
|
1659
|
+
function attr(el, name, val) {
|
|
1514
1660
|
|
|
1515
1661
|
// get
|
|
1516
1662
|
if (arguments.length == 2) {
|
|
@@ -1538,7 +1684,7 @@
|
|
|
1538
1684
|
* toString reference.
|
|
1539
1685
|
*/
|
|
1540
1686
|
|
|
1541
|
-
const toString
|
|
1687
|
+
const toString = Object.prototype.toString;
|
|
1542
1688
|
|
|
1543
1689
|
/**
|
|
1544
1690
|
* Wrap `el` in a `ClassList`.
|
|
@@ -1548,8 +1694,8 @@
|
|
|
1548
1694
|
* @api public
|
|
1549
1695
|
*/
|
|
1550
1696
|
|
|
1551
|
-
function classes
|
|
1552
|
-
return new ClassList
|
|
1697
|
+
function classes(el) {
|
|
1698
|
+
return new ClassList(el);
|
|
1553
1699
|
}
|
|
1554
1700
|
|
|
1555
1701
|
/**
|
|
@@ -1559,7 +1705,7 @@
|
|
|
1559
1705
|
* @api private
|
|
1560
1706
|
*/
|
|
1561
1707
|
|
|
1562
|
-
function ClassList
|
|
1708
|
+
function ClassList(el) {
|
|
1563
1709
|
if (!el || !el.nodeType) {
|
|
1564
1710
|
throw new Error('A DOM element reference is required');
|
|
1565
1711
|
}
|
|
@@ -1575,7 +1721,7 @@
|
|
|
1575
1721
|
* @api public
|
|
1576
1722
|
*/
|
|
1577
1723
|
|
|
1578
|
-
ClassList
|
|
1724
|
+
ClassList.prototype.add = function(name) {
|
|
1579
1725
|
this.list.add(name);
|
|
1580
1726
|
return this;
|
|
1581
1727
|
};
|
|
@@ -1590,8 +1736,8 @@
|
|
|
1590
1736
|
* @api public
|
|
1591
1737
|
*/
|
|
1592
1738
|
|
|
1593
|
-
ClassList
|
|
1594
|
-
if ('[object RegExp]' == toString
|
|
1739
|
+
ClassList.prototype.remove = function(name) {
|
|
1740
|
+
if ('[object RegExp]' == toString.call(name)) {
|
|
1595
1741
|
return this.removeMatching(name);
|
|
1596
1742
|
}
|
|
1597
1743
|
|
|
@@ -1607,7 +1753,7 @@
|
|
|
1607
1753
|
* @api private
|
|
1608
1754
|
*/
|
|
1609
1755
|
|
|
1610
|
-
ClassList
|
|
1756
|
+
ClassList.prototype.removeMatching = function(re) {
|
|
1611
1757
|
const arr = this.array();
|
|
1612
1758
|
for (let i = 0; i < arr.length; i++) {
|
|
1613
1759
|
if (re.test(arr[i])) {
|
|
@@ -1629,7 +1775,7 @@
|
|
|
1629
1775
|
* @api public
|
|
1630
1776
|
*/
|
|
1631
1777
|
|
|
1632
|
-
ClassList
|
|
1778
|
+
ClassList.prototype.toggle = function(name, force) {
|
|
1633
1779
|
if ('undefined' !== typeof force) {
|
|
1634
1780
|
if (force !== this.list.toggle(name, force)) {
|
|
1635
1781
|
this.list.toggle(name); // toggle again to correct
|
|
@@ -1647,7 +1793,7 @@
|
|
|
1647
1793
|
* @api public
|
|
1648
1794
|
*/
|
|
1649
1795
|
|
|
1650
|
-
ClassList
|
|
1796
|
+
ClassList.prototype.array = function() {
|
|
1651
1797
|
return Array.from(this.list);
|
|
1652
1798
|
};
|
|
1653
1799
|
|
|
@@ -1659,15 +1805,15 @@
|
|
|
1659
1805
|
* @api public
|
|
1660
1806
|
*/
|
|
1661
1807
|
|
|
1662
|
-
ClassList
|
|
1663
|
-
ClassList
|
|
1808
|
+
ClassList.prototype.has =
|
|
1809
|
+
ClassList.prototype.contains = function(name) {
|
|
1664
1810
|
return this.list.contains(name);
|
|
1665
1811
|
};
|
|
1666
1812
|
|
|
1667
1813
|
/**
|
|
1668
1814
|
* Remove all children from the given element.
|
|
1669
1815
|
*/
|
|
1670
|
-
function clear
|
|
1816
|
+
function clear(el) {
|
|
1671
1817
|
|
|
1672
1818
|
var c;
|
|
1673
1819
|
|
|
@@ -1819,7 +1965,7 @@
|
|
|
1819
1965
|
* Expose `parse`.
|
|
1820
1966
|
*/
|
|
1821
1967
|
|
|
1822
|
-
var domify = parse
|
|
1968
|
+
var domify = parse;
|
|
1823
1969
|
|
|
1824
1970
|
/**
|
|
1825
1971
|
* Tests for browser support.
|
|
@@ -1883,7 +2029,7 @@
|
|
|
1883
2029
|
* @api private
|
|
1884
2030
|
*/
|
|
1885
2031
|
|
|
1886
|
-
function parse
|
|
2032
|
+
function parse(html, doc) {
|
|
1887
2033
|
if ('string' != typeof html) throw new TypeError('String expected');
|
|
1888
2034
|
|
|
1889
2035
|
// default to the global `document` object
|
|
@@ -1941,625 +2087,57 @@
|
|
|
1941
2087
|
return el.querySelectorAll(selector);
|
|
1942
2088
|
}
|
|
1943
2089
|
|
|
1944
|
-
function remove$
|
|
2090
|
+
function remove$1(el) {
|
|
1945
2091
|
el.parentNode && el.parentNode.removeChild(el);
|
|
1946
2092
|
}
|
|
1947
2093
|
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
2094
|
+
/**
|
|
2095
|
+
* @param {<SVGElement>} element
|
|
2096
|
+
* @param {number} x
|
|
2097
|
+
* @param {number} y
|
|
2098
|
+
* @param {number} angle
|
|
2099
|
+
* @param {number} amount
|
|
2100
|
+
*/
|
|
2101
|
+
function transform(gfx, x, y, angle, amount) {
|
|
2102
|
+
var translate = createTransform();
|
|
2103
|
+
translate.setTranslate(x, y);
|
|
2104
|
+
|
|
2105
|
+
var rotate = createTransform();
|
|
2106
|
+
rotate.setRotate(angle || 0, 0, 0);
|
|
2107
|
+
|
|
2108
|
+
var scale = createTransform();
|
|
2109
|
+
scale.setScale(amount || 1, amount || 1);
|
|
2110
|
+
|
|
2111
|
+
transform$1(gfx, [ translate, rotate, scale ]);
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* @param {SVGElement} element
|
|
2117
|
+
* @param {number} x
|
|
2118
|
+
* @param {number} y
|
|
2119
|
+
*/
|
|
2120
|
+
function translate$1(gfx, x, y) {
|
|
2121
|
+
var translate = createTransform();
|
|
2122
|
+
translate.setTranslate(x, y);
|
|
2123
|
+
|
|
2124
|
+
transform$1(gfx, translate);
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
|
|
2128
|
+
/**
|
|
2129
|
+
* @param {SVGElement} element
|
|
2130
|
+
* @param {number} angle
|
|
2131
|
+
*/
|
|
2132
|
+
function rotate(gfx, angle) {
|
|
2133
|
+
var rotate = createTransform();
|
|
2134
|
+
rotate.setRotate(angle, 0, 0);
|
|
2135
|
+
|
|
2136
|
+
transform$1(gfx, rotate);
|
|
1962
2137
|
}
|
|
1963
2138
|
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
*/
|
|
1967
|
-
|
|
1968
|
-
/**
|
|
1969
|
-
* Append a node to a target element and return the appended node.
|
|
1970
|
-
*
|
|
1971
|
-
* @param {SVGElement} element
|
|
1972
|
-
* @param {SVGElement} target
|
|
1973
|
-
*
|
|
1974
|
-
* @return {SVGElement} the appended node
|
|
1975
|
-
*/
|
|
1976
|
-
function appendTo$1(element, target) {
|
|
1977
|
-
return target.appendChild(ensureImported$1(element, target));
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
/**
|
|
1981
|
-
* append utility
|
|
1982
|
-
*/
|
|
1983
|
-
|
|
1984
|
-
/**
|
|
1985
|
-
* Append a node to an element
|
|
1986
|
-
*
|
|
1987
|
-
* @param {SVGElement} element
|
|
1988
|
-
* @param {SVGElement} node
|
|
1989
|
-
*
|
|
1990
|
-
* @return {SVGElement} the element
|
|
1991
|
-
*/
|
|
1992
|
-
function append$1(target, node) {
|
|
1993
|
-
appendTo$1(node, target);
|
|
1994
|
-
return target;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
/**
|
|
1998
|
-
* attribute accessor utility
|
|
1999
|
-
*/
|
|
2000
|
-
|
|
2001
|
-
var LENGTH_ATTR$1 = 2;
|
|
2002
|
-
|
|
2003
|
-
var CSS_PROPERTIES$1 = {
|
|
2004
|
-
'alignment-baseline': 1,
|
|
2005
|
-
'baseline-shift': 1,
|
|
2006
|
-
'clip': 1,
|
|
2007
|
-
'clip-path': 1,
|
|
2008
|
-
'clip-rule': 1,
|
|
2009
|
-
'color': 1,
|
|
2010
|
-
'color-interpolation': 1,
|
|
2011
|
-
'color-interpolation-filters': 1,
|
|
2012
|
-
'color-profile': 1,
|
|
2013
|
-
'color-rendering': 1,
|
|
2014
|
-
'cursor': 1,
|
|
2015
|
-
'direction': 1,
|
|
2016
|
-
'display': 1,
|
|
2017
|
-
'dominant-baseline': 1,
|
|
2018
|
-
'enable-background': 1,
|
|
2019
|
-
'fill': 1,
|
|
2020
|
-
'fill-opacity': 1,
|
|
2021
|
-
'fill-rule': 1,
|
|
2022
|
-
'filter': 1,
|
|
2023
|
-
'flood-color': 1,
|
|
2024
|
-
'flood-opacity': 1,
|
|
2025
|
-
'font': 1,
|
|
2026
|
-
'font-family': 1,
|
|
2027
|
-
'font-size': LENGTH_ATTR$1,
|
|
2028
|
-
'font-size-adjust': 1,
|
|
2029
|
-
'font-stretch': 1,
|
|
2030
|
-
'font-style': 1,
|
|
2031
|
-
'font-variant': 1,
|
|
2032
|
-
'font-weight': 1,
|
|
2033
|
-
'glyph-orientation-horizontal': 1,
|
|
2034
|
-
'glyph-orientation-vertical': 1,
|
|
2035
|
-
'image-rendering': 1,
|
|
2036
|
-
'kerning': 1,
|
|
2037
|
-
'letter-spacing': 1,
|
|
2038
|
-
'lighting-color': 1,
|
|
2039
|
-
'marker': 1,
|
|
2040
|
-
'marker-end': 1,
|
|
2041
|
-
'marker-mid': 1,
|
|
2042
|
-
'marker-start': 1,
|
|
2043
|
-
'mask': 1,
|
|
2044
|
-
'opacity': 1,
|
|
2045
|
-
'overflow': 1,
|
|
2046
|
-
'pointer-events': 1,
|
|
2047
|
-
'shape-rendering': 1,
|
|
2048
|
-
'stop-color': 1,
|
|
2049
|
-
'stop-opacity': 1,
|
|
2050
|
-
'stroke': 1,
|
|
2051
|
-
'stroke-dasharray': 1,
|
|
2052
|
-
'stroke-dashoffset': 1,
|
|
2053
|
-
'stroke-linecap': 1,
|
|
2054
|
-
'stroke-linejoin': 1,
|
|
2055
|
-
'stroke-miterlimit': 1,
|
|
2056
|
-
'stroke-opacity': 1,
|
|
2057
|
-
'stroke-width': LENGTH_ATTR$1,
|
|
2058
|
-
'text-anchor': 1,
|
|
2059
|
-
'text-decoration': 1,
|
|
2060
|
-
'text-rendering': 1,
|
|
2061
|
-
'unicode-bidi': 1,
|
|
2062
|
-
'visibility': 1,
|
|
2063
|
-
'word-spacing': 1,
|
|
2064
|
-
'writing-mode': 1
|
|
2065
|
-
};
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
function getAttribute$1(node, name) {
|
|
2069
|
-
if (CSS_PROPERTIES$1[name]) {
|
|
2070
|
-
return node.style[name];
|
|
2071
|
-
} else {
|
|
2072
|
-
return node.getAttributeNS(null, name);
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
function setAttribute$1(node, name, value) {
|
|
2077
|
-
var hyphenated = name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2078
|
-
|
|
2079
|
-
var type = CSS_PROPERTIES$1[hyphenated];
|
|
2080
|
-
|
|
2081
|
-
if (type) {
|
|
2082
|
-
|
|
2083
|
-
// append pixel unit, unless present
|
|
2084
|
-
if (type === LENGTH_ATTR$1 && typeof value === 'number') {
|
|
2085
|
-
value = String(value) + 'px';
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
node.style[hyphenated] = value;
|
|
2089
|
-
} else {
|
|
2090
|
-
node.setAttributeNS(null, name, value);
|
|
2091
|
-
}
|
|
2092
|
-
}
|
|
2093
|
-
|
|
2094
|
-
function setAttributes$1(node, attrs) {
|
|
2095
|
-
|
|
2096
|
-
var names = Object.keys(attrs), i, name;
|
|
2097
|
-
|
|
2098
|
-
for (i = 0, name; (name = names[i]); i++) {
|
|
2099
|
-
setAttribute$1(node, name, attrs[name]);
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
/**
|
|
2104
|
-
* Gets or sets raw attributes on a node.
|
|
2105
|
-
*
|
|
2106
|
-
* @param {SVGElement} node
|
|
2107
|
-
* @param {Object} [attrs]
|
|
2108
|
-
* @param {String} [name]
|
|
2109
|
-
* @param {String} [value]
|
|
2110
|
-
*
|
|
2111
|
-
* @return {String}
|
|
2112
|
-
*/
|
|
2113
|
-
function attr$1(node, name, value) {
|
|
2114
|
-
if (typeof name === 'string') {
|
|
2115
|
-
if (value !== undefined) {
|
|
2116
|
-
setAttribute$1(node, name, value);
|
|
2117
|
-
} else {
|
|
2118
|
-
return getAttribute$1(node, name);
|
|
2119
|
-
}
|
|
2120
|
-
} else {
|
|
2121
|
-
setAttributes$1(node, name);
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
return node;
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
/**
|
|
2128
|
-
* Taken from https://github.com/component/classes
|
|
2129
|
-
*
|
|
2130
|
-
* Without the component bits.
|
|
2131
|
-
*/
|
|
2132
|
-
|
|
2133
|
-
/**
|
|
2134
|
-
* toString reference.
|
|
2135
|
-
*/
|
|
2136
|
-
|
|
2137
|
-
const toString = Object.prototype.toString;
|
|
2138
|
-
|
|
2139
|
-
/**
|
|
2140
|
-
* Wrap `el` in a `ClassList`.
|
|
2141
|
-
*
|
|
2142
|
-
* @param {Element} el
|
|
2143
|
-
* @return {ClassList}
|
|
2144
|
-
* @api public
|
|
2145
|
-
*/
|
|
2146
|
-
|
|
2147
|
-
function classes(el) {
|
|
2148
|
-
return new ClassList(el);
|
|
2149
|
-
}
|
|
2150
|
-
|
|
2151
|
-
function ClassList(el) {
|
|
2152
|
-
if (!el || !el.nodeType) {
|
|
2153
|
-
throw new Error('A DOM element reference is required');
|
|
2154
|
-
}
|
|
2155
|
-
this.el = el;
|
|
2156
|
-
this.list = el.classList;
|
|
2157
|
-
}
|
|
2158
|
-
|
|
2159
|
-
/**
|
|
2160
|
-
* Add class `name` if not already present.
|
|
2161
|
-
*
|
|
2162
|
-
* @param {String} name
|
|
2163
|
-
* @return {ClassList}
|
|
2164
|
-
* @api public
|
|
2165
|
-
*/
|
|
2166
|
-
|
|
2167
|
-
ClassList.prototype.add = function(name) {
|
|
2168
|
-
this.list.add(name);
|
|
2169
|
-
return this;
|
|
2170
|
-
};
|
|
2171
|
-
|
|
2172
|
-
/**
|
|
2173
|
-
* Remove class `name` when present, or
|
|
2174
|
-
* pass a regular expression to remove
|
|
2175
|
-
* any which match.
|
|
2176
|
-
*
|
|
2177
|
-
* @param {String|RegExp} name
|
|
2178
|
-
* @return {ClassList}
|
|
2179
|
-
* @api public
|
|
2180
|
-
*/
|
|
2181
|
-
|
|
2182
|
-
ClassList.prototype.remove = function(name) {
|
|
2183
|
-
if ('[object RegExp]' == toString.call(name)) {
|
|
2184
|
-
return this.removeMatching(name);
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
this.list.remove(name);
|
|
2188
|
-
return this;
|
|
2189
|
-
};
|
|
2190
|
-
|
|
2191
|
-
/**
|
|
2192
|
-
* Remove all classes matching `re`.
|
|
2193
|
-
*
|
|
2194
|
-
* @param {RegExp} re
|
|
2195
|
-
* @return {ClassList}
|
|
2196
|
-
* @api private
|
|
2197
|
-
*/
|
|
2198
|
-
|
|
2199
|
-
ClassList.prototype.removeMatching = function(re) {
|
|
2200
|
-
const arr = this.array();
|
|
2201
|
-
for (let i = 0; i < arr.length; i++) {
|
|
2202
|
-
if (re.test(arr[i])) {
|
|
2203
|
-
this.remove(arr[i]);
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
return this;
|
|
2207
|
-
};
|
|
2208
|
-
|
|
2209
|
-
/**
|
|
2210
|
-
* Toggle class `name`, can force state via `force`.
|
|
2211
|
-
*
|
|
2212
|
-
* For browsers that support classList, but do not support `force` yet,
|
|
2213
|
-
* the mistake will be detected and corrected.
|
|
2214
|
-
*
|
|
2215
|
-
* @param {String} name
|
|
2216
|
-
* @param {Boolean} force
|
|
2217
|
-
* @return {ClassList}
|
|
2218
|
-
* @api public
|
|
2219
|
-
*/
|
|
2220
|
-
|
|
2221
|
-
ClassList.prototype.toggle = function(name, force) {
|
|
2222
|
-
if ('undefined' !== typeof force) {
|
|
2223
|
-
if (force !== this.list.toggle(name, force)) {
|
|
2224
|
-
this.list.toggle(name); // toggle again to correct
|
|
2225
|
-
}
|
|
2226
|
-
} else {
|
|
2227
|
-
this.list.toggle(name);
|
|
2228
|
-
}
|
|
2229
|
-
return this;
|
|
2230
|
-
};
|
|
2231
|
-
|
|
2232
|
-
/**
|
|
2233
|
-
* Return an array of classes.
|
|
2234
|
-
*
|
|
2235
|
-
* @return {Array}
|
|
2236
|
-
* @api public
|
|
2237
|
-
*/
|
|
2238
|
-
|
|
2239
|
-
ClassList.prototype.array = function() {
|
|
2240
|
-
return Array.from(this.list);
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
/**
|
|
2244
|
-
* Check if class `name` is present.
|
|
2245
|
-
*
|
|
2246
|
-
* @param {String} name
|
|
2247
|
-
* @return {ClassList}
|
|
2248
|
-
* @api public
|
|
2249
|
-
*/
|
|
2250
|
-
|
|
2251
|
-
ClassList.prototype.has =
|
|
2252
|
-
ClassList.prototype.contains = function(name) {
|
|
2253
|
-
return this.list.contains(name);
|
|
2254
|
-
};
|
|
2255
|
-
|
|
2256
|
-
function remove$1(element) {
|
|
2257
|
-
var parent = element.parentNode;
|
|
2258
|
-
|
|
2259
|
-
if (parent) {
|
|
2260
|
-
parent.removeChild(element);
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
return element;
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
/**
|
|
2267
|
-
* Clear utility
|
|
2268
|
-
*/
|
|
2269
|
-
|
|
2270
|
-
/**
|
|
2271
|
-
* Removes all children from the given element
|
|
2272
|
-
*
|
|
2273
|
-
* @param {DOMElement} element
|
|
2274
|
-
* @return {DOMElement} the element (for chaining)
|
|
2275
|
-
*/
|
|
2276
|
-
function clear(element) {
|
|
2277
|
-
var child;
|
|
2278
|
-
|
|
2279
|
-
while ((child = element.firstChild)) {
|
|
2280
|
-
remove$1(child);
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
return element;
|
|
2284
|
-
}
|
|
2285
|
-
|
|
2286
|
-
var ns$1 = {
|
|
2287
|
-
svg: 'http://www.w3.org/2000/svg'
|
|
2288
|
-
};
|
|
2289
|
-
|
|
2290
|
-
/**
|
|
2291
|
-
* DOM parsing utility
|
|
2292
|
-
*/
|
|
2293
|
-
|
|
2294
|
-
var SVG_START$1 = '<svg xmlns="' + ns$1.svg + '"';
|
|
2295
|
-
|
|
2296
|
-
function parse$1(svg) {
|
|
2297
|
-
|
|
2298
|
-
var unwrap = false;
|
|
2299
|
-
|
|
2300
|
-
// ensure we import a valid svg document
|
|
2301
|
-
if (svg.substring(0, 4) === '<svg') {
|
|
2302
|
-
if (svg.indexOf(ns$1.svg) === -1) {
|
|
2303
|
-
svg = SVG_START$1 + svg.substring(4);
|
|
2304
|
-
}
|
|
2305
|
-
} else {
|
|
2306
|
-
|
|
2307
|
-
// namespace svg
|
|
2308
|
-
svg = SVG_START$1 + '>' + svg + '</svg>';
|
|
2309
|
-
unwrap = true;
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
var parsed = parseDocument$1(svg);
|
|
2313
|
-
|
|
2314
|
-
if (!unwrap) {
|
|
2315
|
-
return parsed;
|
|
2316
|
-
}
|
|
2317
|
-
|
|
2318
|
-
var fragment = document.createDocumentFragment();
|
|
2319
|
-
|
|
2320
|
-
var parent = parsed.firstChild;
|
|
2321
|
-
|
|
2322
|
-
while (parent.firstChild) {
|
|
2323
|
-
fragment.appendChild(parent.firstChild);
|
|
2324
|
-
}
|
|
2325
|
-
|
|
2326
|
-
return fragment;
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
-
function parseDocument$1(svg) {
|
|
2330
|
-
|
|
2331
|
-
var parser;
|
|
2332
|
-
|
|
2333
|
-
// parse
|
|
2334
|
-
parser = new DOMParser();
|
|
2335
|
-
parser.async = false;
|
|
2336
|
-
|
|
2337
|
-
return parser.parseFromString(svg, 'text/xml');
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
/**
|
|
2341
|
-
* Create utility for SVG elements
|
|
2342
|
-
*/
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
/**
|
|
2346
|
-
* Create a specific type from name or SVG markup.
|
|
2347
|
-
*
|
|
2348
|
-
* @param {String} name the name or markup of the element
|
|
2349
|
-
* @param {Object} [attrs] attributes to set on the element
|
|
2350
|
-
*
|
|
2351
|
-
* @returns {SVGElement}
|
|
2352
|
-
*/
|
|
2353
|
-
function create$2(name, attrs) {
|
|
2354
|
-
var element;
|
|
2355
|
-
|
|
2356
|
-
if (name.charAt(0) === '<') {
|
|
2357
|
-
element = parse$1(name).firstChild;
|
|
2358
|
-
element = document.importNode(element, true);
|
|
2359
|
-
} else {
|
|
2360
|
-
element = document.createElementNS(ns$1.svg, name);
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
if (attrs) {
|
|
2364
|
-
attr$1(element, attrs);
|
|
2365
|
-
}
|
|
2366
|
-
|
|
2367
|
-
return element;
|
|
2368
|
-
}
|
|
2369
|
-
|
|
2370
|
-
/**
|
|
2371
|
-
* Serialization util
|
|
2372
|
-
*/
|
|
2373
|
-
|
|
2374
|
-
var TEXT_ENTITIES = /([&<>]{1})/g;
|
|
2375
|
-
var ATTR_ENTITIES = /([\n\r"]{1})/g;
|
|
2376
|
-
|
|
2377
|
-
var ENTITY_REPLACEMENT = {
|
|
2378
|
-
'&': '&',
|
|
2379
|
-
'<': '<',
|
|
2380
|
-
'>': '>',
|
|
2381
|
-
'"': '\''
|
|
2382
|
-
};
|
|
2383
|
-
|
|
2384
|
-
function escape$1(str, pattern) {
|
|
2385
|
-
|
|
2386
|
-
function replaceFn(match, entity) {
|
|
2387
|
-
return ENTITY_REPLACEMENT[entity] || entity;
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
return str.replace(pattern, replaceFn);
|
|
2391
|
-
}
|
|
2392
|
-
|
|
2393
|
-
function serialize(node, output) {
|
|
2394
|
-
|
|
2395
|
-
var i, len, attrMap, attrNode, childNodes;
|
|
2396
|
-
|
|
2397
|
-
switch (node.nodeType) {
|
|
2398
|
-
|
|
2399
|
-
// TEXT
|
|
2400
|
-
case 3:
|
|
2401
|
-
|
|
2402
|
-
// replace special XML characters
|
|
2403
|
-
output.push(escape$1(node.textContent, TEXT_ENTITIES));
|
|
2404
|
-
break;
|
|
2405
|
-
|
|
2406
|
-
// ELEMENT
|
|
2407
|
-
case 1:
|
|
2408
|
-
output.push('<', node.tagName);
|
|
2409
|
-
|
|
2410
|
-
if (node.hasAttributes()) {
|
|
2411
|
-
attrMap = node.attributes;
|
|
2412
|
-
for (i = 0, len = attrMap.length; i < len; ++i) {
|
|
2413
|
-
attrNode = attrMap.item(i);
|
|
2414
|
-
output.push(' ', attrNode.name, '="', escape$1(attrNode.value, ATTR_ENTITIES), '"');
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
if (node.hasChildNodes()) {
|
|
2419
|
-
output.push('>');
|
|
2420
|
-
childNodes = node.childNodes;
|
|
2421
|
-
for (i = 0, len = childNodes.length; i < len; ++i) {
|
|
2422
|
-
serialize(childNodes.item(i), output);
|
|
2423
|
-
}
|
|
2424
|
-
output.push('</', node.tagName, '>');
|
|
2425
|
-
} else {
|
|
2426
|
-
output.push('/>');
|
|
2427
|
-
}
|
|
2428
|
-
break;
|
|
2429
|
-
|
|
2430
|
-
// COMMENT
|
|
2431
|
-
case 8:
|
|
2432
|
-
output.push('<!--', escape$1(node.nodeValue, TEXT_ENTITIES), '-->');
|
|
2433
|
-
break;
|
|
2434
|
-
|
|
2435
|
-
// CDATA
|
|
2436
|
-
case 4:
|
|
2437
|
-
output.push('<![CDATA[', node.nodeValue, ']]>');
|
|
2438
|
-
break;
|
|
2439
|
-
|
|
2440
|
-
default:
|
|
2441
|
-
throw new Error('unable to handle node ' + node.nodeType);
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
return output;
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2447
|
-
/**
|
|
2448
|
-
* innerHTML like functionality for SVG elements.
|
|
2449
|
-
* based on innerSVG (https://code.google.com/p/innersvg)
|
|
2450
|
-
*/
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
function set(element, svg) {
|
|
2454
|
-
|
|
2455
|
-
var parsed = parse$1(svg);
|
|
2456
|
-
|
|
2457
|
-
// clear element contents
|
|
2458
|
-
clear(element);
|
|
2459
|
-
|
|
2460
|
-
if (!svg) {
|
|
2461
|
-
return;
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
if (!isFragment(parsed)) {
|
|
2465
|
-
|
|
2466
|
-
// extract <svg> from parsed document
|
|
2467
|
-
parsed = parsed.documentElement;
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
var nodes = slice$1(parsed.childNodes);
|
|
2471
|
-
|
|
2472
|
-
// import + append each node
|
|
2473
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
2474
|
-
appendTo$1(nodes[i], element);
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2477
|
-
}
|
|
2478
|
-
|
|
2479
|
-
function get(element) {
|
|
2480
|
-
var child = element.firstChild,
|
|
2481
|
-
output = [];
|
|
2482
|
-
|
|
2483
|
-
while (child) {
|
|
2484
|
-
serialize(child, output);
|
|
2485
|
-
child = child.nextSibling;
|
|
2486
|
-
}
|
|
2487
|
-
|
|
2488
|
-
return output.join('');
|
|
2489
|
-
}
|
|
2490
|
-
|
|
2491
|
-
function isFragment(node) {
|
|
2492
|
-
return node.nodeName === '#document-fragment';
|
|
2493
|
-
}
|
|
2494
|
-
|
|
2495
|
-
function innerSVG(element, svg) {
|
|
2496
|
-
|
|
2497
|
-
if (svg !== undefined) {
|
|
2498
|
-
|
|
2499
|
-
try {
|
|
2500
|
-
set(element, svg);
|
|
2501
|
-
} catch (e) {
|
|
2502
|
-
throw new Error('error parsing SVG: ' + e.message);
|
|
2503
|
-
}
|
|
2504
|
-
|
|
2505
|
-
return element;
|
|
2506
|
-
} else {
|
|
2507
|
-
return get(element);
|
|
2508
|
-
}
|
|
2509
|
-
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
function slice$1(arr) {
|
|
2513
|
-
return Array.prototype.slice.call(arr);
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
/**
|
|
2517
|
-
* @param {<SVGElement>} element
|
|
2518
|
-
* @param {number} x
|
|
2519
|
-
* @param {number} y
|
|
2520
|
-
* @param {number} angle
|
|
2521
|
-
* @param {number} amount
|
|
2522
|
-
*/
|
|
2523
|
-
function transform(gfx, x, y, angle, amount) {
|
|
2524
|
-
var translate = createTransform();
|
|
2525
|
-
translate.setTranslate(x, y);
|
|
2526
|
-
|
|
2527
|
-
var rotate = createTransform();
|
|
2528
|
-
rotate.setRotate(angle || 0, 0, 0);
|
|
2529
|
-
|
|
2530
|
-
var scale = createTransform();
|
|
2531
|
-
scale.setScale(amount || 1, amount || 1);
|
|
2532
|
-
|
|
2533
|
-
transform$1(gfx, [ translate, rotate, scale ]);
|
|
2534
|
-
}
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
/**
|
|
2538
|
-
* @param {SVGElement} element
|
|
2539
|
-
* @param {number} x
|
|
2540
|
-
* @param {number} y
|
|
2541
|
-
*/
|
|
2542
|
-
function translate$1(gfx, x, y) {
|
|
2543
|
-
var translate = createTransform();
|
|
2544
|
-
translate.setTranslate(x, y);
|
|
2545
|
-
|
|
2546
|
-
transform$1(gfx, translate);
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
/**
|
|
2551
|
-
* @param {SVGElement} element
|
|
2552
|
-
* @param {number} angle
|
|
2553
|
-
*/
|
|
2554
|
-
function rotate(gfx, angle) {
|
|
2555
|
-
var rotate = createTransform();
|
|
2556
|
-
rotate.setRotate(angle, 0, 0);
|
|
2557
|
-
|
|
2558
|
-
transform$1(gfx, rotate);
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
function createCommonjsModule(fn, module) {
|
|
2562
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
2139
|
+
function createCommonjsModule(fn, module) {
|
|
2140
|
+
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
2563
2141
|
}
|
|
2564
2142
|
|
|
2565
2143
|
var hat_1 = createCommonjsModule(function (module) {
|
|
@@ -2765,11 +2343,11 @@
|
|
|
2765
2343
|
attrs.strokeDasharray = [ 10000, 1 ];
|
|
2766
2344
|
}
|
|
2767
2345
|
|
|
2768
|
-
var marker = create$
|
|
2346
|
+
var marker = create$1('marker');
|
|
2769
2347
|
|
|
2770
2348
|
attr$1(options.element, attrs);
|
|
2771
2349
|
|
|
2772
|
-
append
|
|
2350
|
+
append(marker, options.element);
|
|
2773
2351
|
|
|
2774
2352
|
attr$1(marker, {
|
|
2775
2353
|
id: id,
|
|
@@ -2784,12 +2362,12 @@
|
|
|
2784
2362
|
var defs = query('defs', canvas._svg);
|
|
2785
2363
|
|
|
2786
2364
|
if (!defs) {
|
|
2787
|
-
defs = create$
|
|
2365
|
+
defs = create$1('defs');
|
|
2788
2366
|
|
|
2789
|
-
append
|
|
2367
|
+
append(canvas._svg, defs);
|
|
2790
2368
|
}
|
|
2791
2369
|
|
|
2792
|
-
append
|
|
2370
|
+
append(defs, marker);
|
|
2793
2371
|
|
|
2794
2372
|
markers[id] = marker;
|
|
2795
2373
|
}
|
|
@@ -2813,7 +2391,7 @@
|
|
|
2813
2391
|
function createMarker(id, type, fill, stroke) {
|
|
2814
2392
|
|
|
2815
2393
|
if (type === 'sequenceflow-end') {
|
|
2816
|
-
var sequenceflowEnd = create$
|
|
2394
|
+
var sequenceflowEnd = create$1('path');
|
|
2817
2395
|
attr$1(sequenceflowEnd, { d: 'M 1 5 L 11 10 L 1 15 Z' });
|
|
2818
2396
|
|
|
2819
2397
|
addMarker(id, {
|
|
@@ -2828,7 +2406,7 @@
|
|
|
2828
2406
|
}
|
|
2829
2407
|
|
|
2830
2408
|
if (type === 'messageflow-start') {
|
|
2831
|
-
var messageflowStart = create$
|
|
2409
|
+
var messageflowStart = create$1('circle');
|
|
2832
2410
|
attr$1(messageflowStart, { cx: 6, cy: 6, r: 3.5 });
|
|
2833
2411
|
|
|
2834
2412
|
addMarker(id, {
|
|
@@ -2842,7 +2420,7 @@
|
|
|
2842
2420
|
}
|
|
2843
2421
|
|
|
2844
2422
|
if (type === 'messageflow-end') {
|
|
2845
|
-
var messageflowEnd = create$
|
|
2423
|
+
var messageflowEnd = create$1('path');
|
|
2846
2424
|
attr$1(messageflowEnd, { d: 'm 1 5 l 0 -3 l 7 3 l -7 3 z' });
|
|
2847
2425
|
|
|
2848
2426
|
addMarker(id, {
|
|
@@ -2857,7 +2435,7 @@
|
|
|
2857
2435
|
}
|
|
2858
2436
|
|
|
2859
2437
|
if (type === 'association-start') {
|
|
2860
|
-
var associationStart = create$
|
|
2438
|
+
var associationStart = create$1('path');
|
|
2861
2439
|
attr$1(associationStart, { d: 'M 11 5 L 1 10 L 11 15' });
|
|
2862
2440
|
|
|
2863
2441
|
addMarker(id, {
|
|
@@ -2873,7 +2451,7 @@
|
|
|
2873
2451
|
}
|
|
2874
2452
|
|
|
2875
2453
|
if (type === 'association-end') {
|
|
2876
|
-
var associationEnd = create$
|
|
2454
|
+
var associationEnd = create$1('path');
|
|
2877
2455
|
attr$1(associationEnd, { d: 'M 1 5 L 11 10 L 1 15' });
|
|
2878
2456
|
|
|
2879
2457
|
addMarker(id, {
|
|
@@ -2889,7 +2467,7 @@
|
|
|
2889
2467
|
}
|
|
2890
2468
|
|
|
2891
2469
|
if (type === 'conditional-flow-marker') {
|
|
2892
|
-
var conditionalflowMarker = create$
|
|
2470
|
+
var conditionalflowMarker = create$1('path');
|
|
2893
2471
|
attr$1(conditionalflowMarker, { d: 'M 0 10 L 8 6 L 16 10 L 8 14 Z' });
|
|
2894
2472
|
|
|
2895
2473
|
addMarker(id, {
|
|
@@ -2904,7 +2482,7 @@
|
|
|
2904
2482
|
}
|
|
2905
2483
|
|
|
2906
2484
|
if (type === 'conditional-default-flow-marker') {
|
|
2907
|
-
var conditionaldefaultflowMarker = create$
|
|
2485
|
+
var conditionaldefaultflowMarker = create$1('path');
|
|
2908
2486
|
attr$1(conditionaldefaultflowMarker, { d: 'M 6 4 L 10 16' });
|
|
2909
2487
|
|
|
2910
2488
|
addMarker(id, {
|
|
@@ -2940,7 +2518,7 @@
|
|
|
2940
2518
|
var cx = width / 2,
|
|
2941
2519
|
cy = height / 2;
|
|
2942
2520
|
|
|
2943
|
-
var circle = create$
|
|
2521
|
+
var circle = create$1('circle');
|
|
2944
2522
|
attr$1(circle, {
|
|
2945
2523
|
cx: cx,
|
|
2946
2524
|
cy: cy,
|
|
@@ -2948,7 +2526,7 @@
|
|
|
2948
2526
|
});
|
|
2949
2527
|
attr$1(circle, attrs);
|
|
2950
2528
|
|
|
2951
|
-
append
|
|
2529
|
+
append(parentGfx, circle);
|
|
2952
2530
|
|
|
2953
2531
|
return circle;
|
|
2954
2532
|
}
|
|
@@ -2968,7 +2546,7 @@
|
|
|
2968
2546
|
fill: 'white'
|
|
2969
2547
|
});
|
|
2970
2548
|
|
|
2971
|
-
var rect = create$
|
|
2549
|
+
var rect = create$1('rect');
|
|
2972
2550
|
attr$1(rect, {
|
|
2973
2551
|
x: offset,
|
|
2974
2552
|
y: offset,
|
|
@@ -2979,7 +2557,7 @@
|
|
|
2979
2557
|
});
|
|
2980
2558
|
attr$1(rect, attrs);
|
|
2981
2559
|
|
|
2982
|
-
append
|
|
2560
|
+
append(parentGfx, rect);
|
|
2983
2561
|
|
|
2984
2562
|
return rect;
|
|
2985
2563
|
}
|
|
@@ -3001,13 +2579,13 @@
|
|
|
3001
2579
|
fill: 'white'
|
|
3002
2580
|
});
|
|
3003
2581
|
|
|
3004
|
-
var polygon = create$
|
|
2582
|
+
var polygon = create$1('polygon');
|
|
3005
2583
|
attr$1(polygon, {
|
|
3006
2584
|
points: pointsString
|
|
3007
2585
|
});
|
|
3008
2586
|
attr$1(polygon, attrs);
|
|
3009
2587
|
|
|
3010
|
-
append
|
|
2588
|
+
append(parentGfx, polygon);
|
|
3011
2589
|
|
|
3012
2590
|
return polygon;
|
|
3013
2591
|
}
|
|
@@ -3021,7 +2599,7 @@
|
|
|
3021
2599
|
|
|
3022
2600
|
var line = createLine(waypoints, attrs);
|
|
3023
2601
|
|
|
3024
|
-
append
|
|
2602
|
+
append(parentGfx, line);
|
|
3025
2603
|
|
|
3026
2604
|
return line;
|
|
3027
2605
|
}
|
|
@@ -3033,11 +2611,11 @@
|
|
|
3033
2611
|
stroke: black
|
|
3034
2612
|
});
|
|
3035
2613
|
|
|
3036
|
-
var path = create$
|
|
2614
|
+
var path = create$1('path');
|
|
3037
2615
|
attr$1(path, { d: d });
|
|
3038
2616
|
attr$1(path, attrs);
|
|
3039
2617
|
|
|
3040
|
-
append
|
|
2618
|
+
append(parentGfx, path);
|
|
3041
2619
|
|
|
3042
2620
|
return path;
|
|
3043
2621
|
}
|
|
@@ -3123,9 +2701,9 @@
|
|
|
3123
2701
|
|
|
3124
2702
|
var text = textRenderer.createText(label || '', options);
|
|
3125
2703
|
|
|
3126
|
-
classes(text).add('djs-label');
|
|
2704
|
+
classes$1(text).add('djs-label');
|
|
3127
2705
|
|
|
3128
|
-
append
|
|
2706
|
+
append(parentGfx, text);
|
|
3129
2707
|
|
|
3130
2708
|
return text;
|
|
3131
2709
|
}
|
|
@@ -4768,9 +4346,9 @@
|
|
|
4768
4346
|
var helperSvg = document.getElementById('helper-svg');
|
|
4769
4347
|
|
|
4770
4348
|
if (!helperSvg) {
|
|
4771
|
-
helperSvg = create$
|
|
4349
|
+
helperSvg = create$1('svg');
|
|
4772
4350
|
|
|
4773
|
-
attr$
|
|
4351
|
+
attr$1(helperSvg, {
|
|
4774
4352
|
id: 'helper-svg'
|
|
4775
4353
|
});
|
|
4776
4354
|
|
|
@@ -4864,13 +4442,13 @@
|
|
|
4864
4442
|
var maxWidth = box.width - padding.left - padding.right;
|
|
4865
4443
|
|
|
4866
4444
|
// ensure correct rendering by attaching helper text node to invisible SVG
|
|
4867
|
-
var helperText = create$
|
|
4868
|
-
attr$
|
|
4869
|
-
attr$
|
|
4445
|
+
var helperText = create$1('text');
|
|
4446
|
+
attr$1(helperText, { x: 0, y: 0 });
|
|
4447
|
+
attr$1(helperText, style);
|
|
4870
4448
|
|
|
4871
4449
|
var helperSvg = getHelperSvg();
|
|
4872
4450
|
|
|
4873
|
-
append
|
|
4451
|
+
append(helperSvg, helperText);
|
|
4874
4452
|
|
|
4875
4453
|
while (lines.length) {
|
|
4876
4454
|
layouted.push(layoutNext(lines, maxWidth, helperText));
|
|
@@ -4899,9 +4477,9 @@
|
|
|
4899
4477
|
y -= (lineHeight || layouted[0].height) / 4;
|
|
4900
4478
|
|
|
4901
4479
|
|
|
4902
|
-
var textElement = create$
|
|
4480
|
+
var textElement = create$1('text');
|
|
4903
4481
|
|
|
4904
|
-
attr$
|
|
4482
|
+
attr$1(textElement, style);
|
|
4905
4483
|
|
|
4906
4484
|
// layout each line taking into account that parent
|
|
4907
4485
|
// shape might resize to fit text size
|
|
@@ -4928,15 +4506,15 @@
|
|
|
4928
4506
|
- line.width) / 2 + padding.left), 0);
|
|
4929
4507
|
}
|
|
4930
4508
|
|
|
4931
|
-
var tspan = create$
|
|
4932
|
-
attr$
|
|
4509
|
+
var tspan = create$1('tspan');
|
|
4510
|
+
attr$1(tspan, { x: x, y: y });
|
|
4933
4511
|
|
|
4934
4512
|
tspan.textContent = line.text;
|
|
4935
4513
|
|
|
4936
|
-
append
|
|
4514
|
+
append(textElement, tspan);
|
|
4937
4515
|
});
|
|
4938
4516
|
|
|
4939
|
-
remove$
|
|
4517
|
+
remove$2(helperText);
|
|
4940
4518
|
|
|
4941
4519
|
var dimensions = {
|
|
4942
4520
|
width: maxLineWidth,
|
|
@@ -6511,13 +6089,13 @@
|
|
|
6511
6089
|
throw new Error('invalid hit type <' + type + '>');
|
|
6512
6090
|
}
|
|
6513
6091
|
|
|
6514
|
-
attr$
|
|
6092
|
+
attr$1(hit, attrs);
|
|
6515
6093
|
|
|
6516
6094
|
return hit;
|
|
6517
6095
|
}
|
|
6518
6096
|
|
|
6519
6097
|
function appendHit(gfx, hit) {
|
|
6520
|
-
append
|
|
6098
|
+
append(gfx, hit);
|
|
6521
6099
|
}
|
|
6522
6100
|
|
|
6523
6101
|
|
|
@@ -6531,7 +6109,7 @@
|
|
|
6531
6109
|
this.removeHits = function(gfx) {
|
|
6532
6110
|
var hits = all('.djs-hit', gfx);
|
|
6533
6111
|
|
|
6534
|
-
forEach$1(hits, remove$
|
|
6112
|
+
forEach$1(hits, remove$2);
|
|
6535
6113
|
};
|
|
6536
6114
|
|
|
6537
6115
|
/**
|
|
@@ -6595,11 +6173,11 @@
|
|
|
6595
6173
|
y: 0
|
|
6596
6174
|
}, attrs);
|
|
6597
6175
|
|
|
6598
|
-
var hit = create$
|
|
6176
|
+
var hit = create$1('rect');
|
|
6599
6177
|
|
|
6600
6178
|
applyStyle(hit, type);
|
|
6601
6179
|
|
|
6602
|
-
attr$
|
|
6180
|
+
attr$1(hit, attrs);
|
|
6603
6181
|
|
|
6604
6182
|
appendHit(gfx, hit);
|
|
6605
6183
|
|
|
@@ -6625,7 +6203,7 @@
|
|
|
6625
6203
|
if (element.waypoints) {
|
|
6626
6204
|
updateLine(hit, element.waypoints);
|
|
6627
6205
|
} else {
|
|
6628
|
-
attr$
|
|
6206
|
+
attr$1(hit, {
|
|
6629
6207
|
width: element.width,
|
|
6630
6208
|
height: element.height
|
|
6631
6209
|
});
|
|
@@ -6833,9 +6411,9 @@
|
|
|
6833
6411
|
var self = this;
|
|
6834
6412
|
|
|
6835
6413
|
function createOutline(gfx, bounds) {
|
|
6836
|
-
var outline = create$
|
|
6414
|
+
var outline = create$1('rect');
|
|
6837
6415
|
|
|
6838
|
-
attr$
|
|
6416
|
+
attr$1(outline, assign$1({
|
|
6839
6417
|
x: 10,
|
|
6840
6418
|
y: 10,
|
|
6841
6419
|
rx: 3,
|
|
@@ -6843,7 +6421,7 @@
|
|
|
6843
6421
|
height: 100
|
|
6844
6422
|
}, OUTLINE_STYLE));
|
|
6845
6423
|
|
|
6846
|
-
append
|
|
6424
|
+
append(gfx, outline);
|
|
6847
6425
|
|
|
6848
6426
|
return outline;
|
|
6849
6427
|
}
|
|
@@ -6887,7 +6465,7 @@
|
|
|
6887
6465
|
*/
|
|
6888
6466
|
Outline.prototype.updateShapeOutline = function(outline, element) {
|
|
6889
6467
|
|
|
6890
|
-
attr$
|
|
6468
|
+
attr$1(outline, {
|
|
6891
6469
|
x: -this.offset,
|
|
6892
6470
|
y: -this.offset,
|
|
6893
6471
|
width: element.width + this.offset * 2,
|
|
@@ -6908,7 +6486,7 @@
|
|
|
6908
6486
|
|
|
6909
6487
|
var bbox = getBBox(connection);
|
|
6910
6488
|
|
|
6911
|
-
attr$
|
|
6489
|
+
attr$1(outline, {
|
|
6912
6490
|
x: bbox.x - this.offset,
|
|
6913
6491
|
y: bbox.y - this.offset,
|
|
6914
6492
|
width: bbox.width + this.offset * 2,
|
|
@@ -7112,13 +6690,13 @@
|
|
|
7112
6690
|
SelectionVisuals.prototype._updateSelectionOutline = function(selection) {
|
|
7113
6691
|
var layer = this._canvas.getLayer('selectionOutline');
|
|
7114
6692
|
|
|
7115
|
-
clear$
|
|
6693
|
+
clear$1(layer);
|
|
7116
6694
|
|
|
7117
6695
|
var enabled = selection.length > 1;
|
|
7118
6696
|
|
|
7119
6697
|
var container = this._canvas.getContainer();
|
|
7120
6698
|
|
|
7121
|
-
classes$
|
|
6699
|
+
classes$1(container)[enabled ? 'add' : 'remove']('djs-multi-select');
|
|
7122
6700
|
|
|
7123
6701
|
if (!enabled) {
|
|
7124
6702
|
return;
|
|
@@ -7126,15 +6704,15 @@
|
|
|
7126
6704
|
|
|
7127
6705
|
var bBox = addSelectionOutlinePadding(getBBox(selection));
|
|
7128
6706
|
|
|
7129
|
-
var rect = create$
|
|
6707
|
+
var rect = create$1('rect');
|
|
7130
6708
|
|
|
7131
|
-
attr$
|
|
6709
|
+
attr$1(rect, assign$1({
|
|
7132
6710
|
rx: 3
|
|
7133
6711
|
}, bBox));
|
|
7134
6712
|
|
|
7135
|
-
classes$
|
|
6713
|
+
classes$1(rect).add('djs-selection-outline');
|
|
7136
6714
|
|
|
7137
|
-
append
|
|
6715
|
+
append(layer, rect);
|
|
7138
6716
|
};
|
|
7139
6717
|
|
|
7140
6718
|
// helpers //////////
|
|
@@ -7543,8 +7121,8 @@
|
|
|
7543
7121
|
var container = self._getOverlayContainer(overlay.element, true);
|
|
7544
7122
|
|
|
7545
7123
|
if (overlay) {
|
|
7546
|
-
remove$
|
|
7547
|
-
remove$
|
|
7124
|
+
remove$1(overlay.html);
|
|
7125
|
+
remove$1(overlay.htmlContainer);
|
|
7548
7126
|
|
|
7549
7127
|
delete overlay.htmlContainer;
|
|
7550
7128
|
delete overlay.element;
|
|
@@ -7577,7 +7155,7 @@
|
|
|
7577
7155
|
|
|
7578
7156
|
this._overlayContainers = [];
|
|
7579
7157
|
|
|
7580
|
-
clear
|
|
7158
|
+
clear(this._overlayRoot);
|
|
7581
7159
|
};
|
|
7582
7160
|
|
|
7583
7161
|
Overlays.prototype._updateOverlayContainer = function(container) {
|
|
@@ -7598,7 +7176,7 @@
|
|
|
7598
7176
|
|
|
7599
7177
|
setPosition(html, x, y);
|
|
7600
7178
|
|
|
7601
|
-
attr
|
|
7179
|
+
attr(container.html, 'data-container-id', element.id);
|
|
7602
7180
|
};
|
|
7603
7181
|
|
|
7604
7182
|
|
|
@@ -7725,7 +7303,7 @@
|
|
|
7725
7303
|
htmlContainer.appendChild(html);
|
|
7726
7304
|
|
|
7727
7305
|
if (overlay.type) {
|
|
7728
|
-
classes
|
|
7306
|
+
classes(htmlContainer).add('djs-overlay-' + overlay.type);
|
|
7729
7307
|
}
|
|
7730
7308
|
|
|
7731
7309
|
var elementRoot = this._canvas.findRoot(element);
|
|
@@ -7854,7 +7432,7 @@
|
|
|
7854
7432
|
var container = self._getOverlayContainer(element);
|
|
7855
7433
|
|
|
7856
7434
|
if (container) {
|
|
7857
|
-
remove$
|
|
7435
|
+
remove$1(container.html);
|
|
7858
7436
|
var i = self._overlayContainers.indexOf(container);
|
|
7859
7437
|
if (i !== -1) {
|
|
7860
7438
|
self._overlayContainers.splice(i, 1);
|
|
@@ -7885,7 +7463,7 @@
|
|
|
7885
7463
|
eventBus.on('element.marker.update', function(e) {
|
|
7886
7464
|
var container = self._getOverlayContainer(e.element, true);
|
|
7887
7465
|
if (container) {
|
|
7888
|
-
classes
|
|
7466
|
+
classes(container.html)[e.add ? 'add' : 'remove'](e.marker);
|
|
7889
7467
|
}
|
|
7890
7468
|
});
|
|
7891
7469
|
|
|
@@ -8350,7 +7928,7 @@
|
|
|
8350
7928
|
function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays, canvas) {
|
|
8351
7929
|
var breadcrumbs = domify$1('<ul class="bjs-breadcrumbs"></ul>');
|
|
8352
7930
|
var container = canvas.getContainer();
|
|
8353
|
-
var containerClasses = classes
|
|
7931
|
+
var containerClasses = classes(container);
|
|
8354
7932
|
container.appendChild(breadcrumbs);
|
|
8355
7933
|
|
|
8356
7934
|
var boParents = [];
|
|
@@ -8906,7 +8484,7 @@
|
|
|
8906
8484
|
}
|
|
8907
8485
|
|
|
8908
8486
|
var hasContent = bo && bo.flowElements && bo.flowElements.length;
|
|
8909
|
-
classes
|
|
8487
|
+
classes(overlay.html).toggle(EMPTY_MARKER, !hasContent);
|
|
8910
8488
|
};
|
|
8911
8489
|
|
|
8912
8490
|
/**
|
|
@@ -9458,9 +9036,9 @@
|
|
|
9458
9036
|
};
|
|
9459
9037
|
|
|
9460
9038
|
DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
|
|
9461
|
-
var rect = create$
|
|
9039
|
+
var rect = create$1('rect');
|
|
9462
9040
|
|
|
9463
|
-
attr$
|
|
9041
|
+
attr$1(rect, {
|
|
9464
9042
|
x: 0,
|
|
9465
9043
|
y: 0,
|
|
9466
9044
|
width: element.width || 0,
|
|
@@ -9468,12 +9046,12 @@
|
|
|
9468
9046
|
});
|
|
9469
9047
|
|
|
9470
9048
|
if (isFrameElement(element)) {
|
|
9471
|
-
attr$
|
|
9049
|
+
attr$1(rect, assign$1({}, this.FRAME_STYLE, attrs || {}));
|
|
9472
9050
|
} else {
|
|
9473
|
-
attr$
|
|
9051
|
+
attr$1(rect, assign$1({}, this.SHAPE_STYLE, attrs || {}));
|
|
9474
9052
|
}
|
|
9475
9053
|
|
|
9476
|
-
append
|
|
9054
|
+
append(visuals, rect);
|
|
9477
9055
|
|
|
9478
9056
|
return rect;
|
|
9479
9057
|
};
|
|
@@ -9481,7 +9059,7 @@
|
|
|
9481
9059
|
DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
|
|
9482
9060
|
|
|
9483
9061
|
var line = createLine(connection.waypoints, assign$1({}, this.CONNECTION_STYLE, attrs || {}));
|
|
9484
|
-
append
|
|
9062
|
+
append(visuals, line);
|
|
9485
9063
|
|
|
9486
9064
|
return line;
|
|
9487
9065
|
};
|
|
@@ -9704,7 +9282,7 @@
|
|
|
9704
9282
|
// this way we can always get the correct container size
|
|
9705
9283
|
// (this is impossible for <svg> elements at the moment)
|
|
9706
9284
|
const parent = document.createElement('div');
|
|
9707
|
-
parent.setAttribute('class', 'djs-container');
|
|
9285
|
+
parent.setAttribute('class', 'djs-container djs-parent');
|
|
9708
9286
|
|
|
9709
9287
|
assign(parent, {
|
|
9710
9288
|
position: 'relative',
|
|
@@ -9719,8 +9297,8 @@
|
|
|
9719
9297
|
}
|
|
9720
9298
|
|
|
9721
9299
|
function createGroup(parent, cls, childIndex) {
|
|
9722
|
-
const group = create$
|
|
9723
|
-
classes$
|
|
9300
|
+
const group = create$1('g');
|
|
9301
|
+
classes$1(group).add(cls);
|
|
9724
9302
|
|
|
9725
9303
|
const index = childIndex !== undefined ? childIndex : parent.childNodes.length - 1;
|
|
9726
9304
|
|
|
@@ -9798,10 +9376,10 @@
|
|
|
9798
9376
|
// html container
|
|
9799
9377
|
const container = this._container = createContainer(config);
|
|
9800
9378
|
|
|
9801
|
-
const svg = this._svg = create$
|
|
9802
|
-
attr$
|
|
9379
|
+
const svg = this._svg = create$1('svg');
|
|
9380
|
+
attr$1(svg, { width: '100%', height: '100%' });
|
|
9803
9381
|
|
|
9804
|
-
append
|
|
9382
|
+
append(container, svg);
|
|
9805
9383
|
|
|
9806
9384
|
const viewport = this._viewport = createGroup(svg, 'viewport');
|
|
9807
9385
|
|
|
@@ -10039,7 +9617,7 @@
|
|
|
10039
9617
|
return group;
|
|
10040
9618
|
}
|
|
10041
9619
|
|
|
10042
|
-
remove$
|
|
9620
|
+
remove$2(group);
|
|
10043
9621
|
|
|
10044
9622
|
layer.visible = false;
|
|
10045
9623
|
|
|
@@ -10054,7 +9632,7 @@
|
|
|
10054
9632
|
if (layer) {
|
|
10055
9633
|
delete this._layers[name];
|
|
10056
9634
|
|
|
10057
|
-
remove$
|
|
9635
|
+
remove$2(layer.group);
|
|
10058
9636
|
}
|
|
10059
9637
|
};
|
|
10060
9638
|
|
|
@@ -10147,9 +9725,9 @@
|
|
|
10147
9725
|
|
|
10148
9726
|
// invoke either addClass or removeClass based on mode
|
|
10149
9727
|
if (add) {
|
|
10150
|
-
classes$
|
|
9728
|
+
classes$1(gfx).add(marker);
|
|
10151
9729
|
} else {
|
|
10152
|
-
classes$
|
|
9730
|
+
classes$1(gfx).remove(marker);
|
|
10153
9731
|
}
|
|
10154
9732
|
}
|
|
10155
9733
|
});
|
|
@@ -10215,7 +9793,7 @@
|
|
|
10215
9793
|
|
|
10216
9794
|
const gfx = this.getGraphics(element);
|
|
10217
9795
|
|
|
10218
|
-
return classes$
|
|
9796
|
+
return classes$1(gfx).has(marker);
|
|
10219
9797
|
};
|
|
10220
9798
|
|
|
10221
9799
|
/**
|
|
@@ -11113,10 +10691,10 @@
|
|
|
11113
10691
|
this._validateId(id);
|
|
11114
10692
|
|
|
11115
10693
|
// associate dom node with element
|
|
11116
|
-
attr$
|
|
10694
|
+
attr$1(gfx, ELEMENT_ID, id);
|
|
11117
10695
|
|
|
11118
10696
|
if (secondaryGfx) {
|
|
11119
|
-
attr$
|
|
10697
|
+
attr$1(secondaryGfx, ELEMENT_ID, id);
|
|
11120
10698
|
}
|
|
11121
10699
|
|
|
11122
10700
|
this._elements[id] = { element: element, gfx: gfx, secondaryGfx: secondaryGfx };
|
|
@@ -11125,7 +10703,7 @@
|
|
|
11125
10703
|
/**
|
|
11126
10704
|
* Removes an element from the registry.
|
|
11127
10705
|
*
|
|
11128
|
-
* @param {djs.model.Base} element
|
|
10706
|
+
* @param {string|djs.model.Base} element
|
|
11129
10707
|
*/
|
|
11130
10708
|
ElementRegistry.prototype.remove = function(element) {
|
|
11131
10709
|
var elements = this._elements,
|
|
@@ -11135,10 +10713,10 @@
|
|
|
11135
10713
|
if (container) {
|
|
11136
10714
|
|
|
11137
10715
|
// unset element id on gfx
|
|
11138
|
-
attr$
|
|
10716
|
+
attr$1(container.gfx, ELEMENT_ID, '');
|
|
11139
10717
|
|
|
11140
10718
|
if (container.secondaryGfx) {
|
|
11141
|
-
attr$
|
|
10719
|
+
attr$1(container.secondaryGfx, ELEMENT_ID, '');
|
|
11142
10720
|
}
|
|
11143
10721
|
|
|
11144
10722
|
delete elements[id];
|
|
@@ -11148,7 +10726,7 @@
|
|
|
11148
10726
|
/**
|
|
11149
10727
|
* Update the id of an element
|
|
11150
10728
|
*
|
|
11151
|
-
* @param {djs.model.Base} element
|
|
10729
|
+
* @param {string|djs.model.Base} element
|
|
11152
10730
|
* @param {string} newId
|
|
11153
10731
|
*/
|
|
11154
10732
|
ElementRegistry.prototype.updateId = function(element, newId) {
|
|
@@ -11177,7 +10755,7 @@
|
|
|
11177
10755
|
/**
|
|
11178
10756
|
* Update the graphics of an element
|
|
11179
10757
|
*
|
|
11180
|
-
* @param {djs.model.Base} element
|
|
10758
|
+
* @param {string|djs.model.Base} element
|
|
11181
10759
|
* @param {SVGElement} gfx
|
|
11182
10760
|
* @param {boolean} [secondary=false] whether to update the secondary connected element
|
|
11183
10761
|
*/
|
|
@@ -11193,7 +10771,7 @@
|
|
|
11193
10771
|
}
|
|
11194
10772
|
|
|
11195
10773
|
if (gfx) {
|
|
11196
|
-
attr$
|
|
10774
|
+
attr$1(gfx, ELEMENT_ID, id);
|
|
11197
10775
|
}
|
|
11198
10776
|
|
|
11199
10777
|
return gfx;
|
|
@@ -11218,7 +10796,7 @@
|
|
|
11218
10796
|
if (typeof filter === 'string') {
|
|
11219
10797
|
id = filter;
|
|
11220
10798
|
} else {
|
|
11221
|
-
id = filter && attr$
|
|
10799
|
+
id = filter && attr$1(filter, ELEMENT_ID);
|
|
11222
10800
|
}
|
|
11223
10801
|
|
|
11224
10802
|
var container = this._elements[id];
|
|
@@ -11883,7 +11461,7 @@
|
|
|
11883
11461
|
*
|
|
11884
11462
|
* @return {Base} the new model instance
|
|
11885
11463
|
*/
|
|
11886
|
-
function create
|
|
11464
|
+
function create(type, attrs) {
|
|
11887
11465
|
var Type = types$7[type];
|
|
11888
11466
|
if (!Type) {
|
|
11889
11467
|
throw new Error('unknown type: <' + type + '>');
|
|
@@ -11931,7 +11509,7 @@
|
|
|
11931
11509
|
attrs.id = type + '_' + (this._uid++);
|
|
11932
11510
|
}
|
|
11933
11511
|
|
|
11934
|
-
return create
|
|
11512
|
+
return create(type, attrs);
|
|
11935
11513
|
};
|
|
11936
11514
|
|
|
11937
11515
|
var FN_REF = '__fn';
|
|
@@ -12501,10 +12079,10 @@
|
|
|
12501
12079
|
} else {
|
|
12502
12080
|
childrenGfx = getChildren(gfx);
|
|
12503
12081
|
if (!childrenGfx) {
|
|
12504
|
-
childrenGfx = create$
|
|
12505
|
-
classes$
|
|
12082
|
+
childrenGfx = create$1('g');
|
|
12083
|
+
classes$1(childrenGfx).add('djs-children');
|
|
12506
12084
|
|
|
12507
|
-
append
|
|
12085
|
+
append(gfx.parentNode, childrenGfx);
|
|
12508
12086
|
}
|
|
12509
12087
|
}
|
|
12510
12088
|
|
|
@@ -12518,7 +12096,7 @@
|
|
|
12518
12096
|
GraphicsFactory.prototype._clear = function(gfx) {
|
|
12519
12097
|
var visual = getVisual(gfx);
|
|
12520
12098
|
|
|
12521
|
-
clear
|
|
12099
|
+
clear(visual);
|
|
12522
12100
|
|
|
12523
12101
|
return visual;
|
|
12524
12102
|
};
|
|
@@ -12553,31 +12131,31 @@
|
|
|
12553
12131
|
GraphicsFactory.prototype._createContainer = function(
|
|
12554
12132
|
type, childrenGfx, parentIndex, isFrame
|
|
12555
12133
|
) {
|
|
12556
|
-
var outerGfx = create$
|
|
12557
|
-
classes$
|
|
12134
|
+
var outerGfx = create$1('g');
|
|
12135
|
+
classes$1(outerGfx).add('djs-group');
|
|
12558
12136
|
|
|
12559
12137
|
// insert node at position
|
|
12560
12138
|
if (typeof parentIndex !== 'undefined') {
|
|
12561
12139
|
prependTo(outerGfx, childrenGfx, childrenGfx.childNodes[parentIndex]);
|
|
12562
12140
|
} else {
|
|
12563
|
-
append
|
|
12141
|
+
append(childrenGfx, outerGfx);
|
|
12564
12142
|
}
|
|
12565
12143
|
|
|
12566
|
-
var gfx = create$
|
|
12567
|
-
classes$
|
|
12568
|
-
classes$
|
|
12144
|
+
var gfx = create$1('g');
|
|
12145
|
+
classes$1(gfx).add('djs-element');
|
|
12146
|
+
classes$1(gfx).add('djs-' + type);
|
|
12569
12147
|
|
|
12570
12148
|
if (isFrame) {
|
|
12571
|
-
classes$
|
|
12149
|
+
classes$1(gfx).add('djs-frame');
|
|
12572
12150
|
}
|
|
12573
12151
|
|
|
12574
|
-
append
|
|
12152
|
+
append(outerGfx, gfx);
|
|
12575
12153
|
|
|
12576
12154
|
// create visual
|
|
12577
|
-
var visual = create$
|
|
12578
|
-
classes$
|
|
12155
|
+
var visual = create$1('g');
|
|
12156
|
+
classes$1(visual).add('djs-visual');
|
|
12579
12157
|
|
|
12580
|
-
append
|
|
12158
|
+
append(gfx, visual);
|
|
12581
12159
|
|
|
12582
12160
|
return gfx;
|
|
12583
12161
|
};
|
|
@@ -12669,9 +12247,9 @@
|
|
|
12669
12247
|
}
|
|
12670
12248
|
|
|
12671
12249
|
if (element.hidden) {
|
|
12672
|
-
attr$
|
|
12250
|
+
attr$1(gfx, 'display', 'none');
|
|
12673
12251
|
} else {
|
|
12674
|
-
attr$
|
|
12252
|
+
attr$1(gfx, 'display', 'block');
|
|
12675
12253
|
}
|
|
12676
12254
|
};
|
|
12677
12255
|
|
|
@@ -12679,7 +12257,7 @@
|
|
|
12679
12257
|
var gfx = this._elementRegistry.getGraphics(element);
|
|
12680
12258
|
|
|
12681
12259
|
// remove
|
|
12682
|
-
remove$
|
|
12260
|
+
remove$2(gfx.parentNode);
|
|
12683
12261
|
};
|
|
12684
12262
|
|
|
12685
12263
|
|
|
@@ -21355,903 +20933,640 @@
|
|
|
21355
20933
|
definitions: definitions,
|
|
21356
20934
|
elementsById: elementsById,
|
|
21357
20935
|
references: references,
|
|
21358
|
-
warnings: aggregatedWarnings
|
|
21359
|
-
})) || definitions;
|
|
21360
|
-
|
|
21361
|
-
const importResult = await this.importDefinitions(definitions, bpmnDiagram);
|
|
21362
|
-
|
|
21363
|
-
aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
|
|
21364
|
-
|
|
21365
|
-
this._emit('import.done', { error: null, warnings: aggregatedWarnings });
|
|
21366
|
-
|
|
21367
|
-
return { warnings: aggregatedWarnings };
|
|
21368
|
-
} catch (err) {
|
|
21369
|
-
let error = err;
|
|
21370
|
-
aggregatedWarnings = aggregatedWarnings.concat(error.warnings || []);
|
|
21371
|
-
addWarningsToError(error, aggregatedWarnings);
|
|
21372
|
-
|
|
21373
|
-
error = checkValidationError(error);
|
|
21374
|
-
|
|
21375
|
-
this._emit('import.done', { error, warnings: error.warnings });
|
|
21376
|
-
|
|
21377
|
-
throw error;
|
|
21378
|
-
}
|
|
21379
|
-
});
|
|
21380
|
-
|
|
21381
|
-
/**
|
|
21382
|
-
* The importDefinitions result.
|
|
21383
|
-
*
|
|
21384
|
-
* @typedef {Object} ImportDefinitionsResult
|
|
21385
|
-
*
|
|
21386
|
-
* @property {Array<string>} warnings
|
|
21387
|
-
*/
|
|
21388
|
-
|
|
21389
|
-
/**
|
|
21390
|
-
* The importDefinitions error.
|
|
21391
|
-
*
|
|
21392
|
-
* @typedef {Error} ImportDefinitionsError
|
|
21393
|
-
*
|
|
21394
|
-
* @property {Array<string>} warnings
|
|
21395
|
-
*/
|
|
21396
|
-
|
|
21397
|
-
/**
|
|
21398
|
-
* Import parsed definitions and render a BPMN 2.0 diagram.
|
|
21399
|
-
*
|
|
21400
|
-
* Once finished the viewer reports back the result to the
|
|
21401
|
-
* provided callback function with (err, warnings).
|
|
21402
|
-
*
|
|
21403
|
-
* ## Life-Cycle Events
|
|
21404
|
-
*
|
|
21405
|
-
* During import the viewer will fire life-cycle events:
|
|
21406
|
-
*
|
|
21407
|
-
* * import.render.start (graphical import start)
|
|
21408
|
-
* * import.render.complete (graphical import finished)
|
|
21409
|
-
*
|
|
21410
|
-
* You can use these events to hook into the life-cycle.
|
|
21411
|
-
*
|
|
21412
|
-
* @param {ModdleElement<Definitions>} definitions parsed BPMN 2.0 definitions
|
|
21413
|
-
* @param {ModdleElement<BPMNDiagram>|string} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
|
|
21414
|
-
*
|
|
21415
|
-
* Returns {Promise<ImportDefinitionsResult, ImportDefinitionsError>}
|
|
21416
|
-
*/
|
|
21417
|
-
BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
|
|
21418
|
-
this._setDefinitions(definitions);
|
|
21419
|
-
const result = await this.open(bpmnDiagram);
|
|
21420
|
-
|
|
21421
|
-
return { warnings: result.warnings };
|
|
21422
|
-
});
|
|
21423
|
-
|
|
21424
|
-
/**
|
|
21425
|
-
* The open result.
|
|
21426
|
-
*
|
|
21427
|
-
* @typedef {Object} OpenResult
|
|
21428
|
-
*
|
|
21429
|
-
* @property {Array<string>} warnings
|
|
21430
|
-
*/
|
|
21431
|
-
|
|
21432
|
-
/**
|
|
21433
|
-
* The open error.
|
|
21434
|
-
*
|
|
21435
|
-
* @typedef {Error} OpenError
|
|
21436
|
-
*
|
|
21437
|
-
* @property {Array<string>} warnings
|
|
21438
|
-
*/
|
|
21439
|
-
|
|
21440
|
-
/**
|
|
21441
|
-
* Open diagram of previously imported XML.
|
|
21442
|
-
*
|
|
21443
|
-
* Once finished the viewer reports back the result to the
|
|
21444
|
-
* provided callback function with (err, warnings).
|
|
21445
|
-
*
|
|
21446
|
-
* ## Life-Cycle Events
|
|
21447
|
-
*
|
|
21448
|
-
* During switch the viewer will fire life-cycle events:
|
|
21449
|
-
*
|
|
21450
|
-
* * import.render.start (graphical import start)
|
|
21451
|
-
* * import.render.complete (graphical import finished)
|
|
21452
|
-
*
|
|
21453
|
-
* You can use these events to hook into the life-cycle.
|
|
21454
|
-
*
|
|
21455
|
-
* @param {string|ModdleElement<BPMNDiagram>} [bpmnDiagramOrId] id or the diagram to open
|
|
21456
|
-
*
|
|
21457
|
-
* Returns {Promise<OpenResult, OpenError>}
|
|
21458
|
-
*/
|
|
21459
|
-
BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
|
|
21460
|
-
|
|
21461
|
-
const definitions = this._definitions;
|
|
21462
|
-
let bpmnDiagram = bpmnDiagramOrId;
|
|
21463
|
-
|
|
21464
|
-
if (!definitions) {
|
|
21465
|
-
const error = new Error('no XML imported');
|
|
21466
|
-
addWarningsToError(error, []);
|
|
21467
|
-
|
|
21468
|
-
throw error;
|
|
21469
|
-
}
|
|
21470
|
-
|
|
21471
|
-
if (typeof bpmnDiagramOrId === 'string') {
|
|
21472
|
-
bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
|
|
21473
|
-
|
|
21474
|
-
if (!bpmnDiagram) {
|
|
21475
|
-
const error = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
|
|
21476
|
-
addWarningsToError(error, []);
|
|
21477
|
-
|
|
21478
|
-
throw error;
|
|
21479
|
-
}
|
|
21480
|
-
}
|
|
21481
|
-
|
|
21482
|
-
// clear existing rendered diagram
|
|
21483
|
-
// catch synchronous exceptions during #clear()
|
|
21484
|
-
try {
|
|
21485
|
-
this.clear();
|
|
21486
|
-
} catch (error) {
|
|
21487
|
-
addWarningsToError(error, []);
|
|
21488
|
-
|
|
21489
|
-
throw error;
|
|
21490
|
-
}
|
|
21491
|
-
|
|
21492
|
-
// perform graphical import
|
|
21493
|
-
const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
|
|
21494
|
-
|
|
21495
|
-
return { warnings };
|
|
21496
|
-
});
|
|
21497
|
-
|
|
21498
|
-
/**
|
|
21499
|
-
* The saveXML result.
|
|
21500
|
-
*
|
|
21501
|
-
* @typedef {Object} SaveXMLResult
|
|
21502
|
-
*
|
|
21503
|
-
* @property {string} xml
|
|
21504
|
-
*/
|
|
21505
|
-
|
|
21506
|
-
/**
|
|
21507
|
-
* Export the currently displayed BPMN 2.0 diagram as
|
|
21508
|
-
* a BPMN 2.0 XML document.
|
|
21509
|
-
*
|
|
21510
|
-
* ## Life-Cycle Events
|
|
21511
|
-
*
|
|
21512
|
-
* During XML saving the viewer will fire life-cycle events:
|
|
21513
|
-
*
|
|
21514
|
-
* * saveXML.start (before serialization)
|
|
21515
|
-
* * saveXML.serialized (after xml generation)
|
|
21516
|
-
* * saveXML.done (everything done)
|
|
21517
|
-
*
|
|
21518
|
-
* You can use these events to hook into the life-cycle.
|
|
21519
|
-
*
|
|
21520
|
-
* @param {Object} [options] export options
|
|
21521
|
-
* @param {boolean} [options.format=false] output formatted XML
|
|
21522
|
-
* @param {boolean} [options.preamble=true] output preamble
|
|
21523
|
-
*
|
|
21524
|
-
* Returns {Promise<SaveXMLResult, Error>}
|
|
21525
|
-
*/
|
|
21526
|
-
BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
|
|
21527
|
-
|
|
21528
|
-
options = options || {};
|
|
21529
|
-
|
|
21530
|
-
let definitions = this._definitions,
|
|
21531
|
-
error, xml;
|
|
21532
|
-
|
|
21533
|
-
try {
|
|
21534
|
-
if (!definitions) {
|
|
21535
|
-
throw new Error('no definitions loaded');
|
|
21536
|
-
}
|
|
20936
|
+
warnings: aggregatedWarnings
|
|
20937
|
+
})) || definitions;
|
|
21537
20938
|
|
|
21538
|
-
|
|
21539
|
-
definitions = this._emit('saveXML.start', {
|
|
21540
|
-
definitions
|
|
21541
|
-
}) || definitions;
|
|
20939
|
+
const importResult = await this.importDefinitions(definitions, bpmnDiagram);
|
|
21542
20940
|
|
|
21543
|
-
|
|
21544
|
-
xml = result.xml;
|
|
20941
|
+
aggregatedWarnings = aggregatedWarnings.concat(importResult.warnings);
|
|
21545
20942
|
|
|
21546
|
-
|
|
21547
|
-
|
|
21548
|
-
|
|
20943
|
+
this._emit('import.done', { error: null, warnings: aggregatedWarnings });
|
|
20944
|
+
|
|
20945
|
+
return { warnings: aggregatedWarnings };
|
|
21549
20946
|
} catch (err) {
|
|
21550
|
-
error = err;
|
|
21551
|
-
|
|
20947
|
+
let error = err;
|
|
20948
|
+
aggregatedWarnings = aggregatedWarnings.concat(error.warnings || []);
|
|
20949
|
+
addWarningsToError(error, aggregatedWarnings);
|
|
21552
20950
|
|
|
21553
|
-
|
|
20951
|
+
error = checkValidationError(error);
|
|
21554
20952
|
|
|
21555
|
-
|
|
20953
|
+
this._emit('import.done', { error, warnings: error.warnings });
|
|
21556
20954
|
|
|
21557
|
-
if (error) {
|
|
21558
20955
|
throw error;
|
|
21559
20956
|
}
|
|
21560
|
-
|
|
21561
|
-
return result;
|
|
21562
20957
|
});
|
|
21563
20958
|
|
|
21564
20959
|
/**
|
|
21565
|
-
|
|
21566
|
-
|
|
21567
|
-
|
|
21568
|
-
|
|
21569
|
-
|
|
21570
|
-
|
|
20960
|
+
* The importDefinitions result.
|
|
20961
|
+
*
|
|
20962
|
+
* @typedef {Object} ImportDefinitionsResult
|
|
20963
|
+
*
|
|
20964
|
+
* @property {Array<string>} warnings
|
|
20965
|
+
*/
|
|
21571
20966
|
|
|
21572
20967
|
/**
|
|
21573
|
-
|
|
21574
|
-
|
|
20968
|
+
* The importDefinitions error.
|
|
20969
|
+
*
|
|
20970
|
+
* @typedef {Error} ImportDefinitionsError
|
|
20971
|
+
*
|
|
20972
|
+
* @property {Array<string>} warnings
|
|
20973
|
+
*/
|
|
20974
|
+
|
|
20975
|
+
/**
|
|
20976
|
+
* Import parsed definitions and render a BPMN 2.0 diagram.
|
|
20977
|
+
*
|
|
20978
|
+
* Once finished the viewer reports back the result to the
|
|
20979
|
+
* provided callback function with (err, warnings).
|
|
21575
20980
|
*
|
|
21576
20981
|
* ## Life-Cycle Events
|
|
21577
20982
|
*
|
|
21578
|
-
* During
|
|
20983
|
+
* During import the viewer will fire life-cycle events:
|
|
21579
20984
|
*
|
|
21580
|
-
* *
|
|
21581
|
-
* *
|
|
20985
|
+
* * import.render.start (graphical import start)
|
|
20986
|
+
* * import.render.complete (graphical import finished)
|
|
21582
20987
|
*
|
|
21583
20988
|
* You can use these events to hook into the life-cycle.
|
|
21584
20989
|
*
|
|
21585
|
-
* @param {
|
|
20990
|
+
* @param {ModdleElement<Definitions>} definitions parsed BPMN 2.0 definitions
|
|
20991
|
+
* @param {ModdleElement<BPMNDiagram>|string} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
|
|
21586
20992
|
*
|
|
21587
|
-
* Returns {Promise<
|
|
20993
|
+
* Returns {Promise<ImportDefinitionsResult, ImportDefinitionsError>}
|
|
21588
20994
|
*/
|
|
21589
|
-
BaseViewer.prototype.
|
|
21590
|
-
this.
|
|
21591
|
-
|
|
21592
|
-
let svg, err;
|
|
21593
|
-
|
|
21594
|
-
try {
|
|
21595
|
-
const canvas = this.get('canvas');
|
|
21596
|
-
|
|
21597
|
-
const contentNode = canvas.getActiveLayer(),
|
|
21598
|
-
defsNode = query('defs', canvas._svg);
|
|
21599
|
-
|
|
21600
|
-
const contents = innerSVG(contentNode),
|
|
21601
|
-
defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
|
|
21602
|
-
|
|
21603
|
-
const bbox = contentNode.getBBox();
|
|
21604
|
-
|
|
21605
|
-
svg =
|
|
21606
|
-
'<?xml version="1.0" encoding="utf-8"?>\n' +
|
|
21607
|
-
'<!-- created with bpmn-js / http://bpmn.io -->\n' +
|
|
21608
|
-
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
|
21609
|
-
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
|
21610
|
-
'width="' + bbox.width + '" height="' + bbox.height + '" ' +
|
|
21611
|
-
'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
|
|
21612
|
-
defs + contents +
|
|
21613
|
-
'</svg>';
|
|
21614
|
-
} catch (e) {
|
|
21615
|
-
err = e;
|
|
21616
|
-
}
|
|
21617
|
-
|
|
21618
|
-
this._emit('saveSVG.done', {
|
|
21619
|
-
error: err,
|
|
21620
|
-
svg: svg
|
|
21621
|
-
});
|
|
21622
|
-
|
|
21623
|
-
if (err) {
|
|
21624
|
-
throw err;
|
|
21625
|
-
}
|
|
20995
|
+
BaseViewer.prototype.importDefinitions = wrapForCompatibility(async function importDefinitions(definitions, bpmnDiagram) {
|
|
20996
|
+
this._setDefinitions(definitions);
|
|
20997
|
+
const result = await this.open(bpmnDiagram);
|
|
21626
20998
|
|
|
21627
|
-
return {
|
|
20999
|
+
return { warnings: result.warnings };
|
|
21628
21000
|
});
|
|
21629
21001
|
|
|
21630
21002
|
/**
|
|
21631
|
-
*
|
|
21632
|
-
*
|
|
21633
|
-
* @example
|
|
21634
|
-
*
|
|
21635
|
-
* const elementRegistry = viewer.get('elementRegistry');
|
|
21636
|
-
* const startEventShape = elementRegistry.get('StartEvent_1');
|
|
21637
|
-
*
|
|
21638
|
-
* @param {string} name
|
|
21003
|
+
* The open result.
|
|
21639
21004
|
*
|
|
21640
|
-
* @
|
|
21005
|
+
* @typedef {Object} OpenResult
|
|
21641
21006
|
*
|
|
21642
|
-
* @
|
|
21007
|
+
* @property {Array<string>} warnings
|
|
21643
21008
|
*/
|
|
21644
21009
|
|
|
21645
21010
|
/**
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
* });
|
|
21653
|
-
*
|
|
21654
|
-
* @param {Function} fn to be invoked
|
|
21655
|
-
*
|
|
21656
|
-
* @return {Object} the functions return value
|
|
21657
|
-
*
|
|
21658
|
-
* @method BaseViewer#invoke
|
|
21659
|
-
*/
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
BaseViewer.prototype._setDefinitions = function(definitions) {
|
|
21663
|
-
this._definitions = definitions;
|
|
21664
|
-
};
|
|
21665
|
-
|
|
21666
|
-
BaseViewer.prototype.getModules = function() {
|
|
21667
|
-
return this._modules;
|
|
21668
|
-
};
|
|
21011
|
+
* The open error.
|
|
21012
|
+
*
|
|
21013
|
+
* @typedef {Error} OpenError
|
|
21014
|
+
*
|
|
21015
|
+
* @property {Array<string>} warnings
|
|
21016
|
+
*/
|
|
21669
21017
|
|
|
21670
21018
|
/**
|
|
21671
|
-
*
|
|
21019
|
+
* Open diagram of previously imported XML.
|
|
21672
21020
|
*
|
|
21673
|
-
*
|
|
21674
|
-
*
|
|
21021
|
+
* Once finished the viewer reports back the result to the
|
|
21022
|
+
* provided callback function with (err, warnings).
|
|
21675
21023
|
*
|
|
21676
|
-
*
|
|
21677
|
-
*/
|
|
21678
|
-
BaseViewer.prototype.clear = function() {
|
|
21679
|
-
if (!this.getDefinitions()) {
|
|
21680
|
-
|
|
21681
|
-
// no diagram to clear
|
|
21682
|
-
return;
|
|
21683
|
-
}
|
|
21684
|
-
|
|
21685
|
-
// remove drawn elements
|
|
21686
|
-
Diagram.prototype.clear.call(this);
|
|
21687
|
-
};
|
|
21688
|
-
|
|
21689
|
-
/**
|
|
21690
|
-
* Destroy the viewer instance and remove all its
|
|
21691
|
-
* remainders from the document tree.
|
|
21692
|
-
*/
|
|
21693
|
-
BaseViewer.prototype.destroy = function() {
|
|
21694
|
-
|
|
21695
|
-
// diagram destroy
|
|
21696
|
-
Diagram.prototype.destroy.call(this);
|
|
21697
|
-
|
|
21698
|
-
// dom detach
|
|
21699
|
-
remove$2(this._container);
|
|
21700
|
-
};
|
|
21701
|
-
|
|
21702
|
-
/**
|
|
21703
|
-
* Register an event listener
|
|
21024
|
+
* ## Life-Cycle Events
|
|
21704
21025
|
*
|
|
21705
|
-
*
|
|
21026
|
+
* During switch the viewer will fire life-cycle events:
|
|
21706
21027
|
*
|
|
21707
|
-
*
|
|
21708
|
-
*
|
|
21709
|
-
* @param {Function} callback
|
|
21710
|
-
* @param {Object} [that]
|
|
21711
|
-
*/
|
|
21712
|
-
BaseViewer.prototype.on = function(event, priority, callback, target) {
|
|
21713
|
-
return this.get('eventBus').on(event, priority, callback, target);
|
|
21714
|
-
};
|
|
21715
|
-
|
|
21716
|
-
/**
|
|
21717
|
-
* De-register an event listener
|
|
21028
|
+
* * import.render.start (graphical import start)
|
|
21029
|
+
* * import.render.complete (graphical import finished)
|
|
21718
21030
|
*
|
|
21719
|
-
*
|
|
21720
|
-
*
|
|
21031
|
+
* You can use these events to hook into the life-cycle.
|
|
21032
|
+
*
|
|
21033
|
+
* @param {string|ModdleElement<BPMNDiagram>} [bpmnDiagramOrId] id or the diagram to open
|
|
21034
|
+
*
|
|
21035
|
+
* Returns {Promise<OpenResult, OpenError>}
|
|
21721
21036
|
*/
|
|
21722
|
-
BaseViewer.prototype.
|
|
21723
|
-
this.get('eventBus').off(event, callback);
|
|
21724
|
-
};
|
|
21725
|
-
|
|
21726
|
-
BaseViewer.prototype.attachTo = function(parentNode) {
|
|
21727
|
-
|
|
21728
|
-
if (!parentNode) {
|
|
21729
|
-
throw new Error('parentNode required');
|
|
21730
|
-
}
|
|
21731
|
-
|
|
21732
|
-
// ensure we detach from the
|
|
21733
|
-
// previous, old parent
|
|
21734
|
-
this.detach();
|
|
21735
|
-
|
|
21736
|
-
// unwrap jQuery if provided
|
|
21737
|
-
if (parentNode.get && parentNode.constructor.prototype.jquery) {
|
|
21738
|
-
parentNode = parentNode.get(0);
|
|
21739
|
-
}
|
|
21740
|
-
|
|
21741
|
-
if (typeof parentNode === 'string') {
|
|
21742
|
-
parentNode = query(parentNode);
|
|
21743
|
-
}
|
|
21744
|
-
|
|
21745
|
-
parentNode.appendChild(this._container);
|
|
21746
|
-
|
|
21747
|
-
this._emit('attach', {});
|
|
21748
|
-
|
|
21749
|
-
this.get('canvas').resized();
|
|
21750
|
-
};
|
|
21751
|
-
|
|
21752
|
-
BaseViewer.prototype.getDefinitions = function() {
|
|
21753
|
-
return this._definitions;
|
|
21754
|
-
};
|
|
21755
|
-
|
|
21756
|
-
BaseViewer.prototype.detach = function() {
|
|
21757
|
-
|
|
21758
|
-
const container = this._container,
|
|
21759
|
-
parentNode = container.parentNode;
|
|
21760
|
-
|
|
21761
|
-
if (!parentNode) {
|
|
21762
|
-
return;
|
|
21763
|
-
}
|
|
21037
|
+
BaseViewer.prototype.open = wrapForCompatibility(async function open(bpmnDiagramOrId) {
|
|
21764
21038
|
|
|
21765
|
-
this.
|
|
21039
|
+
const definitions = this._definitions;
|
|
21040
|
+
let bpmnDiagram = bpmnDiagramOrId;
|
|
21766
21041
|
|
|
21767
|
-
|
|
21768
|
-
|
|
21042
|
+
if (!definitions) {
|
|
21043
|
+
const error = new Error('no XML imported');
|
|
21044
|
+
addWarningsToError(error, []);
|
|
21769
21045
|
|
|
21770
|
-
|
|
21046
|
+
throw error;
|
|
21047
|
+
}
|
|
21771
21048
|
|
|
21772
|
-
|
|
21773
|
-
|
|
21774
|
-
staticModules = [
|
|
21775
|
-
{
|
|
21776
|
-
bpmnjs: [ 'value', this ],
|
|
21777
|
-
moddle: [ 'value', moddle ]
|
|
21778
|
-
}
|
|
21779
|
-
];
|
|
21049
|
+
if (typeof bpmnDiagramOrId === 'string') {
|
|
21050
|
+
bpmnDiagram = findBPMNDiagram(definitions, bpmnDiagramOrId);
|
|
21780
21051
|
|
|
21781
|
-
|
|
21052
|
+
if (!bpmnDiagram) {
|
|
21053
|
+
const error = new Error('BPMNDiagram <' + bpmnDiagramOrId + '> not found');
|
|
21054
|
+
addWarningsToError(error, []);
|
|
21782
21055
|
|
|
21783
|
-
|
|
21784
|
-
|
|
21785
|
-
|
|
21786
|
-
});
|
|
21056
|
+
throw error;
|
|
21057
|
+
}
|
|
21058
|
+
}
|
|
21787
21059
|
|
|
21788
|
-
//
|
|
21789
|
-
|
|
21060
|
+
// clear existing rendered diagram
|
|
21061
|
+
// catch synchronous exceptions during #clear()
|
|
21062
|
+
try {
|
|
21063
|
+
this.clear();
|
|
21064
|
+
} catch (error) {
|
|
21065
|
+
addWarningsToError(error, []);
|
|
21790
21066
|
|
|
21791
|
-
|
|
21792
|
-
this.attachTo(options.container);
|
|
21067
|
+
throw error;
|
|
21793
21068
|
}
|
|
21794
|
-
|
|
21069
|
+
|
|
21070
|
+
// perform graphical import
|
|
21071
|
+
const { warnings } = await importBpmnDiagram(this, definitions, bpmnDiagram);
|
|
21072
|
+
|
|
21073
|
+
return { warnings };
|
|
21074
|
+
});
|
|
21795
21075
|
|
|
21796
21076
|
/**
|
|
21797
|
-
*
|
|
21077
|
+
* The saveXML result.
|
|
21798
21078
|
*
|
|
21799
|
-
* @
|
|
21800
|
-
* @param {Object} event
|
|
21079
|
+
* @typedef {Object} SaveXMLResult
|
|
21801
21080
|
*
|
|
21802
|
-
* @
|
|
21081
|
+
* @property {string} xml
|
|
21803
21082
|
*/
|
|
21804
|
-
BaseViewer.prototype._emit = function(type, event) {
|
|
21805
|
-
return this.get('eventBus').fire(type, event);
|
|
21806
|
-
};
|
|
21807
|
-
|
|
21808
|
-
BaseViewer.prototype._createContainer = function(options) {
|
|
21809
|
-
|
|
21810
|
-
const container = domify$1('<div class="bjs-container"></div>');
|
|
21811
|
-
|
|
21812
|
-
assign(container, {
|
|
21813
|
-
width: ensureUnit(options.width),
|
|
21814
|
-
height: ensureUnit(options.height),
|
|
21815
|
-
position: options.position
|
|
21816
|
-
});
|
|
21817
|
-
|
|
21818
|
-
return container;
|
|
21819
|
-
};
|
|
21820
|
-
|
|
21821
|
-
BaseViewer.prototype._createModdle = function(options) {
|
|
21822
|
-
const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
|
|
21823
21083
|
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21084
|
+
/**
|
|
21085
|
+
* Export the currently displayed BPMN 2.0 diagram as
|
|
21086
|
+
* a BPMN 2.0 XML document.
|
|
21087
|
+
*
|
|
21088
|
+
* ## Life-Cycle Events
|
|
21089
|
+
*
|
|
21090
|
+
* During XML saving the viewer will fire life-cycle events:
|
|
21091
|
+
*
|
|
21092
|
+
* * saveXML.start (before serialization)
|
|
21093
|
+
* * saveXML.serialized (after xml generation)
|
|
21094
|
+
* * saveXML.done (everything done)
|
|
21095
|
+
*
|
|
21096
|
+
* You can use these events to hook into the life-cycle.
|
|
21097
|
+
*
|
|
21098
|
+
* @param {Object} [options] export options
|
|
21099
|
+
* @param {boolean} [options.format=false] output formatted XML
|
|
21100
|
+
* @param {boolean} [options.preamble=true] output preamble
|
|
21101
|
+
*
|
|
21102
|
+
* Returns {Promise<SaveXMLResult, Error>}
|
|
21103
|
+
*/
|
|
21104
|
+
BaseViewer.prototype.saveXML = wrapForCompatibility(async function saveXML(options) {
|
|
21828
21105
|
|
|
21829
|
-
|
|
21106
|
+
options = options || {};
|
|
21830
21107
|
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
return err;
|
|
21834
|
-
}
|
|
21108
|
+
let definitions = this._definitions,
|
|
21109
|
+
error, xml;
|
|
21835
21110
|
|
|
21836
|
-
|
|
21111
|
+
try {
|
|
21112
|
+
if (!definitions) {
|
|
21113
|
+
throw new Error('no definitions loaded');
|
|
21114
|
+
}
|
|
21837
21115
|
|
|
21838
|
-
|
|
21839
|
-
|
|
21116
|
+
// allow to fiddle around with definitions
|
|
21117
|
+
definitions = this._emit('saveXML.start', {
|
|
21118
|
+
definitions
|
|
21119
|
+
}) || definitions;
|
|
21840
21120
|
|
|
21841
|
-
|
|
21842
|
-
|
|
21121
|
+
const result = await this._moddle.toXML(definitions, options);
|
|
21122
|
+
xml = result.xml;
|
|
21843
21123
|
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
21124
|
+
xml = this._emit('saveXML.serialized', {
|
|
21125
|
+
xml
|
|
21126
|
+
}) || xml;
|
|
21127
|
+
} catch (err) {
|
|
21128
|
+
error = err;
|
|
21848
21129
|
}
|
|
21849
21130
|
|
|
21850
|
-
|
|
21851
|
-
}
|
|
21852
|
-
|
|
21853
|
-
const DEFAULT_OPTIONS = {
|
|
21854
|
-
width: '100%',
|
|
21855
|
-
height: '100%',
|
|
21856
|
-
position: 'relative'
|
|
21857
|
-
};
|
|
21131
|
+
const result = error ? { error } : { xml };
|
|
21858
21132
|
|
|
21133
|
+
this._emit('saveXML.done', result);
|
|
21859
21134
|
|
|
21860
|
-
|
|
21861
|
-
|
|
21862
|
-
|
|
21863
|
-
function ensureUnit(val) {
|
|
21864
|
-
return val + (isNumber(val) ? 'px' : '');
|
|
21865
|
-
}
|
|
21135
|
+
if (error) {
|
|
21136
|
+
throw error;
|
|
21137
|
+
}
|
|
21866
21138
|
|
|
21139
|
+
return result;
|
|
21140
|
+
});
|
|
21867
21141
|
|
|
21868
21142
|
/**
|
|
21869
|
-
*
|
|
21143
|
+
* The saveSVG result.
|
|
21870
21144
|
*
|
|
21871
|
-
* @
|
|
21872
|
-
* @param {string} diagramId
|
|
21145
|
+
* @typedef {Object} SaveSVGResult
|
|
21873
21146
|
*
|
|
21874
|
-
* @
|
|
21147
|
+
* @property {string} svg
|
|
21875
21148
|
*/
|
|
21876
|
-
function findBPMNDiagram(definitions, diagramId) {
|
|
21877
|
-
if (!diagramId) {
|
|
21878
|
-
return null;
|
|
21879
|
-
}
|
|
21880
|
-
|
|
21881
|
-
return find(definitions.diagrams, function(element) {
|
|
21882
|
-
return element.id === diagramId;
|
|
21883
|
-
}) || null;
|
|
21884
|
-
}
|
|
21885
21149
|
|
|
21886
21150
|
/**
|
|
21887
|
-
*
|
|
21888
|
-
*
|
|
21151
|
+
* Export the currently displayed BPMN 2.0 diagram as
|
|
21152
|
+
* an SVG image.
|
|
21889
21153
|
*
|
|
21890
|
-
*
|
|
21154
|
+
* ## Life-Cycle Events
|
|
21891
21155
|
*
|
|
21892
|
-
*
|
|
21156
|
+
* During SVG saving the viewer will fire life-cycle events:
|
|
21157
|
+
*
|
|
21158
|
+
* * saveSVG.start (before serialization)
|
|
21159
|
+
* * saveSVG.done (everything done)
|
|
21160
|
+
*
|
|
21161
|
+
* You can use these events to hook into the life-cycle.
|
|
21162
|
+
*
|
|
21163
|
+
* @param {Object} [options]
|
|
21164
|
+
*
|
|
21165
|
+
* Returns {Promise<SaveSVGResult, Error>}
|
|
21893
21166
|
*/
|
|
21894
|
-
function
|
|
21895
|
-
|
|
21167
|
+
BaseViewer.prototype.saveSVG = wrapForCompatibility(async function saveSVG(options = {}) {
|
|
21168
|
+
this._emit('saveSVG.start');
|
|
21896
21169
|
|
|
21897
|
-
|
|
21898
|
-
'<a href="http://bpmn.io" ' +
|
|
21899
|
-
'target="_blank" ' +
|
|
21900
|
-
'class="bjs-powered-by" ' +
|
|
21901
|
-
'title="Powered by bpmn.io" ' +
|
|
21902
|
-
'>' +
|
|
21903
|
-
img +
|
|
21904
|
-
'</a>';
|
|
21170
|
+
let svg, err;
|
|
21905
21171
|
|
|
21906
|
-
|
|
21172
|
+
try {
|
|
21173
|
+
const canvas = this.get('canvas');
|
|
21907
21174
|
|
|
21908
|
-
|
|
21909
|
-
|
|
21910
|
-
position: 'absolute',
|
|
21911
|
-
bottom: '15px',
|
|
21912
|
-
right: '15px',
|
|
21913
|
-
zIndex: '100'
|
|
21914
|
-
});
|
|
21175
|
+
const contentNode = canvas.getActiveLayer(),
|
|
21176
|
+
defsNode = query('defs', canvas._svg);
|
|
21915
21177
|
|
|
21916
|
-
|
|
21178
|
+
const contents = innerSVG(contentNode),
|
|
21179
|
+
defs = defsNode ? '<defs>' + innerSVG(defsNode) + '</defs>' : '';
|
|
21917
21180
|
|
|
21918
|
-
|
|
21919
|
-
open();
|
|
21181
|
+
const bbox = contentNode.getBBox();
|
|
21920
21182
|
|
|
21921
|
-
|
|
21183
|
+
svg =
|
|
21184
|
+
'<?xml version="1.0" encoding="utf-8"?>\n' +
|
|
21185
|
+
'<!-- created with bpmn-js / http://bpmn.io -->\n' +
|
|
21186
|
+
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
|
|
21187
|
+
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
|
21188
|
+
'width="' + bbox.width + '" height="' + bbox.height + '" ' +
|
|
21189
|
+
'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
|
|
21190
|
+
defs + contents +
|
|
21191
|
+
'</svg>';
|
|
21192
|
+
} catch (e) {
|
|
21193
|
+
err = e;
|
|
21194
|
+
}
|
|
21195
|
+
|
|
21196
|
+
this._emit('saveSVG.done', {
|
|
21197
|
+
error: err,
|
|
21198
|
+
svg: svg
|
|
21922
21199
|
});
|
|
21923
|
-
}
|
|
21924
21200
|
|
|
21925
|
-
|
|
21201
|
+
if (err) {
|
|
21202
|
+
throw err;
|
|
21203
|
+
}
|
|
21204
|
+
|
|
21205
|
+
return { svg };
|
|
21206
|
+
});
|
|
21926
21207
|
|
|
21927
21208
|
/**
|
|
21928
|
-
*
|
|
21929
|
-
*
|
|
21930
|
-
* Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
|
|
21931
|
-
* additional features.
|
|
21932
|
-
*
|
|
21209
|
+
* Get a named diagram service.
|
|
21933
21210
|
*
|
|
21934
|
-
*
|
|
21211
|
+
* @example
|
|
21935
21212
|
*
|
|
21936
|
-
*
|
|
21937
|
-
*
|
|
21938
|
-
* named services.
|
|
21213
|
+
* const elementRegistry = viewer.get('elementRegistry');
|
|
21214
|
+
* const startEventShape = elementRegistry.get('StartEvent_1');
|
|
21939
21215
|
*
|
|
21940
|
-
*
|
|
21941
|
-
* logging component that integrates with interaction events:
|
|
21216
|
+
* @param {string} name
|
|
21942
21217
|
*
|
|
21218
|
+
* @return {Object} diagram service instance
|
|
21943
21219
|
*
|
|
21944
|
-
*
|
|
21220
|
+
* @method BaseViewer#get
|
|
21221
|
+
*/
|
|
21222
|
+
|
|
21223
|
+
/**
|
|
21224
|
+
* Invoke a function in the context of this viewer.
|
|
21945
21225
|
*
|
|
21946
|
-
*
|
|
21947
|
-
* function InteractionLogger(eventBus) {
|
|
21948
|
-
* eventBus.on('element.hover', function(event) {
|
|
21949
|
-
* console.log()
|
|
21950
|
-
* })
|
|
21951
|
-
* }
|
|
21226
|
+
* @example
|
|
21952
21227
|
*
|
|
21953
|
-
*
|
|
21228
|
+
* viewer.invoke(function(elementRegistry) {
|
|
21229
|
+
* const startEventShape = elementRegistry.get('StartEvent_1');
|
|
21230
|
+
* });
|
|
21954
21231
|
*
|
|
21955
|
-
*
|
|
21956
|
-
* var extensionModule = {
|
|
21957
|
-
* __init__: [ 'interactionLogger' ],
|
|
21958
|
-
* interactionLogger: [ 'type', InteractionLogger ]
|
|
21959
|
-
* };
|
|
21232
|
+
* @param {Function} fn to be invoked
|
|
21960
21233
|
*
|
|
21961
|
-
*
|
|
21962
|
-
* var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
|
|
21963
|
-
* bpmnViewer.importXML(...);
|
|
21964
|
-
* ```
|
|
21234
|
+
* @return {Object} the functions return value
|
|
21965
21235
|
*
|
|
21966
|
-
* @
|
|
21967
|
-
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
21968
|
-
* @param {string|number} [options.width] the width of the viewer
|
|
21969
|
-
* @param {string|number} [options.height] the height of the viewer
|
|
21970
|
-
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
21971
|
-
* @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
|
|
21972
|
-
* @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
|
|
21236
|
+
* @method BaseViewer#invoke
|
|
21973
21237
|
*/
|
|
21974
|
-
function Viewer$1(options) {
|
|
21975
|
-
BaseViewer.call(this, options);
|
|
21976
|
-
}
|
|
21977
|
-
|
|
21978
|
-
e(Viewer$1, BaseViewer);
|
|
21979
|
-
|
|
21980
|
-
// modules the viewer is composed of
|
|
21981
|
-
Viewer$1.prototype._modules = [
|
|
21982
|
-
CoreModule$1,
|
|
21983
|
-
TranslateModule,
|
|
21984
|
-
SelectionModule,
|
|
21985
|
-
OverlaysModule,
|
|
21986
|
-
DrilldownModdule
|
|
21987
|
-
];
|
|
21988
21238
|
|
|
21989
|
-
// default moddle extensions the viewer is composed of
|
|
21990
|
-
Viewer$1.prototype._moddleExtensions = {};
|
|
21991
21239
|
|
|
21992
|
-
function
|
|
21240
|
+
BaseViewer.prototype._setDefinitions = function(definitions) {
|
|
21241
|
+
this._definitions = definitions;
|
|
21242
|
+
};
|
|
21993
21243
|
|
|
21994
|
-
|
|
21995
|
-
|
|
21244
|
+
BaseViewer.prototype.getModules = function() {
|
|
21245
|
+
return this._modules;
|
|
21246
|
+
};
|
|
21996
21247
|
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
21248
|
+
/**
|
|
21249
|
+
* Remove all drawn elements from the viewer.
|
|
21250
|
+
*
|
|
21251
|
+
* After calling this method the viewer can still
|
|
21252
|
+
* be reused for opening another diagram.
|
|
21253
|
+
*
|
|
21254
|
+
* @method BaseViewer#clear
|
|
21255
|
+
*/
|
|
21256
|
+
BaseViewer.prototype.clear = function() {
|
|
21257
|
+
if (!this.getDefinitions()) {
|
|
22000
21258
|
|
|
22001
|
-
|
|
22002
|
-
|
|
21259
|
+
// no diagram to clear
|
|
21260
|
+
return;
|
|
22003
21261
|
}
|
|
22004
21262
|
|
|
22005
|
-
|
|
22006
|
-
|
|
21263
|
+
// remove drawn elements
|
|
21264
|
+
Diagram.prototype.clear.call(this);
|
|
21265
|
+
};
|
|
22007
21266
|
|
|
22008
21267
|
/**
|
|
22009
|
-
*
|
|
21268
|
+
* Destroy the viewer instance and remove all its
|
|
21269
|
+
* remainders from the document tree.
|
|
22010
21270
|
*/
|
|
21271
|
+
BaseViewer.prototype.destroy = function() {
|
|
22011
21272
|
|
|
22012
|
-
|
|
22013
|
-
|
|
22014
|
-
*
|
|
22015
|
-
* @param {SVGElement} element
|
|
22016
|
-
* @param {SVGElement} target
|
|
22017
|
-
*
|
|
22018
|
-
* @return {SVGElement} the appended node
|
|
22019
|
-
*/
|
|
22020
|
-
function appendTo(element, target) {
|
|
22021
|
-
return target.appendChild(ensureImported(element, target));
|
|
22022
|
-
}
|
|
21273
|
+
// diagram destroy
|
|
21274
|
+
Diagram.prototype.destroy.call(this);
|
|
22023
21275
|
|
|
22024
|
-
|
|
22025
|
-
|
|
22026
|
-
|
|
21276
|
+
// dom detach
|
|
21277
|
+
remove$1(this._container);
|
|
21278
|
+
};
|
|
22027
21279
|
|
|
22028
21280
|
/**
|
|
22029
|
-
*
|
|
21281
|
+
* Register an event listener
|
|
22030
21282
|
*
|
|
22031
|
-
* @
|
|
22032
|
-
* @param {SVGElement} node
|
|
21283
|
+
* Remove a previously added listener via {@link #off(event, callback)}.
|
|
22033
21284
|
*
|
|
22034
|
-
* @
|
|
21285
|
+
* @param {string} event
|
|
21286
|
+
* @param {number} [priority]
|
|
21287
|
+
* @param {Function} callback
|
|
21288
|
+
* @param {Object} [that]
|
|
22035
21289
|
*/
|
|
22036
|
-
function
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
}
|
|
21290
|
+
BaseViewer.prototype.on = function(event, priority, callback, target) {
|
|
21291
|
+
return this.get('eventBus').on(event, priority, callback, target);
|
|
21292
|
+
};
|
|
22040
21293
|
|
|
22041
21294
|
/**
|
|
22042
|
-
*
|
|
21295
|
+
* De-register an event listener
|
|
21296
|
+
*
|
|
21297
|
+
* @param {string} event
|
|
21298
|
+
* @param {Function} callback
|
|
22043
21299
|
*/
|
|
21300
|
+
BaseViewer.prototype.off = function(event, callback) {
|
|
21301
|
+
this.get('eventBus').off(event, callback);
|
|
21302
|
+
};
|
|
22044
21303
|
|
|
22045
|
-
|
|
21304
|
+
BaseViewer.prototype.attachTo = function(parentNode) {
|
|
22046
21305
|
|
|
22047
|
-
|
|
22048
|
-
|
|
22049
|
-
|
|
22050
|
-
'clip': 1,
|
|
22051
|
-
'clip-path': 1,
|
|
22052
|
-
'clip-rule': 1,
|
|
22053
|
-
'color': 1,
|
|
22054
|
-
'color-interpolation': 1,
|
|
22055
|
-
'color-interpolation-filters': 1,
|
|
22056
|
-
'color-profile': 1,
|
|
22057
|
-
'color-rendering': 1,
|
|
22058
|
-
'cursor': 1,
|
|
22059
|
-
'direction': 1,
|
|
22060
|
-
'display': 1,
|
|
22061
|
-
'dominant-baseline': 1,
|
|
22062
|
-
'enable-background': 1,
|
|
22063
|
-
'fill': 1,
|
|
22064
|
-
'fill-opacity': 1,
|
|
22065
|
-
'fill-rule': 1,
|
|
22066
|
-
'filter': 1,
|
|
22067
|
-
'flood-color': 1,
|
|
22068
|
-
'flood-opacity': 1,
|
|
22069
|
-
'font': 1,
|
|
22070
|
-
'font-family': 1,
|
|
22071
|
-
'font-size': LENGTH_ATTR,
|
|
22072
|
-
'font-size-adjust': 1,
|
|
22073
|
-
'font-stretch': 1,
|
|
22074
|
-
'font-style': 1,
|
|
22075
|
-
'font-variant': 1,
|
|
22076
|
-
'font-weight': 1,
|
|
22077
|
-
'glyph-orientation-horizontal': 1,
|
|
22078
|
-
'glyph-orientation-vertical': 1,
|
|
22079
|
-
'image-rendering': 1,
|
|
22080
|
-
'kerning': 1,
|
|
22081
|
-
'letter-spacing': 1,
|
|
22082
|
-
'lighting-color': 1,
|
|
22083
|
-
'marker': 1,
|
|
22084
|
-
'marker-end': 1,
|
|
22085
|
-
'marker-mid': 1,
|
|
22086
|
-
'marker-start': 1,
|
|
22087
|
-
'mask': 1,
|
|
22088
|
-
'opacity': 1,
|
|
22089
|
-
'overflow': 1,
|
|
22090
|
-
'pointer-events': 1,
|
|
22091
|
-
'shape-rendering': 1,
|
|
22092
|
-
'stop-color': 1,
|
|
22093
|
-
'stop-opacity': 1,
|
|
22094
|
-
'stroke': 1,
|
|
22095
|
-
'stroke-dasharray': 1,
|
|
22096
|
-
'stroke-dashoffset': 1,
|
|
22097
|
-
'stroke-linecap': 1,
|
|
22098
|
-
'stroke-linejoin': 1,
|
|
22099
|
-
'stroke-miterlimit': 1,
|
|
22100
|
-
'stroke-opacity': 1,
|
|
22101
|
-
'stroke-width': LENGTH_ATTR,
|
|
22102
|
-
'text-anchor': 1,
|
|
22103
|
-
'text-decoration': 1,
|
|
22104
|
-
'text-rendering': 1,
|
|
22105
|
-
'unicode-bidi': 1,
|
|
22106
|
-
'visibility': 1,
|
|
22107
|
-
'word-spacing': 1,
|
|
22108
|
-
'writing-mode': 1
|
|
22109
|
-
};
|
|
21306
|
+
if (!parentNode) {
|
|
21307
|
+
throw new Error('parentNode required');
|
|
21308
|
+
}
|
|
22110
21309
|
|
|
21310
|
+
// ensure we detach from the
|
|
21311
|
+
// previous, old parent
|
|
21312
|
+
this.detach();
|
|
22111
21313
|
|
|
22112
|
-
|
|
22113
|
-
if (
|
|
22114
|
-
|
|
22115
|
-
} else {
|
|
22116
|
-
return node.getAttributeNS(null, name);
|
|
21314
|
+
// unwrap jQuery if provided
|
|
21315
|
+
if (parentNode.get && parentNode.constructor.prototype.jquery) {
|
|
21316
|
+
parentNode = parentNode.get(0);
|
|
22117
21317
|
}
|
|
22118
|
-
}
|
|
22119
21318
|
|
|
22120
|
-
|
|
22121
|
-
|
|
21319
|
+
if (typeof parentNode === 'string') {
|
|
21320
|
+
parentNode = query(parentNode);
|
|
21321
|
+
}
|
|
22122
21322
|
|
|
22123
|
-
|
|
21323
|
+
parentNode.appendChild(this._container);
|
|
22124
21324
|
|
|
22125
|
-
|
|
21325
|
+
this._emit('attach', {});
|
|
22126
21326
|
|
|
22127
|
-
|
|
22128
|
-
|
|
22129
|
-
value = String(value) + 'px';
|
|
22130
|
-
}
|
|
21327
|
+
this.get('canvas').resized();
|
|
21328
|
+
};
|
|
22131
21329
|
|
|
22132
|
-
|
|
22133
|
-
|
|
22134
|
-
|
|
21330
|
+
BaseViewer.prototype.getDefinitions = function() {
|
|
21331
|
+
return this._definitions;
|
|
21332
|
+
};
|
|
21333
|
+
|
|
21334
|
+
BaseViewer.prototype.detach = function() {
|
|
21335
|
+
|
|
21336
|
+
const container = this._container,
|
|
21337
|
+
parentNode = container.parentNode;
|
|
21338
|
+
|
|
21339
|
+
if (!parentNode) {
|
|
21340
|
+
return;
|
|
22135
21341
|
}
|
|
22136
|
-
}
|
|
22137
21342
|
|
|
22138
|
-
|
|
21343
|
+
this._emit('detach', {});
|
|
21344
|
+
|
|
21345
|
+
parentNode.removeChild(container);
|
|
21346
|
+
};
|
|
21347
|
+
|
|
21348
|
+
BaseViewer.prototype._init = function(container, moddle, options) {
|
|
21349
|
+
|
|
21350
|
+
const baseModules = options.modules || this.getModules(),
|
|
21351
|
+
additionalModules = options.additionalModules || [],
|
|
21352
|
+
staticModules = [
|
|
21353
|
+
{
|
|
21354
|
+
bpmnjs: [ 'value', this ],
|
|
21355
|
+
moddle: [ 'value', moddle ]
|
|
21356
|
+
}
|
|
21357
|
+
];
|
|
21358
|
+
|
|
21359
|
+
const diagramModules = [].concat(staticModules, baseModules, additionalModules);
|
|
21360
|
+
|
|
21361
|
+
const diagramOptions = assign$1(omit(options, [ 'additionalModules' ]), {
|
|
21362
|
+
canvas: assign$1({}, options.canvas, { container: container }),
|
|
21363
|
+
modules: diagramModules
|
|
21364
|
+
});
|
|
22139
21365
|
|
|
22140
|
-
|
|
21366
|
+
// invoke diagram constructor
|
|
21367
|
+
Diagram.call(this, diagramOptions);
|
|
22141
21368
|
|
|
22142
|
-
|
|
22143
|
-
|
|
21369
|
+
if (options && options.container) {
|
|
21370
|
+
this.attachTo(options.container);
|
|
22144
21371
|
}
|
|
22145
|
-
}
|
|
21372
|
+
};
|
|
22146
21373
|
|
|
22147
21374
|
/**
|
|
22148
|
-
*
|
|
21375
|
+
* Emit an event on the underlying {@link EventBus}
|
|
22149
21376
|
*
|
|
22150
|
-
* @param {
|
|
22151
|
-
* @param {Object}
|
|
22152
|
-
* @param {String} [name]
|
|
22153
|
-
* @param {String} [value]
|
|
21377
|
+
* @param {string} type
|
|
21378
|
+
* @param {Object} event
|
|
22154
21379
|
*
|
|
22155
|
-
* @return {
|
|
21380
|
+
* @return {Object} event processing result (if any)
|
|
22156
21381
|
*/
|
|
22157
|
-
function
|
|
22158
|
-
|
|
22159
|
-
|
|
22160
|
-
setAttribute(node, name, value);
|
|
22161
|
-
} else {
|
|
22162
|
-
return getAttribute(node, name);
|
|
22163
|
-
}
|
|
22164
|
-
} else {
|
|
22165
|
-
setAttributes(node, name);
|
|
22166
|
-
}
|
|
21382
|
+
BaseViewer.prototype._emit = function(type, event) {
|
|
21383
|
+
return this.get('eventBus').fire(type, event);
|
|
21384
|
+
};
|
|
22167
21385
|
|
|
22168
|
-
|
|
22169
|
-
}
|
|
21386
|
+
BaseViewer.prototype._createContainer = function(options) {
|
|
22170
21387
|
|
|
22171
|
-
|
|
22172
|
-
svg: 'http://www.w3.org/2000/svg'
|
|
22173
|
-
};
|
|
21388
|
+
const container = domify$1('<div class="bjs-container"></div>');
|
|
22174
21389
|
|
|
22175
|
-
|
|
22176
|
-
|
|
22177
|
-
|
|
21390
|
+
assign(container, {
|
|
21391
|
+
width: ensureUnit(options.width),
|
|
21392
|
+
height: ensureUnit(options.height),
|
|
21393
|
+
position: options.position
|
|
21394
|
+
});
|
|
22178
21395
|
|
|
22179
|
-
|
|
21396
|
+
return container;
|
|
21397
|
+
};
|
|
22180
21398
|
|
|
22181
|
-
function
|
|
21399
|
+
BaseViewer.prototype._createModdle = function(options) {
|
|
21400
|
+
const moddleOptions = assign$1({}, this._moddleExtensions, options.moddleExtensions);
|
|
22182
21401
|
|
|
22183
|
-
|
|
21402
|
+
return new simple(moddleOptions);
|
|
21403
|
+
};
|
|
22184
21404
|
|
|
22185
|
-
|
|
22186
|
-
if (svg.substring(0, 4) === '<svg') {
|
|
22187
|
-
if (svg.indexOf(ns.svg) === -1) {
|
|
22188
|
-
svg = SVG_START + svg.substring(4);
|
|
22189
|
-
}
|
|
22190
|
-
} else {
|
|
21405
|
+
BaseViewer.prototype._modules = [];
|
|
22191
21406
|
|
|
22192
|
-
|
|
22193
|
-
svg = SVG_START + '>' + svg + '</svg>';
|
|
22194
|
-
unwrap = true;
|
|
22195
|
-
}
|
|
21407
|
+
// helpers ///////////////
|
|
22196
21408
|
|
|
22197
|
-
|
|
21409
|
+
function addWarningsToError(err, warningsAry) {
|
|
21410
|
+
err.warnings = warningsAry;
|
|
21411
|
+
return err;
|
|
21412
|
+
}
|
|
22198
21413
|
|
|
22199
|
-
|
|
22200
|
-
return parsed;
|
|
22201
|
-
}
|
|
21414
|
+
function checkValidationError(err) {
|
|
22202
21415
|
|
|
22203
|
-
|
|
21416
|
+
// check if we can help the user by indicating wrong BPMN 2.0 xml
|
|
21417
|
+
// (in case he or the exporting tool did not get that right)
|
|
22204
21418
|
|
|
22205
|
-
|
|
21419
|
+
const pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
|
|
21420
|
+
const match = pattern.exec(err.message);
|
|
22206
21421
|
|
|
22207
|
-
|
|
22208
|
-
|
|
21422
|
+
if (match) {
|
|
21423
|
+
err.message =
|
|
21424
|
+
'unparsable content <' + match[1] + '> detected; ' +
|
|
21425
|
+
'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
|
|
22209
21426
|
}
|
|
22210
21427
|
|
|
22211
|
-
return
|
|
21428
|
+
return err;
|
|
22212
21429
|
}
|
|
22213
21430
|
|
|
22214
|
-
|
|
22215
|
-
|
|
22216
|
-
|
|
21431
|
+
const DEFAULT_OPTIONS = {
|
|
21432
|
+
width: '100%',
|
|
21433
|
+
height: '100%',
|
|
21434
|
+
position: 'relative'
|
|
21435
|
+
};
|
|
22217
21436
|
|
|
22218
|
-
// parse
|
|
22219
|
-
parser = new DOMParser();
|
|
22220
|
-
parser.async = false;
|
|
22221
21437
|
|
|
22222
|
-
|
|
21438
|
+
/**
|
|
21439
|
+
* Ensure the passed argument is a proper unit (defaulting to px)
|
|
21440
|
+
*/
|
|
21441
|
+
function ensureUnit(val) {
|
|
21442
|
+
return val + (isNumber(val) ? 'px' : '');
|
|
22223
21443
|
}
|
|
22224
21444
|
|
|
21445
|
+
|
|
22225
21446
|
/**
|
|
22226
|
-
*
|
|
21447
|
+
* Find BPMNDiagram in definitions by ID
|
|
21448
|
+
*
|
|
21449
|
+
* @param {ModdleElement<Definitions>} definitions
|
|
21450
|
+
* @param {string} diagramId
|
|
21451
|
+
*
|
|
21452
|
+
* @return {ModdleElement<BPMNDiagram>|null}
|
|
22227
21453
|
*/
|
|
21454
|
+
function findBPMNDiagram(definitions, diagramId) {
|
|
21455
|
+
if (!diagramId) {
|
|
21456
|
+
return null;
|
|
21457
|
+
}
|
|
22228
21458
|
|
|
21459
|
+
return find(definitions.diagrams, function(element) {
|
|
21460
|
+
return element.id === diagramId;
|
|
21461
|
+
}) || null;
|
|
21462
|
+
}
|
|
22229
21463
|
|
|
22230
21464
|
/**
|
|
22231
|
-
*
|
|
21465
|
+
* Adds the project logo to the diagram container as
|
|
21466
|
+
* required by the bpmn.io license.
|
|
22232
21467
|
*
|
|
22233
|
-
* @
|
|
22234
|
-
* @param {Object} [attrs] attributes to set on the element
|
|
21468
|
+
* @see http://bpmn.io/license
|
|
22235
21469
|
*
|
|
22236
|
-
* @
|
|
21470
|
+
* @param {Element} container
|
|
22237
21471
|
*/
|
|
22238
|
-
function
|
|
22239
|
-
|
|
21472
|
+
function addProjectLogo(container) {
|
|
21473
|
+
const img = BPMNIO_IMG;
|
|
22240
21474
|
|
|
22241
|
-
|
|
22242
|
-
|
|
22243
|
-
|
|
22244
|
-
|
|
22245
|
-
|
|
22246
|
-
|
|
21475
|
+
const linkMarkup =
|
|
21476
|
+
'<a href="http://bpmn.io" ' +
|
|
21477
|
+
'target="_blank" ' +
|
|
21478
|
+
'class="bjs-powered-by" ' +
|
|
21479
|
+
'title="Powered by bpmn.io" ' +
|
|
21480
|
+
'>' +
|
|
21481
|
+
img +
|
|
21482
|
+
'</a>';
|
|
22247
21483
|
|
|
22248
|
-
|
|
22249
|
-
attr(element, attrs);
|
|
22250
|
-
}
|
|
21484
|
+
const linkElement = domify$1(linkMarkup);
|
|
22251
21485
|
|
|
22252
|
-
|
|
21486
|
+
assign(query('svg', linkElement), LOGO_STYLES);
|
|
21487
|
+
assign(linkElement, LINK_STYLES, {
|
|
21488
|
+
position: 'absolute',
|
|
21489
|
+
bottom: '15px',
|
|
21490
|
+
right: '15px',
|
|
21491
|
+
zIndex: '100'
|
|
21492
|
+
});
|
|
21493
|
+
|
|
21494
|
+
container.appendChild(linkElement);
|
|
21495
|
+
|
|
21496
|
+
event.bind(linkElement, 'click', function(event) {
|
|
21497
|
+
open();
|
|
21498
|
+
|
|
21499
|
+
event.preventDefault();
|
|
21500
|
+
});
|
|
21501
|
+
}
|
|
21502
|
+
|
|
21503
|
+
/* </project-logo> */
|
|
21504
|
+
|
|
21505
|
+
/**
|
|
21506
|
+
* A viewer for BPMN 2.0 diagrams.
|
|
21507
|
+
*
|
|
21508
|
+
* Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
|
|
21509
|
+
* additional features.
|
|
21510
|
+
*
|
|
21511
|
+
*
|
|
21512
|
+
* ## Extending the Viewer
|
|
21513
|
+
*
|
|
21514
|
+
* In order to extend the viewer pass extension modules to bootstrap via the
|
|
21515
|
+
* `additionalModules` option. An extension module is an object that exposes
|
|
21516
|
+
* named services.
|
|
21517
|
+
*
|
|
21518
|
+
* The following example depicts the integration of a simple
|
|
21519
|
+
* logging component that integrates with interaction events:
|
|
21520
|
+
*
|
|
21521
|
+
*
|
|
21522
|
+
* ```javascript
|
|
21523
|
+
*
|
|
21524
|
+
* // logging component
|
|
21525
|
+
* function InteractionLogger(eventBus) {
|
|
21526
|
+
* eventBus.on('element.hover', function(event) {
|
|
21527
|
+
* console.log()
|
|
21528
|
+
* })
|
|
21529
|
+
* }
|
|
21530
|
+
*
|
|
21531
|
+
* InteractionLogger.$inject = [ 'eventBus' ]; // minification save
|
|
21532
|
+
*
|
|
21533
|
+
* // extension module
|
|
21534
|
+
* var extensionModule = {
|
|
21535
|
+
* __init__: [ 'interactionLogger' ],
|
|
21536
|
+
* interactionLogger: [ 'type', InteractionLogger ]
|
|
21537
|
+
* };
|
|
21538
|
+
*
|
|
21539
|
+
* // extend the viewer
|
|
21540
|
+
* var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
|
|
21541
|
+
* bpmnViewer.importXML(...);
|
|
21542
|
+
* ```
|
|
21543
|
+
*
|
|
21544
|
+
* @param {Object} [options] configuration options to pass to the viewer
|
|
21545
|
+
* @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
|
|
21546
|
+
* @param {string|number} [options.width] the width of the viewer
|
|
21547
|
+
* @param {string|number} [options.height] the height of the viewer
|
|
21548
|
+
* @param {Object} [options.moddleExtensions] extension packages to provide
|
|
21549
|
+
* @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
|
|
21550
|
+
* @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
|
|
21551
|
+
*/
|
|
21552
|
+
function Viewer$1(options) {
|
|
21553
|
+
BaseViewer.call(this, options);
|
|
22253
21554
|
}
|
|
22254
21555
|
|
|
21556
|
+
e(Viewer$1, BaseViewer);
|
|
21557
|
+
|
|
21558
|
+
// modules the viewer is composed of
|
|
21559
|
+
Viewer$1.prototype._modules = [
|
|
21560
|
+
CoreModule$1,
|
|
21561
|
+
TranslateModule,
|
|
21562
|
+
SelectionModule,
|
|
21563
|
+
OverlaysModule,
|
|
21564
|
+
DrilldownModdule
|
|
21565
|
+
];
|
|
21566
|
+
|
|
21567
|
+
// default moddle extensions the viewer is composed of
|
|
21568
|
+
Viewer$1.prototype._moddleExtensions = {};
|
|
21569
|
+
|
|
22255
21570
|
function getModelerTemplateIcon(element) {
|
|
22256
21571
|
var modelerTemplateIcon = getBusinessObject(element).get('zeebe:modelerTemplateIcon');
|
|
22257
21572
|
return modelerTemplateIcon;
|
|
@@ -22291,8 +21606,8 @@
|
|
|
22291
21606
|
|
|
22292
21607
|
var modelerTemplateIcon = getModelerTemplateIcon(element);
|
|
22293
21608
|
|
|
22294
|
-
var icon = create('image');
|
|
22295
|
-
attr(icon, {
|
|
21609
|
+
var icon = create$1('image');
|
|
21610
|
+
attr$1(icon, {
|
|
22296
21611
|
href: modelerTemplateIcon,
|
|
22297
21612
|
x: 5,
|
|
22298
21613
|
y: 5,
|
|
@@ -22722,6 +22037,29 @@
|
|
|
22722
22037
|
type: "String"
|
|
22723
22038
|
}
|
|
22724
22039
|
]
|
|
22040
|
+
},
|
|
22041
|
+
{
|
|
22042
|
+
name: "Script",
|
|
22043
|
+
superClass: [
|
|
22044
|
+
"Element"
|
|
22045
|
+
],
|
|
22046
|
+
meta: {
|
|
22047
|
+
allowedIn: [
|
|
22048
|
+
"bpmn:ScriptTask"
|
|
22049
|
+
]
|
|
22050
|
+
},
|
|
22051
|
+
properties: [
|
|
22052
|
+
{
|
|
22053
|
+
name: "expression",
|
|
22054
|
+
type: "String",
|
|
22055
|
+
isAttr: true
|
|
22056
|
+
},
|
|
22057
|
+
{
|
|
22058
|
+
name: "resultVariable",
|
|
22059
|
+
type: "String",
|
|
22060
|
+
isAttr: true
|
|
22061
|
+
}
|
|
22062
|
+
]
|
|
22725
22063
|
}
|
|
22726
22064
|
];
|
|
22727
22065
|
var zeebeModdle = {
|