bpmn-js 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ All notable changes to [bpmn-js](https://github.com/bpmn-io/bpmn-js) are documen
6
6
 
7
7
  ___Note:__ Yet to be released changes appear here._
8
8
 
9
+ ## 3.5.0
10
+
11
+ * `FEAT`: restore `Viewer#importDefinitions` and make it public API ([#1112](https://github.com/bpmn-io/bpmn-js/pull/1112))
12
+
13
+ ## 3.4.3
14
+
15
+ * `FIX`: prevent HTML injection in search ([diagram-js#362](https://github.com/bpmn-io/diagram-js/pull/362))
16
+
17
+ ## 3.4.2
18
+
19
+ * `FIX`: do not evaluate pasted text as HTML ([#1073](https://github.com/bpmn-io/bpmn-js/issues/1073))
20
+
21
+ ## 3.4.1
22
+
23
+ _Republish of `v3.4.0` without `.git` folder._
24
+
9
25
  ## 3.4.0
10
26
 
11
27
  * `FIX`: properly render colored connection markers ([#981](https://github.com/bpmn-io/bpmn-js/issues/981))
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v3.4.0
2
+ * bpmn-js - bpmn-modeler v3.5.0
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2019-04-25
11
+ * Date: 2019-06-28
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -20260,9 +20260,7 @@
20260
20260
  return done(err, parseWarnings);
20261
20261
  }
20262
20262
 
20263
- self._setDefinitions(definitions);
20264
-
20265
- self.open(bpmnDiagram, function(err, importWarnings) {
20263
+ self.importDefinitions(definitions, bpmnDiagram, function(err, importWarnings) {
20266
20264
  var allWarnings = [].concat(parseWarnings, importWarnings || []);
20267
20265
 
20268
20266
  self._emit('import.done', { error: err, warnings: allWarnings });
@@ -20272,6 +20270,40 @@
20272
20270
  });
20273
20271
  };
20274
20272
 
20273
+ /**
20274
+ * Import parsed definitions and render a BPMN 2.0 diagram.
20275
+ *
20276
+ * Once finished the viewer reports back the result to the
20277
+ * provided callback function with (err, warnings).
20278
+ *
20279
+ * ## Life-Cycle Events
20280
+ *
20281
+ * During import the viewer will fire life-cycle events:
20282
+ *
20283
+ * * import.render.start (graphical import start)
20284
+ * * import.render.complete (graphical import finished)
20285
+ *
20286
+ * You can use these events to hook into the life-cycle.
20287
+ *
20288
+ * @param {ModdleElement<Definitions>} definitions parsed BPMN 2.0 definitions
20289
+ * @param {ModdleElement<BPMNDiagram>|String} [bpmnDiagram] BPMN diagram or id of diagram to render (if not provided, the first one will be rendered)
20290
+ * @param {Function} [done] invoked with (err, warnings=[])
20291
+ */
20292
+ Viewer.prototype.importDefinitions = function(definitions, bpmnDiagram, done) {
20293
+
20294
+ if (isFunction(bpmnDiagram)) {
20295
+ done = bpmnDiagram;
20296
+ bpmnDiagram = null;
20297
+ }
20298
+
20299
+ // done is optional
20300
+ done = done || function() {};
20301
+
20302
+ this._setDefinitions(definitions);
20303
+
20304
+ return this.open(bpmnDiagram, done);
20305
+ };
20306
+
20275
20307
  /**
20276
20308
  * Open diagram of previously imported XML.
20277
20309
  *
@@ -26986,6 +27018,17 @@
26986
27018
  }));
26987
27019
  });
26988
27020
 
27021
+ var HTML_ESCAPE_MAP = {
27022
+ '<': '&lt',
27023
+ '>': '&gt'
27024
+ };
27025
+
27026
+ function escapeHTML(str) {
27027
+ return str.replace(/[<>]/g, function(match) {
27028
+ return HTML_ESCAPE_MAP[match];
27029
+ });
27030
+ }
27031
+
26989
27032
  var round$2 = Math.round,
26990
27033
  max = Math.max;
26991
27034
 
@@ -28396,8 +28439,6 @@
28396
28439
  * Intercept paste events to remove formatting from pasted text.
28397
28440
  */
28398
28441
  TextBox.prototype.handlePaste = function(e) {
28399
- var self = this;
28400
-
28401
28442
  var options = this.options,
28402
28443
  style = this.style;
28403
28444
 
@@ -28415,77 +28456,88 @@
28415
28456
  text = window.clipboardData.getData('Text');
28416
28457
  }
28417
28458
 
28418
- // insertHTML command not supported by Internet Explorer
28419
- var success = document.execCommand('insertHTML', false, text);
28459
+ this.insertText(text);
28420
28460
 
28421
- if (!success) {
28461
+ if (options.autoResize) {
28462
+ var hasResized = this.autoResize(style);
28422
28463
 
28423
- // Internet Explorer
28424
- var range = this.getSelection(),
28425
- startContainer = range.startContainer,
28426
- endContainer = range.endContainer,
28427
- startOffset = range.startOffset,
28428
- endOffset = range.endOffset,
28429
- commonAncestorContainer = range.commonAncestorContainer;
28464
+ if (hasResized) {
28465
+ this.resizeHandler(hasResized);
28466
+ }
28467
+ }
28468
+ };
28430
28469
 
28431
- var childNodesArray = toArray(commonAncestorContainer.childNodes);
28470
+ TextBox.prototype.insertText = function(text) {
28432
28471
 
28433
- var container,
28434
- offset;
28472
+ // insertText command not supported by Internet Explorer
28473
+ var success = document.execCommand('insertText', false, text);
28435
28474
 
28436
- if (isTextNode(commonAncestorContainer)) {
28437
- var containerTextContent = startContainer.textContent;
28475
+ if (success) {
28476
+ return;
28477
+ }
28438
28478
 
28439
- startContainer.textContent =
28440
- containerTextContent.substring(0, startOffset)
28441
- + text
28442
- + containerTextContent.substring(endOffset);
28479
+ this._insertTextIE(text);
28480
+ };
28443
28481
 
28444
- container = startContainer;
28445
- offset = startOffset + text.length;
28482
+ TextBox.prototype._insertTextIE = function(text) {
28446
28483
 
28447
- } else if (startContainer === this.content && endContainer === this.content) {
28448
- var textNode = document.createTextNode(text);
28484
+ // Internet Explorer
28485
+ var range = this.getSelection(),
28486
+ startContainer = range.startContainer,
28487
+ endContainer = range.endContainer,
28488
+ startOffset = range.startOffset,
28489
+ endOffset = range.endOffset,
28490
+ commonAncestorContainer = range.commonAncestorContainer;
28449
28491
 
28450
- this.content.insertBefore(textNode, childNodesArray[startOffset]);
28492
+ var childNodesArray = toArray(commonAncestorContainer.childNodes);
28451
28493
 
28452
- container = textNode;
28453
- offset = textNode.textContent.length;
28454
- } else {
28455
- var startContainerChildIndex = childNodesArray.indexOf(startContainer),
28456
- endContainerChildIndex = childNodesArray.indexOf(endContainer);
28457
-
28458
- childNodesArray.forEach(function(childNode, index) {
28459
-
28460
- if (index === startContainerChildIndex) {
28461
- childNode.textContent =
28462
- startContainer.textContent.substring(0, startOffset) +
28463
- text +
28464
- endContainer.textContent.substring(endOffset);
28465
- } else if (index > startContainerChildIndex && index <= endContainerChildIndex) {
28466
- remove(childNode);
28467
- }
28468
- });
28494
+ var container,
28495
+ offset;
28469
28496
 
28470
- container = startContainer;
28471
- offset = startOffset + text.length;
28472
- }
28497
+ if (isTextNode(commonAncestorContainer)) {
28498
+ var containerTextContent = startContainer.textContent;
28473
28499
 
28474
- if (container && offset !== undefined) {
28500
+ startContainer.textContent =
28501
+ containerTextContent.substring(0, startOffset)
28502
+ + text
28503
+ + containerTextContent.substring(endOffset);
28475
28504
 
28476
- // is necessary in Internet Explorer
28477
- setTimeout(function() {
28478
- self.setSelection(container, offset);
28479
- });
28480
- }
28505
+ container = startContainer;
28506
+ offset = startOffset + text.length;
28507
+
28508
+ } else if (startContainer === this.content && endContainer === this.content) {
28509
+ var textNode = document.createTextNode(text);
28510
+
28511
+ this.content.insertBefore(textNode, childNodesArray[startOffset]);
28512
+
28513
+ container = textNode;
28514
+ offset = textNode.textContent.length;
28515
+ } else {
28516
+ var startContainerChildIndex = childNodesArray.indexOf(startContainer),
28517
+ endContainerChildIndex = childNodesArray.indexOf(endContainer);
28518
+
28519
+ childNodesArray.forEach(function(childNode, index) {
28520
+
28521
+ if (index === startContainerChildIndex) {
28522
+ childNode.textContent =
28523
+ startContainer.textContent.substring(0, startOffset) +
28524
+ text +
28525
+ endContainer.textContent.substring(endOffset);
28526
+ } else if (index > startContainerChildIndex && index <= endContainerChildIndex) {
28527
+ remove(childNode);
28528
+ }
28529
+ });
28530
+
28531
+ container = startContainer;
28532
+ offset = startOffset + text.length;
28481
28533
  }
28482
28534
 
28483
- if (options.autoResize) {
28484
- var hasResized = this.autoResize(style);
28535
+ if (container && offset !== undefined) {
28485
28536
 
28486
- if (hasResized) {
28487
- this.resizeHandler(hasResized);
28488
- }
28537
+ // is necessary in Internet Explorer
28538
+ setTimeout(function() {
28539
+ self.setSelection(container, offset);
28540
+ });
28489
28541
  }
28490
28542
  };
28491
28543
 
@@ -50736,9 +50788,9 @@
50736
50788
 
50737
50789
  tokens.forEach(function(t) {
50738
50790
  if (t.matched) {
50739
- htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + t.matched + '</strong>';
50791
+ htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + escapeHTML(t.matched) + '</strong>';
50740
50792
  } else {
50741
- htmlText += t.normal;
50793
+ htmlText += escapeHTML(t.normal);
50742
50794
  }
50743
50795
  });
50744
50796