jodit 4.19.7 → 4.19.8

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 (76) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +8 -8
  4. package/es2015/jodit.js +295 -100
  5. package/es2015/jodit.min.js +4 -4
  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 +8 -8
  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 +9 -9
  18. package/es2021/jodit.js +229 -44
  19. package/es2021/jodit.min.js +57 -57
  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 +229 -44
  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 +371 -103
  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.d.ts +1 -0
  51. package/esm/core/constants.js +3 -1
  52. package/esm/core/helpers/utils/error/error.d.ts +1 -0
  53. package/esm/core/helpers/utils/error/error.js +4 -1
  54. package/esm/core/helpers/utils/error/errors/answer-error.d.ts +13 -0
  55. package/esm/core/helpers/utils/error/errors/answer-error.js +17 -0
  56. package/esm/core/helpers/utils/error/errors/index.d.ts +1 -0
  57. package/esm/core/helpers/utils/error/errors/index.js +1 -0
  58. package/esm/core/request/ajax.d.ts +1 -0
  59. package/esm/core/request/ajax.js +20 -1
  60. package/esm/modules/file-browser/data-provider.js +5 -3
  61. package/esm/modules/uploader/config.js +4 -0
  62. package/esm/modules/uploader/helpers/send-files.d.ts +2 -2
  63. package/esm/modules/uploader/helpers/send-files.js +76 -9
  64. package/esm/modules/uploader/helpers/upload-error.d.ts +15 -0
  65. package/esm/modules/uploader/helpers/upload-error.js +16 -0
  66. package/esm/modules/uploader/uploader.js +15 -3
  67. package/esm/types/uploader.d.ts +117 -11
  68. package/package.json +2 -2
  69. package/types/core/constants.d.ts +1 -0
  70. package/types/core/helpers/utils/error/error.d.ts +1 -0
  71. package/types/core/helpers/utils/error/errors/answer-error.d.ts +13 -0
  72. package/types/core/helpers/utils/error/errors/index.d.ts +1 -0
  73. package/types/core/request/ajax.d.ts +1 -0
  74. package/types/modules/uploader/helpers/send-files.d.ts +2 -2
  75. package/types/modules/uploader/helpers/upload-error.d.ts +15 -0
  76. package/types/types/uploader.d.ts +117 -11
@@ -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.19.7
4
+ * Version: v4.19.8
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1824,7 +1824,7 @@ __webpack_require__.r(__webpack_exports__);
1824
1824
  * ```
1825
1825
  * @packageDocumentation
1826
1826
  * @module constants
1827
- */ const APP_VERSION = "4.19.7";
1827
+ */ const APP_VERSION = "4.19.8";
1828
1828
  // prettier-ignore
1829
1829
  const ES = "es2021";
1830
1830
  const IS_ES_MODERN = true;
@@ -1963,6 +1963,8 @@ const EMULATE_DBLCLICK_TIMEOUT = 300;
1963
1963
  * ```
1964
1964
  */ const INSERT_ONLY_TEXT = 'insert_only_text';
1965
1965
  const SAFE_COUNT_CHANGE_CALL = 10;
1966
+ // Connector answer code for a file name that is already taken (same as the HTTP status)
1967
+ const ERROR_CODE_CONFLICT = 409;
1966
1968
  const IS_MAC = typeof globalWindow !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(globalWindow.navigator.platform);
1967
1969
  const KEY_ALIASES = {
1968
1970
  add: '+',
@@ -2046,6 +2048,7 @@ const PASSIVE_EVENTS = new Set([
2046
2048
  /* harmony export */ "CLIPBOARD_ID", 0, /* binding */ CLIPBOARD_ID,
2047
2049
  /* harmony export */ "COMMAND_KEYS", 0, /* binding */ COMMAND_KEYS,
2048
2050
  /* harmony export */ "EMULATE_DBLCLICK_TIMEOUT", 0, /* binding */ EMULATE_DBLCLICK_TIMEOUT,
2051
+ /* harmony export */ "ERROR_CODE_CONFLICT", 0, /* binding */ ERROR_CODE_CONFLICT,
2049
2052
  /* harmony export */ "ES", 0, /* binding */ ES,
2050
2053
  /* harmony export */ "FAT_MODE", 0, /* binding */ FAT_MODE,
2051
2054
  /* harmony export */ "HOMEPAGE", 0, /* binding */ HOMEPAGE,
@@ -8745,6 +8748,7 @@ const dataBind = (elm, key, value)=>{
8745
8748
 
8746
8749
  "use strict";
8747
8750
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8751
+ /* harmony export */ answer: function() { return /* binding */ answer; },
8748
8752
  /* harmony export */ connection: function() { return /* binding */ connection; },
8749
8753
  /* harmony export */ error: function() { return /* binding */ error; },
8750
8754
  /* harmony export */ options: function() { return /* binding */ options; }
@@ -8768,6 +8772,9 @@ function connection(message) {
8768
8772
  function options(message) {
8769
8773
  return new _errors__WEBPACK_IMPORTED_MODULE_0__.OptionsError(message);
8770
8774
  }
8775
+ function answer(message, resp, code) {
8776
+ return new _errors__WEBPACK_IMPORTED_MODULE_0__.AnswerError(message, resp, code);
8777
+ }
8771
8778
 
8772
8779
 
8773
8780
  /***/ }),
@@ -8793,6 +8800,32 @@ function options(message) {
8793
8800
  }
8794
8801
 
8795
8802
 
8803
+ /***/ }),
8804
+
8805
+ /***/ 45052:
8806
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
8807
+
8808
+ "use strict";
8809
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8810
+ /* harmony export */ AnswerError: function() { return /* binding */ AnswerError; }
8811
+ /* harmony export */ });
8812
+ /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
8813
+
8814
+ /*!
8815
+ * Jodit Editor (https://xdsoft.net/jodit/)
8816
+ * Released under MIT see LICENSE.txt in the project root for license information.
8817
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
8818
+ */ /**
8819
+ * @module helpers/utils
8820
+ */ // A connector refused the request: the answer and its `data.code` stay reachable for the handler
8821
+ class AnswerError extends Error {
8822
+ constructor(message, answer, code){
8823
+ super(message), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "answer", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "code", void 0), this.answer = answer, this.code = code;
8824
+ Object.setPrototypeOf(this, AnswerError.prototype);
8825
+ }
8826
+ }
8827
+
8828
+
8796
8829
  /***/ }),
8797
8830
 
8798
8831
  /***/ 58250:
@@ -8823,13 +8856,15 @@ function options(message) {
8823
8856
 
8824
8857
  "use strict";
8825
8858
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8826
- /* harmony export */ ConnectionError: function() { return /* reexport safe */ _connection_error__WEBPACK_IMPORTED_MODULE_1__.ConnectionError; },
8827
- /* harmony export */ OptionsError: function() { return /* reexport safe */ _options_error__WEBPACK_IMPORTED_MODULE_2__.OptionsError; },
8859
+ /* harmony export */ AnswerError: function() { return /* reexport safe */ _answer_error__WEBPACK_IMPORTED_MODULE_1__.AnswerError; },
8860
+ /* harmony export */ ConnectionError: function() { return /* reexport safe */ _connection_error__WEBPACK_IMPORTED_MODULE_2__.ConnectionError; },
8861
+ /* harmony export */ OptionsError: function() { return /* reexport safe */ _options_error__WEBPACK_IMPORTED_MODULE_3__.OptionsError; },
8828
8862
  /* harmony export */ abort: function() { return /* reexport safe */ _abort_error__WEBPACK_IMPORTED_MODULE_0__.abort; }
8829
8863
  /* harmony export */ });
8830
8864
  /* harmony import */ var _abort_error__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14228);
8831
- /* harmony import */ var _connection_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58250);
8832
- /* harmony import */ var _options_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11080);
8865
+ /* harmony import */ var _answer_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(45052);
8866
+ /* harmony import */ var _connection_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(58250);
8867
+ /* harmony import */ var _options_error__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(11080);
8833
8868
  /*!
8834
8869
  * Jodit Editor (https://xdsoft.net/jodit/)
8835
8870
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -8841,6 +8876,7 @@ function options(message) {
8841
8876
 
8842
8877
 
8843
8878
 
8879
+
8844
8880
  /***/ }),
8845
8881
 
8846
8882
  /***/ 11080:
@@ -8871,9 +8907,11 @@ function options(message) {
8871
8907
 
8872
8908
  "use strict";
8873
8909
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8910
+ /* harmony export */ AnswerError: function() { return /* reexport safe */ _errors___WEBPACK_IMPORTED_MODULE_1__.AnswerError; },
8874
8911
  /* harmony export */ ConnectionError: function() { return /* reexport safe */ _errors___WEBPACK_IMPORTED_MODULE_1__.ConnectionError; },
8875
8912
  /* harmony export */ OptionsError: function() { return /* reexport safe */ _errors___WEBPACK_IMPORTED_MODULE_1__.OptionsError; },
8876
8913
  /* harmony export */ abort: function() { return /* reexport safe */ _errors___WEBPACK_IMPORTED_MODULE_1__.abort; },
8914
+ /* harmony export */ answer: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_0__.answer; },
8877
8915
  /* harmony export */ connection: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_0__.connection; },
8878
8916
  /* harmony export */ error: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_0__.error; },
8879
8917
  /* harmony export */ options: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_0__.options; }
@@ -9115,6 +9153,7 @@ const isPart = (node, part)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_0__.Dom
9115
9153
  __webpack_require__.r(__webpack_exports__);
9116
9154
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9117
9155
  /* harmony export */ $$: function() { return /* reexport safe */ _selector__WEBPACK_IMPORTED_MODULE_27__.$$; },
9156
+ /* harmony export */ AnswerError: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_13__.AnswerError; },
9118
9157
  /* harmony export */ ConfigDeepFlatten: function() { return /* reexport safe */ _config_proto__WEBPACK_IMPORTED_MODULE_7__.ConfigDeepFlatten; },
9119
9158
  /* harmony export */ ConfigFlatten: function() { return /* reexport safe */ _config_proto__WEBPACK_IMPORTED_MODULE_7__.ConfigFlatten; },
9120
9159
  /* harmony export */ ConfigMerge: function() { return /* reexport safe */ _config_proto__WEBPACK_IMPORTED_MODULE_7__.ConfigMerge; },
@@ -9126,6 +9165,7 @@ __webpack_require__.r(__webpack_exports__);
9126
9165
  /* harmony export */ abort: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_13__.abort; },
9127
9166
  /* harmony export */ alignElement: function() { return /* reexport safe */ _align__WEBPACK_IMPORTED_MODULE_0__.alignElement; },
9128
9167
  /* harmony export */ alreadyLoadedList: function() { return /* reexport safe */ _append_script__WEBPACK_IMPORTED_MODULE_1__.alreadyLoadedList; },
9168
+ /* harmony export */ answer: function() { return /* reexport safe */ _error__WEBPACK_IMPORTED_MODULE_13__.answer; },
9129
9169
  /* harmony export */ appendScriptAsync: function() { return /* reexport safe */ _append_script__WEBPACK_IMPORTED_MODULE_1__.appendScriptAsync; },
9130
9170
  /* harmony export */ appendStyleAsync: function() { return /* reexport safe */ _append_script__WEBPACK_IMPORTED_MODULE_1__.appendStyleAsync; },
9131
9171
  /* harmony export */ attr: function() { return /* reexport safe */ _attr__WEBPACK_IMPORTED_MODULE_3__.attr; },
@@ -10705,6 +10745,23 @@ class Ajax {
10705
10745
  } catch {}
10706
10746
  return this;
10707
10747
  }
10748
+ // A connector answers an error with its JSON envelope and a real HTTP status (403, 409): the body says why, the reason phrase does not
10749
+ __hasAnswerEnvelope() {
10750
+ const { xhr } = this;
10751
+ if (xhr.responseType && xhr.responseType !== 'text') {
10752
+ return false;
10753
+ }
10754
+ const text = xhr.responseText;
10755
+ if (!text || text[0] !== '{') {
10756
+ return false;
10757
+ }
10758
+ try {
10759
+ const answer = JSON.parse(text);
10760
+ return (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.isPlainObject)(answer) && 'success' in answer;
10761
+ } catch {
10762
+ return false;
10763
+ }
10764
+ }
10708
10765
  send() {
10709
10766
  this.__activated = true;
10710
10767
  const { xhr, o } = this;
@@ -10738,7 +10795,7 @@ class Ajax {
10738
10795
  xhr.onreadystatechange = ()=>{
10739
10796
  this.options.onProgress?.(10);
10740
10797
  if (xhr.readyState === XMLHttpRequest.DONE) {
10741
- if (o.successStatuses.includes(xhr.status)) {
10798
+ if (o.successStatuses.includes(xhr.status) || this.__hasAnswerEnvelope()) {
10742
10799
  onResolve();
10743
10800
  } else if (xhr.statusText) {
10744
10801
  this.__isFulfilled = true;
@@ -21565,7 +21622,7 @@ class DataProvider {
21565
21622
  }).catch(()=>null);
21566
21623
  return promise.then((resp)=>resp.json()).then((resp)=>{
21567
21624
  if (resp && !this.isSuccess(resp)) {
21568
- throw new Error(this.getMessage(resp));
21625
+ throw (0,jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_9__.answer)(this.getMessage(resp), resp, resp.data?.code);
21569
21626
  }
21570
21627
  return resp;
21571
21628
  });
@@ -21700,7 +21757,7 @@ class DataProvider {
21700
21757
  if (this.isSuccess(resp)) {
21701
21758
  return resp.data;
21702
21759
  }
21703
- throw (0,jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_9__.error)(this.getMessage(resp));
21760
+ throw (0,jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_9__.answer)(this.getMessage(resp), resp, resp.data?.code);
21704
21761
  });
21705
21762
  }
21706
21763
  /**
@@ -26540,6 +26597,10 @@ jodit_config__WEBPACK_IMPORTED_MODULE_3__.Config.prototype.uploader = {
26540
26597
  defaultHandlerError (e) {
26541
26598
  this.j.message.error(e.message);
26542
26599
  },
26600
+ promptOnExists: true,
26601
+ promptOnExistsSuggestName (name) {
26602
+ return name;
26603
+ },
26543
26604
  contentType (requestData) {
26544
26605
  return this.ow.FormData !== undefined && typeof requestData !== 'string' ? false : 'application/x-www-form-urlencoded; charset=UTF-8';
26545
26606
  }
@@ -26716,8 +26777,12 @@ function processOldBrowserDrag(self, cData, handlerSuccess, handlerError, onFina
26716
26777
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
26717
26778
  /* harmony export */ sendFiles: function() { return /* binding */ sendFiles; }
26718
26779
  /* harmony export */ });
26719
- /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(65946);
26720
- /* harmony import */ var jodit_modules_uploader_helpers_send__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(77911);
26780
+ /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81937);
26781
+ /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(65946);
26782
+ /* harmony import */ var jodit_core_traits_dlgs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(80512);
26783
+ /* harmony import */ var jodit_modules_dialog_prompt__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(74103);
26784
+ /* harmony import */ var jodit_modules_uploader_helpers_send__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(77911);
26785
+ /* harmony import */ var jodit_modules_uploader_helpers_upload_error__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(55083);
26721
26786
  /*!
26722
26787
  * Jodit Editor (https://xdsoft.net/jodit/)
26723
26788
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -26726,24 +26791,46 @@ function processOldBrowserDrag(self, cData, handlerSuccess, handlerError, onFina
26726
26791
  * @module modules/uploader
26727
26792
  */
26728
26793
 
26794
+
26795
+
26796
+
26797
+
26729
26798
  /**
26730
26799
  * Send files to server
26731
- */ function sendFiles(uploader, files, handlerSuccess, handlerError, process) {
26800
+ */ async function sendFiles(uploader, files, handlerSuccess, handlerError, process, // Set when a refused upload is sent again: `beforeUpload` already had its say
26801
+ retryOf) {
26732
26802
  if (!files) {
26733
- return Promise.reject((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.error)('Need files'));
26803
+ throw (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.error)('Need files');
26734
26804
  }
26735
26805
  const { o } = uploader;
26736
- let fileList = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.toArray)(files);
26806
+ let fileList = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.toArray)(files);
26737
26807
  if (!fileList.length) {
26738
- return Promise.reject((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.error)('Need files'));
26808
+ throw (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.error)('Need files');
26739
26809
  }
26740
- // Client-side validation hook — returning `false` aborts the upload.
26810
+ let extraData = retryOf?.data;
26811
+ // Client-side validation hook — returning `false` aborts the upload, and it may hand back the files to send instead
26741
26812
  // See https://github.com/xdan/jodit/issues/1329
26742
- if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction)(o.beforeUpload)) {
26743
- if (o.beforeUpload.call(uploader, fileList) === false) {
26744
- const err = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.error)('Upload canceled');
26813
+ if (!retryOf && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(o.beforeUpload)) {
26814
+ let plan;
26815
+ try {
26816
+ plan = await o.beforeUpload.call(uploader, fileList);
26817
+ } catch (e) {
26818
+ (handlerError || o.defaultHandlerError).call(uploader, e);
26819
+ throw e;
26820
+ }
26821
+ if (plan === false) {
26822
+ const err = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.error)('Upload canceled');
26745
26823
  (handlerError || o.defaultHandlerError).call(uploader, err);
26746
- return Promise.reject(err);
26824
+ throw err;
26825
+ }
26826
+ if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isArray)(plan)) {
26827
+ fileList = plan;
26828
+ } else if ((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isPlainObject)(plan) && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isArray)(plan.files)) {
26829
+ fileList = plan.files;
26830
+ extraData = plan.data;
26831
+ }
26832
+ if (!fileList.length) {
26833
+ return [];
26747
26834
  }
26748
26835
  }
26749
26836
  const promises = [];
@@ -26783,20 +26870,35 @@ function processOldBrowserDrag(self, cData, handlerSuccess, handlerError, onFina
26783
26870
  if (process) {
26784
26871
  process(form);
26785
26872
  }
26786
- if (o.data && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(o.data)) {
26873
+ if (o.data && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isPlainObject)(o.data)) {
26787
26874
  Object.keys(o.data).forEach((key)=>{
26788
26875
  form.append(key, o.data[key]);
26789
26876
  });
26790
26877
  }
26878
+ if (extraData) {
26879
+ Object.keys(extraData).forEach((key)=>{
26880
+ form.append(key, extraData[key]);
26881
+ });
26882
+ }
26791
26883
  o.prepareData.call(uploader, form);
26792
- promises.push((0,jodit_modules_uploader_helpers_send__WEBPACK_IMPORTED_MODULE_1__.send)(uploader, form).then((resp)=>{
26884
+ promises.push((0,jodit_modules_uploader_helpers_send__WEBPACK_IMPORTED_MODULE_4__.send)(uploader, form).then((resp)=>{
26793
26885
  if (o.isSuccess.call(uploader, resp)) {
26794
- const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction)(handlerSuccess) ? handlerSuccess : o.defaultHandlerSuccess;
26886
+ const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(handlerSuccess) ? handlerSuccess : o.defaultHandlerSuccess;
26795
26887
  handler.call(uploader, o.process.call(uploader, resp));
26796
26888
  return resp;
26797
26889
  }
26798
- const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction)(handlerError) ? handlerError : o.defaultHandlerError;
26799
- handler.call(uploader, (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.error)(o.getMessage.call(uploader, resp)));
26890
+ const err = new jodit_modules_uploader_helpers_upload_error__WEBPACK_IMPORTED_MODULE_5__.UploadError(o.getMessage.call(uploader, resp), resp, fileList, (plan)=>sendFiles(uploader, plan?.files ?? fileList, handlerSuccess, handlerError, process, {
26891
+ data: {
26892
+ ...extraData,
26893
+ ...plan?.data
26894
+ }
26895
+ }));
26896
+ // A taken name is part of the upload, not a failure: ask for another one first
26897
+ if (err.code === jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.ERROR_CODE_CONFLICT && o.promptOnExists) {
26898
+ return askAnotherName(uploader, err);
26899
+ }
26900
+ const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(handlerError) ? handlerError : o.defaultHandlerError;
26901
+ handler.call(uploader, err);
26800
26902
  return resp;
26801
26903
  }).then(()=>{
26802
26904
  uploader.j.events && uploader.j.e.fire('filesWereUploaded');
@@ -26804,6 +26906,45 @@ function processOldBrowserDrag(self, cData, handlerSuccess, handlerError, onFina
26804
26906
  }
26805
26907
  return Promise.all(promises);
26806
26908
  }
26909
+ function askAnotherName(uploader, err) {
26910
+ const { files } = err;
26911
+ // A batch is refused as a whole (the connector saved nothing) and the answer does not say which name is taken,
26912
+ // so the files go again one by one: the free ones are simply stored, the taken one answers 409 alone and gets its prompt
26913
+ if (files.length > 1) {
26914
+ return files.reduce((chain, file)=>chain.then(()=>err.retry({
26915
+ files: [
26916
+ file
26917
+ ]
26918
+ })), Promise.resolve());
26919
+ }
26920
+ const [file] = files;
26921
+ const { j, o } = uploader;
26922
+ return new Promise((resolve)=>{
26923
+ let answered = false;
26924
+ // `Dlgs.prototype.dlg`: the uploader's view does not always carry the Dlgs trait
26925
+ const dialog = jodit_modules_dialog_prompt__WEBPACK_IMPORTED_MODULE_3__.Prompt.call(jodit_core_traits_dlgs__WEBPACK_IMPORTED_MODULE_2__.Dlgs.prototype.dlg.call(j, {
26926
+ closeOnClickOverlay: true
26927
+ }), j.i18n(err.message), j.i18n('Rename'), (newName)=>{
26928
+ newName = newName.trim();
26929
+ if (!newName) {
26930
+ return false;
26931
+ }
26932
+ answered = true;
26933
+ resolve(err.retry({
26934
+ files: [
26935
+ new File([
26936
+ file
26937
+ ], newName, {
26938
+ type: file.type
26939
+ })
26940
+ ]
26941
+ }));
26942
+ }, j.i18n('Enter new name'), o.promptOnExistsSuggestName.call(uploader, file.name));
26943
+ dialog.e.on(dialog, 'afterClose', ()=>{
26944
+ !answered && resolve(undefined);
26945
+ });
26946
+ });
26947
+ }
26807
26948
  function readImagesWithReader(fileList, imagesExtensions, promises, uploader, handlerSuccess, defaultHandlerSuccess) {
26808
26949
  const readerPromises = [];
26809
26950
  let file, i;
@@ -26832,7 +26973,7 @@ function readImagesWithReader(fileList, imagesExtensions, promises, uploader, ha
26832
26973
  name
26833
26974
  ]
26834
26975
  };
26835
- const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction)(handlerSuccess) ? handlerSuccess : defaultHandlerSuccess;
26976
+ const handler = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.isFunction)(handlerSuccess) ? handlerSuccess : defaultHandlerSuccess;
26836
26977
  handler.call(uploader, resp);
26837
26978
  resolve(resp);
26838
26979
  };
@@ -26948,6 +27089,34 @@ function send(uploader, data) {
26948
27089
  /* harmony export */ ]);
26949
27090
 
26950
27091
 
27092
+ /***/ }),
27093
+
27094
+ /***/ 55083:
27095
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
27096
+
27097
+ "use strict";
27098
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
27099
+ /* harmony export */ UploadError: function() { return /* binding */ UploadError; }
27100
+ /* harmony export */ });
27101
+ /* harmony import */ var _swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25045);
27102
+ /* harmony import */ var jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(33201);
27103
+ /*!
27104
+ * Jodit Editor (https://xdsoft.net/jodit/)
27105
+ * Released under MIT see LICENSE.txt in the project root for license information.
27106
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
27107
+ */ /**
27108
+ * @module modules/uploader
27109
+ */
27110
+
27111
+ // The connector refused these files: the handler can change the request and send it again
27112
+ class UploadError extends jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_1__.AnswerError {
27113
+ constructor(message, answer, files, retry){
27114
+ super(message, answer, answer.data?.code), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "files", void 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "retry", void 0), this.files = files, this.retry = retry;
27115
+ Object.setPrototypeOf(this, UploadError.prototype);
27116
+ }
27117
+ }
27118
+
27119
+
26951
27120
  /***/ }),
26952
27121
 
26953
27122
  /***/ 94925:
@@ -26962,9 +27131,10 @@ function send(uploader, data) {
26962
27131
  /* harmony import */ var jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(81937);
26963
27132
  /* harmony import */ var jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(23211);
26964
27133
  /* harmony import */ var jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65946);
26965
- /* harmony import */ var jodit_config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5266);
26966
- /* harmony import */ var jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(11981);
26967
- /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(40013);
27134
+ /* harmony import */ var jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(33201);
27135
+ /* harmony import */ var jodit_config__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5266);
27136
+ /* harmony import */ var jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(11981);
27137
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(40013);
26968
27138
  /*!
26969
27139
  * Jodit Editor (https://xdsoft.net/jodit/)
26970
27140
  * Released under MIT see LICENSE.txt in the project root for license information.
@@ -26982,6 +27152,7 @@ function send(uploader, data) {
26982
27152
 
26983
27153
 
26984
27154
 
27155
+
26985
27156
  class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewComponent {
26986
27157
  get j() {
26987
27158
  return this.jodit;
@@ -27037,14 +27208,14 @@ class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewCo
27037
27208
  }
27038
27209
  };
27039
27210
  // send data on server
27040
- if (!jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.IS_IE && (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.hasFiles)(cData)) {
27041
- (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.sendFiles)(self, cData.files, handlerSuccess, handlerError).finally(onFinally);
27211
+ if (!jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.IS_IE && (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.hasFiles)(cData)) {
27212
+ (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.sendFiles)(self, cData.files, handlerSuccess, handlerError).finally(onFinally);
27042
27213
  return false;
27043
27214
  }
27044
27215
  if (jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.IS_IE && !jodit_core_constants__WEBPACK_IMPORTED_MODULE_2__.IS_ES_NEXT) {
27045
- return (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.processOldBrowserDrag)(self, cData, handlerSuccess, handlerError, onFinally);
27216
+ return (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.processOldBrowserDrag)(self, cData, handlerSuccess, handlerError, onFinally);
27046
27217
  }
27047
- if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.hasItems)(cData)) {
27218
+ if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.hasItems)(cData)) {
27048
27219
  const { items } = cData;
27049
27220
  for(i = 0; i < items.length; i += 1){
27050
27221
  if (items[i].kind === 'file' && items[i].type === 'image/png') {
@@ -27052,7 +27223,7 @@ class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewCo
27052
27223
  if (file) {
27053
27224
  const mime = file.type.match(/\/([a-z0-9]+)/i);
27054
27225
  extension = mime[1] ? mime[1].toLowerCase() : '';
27055
- (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.sendFiles)(self, [
27226
+ (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.sendFiles)(self, [
27056
27227
  file
27057
27228
  ], handlerSuccess, handlerError, processData).finally(onFinally);
27058
27229
  }
@@ -27074,27 +27245,27 @@ class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewCo
27074
27245
  self.j.e.on(form, 'dragend dragover dragenter dragleave drop', (e)=>{
27075
27246
  e.preventDefault();
27076
27247
  }).on(form, 'dragover', (event)=>{
27077
- if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.hasFiles)(event.dataTransfer) || (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.hasItems)(event.dataTransfer)) {
27248
+ if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.hasFiles)(event.dataTransfer) || (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.hasItems)(event.dataTransfer)) {
27078
27249
  form.classList.add('jodit_drag_hover');
27079
27250
  event.preventDefault();
27080
27251
  }
27081
27252
  }).on(form, 'dragend dragleave', (event)=>{
27082
27253
  form.classList.remove('jodit_drag_hover');
27083
- if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.hasFiles)(event.dataTransfer)) {
27254
+ if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.hasFiles)(event.dataTransfer)) {
27084
27255
  event.preventDefault();
27085
27256
  }
27086
27257
  }).on(form, 'drop', (event)=>{
27087
27258
  form.classList.remove('jodit_drag_hover');
27088
- if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.hasFiles)(event.dataTransfer)) {
27259
+ if ((0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.hasFiles)(event.dataTransfer)) {
27089
27260
  event.preventDefault();
27090
27261
  event.stopImmediatePropagation();
27091
- (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.sendFiles)(self, event.dataTransfer.files, handlerSuccess, handlerError).finally(onFinally);
27262
+ (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.sendFiles)(self, event.dataTransfer.files, handlerSuccess, handlerError).finally(onFinally);
27092
27263
  }
27093
27264
  });
27094
27265
  const inputFile = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.first(form, (node)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isTag(node, 'input') && (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.attr)(node, 'type')?.toLowerCase() === 'file');
27095
27266
  if (inputFile) {
27096
27267
  self.j.e.on(inputFile, 'change', ()=>{
27097
- (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.sendFiles)(self, inputFile.files, handlerSuccess, handlerError).then(()=>{
27268
+ (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.sendFiles)(self, inputFile.files, handlerSuccess, handlerError).then(()=>{
27098
27269
  inputFile.value = '';
27099
27270
  if (!/safari/i.test(navigator.userAgent)) {
27100
27271
  inputFile.type = '';
@@ -27109,7 +27280,7 @@ class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewCo
27109
27280
  */ uploadRemoteImage(url, handlerSuccess, handlerError) {
27110
27281
  const uploader = this, { o } = uploader;
27111
27282
  const handlerE = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.isFunction)(handlerError) ? handlerError : o.defaultHandlerError;
27112
- (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.send)(uploader, {
27283
+ (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.send)(uploader, {
27113
27284
  action: 'fileUploadRemote',
27114
27285
  url
27115
27286
  }).then((resp)=>{
@@ -27118,17 +27289,31 @@ class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewCo
27118
27289
  handler.call(uploader, o.process.call(uploader, resp));
27119
27290
  return;
27120
27291
  }
27121
- handlerE.call(uploader, (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.error)(o.getMessage.call(uploader, resp)));
27292
+ handlerE.call(uploader, (0,jodit_core_helpers_utils_error__WEBPACK_IMPORTED_MODULE_5__.answer)(o.getMessage.call(uploader, resp), resp, resp.data?.code));
27122
27293
  }).catch((e)=>handlerE.call(uploader, e));
27123
27294
  }
27124
27295
  upload(files) {
27125
27296
  return this.async.promise((resolve, reject)=>{
27126
- ;(0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.sendFiles)(this, files, resolve, reject);
27297
+ let settled = false;
27298
+ const settle = (end)=>(value)=>{
27299
+ settled = true;
27300
+ end(value);
27301
+ };
27302
+ (0,jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.sendFiles)(this, files, settle(resolve), settle(reject)).then(()=>{
27303
+ // `beforeUpload` kept no file, so no handler ran
27304
+ if (!settled) {
27305
+ resolve({
27306
+ baseurl: '',
27307
+ files: [],
27308
+ isImages: []
27309
+ });
27310
+ }
27311
+ }, settle(reject));
27127
27312
  });
27128
27313
  }
27129
27314
  destruct() {
27130
27315
  this.setStatus(jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.STATUSES.beforeDestruct);
27131
- const instances = jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_6__.ajaxInstances.get(this);
27316
+ const instances = jodit_modules_uploader_helpers__WEBPACK_IMPORTED_MODULE_7__.ajaxInstances.get(this);
27132
27317
  if (instances) {
27133
27318
  instances.forEach((ajax)=>{
27134
27319
  try {
@@ -27141,7 +27326,7 @@ class Uploader extends jodit_core_component___WEBPACK_IMPORTED_MODULE_1__.ViewCo
27141
27326
  }
27142
27327
  constructor(editor, options){
27143
27328
  super(editor), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "path", ''), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "source", 'default'), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "options", void 0);
27144
- this.options = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.ConfigProto)(options || {}, (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.ConfigProto)(jodit_config__WEBPACK_IMPORTED_MODULE_5__.Config.defaultOptions.uploader, (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.isJoditObject)(editor) ? editor.o.uploader : {}));
27329
+ this.options = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.ConfigProto)(options || {}, (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.ConfigProto)(jodit_config__WEBPACK_IMPORTED_MODULE_6__.Config.defaultOptions.uploader, (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_4__.isJoditObject)(editor) ? editor.o.uploader : {}));
27145
27330
  }
27146
27331
  }
27147
27332