jodit 4.17.1 → 4.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/.nvmrc +1 -0
  2. package/CHANGELOG.md +12 -0
  3. package/es2015/jodit.css +1 -1
  4. package/es2015/jodit.fat.min.js +4 -4
  5. package/es2015/jodit.js +182 -7
  6. package/es2015/jodit.min.js +4 -4
  7. package/es2015/plugins/debug/debug.css +1 -1
  8. package/es2015/plugins/debug/debug.js +1 -1
  9. package/es2015/plugins/debug/debug.min.js +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  13. package/es2018/jodit.fat.min.js +4 -4
  14. package/es2018/jodit.min.js +4 -4
  15. package/es2018/plugins/debug/debug.min.js +1 -1
  16. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  17. package/es2021/jodit.css +1 -1
  18. package/es2021/jodit.fat.min.js +6 -6
  19. package/es2021/jodit.js +182 -7
  20. package/es2021/jodit.min.js +6 -6
  21. package/es2021/plugins/debug/debug.css +1 -1
  22. package/es2021/plugins/debug/debug.js +1 -1
  23. package/es2021/plugins/debug/debug.min.js +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  26. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  27. package/es2021.en/jodit.css +1 -1
  28. package/es2021.en/jodit.fat.min.js +24 -24
  29. package/es2021.en/jodit.js +182 -7
  30. package/es2021.en/jodit.min.js +6 -6
  31. package/es2021.en/plugins/debug/debug.css +1 -1
  32. package/es2021.en/plugins/debug/debug.js +1 -1
  33. package/es2021.en/plugins/debug/debug.min.js +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  36. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  37. package/es5/jodit.css +2 -2
  38. package/es5/jodit.fat.min.js +2 -2
  39. package/es5/jodit.js +217 -7
  40. package/es5/jodit.min.css +2 -2
  41. package/es5/jodit.min.js +2 -2
  42. package/es5/plugins/debug/debug.css +1 -1
  43. package/es5/plugins/debug/debug.js +1 -1
  44. package/es5/plugins/debug/debug.min.js +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  47. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  48. package/es5/polyfills.fat.min.js +1 -1
  49. package/es5/polyfills.js +1 -1
  50. package/es5/polyfills.min.js +1 -1
  51. package/esm/core/constants.js +1 -1
  52. package/esm/core/helpers/html/safe-html.js +15 -0
  53. package/esm/core/selection/helpers/composed-ranges.d.ts +21 -0
  54. package/esm/core/selection/helpers/composed-ranges.js +45 -0
  55. package/esm/core/selection/helpers/index.d.ts +1 -0
  56. package/esm/core/selection/helpers/index.js +1 -0
  57. package/esm/core/selection/selection.d.ts +23 -0
  58. package/esm/core/selection/selection.js +80 -4
  59. package/esm/jodit.js +5 -0
  60. package/esm/plugins/clean-html/clean-html.d.ts +8 -0
  61. package/esm/plugins/clean-html/clean-html.js +13 -0
  62. package/examples/build/es2015/jodit.min.css +1 -0
  63. package/examples/build/es2015/jodit.min.js +10 -0
  64. package/examples/build/es2015/plugins/debug/debug.min.js +10 -0
  65. package/examples/build/es2015/plugins/speech-recognize/speech-recognize.min.css +1 -0
  66. package/examples/build/es2015/plugins/speech-recognize/speech-recognize.min.js +10 -0
  67. package/package.json +1 -1
  68. package/types/core/selection/helpers/composed-ranges.d.ts +21 -0
  69. package/types/core/selection/helpers/index.d.ts +1 -0
  70. package/types/core/selection/selection.d.ts +23 -0
  71. package/types/plugins/clean-html/clean-html.d.ts +8 -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.17.1
4
+ * Version: v4.17.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -2129,7 +2129,7 @@ __webpack_require__.r(__webpack_exports__);
2129
2129
  * @packageDocumentation
2130
2130
  * @module constants
2131
2131
  */
2132
- var APP_VERSION = "4.17.1";
2132
+ var APP_VERSION = "4.17.3";
2133
2133
  // prettier-ignore
2134
2134
  var ES = "es5";
2135
2135
  var IS_ES_MODERN = false;
@@ -7161,6 +7161,38 @@ function isSmuggledForeignHtml(elm) {
7161
7161
  }
7162
7162
  }
7163
7163
  }
7164
+ // `<noscript>` is parsed as markup in a document with scripting off (the
7165
+ // inert document the value is sanitized in) and as raw text in one with
7166
+ // scripting on (the live editor). The same serialized bytes therefore
7167
+ // describe two different trees, and markup hidden as inert text in the
7168
+ // first comes alive as elements in the second. The element has no use in
7169
+ // editor content, so it goes, together with everything it carried.
7170
+ var noscript = [];
7171
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.each(box, function(node) {
7172
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isElement(node) && node.nodeName === 'NOSCRIPT') {
7173
+ noscript.push(node);
7174
+ }
7175
+ });
7176
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
7177
+ try {
7178
+ for(var _iterator1 = noscript[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
7179
+ var elm1 = _step1.value;
7180
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(elm1);
7181
+ }
7182
+ } catch (err) {
7183
+ _didIteratorError1 = true;
7184
+ _iteratorError1 = err;
7185
+ } finally{
7186
+ try {
7187
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
7188
+ _iterator1.return();
7189
+ }
7190
+ } finally{
7191
+ if (_didIteratorError1) {
7192
+ throw _iteratorError1;
7193
+ }
7194
+ }
7195
+ }
7164
7196
  var removeEvents = (_options_removeEventAttributes = options.removeEventAttributes) !== null && _options_removeEventAttributes !== void 0 ? _options_removeEventAttributes : options.removeOnError;
7165
7197
  // Single synchronous traversal of the subtree. Besides removing event
7166
7198
  // handlers and `javascript:` links, `sanitizeHTMLElement` neutralises
@@ -11970,6 +12002,73 @@ var Response = /*#__PURE__*/ function() {
11970
12002
  }();
11971
12003
 
11972
12004
 
12005
+ /***/ }),
12006
+
12007
+ /***/ 43134:
12008
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
12009
+
12010
+ "use strict";
12011
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12012
+ /* harmony export */ composedRanges: function() { return /* binding */ composedRanges; }
12013
+ /* harmony export */ });
12014
+ /* harmony import */ var jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28686);
12015
+ /*!
12016
+ * Jodit Editor (https://xdsoft.net/jodit/)
12017
+ * Released under MIT see LICENSE.txt in the project root for license information.
12018
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
12019
+ */ /**
12020
+ * @module selection
12021
+ */
12022
+ function isInside(node, shadowRoot) {
12023
+ return node === shadowRoot || shadowRoot.contains(node);
12024
+ }
12025
+ function usable(ranges, shadowRoot) {
12026
+ return Array.isArray(ranges) && ranges.length > 0 && ranges.every(function(range) {
12027
+ return isInside(range.startContainer, shadowRoot);
12028
+ });
12029
+ }
12030
+ /**
12031
+ * Ranges of a selection that lies inside the given shadow tree.
12032
+ *
12033
+ * `window.getSelection()` stops at the shadow boundary and reports the host
12034
+ * instead of the node the caret is really in. `getComposedRanges` is the
12035
+ * standard way to ask past that boundary.
12036
+ *
12037
+ * @returns `null` when the browser has no `getComposedRanges`, or when neither
12038
+ * call shape returned ranges that point inside the shadow tree — in which case
12039
+ * there is nothing better to offer than the plain window selection.
12040
+ */ function composedRanges(selection, shadowRoot) {
12041
+ var getComposedRanges = selection.getComposedRanges;
12042
+ if (!(0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_0__.isFunction)(getComposedRanges)) {
12043
+ return null;
12044
+ }
12045
+ for(var _i = 0, _iter = [
12046
+ [
12047
+ {
12048
+ shadowRoots: [
12049
+ shadowRoot
12050
+ ]
12051
+ }
12052
+ ],
12053
+ [
12054
+ shadowRoot
12055
+ ]
12056
+ ]; _i < _iter.length; _i++){
12057
+ var args = _iter[_i];
12058
+ var ranges = void 0;
12059
+ try {
12060
+ ranges = getComposedRanges.apply(selection, args);
12061
+ } catch (unused) {
12062
+ continue;
12063
+ }
12064
+ if (usable(ranges, shadowRoot)) {
12065
+ return ranges;
12066
+ }
12067
+ }
12068
+ return null;
12069
+ }
12070
+
12071
+
11973
12072
  /***/ }),
11974
12073
 
11975
12074
  /***/ 42259:
@@ -11977,14 +12076,16 @@ var Response = /*#__PURE__*/ function() {
11977
12076
 
11978
12077
  "use strict";
11979
12078
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12079
+ /* harmony export */ composedRanges: function() { return /* reexport safe */ _composed_ranges__WEBPACK_IMPORTED_MODULE_2__.composedRanges; },
11980
12080
  /* harmony export */ cursorInTheEdgeOfString: function() { return /* binding */ cursorInTheEdgeOfString; },
11981
12081
  /* harmony export */ findCorrectCurrentNode: function() { return /* binding */ findCorrectCurrentNode; },
11982
- /* harmony export */ moveNodeInsideStart: function() { return /* reexport safe */ _move_node_inside_start__WEBPACK_IMPORTED_MODULE_2__.moveNodeInsideStart; }
12082
+ /* harmony export */ moveNodeInsideStart: function() { return /* reexport safe */ _move_node_inside_start__WEBPACK_IMPORTED_MODULE_3__.moveNodeInsideStart; }
11983
12083
  /* harmony export */ });
11984
12084
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81937);
11985
12085
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23211);
11986
- /* harmony import */ var _move_node_inside_start__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89817);
11987
- /* harmony import */ var _move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7470);
12086
+ /* harmony import */ var _composed_ranges__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(43134);
12087
+ /* harmony import */ var _move_node_inside_start__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(89817);
12088
+ /* harmony import */ var _move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7470);
11988
12089
  /*!
11989
12090
  * Jodit Editor (https://xdsoft.net/jodit/)
11990
12091
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -11995,6 +12096,7 @@ var Response = /*#__PURE__*/ function() {
11995
12096
 
11996
12097
 
11997
12098
 
12099
+
11998
12100
  /**
11999
12101
  * Despite the name, returns `true` when the cursor is NOT at the checked edge
12000
12102
  * of the text node: there is significant (non invisible-space) text between
@@ -12268,12 +12370,100 @@ var Selection = /*#__PURE__*/ function() {
12268
12370
  get: /**
12269
12371
  * Return current selection object
12270
12372
  */ function get() {
12271
- if (this.j.o.shadowRoot && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isFunction)(this.j.o.shadowRoot.getSelection)) {
12272
- return this.j.o.shadowRoot.getSelection();
12373
+ var shadowRoot = this.j.o.shadowRoot;
12374
+ if (shadowRoot) {
12375
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isFunction)(shadowRoot.getSelection)) {
12376
+ return shadowRoot.getSelection();
12377
+ }
12378
+ var composed = this.__composedSelection(shadowRoot);
12379
+ if (composed) {
12380
+ return composed;
12381
+ }
12273
12382
  }
12274
12383
  return this.win.getSelection();
12275
12384
  }
12276
12385
  },
12386
+ {
12387
+ key: "__composedSelection",
12388
+ value: /**
12389
+ * Selection of a shadow tree in a browser without `ShadowRoot.getSelection`.
12390
+ *
12391
+ * `ShadowRoot.getSelection()` is a non-standard method that WebKit never
12392
+ * implemented, and `window.getSelection()` stops at the shadow boundary: for
12393
+ * a caret inside the shadow tree it reports the host, or the document
12394
+ * itself. Everything downstream then works on the wrong tree, which is why
12395
+ * Backspace used to throw `HierarchyRequestError` and Enter did nothing when
12396
+ * the editor lived in a shadow root in Safari.
12397
+ *
12398
+ * The standard replacement is `Selection.getComposedRanges()`, which does
12399
+ * reach into a shadow tree it is given. It hands back `StaticRange`s, and
12400
+ * the editor mutates ranges constantly, so they are turned into live ones.
12401
+ *
12402
+ * Reads are answered from those ranges; everything else, including the
12403
+ * writes (`addRange`, `removeAllRanges`, `setBaseAndExtent`), goes to the
12404
+ * real selection, which does accept nodes inside a shadow tree. Reading is
12405
+ * the only side the browser blocks.
12406
+ *
12407
+ * @returns `null` when the browser offers neither API, so the caller falls
12408
+ * back to the plain window selection.
12409
+ */ function __composedSelection(shadowRoot) {
12410
+ var _this = this;
12411
+ var selection = this.win.getSelection();
12412
+ if (!selection) {
12413
+ return null;
12414
+ }
12415
+ // Firefox has no `ShadowRoot.getSelection` either, but its window
12416
+ // selection does see into a shadow tree. Where the plain selection
12417
+ // already points at the right node there is nothing to work around, and
12418
+ // taking it over would change behaviour that works today.
12419
+ var anchorNode = selection.anchorNode;
12420
+ if (anchorNode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isOrContains(shadowRoot, anchorNode)) {
12421
+ return null;
12422
+ }
12423
+ var ranges = (0,_helpers__WEBPACK_IMPORTED_MODULE_17__.composedRanges)(selection, shadowRoot);
12424
+ if (!ranges) {
12425
+ return null;
12426
+ }
12427
+ var live = ranges.map(function(staticRange) {
12428
+ var range = _this.createRange();
12429
+ range.setStart(staticRange.startContainer, staticRange.startOffset);
12430
+ range.setEnd(staticRange.endContainer, staticRange.endOffset);
12431
+ return range;
12432
+ });
12433
+ var first = live[0];
12434
+ var overrides = {
12435
+ rangeCount: live.length,
12436
+ getRangeAt: function getRangeAt(index) {
12437
+ return live[index];
12438
+ },
12439
+ isCollapsed: live.every(function(range) {
12440
+ return range.collapsed;
12441
+ }),
12442
+ // Without these the editor asks the window selection where the
12443
+ // caret is, is told "outside the editable area", and resets the
12444
+ // caret to the start of it — which is the focus loss that shows up
12445
+ // right after a successful Backspace.
12446
+ anchorNode: first ? first.startContainer : null,
12447
+ anchorOffset: first ? first.startOffset : 0,
12448
+ focusNode: first ? first.endContainer : null,
12449
+ focusOffset: first ? first.endOffset : 0,
12450
+ toString: function toString() {
12451
+ return live.map(function(range) {
12452
+ return range.toString();
12453
+ }).join('');
12454
+ }
12455
+ };
12456
+ return new Proxy(selection, {
12457
+ get: function get(target, property) {
12458
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isString)(property) && property in overrides) {
12459
+ return overrides[property];
12460
+ }
12461
+ var value = Reflect.get(target, property, target);
12462
+ return (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isFunction)(value) ? value.bind(target) : value;
12463
+ }
12464
+ });
12465
+ }
12466
+ },
12277
12467
  {
12278
12468
  key: "range",
12279
12469
  get: /**
@@ -21749,6 +21939,11 @@ var Jodit = /*#__PURE__*/ function(ViewWithToolbar) {
21749
21939
  }
21750
21940
  if (this.editor) {
21751
21941
  this.editor.innerHTML = data.value;
21942
+ // Fired synchronously, before any task can run: the value was
21943
+ // sanitized in an inert document and re-parsed here with scripting
21944
+ // on, and the two parsers do not always agree. Listeners get to
21945
+ // look at the tree that actually exists.
21946
+ this.e.fire('afterSetNativeEditorValue');
21752
21947
  }
21753
21948
  }
21754
21949
  },
@@ -34449,6 +34644,18 @@ var cleanHtml = /*#__PURE__*/ function(Plugin) {
34449
34644
  }
34450
34645
  }
34451
34646
  },
34647
+ {
34648
+ key: "onAfterSetNativeEditorValue",
34649
+ value: /**
34650
+ * The value was sanitized in an inert document and has just been re-parsed
34651
+ * into the live editor with scripting on. Where the two parsers disagree
34652
+ * (`<noscript>`, raw-text elements), markup that was inert text a moment
34653
+ * ago is a real element now, so the live tree is sanitized once more, in
34654
+ * the same call stack, before any handler it might carry can fire.
34655
+ */ function onAfterSetNativeEditorValue() {
34656
+ ;(0,jodit_core_helpers_html_safe_html__WEBPACK_IMPORTED_MODULE_13__.safeHTML)(this.j.editor, this.j.o.cleanHTML);
34657
+ }
34658
+ },
34452
34659
  {
34453
34660
  key: "onBeforeSetNativeEditorValue",
34454
34661
  value: /**
@@ -34586,6 +34793,9 @@ var cleanHtml = /*#__PURE__*/ function(Plugin) {
34586
34793
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_7__.__decorate)([
34587
34794
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':beforeCommand')
34588
34795
  ], cleanHtml.prototype, "beforeCommand", null);
34796
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_7__.__decorate)([
34797
+ (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':afterSetNativeEditorValue')
34798
+ ], cleanHtml.prototype, "onAfterSetNativeEditorValue", null);
34589
34799
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_7__.__decorate)([
34590
34800
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_9__.watch)(':beforeSetNativeEditorValue')
34591
34801
  ], cleanHtml.prototype, "onBeforeSetNativeEditorValue", null);
package/es5/jodit.min.css CHANGED
@@ -1,14 +1,14 @@
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.17.1
4
+ * Version: v4.17.3
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
8
8
  /*!
9
9
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
10
10
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
11
- * Version: v4.17.1
11
+ * Version: v4.17.3
12
12
  * Url: https://xdsoft.net/jodit/
13
13
  * License(s): MIT
14
14
  */