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/es2015/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
  */
@@ -1805,7 +1805,7 @@ __webpack_require__.r(__webpack_exports__);
1805
1805
  * ```
1806
1806
  * @packageDocumentation
1807
1807
  * @module constants
1808
- */ const APP_VERSION = "4.17.2";
1808
+ */ const APP_VERSION = "4.17.4";
1809
1809
  // prettier-ignore
1810
1810
  const ES = "es2015";
1811
1811
  const IS_ES_MODERN = true;
@@ -6222,6 +6222,21 @@ function isSmuggledForeignHtml(elm) {
6222
6222
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(elm);
6223
6223
  }
6224
6224
  }
6225
+ // `<noscript>` is parsed as markup in a document with scripting off (the
6226
+ // inert document the value is sanitized in) and as raw text in one with
6227
+ // scripting on (the live editor). The same serialized bytes therefore
6228
+ // describe two different trees, and markup hidden as inert text in the
6229
+ // first comes alive as elements in the second. The element has no use in
6230
+ // editor content, so it goes, together with everything it carried.
6231
+ const noscript = [];
6232
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.each(box, (node)=>{
6233
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isElement(node) && node.nodeName === 'NOSCRIPT') {
6234
+ noscript.push(node);
6235
+ }
6236
+ });
6237
+ for (const elm of noscript){
6238
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.safeRemove(elm);
6239
+ }
6225
6240
  const removeEvents = (_options_removeEventAttributes = options.removeEventAttributes) !== null && _options_removeEventAttributes !== void 0 ? _options_removeEventAttributes : options.removeOnError;
6226
6241
  // Single synchronous traversal of the subtree. Besides removing event
6227
6242
  // handlers and `javascript:` links, `sanitizeHTMLElement` neutralises
@@ -18112,6 +18127,11 @@ class Jodit extends jodit_modules__WEBPACK_IMPORTED_MODULE_11__.ViewWithToolbar
18112
18127
  }
18113
18128
  if (this.editor) {
18114
18129
  this.editor.innerHTML = data.value;
18130
+ // Fired synchronously, before any task can run: the value was
18131
+ // sanitized in an inert document and re-parsed here with scripting
18132
+ // on, and the two parsers do not always agree. Listeners get to
18133
+ // look at the tree that actually exists.
18134
+ this.e.fire('afterSetNativeEditorValue');
18115
18135
  }
18116
18136
  }
18117
18137
  /**
@@ -20927,6 +20947,16 @@ const DOCS_URL = 'https://xdsoft.net/jodit/docs/modules/file_browser.html';
20927
20947
  });
20928
20948
  return resp;
20929
20949
  }
20950
+ /**
20951
+ * Actions that only read from the connector. A newer request for one of them
20952
+ * makes the older one pointless, so it is aborted; every other action changes
20953
+ * server state and must be allowed to finish.
20954
+ */ const REPLACEABLE_ACTIONS = new Set([
20955
+ 'items',
20956
+ 'folder',
20957
+ 'permissions',
20958
+ 'getLocalFileByUrl'
20959
+ ]);
20930
20960
  class DataProvider {
20931
20961
  /**
20932
20962
  * Alias for options
@@ -20935,10 +20965,19 @@ class DataProvider {
20935
20965
  }
20936
20966
  get(name) {
20937
20967
  const instances = this.__ajaxInstances;
20938
- if (instances.has(name)) {
20939
- const ajax = instances.get(name);
20968
+ // A listing asked for again supersedes the one still loading, so the
20969
+ // earlier request is aborted. That must never happen to a request
20970
+ // that changes something on the server: aborting it does not undo it,
20971
+ // the caller just never hears the result. Removing several files at
20972
+ // once used to send one `fileRemove` per file and abort all but the
20973
+ // last, so only the last one was ever removed. Mutating requests get a
20974
+ // key of their own and run side by side.
20975
+ const replaceable = REPLACEABLE_ACTIONS.has(name);
20976
+ const key = replaceable ? name : `${name}#${++this.__requestSerial}`;
20977
+ if (replaceable && instances.has(key)) {
20978
+ const ajax = instances.get(key);
20940
20979
  ajax === null || ajax === void 0 ? void 0 : ajax.abort();
20941
- instances.delete(name);
20980
+ instances.delete(key);
20942
20981
  }
20943
20982
  const opts = (0,jodit_core_helpers_utils_config_proto__WEBPACK_IMPORTED_MODULE_11__.ConfigProto)(this.options[name] !== undefined ? this.options[name] : {}, (0,jodit_core_helpers_utils_config_proto__WEBPACK_IMPORTED_MODULE_11__.ConfigProto)({
20944
20983
  onProgress: this.progressHandler
@@ -20947,11 +20986,11 @@ class DataProvider {
20947
20986
  opts.data = opts.prepareData.call(this, opts.data);
20948
20987
  }
20949
20988
  const ajax = new jodit_core_request_ajax__WEBPACK_IMPORTED_MODULE_14__.Ajax(opts);
20950
- instances.set(name, ajax);
20989
+ instances.set(key, ajax);
20951
20990
  const promise = ajax.send();
20952
20991
  promise.finally(()=>{
20953
20992
  ajax.destruct();
20954
- instances.delete(name);
20993
+ instances.delete(key);
20955
20994
  this.progressHandler(100);
20956
20995
  }).catch(()=>null);
20957
20996
  return promise.then((resp)=>resp.json()).then((resp)=>{
@@ -21263,11 +21302,13 @@ class DataProvider {
21263
21302
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(this, "options", void 0);
21264
21303
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(this, "__currentPermissions", void 0);
21265
21304
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(this, "__ajaxInstances", void 0);
21305
+ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(this, "__requestSerial", void 0);
21266
21306
  (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_1__._)(this, "progressHandler", void 0);
21267
21307
  this.parent = parent;
21268
21308
  this.options = options;
21269
21309
  this.__currentPermissions = null;
21270
21310
  this.__ajaxInstances = new Map();
21311
+ this.__requestSerial = 0;
21271
21312
  this.progressHandler = (ignore)=>{};
21272
21313
  }
21273
21314
  }
@@ -28965,6 +29006,15 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
28965
29006
  return false;
28966
29007
  }
28967
29008
  }
29009
+ /**
29010
+ * The value was sanitized in an inert document and has just been re-parsed
29011
+ * into the live editor with scripting on. Where the two parsers disagree
29012
+ * (`<noscript>`, raw-text elements), markup that was inert text a moment
29013
+ * ago is a real element now, so the live tree is sanitized once more, in
29014
+ * the same call stack, before any handler it might carry can fire.
29015
+ */ onAfterSetNativeEditorValue() {
29016
+ ;(0,jodit_core_helpers_html_safe_html__WEBPACK_IMPORTED_MODULE_6__.safeHTML)(this.j.editor, this.j.o.cleanHTML);
29017
+ }
28968
29018
  /**
28969
29019
  * Event handler when manually assigning a value to the HTML editor.
28970
29020
  */ onBeforeSetNativeEditorValue(data) {
@@ -29091,6 +29141,9 @@ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Pl
29091
29141
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29092
29142
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeCommand')
29093
29143
  ], cleanHtml.prototype, "beforeCommand", null);
29144
+ (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29145
+ (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':afterSetNativeEditorValue')
29146
+ ], cleanHtml.prototype, "onAfterSetNativeEditorValue", null);
29094
29147
  (0,_swc_helpers_ts_decorate__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
29095
29148
  (0,jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.watch)(':beforeSetNativeEditorValue')
29096
29149
  ], cleanHtml.prototype, "onBeforeSetNativeEditorValue", null);