jodit 4.17.3 → 4.17.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 (66) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +4 -4
  4. package/es2015/jodit.js +73 -9
  5. package/es2015/jodit.min.js +10 -10
  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 +4 -4
  13. package/es2018/jodit.min.js +4 -4
  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 +69 -9
  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 +5 -5
  28. package/es2021.en/jodit.js +69 -9
  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 +79 -9
  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/selection.d.ts +5 -0
  52. package/esm/core/selection/selection.js +25 -0
  53. package/esm/modules/file-browser/data-provider.d.ts +1 -0
  54. package/esm/modules/file-browser/data-provider.js +26 -5
  55. package/esm/plugins/select/select.d.ts +7 -0
  56. package/esm/plugins/select/select.js +19 -1
  57. package/package.json +1 -1
  58. package/types/core/selection/selection.d.ts +5 -0
  59. package/types/modules/file-browser/data-provider.d.ts +1 -0
  60. package/types/plugins/select/select.d.ts +7 -0
  61. package/.nvmrc +0 -1
  62. package/examples/build/es2015/jodit.min.css +0 -1
  63. package/examples/build/es2015/jodit.min.js +0 -10
  64. package/examples/build/es2015/plugins/debug/debug.min.js +0 -10
  65. package/examples/build/es2015/plugins/speech-recognize/speech-recognize.min.css +0 -1
  66. package/examples/build/es2015/plugins/speech-recognize/speech-recognize.min.js +0 -10
package/es2021/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.3
4
+ * Version: v4.17.5
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.3";
1802
+ */ const APP_VERSION = "4.17.5";
1803
1803
  // prettier-ignore
1804
1804
  const ES = "es2021";
1805
1805
  const IS_ES_MODERN = true;
@@ -10957,6 +10957,16 @@ class Selection {
10957
10957
  }
10958
10958
  });
10959
10959
  }
10960
+ /**
10961
+ * How many ranges the browser's own selection holds right now, as opposed
10962
+ * to the composed view that [[sel]] may answer from.
10963
+ */ __nativeRangeCount() {
10964
+ const { shadowRoot } = this.j.o;
10965
+ if (shadowRoot && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(shadowRoot.getSelection)) {
10966
+ return shadowRoot.getSelection()?.rangeCount ?? 0;
10967
+ }
10968
+ return this.win.getSelection()?.rangeCount ?? 0;
10969
+ }
10960
10970
  /**
10961
10971
  * Return first selected range or create new
10962
10972
  */ get range() {
@@ -11751,6 +11761,16 @@ class Selection {
11751
11761
  if (backward && ranges.length === 1) {
11752
11762
  const range = ranges[0];
11753
11763
  sel.setBaseAndExtent(range.endContainer, range.endOffset, range.startContainer, range.startOffset);
11764
+ } else if (ranges.length === 1 && !this.__nativeRangeCount() && (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_6__.isFunction)(sel.setBaseAndExtent)) {
11765
+ // `addRange` is specified to ignore a range whose root is not
11766
+ // the document, which is every range inside a shadow tree.
11767
+ // Chrome's `ShadowRoot.getSelection()` takes them anyway, but
11768
+ // Safari has only the window selection, so after
11769
+ // `removeAllRanges` the caret is simply gone: a character was
11770
+ // deleted and nothing was left to type into. `setBaseAndExtent`
11771
+ // does accept nodes inside a shadow tree.
11772
+ const range = ranges[0];
11773
+ sel.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
11754
11774
  }
11755
11775
  }
11756
11776
  /**
@@ -20788,6 +20808,16 @@ const DOCS_URL = 'https://xdsoft.net/jodit/docs/modules/file_browser.html';
20788
20808
  });
20789
20809
  return resp;
20790
20810
  }
20811
+ /**
20812
+ * Actions that only read from the connector. A newer request for one of them
20813
+ * makes the older one pointless, so it is aborted; every other action changes
20814
+ * server state and must be allowed to finish.
20815
+ */ const REPLACEABLE_ACTIONS = new Set([
20816
+ 'items',
20817
+ 'folder',
20818
+ 'permissions',
20819
+ 'getLocalFileByUrl'
20820
+ ]);
20791
20821
  class DataProvider {
20792
20822
  /**
20793
20823
  * Alias for options
@@ -20796,10 +20826,19 @@ class DataProvider {
20796
20826
  }
20797
20827
  get(name) {
20798
20828
  const instances = this.__ajaxInstances;
20799
- if (instances.has(name)) {
20800
- const ajax = instances.get(name);
20829
+ // A listing asked for again supersedes the one still loading, so the
20830
+ // earlier request is aborted. That must never happen to a request
20831
+ // that changes something on the server: aborting it does not undo it,
20832
+ // the caller just never hears the result. Removing several files at
20833
+ // once used to send one `fileRemove` per file and abort all but the
20834
+ // last, so only the last one was ever removed. Mutating requests get a
20835
+ // key of their own and run side by side.
20836
+ const replaceable = REPLACEABLE_ACTIONS.has(name);
20837
+ const key = replaceable ? name : `${name}#${++this.__requestSerial}`;
20838
+ if (replaceable && instances.has(key)) {
20839
+ const ajax = instances.get(key);
20801
20840
  ajax?.abort();
20802
- instances.delete(name);
20841
+ instances.delete(key);
20803
20842
  }
20804
20843
  const opts = (0,jodit_core_helpers_utils_config_proto__WEBPACK_IMPORTED_MODULE_8__.ConfigProto)(this.options[name] !== undefined ? this.options[name] : {}, (0,jodit_core_helpers_utils_config_proto__WEBPACK_IMPORTED_MODULE_8__.ConfigProto)({
20805
20844
  onProgress: this.progressHandler
@@ -20808,11 +20847,11 @@ class DataProvider {
20808
20847
  opts.data = opts.prepareData.call(this, opts.data);
20809
20848
  }
20810
20849
  const ajax = new jodit_core_request_ajax__WEBPACK_IMPORTED_MODULE_11__.Ajax(opts);
20811
- instances.set(name, ajax);
20850
+ instances.set(key, ajax);
20812
20851
  const promise = ajax.send();
20813
20852
  promise.finally(()=>{
20814
20853
  ajax.destruct();
20815
- instances.delete(name);
20854
+ instances.delete(key);
20816
20855
  this.progressHandler(100);
20817
20856
  }).catch(()=>null);
20818
20857
  return promise.then((resp)=>resp.json()).then((resp)=>{
@@ -21117,11 +21156,13 @@ class DataProvider {
21117
21156
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "options", void 0);
21118
21157
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__currentPermissions", void 0);
21119
21158
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__ajaxInstances", void 0);
21159
+ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__requestSerial", void 0);
21120
21160
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "progressHandler", void 0);
21121
21161
  this.parent = parent;
21122
21162
  this.options = options;
21123
21163
  this.__currentPermissions = null;
21124
21164
  this.__ajaxInstances = new Map();
21165
+ this.__requestSerial = 0;
21125
21166
  this.progressHandler = (ignore)=>{};
21126
21167
  }
21127
21168
  }
@@ -41755,13 +41796,22 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.select = {
41755
41796
  j.e.fire(e.type + 'Editor', target, e);
41756
41797
  }
41757
41798
  }
41799
+ onOutsidePress(e) {
41800
+ this.__pressTarget = e.target;
41801
+ }
41758
41802
  /**
41759
41803
  * @event outsideClick(e) - when user clicked on the outside of editor
41760
41804
  */ onOutsideClick(e) {
41761
- const node = e.target;
41805
+ const node = e.target, pressed = this.__pressTarget;
41806
+ this.__pressTarget = null;
41762
41807
  if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.up(node, (elm)=>elm === this.j.editor)) {
41763
41808
  return;
41764
41809
  }
41810
+ // Selecting the text of a popup input with the mouse and releasing
41811
+ // the button past the popup's edge is not a click outside of it.
41812
+ if (pressed && jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.UIElement.closestElement(pressed, jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.Popup)) {
41813
+ return;
41814
+ }
41765
41815
  const box = jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.UIElement.closestElement(node, jodit_core_ui__WEBPACK_IMPORTED_MODULE_8__.Popup);
41766
41816
  if (!box) {
41767
41817
  this.j.e.fire('outsideClick', e);
@@ -41865,12 +41915,22 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.select = {
41865
41915
  'touchstart',
41866
41916
  'mouseup',
41867
41917
  'touchend'
41868
- ]);
41918
+ ]), /**
41919
+ * Where the last press started. Chrome reports a drag that begins in one
41920
+ * element and ends in another as a `click` on their common ancestor, so a
41921
+ * press inside a popup is remembered to tell such a drag from a real click.
41922
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__pressTarget", null);
41869
41923
  }
41870
41924
  }
41871
41925
  ;(0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
41872
41926
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.autobind
41873
41927
  ], select.prototype, "onStartSelection", null);
41928
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
41929
+ (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.watch)([
41930
+ 'ow:mousedown',
41931
+ 'ow:touchstart'
41932
+ ])
41933
+ ], select.prototype, "onOutsidePress", null);
41874
41934
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
41875
41935
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_3__.watch)('ow:click')
41876
41936
  ], select.prototype, "onOutsideClick", null);