jodit 4.19.14 → 4.20.0

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 (212) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/es2015/jodit.css +76 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +9 -9
  5. package/es2015/jodit.js +1447 -598
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +9 -9
  8. package/es2015/plugins/debug/debug.css +1 -1
  9. package/es2015/plugins/debug/debug.js +1 -1
  10. package/es2015/plugins/debug/debug.min.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  13. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  14. package/es2018/jodit.fat.min.css +1 -1
  15. package/es2018/jodit.fat.min.js +9 -9
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +9 -9
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  20. package/es2021/jodit.css +76 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +14 -14
  23. package/es2021/jodit.js +1428 -595
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +14 -14
  26. package/es2021/plugins/debug/debug.css +1 -1
  27. package/es2021/plugins/debug/debug.js +1 -1
  28. package/es2021/plugins/debug/debug.min.js +1 -1
  29. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  30. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  31. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  32. package/es2021.en/jodit.css +76 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +14 -14
  35. package/es2021.en/jodit.js +1402 -569
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +14 -14
  38. package/es2021.en/plugins/debug/debug.css +1 -1
  39. package/es2021.en/plugins/debug/debug.js +1 -1
  40. package/es2021.en/plugins/debug/debug.min.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  42. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  44. package/es5/jodit.css +96 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +1684 -705
  48. package/es5/jodit.min.css +3 -3
  49. package/es5/jodit.min.js +2 -2
  50. package/es5/plugins/debug/debug.css +1 -1
  51. package/es5/plugins/debug/debug.js +1 -1
  52. package/es5/plugins/debug/debug.min.js +1 -1
  53. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  56. package/es5/polyfills.fat.min.js +1 -1
  57. package/es5/polyfills.js +1 -1
  58. package/es5/polyfills.min.js +1 -1
  59. package/esm/config.d.ts +10 -3
  60. package/esm/core/constants.js +1 -1
  61. package/esm/core/helpers/utils/anchor.d.ts +22 -0
  62. package/esm/core/helpers/utils/anchor.js +29 -0
  63. package/esm/core/helpers/utils/index.d.ts +1 -0
  64. package/esm/core/helpers/utils/index.js +1 -0
  65. package/esm/core/ui/popup/popup.d.ts +5 -0
  66. package/esm/core/ui/popup/popup.js +5 -0
  67. package/esm/jodit.js +11 -14
  68. package/esm/langs/ar.d.ts +5 -0
  69. package/esm/langs/ar.js +5 -0
  70. package/esm/langs/az.d.ts +5 -0
  71. package/esm/langs/az.js +5 -0
  72. package/esm/langs/cs_cz.d.ts +5 -0
  73. package/esm/langs/cs_cz.js +6 -1
  74. package/esm/langs/de.d.ts +5 -0
  75. package/esm/langs/de.js +6 -0
  76. package/esm/langs/es.d.ts +5 -0
  77. package/esm/langs/es.js +6 -1
  78. package/esm/langs/fa.d.ts +5 -0
  79. package/esm/langs/fa.js +6 -1
  80. package/esm/langs/fi.d.ts +5 -0
  81. package/esm/langs/fi.js +5 -0
  82. package/esm/langs/fr.d.ts +5 -0
  83. package/esm/langs/fr.js +5 -0
  84. package/esm/langs/he.d.ts +5 -0
  85. package/esm/langs/he.js +6 -1
  86. package/esm/langs/hu.d.ts +5 -0
  87. package/esm/langs/hu.js +5 -0
  88. package/esm/langs/id.d.ts +5 -0
  89. package/esm/langs/id.js +6 -1
  90. package/esm/langs/it.d.ts +5 -0
  91. package/esm/langs/it.js +6 -1
  92. package/esm/langs/ja.d.ts +5 -0
  93. package/esm/langs/ja.js +6 -1
  94. package/esm/langs/ko.d.ts +5 -0
  95. package/esm/langs/ko.js +6 -1
  96. package/esm/langs/mn.d.ts +5 -0
  97. package/esm/langs/mn.js +6 -1
  98. package/esm/langs/nl.d.ts +5 -0
  99. package/esm/langs/nl.js +5 -0
  100. package/esm/langs/no.d.ts +5 -0
  101. package/esm/langs/no.js +5 -0
  102. package/esm/langs/pl.d.ts +5 -0
  103. package/esm/langs/pl.js +5 -0
  104. package/esm/langs/pt_br.d.ts +5 -0
  105. package/esm/langs/pt_br.js +6 -1
  106. package/esm/langs/ru.d.ts +5 -0
  107. package/esm/langs/ru.js +6 -1
  108. package/esm/langs/sk.d.ts +5 -0
  109. package/esm/langs/sk.js +5 -0
  110. package/esm/langs/sv.d.ts +5 -0
  111. package/esm/langs/sv.js +5 -0
  112. package/esm/langs/tr.d.ts +5 -0
  113. package/esm/langs/tr.js +6 -1
  114. package/esm/langs/ua.d.ts +5 -0
  115. package/esm/langs/ua.js +6 -1
  116. package/esm/langs/zh_cn.d.ts +5 -0
  117. package/esm/langs/zh_cn.js +6 -1
  118. package/esm/langs/zh_tw.d.ts +5 -0
  119. package/esm/langs/zh_tw.js +5 -0
  120. package/esm/modules/file-browser/file-browser.d.ts +3 -4
  121. package/esm/modules/file-browser/file-browser.js +12 -12
  122. package/esm/modules/toolbar/button/button.d.ts +7 -0
  123. package/esm/modules/toolbar/button/button.js +30 -4
  124. package/esm/modules/uploader/config.js +18 -18
  125. package/esm/modules/uploader/helpers/index.d.ts +1 -0
  126. package/esm/modules/uploader/helpers/index.js +1 -0
  127. package/esm/modules/uploader/helpers/normalize-uploader-data.d.ts +32 -0
  128. package/esm/modules/uploader/helpers/normalize-uploader-data.js +54 -0
  129. package/esm/modules/uploader/helpers/send-files.js +11 -6
  130. package/esm/modules/uploader/uploader.d.ts +4 -5
  131. package/esm/modules/uploader/uploader.js +12 -8
  132. package/esm/plugins/all.d.ts +1 -0
  133. package/esm/plugins/all.js +1 -0
  134. package/esm/plugins/anchor/anchor.d.ts +67 -0
  135. package/esm/plugins/anchor/anchor.js +302 -0
  136. package/esm/plugins/anchor/config.d.ts +6 -0
  137. package/esm/plugins/anchor/config.js +13 -0
  138. package/esm/plugins/file/file.d.ts +1 -1
  139. package/esm/plugins/file/file.js +6 -6
  140. package/esm/plugins/image/image.js +2 -2
  141. package/esm/plugins/image-caption/image-caption.js +1 -2
  142. package/esm/plugins/image-properties/utils/open-image-popup.js +7 -6
  143. package/esm/plugins/index.d.ts +1 -0
  144. package/esm/plugins/inline-popup/config/config.d.ts +8 -2
  145. package/esm/plugins/inline-popup/config/config.js +1 -0
  146. package/esm/plugins/inline-popup/config/items/cells.js +0 -10
  147. package/esm/plugins/inline-popup/config/items/img.js +1 -1
  148. package/esm/plugins/inline-popup/inline-popup.d.ts +9 -12
  149. package/esm/plugins/inline-popup/inline-popup.js +53 -77
  150. package/esm/plugins/link/link.js +150 -3
  151. package/esm/plugins/select/select.d.ts +31 -0
  152. package/esm/plugins/select/select.js +235 -2
  153. package/esm/plugins/select-cells/select-cells.d.ts +11 -0
  154. package/esm/plugins/select-cells/select-cells.js +48 -17
  155. package/esm/plugins/video/config.d.ts +1 -1
  156. package/esm/plugins/video/config.js +4 -3
  157. package/esm/plugins/video-properties/video-properties.js +7 -6
  158. package/esm/styles/icons/anchor.svg.js +1 -0
  159. package/esm/styles/icons/index.d.ts +1 -1
  160. package/esm/styles/icons/index.js +2 -1
  161. package/esm/types/file-browser.d.ts +8 -1
  162. package/esm/types/popup.d.ts +1 -0
  163. package/esm/types/uploader.d.ts +39 -1
  164. package/package.json +1 -1
  165. package/types/config.d.ts +10 -3
  166. package/types/core/helpers/utils/anchor.d.ts +22 -0
  167. package/types/core/helpers/utils/index.d.ts +1 -0
  168. package/types/core/ui/popup/popup.d.ts +5 -0
  169. package/types/langs/ar.d.ts +5 -0
  170. package/types/langs/az.d.ts +5 -0
  171. package/types/langs/cs_cz.d.ts +5 -0
  172. package/types/langs/de.d.ts +5 -0
  173. package/types/langs/es.d.ts +5 -0
  174. package/types/langs/fa.d.ts +5 -0
  175. package/types/langs/fi.d.ts +5 -0
  176. package/types/langs/fr.d.ts +5 -0
  177. package/types/langs/he.d.ts +5 -0
  178. package/types/langs/hu.d.ts +5 -0
  179. package/types/langs/id.d.ts +5 -0
  180. package/types/langs/it.d.ts +5 -0
  181. package/types/langs/ja.d.ts +5 -0
  182. package/types/langs/ko.d.ts +5 -0
  183. package/types/langs/mn.d.ts +5 -0
  184. package/types/langs/nl.d.ts +5 -0
  185. package/types/langs/no.d.ts +5 -0
  186. package/types/langs/pl.d.ts +5 -0
  187. package/types/langs/pt_br.d.ts +5 -0
  188. package/types/langs/ru.d.ts +5 -0
  189. package/types/langs/sk.d.ts +5 -0
  190. package/types/langs/sv.d.ts +5 -0
  191. package/types/langs/tr.d.ts +5 -0
  192. package/types/langs/ua.d.ts +5 -0
  193. package/types/langs/zh_cn.d.ts +5 -0
  194. package/types/langs/zh_tw.d.ts +5 -0
  195. package/types/modules/file-browser/file-browser.d.ts +3 -4
  196. package/types/modules/toolbar/button/button.d.ts +7 -0
  197. package/types/modules/uploader/helpers/index.d.ts +1 -0
  198. package/types/modules/uploader/helpers/normalize-uploader-data.d.ts +32 -0
  199. package/types/modules/uploader/uploader.d.ts +4 -5
  200. package/types/plugins/anchor/anchor.d.ts +67 -0
  201. package/types/plugins/anchor/config.d.ts +6 -0
  202. package/types/plugins/file/file.d.ts +1 -1
  203. package/types/plugins/index.d.ts +1 -0
  204. package/types/plugins/inline-popup/config/config.d.ts +8 -2
  205. package/types/plugins/inline-popup/inline-popup.d.ts +9 -12
  206. package/types/plugins/select/select.d.ts +31 -0
  207. package/types/plugins/select-cells/select-cells.d.ts +11 -0
  208. package/types/plugins/video/config.d.ts +1 -1
  209. package/types/styles/icons/index.d.ts +1 -1
  210. package/types/types/file-browser.d.ts +8 -1
  211. package/types/types/popup.d.ts +1 -0
  212. package/types/types/uploader.d.ts +39 -1
@@ -7,6 +7,7 @@ import { isArray } from "../../core/helpers/checker/is-array.js";
7
7
  import { isJoditObject } from "../../core/helpers/checker/is-jodit-object.js";
8
8
  import { attr } from "../../core/helpers/utils/attr.js";
9
9
  import { Config } from "../../config.js";
10
+ import { getItems } from "./helpers/normalize-uploader-data.js";
10
11
  /**
11
12
  * Module for processing download documents and images by Drag and Drop
12
13
  * Drag and Drop files
@@ -67,24 +68,23 @@ Config.prototype.uploader = {
67
68
  if (!isJoditObject(j)) {
68
69
  return;
69
70
  }
70
- if (resp.files && resp.files.length) {
71
- resp.files.forEach((filename, index) => {
72
- const [tagName, attrName] = resp.isImages && resp.isImages[index]
73
- ? ['img', 'src']
74
- : ['a', 'href'];
75
- const elm = j.createInside.element(tagName);
76
- attr(elm, attrName, resp.baseurl + filename);
77
- if (tagName === 'a') {
78
- elm.textContent = j.o.uploader.getDisplayName.call(this, resp.baseurl, filename);
79
- }
80
- if (tagName === 'img') {
81
- j.s.insertImage(elm, null, j.o.imageDefaultWidth);
82
- }
83
- else {
84
- j.s.insertNode(elm);
85
- }
86
- });
87
- }
71
+ const { baseurl } = resp;
72
+ getItems(resp).forEach(({ file, isImage }) => {
73
+ const [tagName, attrName] = isImage
74
+ ? ['img', 'src']
75
+ : ['a', 'href'];
76
+ const elm = j.createInside.element(tagName);
77
+ attr(elm, attrName, baseurl + file);
78
+ if (tagName === 'a') {
79
+ elm.textContent = j.o.uploader.getDisplayName.call(this, baseurl, file);
80
+ }
81
+ if (tagName === 'img') {
82
+ j.s.insertImage(elm, null, j.o.imageDefaultWidth);
83
+ }
84
+ else {
85
+ j.s.insertNode(elm);
86
+ }
87
+ });
88
88
  },
89
89
  defaultHandlerError(e) {
90
90
  this.j.message.error(e.message);
@@ -9,6 +9,7 @@
9
9
  import type { Nullable } from "../../../types/index";
10
10
  export * from "./build-data";
11
11
  export * from "./data-uri-to-blob";
12
+ export * from "./normalize-uploader-data";
12
13
  export * from "./process-old-browser-drag";
13
14
  export * from "./send";
14
15
  export * from "./send-files";
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export * from "./build-data.js";
7
7
  export * from "./data-uri-to-blob.js";
8
+ export * from "./normalize-uploader-data.js";
8
9
  export * from "./process-old-browser-drag.js";
9
10
  export * from "./send.js";
10
11
  export * from "./send-files.js";
@@ -0,0 +1,32 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * @module modules/uploader
8
+ */
9
+ import type { IUploadedFile, IUploaderData, IUploaderProcessData } from "../../../types/index";
10
+ type FilesData = Partial<Pick<IUploaderData, 'items' | 'files' | 'isImages' | 'fileNames'>>;
11
+ type Normalized<T> = T & IUploaderData & {
12
+ items: IUploadedFile[];
13
+ };
14
+ /**
15
+ * The files in upload or file browser data, one object each. While the
16
+ * deprecated `files` array is set, it and `isImages` and `fileNames` win
17
+ * over `items`, so a handler that edits them and passes the data on to a
18
+ * default handler still gets its edits inserted. A file browser that
19
+ * passes only the arrays works too.
20
+ */
21
+ export declare function getItems(data: FilesData): IUploadedFile[];
22
+ /**
23
+ * Gives the data both `items` and the deprecated `files`, `isImages` and
24
+ * `fileNames` arrays, building whichever is missing, so a handler can read
25
+ * either. When both are given, `items` is rebuilt from the arrays, as in
26
+ * [[getItems]], unless `files` is empty and `items` isn't, as from a
27
+ * `process` that spreads the server's answer and adds `items`. Anything but
28
+ * an object, such as the `null` a custom `process` may return, is passed on
29
+ * as it is.
30
+ */
31
+ export declare function normalizeUploaderData<T extends IUploaderProcessData>(data: T): Normalized<T>;
32
+ export {};
@@ -0,0 +1,54 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ import { isArray } from "../../../core/helpers/checker/is-array.js";
7
+ import { isString } from "../../../core/helpers/checker/is-string.js";
8
+ /**
9
+ * The files in upload or file browser data, one object each. While the
10
+ * deprecated `files` array is set, it and `isImages` and `fileNames` win
11
+ * over `items`, so a handler that edits them and passes the data on to a
12
+ * default handler still gets its edits inserted. A file browser that
13
+ * passes only the arrays works too.
14
+ */
15
+ export function getItems(data) {
16
+ const { files, isImages, fileNames, items } = data;
17
+ if (!isArray(files)) {
18
+ return items !== null && items !== void 0 ? items : [];
19
+ }
20
+ return files.map((file, i) => {
21
+ const name = fileNames === null || fileNames === void 0 ? void 0 : fileNames[i];
22
+ return {
23
+ file,
24
+ isImage: Boolean(isImages === null || isImages === void 0 ? void 0 : isImages[i]),
25
+ ...(name !== undefined ? { name } : {})
26
+ };
27
+ });
28
+ }
29
+ /**
30
+ * Gives the data both `items` and the deprecated `files`, `isImages` and
31
+ * `fileNames` arrays, building whichever is missing, so a handler can read
32
+ * either. When both are given, `items` is rebuilt from the arrays, as in
33
+ * [[getItems]], unless `files` is empty and `items` isn't, as from a
34
+ * `process` that spreads the server's answer and adds `items`. Anything but
35
+ * an object, such as the `null` a custom `process` may return, is passed on
36
+ * as it is.
37
+ */
38
+ export function normalizeUploaderData(data) {
39
+ if (!data || typeof data !== 'object') {
40
+ return data;
41
+ }
42
+ const { files, items } = data;
43
+ if (!items || (isArray(files) && (files.length || !items.length))) {
44
+ return { ...data, items: getItems(data) };
45
+ }
46
+ const names = items.map(({ name }) => name);
47
+ return {
48
+ ...data,
49
+ files: items.map(({ file }) => file),
50
+ isImages: items.map(({ isImage }) => isImage),
51
+ ...(names.every(isString) ? { fileNames: names } : {}),
52
+ items
53
+ };
54
+ }
@@ -7,6 +7,7 @@ import { ERROR_CODE_CONFLICT } from "../../../core/constants.js";
7
7
  import { error, isArray, isFunction, isPlainObject, toArray } from "../../../core/helpers/index.js";
8
8
  import { Dlgs } from "../../../core/traits/dlgs.js";
9
9
  import { Prompt } from "../../dialog/prompt.js";
10
+ import { normalizeUploaderData } from "./normalize-uploader-data.js";
10
11
  import { send } from "./send.js";
11
12
  import { UploadError } from "./upload-error.js";
12
13
  /**
@@ -103,7 +104,7 @@ retryOf) {
103
104
  const handler = isFunction(handlerSuccess)
104
105
  ? handlerSuccess
105
106
  : o.defaultHandlerSuccess;
106
- handler.call(uploader, o.process.call(uploader, resp));
107
+ handler.call(uploader, normalizeUploaderData(o.process.call(uploader, resp)));
107
108
  return resp;
108
109
  }
109
110
  const err = new UploadError(o.getMessage.call(uploader, resp), resp, fileList, plan => {
@@ -171,12 +172,16 @@ function readImagesWithReader(fileList, imagesExtensions, promises, uploader, ha
171
172
  const readerPromise = uploader.j.async.promise((resolve, reject) => {
172
173
  reader.onerror = reject;
173
174
  reader.onloadend = () => {
174
- const resp = {
175
+ const resp = normalizeUploaderData({
175
176
  baseurl: '',
176
- files: [reader.result],
177
- isImages: [true],
178
- fileNames: [name]
179
- };
177
+ items: [
178
+ {
179
+ file: reader.result,
180
+ isImage: true,
181
+ name
182
+ }
183
+ ]
184
+ });
180
185
  const handler = isFunction(handlerSuccess)
181
186
  ? handlerSuccess
182
187
  : defaultHandlerSuccess;
@@ -40,11 +40,10 @@ export declare class Uploader extends ViewComponent implements IUploader {
40
40
  * ```javascript
41
41
  * var $form = jQuery('<form><input type="text" typpe="file"></form>');
42
42
  * jQuery('body').append($form);
43
- * Jodit.editors.someidfoeditor.uploader.bind($form[0], function (files) {
44
- * var i;
45
- * for (i = 0; i < data.files.length; i += 1) {
46
- * parent.s.insertImage(data.files[i])
47
- * }
43
+ * Jodit.editors.someidfoeditor.uploader.bind($form[0], function (data) {
44
+ * data.items.forEach(function (item) {
45
+ * parent.s.insertImage(data.baseurl + item.file);
46
+ * });
48
47
  * });
49
48
  * ```
50
49
  */
@@ -9,7 +9,7 @@ import { Dom } from "../../core/dom/dom.js";
9
9
  import { attr, ConfigProto, isFunction, isJoditObject } from "../../core/helpers/index.js";
10
10
  import { answer } from "../../core/helpers/utils/error/index.js";
11
11
  import { Config } from "../../config.js";
12
- import { ajaxInstances, hasFiles, hasItems, processOldBrowserDrag, send, sendFiles } from "./helpers/index.js";
12
+ import { ajaxInstances, hasFiles, hasItems, normalizeUploaderData, processOldBrowserDrag, send, sendFiles } from "./helpers/index.js";
13
13
  import "./config.js";
14
14
  export class Uploader extends ViewComponent {
15
15
  get j() {
@@ -48,11 +48,10 @@ export class Uploader extends ViewComponent {
48
48
  * ```javascript
49
49
  * var $form = jQuery('<form><input type="text" typpe="file"></form>');
50
50
  * jQuery('body').append($form);
51
- * Jodit.editors.someidfoeditor.uploader.bind($form[0], function (files) {
52
- * var i;
53
- * for (i = 0; i < data.files.length; i += 1) {
54
- * parent.s.insertImage(data.files[i])
55
- * }
51
+ * Jodit.editors.someidfoeditor.uploader.bind($form[0], function (data) {
52
+ * data.items.forEach(function (item) {
53
+ * parent.s.insertImage(data.baseurl + item.file);
54
+ * });
56
55
  * });
57
56
  * ```
58
57
  */
@@ -168,7 +167,7 @@ export class Uploader extends ViewComponent {
168
167
  const handler = isFunction(handlerSuccess)
169
168
  ? handlerSuccess
170
169
  : o.defaultHandlerSuccess;
171
- handler.call(uploader, o.process.call(uploader, resp));
170
+ handler.call(uploader, normalizeUploaderData(o.process.call(uploader, resp)));
172
171
  return;
173
172
  }
174
173
  handlerE.call(uploader, answer(o.getMessage.call(uploader, resp), resp, (_a = resp.data) === null || _a === void 0 ? void 0 : _a.code));
@@ -185,7 +184,12 @@ export class Uploader extends ViewComponent {
185
184
  sendFiles(this, files, settle(resolve), settle(reject)).then(() => {
186
185
  // `beforeUpload` kept no file, so no handler ran
187
186
  if (!settled) {
188
- resolve({ baseurl: '', files: [], isImages: [] });
187
+ resolve({
188
+ baseurl: '',
189
+ items: [],
190
+ files: [],
191
+ isImages: []
192
+ });
189
193
  }
190
194
  }, settle(reject));
191
195
  });
@@ -40,6 +40,7 @@ import "./key-arrow-outside/key-arrow-outside";
40
40
  import "./limit/limit";
41
41
  import "./line-height/line-height";
42
42
  import "./link/link";
43
+ import "./anchor/anchor";
43
44
  import "./media/media";
44
45
  import "./mobile/mobile";
45
46
  import "./ordered-list/ordered-list";
@@ -41,6 +41,7 @@ import "./key-arrow-outside/key-arrow-outside.js";
41
41
  import "./limit/limit.js";
42
42
  import "./line-height/line-height.js";
43
43
  import "./link/link.js";
44
+ import "./anchor/anchor.js";
44
45
  import "./media/media.js";
45
46
  import "./mobile/mobile.js";
46
47
  import "./ordered-list/ordered-list.js";
@@ -0,0 +1,67 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ /**
7
+ * [[include:plugins/anchor/README.md]]
8
+ * @packageDocumentation
9
+ * @module plugins/anchor
10
+ */
11
+ import type { IJodit } from "../../types/index";
12
+ import { Plugin } from "../../core/plugin/index";
13
+ import "./config";
14
+ /**
15
+ * Inserts anchors, empty `<a id>` that links in the document reach as
16
+ * `#name`, and renames and removes them
17
+ */
18
+ export declare class anchor extends Plugin {
19
+ /** @override */
20
+ buttons: Plugin['buttons'];
21
+ /** @override */
22
+ protected afterInit(jodit: IJodit): void;
23
+ /**
24
+ * An anchor gets its own popup, in place of the link's
25
+ */
26
+ private __onClickA;
27
+ /**
28
+ * Anchors are uneditable in the editor, so typing beside one never goes
29
+ * into it and it's deleted as a whole
30
+ */
31
+ protected onChange(): void;
32
+ /**
33
+ * The editor's own attribute stays out of the value
34
+ */
35
+ protected onAfterGetValueFromEditor(data: {
36
+ value: string;
37
+ }): void;
38
+ /**
39
+ * The form that names a new anchor, or renames or removes `target`
40
+ */
41
+ private __generateForm;
42
+ /**
43
+ * The form in the anchor's own popup. The popup takes it out without
44
+ * destructing it when it shows something else, so it goes when the next
45
+ * one is made
46
+ */
47
+ private __form;
48
+ private __dropForm;
49
+ /**
50
+ * Another element in the document has the name as its `id`, or another
51
+ * anchor as its `name`
52
+ */
53
+ private __isTaken;
54
+ /**
55
+ * At the caret, or at the start of the selection. An anchor can't go in
56
+ * a link, so in one it goes just before it
57
+ */
58
+ private __insert;
59
+ /**
60
+ * Gives the anchor the new name in whichever of `id` and `name` it has,
61
+ * and the links to it the new `#name`, unless they still reach
62
+ * something else by the old one, as they do after a copy is pasted
63
+ */
64
+ private __rename;
65
+ /** @override */
66
+ protected beforeDestruct(jodit: IJodit): void;
67
+ }
@@ -0,0 +1,302 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
9
+ r = Reflect.decorate(decorators, target, key, desc);
10
+ else
11
+ for (var i = decorators.length - 1; i >= 0; i--)
12
+ if (d = decorators[i])
13
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
14
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
15
+ };
16
+ import * as consts from "../../core/constants.js";
17
+ import { autobind, debounce, watch } from "../../core/decorators/index.js";
18
+ import { Dom } from "../../core/dom/dom.js";
19
+ import { getContainer, pluginSystem } from "../../core/global.js";
20
+ import { attr, camelCase, getAnchorName, getAnchors, isAnchor, position, toArray } from "../../core/helpers/index.js";
21
+ import { Plugin } from "../../core/plugin/index.js";
22
+ import { UIButton } from "../../core/ui/button/index.js";
23
+ import { UIBlock, UIForm, UIInput } from "../../core/ui/form/index.js";
24
+ import "./config.js";
25
+ const ICON = "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e88e5' stroke-width='2.5' stroke-linejoin='round'%3E%3Cpath d='M6 3h12v18l-6-4-6 4z'/%3E%3C/svg%3E\")";
26
+ const MARKER = ['id', 'name']
27
+ .map(key => `.jodit-wysiwyg a[${key}]:not([href]):empty::before`)
28
+ .join(',');
29
+ /**
30
+ * Each anchor's marker, in the editing area only
31
+ */
32
+ const MARKER_STYLE = `${MARKER}{display:inline-block;width:.75em;height:1em;margin:0 .1em;vertical-align:-.15em;background:${ICON} center/contain no-repeat;cursor:pointer;content:''}`;
33
+ /**
34
+ * The attribute `markAnchor` gives an anchor: an empty `<a>` with no `href`
35
+ */
36
+ const MARK = ' contenteditable="false"';
37
+ /**
38
+ * Inserts anchors, empty `<a id>` that links in the document reach as
39
+ * `#name`, and renames and removes them
40
+ */
41
+ export class anchor extends Plugin {
42
+ constructor() {
43
+ super(...arguments);
44
+ /** @override */
45
+ this.buttons = [
46
+ {
47
+ name: 'anchor',
48
+ group: 'insert'
49
+ }
50
+ ];
51
+ /**
52
+ * The form in the anchor's own popup. The popup takes it out without
53
+ * destructing it when it shows something else, so it goes when the next
54
+ * one is made
55
+ */
56
+ this.__form = null;
57
+ }
58
+ /** @override */
59
+ afterInit(jodit) {
60
+ // It goes in the editing document, so iframe mode has it whatever `iframeStyle` holds
61
+ getContainer(jodit, 'anchor', 'style', true).textContent = MARKER_STYLE;
62
+ jodit.e
63
+ .on('generateAnchorForm.anchor', this.__generateForm)
64
+ .on('clickA touchstartA', this.__onClickA, { top: true });
65
+ }
66
+ /**
67
+ * An anchor gets its own popup, in place of the link's
68
+ */
69
+ __onClickA(target, e) {
70
+ var _a;
71
+ const { j } = this;
72
+ if (j.o.readonly || !isAnchor(target)) {
73
+ return;
74
+ }
75
+ j.e.stopPropagation(camelCase(((_a = e === null || e === void 0 ? void 0 : e.type) !== null && _a !== void 0 ? _a : 'click') + '_a'));
76
+ // Afresh, so a form left with a change unsaved shows the name it has
77
+ j.e.fire('showPopup', target, () => position(target, j), 'anchor', true);
78
+ return false;
79
+ }
80
+ /**
81
+ * Anchors are uneditable in the editor, so typing beside one never goes
82
+ * into it and it's deleted as a whole
83
+ */
84
+ onChange() {
85
+ const { j } = this;
86
+ if (j.isInDestruct || j.getMode() === consts.MODE_SOURCE) {
87
+ return;
88
+ }
89
+ getAnchors(j.editor).forEach(markAnchor);
90
+ }
91
+ /**
92
+ * The editor's own attribute stays out of the value
93
+ */
94
+ onAfterGetValueFromEditor(data) {
95
+ data.value = unmarkAnchors(data.value);
96
+ }
97
+ /**
98
+ * The form that names a new anchor, or renames or removes `target`
99
+ */
100
+ __generateForm(target, close) {
101
+ const { j } = this;
102
+ const current = isAnchor(target) ? target : null;
103
+ const input = new UIInput(j, {
104
+ name: 'name',
105
+ ref: 'name_input',
106
+ label: 'Anchor',
107
+ required: true
108
+ });
109
+ const buttons = [
110
+ new UIButton(j, {
111
+ name: 'insert',
112
+ type: 'submit',
113
+ variant: 'primary',
114
+ text: current ? 'Update' : 'Insert'
115
+ })
116
+ ];
117
+ if (current) {
118
+ input.value = getAnchorName(current);
119
+ buttons.unshift(new UIButton(j, {
120
+ name: 'remove',
121
+ variant: 'default',
122
+ text: 'Remove'
123
+ }).onAction(() => {
124
+ if (!j.o.readonly) {
125
+ j.s.restore();
126
+ Dom.safeRemove(current);
127
+ j.synchronizeValues();
128
+ }
129
+ close();
130
+ }));
131
+ }
132
+ const form = new UIForm(j, [
133
+ new UIBlock(j, [input]),
134
+ new UIBlock(j, buttons, { align: 'full' })
135
+ ]);
136
+ if (current) {
137
+ this.__dropForm();
138
+ this.__form = form;
139
+ // The toolbar's popup closes on Escape by itself; the anchor's own doesn't
140
+ j.e.on(form.container, 'keydown', (e) => {
141
+ if (e.key === consts.KEY_ESC) {
142
+ close();
143
+ j.s.restore();
144
+ }
145
+ });
146
+ }
147
+ form.onSubmit(() => {
148
+ // The editor can turn readonly while the form is open
149
+ if (j.o.readonly) {
150
+ close();
151
+ return false;
152
+ }
153
+ const name = input.value.trim().replace(/^#/, '');
154
+ const error = !name
155
+ ? 'Please fill out this field'
156
+ : /\s/.test(name)
157
+ ? 'The name cannot contain spaces'
158
+ : this.__isTaken(name, current)
159
+ ? 'This name is already in use'
160
+ : '';
161
+ if (error) {
162
+ input.error = error;
163
+ input.focus();
164
+ return false;
165
+ }
166
+ j.s.restore();
167
+ if (current) {
168
+ this.__rename(current, name);
169
+ }
170
+ else {
171
+ this.__insert(name);
172
+ }
173
+ j.synchronizeValues();
174
+ close();
175
+ return false;
176
+ });
177
+ j.async.requestIdleCallback(() => input.focus());
178
+ return form;
179
+ }
180
+ __dropForm() {
181
+ const form = this.__form;
182
+ this.__form = null;
183
+ if (form && !form.isInDestruct) {
184
+ this.j.e.off(form.container, 'keydown');
185
+ form.destruct();
186
+ }
187
+ }
188
+ /**
189
+ * Another element in the document has the name as its `id`, or another
190
+ * anchor as its `name`
191
+ */
192
+ __isTaken(name, current) {
193
+ return toArray(this.j.editor.querySelectorAll('[id], a[name]')).some(elm => elm !== current &&
194
+ (elm.id === name ||
195
+ (isAnchor(elm) && attr(elm, 'name') === name)));
196
+ }
197
+ /**
198
+ * At the caret, or at the start of the selection. An anchor can't go in
199
+ * a link, so in one it goes just before it
200
+ */
201
+ __insert(name) {
202
+ const { j } = this;
203
+ const anchor = j.createInside.element('a', { id: name });
204
+ const range = j.s.range;
205
+ markAnchor(anchor);
206
+ if (!range.collapsed) {
207
+ range.collapse(true);
208
+ j.s.selectRange(range);
209
+ }
210
+ const link = Dom.closest(range.startContainer, 'a', j.editor);
211
+ if (link) {
212
+ Dom.before(link, anchor);
213
+ j.s.setCursorAfter(anchor);
214
+ }
215
+ else {
216
+ j.s.insertNode(anchor, true, false);
217
+ }
218
+ }
219
+ /**
220
+ * Gives the anchor the new name in whichever of `id` and `name` it has,
221
+ * and the links to it the new `#name`, unless they still reach
222
+ * something else by the old one, as they do after a copy is pasted
223
+ */
224
+ __rename(current, name) {
225
+ const old = getAnchorName(current);
226
+ const shared = this.__isTaken(old, current);
227
+ ['id', 'name'].forEach(key => {
228
+ if (current.hasAttribute(key)) {
229
+ attr(current, key, name);
230
+ }
231
+ });
232
+ if (shared) {
233
+ return;
234
+ }
235
+ toArray(this.j.editor.querySelectorAll('a[href]')).forEach(link => {
236
+ if (attr(link, 'href') === '#' + old) {
237
+ attr(link, 'href', '#' + name);
238
+ }
239
+ });
240
+ }
241
+ /** @override */
242
+ beforeDestruct(jodit) {
243
+ this.__dropForm();
244
+ jodit.e
245
+ .off('generateAnchorForm.anchor', this.__generateForm)
246
+ .off('clickA touchstartA', this.__onClickA);
247
+ }
248
+ }
249
+ __decorate([
250
+ autobind
251
+ ], anchor.prototype, "__onClickA", null);
252
+ __decorate([
253
+ watch([':change', ':afterInit', ':afterSetMode']),
254
+ debounce()
255
+ ], anchor.prototype, "onChange", null);
256
+ __decorate([
257
+ watch(':afterGetValueFromEditor')
258
+ ], anchor.prototype, "onAfterGetValueFromEditor", null);
259
+ __decorate([
260
+ autobind
261
+ ], anchor.prototype, "__generateForm", null);
262
+ function markAnchor(anchor) {
263
+ if (attr(anchor, 'contenteditable') !== 'false') {
264
+ attr(anchor, 'contenteditable', false);
265
+ }
266
+ }
267
+ /**
268
+ * Takes `MARK` off each anchor in one pass over the tags, as a regex with
269
+ * `[^>]*` backtracks quadratically on a long run of `<a` (CWE-1333)
270
+ */
271
+ function unmarkAnchors(html) {
272
+ if (!html.includes(MARK)) {
273
+ return html;
274
+ }
275
+ let result = '';
276
+ let copied = 0;
277
+ let cursor = 0;
278
+ for (;;) {
279
+ const start = html.indexOf('<', cursor);
280
+ if (start === -1) {
281
+ break;
282
+ }
283
+ const end = html.indexOf('>', start);
284
+ if (end === -1) {
285
+ break;
286
+ }
287
+ if (html.startsWith('<a', start) &&
288
+ /\s/.test(html.charAt(start + 2)) &&
289
+ html.startsWith('</a>', end + 1)) {
290
+ const tag = html.slice(start, end);
291
+ const at = tag.indexOf(MARK);
292
+ if (at !== -1 && !/\shref=/.test(tag)) {
293
+ result += html.slice(copied, start + at);
294
+ copied = start + at + MARK.length;
295
+ }
296
+ }
297
+ // Past the whole tag, so an `<a` inside one of its attributes is never read as a tag
298
+ cursor = end + 1;
299
+ }
300
+ return copied === 0 ? html : result + html.slice(copied);
301
+ }
302
+ pluginSystem.add('anchor', anchor);
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ import "../inline-popup/config/config";
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Jodit Editor (https://xdsoft.net/jodit/)
3
+ * Released under MIT see LICENSE.txt in the project root for license information.
4
+ * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
5
+ */
6
+ import { Config } from "../../config.js";
7
+ // The anchor's popup goes in its list
8
+ import "../inline-popup/config/config.js";
9
+ Config.prototype.controls.anchor = {
10
+ popup: (editor, current, close) => editor.e.fire('generateAnchorForm.anchor', null, close),
11
+ tooltip: 'Insert anchor'
12
+ };
13
+ Config.prototype.popup.anchor = (editor, target, close) => editor.e.fire('generateAnchorForm.anchor', target, close);