jodit 4.17.2 → 4.17.4

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 (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +5 -5
  4. package/es2015/jodit.js +60 -7
  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 +5 -5
  13. package/es2018/jodit.min.js +5 -5
  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 +6 -6
  18. package/es2021/jodit.js +60 -7
  19. package/es2021/jodit.min.js +6 -6
  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 +6 -6
  28. package/es2021.en/jodit.js +60 -7
  29. package/es2021.en/jodit.min.js +6 -6
  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 +80 -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/helpers/html/safe-html.js +15 -0
  52. package/esm/jodit.js +5 -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/clean-html/clean-html.d.ts +8 -0
  56. package/esm/plugins/clean-html/clean-html.js +13 -0
  57. package/package.json +1 -1
  58. package/types/modules/file-browser/data-provider.d.ts +1 -0
  59. package/types/plugins/clean-html/clean-html.d.ts +8 -0
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.2
4
+ * Version: v4.17.4
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.2";
1802
+ */ const APP_VERSION = "4.17.4";
1803
1803
  // prettier-ignore
1804
1804
  const ES = "es2021";
1805
1805
  const IS_ES_MODERN = true;
@@ -6197,6 +6197,21 @@ function isSmuggledForeignHtml(elm) {
6197
6197
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(elm);
6198
6198
  }
6199
6199
  }
6200
+ // `<noscript>` is parsed as markup in a document with scripting off (the
6201
+ // inert document the value is sanitized in) and as raw text in one with
6202
+ // scripting on (the live editor). The same serialized bytes therefore
6203
+ // describe two different trees, and markup hidden as inert text in the
6204
+ // first comes alive as elements in the second. The element has no use in
6205
+ // editor content, so it goes, together with everything it carried.
6206
+ const noscript = [];
6207
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.each(box, (node)=>{
6208
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isElement(node) && node.nodeName === 'NOSCRIPT') {
6209
+ noscript.push(node);
6210
+ }
6211
+ });
6212
+ for (const elm of noscript){
6213
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(elm);
6214
+ }
6200
6215
  const removeEvents = options.removeEventAttributes ?? options.removeOnError;
6201
6216
  // Single synchronous traversal of the subtree. Besides removing event
6202
6217
  // handlers and `javascript:` links, `sanitizeHTMLElement` neutralises
@@ -17971,6 +17986,11 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_10__.ViewWithToolbar
17971
17986
  }
17972
17987
  if (this.editor) {
17973
17988
  this.editor.innerHTML = data.value;
17989
+ // Fired synchronously, before any task can run: the value was
17990
+ // sanitized in an inert document and re-parsed here with scripting
17991
+ // on, and the two parsers do not always agree. Listeners get to
17992
+ // look at the tree that actually exists.
17993
+ this.e.fire('afterSetNativeEditorValue');
17974
17994
  }
17975
17995
  }
17976
17996
  /**
@@ -20768,6 +20788,16 @@ const DOCS_URL = 'https://xdsoft.net/jodit/docs/modules/file_browser.html';
20768
20788
  });
20769
20789
  return resp;
20770
20790
  }
20791
+ /**
20792
+ * Actions that only read from the connector. A newer request for one of them
20793
+ * makes the older one pointless, so it is aborted; every other action changes
20794
+ * server state and must be allowed to finish.
20795
+ */ const REPLACEABLE_ACTIONS = new Set([
20796
+ 'items',
20797
+ 'folder',
20798
+ 'permissions',
20799
+ 'getLocalFileByUrl'
20800
+ ]);
20771
20801
  class DataProvider {
20772
20802
  /**
20773
20803
  * Alias for options
@@ -20776,10 +20806,19 @@ class DataProvider {
20776
20806
  }
20777
20807
  get(name) {
20778
20808
  const instances = this.__ajaxInstances;
20779
- if (instances.has(name)) {
20780
- const ajax = instances.get(name);
20809
+ // A listing asked for again supersedes the one still loading, so the
20810
+ // earlier request is aborted. That must never happen to a request
20811
+ // that changes something on the server: aborting it does not undo it,
20812
+ // the caller just never hears the result. Removing several files at
20813
+ // once used to send one `fileRemove` per file and abort all but the
20814
+ // last, so only the last one was ever removed. Mutating requests get a
20815
+ // key of their own and run side by side.
20816
+ const replaceable = REPLACEABLE_ACTIONS.has(name);
20817
+ const key = replaceable ? name : `${name}#${++this.__requestSerial}`;
20818
+ if (replaceable && instances.has(key)) {
20819
+ const ajax = instances.get(key);
20781
20820
  ajax?.abort();
20782
- instances.delete(name);
20821
+ instances.delete(key);
20783
20822
  }
20784
20823
  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)({
20785
20824
  onProgress: this.progressHandler
@@ -20788,11 +20827,11 @@ class DataProvider {
20788
20827
  opts.data = opts.prepareData.call(this, opts.data);
20789
20828
  }
20790
20829
  const ajax = new jodit_core_request_ajax__WEBPACK_IMPORTED_MODULE_11__.Ajax(opts);
20791
- instances.set(name, ajax);
20830
+ instances.set(key, ajax);
20792
20831
  const promise = ajax.send();
20793
20832
  promise.finally(()=>{
20794
20833
  ajax.destruct();
20795
- instances.delete(name);
20834
+ instances.delete(key);
20796
20835
  this.progressHandler(100);
20797
20836
  }).catch(()=>null);
20798
20837
  return promise.then((resp)=>resp.json()).then((resp)=>{
@@ -21097,11 +21136,13 @@ class DataProvider {
21097
21136
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "options", void 0);
21098
21137
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__currentPermissions", void 0);
21099
21138
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__ajaxInstances", void 0);
21139
+ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__requestSerial", void 0);
21100
21140
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "progressHandler", void 0);
21101
21141
  this.parent = parent;
21102
21142
  this.options = options;
21103
21143
  this.__currentPermissions = null;
21104
21144
  this.__ajaxInstances = new Map();
21145
+ this.__requestSerial = 0;
21105
21146
  this.progressHandler = (ignore)=>{};
21106
21147
  }
21107
21148
  }
@@ -28752,6 +28793,15 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
28752
28793
  return false;
28753
28794
  }
28754
28795
  }
28796
+ /**
28797
+ * The value was sanitized in an inert document and has just been re-parsed
28798
+ * into the live editor with scripting on. Where the two parsers disagree
28799
+ * (`<noscript>`, raw-text elements), markup that was inert text a moment
28800
+ * ago is a real element now, so the live tree is sanitized once more, in
28801
+ * the same call stack, before any handler it might carry can fire.
28802
+ */ onAfterSetNativeEditorValue() {
28803
+ ;(0,jodit_core_helpers_html_safe_html__WEBPACK_IMPORTED_MODULE_6__.safeHTML)(this.j.editor, this.j.o.cleanHTML);
28804
+ }
28755
28805
  /**
28756
28806
  * Event handler when manually assigning a value to the HTML editor.
28757
28807
  */ onBeforeSetNativeEditorValue(data) {
@@ -28877,6 +28927,9 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
28877
28927
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
28878
28928
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeCommand')
28879
28929
  ], cleanHtml.prototype, "beforeCommand", null);
28930
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
28931
+ (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':afterSetNativeEditorValue')
28932
+ ], cleanHtml.prototype, "onAfterSetNativeEditorValue", null);
28880
28933
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
28881
28934
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeSetNativeEditorValue')
28882
28935
  ], cleanHtml.prototype, "onBeforeSetNativeEditorValue", null);