tinymce-rails 5.5.1 → 5.6.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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/source/tinymce/tinymce.js +780 -450
  3. data/lib/tinymce/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/tinymce/plugins/advlist/plugin.js +1 -1
  5. data/vendor/assets/javascripts/tinymce/plugins/anchor/plugin.js +1 -1
  6. data/vendor/assets/javascripts/tinymce/plugins/autolink/plugin.js +1 -1
  7. data/vendor/assets/javascripts/tinymce/plugins/autoresize/plugin.js +1 -1
  8. data/vendor/assets/javascripts/tinymce/plugins/autosave/plugin.js +2 -2
  9. data/vendor/assets/javascripts/tinymce/plugins/bbcode/plugin.js +1 -1
  10. data/vendor/assets/javascripts/tinymce/plugins/charmap/plugin.js +1 -1
  11. data/vendor/assets/javascripts/tinymce/plugins/code/plugin.js +1 -1
  12. data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +2 -2
  13. data/vendor/assets/javascripts/tinymce/plugins/colorpicker/plugin.js +1 -1
  14. data/vendor/assets/javascripts/tinymce/plugins/contextmenu/plugin.js +1 -1
  15. data/vendor/assets/javascripts/tinymce/plugins/directionality/plugin.js +1 -1
  16. data/vendor/assets/javascripts/tinymce/plugins/emoticons/js/emojiimages.js +3 -0
  17. data/vendor/assets/javascripts/tinymce/plugins/emoticons/js/emojis.js +2 -2
  18. data/vendor/assets/javascripts/tinymce/plugins/emoticons/plugin.js +2 -2
  19. data/vendor/assets/javascripts/tinymce/plugins/fullpage/plugin.js +2 -2
  20. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.js +2 -2
  21. data/vendor/assets/javascripts/tinymce/plugins/help/plugin.js +1 -1
  22. data/vendor/assets/javascripts/tinymce/plugins/hr/plugin.js +1 -1
  23. data/vendor/assets/javascripts/tinymce/plugins/image/plugin.js +2 -2
  24. data/vendor/assets/javascripts/tinymce/plugins/imagetools/plugin.js +2 -2
  25. data/vendor/assets/javascripts/tinymce/plugins/importcss/plugin.js +1 -1
  26. data/vendor/assets/javascripts/tinymce/plugins/insertdatetime/plugin.js +1 -1
  27. data/vendor/assets/javascripts/tinymce/plugins/legacyoutput/plugin.js +1 -1
  28. data/vendor/assets/javascripts/tinymce/plugins/link/plugin.js +2 -2
  29. data/vendor/assets/javascripts/tinymce/plugins/lists/plugin.js +2 -2
  30. data/vendor/assets/javascripts/tinymce/plugins/media/plugin.js +1 -1
  31. data/vendor/assets/javascripts/tinymce/plugins/nonbreaking/plugin.js +1 -1
  32. data/vendor/assets/javascripts/tinymce/plugins/noneditable/plugin.js +1 -1
  33. data/vendor/assets/javascripts/tinymce/plugins/pagebreak/plugin.js +1 -1
  34. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.js +2 -2
  35. data/vendor/assets/javascripts/tinymce/plugins/preview/plugin.js +1 -1
  36. data/vendor/assets/javascripts/tinymce/plugins/print/plugin.js +1 -1
  37. data/vendor/assets/javascripts/tinymce/plugins/quickbars/plugin.js +1 -1
  38. data/vendor/assets/javascripts/tinymce/plugins/save/plugin.js +1 -1
  39. data/vendor/assets/javascripts/tinymce/plugins/searchreplace/plugin.js +1 -1
  40. data/vendor/assets/javascripts/tinymce/plugins/spellchecker/plugin.js +1 -1
  41. data/vendor/assets/javascripts/tinymce/plugins/tabfocus/plugin.js +1 -1
  42. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +2 -2
  43. data/vendor/assets/javascripts/tinymce/plugins/template/plugin.js +1 -1
  44. data/vendor/assets/javascripts/tinymce/plugins/textcolor/plugin.js +1 -1
  45. data/vendor/assets/javascripts/tinymce/plugins/textpattern/plugin.js +2 -2
  46. data/vendor/assets/javascripts/tinymce/plugins/toc/plugin.js +1 -1
  47. data/vendor/assets/javascripts/tinymce/plugins/visualblocks/plugin.js +1 -1
  48. data/vendor/assets/javascripts/tinymce/plugins/visualchars/plugin.js +2 -2
  49. data/vendor/assets/javascripts/tinymce/plugins/wordcount/plugin.js +1 -1
  50. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.css +1 -1
  51. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.inline.css +1 -1
  52. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.inline.min.css +1 -1
  53. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/content.min.css +1 -1
  54. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.css +1 -1
  55. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.min.css +1 -1
  56. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +7 -0
  57. data/vendor/assets/javascripts/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +7 -0
  58. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.css +1 -1
  59. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.inline.css +1 -1
  60. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.inline.min.css +1 -1
  61. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/content.min.css +1 -1
  62. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.css +1 -1
  63. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.min.css +1 -1
  64. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.shadowdom.css +7 -0
  65. data/vendor/assets/javascripts/tinymce/skins/ui/oxide/skin.shadowdom.min.css +7 -0
  66. data/vendor/assets/javascripts/tinymce/themes/mobile/theme.js +2 -2
  67. data/vendor/assets/javascripts/tinymce/themes/silver/theme.js +2 -2
  68. data/vendor/assets/javascripts/tinymce/tinymce.d.ts +174 -78
  69. data/vendor/assets/javascripts/tinymce/tinymce.js +2 -2
  70. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 113fca8ae4c444500ff85d979c20bb64e34ca97a1fda0e40c1a47e65085b1250
4
- data.tar.gz: 592de1c1097a36a507a921803418cfe928232e405b10a5b21f6165247fad962b
3
+ metadata.gz: 159f4e2fdda26948b13381017ab9afdb2d87015b6614135910505a7536d7e46f
4
+ data.tar.gz: 7a23784af13bed8369f6dd42e1b8c0de9b1791cabfa511889df796557b32666a
5
5
  SHA512:
6
- metadata.gz: af95120e37b030f52e51078df0e8c15666bb0c35484229ae7f45d5d0ed62c244c71f4fdb28e5383e7bf70004766157a8cb7820fcfec766a7a4ad43f292c03037
7
- data.tar.gz: '0427567282b18365d2145c8c85e4f4ff83e4e660b73bdc97cf090f684284db7b4ede1b34fef62c862f9ea44b7a4acd40633e91e8f87175cd432da8c895db4a6b'
6
+ metadata.gz: d36b43a193e73f2d63120bbea00e6cbb253b5fa225dcdce7e05e1d8cd803f2d3226458a4d4a85c0cc5f6df67235db160c83b8c6a26b0c95b6219d6c2925e1e39
7
+ data.tar.gz: 933b751478bcf2b5d2fcc6010311bccefb8bc1e65af5580d7c7ff1057cd0ec45e7e57135025b565ca17ce685263794e91945b50bc072f3f20b3cc9f8e0492eb5
@@ -4,7 +4,7 @@
4
4
  * For LGPL see License.txt in the project root for license information.
5
5
  * For commercial licenses see https://www.tiny.cloud/
6
6
  *
7
- * Version: 5.5.1 (2020-10-01)
7
+ * Version: 5.6.0 (2020-11-18)
8
8
  */
9
9
  (function () {
10
10
  'use strict';
@@ -157,6 +157,9 @@
157
157
  throw new Error(msg);
158
158
  };
159
159
  };
160
+ var call = function (f) {
161
+ f();
162
+ };
160
163
  var never = constant(false);
161
164
  var always = constant(true);
162
165
 
@@ -454,15 +457,27 @@
454
457
  copy.sort(comparator);
455
458
  return copy;
456
459
  };
460
+ var get = function (xs, i) {
461
+ return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
462
+ };
457
463
  var head = function (xs) {
458
- return xs.length === 0 ? Optional.none() : Optional.some(xs[0]);
464
+ return get(xs, 0);
459
465
  };
460
466
  var last = function (xs) {
461
- return xs.length === 0 ? Optional.none() : Optional.some(xs[xs.length - 1]);
467
+ return get(xs, xs.length - 1);
462
468
  };
463
469
  var from$1 = isFunction(Array.from) ? Array.from : function (x) {
464
470
  return nativeSlice.call(x);
465
471
  };
472
+ var findMap = function (arr, f) {
473
+ for (var i = 0; i < arr.length; i++) {
474
+ var r = f(arr[i], i);
475
+ if (r.isSome()) {
476
+ return r;
477
+ }
478
+ }
479
+ return Optional.none();
480
+ };
466
481
 
467
482
  var keys = Object.keys;
468
483
  var hasOwnProperty = Object.hasOwnProperty;
@@ -528,12 +543,15 @@
528
543
  return v;
529
544
  });
530
545
  };
531
- var get = function (obj, key) {
546
+ var get$1 = function (obj, key) {
532
547
  return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
533
548
  };
534
549
  var has = function (obj, key) {
535
550
  return hasOwnProperty.call(obj, key);
536
551
  };
552
+ var hasNonNullableKey = function (obj, key) {
553
+ return has(obj, key) && obj[key] !== undefined && obj[key] !== null;
554
+ };
537
555
  var equal = function (a1, a2, eq) {
538
556
  if (eq === void 0) {
539
557
  eq = eqAny;
@@ -766,9 +784,16 @@
766
784
  detectOs: detectOs
767
785
  };
768
786
 
787
+ var removeFromStart = function (str, numChars) {
788
+ return str.substring(numChars);
789
+ };
790
+
769
791
  var checkRange = function (str, substr, start) {
770
792
  return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
771
793
  };
794
+ var removeLeading = function (str, prefix) {
795
+ return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
796
+ };
772
797
  var contains$1 = function (str, substr) {
773
798
  return str.indexOf(substr) !== -1;
774
799
  };
@@ -1617,7 +1642,7 @@
1617
1642
  return boxPosition(dom);
1618
1643
  };
1619
1644
 
1620
- var get$1 = function (_DOC) {
1645
+ var get$2 = function (_DOC) {
1621
1646
  var doc = _DOC !== undefined ? _DOC.dom : document;
1622
1647
  var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
1623
1648
  var y = doc.body.scrollTop || doc.documentElement.scrollTop;
@@ -1639,7 +1664,7 @@
1639
1664
  }
1640
1665
  };
1641
1666
 
1642
- var get$2 = function (_win) {
1667
+ var get$3 = function (_win) {
1643
1668
  var win = _win === undefined ? window : _win;
1644
1669
  return Optional.from(win['visualViewport']);
1645
1670
  };
@@ -1656,8 +1681,8 @@
1656
1681
  var getBounds = function (_win) {
1657
1682
  var win = _win === undefined ? window : _win;
1658
1683
  var doc = win.document;
1659
- var scroll = get$1(SugarElement.fromDom(doc));
1660
- return get$2(win).fold(function () {
1684
+ var scroll = get$2(SugarElement.fromDom(doc));
1685
+ return get$3(win).fold(function () {
1661
1686
  var html = win.document.documentElement;
1662
1687
  var width = html.clientWidth;
1663
1688
  var height = html.clientHeight;
@@ -1780,12 +1805,12 @@
1780
1805
  rawSet(dom, k, v);
1781
1806
  });
1782
1807
  };
1783
- var get$3 = function (element, key) {
1808
+ var get$4 = function (element, key) {
1784
1809
  var v = element.dom.getAttribute(key);
1785
1810
  return v === null ? undefined : v;
1786
1811
  };
1787
1812
  var getOpt = function (element, key) {
1788
- return Optional.from(get$3(element, key));
1813
+ return Optional.from(get$4(element, key));
1789
1814
  };
1790
1815
  var has$1 = function (element, key) {
1791
1816
  var dom = element.dom;
@@ -1816,7 +1841,7 @@
1816
1841
  internalSet(dom, k, v);
1817
1842
  });
1818
1843
  };
1819
- var get$4 = function (element, property) {
1844
+ var get$5 = function (element, property) {
1820
1845
  var dom = element.dom;
1821
1846
  var styles = window.getComputedStyle(dom);
1822
1847
  var r = styles.getPropertyValue(property);
@@ -1876,7 +1901,7 @@
1876
1901
  var pos;
1877
1902
  rootElm = rootElm ? rootElm : body;
1878
1903
  if (elm) {
1879
- if (rootElm === body && elm.getBoundingClientRect && get$4(SugarElement.fromDom(body), 'position') === 'static') {
1904
+ if (rootElm === body && elm.getBoundingClientRect && get$5(SugarElement.fromDom(body), 'position') === 'static') {
1880
1905
  pos = elm.getBoundingClientRect();
1881
1906
  x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - doc.documentElement.clientLeft;
1882
1907
  y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - doc.documentElement.clientTop;
@@ -2757,7 +2782,13 @@
2757
2782
  };
2758
2783
 
2759
2784
  function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {
2760
- return is(scope, a) ? Optional.some(scope) : isFunction(isRoot) && isRoot(scope) ? Optional.none() : ancestor(scope, a, isRoot);
2785
+ if (is(scope, a)) {
2786
+ return Optional.some(scope);
2787
+ } else if (isFunction(isRoot) && isRoot(scope)) {
2788
+ return Optional.none();
2789
+ } else {
2790
+ return ancestor(scope, a, isRoot);
2791
+ }
2761
2792
  }
2762
2793
 
2763
2794
  var ancestor = function (scope, predicate, isRoot) {
@@ -2780,6 +2811,22 @@
2780
2811
  };
2781
2812
  return ClosestOrAncestor(is, ancestor, scope, predicate, isRoot);
2782
2813
  };
2814
+ var sibling = function (scope, predicate) {
2815
+ var element = scope.dom;
2816
+ if (!element.parentNode) {
2817
+ return Optional.none();
2818
+ }
2819
+ return child$1(SugarElement.fromDom(element.parentNode), function (x) {
2820
+ return !eq$2(scope, x) && predicate(x);
2821
+ });
2822
+ };
2823
+ var child$1 = function (scope, predicate) {
2824
+ var pred = function (node) {
2825
+ return predicate(SugarElement.fromDom(node));
2826
+ };
2827
+ var result = find(scope.dom.childNodes, pred);
2828
+ return result.map(SugarElement.fromDom);
2829
+ };
2783
2830
 
2784
2831
  var ancestor$1 = function (scope, selector, isRoot) {
2785
2832
  return ancestor(scope, function (e) {
@@ -3078,7 +3125,7 @@
3078
3125
  descendant(styleContainer, '#' + id).each(remove);
3079
3126
  };
3080
3127
  var getOrCreateState = function (url) {
3081
- return get(loadedStates, url).getOrThunk(function () {
3128
+ return get$1(loadedStates, url).getOrThunk(function () {
3082
3129
  return {
3083
3130
  id: 'mce-u' + idCount++,
3084
3131
  passed: [],
@@ -3193,7 +3240,7 @@
3193
3240
  };
3194
3241
  var unload = function (url) {
3195
3242
  var urlWithSuffix = Tools._addCacheSuffix(url);
3196
- get(loadedStates, urlWithSuffix).each(function (state) {
3243
+ get$1(loadedStates, urlWithSuffix).each(function (state) {
3197
3244
  var count = --state.count;
3198
3245
  if (count === 0) {
3199
3246
  delete loadedStates[urlWithSuffix];
@@ -4392,7 +4439,7 @@
4392
4439
  elements[items[1]].outputName = items[0];
4393
4440
  });
4394
4441
  }
4395
- each$3(split('ol ul sub sup blockquote span font a table tbody tr strong em b i'), function (name) {
4442
+ each$3(split('ol ul sub sup blockquote span font a table tbody strong em b i'), function (name) {
4396
4443
  if (elements[name]) {
4397
4444
  elements[name].removeEmpty = true;
4398
4445
  }
@@ -4873,13 +4920,16 @@
4873
4920
  eventUtils.domLoaded = true;
4874
4921
  callback(event);
4875
4922
  }
4923
+ win = null;
4876
4924
  };
4877
4925
  if (isDocReady()) {
4878
4926
  readyHandler();
4879
4927
  } else {
4880
4928
  addEvent(win, 'DOMContentLoaded', readyHandler);
4881
4929
  }
4882
- addEvent(win, 'load', readyHandler);
4930
+ if (!eventUtils.domLoaded) {
4931
+ addEvent(win, 'load', readyHandler);
4932
+ }
4883
4933
  };
4884
4934
  var EventUtils = function () {
4885
4935
  function EventUtils() {
@@ -6778,7 +6828,7 @@
6778
6828
  }
6779
6829
  return matched;
6780
6830
  };
6781
- var sibling = function (node, siblingName, nodeType, until) {
6831
+ var sibling$1 = function (node, siblingName, nodeType, until) {
6782
6832
  var result = [];
6783
6833
  if (until instanceof DomQuery) {
6784
6834
  until = until[0];
@@ -6822,7 +6872,7 @@
6822
6872
  return firstSibling(node, 'previousSibling', 1);
6823
6873
  },
6824
6874
  children: function (node) {
6825
- return sibling(node.firstChild, 'nextSibling', 1);
6875
+ return sibling$1(node.firstChild, 'nextSibling', 1);
6826
6876
  },
6827
6877
  contents: function (node) {
6828
6878
  return Tools.toArray((node.nodeName === 'iframe' ? node.contentDocument || node.contentWindow.document : node).childNodes);
@@ -6861,10 +6911,10 @@
6861
6911
  return dir(node, 'parentNode', until);
6862
6912
  },
6863
6913
  nextUntil: function (node, until) {
6864
- return sibling(node, 'nextSibling', 1, until).slice(1);
6914
+ return sibling$1(node, 'nextSibling', 1, until).slice(1);
6865
6915
  },
6866
6916
  prevUntil: function (node, until) {
6867
- return sibling(node, 'previousSibling', 1, until).slice(1);
6917
+ return sibling$1(node, 'previousSibling', 1, until).slice(1);
6868
6918
  }
6869
6919
  }, function (name, fn) {
6870
6920
  DomQueryConstructor.fn[name] = function (selector, filter) {
@@ -7201,7 +7251,7 @@
7201
7251
  }
7202
7252
  }
7203
7253
  while (node) {
7204
- if (node === root || !node.nodeType || node.nodeType === 9) {
7254
+ if (node === root || isNullable(node.nodeType) || isDocument$1(node) || isDocumentFragment$1(node)) {
7205
7255
  break;
7206
7256
  }
7207
7257
  if (!selector || typeof selector === 'function' && selector(node)) {
@@ -7795,14 +7845,18 @@
7795
7845
  ScriptLoader.prototype.loadScript = function (url, success, failure) {
7796
7846
  var dom = DOM;
7797
7847
  var elm;
7798
- var done = function () {
7848
+ var cleanup = function () {
7799
7849
  dom.remove(id);
7800
7850
  if (elm) {
7801
- elm.onreadystatechange = elm.onload = elm = null;
7851
+ elm.onerror = elm.onload = elm = null;
7802
7852
  }
7853
+ };
7854
+ var done = function () {
7855
+ cleanup();
7803
7856
  success();
7804
7857
  };
7805
7858
  var error = function () {
7859
+ cleanup();
7806
7860
  if (isFunction(failure)) {
7807
7861
  failure();
7808
7862
  } else {
@@ -7831,8 +7885,8 @@
7831
7885
  };
7832
7886
  ScriptLoader.prototype.add = function (url, success, scope, failure) {
7833
7887
  var state = this.states[url];
7888
+ this.queue.push(url);
7834
7889
  if (state === undefined) {
7835
- this.queue.push(url);
7836
7890
  this.states[url] = QUEUED;
7837
7891
  }
7838
7892
  if (success) {
@@ -7946,7 +8000,7 @@
7946
8000
  var data = {};
7947
8001
  var currentCode = Cell('en');
7948
8002
  var getLanguageData = function () {
7949
- return get(data, currentCode.get());
8003
+ return get$1(data, currentCode.get());
7950
8004
  };
7951
8005
  var getData = function () {
7952
8006
  return map$1(data, function (value) {
@@ -7983,7 +8037,7 @@
7983
8037
  };
7984
8038
  var getLangData = function (text) {
7985
8039
  var textstr = toString(text);
7986
- return get(langData, textstr.toLowerCase()).map(toString).getOr(textstr);
8040
+ return get$1(langData, textstr.toLowerCase()).map(toString).getOr(textstr);
7987
8041
  };
7988
8042
  var removeContext = function (str) {
7989
8043
  return str.replace(/{context:\w+}$/, '');
@@ -8005,7 +8059,7 @@
8005
8059
  };
8006
8060
  var isRtl = function () {
8007
8061
  return getLanguageData().bind(function (items) {
8008
- return get(items, '_dir');
8062
+ return get$1(items, '_dir');
8009
8063
  }).exists(function (dir) {
8010
8064
  return dir === 'rtl';
8011
8065
  });
@@ -8220,7 +8274,7 @@
8220
8274
  };
8221
8275
 
8222
8276
  var read = function (element, attr) {
8223
- var value = get$3(element, attr);
8277
+ var value = get$4(element, attr);
8224
8278
  return value === undefined || value === '' ? [] : value.split(' ');
8225
8279
  };
8226
8280
  var add$1 = function (element, attr, id) {
@@ -8244,7 +8298,7 @@
8244
8298
  var supports = function (element) {
8245
8299
  return element.dom.classList !== undefined;
8246
8300
  };
8247
- var get$5 = function (element) {
8301
+ var get$6 = function (element) {
8248
8302
  return read(element, 'class');
8249
8303
  };
8250
8304
  var add$2 = function (element, clazz) {
@@ -8262,7 +8316,7 @@
8262
8316
  }
8263
8317
  };
8264
8318
  var cleanClass = function (element) {
8265
- var classList = supports(element) ? element.dom.classList : get$5(element);
8319
+ var classList = supports(element) ? element.dom.classList : get$6(element);
8266
8320
  if (classList.length === 0) {
8267
8321
  remove$1(element, 'class');
8268
8322
  }
@@ -8314,7 +8368,7 @@
8314
8368
  });
8315
8369
  var getAttr = function (c, property) {
8316
8370
  if (has$1(c, property)) {
8317
- return Optional.some(get$3(c, property));
8371
+ return Optional.some(get$4(c, property));
8318
8372
  } else {
8319
8373
  return Optional.none();
8320
8374
  }
@@ -8344,7 +8398,7 @@
8344
8398
  var markers = descendants$1(body, '[' + dataAnnotation() + '="' + name + '"]');
8345
8399
  var directory = {};
8346
8400
  each(markers, function (m) {
8347
- var uid = get$3(m, dataAnnotationId());
8401
+ var uid = get$4(m, dataAnnotationId());
8348
8402
  var nodesAlready = directory.hasOwnProperty(uid) ? directory[uid] : [];
8349
8403
  directory[uid] = nodesAlready.concat([m]);
8350
8404
  });
@@ -8491,7 +8545,7 @@
8491
8545
  return children(SugarElement.fromDom(div));
8492
8546
  };
8493
8547
 
8494
- var get$6 = function (element) {
8548
+ var get$7 = function (element) {
8495
8549
  return element.dom.innerHTML;
8496
8550
  };
8497
8551
  var set$1 = function (element, content) {
@@ -9493,6 +9547,9 @@
9493
9547
  return '';
9494
9548
  }
9495
9549
  };
9550
+ var canFormatEmptyLines = function (editor) {
9551
+ return editor.getParam('format_empty_lines', false, 'boolean');
9552
+ };
9496
9553
  var getCustomUiSelector = function (editor) {
9497
9554
  return editor.getParam('custom_ui_selector', '', 'string');
9498
9555
  };
@@ -9541,6 +9598,15 @@
9541
9598
  var shouldBlockUnsupportedDrop = function (editor) {
9542
9599
  return editor.getParam('block_unsupported_drop', true, 'boolean');
9543
9600
  };
9601
+ var isVisualAidsEnabled = function (editor) {
9602
+ return editor.getParam('visual', true, 'boolean');
9603
+ };
9604
+ var getVisualAidsTableClass = function (editor) {
9605
+ return editor.getParam('visual_table_class', 'mce-item-table', 'string');
9606
+ };
9607
+ var getVisualAidsAnchorClass = function (editor) {
9608
+ return editor.getParam('visual_anchor_class', 'mce-item-anchor', 'string');
9609
+ };
9544
9610
 
9545
9611
  var isElement$4 = isElement$1;
9546
9612
  var isText$6 = isText$1;
@@ -10528,11 +10594,19 @@
10528
10594
  var isValid = function (ed, parent, child) {
10529
10595
  return ed.schema.isValidChild(parent, child);
10530
10596
  };
10531
- var isWhiteSpaceNode = function (node) {
10532
- return node && isText$1(node) && /^([\t \r\n]+|)$/.test(node.nodeValue);
10597
+ var isWhiteSpaceNode = function (node, allowSpaces) {
10598
+ if (allowSpaces === void 0) {
10599
+ allowSpaces = false;
10600
+ }
10601
+ if (isNonNullable(node) && isText$1(node)) {
10602
+ var data = allowSpaces ? node.data.replace(/ /g, '\xA0') : node.data;
10603
+ return isWhitespaceText(data);
10604
+ } else {
10605
+ return false;
10606
+ }
10533
10607
  };
10534
10608
  var isEmptyTextNode = function (node) {
10535
- return node && isText$1(node) && node.length === 0;
10609
+ return isNonNullable(node) && isText$1(node) && node.length === 0;
10536
10610
  };
10537
10611
  var replaceVars = function (value, vars) {
10538
10612
  if (typeof value !== 'string') {
@@ -10586,7 +10660,7 @@
10586
10660
  'styles',
10587
10661
  'attributes'
10588
10662
  ], function (key) {
10589
- return get(format, key).exists(function (field) {
10663
+ return get$1(format, key).exists(function (field) {
10590
10664
  var fieldValues = isArray(field) ? field : values(field);
10591
10665
  return exists(fieldValues, isVariableValue);
10592
10666
  });
@@ -10618,13 +10692,22 @@
10618
10692
  });
10619
10693
  });
10620
10694
  };
10695
+ var isBlockFormat = function (format) {
10696
+ return hasNonNullableKey(format, 'block');
10697
+ };
10698
+ var isSelectorFormat = function (format) {
10699
+ return hasNonNullableKey(format, 'selector');
10700
+ };
10701
+ var isInlineFormat = function (format) {
10702
+ return hasNonNullableKey(format, 'inline');
10703
+ };
10621
10704
 
10622
10705
  var isBookmarkNode$2 = isBookmarkNode$1;
10623
10706
  var getParents$2 = getParents$1;
10624
10707
  var isWhiteSpaceNode$1 = isWhiteSpaceNode;
10625
10708
  var isTextBlock$2 = isTextBlock$1;
10626
10709
  var isBogusBr = function (node) {
10627
- return node.nodeName === 'BR' && node.getAttribute('data-mce-bogus') && !node.nextSibling;
10710
+ return isBr(node) && node.getAttribute('data-mce-bogus') && !node.nextSibling;
10628
10711
  };
10629
10712
  var findParentContentEditable = function (dom, node) {
10630
10713
  var parent = node;
@@ -10723,13 +10806,23 @@
10723
10806
  }
10724
10807
  return node || container;
10725
10808
  };
10726
- var findParentContainer = function (dom, format, startContainer, startOffset, endContainer, endOffset, start) {
10727
- var container, parent, sibling;
10728
- container = parent = start ? startContainer : endContainer;
10809
+ var isAtBlockBoundary = function (dom, root, container, siblingName) {
10810
+ var parent = container.parentNode;
10811
+ if (isNonNullable(container[siblingName])) {
10812
+ return false;
10813
+ } else if (parent === root || isNullable(parent) || dom.isBlock(parent)) {
10814
+ return true;
10815
+ } else {
10816
+ return isAtBlockBoundary(dom, root, parent, siblingName);
10817
+ }
10818
+ };
10819
+ var findParentContainer = function (dom, format, container, offset, start) {
10820
+ var parent = container;
10821
+ var sibling;
10729
10822
  var siblingName = start ? 'previousSibling' : 'nextSibling';
10730
10823
  var root = dom.getRoot();
10731
10824
  if (isText$1(container) && !isWhiteSpaceNode$1(container)) {
10732
- if (start ? startOffset > 0 : endOffset < container.nodeValue.length) {
10825
+ if (start ? offset > 0 : offset < container.data.length) {
10733
10826
  return container;
10734
10827
  }
10735
10828
  }
@@ -10738,7 +10831,8 @@
10738
10831
  return parent;
10739
10832
  }
10740
10833
  for (sibling = parent[siblingName]; sibling; sibling = sibling[siblingName]) {
10741
- if (!isBookmarkNode$2(sibling) && !isWhiteSpaceNode$1(sibling) && !isBogusBr(sibling)) {
10834
+ var allowSpaces = isText$1(sibling) && !isAtBlockBoundary(dom, root, sibling, siblingName);
10835
+ if (!isBookmarkNode$2(sibling) && !isBogusBr(sibling) && !isWhiteSpaceNode$1(sibling, allowSpaces)) {
10742
10836
  return parent;
10743
10837
  }
10744
10838
  }
@@ -10750,6 +10844,9 @@
10750
10844
  }
10751
10845
  return container;
10752
10846
  };
10847
+ var isSelfOrParentBookmark = function (container) {
10848
+ return isBookmarkNode$2(container.parentNode) || isBookmarkNode$2(container);
10849
+ };
10753
10850
  var expandRng = function (editor, rng, format, includeTrailingSpace) {
10754
10851
  if (includeTrailingSpace === void 0) {
10755
10852
  includeTrailingSpace = false;
@@ -10770,7 +10867,7 @@
10770
10867
  }
10771
10868
  startContainer = findParentContentEditable(dom, startContainer);
10772
10869
  endContainer = findParentContentEditable(dom, endContainer);
10773
- if (isBookmarkNode$2(startContainer.parentNode) || isBookmarkNode$2(startContainer)) {
10870
+ if (isSelfOrParentBookmark(startContainer)) {
10774
10871
  startContainer = isBookmarkNode$2(startContainer) ? startContainer : startContainer.parentNode;
10775
10872
  if (rng.collapsed) {
10776
10873
  startContainer = startContainer.previousSibling || startContainer;
@@ -10781,7 +10878,7 @@
10781
10878
  startOffset = rng.collapsed ? startContainer.length : 0;
10782
10879
  }
10783
10880
  }
10784
- if (isBookmarkNode$2(endContainer.parentNode) || isBookmarkNode$2(endContainer)) {
10881
+ if (isSelfOrParentBookmark(endContainer)) {
10785
10882
  endContainer = isBookmarkNode$2(endContainer) ? endContainer : endContainer.parentNode;
10786
10883
  if (rng.collapsed) {
10787
10884
  endContainer = endContainer.nextSibling || endContainer;
@@ -10808,10 +10905,10 @@
10808
10905
  }
10809
10906
  if (format[0].inline || format[0].block_expand) {
10810
10907
  if (!format[0].inline || (!isText$1(startContainer) || startOffset === 0)) {
10811
- startContainer = findParentContainer(dom, format, startContainer, startOffset, endContainer, endOffset, true);
10908
+ startContainer = findParentContainer(dom, format, startContainer, startOffset, true);
10812
10909
  }
10813
10910
  if (!format[0].inline || (!isText$1(endContainer) || endOffset === endContainer.nodeValue.length)) {
10814
- endContainer = findParentContainer(dom, format, startContainer, startOffset, endContainer, endOffset, false);
10911
+ endContainer = findParentContainer(dom, format, endContainer, endOffset, false);
10815
10912
  }
10816
10913
  }
10817
10914
  if (format[0].selector && format[0].expand !== false && !format[0].inline) {
@@ -10823,10 +10920,10 @@
10823
10920
  endContainer = findBlockEndPoint(editor, format, endContainer, 'nextSibling');
10824
10921
  if (format[0].block) {
10825
10922
  if (!dom.isBlock(startContainer)) {
10826
- startContainer = findParentContainer(dom, format, startContainer, startOffset, endContainer, endOffset, true);
10923
+ startContainer = findParentContainer(dom, format, startContainer, startOffset, true);
10827
10924
  }
10828
10925
  if (!dom.isBlock(endContainer)) {
10829
- endContainer = findParentContainer(dom, format, startContainer, startOffset, endContainer, endOffset, false);
10926
+ endContainer = findParentContainer(dom, format, endContainer, endOffset, false);
10830
10927
  }
10831
10928
  }
10832
10929
  }
@@ -11098,12 +11195,12 @@
11098
11195
  }
11099
11196
 
11100
11197
  var api = NodeValue(isText, 'text');
11101
- var get$7 = function (element) {
11198
+ var get$8 = function (element) {
11102
11199
  return api.get(element);
11103
11200
  };
11104
11201
 
11105
11202
  var isZeroWidth = function (elem) {
11106
- return isText(elem) && get$7(elem) === ZWSP;
11203
+ return isText(elem) && get$8(elem) === ZWSP;
11107
11204
  };
11108
11205
  var context = function (editor, elem, wrapName, nodeName) {
11109
11206
  return parent(elem).fold(function () {
@@ -12052,7 +12149,7 @@
12052
12149
  var get = function (element) {
12053
12150
  var r = getOffset(element);
12054
12151
  if (r <= 0 || r === null) {
12055
- var css = get$4(element, name);
12152
+ var css = get$5(element, name);
12056
12153
  return parseFloat(css) || 0;
12057
12154
  }
12058
12155
  return r;
@@ -12060,7 +12157,7 @@
12060
12157
  var getOuter = get;
12061
12158
  var aggregate = function (element, properties) {
12062
12159
  return foldl(properties, function (acc, property) {
12063
- var val = get$4(element, property);
12160
+ var val = get$5(element, property);
12064
12161
  var value = val === undefined ? 0 : parseInt(val, 10);
12065
12162
  return isNaN(value) ? acc : acc + value;
12066
12163
  }, 0);
@@ -12083,7 +12180,7 @@
12083
12180
  var dom = element.dom;
12084
12181
  return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
12085
12182
  });
12086
- var get$8 = function (element) {
12183
+ var get$9 = function (element) {
12087
12184
  return api$1.get(element);
12088
12185
  };
12089
12186
 
@@ -12117,7 +12214,7 @@
12117
12214
 
12118
12215
  var find$2 = function (element) {
12119
12216
  var doc = SugarElement.fromDom(document);
12120
- var scroll = get$1(doc);
12217
+ var scroll = get$2(doc);
12121
12218
  var frames = pathTo(element, Navigation);
12122
12219
  var offset = viewport(element);
12123
12220
  var r = foldr(frames, function (b, a) {
@@ -12171,7 +12268,7 @@
12171
12268
  } else if (isText(last)) {
12172
12269
  return {
12173
12270
  element: last,
12174
- offset: get$7(last).length
12271
+ offset: get$8(last).length
12175
12272
  };
12176
12273
  } else {
12177
12274
  return {
@@ -12184,7 +12281,7 @@
12184
12281
  };
12185
12282
  var markerInfo = function (element, cleanupFun) {
12186
12283
  var pos = absolute(element);
12187
- var height = get$8(element);
12284
+ var height = get$9(element);
12188
12285
  return {
12189
12286
  element: element,
12190
12287
  bottom: pos.top + height,
@@ -12217,7 +12314,7 @@
12217
12314
  if (fireScrollIntoViewEvent(editor, data)) {
12218
12315
  return;
12219
12316
  }
12220
- var scrollTop = get$1(doc).top;
12317
+ var scrollTop = get$2(doc).top;
12221
12318
  f(doc, scrollTop, marker, alignToTop);
12222
12319
  fireAfterScrollIntoViewEvent(editor, data);
12223
12320
  };
@@ -12415,7 +12512,7 @@
12415
12512
 
12416
12513
  var browser$3 = detect$3().browser;
12417
12514
  var clamp = function (offset, element) {
12418
- var max = isText(element) ? get$7(element).length : children(element).length + 1;
12515
+ var max = isText(element) ? get$8(element).length : children(element).length + 1;
12419
12516
  if (offset > max) {
12420
12517
  return max;
12421
12518
  } else if (offset < 0) {
@@ -12841,6 +12938,200 @@
12841
12938
  });
12842
12939
  };
12843
12940
 
12941
+ var ensureIsRoot = function (isRoot) {
12942
+ return isFunction(isRoot) ? isRoot : never;
12943
+ };
12944
+ var ancestor$3 = function (scope, transform, isRoot) {
12945
+ var element = scope.dom;
12946
+ var stop = ensureIsRoot(isRoot);
12947
+ while (element.parentNode) {
12948
+ element = element.parentNode;
12949
+ var el = SugarElement.fromDom(element);
12950
+ var transformed = transform(el);
12951
+ if (transformed.isSome()) {
12952
+ return transformed;
12953
+ } else if (stop(el)) {
12954
+ break;
12955
+ }
12956
+ }
12957
+ return Optional.none();
12958
+ };
12959
+ var closest$2 = function (scope, transform, isRoot) {
12960
+ var current = transform(scope);
12961
+ var stop = ensureIsRoot(isRoot);
12962
+ return current.orThunk(function () {
12963
+ return stop(scope) ? Optional.none() : ancestor$3(scope, transform, stop);
12964
+ });
12965
+ };
12966
+
12967
+ var isEq$2 = isEq;
12968
+ var matchesUnInheritedFormatSelector = function (ed, node, name) {
12969
+ var formatList = ed.formatter.get(name);
12970
+ if (formatList) {
12971
+ for (var i = 0; i < formatList.length; i++) {
12972
+ if (formatList[i].inherit === false && ed.dom.is(node, formatList[i].selector)) {
12973
+ return true;
12974
+ }
12975
+ }
12976
+ }
12977
+ return false;
12978
+ };
12979
+ var matchParents = function (editor, node, name, vars) {
12980
+ var root = editor.dom.getRoot();
12981
+ if (node === root) {
12982
+ return false;
12983
+ }
12984
+ node = editor.dom.getParent(node, function (node) {
12985
+ if (matchesUnInheritedFormatSelector(editor, node, name)) {
12986
+ return true;
12987
+ }
12988
+ return node.parentNode === root || !!matchNode(editor, node, name, vars, true);
12989
+ });
12990
+ return matchNode(editor, node, name, vars);
12991
+ };
12992
+ var matchName = function (dom, node, format) {
12993
+ if (isEq$2(node, format.inline)) {
12994
+ return true;
12995
+ }
12996
+ if (isEq$2(node, format.block)) {
12997
+ return true;
12998
+ }
12999
+ if (format.selector) {
13000
+ return node.nodeType === 1 && dom.is(node, format.selector);
13001
+ }
13002
+ };
13003
+ var matchItems = function (dom, node, format, itemName, similar, vars) {
13004
+ var key, value;
13005
+ var items = format[itemName];
13006
+ var i;
13007
+ if (format.onmatch) {
13008
+ return format.onmatch(node, format, itemName);
13009
+ }
13010
+ if (items) {
13011
+ if (typeof items.length === 'undefined') {
13012
+ for (key in items) {
13013
+ if (items.hasOwnProperty(key)) {
13014
+ if (itemName === 'attributes') {
13015
+ value = dom.getAttrib(node, key);
13016
+ } else {
13017
+ value = getStyle(dom, node, key);
13018
+ }
13019
+ if (similar && !value && !format.exact) {
13020
+ return;
13021
+ }
13022
+ if ((!similar || format.exact) && !isEq$2(value, normalizeStyleValue(dom, replaceVars(items[key], vars), key))) {
13023
+ return;
13024
+ }
13025
+ }
13026
+ }
13027
+ } else {
13028
+ for (i = 0; i < items.length; i++) {
13029
+ if (itemName === 'attributes' ? dom.getAttrib(node, items[i]) : getStyle(dom, node, items[i])) {
13030
+ return format;
13031
+ }
13032
+ }
13033
+ }
13034
+ }
13035
+ return format;
13036
+ };
13037
+ var matchNode = function (ed, node, name, vars, similar) {
13038
+ var formatList = ed.formatter.get(name);
13039
+ var format, i, x, classes;
13040
+ var dom = ed.dom;
13041
+ if (formatList && node) {
13042
+ for (i = 0; i < formatList.length; i++) {
13043
+ format = formatList[i];
13044
+ if (matchName(ed.dom, node, format) && matchItems(dom, node, format, 'attributes', similar, vars) && matchItems(dom, node, format, 'styles', similar, vars)) {
13045
+ if (classes = format.classes) {
13046
+ for (x = 0; x < classes.length; x++) {
13047
+ if (!ed.dom.hasClass(node, classes[x])) {
13048
+ return;
13049
+ }
13050
+ }
13051
+ }
13052
+ return format;
13053
+ }
13054
+ }
13055
+ }
13056
+ };
13057
+ var match = function (editor, name, vars, node) {
13058
+ if (node) {
13059
+ return matchParents(editor, node, name, vars);
13060
+ }
13061
+ node = editor.selection.getNode();
13062
+ if (matchParents(editor, node, name, vars)) {
13063
+ return true;
13064
+ }
13065
+ var startNode = editor.selection.getStart();
13066
+ if (startNode !== node) {
13067
+ if (matchParents(editor, startNode, name, vars)) {
13068
+ return true;
13069
+ }
13070
+ }
13071
+ return false;
13072
+ };
13073
+ var matchAll = function (editor, names, vars) {
13074
+ var matchedFormatNames = [];
13075
+ var checkedMap = {};
13076
+ var startElement = editor.selection.getStart();
13077
+ editor.dom.getParent(startElement, function (node) {
13078
+ for (var i = 0; i < names.length; i++) {
13079
+ var name_1 = names[i];
13080
+ if (!checkedMap[name_1] && matchNode(editor, node, name_1, vars)) {
13081
+ checkedMap[name_1] = true;
13082
+ matchedFormatNames.push(name_1);
13083
+ }
13084
+ }
13085
+ }, editor.dom.getRoot());
13086
+ return matchedFormatNames;
13087
+ };
13088
+ var closest$3 = function (editor, names) {
13089
+ var isRoot = function (elm) {
13090
+ return eq$2(elm, SugarElement.fromDom(editor.getBody()));
13091
+ };
13092
+ var match = function (elm, name) {
13093
+ return matchNode(editor, elm.dom, name) ? Optional.some(name) : Optional.none();
13094
+ };
13095
+ return Optional.from(editor.selection.getStart(true)).bind(function (rawElm) {
13096
+ return closest$2(SugarElement.fromDom(rawElm), function (elm) {
13097
+ return findMap(names, function (name) {
13098
+ return match(elm, name);
13099
+ });
13100
+ }, isRoot);
13101
+ }).getOrNull();
13102
+ };
13103
+ var canApply = function (editor, name) {
13104
+ var formatList = editor.formatter.get(name);
13105
+ var startNode, parents, i, x, selector;
13106
+ var dom = editor.dom;
13107
+ if (formatList) {
13108
+ startNode = editor.selection.getStart();
13109
+ parents = getParents$1(dom, startNode);
13110
+ for (x = formatList.length - 1; x >= 0; x--) {
13111
+ selector = formatList[x].selector;
13112
+ if (!selector || formatList[x].defaultBlock) {
13113
+ return true;
13114
+ }
13115
+ for (i = parents.length - 1; i >= 0; i--) {
13116
+ if (dom.is(parents[i], selector)) {
13117
+ return true;
13118
+ }
13119
+ }
13120
+ }
13121
+ }
13122
+ return false;
13123
+ };
13124
+ var matchAllOnNode = function (editor, node, formatNames) {
13125
+ return foldl(formatNames, function (acc, name) {
13126
+ var matchSimilar = isVariableFormatName(editor, name);
13127
+ if (editor.formatter.matchNode(node, name, {}, matchSimilar)) {
13128
+ return acc.concat([name]);
13129
+ } else {
13130
+ return acc;
13131
+ }
13132
+ }, []);
13133
+ };
13134
+
12844
13135
  var typeLookup = {
12845
13136
  '#text': 3,
12846
13137
  '#comment': 8,
@@ -13340,7 +13631,7 @@
13340
13631
  };
13341
13632
  var restoreDataUris = function (html, result) {
13342
13633
  return html.replace(new RegExp(result.prefix + '_[0-9]+', 'g'), function (imageId) {
13343
- return get(result.uris, imageId).getOr(imageId);
13634
+ return get$1(result.uris, imageId).getOr(imageId);
13344
13635
  });
13345
13636
  };
13346
13637
  var parseDataUri = function (uri) {
@@ -13355,14 +13646,22 @@
13355
13646
  }
13356
13647
  };
13357
13648
 
13649
+ var safeSvgDataUrlElements = [
13650
+ 'img',
13651
+ 'video'
13652
+ ];
13358
13653
  var isValidPrefixAttrName = function (name) {
13359
13654
  return name.indexOf('data-') === 0 || name.indexOf('aria-') === 0;
13360
13655
  };
13361
- var isInvalidUri = function (settings, uri) {
13656
+ var blockSvgDataUris = function (allowSvgDataUrls, tagName) {
13657
+ var allowed = isNullable(allowSvgDataUrls) ? contains(safeSvgDataUrlElements, tagName) : allowSvgDataUrls;
13658
+ return !allowed;
13659
+ };
13660
+ var isInvalidUri = function (settings, uri, tagName) {
13362
13661
  if (settings.allow_html_data_urls) {
13363
13662
  return false;
13364
13663
  } else if (/^data:image\//i.test(uri)) {
13365
- return settings.allow_svg_data_urls === false && /^data:image\/svg\+xml/i.test(uri);
13664
+ return blockSvgDataUris(settings.allow_svg_data_urls, tagName) && /^data:image\/svg\+xml/i.test(uri);
13366
13665
  } else {
13367
13666
  return /^data:/i.test(uri);
13368
13667
  }
@@ -13488,7 +13787,7 @@
13488
13787
  comment(restoreDataUris(value, base64Extract));
13489
13788
  };
13490
13789
  var processAttr = function (value) {
13491
- return get(base64Extract.uris, value).getOr(value);
13790
+ return get$1(base64Extract.uris, value).getOr(value);
13492
13791
  };
13493
13792
  var processMalformedComment = function (value, startIndex) {
13494
13793
  var startTag = value || '';
@@ -13498,7 +13797,7 @@
13498
13797
  processComment(isBogus ? startTag + value : value);
13499
13798
  return endIndex + 1;
13500
13799
  };
13501
- var parseAttribute = function (match, name, value, val2, val3) {
13800
+ var parseAttribute = function (tagName, name, value, val2, val3) {
13502
13801
  var attrRule, i;
13503
13802
  var trimRegExp = /[\s\u0000-\u001F]+/g;
13504
13803
  name = name.toLowerCase();
@@ -13534,7 +13833,7 @@
13534
13833
  if (scriptUriRegExp.test(uri)) {
13535
13834
  return;
13536
13835
  }
13537
- if (isInvalidUri(settings, uri)) {
13836
+ if (isInvalidUri(settings, uri, tagName)) {
13538
13837
  return;
13539
13838
  }
13540
13839
  }
@@ -13604,7 +13903,10 @@
13604
13903
  }
13605
13904
  attrList = [];
13606
13905
  attrList.map = {};
13607
- attribsValue.replace(attrRegExp, parseAttribute);
13906
+ attribsValue.replace(attrRegExp, function (match, name, val, val2, val3) {
13907
+ parseAttribute(value, name, val, val2, val3);
13908
+ return '';
13909
+ });
13608
13910
  } else {
13609
13911
  attrList = [];
13610
13912
  attrList.map = {};
@@ -13800,13 +14102,16 @@
13800
14102
  if (args.format === 'raw') {
13801
14103
  content = Tools.trim(trimExternal(editor.serializer, body.innerHTML));
13802
14104
  } else if (args.format === 'text') {
13803
- content = trim$2(body.innerText || body.textContent);
14105
+ content = editor.dom.isEmpty(body) ? '' : trim$2(body.innerText || body.textContent);
13804
14106
  } else if (args.format === 'tree') {
13805
- return editor.serializer.serialize(body, args);
14107
+ content = editor.serializer.serialize(body, args);
13806
14108
  } else {
13807
14109
  content = trimEmptyContents(editor, editor.serializer.serialize(body, args));
13808
14110
  }
13809
- if (args.format !== 'text' && !isWsPreserveElement(SugarElement.fromDom(body))) {
14111
+ if (!contains([
14112
+ 'text',
14113
+ 'tree'
14114
+ ], args.format) && !isWsPreserveElement(SugarElement.fromDom(body))) {
13810
14115
  args.content = Tools.trim(content);
13811
14116
  } else {
13812
14117
  args.content = content;
@@ -13887,7 +14192,7 @@
13887
14192
  };
13888
14193
  };
13889
14194
  var isImageBlock = function (node) {
13890
- return isImg(node) && get$4(SugarElement.fromDom(node), 'display') === 'block';
14195
+ return isImg(node) && get$5(SugarElement.fromDom(node), 'display') === 'block';
13891
14196
  };
13892
14197
  var isCefNode = function (node) {
13893
14198
  return isContentEditableFalse(node) && !isBogusAll(node);
@@ -13965,7 +14270,7 @@
13965
14270
  });
13966
14271
  });
13967
14272
  };
13968
- var isAtBlockBoundary = function (forward, root, pos) {
14273
+ var isAtBlockBoundary$1 = function (forward, root, pos) {
13969
14274
  return getClosestBlock(root, pos).fold(function () {
13970
14275
  return navigateIgnoreEmptyTextNodes(forward, root.dom, pos).forall(function (newPos) {
13971
14276
  return isInSameBlock(newPos, pos, root.dom) === false;
@@ -13974,8 +14279,8 @@
13974
14279
  return navigateIgnoreEmptyTextNodes(forward, parent.dom, pos).isNone();
13975
14280
  });
13976
14281
  };
13977
- var isAtStartOfBlock = curry(isAtBlockBoundary, false);
13978
- var isAtEndOfBlock = curry(isAtBlockBoundary, true);
14282
+ var isAtStartOfBlock = curry(isAtBlockBoundary$1, false);
14283
+ var isAtEndOfBlock = curry(isAtBlockBoundary$1, true);
13979
14284
  var isBeforeBlock = curry(isAtBeforeAfterBlockBoundary, false);
13980
14285
  var isAfterBlock = curry(isAtBeforeAfterBlockBoundary, true);
13981
14286
 
@@ -14027,7 +14332,7 @@
14027
14332
  return getElementFromPosition(pos).bind(function (elm) {
14028
14333
  return closest(elm, isElement);
14029
14334
  }).exists(function (elm) {
14030
- return isPreValue(get$4(elm, 'white-space'));
14335
+ return isPreValue(get$5(elm, 'white-space'));
14031
14336
  });
14032
14337
  };
14033
14338
  var isAtBeginningOfBody = function (root, pos) {
@@ -15132,8 +15437,10 @@
15132
15437
  args.format = args.format ? args.format : defaultFormat;
15133
15438
  args.set = true;
15134
15439
  args.content = isTreeNode(content) ? '' : content;
15135
- if (!isTreeNode(content) && !args.no_events) {
15440
+ if (!args.no_events) {
15136
15441
  editor.fire('BeforeSetContent', args);
15442
+ }
15443
+ if (!isTreeNode(content)) {
15137
15444
  content = args.content;
15138
15445
  }
15139
15446
  return Optional.from(editor.getBody()).fold(constant(content), function (body) {
@@ -15141,157 +15448,44 @@
15141
15448
  });
15142
15449
  };
15143
15450
 
15144
- var isEq$2 = isEq;
15145
- var matchesUnInheritedFormatSelector = function (ed, node, name) {
15146
- var formatList = ed.formatter.get(name);
15147
- if (formatList) {
15148
- for (var i = 0; i < formatList.length; i++) {
15149
- if (formatList[i].inherit === false && ed.dom.is(node, formatList[i].selector)) {
15150
- return true;
15451
+ var addVisualInternal = function (editor, elm) {
15452
+ var dom = editor.dom;
15453
+ var scope = isNonNullable(elm) ? elm : editor.getBody();
15454
+ if (isUndefined(editor.hasVisual)) {
15455
+ editor.hasVisual = isVisualAidsEnabled(editor);
15456
+ }
15457
+ each(dom.select('table,a', scope), function (matchedElm) {
15458
+ switch (matchedElm.nodeName) {
15459
+ case 'TABLE':
15460
+ var cls = getVisualAidsTableClass(editor);
15461
+ var value = dom.getAttrib(matchedElm, 'border');
15462
+ if ((!value || value === '0') && editor.hasVisual) {
15463
+ dom.addClass(matchedElm, cls);
15464
+ } else {
15465
+ dom.removeClass(matchedElm, cls);
15466
+ }
15467
+ break;
15468
+ case 'A':
15469
+ if (!dom.getAttrib(matchedElm, 'href')) {
15470
+ var value_1 = dom.getAttrib(matchedElm, 'name') || matchedElm.id;
15471
+ var cls_1 = getVisualAidsAnchorClass(editor);
15472
+ if (value_1 && editor.hasVisual) {
15473
+ dom.addClass(matchedElm, cls_1);
15474
+ } else {
15475
+ dom.removeClass(matchedElm, cls_1);
15476
+ }
15151
15477
  }
15478
+ break;
15152
15479
  }
15153
- }
15154
- return false;
15155
- };
15156
- var matchParents = function (editor, node, name, vars) {
15157
- var root = editor.dom.getRoot();
15158
- if (node === root) {
15159
- return false;
15160
- }
15161
- node = editor.dom.getParent(node, function (node) {
15162
- if (matchesUnInheritedFormatSelector(editor, node, name)) {
15163
- return true;
15164
- }
15165
- return node.parentNode === root || !!matchNode(editor, node, name, vars, true);
15166
15480
  });
15167
- return matchNode(editor, node, name, vars);
15168
- };
15169
- var matchName = function (dom, node, format) {
15170
- if (isEq$2(node, format.inline)) {
15171
- return true;
15172
- }
15173
- if (isEq$2(node, format.block)) {
15174
- return true;
15175
- }
15176
- if (format.selector) {
15177
- return node.nodeType === 1 && dom.is(node, format.selector);
15178
- }
15179
- };
15180
- var matchItems = function (dom, node, format, itemName, similar, vars) {
15181
- var key, value;
15182
- var items = format[itemName];
15183
- var i;
15184
- if (format.onmatch) {
15185
- return format.onmatch(node, format, itemName);
15186
- }
15187
- if (items) {
15188
- if (typeof items.length === 'undefined') {
15189
- for (key in items) {
15190
- if (items.hasOwnProperty(key)) {
15191
- if (itemName === 'attributes') {
15192
- value = dom.getAttrib(node, key);
15193
- } else {
15194
- value = getStyle(dom, node, key);
15195
- }
15196
- if (similar && !value && !format.exact) {
15197
- return;
15198
- }
15199
- if ((!similar || format.exact) && !isEq$2(value, normalizeStyleValue(dom, replaceVars(items[key], vars), key))) {
15200
- return;
15201
- }
15202
- }
15203
- }
15204
- } else {
15205
- for (i = 0; i < items.length; i++) {
15206
- if (itemName === 'attributes' ? dom.getAttrib(node, items[i]) : getStyle(dom, node, items[i])) {
15207
- return format;
15208
- }
15209
- }
15210
- }
15211
- }
15212
- return format;
15213
- };
15214
- var matchNode = function (ed, node, name, vars, similar) {
15215
- var formatList = ed.formatter.get(name);
15216
- var format, i, x, classes;
15217
- var dom = ed.dom;
15218
- if (formatList && node) {
15219
- for (i = 0; i < formatList.length; i++) {
15220
- format = formatList[i];
15221
- if (matchName(ed.dom, node, format) && matchItems(dom, node, format, 'attributes', similar, vars) && matchItems(dom, node, format, 'styles', similar, vars)) {
15222
- if (classes = format.classes) {
15223
- for (x = 0; x < classes.length; x++) {
15224
- if (!ed.dom.hasClass(node, classes[x])) {
15225
- return;
15226
- }
15227
- }
15228
- }
15229
- return format;
15230
- }
15231
- }
15232
- }
15233
- };
15234
- var match = function (editor, name, vars, node) {
15235
- if (node) {
15236
- return matchParents(editor, node, name, vars);
15237
- }
15238
- node = editor.selection.getNode();
15239
- if (matchParents(editor, node, name, vars)) {
15240
- return true;
15241
- }
15242
- var startNode = editor.selection.getStart();
15243
- if (startNode !== node) {
15244
- if (matchParents(editor, startNode, name, vars)) {
15245
- return true;
15246
- }
15247
- }
15248
- return false;
15249
- };
15250
- var matchAll = function (editor, names, vars) {
15251
- var matchedFormatNames = [];
15252
- var checkedMap = {};
15253
- var startElement = editor.selection.getStart();
15254
- editor.dom.getParent(startElement, function (node) {
15255
- for (var i = 0; i < names.length; i++) {
15256
- var name_1 = names[i];
15257
- if (!checkedMap[name_1] && matchNode(editor, node, name_1, vars)) {
15258
- checkedMap[name_1] = true;
15259
- matchedFormatNames.push(name_1);
15260
- }
15261
- }
15262
- }, editor.dom.getRoot());
15263
- return matchedFormatNames;
15264
- };
15265
- var canApply = function (editor, name) {
15266
- var formatList = editor.formatter.get(name);
15267
- var startNode, parents, i, x, selector;
15268
- var dom = editor.dom;
15269
- if (formatList) {
15270
- startNode = editor.selection.getStart();
15271
- parents = getParents$1(dom, startNode);
15272
- for (x = formatList.length - 1; x >= 0; x--) {
15273
- selector = formatList[x].selector;
15274
- if (!selector || formatList[x].defaultBlock) {
15275
- return true;
15276
- }
15277
- for (i = parents.length - 1; i >= 0; i--) {
15278
- if (dom.is(parents[i], selector)) {
15279
- return true;
15280
- }
15281
- }
15282
- }
15283
- }
15284
- return false;
15481
+ editor.fire('VisualAid', {
15482
+ element: elm,
15483
+ hasVisual: editor.hasVisual
15484
+ });
15285
15485
  };
15286
- var matchAllOnNode = function (editor, node, formatNames) {
15287
- return foldl(formatNames, function (acc, name) {
15288
- var matchSimilar = isVariableFormatName(editor, name);
15289
- if (editor.formatter.matchNode(node, name, {}, matchSimilar)) {
15290
- return acc.concat([name]);
15291
- } else {
15292
- return acc;
15293
- }
15294
- }, []);
15486
+
15487
+ var sibling$2 = function (scope, predicate) {
15488
+ return sibling(scope, predicate).isSome();
15295
15489
  };
15296
15490
 
15297
15491
  var ZWSP$1 = ZWSP, CARET_ID$1 = '_mce_caret';
@@ -15985,7 +16179,7 @@
15985
16179
  };
15986
16180
  var removeRngStyle = function (rng) {
15987
16181
  var startContainer, endContainer;
15988
- var expandedRng = expandRng(ed, rng, formatList, true);
16182
+ var expandedRng = expandRng(ed, rng, formatList, rng.collapsed);
15989
16183
  if (format.split) {
15990
16184
  expandedRng = split$1(expandedRng);
15991
16185
  startContainer = getContainer(ed, expandedRng, true);
@@ -16153,15 +16347,39 @@
16153
16347
  };
16154
16348
 
16155
16349
  var each$c = Tools.each;
16350
+ var hasFormatProperty = function (format, prop) {
16351
+ return hasNonNullableKey(format, prop);
16352
+ };
16156
16353
  var isElementNode$1 = function (node) {
16157
16354
  return node && node.nodeType === 1 && !isBookmarkNode$1(node) && !isCaretNode(node) && !isBogus(node);
16158
16355
  };
16356
+ var canFormatBR = function (editor, format, node, parentName) {
16357
+ if (canFormatEmptyLines(editor) && isInlineFormat(format)) {
16358
+ var validBRParentElements = __assign(__assign({}, editor.schema.getTextBlockElements()), {
16359
+ td: {},
16360
+ th: {},
16361
+ li: {},
16362
+ dt: {},
16363
+ dd: {},
16364
+ figcaption: {},
16365
+ caption: {},
16366
+ details: {},
16367
+ summary: {}
16368
+ });
16369
+ var hasCaretNodeSibling = sibling$2(SugarElement.fromDom(node), function (sibling) {
16370
+ return isCaretNode(sibling.dom);
16371
+ });
16372
+ return hasNonNullableKey(validBRParentElements, parentName) && isEmpty(SugarElement.fromDom(node.parentNode), false) && !hasCaretNodeSibling;
16373
+ } else {
16374
+ return false;
16375
+ }
16376
+ };
16159
16377
  var applyFormat = function (ed, name, vars, node) {
16160
16378
  var formatList = ed.formatter.get(name);
16161
16379
  var format = formatList[0];
16162
- var rng;
16163
16380
  var isCollapsed = !node && ed.selection.isCollapsed();
16164
- var dom = ed.dom, selection = ed.selection;
16381
+ var dom = ed.dom;
16382
+ var selection = ed.selection;
16165
16383
  var setElementFormat = function (elm, fmt) {
16166
16384
  fmt = fmt || format;
16167
16385
  if (elm) {
@@ -16190,7 +16408,7 @@
16190
16408
  };
16191
16409
  var applyNodeStyle = function (formatList, node) {
16192
16410
  var found = false;
16193
- if (!format.selector) {
16411
+ if (!isSelectorFormat(format)) {
16194
16412
  return false;
16195
16413
  }
16196
16414
  each$c(formatList, function (format) {
@@ -16223,32 +16441,32 @@
16223
16441
  contentEditable = dom.getContentEditable(node) === 'true';
16224
16442
  hasContentEditableState = true;
16225
16443
  }
16226
- if (isEq(nodeName, 'br')) {
16227
- currentWrapElm = 0;
16228
- if (format.block) {
16444
+ if (isBr(node) && !canFormatBR(ed, format, node, parentName)) {
16445
+ currentWrapElm = null;
16446
+ if (isBlockFormat(format)) {
16229
16447
  dom.remove(node);
16230
16448
  }
16231
16449
  return;
16232
16450
  }
16233
16451
  if (format.wrapper && matchNode(ed, node, name, vars)) {
16234
- currentWrapElm = 0;
16452
+ currentWrapElm = null;
16235
16453
  return;
16236
16454
  }
16237
- if (contentEditable && !hasContentEditableState && format.block && !format.wrapper && isTextBlock$1(ed, nodeName) && isValid(ed, parentName, wrapName)) {
16455
+ if (contentEditable && !hasContentEditableState && isBlockFormat(format) && !format.wrapper && isTextBlock$1(ed, nodeName) && isValid(ed, parentName, wrapName)) {
16238
16456
  var elm = dom.rename(node, wrapName);
16239
16457
  setElementFormat(elm);
16240
16458
  newWrappers.push(elm);
16241
- currentWrapElm = 0;
16459
+ currentWrapElm = null;
16242
16460
  return;
16243
16461
  }
16244
- if (format.selector) {
16462
+ if (isSelectorFormat(format)) {
16245
16463
  var found = applyNodeStyle(formatList, node);
16246
- if (!format.inline || found) {
16247
- currentWrapElm = 0;
16464
+ if (!hasFormatProperty(format, 'inline') || found) {
16465
+ currentWrapElm = null;
16248
16466
  return;
16249
16467
  }
16250
16468
  }
16251
- if (contentEditable && !hasContentEditableState && isValid(ed, wrapName, nodeName) && isValid(ed, parentName, wrapName) && !(!nodeSpecific && node.nodeType === 3 && node.nodeValue.length === 1 && node.nodeValue.charCodeAt(0) === 65279) && !isCaretNode(node) && (!format.inline || !dom.isBlock(node))) {
16469
+ if (contentEditable && !hasContentEditableState && isValid(ed, wrapName, nodeName) && isValid(ed, parentName, wrapName) && !(!nodeSpecific && node.nodeType === 3 && node.nodeValue.length === 1 && node.nodeValue.charCodeAt(0) === 65279) && !isCaretNode(node) && (!hasFormatProperty(format, 'inline') || !dom.isBlock(node))) {
16252
16470
  if (!currentWrapElm) {
16253
16471
  currentWrapElm = dom.clone(wrapElm, false);
16254
16472
  node.parentNode.insertBefore(currentWrapElm, node);
@@ -16256,12 +16474,12 @@
16256
16474
  }
16257
16475
  currentWrapElm.appendChild(node);
16258
16476
  } else {
16259
- currentWrapElm = 0;
16477
+ currentWrapElm = null;
16260
16478
  each$c(Tools.grep(node.childNodes), process);
16261
16479
  if (hasContentEditableState) {
16262
16480
  contentEditable = lastContentEditable;
16263
16481
  }
16264
- currentWrapElm = 0;
16482
+ currentWrapElm = null;
16265
16483
  }
16266
16484
  };
16267
16485
  each$c(nodes, process);
@@ -16313,7 +16531,7 @@
16313
16531
  dom.remove(node, true);
16314
16532
  return;
16315
16533
  }
16316
- if (format.inline || format.wrapper) {
16534
+ if (isInlineFormat(format) || format.wrapper) {
16317
16535
  if (!format.exact && childCount === 1) {
16318
16536
  node = mergeStyles(node);
16319
16537
  }
@@ -16329,8 +16547,9 @@
16329
16547
  if (dom.getContentEditable(selection.getNode()) === 'false') {
16330
16548
  node = selection.getNode();
16331
16549
  for (var i = 0, l = formatList.length; i < l; i++) {
16332
- if (formatList[i].ceFalseOverride && dom.is(node, formatList[i].selector)) {
16333
- setElementFormat(node, formatList[i]);
16550
+ var formatItem = formatList[i];
16551
+ if (formatItem.ceFalseOverride && isSelectorFormat(formatItem) && dom.is(node, formatItem.selector)) {
16552
+ setElementFormat(node, formatItem);
16334
16553
  return;
16335
16554
  }
16336
16555
  }
@@ -16340,7 +16559,7 @@
16340
16559
  if (node) {
16341
16560
  if (isNode(node)) {
16342
16561
  if (!applyNodeStyle(formatList, node)) {
16343
- rng = dom.createRng();
16562
+ var rng = dom.createRng();
16344
16563
  rng.setStartBefore(node);
16345
16564
  rng.setEndAfter(node);
16346
16565
  applyRngStyle(dom, expandRng(ed, rng, formatList), null, true);
@@ -16349,10 +16568,11 @@
16349
16568
  applyRngStyle(dom, node, null, true);
16350
16569
  }
16351
16570
  } else {
16352
- if (!isCollapsed || !format.inline || getCellsFromEditor(ed).length) {
16571
+ if (!isCollapsed || !isInlineFormat(format) || getCellsFromEditor(ed).length) {
16353
16572
  var curSelNode = selection.getNode();
16354
- if (!ed.settings.forced_root_block && formatList[0].defaultBlock && !dom.getParent(curSelNode, dom.isBlock)) {
16355
- applyFormat(ed, formatList[0].defaultBlock);
16573
+ var firstFormat = formatList[0];
16574
+ if (!ed.settings.forced_root_block && firstFormat.defaultBlock && !dom.getParent(curSelNode, dom.isBlock)) {
16575
+ applyFormat(ed, firstFormat.defaultBlock);
16356
16576
  }
16357
16577
  selection.setRng(normalize$2(selection.getRng()));
16358
16578
  preserve(selection, true, function (bookmark) {
@@ -16371,6 +16591,97 @@
16371
16591
  }
16372
16592
  };
16373
16593
 
16594
+ var setup$4 = function (registeredFormatListeners, editor) {
16595
+ var currentFormats = Cell({});
16596
+ registeredFormatListeners.set({});
16597
+ editor.on('NodeChange', function (e) {
16598
+ updateAndFireChangeCallbacks(editor, e.element, currentFormats, registeredFormatListeners.get());
16599
+ });
16600
+ };
16601
+ var updateAndFireChangeCallbacks = function (editor, elm, currentFormats, formatChangeData) {
16602
+ var formatsList = keys(currentFormats.get());
16603
+ var newFormats = {};
16604
+ var matchedFormats = {};
16605
+ var parents = filter(getParents$1(editor.dom, elm), function (node) {
16606
+ return node.nodeType === 1 && !node.getAttribute('data-mce-bogus');
16607
+ });
16608
+ each$1(formatChangeData, function (data, format) {
16609
+ Tools.each(parents, function (node) {
16610
+ if (editor.formatter.matchNode(node, format, {}, data.similar)) {
16611
+ if (formatsList.indexOf(format) === -1) {
16612
+ each(data.callbacks, function (callback) {
16613
+ callback(true, {
16614
+ node: node,
16615
+ format: format,
16616
+ parents: parents
16617
+ });
16618
+ });
16619
+ newFormats[format] = data.callbacks;
16620
+ }
16621
+ matchedFormats[format] = data.callbacks;
16622
+ return false;
16623
+ }
16624
+ if (matchesUnInheritedFormatSelector(editor, node, format)) {
16625
+ return false;
16626
+ }
16627
+ });
16628
+ });
16629
+ var remainingFormats = filterRemainingFormats(currentFormats.get(), matchedFormats, elm, parents);
16630
+ currentFormats.set(__assign(__assign({}, newFormats), remainingFormats));
16631
+ };
16632
+ var filterRemainingFormats = function (currentFormats, matchedFormats, elm, parents) {
16633
+ return bifilter(currentFormats, function (callbacks, format) {
16634
+ if (!has(matchedFormats, format)) {
16635
+ each(callbacks, function (callback) {
16636
+ callback(false, {
16637
+ node: elm,
16638
+ format: format,
16639
+ parents: parents
16640
+ });
16641
+ });
16642
+ return false;
16643
+ } else {
16644
+ return true;
16645
+ }
16646
+ }).t;
16647
+ };
16648
+ var addListeners = function (registeredFormatListeners, formats, callback, similar) {
16649
+ var formatChangeItems = registeredFormatListeners.get();
16650
+ each(formats.split(','), function (format) {
16651
+ if (!formatChangeItems[format]) {
16652
+ formatChangeItems[format] = {
16653
+ similar: similar,
16654
+ callbacks: []
16655
+ };
16656
+ }
16657
+ formatChangeItems[format].callbacks.push(callback);
16658
+ });
16659
+ registeredFormatListeners.set(formatChangeItems);
16660
+ };
16661
+ var removeListeners = function (registeredFormatListeners, formats, callback) {
16662
+ var formatChangeItems = registeredFormatListeners.get();
16663
+ each(formats.split(','), function (format) {
16664
+ formatChangeItems[format].callbacks = filter(formatChangeItems[format].callbacks, function (c) {
16665
+ return c !== callback;
16666
+ });
16667
+ if (formatChangeItems[format].callbacks.length === 0) {
16668
+ delete formatChangeItems[format];
16669
+ }
16670
+ });
16671
+ registeredFormatListeners.set(formatChangeItems);
16672
+ };
16673
+ var formatChangedInternal = function (editor, registeredFormatListeners, formats, callback, similar) {
16674
+ if (registeredFormatListeners.get() === null) {
16675
+ setup$4(registeredFormatListeners, editor);
16676
+ }
16677
+ addListeners(registeredFormatListeners, formats, callback, similar);
16678
+ return {
16679
+ unbind: function () {
16680
+ return removeListeners(registeredFormatListeners, formats, callback);
16681
+ }
16682
+ };
16683
+ };
16684
+
16374
16685
  var toggle = function (editor, name, vars, node) {
16375
16686
  var fmt = editor.formatter.get(name);
16376
16687
  if (match(editor, name, vars, node) && (!('toggle' in fmt[0]) || fmt[0].toggle)) {
@@ -16409,7 +16720,7 @@
16409
16720
  };
16410
16721
  };
16411
16722
  var getSpan = function (td, key) {
16412
- var value = parseInt(get$3(td, key), 10);
16723
+ var value = parseInt(get$4(td, key), 10);
16413
16724
  return isNaN(value) ? 1 : value;
16414
16725
  };
16415
16726
  var fillout = function (table, x, y, tr, td) {
@@ -16594,29 +16905,38 @@
16594
16905
  var isCollapsibleWhitespace = function (text, index) {
16595
16906
  return index >= 0 && index < text.length && isWhiteSpace$1(text.charAt(index));
16596
16907
  };
16597
- var getInnerText = function (bin) {
16908
+ var getInnerText = function (bin, shouldTrim) {
16598
16909
  var text = trim$2(bin.innerText);
16599
- return Env.browser.isIE() ? trimLeadingCollapsibleText(text) : text;
16910
+ return shouldTrim ? trimLeadingCollapsibleText(text) : text;
16911
+ };
16912
+ var getContextNodeName = function (parentBlockOpt) {
16913
+ return parentBlockOpt.map(function (block) {
16914
+ return block.nodeName;
16915
+ }).getOr('div').toLowerCase();
16600
16916
  };
16601
16917
  var getTextContent = function (editor) {
16602
16918
  return Optional.from(editor.selection.getRng()).map(function (rng) {
16603
- var bin = editor.dom.add(editor.getBody(), 'div', {
16919
+ var parentBlockOpt = Optional.from(editor.dom.getParent(rng.commonAncestorContainer, editor.dom.isBlock));
16920
+ var body = editor.getBody();
16921
+ var contextNodeName = getContextNodeName(parentBlockOpt);
16922
+ var shouldTrimSpaces = Env.browser.isIE() && contextNodeName !== 'pre';
16923
+ var bin = editor.dom.add(body, contextNodeName, {
16604
16924
  'data-mce-bogus': 'all',
16605
16925
  'style': 'overflow: hidden; opacity: 0;'
16606
16926
  }, rng.cloneContents());
16607
- var text = getInnerText(bin);
16927
+ var text = getInnerText(bin, shouldTrimSpaces);
16608
16928
  var nonRenderedText = trim$2(bin.textContent);
16609
16929
  editor.dom.remove(bin);
16610
16930
  if (isCollapsibleWhitespace(nonRenderedText, 0) || isCollapsibleWhitespace(nonRenderedText, nonRenderedText.length - 1)) {
16611
- var parentBlock = editor.dom.getParent(rng.commonAncestorContainer, editor.dom.isBlock);
16612
- var parentBlockText = getInnerText(parentBlock);
16931
+ var parentBlock = parentBlockOpt.getOr(body);
16932
+ var parentBlockText = getInnerText(parentBlock, shouldTrimSpaces);
16613
16933
  var textIndex = parentBlockText.indexOf(text);
16614
- if (textIndex !== -1) {
16934
+ if (textIndex === -1) {
16935
+ return text;
16936
+ } else {
16615
16937
  var hasProceedingSpace = isCollapsibleWhitespace(parentBlockText, textIndex - 1);
16616
16938
  var hasTrailingSpace = isCollapsibleWhitespace(parentBlockText, textIndex + text.length);
16617
16939
  return (hasProceedingSpace ? ' ' : '') + text + (hasTrailingSpace ? ' ' : '');
16618
- } else {
16619
- return text;
16620
16940
  }
16621
16941
  } else {
16622
16942
  return text;
@@ -16891,7 +17211,7 @@
16891
17211
  var elm = SugarElement.fromTag('body', lazyTempDocument());
16892
17212
  set$1(elm, getLevelContent(level));
16893
17213
  each(descendants$1(elm, '*[data-mce-bogus]'), unwrap);
16894
- return get$6(elm);
17214
+ return get$7(elm);
16895
17215
  };
16896
17216
  var hasEqualContent = function (level1, level2) {
16897
17217
  return getLevelContent(level1) === getLevelContent(level2);
@@ -17115,6 +17435,21 @@
17115
17435
  }
17116
17436
  },
17117
17437
  formatter: {
17438
+ match: function (name, vars, node) {
17439
+ return match(editor, name, vars, node);
17440
+ },
17441
+ matchAll: function (names, vars) {
17442
+ return matchAll(editor, names, vars);
17443
+ },
17444
+ matchNode: function (node, name, vars, similar) {
17445
+ return matchNode(editor, node, name, vars, similar);
17446
+ },
17447
+ canApply: function (name) {
17448
+ return canApply(editor, name);
17449
+ },
17450
+ closest: function (names) {
17451
+ return closest$3(editor, names);
17452
+ },
17118
17453
  apply: function (name, vars, node) {
17119
17454
  return applyFormat(editor, name, vars, node);
17120
17455
  },
@@ -17123,6 +17458,9 @@
17123
17458
  },
17124
17459
  toggle: function (name, vars, node) {
17125
17460
  return toggle(editor, name, vars, node);
17461
+ },
17462
+ formatChanged: function (registeredFormatListeners, formats, callback, similar) {
17463
+ return formatChangedInternal(editor, registeredFormatListeners, formats, callback, similar);
17126
17464
  }
17127
17465
  },
17128
17466
  editor: {
@@ -17134,6 +17472,9 @@
17134
17472
  },
17135
17473
  insertContent: function (value, details) {
17136
17474
  return insertHtmlAtCaret(editor, value, details);
17475
+ },
17476
+ addVisual: function (elm) {
17477
+ return addVisualInternal(editor, elm);
17137
17478
  }
17138
17479
  },
17139
17480
  selection: {
@@ -17182,6 +17523,17 @@
17182
17523
  extra: unsupported
17183
17524
  },
17184
17525
  formatter: {
17526
+ match: function (name, vars, _node) {
17527
+ return rtcEditor.matchFormat(name, defaultVars(vars));
17528
+ },
17529
+ matchAll: unsupported,
17530
+ matchNode: unsupported,
17531
+ canApply: function (name) {
17532
+ return rtcEditor.canApplyFormat(name);
17533
+ },
17534
+ closest: function (names) {
17535
+ return rtcEditor.closestFormat(names);
17536
+ },
17185
17537
  apply: function (name, vars, _node) {
17186
17538
  return rtcEditor.applyFormat(name, defaultVars(vars));
17187
17539
  },
@@ -17190,6 +17542,9 @@
17190
17542
  },
17191
17543
  toggle: function (name, vars, _node) {
17192
17544
  return rtcEditor.toggleFormat(name, defaultVars(vars));
17545
+ },
17546
+ formatChanged: function (_rfl, formats, callback, similar) {
17547
+ return rtcEditor.formatChanged(formats, callback, similar);
17193
17548
  }
17194
17549
  },
17195
17550
  editor: {
@@ -17219,6 +17574,8 @@
17219
17574
  });
17220
17575
  var fragment = isTreeNode$1(value) ? value : tinymceEditor.parser.parse(value, __assign(__assign({}, contextArgs), { insert: true }));
17221
17576
  rtcEditor.insertContent(fragment);
17577
+ },
17578
+ addVisual: function (_elm) {
17222
17579
  }
17223
17580
  },
17224
17581
  selection: {
@@ -17243,9 +17600,9 @@
17243
17600
  var isRtc = function (editor) {
17244
17601
  return has(editor.plugins, 'rtc');
17245
17602
  };
17246
- var setup$4 = function (editor) {
17603
+ var setup$5 = function (editor) {
17247
17604
  var editorCast = editor;
17248
- return get(editor.plugins, 'rtc').fold(function () {
17605
+ return get$1(editor.plugins, 'rtc').fold(function () {
17249
17606
  editorCast.rtcInstance = makePlainAdaptor(editor);
17250
17607
  return Optional.none();
17251
17608
  }, function (rtc) {
@@ -17299,6 +17656,21 @@
17299
17656
  var extra$1 = function (editor, undoManager, index, callback1, callback2) {
17300
17657
  getRtcInstanceWithError(editor).undoManager.extra(undoManager, index, callback1, callback2);
17301
17658
  };
17659
+ var matchFormat = function (editor, name, vars, node) {
17660
+ return getRtcInstanceWithError(editor).formatter.match(name, vars, node);
17661
+ };
17662
+ var matchAllFormats = function (editor, names, vars) {
17663
+ return getRtcInstanceWithError(editor).formatter.matchAll(names, vars);
17664
+ };
17665
+ var matchNodeFormat = function (editor, node, name, vars, similar) {
17666
+ return getRtcInstanceWithError(editor).formatter.matchNode(node, name, vars, similar);
17667
+ };
17668
+ var canApplyFormat = function (editor, name) {
17669
+ return getRtcInstanceWithError(editor).formatter.canApply(name);
17670
+ };
17671
+ var closestFormat = function (editor, names) {
17672
+ return getRtcInstanceWithError(editor).formatter.closest(names);
17673
+ };
17302
17674
  var applyFormat$1 = function (editor, name, vars, node) {
17303
17675
  getRtcInstanceWithError(editor).formatter.apply(name, vars, node);
17304
17676
  };
@@ -17308,6 +17680,12 @@
17308
17680
  var toggleFormat = function (editor, name, vars, node) {
17309
17681
  getRtcInstanceWithError(editor).formatter.toggle(name, vars, node);
17310
17682
  };
17683
+ var formatChanged = function (editor, registeredFormatListeners, formats, callback, similar) {
17684
+ if (similar === void 0) {
17685
+ similar = false;
17686
+ }
17687
+ return getRtcInstanceWithError(editor).formatter.formatChanged(registeredFormatListeners, formats, callback, similar);
17688
+ };
17311
17689
  var getContent = function (editor, args, format) {
17312
17690
  return getRtcInstanceWithFallback(editor).editor.getContent(args, format);
17313
17691
  };
@@ -17320,6 +17698,9 @@
17320
17698
  var getSelectedContent = function (editor, format, args) {
17321
17699
  return getRtcInstanceWithError(editor).selection.getContent(format, args);
17322
17700
  };
17701
+ var addVisual = function (editor, elm) {
17702
+ return getRtcInstanceWithError(editor).editor.addVisual(elm);
17703
+ };
17323
17704
 
17324
17705
  var getContent$1 = function (editor, args) {
17325
17706
  if (args === void 0) {
@@ -18531,6 +18912,7 @@
18531
18912
  var parser = SaxParser$1({
18532
18913
  validate: validate,
18533
18914
  allow_html_data_urls: settings.allow_html_data_urls,
18915
+ allow_svg_data_urls: settings.allow_svg_data_urls,
18534
18916
  allow_script_urls: settings.allow_script_urls,
18535
18917
  allow_conditional_comments: settings.allow_conditional_comments,
18536
18918
  preserve_cdata: settings.preserve_cdata,
@@ -19176,8 +19558,8 @@
19176
19558
  return hasSection(sectionResult, name) ? sectionResult.sections()[name] : {};
19177
19559
  };
19178
19560
  var getToolbarMode = function (settings, defaultVal) {
19179
- return get(settings, 'toolbar_mode').orThunk(function () {
19180
- return get(settings, 'toolbar_drawer').map(function (val) {
19561
+ return get$1(settings, 'toolbar_mode').orThunk(function () {
19562
+ return get$1(settings, 'toolbar_drawer').map(function (val) {
19181
19563
  return val === false ? 'wrap' : val;
19182
19564
  });
19183
19565
  }).getOr(defaultVal);
@@ -19232,13 +19614,25 @@
19232
19614
  var combinePlugins = function (forcedPlugins, plugins) {
19233
19615
  return [].concat(normalizePlugins(forcedPlugins)).concat(normalizePlugins(plugins));
19234
19616
  };
19617
+ var getPlatformPlugins = function (isMobileDevice, sectionResult, desktopPlugins, mobilePlugins) {
19618
+ if (isMobileDevice && isSectionTheme(sectionResult, 'mobile', 'mobile')) {
19619
+ return filterLegacyMobilePlugins(mobilePlugins);
19620
+ } else if (isMobileDevice && hasSection(sectionResult, 'mobile')) {
19621
+ return mobilePlugins;
19622
+ } else {
19623
+ return desktopPlugins;
19624
+ }
19625
+ };
19235
19626
  var processPlugins = function (isMobileDevice, sectionResult, defaultOverrideSettings, settings) {
19236
19627
  var forcedPlugins = normalizePlugins(defaultOverrideSettings.forced_plugins);
19237
19628
  var desktopPlugins = normalizePlugins(settings.plugins);
19238
19629
  var mobileConfig = getSectionConfig(sectionResult, 'mobile');
19239
19630
  var mobilePlugins = mobileConfig.plugins ? normalizePlugins(mobileConfig.plugins) : desktopPlugins;
19240
- var platformPlugins = isMobileDevice && isSectionTheme(sectionResult, 'mobile', 'mobile') ? filterLegacyMobilePlugins(mobilePlugins) : isMobileDevice && hasSection(sectionResult, 'mobile') ? mobilePlugins : desktopPlugins;
19631
+ var platformPlugins = getPlatformPlugins(isMobileDevice, sectionResult, desktopPlugins, mobilePlugins);
19241
19632
  var combinedPlugins = combinePlugins(forcedPlugins, platformPlugins);
19633
+ if (Env.browser.isIE() && contains(combinedPlugins, 'rtc')) {
19634
+ throw new Error('RTC plugin is not supported on IE 11.');
19635
+ }
19242
19636
  return Tools.extend(settings, { plugins: combinedPlugins.join(' ') });
19243
19637
  };
19244
19638
  var isOnMobile = function (isMobileDevice, sectionResult) {
@@ -19331,7 +19725,7 @@
19331
19725
  return rawElm[propName];
19332
19726
  };
19333
19727
  var getComputedSizeProp = function (propName, elm) {
19334
- return parseInt(get$4(elm, propName), 10);
19728
+ return parseInt(get$5(elm, propName), 10);
19335
19729
  };
19336
19730
  var getClientWidth = curry(getProp, 'clientWidth');
19337
19731
  var getClientHeight = curry(getProp, 'clientHeight');
@@ -19409,10 +19803,16 @@
19409
19803
  notifications.splice(index, 1);
19410
19804
  });
19411
19805
  };
19412
- var open = function (spec) {
19806
+ var open = function (spec, fireEvent) {
19807
+ if (fireEvent === void 0) {
19808
+ fireEvent = true;
19809
+ }
19413
19810
  if (editor.removed || !isEditorAttachedToDom(editor)) {
19414
19811
  return;
19415
19812
  }
19813
+ if (fireEvent) {
19814
+ editor.fire('BeforeOpenNotification', { notification: spec });
19815
+ }
19416
19816
  return find(notifications, function (notification) {
19417
19817
  return isEqual(getImplementation().getArgs(notification), spec);
19418
19818
  }).getOrThunk(function () {
@@ -19428,6 +19828,7 @@
19428
19828
  });
19429
19829
  addNotification(notification);
19430
19830
  reposition();
19831
+ editor.fire('OpenNotification', __assign({}, notification));
19431
19832
  return notification;
19432
19833
  });
19433
19834
  };
@@ -19449,7 +19850,7 @@
19449
19850
  text: serviceMessage,
19450
19851
  type: 'warning',
19451
19852
  timeout: 0
19452
- });
19853
+ }, false);
19453
19854
  }
19454
19855
  });
19455
19856
  editor.on('ResizeEditor ResizeWindow NodeChange', function () {
@@ -19841,16 +20242,23 @@
19841
20242
  'image/jpeg': 'jpg',
19842
20243
  'image/jpg': 'jpg',
19843
20244
  'image/gif': 'gif',
19844
- 'image/png': 'png'
20245
+ 'image/png': 'png',
20246
+ 'image/apng': 'apng',
20247
+ 'image/avif': 'avif',
20248
+ 'image/svg+xml': 'svg',
20249
+ 'image/webp': 'webp',
20250
+ 'image/bmp': 'bmp',
20251
+ 'image/tiff': 'tiff'
19845
20252
  };
19846
20253
  return mimes[mime.toLowerCase()] || 'dat';
19847
20254
  };
19848
- var create = function (o, blob, base64, filename) {
20255
+ var create = function (o, blob, base64, name, filename) {
19849
20256
  if (isString(o)) {
19850
20257
  var id = o;
19851
20258
  return toBlobInfo({
19852
20259
  id: id,
19853
- name: filename,
20260
+ name: name,
20261
+ filename: filename,
19854
20262
  blob: blob,
19855
20263
  base64: base64
19856
20264
  });
@@ -19866,13 +20274,14 @@
19866
20274
  }
19867
20275
  var id = o.id || uuid('blobid');
19868
20276
  var name = o.name || id;
20277
+ var blob = o.blob;
19869
20278
  return {
19870
20279
  id: constant(id),
19871
20280
  name: constant(name),
19872
- filename: constant(name + '.' + mimeToExt(o.blob.type)),
19873
- blob: constant(o.blob),
20281
+ filename: constant(o.filename || name + '.' + mimeToExt(blob.type)),
20282
+ blob: constant(blob),
19874
20283
  base64: constant(o.base64),
19875
- blobUri: constant(o.blobUri || URL.createObjectURL(o.blob)),
20284
+ blobUri: constant(o.blobUri || URL.createObjectURL(blob)),
19876
20285
  uri: constant(o.uri)
19877
20286
  };
19878
20287
  };
@@ -19926,11 +20335,31 @@
19926
20335
  };
19927
20336
  };
19928
20337
 
20338
+ var UploadChangeHandler = function (editor) {
20339
+ var lastChangedLevel = Cell(null);
20340
+ editor.on('change AddUndo', function (e) {
20341
+ lastChangedLevel.set(__assign({}, e.level));
20342
+ });
20343
+ var fireIfChanged = function () {
20344
+ var data = editor.undoManager.data;
20345
+ last(data).filter(function (level) {
20346
+ return !isEq$4(lastChangedLevel.get(), level);
20347
+ }).each(function (level) {
20348
+ editor.setDirty(true);
20349
+ editor.fire('change', {
20350
+ level: level,
20351
+ lastLevel: get(data, data.length - 2).getOrNull()
20352
+ });
20353
+ });
20354
+ };
20355
+ return { fireIfChanged: fireIfChanged };
20356
+ };
19929
20357
  var EditorUpload = function (editor) {
19930
20358
  var blobCache = BlobCache();
19931
20359
  var uploader, imageScanner;
19932
20360
  var uploadStatus = UploadStatus();
19933
20361
  var urlFilters = [];
20362
+ var changeHandler = UploadChangeHandler(editor);
19934
20363
  var aliveGuard = function (callback) {
19935
20364
  return function (result) {
19936
20365
  if (editor.selection) {
@@ -20021,6 +20450,9 @@
20021
20450
  blobInfo: blobInfo
20022
20451
  };
20023
20452
  });
20453
+ if (filteredResult.length > 0) {
20454
+ changeHandler.fireIfChanged();
20455
+ }
20024
20456
  if (imagesToRemove.length > 0) {
20025
20457
  if (isRtc(editor)) {
20026
20458
  console.error('Removing images on failed uploads is currently unsupported for RTC');
@@ -20115,7 +20547,7 @@
20115
20547
  e.content = replaceBlobUris(e.content);
20116
20548
  });
20117
20549
  editor.on('GetContent', function (e) {
20118
- if (e.source_view || e.format === 'raw') {
20550
+ if (e.source_view || e.format === 'raw' || e.format === 'tree') {
20119
20551
  return;
20120
20552
  }
20121
20553
  e.content = replaceBlobUris(e.content);
@@ -20144,98 +20576,7 @@
20144
20576
  };
20145
20577
  };
20146
20578
 
20147
- var setup$5 = function (registeredFormatListeners, editor) {
20148
- var currentFormats = Cell({});
20149
- registeredFormatListeners.set({});
20150
- editor.on('NodeChange', function (e) {
20151
- updateAndFireChangeCallbacks(editor, e.element, currentFormats, registeredFormatListeners.get());
20152
- });
20153
- };
20154
- var updateAndFireChangeCallbacks = function (editor, elm, currentFormats, formatChangeData) {
20155
- var formatsList = keys(currentFormats.get());
20156
- var newFormats = {};
20157
- var matchedFormats = {};
20158
- var parents = filter(getParents$1(editor.dom, elm), function (node) {
20159
- return node.nodeType === 1 && !node.getAttribute('data-mce-bogus');
20160
- });
20161
- each$1(formatChangeData, function (data, format) {
20162
- Tools.each(parents, function (node) {
20163
- if (editor.formatter.matchNode(node, format, {}, data.similar)) {
20164
- if (formatsList.indexOf(format) === -1) {
20165
- each(data.callbacks, function (callback) {
20166
- callback(true, {
20167
- node: node,
20168
- format: format,
20169
- parents: parents
20170
- });
20171
- });
20172
- newFormats[format] = data.callbacks;
20173
- }
20174
- matchedFormats[format] = data.callbacks;
20175
- return false;
20176
- }
20177
- if (matchesUnInheritedFormatSelector(editor, node, format)) {
20178
- return false;
20179
- }
20180
- });
20181
- });
20182
- var remainingFormats = filterRemainingFormats(currentFormats.get(), matchedFormats, elm, parents);
20183
- currentFormats.set(__assign(__assign({}, newFormats), remainingFormats));
20184
- };
20185
- var filterRemainingFormats = function (currentFormats, matchedFormats, elm, parents) {
20186
- return bifilter(currentFormats, function (callbacks, format) {
20187
- if (!has(matchedFormats, format)) {
20188
- each(callbacks, function (callback) {
20189
- callback(false, {
20190
- node: elm,
20191
- format: format,
20192
- parents: parents
20193
- });
20194
- });
20195
- return false;
20196
- } else {
20197
- return true;
20198
- }
20199
- }).t;
20200
- };
20201
- var addListeners = function (registeredFormatListeners, formats, callback, similar) {
20202
- var formatChangeItems = registeredFormatListeners.get();
20203
- each(formats.split(','), function (format) {
20204
- if (!formatChangeItems[format]) {
20205
- formatChangeItems[format] = {
20206
- similar: similar,
20207
- callbacks: []
20208
- };
20209
- }
20210
- formatChangeItems[format].callbacks.push(callback);
20211
- });
20212
- registeredFormatListeners.set(formatChangeItems);
20213
- };
20214
- var removeListeners = function (registeredFormatListeners, formats, callback) {
20215
- var formatChangeItems = registeredFormatListeners.get();
20216
- each(formats.split(','), function (format) {
20217
- formatChangeItems[format].callbacks = filter(formatChangeItems[format].callbacks, function (c) {
20218
- return c !== callback;
20219
- });
20220
- if (formatChangeItems[format].callbacks.length === 0) {
20221
- delete formatChangeItems[format];
20222
- }
20223
- });
20224
- registeredFormatListeners.set(formatChangeItems);
20225
- };
20226
- var formatChanged = function (editor, registeredFormatListeners, formats, callback, similar) {
20227
- if (registeredFormatListeners.get() === null) {
20228
- setup$5(registeredFormatListeners, editor);
20229
- }
20230
- addListeners(registeredFormatListeners, formats, callback, similar);
20231
- return {
20232
- unbind: function () {
20233
- return removeListeners(registeredFormatListeners, formats, callback);
20234
- }
20235
- };
20236
- };
20237
-
20238
- var get$9 = function (dom) {
20579
+ var get$a = function (dom) {
20239
20580
  var formats = {
20240
20581
  valigntop: [{
20241
20582
  selector: 'td,th',
@@ -20554,7 +20895,7 @@
20554
20895
  }
20555
20896
  return formats;
20556
20897
  };
20557
- register(get$9(editor.dom));
20898
+ register(get$a(editor.dom));
20558
20899
  register(getFormats(editor));
20559
20900
  return {
20560
20901
  get: get,
@@ -20706,7 +21047,7 @@
20706
21047
  format = format[0];
20707
21048
  }
20708
21049
  if ('preview' in format) {
20709
- var previewOpt = get(format, 'preview');
21050
+ var previewOpt = get$1(format, 'preview');
20710
21051
  if (previewOpt.is(false)) {
20711
21052
  return '';
20712
21053
  } else {
@@ -20830,11 +21171,24 @@
20830
21171
  toggle: function (name, vars, node) {
20831
21172
  toggleFormat(editor, name, vars, node);
20832
21173
  },
20833
- match: curry(match, editor),
20834
- matchAll: curry(matchAll, editor),
20835
- matchNode: curry(matchNode, editor),
20836
- canApply: curry(canApply, editor),
20837
- formatChanged: curry(formatChanged, editor, formatChangeState),
21174
+ match: function (name, vars, node) {
21175
+ return matchFormat(editor, name, vars, node);
21176
+ },
21177
+ closest: function (names) {
21178
+ return closestFormat(editor, names);
21179
+ },
21180
+ matchAll: function (names, vars) {
21181
+ return matchAllFormats(editor, names, vars);
21182
+ },
21183
+ matchNode: function (node, names, vars, similar) {
21184
+ return matchNodeFormat(editor, node, names, vars, similar);
21185
+ },
21186
+ canApply: function (name) {
21187
+ return canApplyFormat(editor, name);
21188
+ },
21189
+ formatChanged: function (formats, callback, similar) {
21190
+ return formatChanged(editor, formatChangeState, formats, callback, similar);
21191
+ },
20838
21192
  getCssText: curry(getCssText, editor)
20839
21193
  };
20840
21194
  };
@@ -22147,7 +22501,7 @@
22147
22501
  };
22148
22502
  var getIndentStyleName = function (useMargin, element) {
22149
22503
  var indentStyleName = useMargin || isTable$1(element) ? 'margin' : 'padding';
22150
- var suffix = get$4(element, 'direction') === 'rtl' ? '-right' : '-left';
22504
+ var suffix = get$5(element, 'direction') === 'rtl' ? '-right' : '-left';
22151
22505
  return indentStyleName + suffix;
22152
22506
  };
22153
22507
  var indentElement = function (dom, command, useMargin, value, unit, element) {
@@ -24731,6 +25085,7 @@
24731
25085
  editor._selectionOverrides.hideFakeCaret();
24732
25086
  editor.selection.placeCaretAt(clientX, clientY);
24733
25087
  }, 0);
25088
+ editor.on('remove', throttledPlaceCaretAt.stop);
24734
25089
  return function (e) {
24735
25090
  return state.on(function (state) {
24736
25091
  var movement = Math.max(Math.abs(e.screenX - state.screenX), Math.abs(e.screenY - state.screenY));
@@ -24924,7 +25279,7 @@
24924
25279
  return dom.hasClass(node, 'mce-offscreen-selection');
24925
25280
  };
24926
25281
  var isFakeSelectionTargetElement = function (node) {
24927
- return isContentEditableFalse$b(node) || isMedia(node);
25282
+ return node !== rootNode && (isContentEditableFalse$b(node) || isMedia(node)) && dom.isChildOf(node, rootNode);
24928
25283
  };
24929
25284
  var isNearFakeSelectionElement = function (pos) {
24930
25285
  return isBeforeContentEditableFalse(pos) || isAfterContentEditableFalse(pos) || isBeforeMedia(pos) || isAfterMedia(pos);
@@ -25710,6 +26065,7 @@
25710
26065
  return removeUndefined({
25711
26066
  allow_conditional_comments: settings.allow_conditional_comments,
25712
26067
  allow_html_data_urls: settings.allow_html_data_urls,
26068
+ allow_svg_data_urls: settings.allow_svg_data_urls,
25713
26069
  allow_html_in_named_anchor: settings.allow_html_in_named_anchor,
25714
26070
  allow_script_urls: settings.allow_script_urls,
25715
26071
  allow_unsafe_link_target: settings.allow_unsafe_link_target,
@@ -25987,7 +26343,7 @@
25987
26343
  setup$a(editor);
25988
26344
  setup$7(editor);
25989
26345
  firePreInit(editor);
25990
- setup$4(editor).fold(function () {
26346
+ setup$5(editor).fold(function () {
25991
26347
  preInit(editor, false);
25992
26348
  }, function (loadingRtc) {
25993
26349
  editor.setProgressState(true);
@@ -26163,13 +26519,27 @@
26163
26519
  return renderThemeFalse(editor);
26164
26520
  }
26165
26521
  };
26522
+ var augmentEditorUiApi = function (editor, api) {
26523
+ var uiApiFacade = {
26524
+ show: Optional.from(api.show).getOr(noop),
26525
+ hide: Optional.from(api.hide).getOr(noop),
26526
+ disable: Optional.from(api.disable).getOr(noop),
26527
+ isDisabled: Optional.from(api.isDisabled).getOr(never),
26528
+ enable: function () {
26529
+ if (!editor.mode.isReadOnly()) {
26530
+ Optional.from(api.enable).map(call);
26531
+ }
26532
+ }
26533
+ };
26534
+ editor.ui = __assign(__assign({}, editor.ui), uiApiFacade);
26535
+ };
26166
26536
  var init$2 = function (editor) {
26167
26537
  editor.fire('ScriptsLoaded');
26168
26538
  initIcons(editor);
26169
26539
  initTheme(editor);
26170
26540
  initPlugins(editor);
26171
26541
  var renderInfo = renderThemeUi(editor);
26172
- editor.ui = __assign(__assign({}, editor.ui), renderInfo.api);
26542
+ augmentEditorUiApi(editor, Optional.from(renderInfo.api).getOr({}));
26173
26543
  var boxInfo = {
26174
26544
  editorContainer: renderInfo.editorContainer,
26175
26545
  iframeContainer: renderInfo.iframeContainer
@@ -26399,30 +26769,8 @@
26399
26769
  loadScripts(editor, editor.suffix);
26400
26770
  };
26401
26771
 
26402
- var ensureIsRoot = function (isRoot) {
26403
- return isFunction(isRoot) ? isRoot : never;
26404
- };
26405
- var ancestor$3 = function (scope, transform, isRoot) {
26406
- var element = scope.dom;
26407
- var stop = ensureIsRoot(isRoot);
26408
- while (element.parentNode) {
26409
- element = element.parentNode;
26410
- var el = SugarElement.fromDom(element);
26411
- var transformed = transform(el);
26412
- if (transformed.isSome()) {
26413
- return transformed;
26414
- } else if (stop(el)) {
26415
- break;
26416
- }
26417
- }
26418
- return Optional.none();
26419
- };
26420
- var closest$2 = function (scope, transform, isRoot) {
26421
- var current = transform(scope);
26422
- var stop = ensureIsRoot(isRoot);
26423
- return current.orThunk(function () {
26424
- return stop(scope) ? Optional.none() : ancestor$3(scope, transform, stop);
26425
- });
26772
+ var addVisual$1 = function (editor, elm) {
26773
+ return addVisual(editor, elm);
26426
26774
  };
26427
26775
 
26428
26776
  var legacyPropNames = {
@@ -26433,7 +26781,7 @@
26433
26781
  var getProperty = function (elm) {
26434
26782
  return getRaw(elm, propName).orThunk(function () {
26435
26783
  if (name(elm) === 'font') {
26436
- return get(legacyPropNames, propName).bind(function (legacyPropName) {
26784
+ return get$1(legacyPropNames, propName).bind(function (legacyPropName) {
26437
26785
  return getOpt(elm, legacyPropName);
26438
26786
  });
26439
26787
  } else {
@@ -26536,8 +26884,8 @@
26536
26884
  return getRaw(elm, 'line-height');
26537
26885
  }, curry(eq$2, root));
26538
26886
  var computedStyle = function () {
26539
- var lineHeight = parseFloat(get$4(elm, 'line-height'));
26540
- var fontSize = parseFloat(get$4(elm, 'font-size'));
26887
+ var lineHeight = parseFloat(get$5(elm, 'line-height'));
26888
+ var fontSize = parseFloat(get$5(elm, 'font-size'));
26541
26889
  return String(lineHeight / fontSize);
26542
26890
  };
26543
26891
  return specifiedStyle.getOrThunk(computedStyle);
@@ -27070,13 +27418,28 @@
27070
27418
  var isClickEvent = function (e) {
27071
27419
  return e.type === 'click';
27072
27420
  };
27073
- var isInAnchor = function (editor, target) {
27074
- return editor.dom.getParent(target, 'a') !== null;
27421
+ var getAnchorHrefOpt = function (editor, elm) {
27422
+ var isRoot = function (elm) {
27423
+ return eq$2(elm, SugarElement.fromDom(editor.getBody()));
27424
+ };
27425
+ return closest$1(elm, 'a', isRoot).bind(function (a) {
27426
+ return getOpt(a, 'href');
27427
+ });
27075
27428
  };
27076
- var preventReadOnlyEvents = function (editor, e) {
27077
- var target = e.target;
27078
- if (isClickEvent(e) && !VK.metaKeyPressed(e) && isInAnchor(editor, target)) {
27079
- e.preventDefault();
27429
+ var processReadonlyEvents = function (editor, e) {
27430
+ if (isClickEvent(e) && !VK.metaKeyPressed(e)) {
27431
+ var elm = SugarElement.fromDom(e.target);
27432
+ getAnchorHrefOpt(editor, elm).each(function (href) {
27433
+ e.preventDefault();
27434
+ if (/^#/.test(href)) {
27435
+ var targetEl = editor.dom.select(href + ',[name="' + removeLeading(href, '#') + '"]');
27436
+ if (targetEl.length) {
27437
+ editor.selection.scrollIntoView(targetEl[0], true);
27438
+ }
27439
+ } else {
27440
+ window.open(href, '_blank', 'rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes');
27441
+ }
27442
+ });
27080
27443
  }
27081
27444
  };
27082
27445
  var registerReadOnlySelectionBlockers = function (editor) {
@@ -27292,7 +27655,7 @@
27292
27655
  if (isListening(editor)) {
27293
27656
  editor.fire(eventName, e);
27294
27657
  } else if (isReadOnly$1(editor)) {
27295
- preventReadOnlyEvents(editor, e);
27658
+ processReadonlyEvents(editor, e);
27296
27659
  }
27297
27660
  };
27298
27661
  var bindEventDelegate = function (editor, eventName) {
@@ -27985,7 +28348,10 @@
27985
28348
  registry: registry(),
27986
28349
  styleSheetLoader: undefined,
27987
28350
  show: noop,
27988
- hide: noop
28351
+ hide: noop,
28352
+ enable: noop,
28353
+ disable: noop,
28354
+ isDisabled: never
27989
28355
  };
27990
28356
  var self = this;
27991
28357
  var modeInstance = create$5(self);
@@ -28265,43 +28631,7 @@
28265
28631
  return url;
28266
28632
  };
28267
28633
  Editor.prototype.addVisual = function (elm) {
28268
- var self = this;
28269
- var settings = self.settings;
28270
- var dom = self.dom;
28271
- var cls;
28272
- elm = elm || self.getBody();
28273
- if (self.hasVisual === undefined) {
28274
- self.hasVisual = settings.visual;
28275
- }
28276
- each$i(dom.select('table,a', elm), function (elm) {
28277
- var value;
28278
- switch (elm.nodeName) {
28279
- case 'TABLE':
28280
- cls = settings.visual_table_class || 'mce-item-table';
28281
- value = dom.getAttrib(elm, 'border');
28282
- if ((!value || value === '0') && self.hasVisual) {
28283
- dom.addClass(elm, cls);
28284
- } else {
28285
- dom.removeClass(elm, cls);
28286
- }
28287
- return;
28288
- case 'A':
28289
- if (!dom.getAttrib(elm, 'href')) {
28290
- value = dom.getAttrib(elm, 'name') || elm.id;
28291
- cls = settings.visual_anchor_class || 'mce-item-anchor';
28292
- if (value && self.hasVisual) {
28293
- dom.addClass(elm, cls);
28294
- } else {
28295
- dom.removeClass(elm, cls);
28296
- }
28297
- }
28298
- return;
28299
- }
28300
- });
28301
- self.fire('VisualAid', {
28302
- element: elm,
28303
- hasVisual: self.hasVisual
28304
- });
28634
+ addVisual$1(this, elm);
28305
28635
  };
28306
28636
  Editor.prototype.remove = function () {
28307
28637
  remove$7(this);
@@ -28401,8 +28731,8 @@
28401
28731
  suffix: null,
28402
28732
  $: DomQuery,
28403
28733
  majorVersion: '5',
28404
- minorVersion: '5.1',
28405
- releaseDate: '2020-10-01',
28734
+ minorVersion: '6.0',
28735
+ releaseDate: '2020-11-18',
28406
28736
  editors: legacyEditors,
28407
28737
  i18n: I18n,
28408
28738
  activeEditor: null,
@@ -28479,7 +28809,7 @@
28479
28809
  var createId = function (elm) {
28480
28810
  var id = elm.id;
28481
28811
  if (!id) {
28482
- id = get(elm, 'name').filter(function (name) {
28812
+ id = get$1(elm, 'name').filter(function (name) {
28483
28813
  return !DOM$a.get(name);
28484
28814
  }).getOrThunk(DOM$a.uniqueId);
28485
28815
  elm.setAttribute('id', id);