jodit 4.12.44 → 4.13.5

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. package/CHANGELOG.md +23 -1
  2. package/es2015/jodit.css +6 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +14 -14
  5. package/es2015/jodit.js +159 -19
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +5 -5
  8. package/es2015/plugins/debug/debug.css +1 -1
  9. package/es2015/plugins/debug/debug.js +1 -1
  10. package/es2015/plugins/debug/debug.min.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  13. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  14. package/es2018/jodit.fat.min.css +1 -1
  15. package/es2018/jodit.fat.min.js +3 -3
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +5 -5
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  20. package/es2021/jodit.css +6 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +5 -5
  23. package/es2021/jodit.js +150 -19
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +7 -7
  26. package/es2021/plugins/debug/debug.css +1 -1
  27. package/es2021/plugins/debug/debug.js +1 -1
  28. package/es2021/plugins/debug/debug.min.js +1 -1
  29. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  30. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  31. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  32. package/es2021.en/jodit.css +6 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +6 -6
  35. package/es2021.en/jodit.js +150 -19
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +6 -6
  38. package/es2021.en/plugins/debug/debug.css +1 -1
  39. package/es2021.en/plugins/debug/debug.js +1 -1
  40. package/es2021.en/plugins/debug/debug.min.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  42. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  44. package/es5/jodit.css +7 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +195 -19
  48. package/es5/jodit.min.css +3 -3
  49. package/es5/jodit.min.js +2 -2
  50. package/es5/plugins/debug/debug.css +1 -1
  51. package/es5/plugins/debug/debug.js +1 -1
  52. package/es5/plugins/debug/debug.min.js +1 -1
  53. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  56. package/es5/polyfills.fat.min.js +1 -1
  57. package/es5/polyfills.js +1 -1
  58. package/es5/polyfills.min.js +1 -1
  59. package/esm/core/constants.js +1 -1
  60. package/esm/core/helpers/html/safe-html.js +3 -2
  61. package/esm/core/selection/selection.d.ts +31 -0
  62. package/esm/core/selection/selection.js +143 -14
  63. package/esm/core/view/view-with-toolbar.d.ts +6 -0
  64. package/esm/core/view/view-with-toolbar.js +18 -2
  65. package/esm/jodit.js +7 -0
  66. package/esm/types/jodit.d.ts +2 -0
  67. package/package.json +1 -1
  68. package/types/core/selection/selection.d.ts +31 -0
  69. package/types/core/view/view-with-toolbar.d.ts +6 -0
  70. package/types/types/jodit.d.ts +2 -0
package/es5/jodit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.12.44
4
+ * Version: v4.13.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -2107,7 +2107,7 @@ __webpack_require__.r(__webpack_exports__);
2107
2107
  * @packageDocumentation
2108
2108
  * @module constants
2109
2109
  */
2110
- var APP_VERSION = "4.12.44";
2110
+ var APP_VERSION = "4.13.5";
2111
2111
  // prettier-ignore
2112
2112
  var ES = "es5";
2113
2113
  var IS_ES_MODERN = false;
@@ -7110,7 +7110,7 @@ var HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
7110
7110
  // markup into a live node.
7111
7111
  var foreign = box.querySelectorAll('math *, svg *');
7112
7112
  for(var i = 0; i < foreign.length; i++){
7113
- if (foreign[i].isConnected && isSmuggledForeignHtml(foreign[i])) {
7113
+ if (box.contains(foreign[i]) && isSmuggledForeignHtml(foreign[i])) {
7114
7114
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(foreign[i]);
7115
7115
  }
7116
7116
  }
@@ -7236,7 +7236,8 @@ function sanitizeHTMLElement(elm) {
7236
7236
  // scheme (e.g. `java\tscript:`) — all of which the browser still resolves to
7237
7237
  // `javascript:` on click. See GHSA-j839-gqq4-gf9j.
7238
7238
  if (safeJavaScriptLink && href && isDangerousUrl(href, tagName)) {
7239
- (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'href', location.protocol + '//' + href);
7239
+ var protocol = typeof location !== 'undefined' ? location.protocol : 'http:';
7240
+ (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'href', protocol + '//' + href);
7240
7241
  effected = true;
7241
7242
  }
7242
7243
  if (safeJavaScriptLink) {
@@ -12949,6 +12950,170 @@ var Selection = /*#__PURE__*/ function() {
12949
12950
  return '';
12950
12951
  }
12951
12952
  },
12953
+ {
12954
+ key: "__wrapSelectionFragments",
12955
+ value: /**
12956
+ * Splits the boundaries of the current selection and wraps every
12957
+ * contiguous run of selected inline content (grouped by block) into a
12958
+ * `<font>` element, returning those wrappers in document order.
12959
+ *
12960
+ * This is a pure-DOM replacement for the old
12961
+ * `nativeExecCommand('fontsize', false, '7')` trick which relied on the
12962
+ * browser to split the selection into `<font size="7">` fragments.
12963
+ */ function __wrapSelectionFragments() {
12964
+ var range = this.range;
12965
+ this.__splitSelectionBoundaries(range);
12966
+ var root = range.commonAncestorContainer;
12967
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(root)) {
12968
+ root = root.parentNode;
12969
+ }
12970
+ if (!root) {
12971
+ return [];
12972
+ }
12973
+ return this.__wrapSelectionRuns(this.__collectContainedNodes(root, range));
12974
+ }
12975
+ },
12976
+ {
12977
+ key: "__splitSelectionBoundaries",
12978
+ value: /**
12979
+ * Splits the text nodes at both ends of the range so that its boundaries
12980
+ * always fall between nodes. Afterwards every node inside the range is
12981
+ * fully (not partially) selected.
12982
+ */ function __splitSelectionBoundaries(range) {
12983
+ var _ref, _ref1;
12984
+ var _endContainer_nodeValue, _startContainer_nodeValue;
12985
+ var startContainer = range.startContainer, endContainer = range.endContainer;
12986
+ var startOffset = range.startOffset, endOffset = range.endOffset;
12987
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(endContainer) && endOffset > 0 && endOffset < ((_ref = (_endContainer_nodeValue = endContainer.nodeValue) === null || _endContainer_nodeValue === void 0 ? void 0 : _endContainer_nodeValue.length) !== null && _ref !== void 0 ? _ref : 0)) {
12988
+ var _ref2;
12989
+ var _endContainer_nodeValue1;
12990
+ endContainer.splitText(endOffset);
12991
+ endOffset = (_ref2 = (_endContainer_nodeValue1 = endContainer.nodeValue) === null || _endContainer_nodeValue1 === void 0 ? void 0 : _endContainer_nodeValue1.length) !== null && _ref2 !== void 0 ? _ref2 : endOffset;
12992
+ }
12993
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(startContainer) && startOffset > 0 && startOffset < ((_ref1 = (_startContainer_nodeValue = startContainer.nodeValue) === null || _startContainer_nodeValue === void 0 ? void 0 : _startContainer_nodeValue.length) !== null && _ref1 !== void 0 ? _ref1 : 0)) {
12994
+ var middle = startContainer.splitText(startOffset);
12995
+ // Selection located inside a single text node - the tail we just
12996
+ // cut off is the actual selected fragment.
12997
+ if (startContainer === endContainer) {
12998
+ var _ref3;
12999
+ var _middle_nodeValue;
13000
+ endContainer = middle;
13001
+ endOffset = (_ref3 = (_middle_nodeValue = middle.nodeValue) === null || _middle_nodeValue === void 0 ? void 0 : _middle_nodeValue.length) !== null && _ref3 !== void 0 ? _ref3 : 0;
13002
+ }
13003
+ startContainer = middle;
13004
+ startOffset = 0;
13005
+ }
13006
+ range.setStart(startContainer, startOffset);
13007
+ range.setEnd(endContainer, endOffset);
13008
+ // Normalize text-edge boundaries (e.g. `(text, 0)` or `(text, length)`)
13009
+ // to the element level so that containment checks based on
13010
+ // `selectNode()` treat a fully selected text node as contained.
13011
+ this.__normalizeRangeBoundary(range, true);
13012
+ this.__normalizeRangeBoundary(range, false);
13013
+ }
13014
+ },
13015
+ {
13016
+ key: "__normalizeRangeBoundary",
13017
+ value: function __normalizeRangeBoundary(range, atStart) {
13018
+ var _ref;
13019
+ var _container_nodeValue;
13020
+ var container = atStart ? range.startContainer : range.endContainer;
13021
+ if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isText(container)) {
13022
+ return;
13023
+ }
13024
+ var offset = atStart ? range.startOffset : range.endOffset;
13025
+ var length = (_ref = (_container_nodeValue = container.nodeValue) === null || _container_nodeValue === void 0 ? void 0 : _container_nodeValue.length) !== null && _ref !== void 0 ? _ref : 0;
13026
+ if (offset === 0) {
13027
+ atStart ? range.setStartBefore(container) : range.setEndBefore(container);
13028
+ } else if (offset >= length) {
13029
+ atStart ? range.setStartAfter(container) : range.setEndAfter(container);
13030
+ }
13031
+ }
13032
+ },
13033
+ {
13034
+ key: "__collectContainedNodes",
13035
+ value: /**
13036
+ * Collects the highest-level nodes that are completely inside the range,
13037
+ * descending into nodes that are only partially selected.
13038
+ */ function __collectContainedNodes(root, range) {
13039
+ var _this = this;
13040
+ var result = [];
13041
+ (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.toArray)(root.childNodes).forEach(function(child) {
13042
+ if (_this.__isFullyContained(range, child)) {
13043
+ result.push(child);
13044
+ } else if (child.childNodes.length && range.intersectsNode(child)) {
13045
+ var _result;
13046
+ (_result = result).push.apply(_result, (0,_swc_helpers_to_consumable_array__WEBPACK_IMPORTED_MODULE_4__._)(_this.__collectContainedNodes(child, range)));
13047
+ }
13048
+ });
13049
+ return result;
13050
+ }
13051
+ },
13052
+ {
13053
+ key: "__isFullyContained",
13054
+ value: function __isFullyContained(range, node) {
13055
+ var nodeRange = this.createRange();
13056
+ nodeRange.selectNode(node);
13057
+ return range.compareBoundaryPoints(Range.START_TO_START, nodeRange) <= 0 && range.compareBoundaryPoints(Range.END_TO_END, nodeRange) >= 0;
13058
+ }
13059
+ },
13060
+ {
13061
+ key: "__wrapSelectionRuns",
13062
+ value: /**
13063
+ * Wraps every contiguous run of selected inline siblings into a `<font>`
13064
+ * element. Block-level nodes are never wrapped themselves - their inline
13065
+ * content is wrapped instead, keeping every `<font>` inside a single block.
13066
+ */ function __wrapSelectionRuns(nodes) {
13067
+ var _this = this;
13068
+ var fonts = [];
13069
+ var run = [];
13070
+ var flush = function flush() {
13071
+ if (run.length) {
13072
+ fonts.push(_this.__wrapRunInFont(run));
13073
+ run = [];
13074
+ }
13075
+ };
13076
+ nodes.forEach(function(node) {
13077
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isElement(node) && _this.__isOrContainsBlock(node)) {
13078
+ var _fonts;
13079
+ flush();
13080
+ (_fonts = fonts).push.apply(_fonts, (0,_swc_helpers_to_consumable_array__WEBPACK_IMPORTED_MODULE_4__._)(_this.__wrapSelectionRuns((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.toArray)(node.childNodes))));
13081
+ } else {
13082
+ if (run.length && run[run.length - 1].parentNode !== node.parentNode) {
13083
+ flush();
13084
+ }
13085
+ run.push(node);
13086
+ }
13087
+ });
13088
+ flush();
13089
+ return fonts;
13090
+ }
13091
+ },
13092
+ {
13093
+ key: "__isOrContainsBlock",
13094
+ value: function __isOrContainsBlock(node) {
13095
+ var _this = this;
13096
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isBlock(node)) {
13097
+ return true;
13098
+ }
13099
+ return (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.toArray)(node.childNodes).some(function(child) {
13100
+ return _this.__isOrContainsBlock(child);
13101
+ });
13102
+ }
13103
+ },
13104
+ {
13105
+ key: "__wrapRunInFont",
13106
+ value: function __wrapRunInFont(run) {
13107
+ var _first_parentNode;
13108
+ var font = this.j.createInside.element('font');
13109
+ var _run = (0,_swc_helpers_sliced_to_array__WEBPACK_IMPORTED_MODULE_3__._)(run, 1), first = _run[0];
13110
+ (_first_parentNode = first.parentNode) === null || _first_parentNode === void 0 ? void 0 : _first_parentNode.insertBefore(font, first);
13111
+ run.forEach(function(node) {
13112
+ return font.appendChild(node);
13113
+ });
13114
+ return font;
13115
+ }
13116
+ },
12952
13117
  {
12953
13118
  key: "wrapInTagGen",
12954
13119
  value: /**
@@ -12978,20 +13143,7 @@ var Selection = /*#__PURE__*/ function() {
12978
13143
  2
12979
13144
  ];
12980
13145
  case 2:
12981
- // fix issue https://github.com/xdan/jodit/issues/65
12982
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.$$)('*[style*=font-size]', this.area).forEach(function(elm) {
12983
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.attr)(elm, 'data-font-size', elm.style.fontSize.toString());
12984
- elm.style.removeProperty('font-size');
12985
- });
12986
- this.j.nativeExecCommand('fontsize', false, '7');
12987
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.$$)('*[data-font-size]', this.area).forEach(function(elm) {
12988
- var fontSize = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.attr)(elm, 'data-font-size');
12989
- if (fontSize) {
12990
- elm.style.fontSize = fontSize;
12991
- (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.attr)(elm, 'data-font-size', null);
12992
- }
12993
- });
12994
- elms = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_11__.$$)('font[size="7"]', this.area);
13146
+ elms = this.__wrapSelectionFragments();
12995
13147
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
12996
13148
  _state.label = 3;
12997
13149
  case 3:
@@ -20031,10 +20183,27 @@ var ViewWithToolbar = /*#__PURE__*/ function(View) {
20031
20183
  if (!this.o.fullsize && ((0,jodit_core_helpers_checker_is_string__WEBPACK_IMPORTED_MODULE_14__.isString)(this.o.toolbar) || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_12__.Dom.isHTMLElement(this.o.toolbar))) {
20032
20184
  return (0,jodit_core_helpers_utils_selector__WEBPACK_IMPORTED_MODULE_15__.resolveElement)(this.o.toolbar, this.o.shadowRoot || this.od);
20033
20185
  }
20034
- this.o.toolbar && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_12__.Dom.appendChildFirst(this.container, this.__defaultToolbarContainer);
20186
+ this.o.toolbar && this.__appendToolbarBox();
20035
20187
  return this.__defaultToolbarContainer;
20036
20188
  }
20037
20189
  },
20190
+ {
20191
+ key: "__appendToolbarBox",
20192
+ value: /**
20193
+ * Keep the toolbar box as the first child of the container, except that
20194
+ * children flagged with `data-jodit-above-toolbar` (e.g. the `above`
20195
+ * workplace slot used for presence bars and banners) stay above it.
20196
+ */ function __appendToolbarBox() {
20197
+ var box = this.__defaultToolbarContainer;
20198
+ var anchor = this.container.firstElementChild;
20199
+ while(anchor && anchor !== box && anchor.hasAttribute('data-jodit-above-toolbar')){
20200
+ anchor = anchor.nextElementSibling;
20201
+ }
20202
+ if (anchor !== box) {
20203
+ this.container.insertBefore(box, anchor);
20204
+ }
20205
+ }
20206
+ },
20038
20207
  {
20039
20208
  /**
20040
20209
  * Change panel container
@@ -21671,6 +21840,12 @@ var Jodit = /*#__PURE__*/ function(ViewWithToolbar) {
21671
21840
  element.style.display = 'none';
21672
21841
  }
21673
21842
  var SLOT = 'workplace-slot';
21843
+ // A slot that always stays ABOVE the toolbar (presence bars, banners…).
21844
+ // The `data-jodit-above-toolbar` attribute tells ViewWithToolbar to keep
21845
+ // the toolbar box below it when (re)attaching the toolbar container.
21846
+ var aboveSlot = this.c.div(this.getFullElName(SLOT, 'above'), NOEDIT);
21847
+ aboveSlot.setAttribute('data-jodit-above-toolbar', '');
21848
+ jodit_modules__WEBPACK_IMPORTED_MODULE_19__.Dom.appendChildFirst(container, aboveSlot);
21674
21849
  var topSlot = this.c.div(this.getFullElName(SLOT, 'top'), NOEDIT);
21675
21850
  container.appendChild(topSlot);
21676
21851
  var centerSlot = this.c.div(this.getFullElName(SLOT, 'center'), NOEDIT);
@@ -21703,6 +21878,7 @@ var Jodit = /*#__PURE__*/ function(ViewWithToolbar) {
21703
21878
  container: container,
21704
21879
  workplace: workplace,
21705
21880
  slots: {
21881
+ above: aboveSlot,
21706
21882
  top: topSlot,
21707
21883
  bottom: bottomPanel,
21708
21884
  center: centerSlot,