jodit 4.19.7 → 4.19.9
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.
- package/CHANGELOG.md +22 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +9 -9
- package/es2015/jodit.js +336 -117
- package/es2015/jodit.min.js +5 -5
- package/es2015/plugins/debug/debug.css +1 -1
- package/es2015/plugins/debug/debug.js +1 -1
- package/es2015/plugins/debug/debug.min.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2018/jodit.fat.min.js +9 -9
- package/es2018/jodit.min.js +5 -5
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.js +11 -11
- package/es2021/jodit.js +267 -59
- package/es2021/jodit.min.js +57 -57
- package/es2021/plugins/debug/debug.css +1 -1
- package/es2021/plugins/debug/debug.js +1 -1
- package/es2021/plugins/debug/debug.min.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.js +7 -7
- package/es2021.en/jodit.js +267 -59
- package/es2021.en/jodit.min.js +7 -7
- package/es2021.en/plugins/debug/debug.css +1 -1
- package/es2021.en/plugins/debug/debug.js +1 -1
- package/es2021.en/plugins/debug/debug.min.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +416 -119
- package/es5/jodit.min.css +2 -2
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.css +1 -1
- package/es5/plugins/debug/debug.js +1 -1
- package/es5/plugins/debug/debug.min.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/polyfills.fat.min.js +1 -1
- package/es5/polyfills.js +1 -1
- package/es5/polyfills.min.js +1 -1
- package/esm/core/constants.d.ts +1 -0
- package/esm/core/constants.js +3 -1
- package/esm/core/helpers/utils/error/error.d.ts +1 -0
- package/esm/core/helpers/utils/error/error.js +4 -1
- package/esm/core/helpers/utils/error/errors/answer-error.d.ts +13 -0
- package/esm/core/helpers/utils/error/errors/answer-error.js +17 -0
- package/esm/core/helpers/utils/error/errors/index.d.ts +1 -0
- package/esm/core/helpers/utils/error/errors/index.js +1 -0
- package/esm/core/helpers/utils/scroll-into-view.js +9 -2
- package/esm/core/request/ajax.d.ts +1 -0
- package/esm/core/request/ajax.js +20 -1
- package/esm/core/selection/selection.js +7 -4
- package/esm/modules/file-browser/data-provider.js +5 -3
- package/esm/modules/uploader/config.js +4 -0
- package/esm/modules/uploader/helpers/send-files.d.ts +2 -2
- package/esm/modules/uploader/helpers/send-files.js +76 -9
- package/esm/modules/uploader/helpers/upload-error.d.ts +15 -0
- package/esm/modules/uploader/helpers/upload-error.js +16 -0
- package/esm/modules/uploader/uploader.js +15 -3
- package/esm/plugins/enter/helpers/check-br.js +7 -1
- package/esm/plugins/font/config.js +8 -8
- package/esm/plugins/hotkeys/hotkeys.js +11 -0
- package/esm/types/uploader.d.ts +117 -11
- package/package.json +2 -2
- package/types/core/constants.d.ts +1 -0
- package/types/core/helpers/utils/error/error.d.ts +1 -0
- package/types/core/helpers/utils/error/errors/answer-error.d.ts +13 -0
- package/types/core/helpers/utils/error/errors/index.d.ts +1 -0
- package/types/core/request/ajax.d.ts +1 -0
- package/types/modules/uploader/helpers/send-files.d.ts +2 -2
- package/types/modules/uploader/helpers/upload-error.d.ts +15 -0
- package/types/types/uploader.d.ts +117 -11
package/es5/polyfills.fat.min.js
CHANGED
package/es5/polyfills.js
CHANGED
package/es5/polyfills.min.js
CHANGED
package/esm/core/constants.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ export declare const INSERT_AS_TEXT = "insert_as_text";
|
|
|
130
130
|
*/
|
|
131
131
|
export declare const INSERT_ONLY_TEXT = "insert_only_text";
|
|
132
132
|
export declare const SAFE_COUNT_CHANGE_CALL = 10;
|
|
133
|
+
export declare const ERROR_CODE_CONFLICT = 409;
|
|
133
134
|
export declare const IS_MAC: boolean;
|
|
134
135
|
export declare const KEY_ALIASES: IDictionary<string>;
|
|
135
136
|
/**
|
package/esm/core/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
export const APP_VERSION = "4.19.
|
|
6
|
+
export const APP_VERSION = "4.19.9";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
|
@@ -152,6 +152,8 @@ export const INSERT_AS_TEXT = 'insert_as_text';
|
|
|
152
152
|
*/
|
|
153
153
|
export const INSERT_ONLY_TEXT = 'insert_only_text';
|
|
154
154
|
export const SAFE_COUNT_CHANGE_CALL = 10;
|
|
155
|
+
// Connector answer code for a file name that is already taken (same as the HTTP status)
|
|
156
|
+
export const ERROR_CODE_CONFLICT = 409;
|
|
155
157
|
export const IS_MAC = typeof globalWindow !== 'undefined' &&
|
|
156
158
|
/Mac|iPod|iPhone|iPad/.test(globalWindow.navigator.platform);
|
|
157
159
|
export const KEY_ALIASES = {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @module helpers/utils
|
|
8
8
|
*/
|
|
9
|
-
import { ConnectionError, OptionsError } from "./errors/index.js";
|
|
9
|
+
import { AnswerError, ConnectionError, OptionsError } from "./errors/index.js";
|
|
10
10
|
/**
|
|
11
11
|
* Helper for create Error object
|
|
12
12
|
*/
|
|
@@ -19,3 +19,6 @@ export function connection(message) {
|
|
|
19
19
|
export function options(message) {
|
|
20
20
|
return new OptionsError(message);
|
|
21
21
|
}
|
|
22
|
+
export function answer(message, resp, code) {
|
|
23
|
+
return new AnswerError(message, resp, code);
|
|
24
|
+
}
|
|
@@ -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
|
+
/**
|
|
7
|
+
* @module helpers/utils
|
|
8
|
+
*/
|
|
9
|
+
export declare class AnswerError<T = unknown> extends Error {
|
|
10
|
+
readonly answer: T;
|
|
11
|
+
readonly code?: number | undefined;
|
|
12
|
+
constructor(message: string, answer: T, code?: number | undefined);
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 helpers/utils
|
|
8
|
+
*/
|
|
9
|
+
// A connector refused the request: the answer and its `data.code` stay reachable for the handler
|
|
10
|
+
export class AnswerError extends Error {
|
|
11
|
+
constructor(message, answer, code) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.answer = answer;
|
|
14
|
+
this.code = code;
|
|
15
|
+
Object.setPrototypeOf(this, AnswerError.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -20,6 +20,7 @@ const SUBPIXEL_TOLERANCE = 1;
|
|
|
20
20
|
* Check if element is in view
|
|
21
21
|
*/
|
|
22
22
|
export function inView(elm, root, doc) {
|
|
23
|
+
var _a;
|
|
23
24
|
let rect = elm.getBoundingClientRect(), el = elm;
|
|
24
25
|
const top = rect.top, height = rect.height;
|
|
25
26
|
while (el && el !== root && el.parentNode) {
|
|
@@ -44,8 +45,14 @@ export function inView(elm, root, doc) {
|
|
|
44
45
|
// element scrolled above the top was wrongly reported as visible and never
|
|
45
46
|
// scrolled to. See #1279
|
|
46
47
|
const clientHeight = (doc.documentElement && doc.documentElement.clientHeight) || 0;
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
// `scrollIntoView` keeps clear of the document's `scroll-padding`, which
|
|
49
|
+
// is how a page allows for a fixed header or footer, so its edges are the
|
|
50
|
+
// viewport's edges here too
|
|
51
|
+
const style = (_a = doc.defaultView) === null || _a === void 0 ? void 0 : _a.getComputedStyle(doc.documentElement), padding = (value = '') => value.endsWith('%')
|
|
52
|
+
? (parseFloat(value) * clientHeight) / 100
|
|
53
|
+
: parseFloat(value) || 0, viewTop = padding(style === null || style === void 0 ? void 0 : style.scrollPaddingTop), viewBottom = clientHeight - padding(style === null || style === void 0 ? void 0 : style.scrollPaddingBottom);
|
|
54
|
+
return ((top + height <= viewBottom + SUBPIXEL_TOLERANCE || top <= viewTop) &&
|
|
55
|
+
top + height >= viewTop);
|
|
49
56
|
}
|
|
50
57
|
/**
|
|
51
58
|
* Scroll element into view if it is not in view
|
|
@@ -21,6 +21,7 @@ export declare class Ajax<T extends object = any> implements IAjax<T> {
|
|
|
21
21
|
get o(): this['options'];
|
|
22
22
|
abort(): Ajax;
|
|
23
23
|
private __isFulfilled;
|
|
24
|
+
private __hasAnswerEnvelope;
|
|
24
25
|
private __activated;
|
|
25
26
|
send(): RejectablePromise<IResponse<T>>;
|
|
26
27
|
stream(): AsyncGenerator<string>;
|
package/esm/core/request/ajax.js
CHANGED
|
@@ -63,6 +63,24 @@ export class Ajax {
|
|
|
63
63
|
catch (_a) { }
|
|
64
64
|
return this;
|
|
65
65
|
}
|
|
66
|
+
// 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
|
|
67
|
+
__hasAnswerEnvelope() {
|
|
68
|
+
const { xhr } = this;
|
|
69
|
+
if (xhr.responseType && xhr.responseType !== 'text') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const text = xhr.responseText;
|
|
73
|
+
if (!text || text[0] !== '{') {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const answer = JSON.parse(text);
|
|
78
|
+
return isPlainObject(answer) && 'success' in answer;
|
|
79
|
+
}
|
|
80
|
+
catch (_a) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
66
84
|
send() {
|
|
67
85
|
this.__activated = true;
|
|
68
86
|
const { xhr, o } = this;
|
|
@@ -99,7 +117,8 @@ export class Ajax {
|
|
|
99
117
|
var _a, _b;
|
|
100
118
|
(_b = (_a = this.options).onProgress) === null || _b === void 0 ? void 0 : _b.call(_a, 10);
|
|
101
119
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
102
|
-
if (o.successStatuses.includes(xhr.status)
|
|
120
|
+
if (o.successStatuses.includes(xhr.status) ||
|
|
121
|
+
this.__hasAnswerEnvelope()) {
|
|
103
122
|
onResolve();
|
|
104
123
|
}
|
|
105
124
|
else if (xhr.statusText) {
|
|
@@ -669,7 +669,9 @@ export class Selection {
|
|
|
669
669
|
}
|
|
670
670
|
if (sel && sel.rangeCount) {
|
|
671
671
|
const range = sel.getRangeAt(0);
|
|
672
|
-
|
|
672
|
+
// A block has no first child outside itself to go by, and what's
|
|
673
|
+
// left beside it would show as a line of its own
|
|
674
|
+
const isBlock = Dom.isBlock(node), first = isBlock ? node : node.firstChild;
|
|
673
675
|
if (Dom.isOrContains(this.area, range.commonAncestorContainer)) {
|
|
674
676
|
Dom.safeInsertNode(range, node);
|
|
675
677
|
}
|
|
@@ -677,9 +679,10 @@ export class Selection {
|
|
|
677
679
|
Dom.append(this.area, node);
|
|
678
680
|
}
|
|
679
681
|
[
|
|
680
|
-
() =>
|
|
681
|
-
() =>
|
|
682
|
-
() => { var _a; return (_a =
|
|
682
|
+
() => first === null || first === void 0 ? void 0 : first.previousSibling,
|
|
683
|
+
() => first === null || first === void 0 ? void 0 : first.previousSibling,
|
|
684
|
+
() => { var _a; return (_a = first === null || first === void 0 ? void 0 : first.previousSibling) === null || _a === void 0 ? void 0 : _a.lastChild; },
|
|
685
|
+
() => isBlock ? node.nextSibling : null
|
|
683
686
|
].forEach(getChildNode => {
|
|
684
687
|
const childNode = getChildNode();
|
|
685
688
|
// Only a text node left with nothing in it by the split
|
|
@@ -20,7 +20,7 @@ import { isFunction } from "../../core/helpers/checker/is-function.js";
|
|
|
20
20
|
import { isPlainObject } from "../../core/helpers/checker/is-plain-object.js";
|
|
21
21
|
import { normalizeRelativePath } from "../../core/helpers/normalize/normalize-relative-path.js";
|
|
22
22
|
import { ConfigProto } from "../../core/helpers/utils/config-proto.js";
|
|
23
|
-
import { abort, error } from "../../core/helpers/utils/error/index.js";
|
|
23
|
+
import { abort, answer, error } from "../../core/helpers/utils/error/index.js";
|
|
24
24
|
import { set } from "../../core/helpers/utils/set.js";
|
|
25
25
|
import { Ajax } from "../../core/request/ajax.js";
|
|
26
26
|
import { FileBrowserItem } from "./builders/item.js";
|
|
@@ -140,8 +140,9 @@ export default class DataProvider {
|
|
|
140
140
|
return promise
|
|
141
141
|
.then(resp => resp.json())
|
|
142
142
|
.then(resp => {
|
|
143
|
+
var _a;
|
|
143
144
|
if (resp && !this.isSuccess(resp)) {
|
|
144
|
-
throw
|
|
145
|
+
throw answer(this.getMessage(resp), resp, (_a = resp.data) === null || _a === void 0 ? void 0 : _a.code);
|
|
145
146
|
}
|
|
146
147
|
return resp;
|
|
147
148
|
});
|
|
@@ -288,10 +289,11 @@ export default class DataProvider {
|
|
|
288
289
|
getPathByUrl(url) {
|
|
289
290
|
set('options.getLocalFileByUrl.data.url', url, this);
|
|
290
291
|
return this.get('getLocalFileByUrl').then(resp => {
|
|
292
|
+
var _a;
|
|
291
293
|
if (this.isSuccess(resp)) {
|
|
292
294
|
return resp.data;
|
|
293
295
|
}
|
|
294
|
-
throw
|
|
296
|
+
throw answer(this.getMessage(resp), resp, (_a = resp.data) === null || _a === void 0 ? void 0 : _a.code);
|
|
295
297
|
});
|
|
296
298
|
}
|
|
297
299
|
/**
|
|
@@ -89,6 +89,10 @@ Config.prototype.uploader = {
|
|
|
89
89
|
defaultHandlerError(e) {
|
|
90
90
|
this.j.message.error(e.message);
|
|
91
91
|
},
|
|
92
|
+
promptOnExists: true,
|
|
93
|
+
promptOnExistsSuggestName(name) {
|
|
94
|
+
return name;
|
|
95
|
+
},
|
|
92
96
|
contentType(requestData) {
|
|
93
97
|
return this.ow.FormData !== undefined &&
|
|
94
98
|
typeof requestData !== 'string'
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @module modules/uploader
|
|
8
8
|
*/
|
|
9
|
-
import type { HandlerError, HandlerSuccess, IUploader } from "../../../types/index";
|
|
9
|
+
import type { HandlerError, HandlerSuccess, IUploader, IUploadPlan } from "../../../types/index";
|
|
10
10
|
/**
|
|
11
11
|
* Send files to server
|
|
12
12
|
*/
|
|
13
|
-
export declare function sendFiles(uploader: IUploader, files: FileList | File[] | null, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError, process?: (form: FormData) => void): Promise<any>;
|
|
13
|
+
export declare function sendFiles(uploader: IUploader, files: FileList | File[] | null, handlerSuccess?: HandlerSuccess, handlerError?: HandlerError, process?: (form: FormData) => void, retryOf?: Partial<IUploadPlan>): Promise<any>;
|
|
@@ -3,27 +3,52 @@
|
|
|
3
3
|
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { ERROR_CODE_CONFLICT } from "../../../core/constants.js";
|
|
7
|
+
import { error, isArray, isFunction, isPlainObject, toArray } from "../../../core/helpers/index.js";
|
|
8
|
+
import { Dlgs } from "../../../core/traits/dlgs.js";
|
|
9
|
+
import { Prompt } from "../../dialog/prompt.js";
|
|
7
10
|
import { send } from "./send.js";
|
|
11
|
+
import { UploadError } from "./upload-error.js";
|
|
8
12
|
/**
|
|
9
13
|
* Send files to server
|
|
10
14
|
*/
|
|
11
|
-
export function sendFiles(uploader, files, handlerSuccess, handlerError, process
|
|
15
|
+
export async function sendFiles(uploader, files, handlerSuccess, handlerError, process,
|
|
16
|
+
// Set when a refused upload is sent again: `beforeUpload` already had its say
|
|
17
|
+
retryOf) {
|
|
12
18
|
if (!files) {
|
|
13
|
-
|
|
19
|
+
throw error('Need files');
|
|
14
20
|
}
|
|
15
21
|
const { o } = uploader;
|
|
16
22
|
let fileList = toArray(files);
|
|
17
23
|
if (!fileList.length) {
|
|
18
|
-
|
|
24
|
+
throw error('Need files');
|
|
19
25
|
}
|
|
20
|
-
|
|
26
|
+
let extraData = retryOf === null || retryOf === void 0 ? void 0 : retryOf.data;
|
|
27
|
+
// Client-side validation hook — returning `false` aborts the upload, and it may hand back the files to send instead
|
|
21
28
|
// See https://github.com/xdan/jodit/issues/1329
|
|
22
|
-
if (isFunction(o.beforeUpload)) {
|
|
23
|
-
|
|
29
|
+
if (!retryOf && isFunction(o.beforeUpload)) {
|
|
30
|
+
let plan;
|
|
31
|
+
try {
|
|
32
|
+
plan = await o.beforeUpload.call(uploader, fileList);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
(handlerError || o.defaultHandlerError).call(uploader, e);
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
if (plan === false) {
|
|
24
39
|
const err = error('Upload canceled');
|
|
25
40
|
(handlerError || o.defaultHandlerError).call(uploader, err);
|
|
26
|
-
|
|
41
|
+
throw err;
|
|
42
|
+
}
|
|
43
|
+
if (isArray(plan)) {
|
|
44
|
+
fileList = plan;
|
|
45
|
+
}
|
|
46
|
+
else if (isPlainObject(plan) && isArray(plan.files)) {
|
|
47
|
+
fileList = plan.files;
|
|
48
|
+
extraData = plan.data;
|
|
49
|
+
}
|
|
50
|
+
if (!fileList.length) {
|
|
51
|
+
return [];
|
|
27
52
|
}
|
|
28
53
|
}
|
|
29
54
|
const promises = [];
|
|
@@ -66,6 +91,11 @@ export function sendFiles(uploader, files, handlerSuccess, handlerError, process
|
|
|
66
91
|
form.append(key, o.data[key]);
|
|
67
92
|
});
|
|
68
93
|
}
|
|
94
|
+
if (extraData) {
|
|
95
|
+
Object.keys(extraData).forEach((key) => {
|
|
96
|
+
form.append(key, extraData[key]);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
69
99
|
o.prepareData.call(uploader, form);
|
|
70
100
|
promises.push(send(uploader, form)
|
|
71
101
|
.then(resp => {
|
|
@@ -76,10 +106,18 @@ export function sendFiles(uploader, files, handlerSuccess, handlerError, process
|
|
|
76
106
|
handler.call(uploader, o.process.call(uploader, resp));
|
|
77
107
|
return resp;
|
|
78
108
|
}
|
|
109
|
+
const err = new UploadError(o.getMessage.call(uploader, resp), resp, fileList, plan => {
|
|
110
|
+
var _a;
|
|
111
|
+
return sendFiles(uploader, (_a = plan === null || plan === void 0 ? void 0 : plan.files) !== null && _a !== void 0 ? _a : fileList, handlerSuccess, handlerError, process, { data: { ...extraData, ...plan === null || plan === void 0 ? void 0 : plan.data } });
|
|
112
|
+
});
|
|
113
|
+
// A taken name is part of the upload, not a failure: ask for another one first
|
|
114
|
+
if (err.code === ERROR_CODE_CONFLICT && o.promptOnExists) {
|
|
115
|
+
return askAnotherName(uploader, err);
|
|
116
|
+
}
|
|
79
117
|
const handler = isFunction(handlerError)
|
|
80
118
|
? handlerError
|
|
81
119
|
: o.defaultHandlerError;
|
|
82
|
-
handler.call(uploader,
|
|
120
|
+
handler.call(uploader, err);
|
|
83
121
|
return resp;
|
|
84
122
|
})
|
|
85
123
|
.then(() => {
|
|
@@ -88,6 +126,35 @@ export function sendFiles(uploader, files, handlerSuccess, handlerError, process
|
|
|
88
126
|
}
|
|
89
127
|
return Promise.all(promises);
|
|
90
128
|
}
|
|
129
|
+
function askAnotherName(uploader, err) {
|
|
130
|
+
const { files } = err;
|
|
131
|
+
// A batch is refused as a whole (the connector saved nothing) and the answer does not say which name is taken,
|
|
132
|
+
// so the files go again one by one: the free ones are simply stored, the taken one answers 409 alone and gets its prompt
|
|
133
|
+
if (files.length > 1) {
|
|
134
|
+
return files.reduce((chain, file) => chain.then(() => err.retry({ files: [file] })), Promise.resolve());
|
|
135
|
+
}
|
|
136
|
+
const [file] = files;
|
|
137
|
+
const { j, o } = uploader;
|
|
138
|
+
return new Promise(resolve => {
|
|
139
|
+
let answered = false;
|
|
140
|
+
// `Dlgs.prototype.dlg`: the uploader's view does not always carry the Dlgs trait
|
|
141
|
+
const dialog = Prompt.call(Dlgs.prototype.dlg.call(j, {
|
|
142
|
+
closeOnClickOverlay: true
|
|
143
|
+
}), j.i18n(err.message), j.i18n('Rename'), (newName) => {
|
|
144
|
+
newName = newName.trim();
|
|
145
|
+
if (!newName) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
answered = true;
|
|
149
|
+
resolve(err.retry({
|
|
150
|
+
files: [new File([file], newName, { type: file.type })]
|
|
151
|
+
}));
|
|
152
|
+
}, j.i18n('Enter new name'), o.promptOnExistsSuggestName.call(uploader, file.name));
|
|
153
|
+
dialog.e.on(dialog, 'afterClose', () => {
|
|
154
|
+
!answered && resolve(undefined);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
91
158
|
function readImagesWithReader(fileList, imagesExtensions, promises, uploader, handlerSuccess, defaultHandlerSuccess) {
|
|
92
159
|
const readerPromises = [];
|
|
93
160
|
let file, i;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 { IUploaderAnswer, IUploadError, IUploadPlan } from "../../../types/index";
|
|
10
|
+
import { AnswerError } from "../../../core/helpers/utils/error/index";
|
|
11
|
+
export declare class UploadError extends AnswerError<IUploaderAnswer> implements IUploadError {
|
|
12
|
+
readonly files: File[];
|
|
13
|
+
readonly retry: (plan?: Partial<IUploadPlan>) => Promise<unknown>;
|
|
14
|
+
constructor(message: string, answer: IUploaderAnswer, files: File[], retry: (plan?: Partial<IUploadPlan>) => Promise<unknown>);
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 { AnswerError } from "../../../core/helpers/utils/error/index.js";
|
|
7
|
+
// The connector refused these files: the handler can change the request and send it again
|
|
8
|
+
export class UploadError extends AnswerError {
|
|
9
|
+
constructor(message, answer, files, retry) {
|
|
10
|
+
var _a;
|
|
11
|
+
super(message, answer, (_a = answer.data) === null || _a === void 0 ? void 0 : _a.code);
|
|
12
|
+
this.files = files;
|
|
13
|
+
this.retry = retry;
|
|
14
|
+
Object.setPrototypeOf(this, UploadError.prototype);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { STATUSES, ViewComponent } from "../../core/component/index.js";
|
|
7
7
|
import { IS_ES_NEXT, IS_IE } from "../../core/constants.js";
|
|
8
8
|
import { Dom } from "../../core/dom/dom.js";
|
|
9
|
-
import { attr, ConfigProto,
|
|
9
|
+
import { attr, ConfigProto, isFunction, isJoditObject } from "../../core/helpers/index.js";
|
|
10
|
+
import { answer } from "../../core/helpers/utils/error/index.js";
|
|
10
11
|
import { Config } from "../../config.js";
|
|
11
12
|
import { ajaxInstances, hasFiles, hasItems, processOldBrowserDrag, send, sendFiles } from "./helpers/index.js";
|
|
12
13
|
import "./config.js";
|
|
@@ -162,6 +163,7 @@ export class Uploader extends ViewComponent {
|
|
|
162
163
|
url
|
|
163
164
|
})
|
|
164
165
|
.then(resp => {
|
|
166
|
+
var _a;
|
|
165
167
|
if (o.isSuccess.call(uploader, resp)) {
|
|
166
168
|
const handler = isFunction(handlerSuccess)
|
|
167
169
|
? handlerSuccess
|
|
@@ -169,13 +171,23 @@ export class Uploader extends ViewComponent {
|
|
|
169
171
|
handler.call(uploader, o.process.call(uploader, resp));
|
|
170
172
|
return;
|
|
171
173
|
}
|
|
172
|
-
handlerE.call(uploader,
|
|
174
|
+
handlerE.call(uploader, answer(o.getMessage.call(uploader, resp), resp, (_a = resp.data) === null || _a === void 0 ? void 0 : _a.code));
|
|
173
175
|
})
|
|
174
176
|
.catch(e => handlerE.call(uploader, e));
|
|
175
177
|
}
|
|
176
178
|
upload(files) {
|
|
177
179
|
return this.async.promise((resolve, reject) => {
|
|
178
|
-
|
|
180
|
+
let settled = false;
|
|
181
|
+
const settle = (end) => (value) => {
|
|
182
|
+
settled = true;
|
|
183
|
+
end(value);
|
|
184
|
+
};
|
|
185
|
+
sendFiles(this, files, settle(resolve), settle(reject)).then(() => {
|
|
186
|
+
// `beforeUpload` kept no file, so no handler ran
|
|
187
|
+
if (!settled) {
|
|
188
|
+
resolve({ baseurl: '', files: [], isImages: [] });
|
|
189
|
+
}
|
|
190
|
+
}, settle(reject));
|
|
179
191
|
});
|
|
180
192
|
}
|
|
181
193
|
constructor(editor, options) {
|
|
@@ -42,7 +42,13 @@ export function checkBR(fake, jodit, shiftKeyPressed, block) {
|
|
|
42
42
|
Dom.after(br, clone);
|
|
43
43
|
Dom.before(clone, fake);
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
// The new `br` ends the line above, so it takes something on the
|
|
46
|
+
// caret's own line to bring that line into view. Chrome won't scroll to
|
|
47
|
+
// an inline element without width, but it will to a `br`
|
|
48
|
+
const mark = br.cloneNode();
|
|
49
|
+
Dom.before(fake, mark);
|
|
50
|
+
scrollIntoViewIfNeeded(mark, jodit.editor, jodit.ed);
|
|
51
|
+
Dom.safeRemove(mark);
|
|
46
52
|
return true;
|
|
47
53
|
}
|
|
48
54
|
return false;
|
|
@@ -22,6 +22,7 @@ Config.prototype.font = {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
Icon.set('font', fontIcon).set('fontsize', fontsizeIcon);
|
|
25
|
+
const hadSelection = new WeakSet();
|
|
25
26
|
Config.prototype.controls.fontsize = {
|
|
26
27
|
command: 'fontsize',
|
|
27
28
|
data: {
|
|
@@ -40,17 +41,17 @@ Config.prototype.controls.fontsize = {
|
|
|
40
41
|
tooltip: 'Font size',
|
|
41
42
|
value: (editor, button) => {
|
|
42
43
|
var _a;
|
|
43
|
-
const current = editor.s.current();
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const current = editor.s.current(), box = current && Dom.closest(current, Dom.isElement, editor.editor), control = button.control;
|
|
45
|
+
// A select names its value, so until there is a selection it shows the
|
|
46
|
+
// editor's own size, and afterwards the size of the last one
|
|
47
|
+
if (box) {
|
|
48
|
+
hadSelection.add(button);
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
if (!box) {
|
|
50
|
+
else if (control.component !== 'select' || hadSelection.has(button)) {
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
const control = button.control;
|
|
52
53
|
const cssKey = ((_a = control.data) === null || _a === void 0 ? void 0 : _a.cssRule) || 'font-size';
|
|
53
|
-
const value = css(box, cssKey);
|
|
54
|
+
const value = css(box || editor.editor, cssKey);
|
|
54
55
|
if (cssKey === 'font-size') {
|
|
55
56
|
const numValue = parseFloat(value.toString());
|
|
56
57
|
if (editor.o.defaultFontSizePoints === 'pt') {
|
|
@@ -85,7 +86,6 @@ Config.prototype.controls.fontsize = {
|
|
|
85
86
|
return keySet.has(normalize(value.toString()));
|
|
86
87
|
}
|
|
87
88
|
};
|
|
88
|
-
const hadSelection = new WeakSet();
|
|
89
89
|
Config.prototype.controls.font = {
|
|
90
90
|
...Config.prototype.controls.fontsize,
|
|
91
91
|
command: 'fontname',
|
|
@@ -47,6 +47,17 @@ export class hotkeys extends Plugin {
|
|
|
47
47
|
40: 'down',
|
|
48
48
|
45: 'insert',
|
|
49
49
|
46: 'del',
|
|
50
|
+
// With Shift the digit keys send other characters: `&` for 7
|
|
51
|
+
48: '0',
|
|
52
|
+
49: '1',
|
|
53
|
+
50: '2',
|
|
54
|
+
51: '3',
|
|
55
|
+
52: '4',
|
|
56
|
+
53: '5',
|
|
57
|
+
54: '6',
|
|
58
|
+
55: '7',
|
|
59
|
+
56: '8',
|
|
60
|
+
57: '9',
|
|
50
61
|
59: ';',
|
|
51
62
|
61: '=',
|
|
52
63
|
91: 'meta',
|