jodit 4.7.4 → 4.7.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 (55) hide show
  1. package/CHANGELOG.md +46 -31
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +3 -3
  4. package/es2015/jodit.js +20 -13
  5. package/es2015/jodit.min.js +3 -3
  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 +3 -3
  13. package/es2018/jodit.min.js +3 -3
  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 +4 -4
  18. package/es2021/jodit.js +20 -13
  19. package/es2021/jodit.min.js +4 -4
  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 +4 -4
  28. package/es2021.en/jodit.js +20 -13
  29. package/es2021.en/jodit.min.js +4 -4
  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 +22 -13
  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/modules/uploader/helpers/send.js +17 -11
  52. package/esm/modules/widget/file-selector/file-selector.js +5 -3
  53. package/esm/types/uploader.d.ts +14 -0
  54. package/package.json +1 -1
  55. package/types/types/uploader.d.ts +14 -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
package/es5/polyfills.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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.7.4
4
+ * Version: v4.7.5
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -3,7 +3,7 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- export const APP_VERSION = "4.7.4";
6
+ export const APP_VERSION = "4.7.5";
7
7
  // prettier-ignore
8
8
  export const ES = "es2020";
9
9
  export const IS_ES_MODERN = true;
@@ -9,28 +9,29 @@ import { buildData } from "./build-data.js";
9
9
  export const ajaxInstances = new WeakMap();
10
10
  export function send(uploader, data) {
11
11
  const requestData = buildData(uploader, data);
12
- const sendData = (request) => {
12
+ const showProgress = (progress) => {
13
+ uploader.j.progressbar.show().progress(progress);
14
+ if (progress >= 100) {
15
+ uploader.j.progressbar.hide();
16
+ }
17
+ };
18
+ let sendData = (request, showProgress) => {
13
19
  const ajax = new Ajax({
14
20
  xhr: () => {
15
21
  const xhr = new XMLHttpRequest();
16
22
  if (uploader.j.ow.FormData !== undefined &&
17
23
  xhr.upload) {
18
- uploader.j.progressbar.show().progress(10);
24
+ showProgress(10);
19
25
  xhr.upload.addEventListener('progress', evt => {
20
26
  if (evt.lengthComputable) {
21
27
  let percentComplete = evt.loaded / evt.total;
22
28
  percentComplete *= 100;
23
- uploader.j.progressbar
24
- .show()
25
- .progress(percentComplete);
26
- if (percentComplete >= 100) {
27
- uploader.j.progressbar.hide();
28
- }
29
+ showProgress(percentComplete);
29
30
  }
30
31
  }, false);
31
32
  }
32
33
  else {
33
- uploader.j.progressbar.hide();
34
+ showProgress(100);
34
35
  }
35
36
  return xhr;
36
37
  },
@@ -67,10 +68,15 @@ export function send(uploader, data) {
67
68
  instances === null || instances === void 0 ? void 0 : instances.delete(ajax);
68
69
  });
69
70
  };
71
+ if (isFunction(uploader.o.customUploadFunction)) {
72
+ sendData = uploader.o.customUploadFunction;
73
+ }
70
74
  if (isPromise(requestData)) {
71
- return requestData.then(sendData).catch(error => {
75
+ return requestData
76
+ .then(data => sendData(data, showProgress))
77
+ .catch(error => {
72
78
  uploader.o.error.call(uploader, error);
73
79
  });
74
80
  }
75
- return sendData(requestData);
81
+ return sendData(requestData, showProgress);
76
82
  }
@@ -19,9 +19,11 @@ import { TabsWidget } from "../tabs/tabs.js";
19
19
  export const FileSelectorWidget = (editor, callbacks, elm, close, isImage = true) => {
20
20
  let currentImage;
21
21
  const tabs = [];
22
+ const options = editor.o.uploader;
22
23
  if (callbacks.upload &&
23
- editor.o.uploader &&
24
- (editor.o.uploader.url || editor.o.uploader.insertImageAsBase64URI)) {
24
+ (options.url ||
25
+ options.insertImageAsBase64URI ||
26
+ options.customUploadFunction)) {
25
27
  const dragBox = editor.c.fromHTML('<div class="jodit-drag-and-drop__file-box">' +
26
28
  `<strong>${editor.i18n(isImage ? 'Drop image' : 'Drop file')}</strong>` +
27
29
  `<span><br>${editor.i18n('or click')}</span>` +
@@ -30,7 +32,7 @@ export const FileSelectorWidget = (editor, callbacks, elm, close, isImage = true
30
32
  editor.uploader.bind(dragBox, resp => {
31
33
  const handler = isFunction(callbacks.upload)
32
34
  ? callbacks.upload
33
- : editor.o.uploader.defaultHandlerSuccess;
35
+ : options.defaultHandlerSuccess;
34
36
  if (isFunction(handler)) {
35
37
  handler.call(editor, resp);
36
38
  }
@@ -90,6 +90,20 @@ export interface IUploaderOptions<T> {
90
90
  defaultHandlerSuccess: HandlerSuccess;
91
91
  defaultHandlerError: HandlerError;
92
92
  contentType: (this: T, requestData: any) => string | false;
93
+ /**
94
+ * This method can be used to replace the function of uploading files
95
+ * ```javascript
96
+ * Jodit.make('#editor', {
97
+ * uploader: {
98
+ * customUploadFunction: (requestData, showProgress) => fetch(requestData).then((res)=>{
99
+ * showProgress(100)
100
+ * return res.json()
101
+ * })
102
+ * }
103
+ * });
104
+ * ```
105
+ */
106
+ customUploadFunction?: (requestData: any, showProgress: (progress: number) => void) => Promise<IUploaderAnswer>;
93
107
  }
94
108
  export interface IUploader extends IViewComponent {
95
109
  readonly jodit: IViewBased;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.7.4",
3
+ "version": "4.7.5",
4
4
  "description": "Jodit is an awesome and useful wysiwyg editor with filebrowser",
5
5
  "main": "esm/index.js",
6
6
  "types": "types/index.d.ts",
@@ -90,6 +90,20 @@ export interface IUploaderOptions<T> {
90
90
  defaultHandlerSuccess: HandlerSuccess;
91
91
  defaultHandlerError: HandlerError;
92
92
  contentType: (this: T, requestData: any) => string | false;
93
+ /**
94
+ * This method can be used to replace the function of uploading files
95
+ * ```javascript
96
+ * Jodit.make('#editor', {
97
+ * uploader: {
98
+ * customUploadFunction: (requestData, showProgress) => fetch(requestData).then((res)=>{
99
+ * showProgress(100)
100
+ * return res.json()
101
+ * })
102
+ * }
103
+ * });
104
+ * ```
105
+ */
106
+ customUploadFunction?: (requestData: any, showProgress: (progress: number) => void) => Promise<IUploaderAnswer>;
93
107
  }
94
108
  export interface IUploader extends IViewComponent {
95
109
  readonly jodit: IViewBased;