jodit 4.17.0 → 4.17.2

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 (64) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +3 -3
  4. package/es2015/jodit.js +171 -12
  5. package/es2015/jodit.min.js +3 -3
  6. package/es2015/plugins/debug/debug.css +1 -1
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.fat.min.js +3 -3
  13. package/es2018/jodit.min.js +3 -3
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +5 -5
  18. package/es2021/jodit.js +171 -12
  19. package/es2021/jodit.min.js +5 -5
  20. package/es2021/plugins/debug/debug.css +1 -1
  21. package/es2021/plugins/debug/debug.js +1 -1
  22. package/es2021/plugins/debug/debug.min.js +1 -1
  23. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +24 -24
  28. package/es2021.en/jodit.js +171 -12
  29. package/es2021.en/jodit.min.js +5 -5
  30. package/es2021.en/plugins/debug/debug.css +1 -1
  31. package/es2021.en/plugins/debug/debug.js +1 -1
  32. package/es2021.en/plugins/debug/debug.min.js +1 -1
  33. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +186 -12
  39. package/es5/jodit.min.css +2 -2
  40. package/es5/jodit.min.js +2 -2
  41. package/es5/plugins/debug/debug.css +1 -1
  42. package/es5/plugins/debug/debug.js +1 -1
  43. package/es5/plugins/debug/debug.min.js +1 -1
  44. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  47. package/es5/polyfills.fat.min.js +1 -1
  48. package/es5/polyfills.js +1 -1
  49. package/es5/polyfills.min.js +1 -1
  50. package/esm/core/constants.js +1 -1
  51. package/esm/core/helpers/html/safe-html.d.ts +1 -1
  52. package/esm/core/helpers/html/safe-html.js +8 -1
  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/plugins/drag-and-drop/drag-and-drop.js +16 -4
  60. package/package.json +1 -1
  61. package/types/core/helpers/html/safe-html.d.ts +1 -1
  62. package/types/core/selection/helpers/composed-ranges.d.ts +21 -0
  63. package/types/core/selection/helpers/index.d.ts +1 -0
  64. package/types/core/selection/selection.d.ts +23 -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.0
4
+ * Version: v4.17.2
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.0";
2132
+ var APP_VERSION = "4.17.2";
2133
2133
  // prettier-ignore
2134
2134
  var ES = "es5";
2135
2135
  var IS_ES_MODERN = false;
@@ -7266,11 +7266,18 @@ function sanitizeHTMLElement(elm) {
7266
7266
  var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
7267
7267
  safeJavaScriptLink: true,
7268
7268
  removeOnError: true
7269
- }, safeJavaScriptLink = _ref.safeJavaScriptLink, removeOnError = _ref.removeOnError;
7269
+ }, safeJavaScriptLink = _ref.safeJavaScriptLink, removeOnError = _ref.removeOnError, removeEventAttributes = _ref.removeEventAttributes;
7270
7270
  if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isElement(elm)) {
7271
7271
  return false;
7272
7272
  }
7273
7273
  var effected = false;
7274
+ // Every `on*` handler, not only `onerror`: the clean-html background
7275
+ // pass calls this directly, and markup that reached the editable area
7276
+ // without `safeHTML` (a drop, a script) kept its handlers otherwise.
7277
+ // See GHSA-jhhp-r3r7-v2cg
7278
+ if (removeEventAttributes && removeAllEventAttributes(elm)) {
7279
+ effected = true;
7280
+ }
7274
7281
  if (removeOnError && elm.hasAttribute('onerror')) {
7275
7282
  (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_1__.attr)(elm, 'onerror', null);
7276
7283
  effected = true;
@@ -11963,6 +11970,73 @@ var Response = /*#__PURE__*/ function() {
11963
11970
  }();
11964
11971
 
11965
11972
 
11973
+ /***/ }),
11974
+
11975
+ /***/ 43134:
11976
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
11977
+
11978
+ "use strict";
11979
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11980
+ /* harmony export */ composedRanges: function() { return /* binding */ composedRanges; }
11981
+ /* harmony export */ });
11982
+ /* harmony import */ var jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28686);
11983
+ /*!
11984
+ * Jodit Editor (https://xdsoft.net/jodit/)
11985
+ * Released under MIT see LICENSE.txt in the project root for license information.
11986
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
11987
+ */ /**
11988
+ * @module selection
11989
+ */
11990
+ function isInside(node, shadowRoot) {
11991
+ return node === shadowRoot || shadowRoot.contains(node);
11992
+ }
11993
+ function usable(ranges, shadowRoot) {
11994
+ return Array.isArray(ranges) && ranges.length > 0 && ranges.every(function(range) {
11995
+ return isInside(range.startContainer, shadowRoot);
11996
+ });
11997
+ }
11998
+ /**
11999
+ * Ranges of a selection that lies inside the given shadow tree.
12000
+ *
12001
+ * `window.getSelection()` stops at the shadow boundary and reports the host
12002
+ * instead of the node the caret is really in. `getComposedRanges` is the
12003
+ * standard way to ask past that boundary.
12004
+ *
12005
+ * @returns `null` when the browser has no `getComposedRanges`, or when neither
12006
+ * call shape returned ranges that point inside the shadow tree — in which case
12007
+ * there is nothing better to offer than the plain window selection.
12008
+ */ function composedRanges(selection, shadowRoot) {
12009
+ var getComposedRanges = selection.getComposedRanges;
12010
+ if (!(0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_0__.isFunction)(getComposedRanges)) {
12011
+ return null;
12012
+ }
12013
+ for(var _i = 0, _iter = [
12014
+ [
12015
+ {
12016
+ shadowRoots: [
12017
+ shadowRoot
12018
+ ]
12019
+ }
12020
+ ],
12021
+ [
12022
+ shadowRoot
12023
+ ]
12024
+ ]; _i < _iter.length; _i++){
12025
+ var args = _iter[_i];
12026
+ var ranges = void 0;
12027
+ try {
12028
+ ranges = getComposedRanges.apply(selection, args);
12029
+ } catch (unused) {
12030
+ continue;
12031
+ }
12032
+ if (usable(ranges, shadowRoot)) {
12033
+ return ranges;
12034
+ }
12035
+ }
12036
+ return null;
12037
+ }
12038
+
12039
+
11966
12040
  /***/ }),
11967
12041
 
11968
12042
  /***/ 42259:
@@ -11970,14 +12044,16 @@ var Response = /*#__PURE__*/ function() {
11970
12044
 
11971
12045
  "use strict";
11972
12046
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12047
+ /* harmony export */ composedRanges: function() { return /* reexport safe */ _composed_ranges__WEBPACK_IMPORTED_MODULE_2__.composedRanges; },
11973
12048
  /* harmony export */ cursorInTheEdgeOfString: function() { return /* binding */ cursorInTheEdgeOfString; },
11974
12049
  /* harmony export */ findCorrectCurrentNode: function() { return /* binding */ findCorrectCurrentNode; },
11975
- /* harmony export */ moveNodeInsideStart: function() { return /* reexport safe */ _move_node_inside_start__WEBPACK_IMPORTED_MODULE_2__.moveNodeInsideStart; }
12050
+ /* harmony export */ moveNodeInsideStart: function() { return /* reexport safe */ _move_node_inside_start__WEBPACK_IMPORTED_MODULE_3__.moveNodeInsideStart; }
11976
12051
  /* harmony export */ });
11977
12052
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81937);
11978
12053
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23211);
11979
- /* harmony import */ var _move_node_inside_start__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89817);
11980
- /* harmony import */ var _move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7470);
12054
+ /* harmony import */ var _composed_ranges__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(43134);
12055
+ /* harmony import */ var _move_node_inside_start__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(89817);
12056
+ /* harmony import */ var _move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7470);
11981
12057
  /*!
11982
12058
  * Jodit Editor (https://xdsoft.net/jodit/)
11983
12059
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -11988,6 +12064,7 @@ var Response = /*#__PURE__*/ function() {
11988
12064
 
11989
12065
 
11990
12066
 
12067
+
11991
12068
  /**
11992
12069
  * Despite the name, returns `true` when the cursor is NOT at the checked edge
11993
12070
  * of the text node: there is significant (non invisible-space) text between
@@ -12261,12 +12338,100 @@ var Selection = /*#__PURE__*/ function() {
12261
12338
  get: /**
12262
12339
  * Return current selection object
12263
12340
  */ function get() {
12264
- if (this.j.o.shadowRoot && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isFunction)(this.j.o.shadowRoot.getSelection)) {
12265
- return this.j.o.shadowRoot.getSelection();
12341
+ var shadowRoot = this.j.o.shadowRoot;
12342
+ if (shadowRoot) {
12343
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isFunction)(shadowRoot.getSelection)) {
12344
+ return shadowRoot.getSelection();
12345
+ }
12346
+ var composed = this.__composedSelection(shadowRoot);
12347
+ if (composed) {
12348
+ return composed;
12349
+ }
12266
12350
  }
12267
12351
  return this.win.getSelection();
12268
12352
  }
12269
12353
  },
12354
+ {
12355
+ key: "__composedSelection",
12356
+ value: /**
12357
+ * Selection of a shadow tree in a browser without `ShadowRoot.getSelection`.
12358
+ *
12359
+ * `ShadowRoot.getSelection()` is a non-standard method that WebKit never
12360
+ * implemented, and `window.getSelection()` stops at the shadow boundary: for
12361
+ * a caret inside the shadow tree it reports the host, or the document
12362
+ * itself. Everything downstream then works on the wrong tree, which is why
12363
+ * Backspace used to throw `HierarchyRequestError` and Enter did nothing when
12364
+ * the editor lived in a shadow root in Safari.
12365
+ *
12366
+ * The standard replacement is `Selection.getComposedRanges()`, which does
12367
+ * reach into a shadow tree it is given. It hands back `StaticRange`s, and
12368
+ * the editor mutates ranges constantly, so they are turned into live ones.
12369
+ *
12370
+ * Reads are answered from those ranges; everything else, including the
12371
+ * writes (`addRange`, `removeAllRanges`, `setBaseAndExtent`), goes to the
12372
+ * real selection, which does accept nodes inside a shadow tree. Reading is
12373
+ * the only side the browser blocks.
12374
+ *
12375
+ * @returns `null` when the browser offers neither API, so the caller falls
12376
+ * back to the plain window selection.
12377
+ */ function __composedSelection(shadowRoot) {
12378
+ var _this = this;
12379
+ var selection = this.win.getSelection();
12380
+ if (!selection) {
12381
+ return null;
12382
+ }
12383
+ // Firefox has no `ShadowRoot.getSelection` either, but its window
12384
+ // selection does see into a shadow tree. Where the plain selection
12385
+ // already points at the right node there is nothing to work around, and
12386
+ // taking it over would change behaviour that works today.
12387
+ var anchorNode = selection.anchorNode;
12388
+ if (anchorNode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_10__.Dom.isOrContains(shadowRoot, anchorNode)) {
12389
+ return null;
12390
+ }
12391
+ var ranges = (0,_helpers__WEBPACK_IMPORTED_MODULE_17__.composedRanges)(selection, shadowRoot);
12392
+ if (!ranges) {
12393
+ return null;
12394
+ }
12395
+ var live = ranges.map(function(staticRange) {
12396
+ var range = _this.createRange();
12397
+ range.setStart(staticRange.startContainer, staticRange.startOffset);
12398
+ range.setEnd(staticRange.endContainer, staticRange.endOffset);
12399
+ return range;
12400
+ });
12401
+ var first = live[0];
12402
+ var overrides = {
12403
+ rangeCount: live.length,
12404
+ getRangeAt: function getRangeAt(index) {
12405
+ return live[index];
12406
+ },
12407
+ isCollapsed: live.every(function(range) {
12408
+ return range.collapsed;
12409
+ }),
12410
+ // Without these the editor asks the window selection where the
12411
+ // caret is, is told "outside the editable area", and resets the
12412
+ // caret to the start of it — which is the focus loss that shows up
12413
+ // right after a successful Backspace.
12414
+ anchorNode: first ? first.startContainer : null,
12415
+ anchorOffset: first ? first.startOffset : 0,
12416
+ focusNode: first ? first.endContainer : null,
12417
+ focusOffset: first ? first.endOffset : 0,
12418
+ toString: function toString() {
12419
+ return live.map(function(range) {
12420
+ return range.toString();
12421
+ }).join('');
12422
+ }
12423
+ };
12424
+ return new Proxy(selection, {
12425
+ get: function get(target, property) {
12426
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isString)(property) && property in overrides) {
12427
+ return overrides[property];
12428
+ }
12429
+ var value = Reflect.get(target, property, target);
12430
+ return (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_12__.isFunction)(value) ? value.bind(target) : value;
12431
+ }
12432
+ });
12433
+ }
12434
+ },
12270
12435
  {
12271
12436
  key: "range",
12272
12437
  get: /**
@@ -37124,7 +37289,11 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_9__.pluginSystem.add('dragAndDropElem
37124
37289
  window,
37125
37290
  this.j.ed,
37126
37291
  this.j.editor
37127
- ], 'dragstart.DragAndDrop', this.onDragStart);
37292
+ ], 'dragstart.DragAndDrop', this.onDragStart)// Always, not only after a `dragstart` seen in this window: a drop
37293
+ // from another window or application never produces one here, and
37294
+ // the browser then inserted its HTML natively, unsanitized. Routed
37295
+ // through the paste plugin instead. See GHSA-jhhp-r3r7-v2cg
37296
+ .on('drop.DragAndDrop', this.onDrop);
37128
37297
  }
37129
37298
  },
37130
37299
  {
@@ -37160,13 +37329,13 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_9__.pluginSystem.add('dragAndDropElem
37160
37329
  {
37161
37330
  key: "addDragListeners",
37162
37331
  value: function addDragListeners() {
37163
- this.j.e.on('dragover', this.onDrag).on('drop.DragAndDrop', this.onDrop).on(window, 'dragend.DragAndDrop drop.DragAndDrop mouseup.DragAndDrop', this.onDragEnd);
37332
+ this.j.e.on('dragover', this.onDrag).on(window, 'dragend.DragAndDrop drop.DragAndDrop mouseup.DragAndDrop', this.onDragEnd);
37164
37333
  }
37165
37334
  },
37166
37335
  {
37167
37336
  key: "removeDragListeners",
37168
37337
  value: function removeDragListeners() {
37169
- this.j.e.off('dragover', this.onDrag).off('drop.DragAndDrop', this.onDrop).off(window, 'dragend.DragAndDrop drop.DragAndDrop mouseup.DragAndDrop', this.onDragEnd);
37338
+ this.j.e.off('dragover', this.onDrag).off(window, 'dragend.DragAndDrop drop.DragAndDrop mouseup.DragAndDrop', this.onDragEnd);
37170
37339
  }
37171
37340
  },
37172
37341
  {
@@ -37240,7 +37409,12 @@ jodit_core_global__WEBPACK_IMPORTED_MODULE_9__.pluginSystem.add('dragAndDropElem
37240
37409
  fragment = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_12__.dataBind)(this.draggable, 'target');
37241
37410
  }
37242
37411
  } else if (this.getText(event)) {
37243
- fragment = this.j.createInside.fromHTML(this.getText(event));
37412
+ // Dropped markup takes the same sanitizing pass as pasted and
37413
+ // assigned content. See GHSA-jhhp-r3r7-v2cg
37414
+ var box = this.j.createInside.div();
37415
+ box.innerHTML = this.getText(event);
37416
+ this.j.e.fire('safeHTML', box);
37417
+ fragment = box.firstChild !== box.lastChild || !box.firstChild ? box : box.firstChild;
37244
37418
  }
37245
37419
  return fragment;
37246
37420
  }
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.0
4
+ * Version: v4.17.2
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.0
11
+ * Version: v4.17.2
12
12
  * Url: https://xdsoft.net/jodit/
13
13
  * License(s): MIT
14
14
  */