jodit 4.17.1 → 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 (60) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +2 -2
  4. package/es2015/jodit.js +150 -7
  5. package/es2015/jodit.min.js +2 -2
  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 +2 -2
  13. package/es2018/jodit.min.js +2 -2
  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 +3 -3
  18. package/es2021/jodit.js +150 -7
  19. package/es2021/jodit.min.js +3 -3
  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 +150 -7
  29. package/es2021.en/jodit.min.js +3 -3
  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 +165 -7
  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/selection/helpers/composed-ranges.d.ts +21 -0
  52. package/esm/core/selection/helpers/composed-ranges.js +45 -0
  53. package/esm/core/selection/helpers/index.d.ts +1 -0
  54. package/esm/core/selection/helpers/index.js +1 -0
  55. package/esm/core/selection/selection.d.ts +23 -0
  56. package/esm/core/selection/selection.js +80 -4
  57. package/package.json +1 -1
  58. package/types/core/selection/helpers/composed-ranges.d.ts +21 -0
  59. package/types/core/selection/helpers/index.d.ts +1 -0
  60. package/types/core/selection/selection.d.ts +23 -0
@@ -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.2
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1799,7 +1799,7 @@ __webpack_require__.r(__webpack_exports__);
1799
1799
  * ```
1800
1800
  * @packageDocumentation
1801
1801
  * @module constants
1802
- */ const APP_VERSION = "4.17.1";
1802
+ */ const APP_VERSION = "4.17.2";
1803
1803
  // prettier-ignore
1804
1804
  const ES = "es2021";
1805
1805
  const IS_ES_MODERN = true;
@@ -10541,6 +10541,70 @@ class Response {
10541
10541
  }
10542
10542
 
10543
10543
 
10544
+ /***/ }),
10545
+
10546
+ /***/ 43134:
10547
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10548
+
10549
+ "use strict";
10550
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10551
+ /* harmony export */ composedRanges: function() { return /* binding */ composedRanges; }
10552
+ /* harmony export */ });
10553
+ /* harmony import */ var jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28686);
10554
+ /*!
10555
+ * Jodit Editor (https://xdsoft.net/jodit/)
10556
+ * Released under MIT see LICENSE.txt in the project root for license information.
10557
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
10558
+ */ /**
10559
+ * @module selection
10560
+ */
10561
+ function isInside(node, shadowRoot) {
10562
+ return node === shadowRoot || shadowRoot.contains(node);
10563
+ }
10564
+ function usable(ranges, shadowRoot) {
10565
+ return Array.isArray(ranges) && ranges.length > 0 && ranges.every((range)=>isInside(range.startContainer, shadowRoot));
10566
+ }
10567
+ /**
10568
+ * Ranges of a selection that lies inside the given shadow tree.
10569
+ *
10570
+ * `window.getSelection()` stops at the shadow boundary and reports the host
10571
+ * instead of the node the caret is really in. `getComposedRanges` is the
10572
+ * standard way to ask past that boundary.
10573
+ *
10574
+ * @returns `null` when the browser has no `getComposedRanges`, or when neither
10575
+ * call shape returned ranges that point inside the shadow tree — in which case
10576
+ * there is nothing better to offer than the plain window selection.
10577
+ */ function composedRanges(selection, shadowRoot) {
10578
+ const getComposedRanges = selection.getComposedRanges;
10579
+ if (!(0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_0__.isFunction)(getComposedRanges)) {
10580
+ return null;
10581
+ }
10582
+ for (const args of [
10583
+ [
10584
+ {
10585
+ shadowRoots: [
10586
+ shadowRoot
10587
+ ]
10588
+ }
10589
+ ],
10590
+ [
10591
+ shadowRoot
10592
+ ]
10593
+ ]){
10594
+ let ranges;
10595
+ try {
10596
+ ranges = getComposedRanges.apply(selection, args);
10597
+ } catch {
10598
+ continue;
10599
+ }
10600
+ if (usable(ranges, shadowRoot)) {
10601
+ return ranges;
10602
+ }
10603
+ }
10604
+ return null;
10605
+ }
10606
+
10607
+
10544
10608
  /***/ }),
10545
10609
 
10546
10610
  /***/ 42259:
@@ -10548,14 +10612,16 @@ class Response {
10548
10612
 
10549
10613
  "use strict";
10550
10614
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10615
+ /* harmony export */ composedRanges: function() { return /* reexport safe */ _composed_ranges__WEBPACK_IMPORTED_MODULE_2__.composedRanges; },
10551
10616
  /* harmony export */ cursorInTheEdgeOfString: function() { return /* binding */ cursorInTheEdgeOfString; },
10552
10617
  /* harmony export */ findCorrectCurrentNode: function() { return /* binding */ findCorrectCurrentNode; },
10553
- /* harmony export */ moveNodeInsideStart: function() { return /* reexport safe */ _move_node_inside_start__WEBPACK_IMPORTED_MODULE_2__.moveNodeInsideStart; }
10618
+ /* harmony export */ moveNodeInsideStart: function() { return /* reexport safe */ _move_node_inside_start__WEBPACK_IMPORTED_MODULE_3__.moveNodeInsideStart; }
10554
10619
  /* harmony export */ });
10555
10620
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81937);
10556
10621
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23211);
10557
- /* harmony import */ var _move_node_inside_start__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89817);
10558
- /* harmony import */ var _move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7470);
10622
+ /* harmony import */ var _composed_ranges__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(43134);
10623
+ /* harmony import */ var _move_node_inside_start__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(89817);
10624
+ /* harmony import */ var _move_the_node_along_the_edge_outward__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7470);
10559
10625
  /*!
10560
10626
  * Jodit Editor (https://xdsoft.net/jodit/)
10561
10627
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -10566,6 +10632,7 @@ class Response {
10566
10632
 
10567
10633
 
10568
10634
 
10635
+
10569
10636
  /**
10570
10637
  * Despite the name, returns `true` when the cursor is NOT at the checked edge
10571
10638
  * of the text node: there is significant (non invisible-space) text between
@@ -10794,11 +10861,87 @@ class Selection {
10794
10861
  /**
10795
10862
  * Return current selection object
10796
10863
  */ get sel() {
10797
- if (this.j.o.shadowRoot && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(this.j.o.shadowRoot.getSelection)) {
10798
- return this.j.o.shadowRoot.getSelection();
10864
+ const { shadowRoot } = this.j.o;
10865
+ if (shadowRoot) {
10866
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(shadowRoot.getSelection)) {
10867
+ return shadowRoot.getSelection();
10868
+ }
10869
+ const composed = this.__composedSelection(shadowRoot);
10870
+ if (composed) {
10871
+ return composed;
10872
+ }
10799
10873
  }
10800
10874
  return this.win.getSelection();
10801
10875
  }
10876
+ /**
10877
+ * Selection of a shadow tree in a browser without `ShadowRoot.getSelection`.
10878
+ *
10879
+ * `ShadowRoot.getSelection()` is a non-standard method that WebKit never
10880
+ * implemented, and `window.getSelection()` stops at the shadow boundary: for
10881
+ * a caret inside the shadow tree it reports the host, or the document
10882
+ * itself. Everything downstream then works on the wrong tree, which is why
10883
+ * Backspace used to throw `HierarchyRequestError` and Enter did nothing when
10884
+ * the editor lived in a shadow root in Safari.
10885
+ *
10886
+ * The standard replacement is `Selection.getComposedRanges()`, which does
10887
+ * reach into a shadow tree it is given. It hands back `StaticRange`s, and
10888
+ * the editor mutates ranges constantly, so they are turned into live ones.
10889
+ *
10890
+ * Reads are answered from those ranges; everything else, including the
10891
+ * writes (`addRange`, `removeAllRanges`, `setBaseAndExtent`), goes to the
10892
+ * real selection, which does accept nodes inside a shadow tree. Reading is
10893
+ * the only side the browser blocks.
10894
+ *
10895
+ * @returns `null` when the browser offers neither API, so the caller falls
10896
+ * back to the plain window selection.
10897
+ */ __composedSelection(shadowRoot) {
10898
+ const selection = this.win.getSelection();
10899
+ if (!selection) {
10900
+ return null;
10901
+ }
10902
+ // Firefox has no `ShadowRoot.getSelection` either, but its window
10903
+ // selection does see into a shadow tree. Where the plain selection
10904
+ // already points at the right node there is nothing to work around, and
10905
+ // taking it over would change behaviour that works today.
10906
+ const { anchorNode } = selection;
10907
+ if (anchorNode && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isOrContains(shadowRoot, anchorNode)) {
10908
+ return null;
10909
+ }
10910
+ const ranges = (0,_helpers__WEBPACK_IMPORTED_MODULE_11__.composedRanges)(selection, shadowRoot);
10911
+ if (!ranges) {
10912
+ return null;
10913
+ }
10914
+ const live = ranges.map((staticRange)=>{
10915
+ const range = this.createRange();
10916
+ range.setStart(staticRange.startContainer, staticRange.startOffset);
10917
+ range.setEnd(staticRange.endContainer, staticRange.endOffset);
10918
+ return range;
10919
+ });
10920
+ const first = live[0];
10921
+ const overrides = {
10922
+ rangeCount: live.length,
10923
+ getRangeAt: (index)=>live[index],
10924
+ isCollapsed: live.every((range)=>range.collapsed),
10925
+ // Without these the editor asks the window selection where the
10926
+ // caret is, is told "outside the editable area", and resets the
10927
+ // caret to the start of it — which is the focus loss that shows up
10928
+ // right after a successful Backspace.
10929
+ anchorNode: first ? first.startContainer : null,
10930
+ anchorOffset: first ? first.startOffset : 0,
10931
+ focusNode: first ? first.endContainer : null,
10932
+ focusOffset: first ? first.endOffset : 0,
10933
+ toString: ()=>live.map((range)=>range.toString()).join('')
10934
+ };
10935
+ return new Proxy(selection, {
10936
+ get (target, property) {
10937
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isString)(property) && property in overrides) {
10938
+ return overrides[property];
10939
+ }
10940
+ const value = Reflect.get(target, property, target);
10941
+ return (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(value) ? value.bind(target) : value;
10942
+ }
10943
+ });
10944
+ }
10802
10945
  /**
10803
10946
  * Return first selected range or create new
10804
10947
  */ get range() {