jodit 4.19.12 → 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.
- package/CHANGELOG.md +30 -0
- package/es2015/jodit.css +76 -1
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +9 -9
- package/es2015/jodit.js +1583 -681
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +9 -9
- 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.css +1 -1
- package/es2018/jodit.fat.min.js +9 -9
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +9 -9
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +76 -1
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +14 -14
- package/es2021/jodit.js +1564 -678
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +14 -14
- 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 +76 -1
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +14 -14
- package/es2021.en/jodit.js +1514 -628
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +14 -14
- 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 +96 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +1844 -791
- package/es5/jodit.min.css +3 -3
- 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/config.d.ts +10 -3
- package/esm/core/constants.js +1 -1
- package/esm/core/global.d.ts +6 -0
- package/esm/core/global.js +21 -4
- package/esm/core/helpers/html/safe-html.js +26 -0
- package/esm/core/helpers/utils/anchor.d.ts +22 -0
- package/esm/core/helpers/utils/anchor.js +29 -0
- package/esm/core/helpers/utils/index.d.ts +1 -0
- package/esm/core/helpers/utils/index.js +1 -0
- package/esm/core/ui/popup/popup.d.ts +5 -0
- package/esm/core/ui/popup/popup.js +5 -0
- package/esm/jodit.d.ts +4 -0
- package/esm/jodit.js +16 -15
- package/esm/langs/ar.d.ts +5 -0
- package/esm/langs/ar.js +5 -0
- package/esm/langs/az.d.ts +5 -0
- package/esm/langs/az.js +5 -0
- package/esm/langs/cs_cz.d.ts +5 -0
- package/esm/langs/cs_cz.js +6 -1
- package/esm/langs/de.d.ts +5 -0
- package/esm/langs/de.js +6 -0
- package/esm/langs/es.d.ts +5 -0
- package/esm/langs/es.js +6 -1
- package/esm/langs/fa.d.ts +5 -0
- package/esm/langs/fa.js +6 -1
- package/esm/langs/fi.d.ts +5 -0
- package/esm/langs/fi.js +5 -0
- package/esm/langs/fr.d.ts +5 -0
- package/esm/langs/fr.js +5 -0
- package/esm/langs/he.d.ts +5 -0
- package/esm/langs/he.js +6 -1
- package/esm/langs/hu.d.ts +5 -0
- package/esm/langs/hu.js +5 -0
- package/esm/langs/id.d.ts +5 -0
- package/esm/langs/id.js +6 -1
- package/esm/langs/it.d.ts +5 -0
- package/esm/langs/it.js +6 -1
- package/esm/langs/ja.d.ts +5 -0
- package/esm/langs/ja.js +6 -1
- package/esm/langs/ko.d.ts +5 -0
- package/esm/langs/ko.js +6 -1
- package/esm/langs/mn.d.ts +5 -0
- package/esm/langs/mn.js +6 -1
- package/esm/langs/nl.d.ts +5 -0
- package/esm/langs/nl.js +5 -0
- package/esm/langs/no.d.ts +5 -0
- package/esm/langs/no.js +5 -0
- package/esm/langs/pl.d.ts +5 -0
- package/esm/langs/pl.js +5 -0
- package/esm/langs/pt_br.d.ts +5 -0
- package/esm/langs/pt_br.js +6 -1
- package/esm/langs/ru.d.ts +5 -0
- package/esm/langs/ru.js +6 -1
- package/esm/langs/sk.d.ts +5 -0
- package/esm/langs/sk.js +5 -0
- package/esm/langs/sv.d.ts +5 -0
- package/esm/langs/sv.js +5 -0
- package/esm/langs/tr.d.ts +5 -0
- package/esm/langs/tr.js +6 -1
- package/esm/langs/ua.d.ts +5 -0
- package/esm/langs/ua.js +6 -1
- package/esm/langs/zh_cn.d.ts +5 -0
- package/esm/langs/zh_cn.js +6 -1
- package/esm/langs/zh_tw.d.ts +5 -0
- package/esm/langs/zh_tw.js +5 -0
- package/esm/languages.js +7 -1
- package/esm/modules/file-browser/file-browser.d.ts +3 -4
- package/esm/modules/file-browser/file-browser.js +12 -12
- package/esm/modules/toolbar/button/button.d.ts +7 -0
- package/esm/modules/toolbar/button/button.js +30 -4
- package/esm/modules/uploader/config.js +18 -18
- package/esm/modules/uploader/helpers/index.d.ts +1 -0
- package/esm/modules/uploader/helpers/index.js +1 -0
- package/esm/modules/uploader/helpers/normalize-uploader-data.d.ts +32 -0
- package/esm/modules/uploader/helpers/normalize-uploader-data.js +54 -0
- package/esm/modules/uploader/helpers/send-files.js +11 -6
- package/esm/modules/uploader/uploader.d.ts +4 -5
- package/esm/modules/uploader/uploader.js +12 -8
- package/esm/plugins/all.d.ts +1 -0
- package/esm/plugins/all.js +1 -0
- package/esm/plugins/anchor/anchor.d.ts +67 -0
- package/esm/plugins/anchor/anchor.js +302 -0
- package/esm/plugins/anchor/config.d.ts +6 -0
- package/esm/plugins/anchor/config.js +13 -0
- package/esm/plugins/file/file.d.ts +1 -1
- package/esm/plugins/file/file.js +6 -6
- package/esm/plugins/image/image.js +2 -2
- package/esm/plugins/image-caption/image-caption.js +1 -2
- package/esm/plugins/image-properties/utils/open-image-popup.js +7 -6
- package/esm/plugins/index.d.ts +1 -0
- package/esm/plugins/inline-popup/config/config.d.ts +8 -2
- package/esm/plugins/inline-popup/config/config.js +1 -0
- package/esm/plugins/inline-popup/config/items/cells.js +0 -10
- package/esm/plugins/inline-popup/config/items/img.js +1 -1
- package/esm/plugins/inline-popup/inline-popup.d.ts +9 -12
- package/esm/plugins/inline-popup/inline-popup.js +53 -77
- package/esm/plugins/link/link.js +150 -3
- package/esm/plugins/select/select.d.ts +31 -0
- package/esm/plugins/select/select.js +235 -2
- package/esm/plugins/select-cells/select-cells.d.ts +11 -0
- package/esm/plugins/select-cells/select-cells.js +48 -17
- package/esm/plugins/video/config.d.ts +1 -1
- package/esm/plugins/video/config.js +4 -3
- package/esm/plugins/video-properties/video-properties.js +7 -6
- package/esm/styles/icons/anchor.svg.js +1 -0
- package/esm/styles/icons/index.d.ts +1 -1
- package/esm/styles/icons/index.js +2 -1
- package/esm/types/file-browser.d.ts +8 -1
- package/esm/types/popup.d.ts +1 -0
- package/esm/types/uploader.d.ts +39 -1
- package/package.json +1 -1
- package/types/config.d.ts +10 -3
- package/types/core/global.d.ts +6 -0
- package/types/core/helpers/utils/anchor.d.ts +22 -0
- package/types/core/helpers/utils/index.d.ts +1 -0
- package/types/core/ui/popup/popup.d.ts +5 -0
- package/types/jodit.d.ts +4 -0
- package/types/langs/ar.d.ts +5 -0
- package/types/langs/az.d.ts +5 -0
- package/types/langs/cs_cz.d.ts +5 -0
- package/types/langs/de.d.ts +5 -0
- package/types/langs/es.d.ts +5 -0
- package/types/langs/fa.d.ts +5 -0
- package/types/langs/fi.d.ts +5 -0
- package/types/langs/fr.d.ts +5 -0
- package/types/langs/he.d.ts +5 -0
- package/types/langs/hu.d.ts +5 -0
- package/types/langs/id.d.ts +5 -0
- package/types/langs/it.d.ts +5 -0
- package/types/langs/ja.d.ts +5 -0
- package/types/langs/ko.d.ts +5 -0
- package/types/langs/mn.d.ts +5 -0
- package/types/langs/nl.d.ts +5 -0
- package/types/langs/no.d.ts +5 -0
- package/types/langs/pl.d.ts +5 -0
- package/types/langs/pt_br.d.ts +5 -0
- package/types/langs/ru.d.ts +5 -0
- package/types/langs/sk.d.ts +5 -0
- package/types/langs/sv.d.ts +5 -0
- package/types/langs/tr.d.ts +5 -0
- package/types/langs/ua.d.ts +5 -0
- package/types/langs/zh_cn.d.ts +5 -0
- package/types/langs/zh_tw.d.ts +5 -0
- package/types/modules/file-browser/file-browser.d.ts +3 -4
- package/types/modules/toolbar/button/button.d.ts +7 -0
- package/types/modules/uploader/helpers/index.d.ts +1 -0
- package/types/modules/uploader/helpers/normalize-uploader-data.d.ts +32 -0
- package/types/modules/uploader/uploader.d.ts +4 -5
- package/types/plugins/anchor/anchor.d.ts +67 -0
- package/types/plugins/anchor/config.d.ts +6 -0
- package/types/plugins/file/file.d.ts +1 -1
- package/types/plugins/index.d.ts +1 -0
- package/types/plugins/inline-popup/config/config.d.ts +8 -2
- package/types/plugins/inline-popup/inline-popup.d.ts +9 -12
- package/types/plugins/select/select.d.ts +31 -0
- package/types/plugins/select-cells/select-cells.d.ts +11 -0
- package/types/plugins/video/config.d.ts +1 -1
- package/types/styles/icons/index.d.ts +1 -1
- package/types/types/file-browser.d.ts +8 -1
- package/types/types/popup.d.ts +1 -0
- package/types/types/uploader.d.ts +39 -1
|
@@ -26,6 +26,7 @@ import { Storage } from "../../core/storage/index.js";
|
|
|
26
26
|
import { Dlgs } from "../../core/traits/dlgs.js";
|
|
27
27
|
import { ViewWithToolbar } from "../../core/view/view-with-toolbar.js";
|
|
28
28
|
import { Config } from "../../config.js";
|
|
29
|
+
import { normalizeUploaderData } from "../uploader/helpers/normalize-uploader-data.js";
|
|
29
30
|
import "./config.js";
|
|
30
31
|
import { loadItems } from "./fetch/load-items.js";
|
|
31
32
|
import { loadTree } from "./fetch/load-tree.js";
|
|
@@ -46,21 +47,21 @@ let FileBrowser = class FileBrowser extends ViewWithToolbar {
|
|
|
46
47
|
onSelect(callback) {
|
|
47
48
|
return () => {
|
|
48
49
|
if (this.state.activeElements.length) {
|
|
49
|
-
const
|
|
50
|
-
const isImages = [];
|
|
50
|
+
const items = [];
|
|
51
51
|
this.state.activeElements.forEach(elm => {
|
|
52
52
|
const url = elm.fileURL;
|
|
53
53
|
if (url) {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
items.push({
|
|
55
|
+
file: url,
|
|
56
|
+
isImage: elm.isImage || false
|
|
57
|
+
});
|
|
56
58
|
}
|
|
57
59
|
});
|
|
58
60
|
this.close();
|
|
59
|
-
const data = {
|
|
61
|
+
const data = normalizeUploaderData({
|
|
60
62
|
baseurl: '',
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
63
|
+
items
|
|
64
|
+
});
|
|
64
65
|
if (isFunction(callback)) {
|
|
65
66
|
callback(data);
|
|
66
67
|
}
|
|
@@ -122,10 +123,9 @@ let FileBrowser = class FileBrowser extends ViewWithToolbar {
|
|
|
122
123
|
* ```javascript
|
|
123
124
|
* var fb = new Jodit.modules.FileBrowser(parent);
|
|
124
125
|
* fb.open(function (data) {
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* }
|
|
126
|
+
* data.items.forEach(function (item) {
|
|
127
|
+
* parent.s.insertImage(data.baseurl + item.file);
|
|
128
|
+
* });
|
|
129
129
|
* });
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
@@ -111,5 +111,12 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
|
|
|
111
111
|
* Click handler
|
|
112
112
|
*/
|
|
113
113
|
protected onClick(originalEvent: MouseEvent): void;
|
|
114
|
+
/**
|
|
115
|
+
* After the button's action, a popup that stays open (an element's)
|
|
116
|
+
* keeps its place beside the element, and only the lists the button is
|
|
117
|
+
* in close. Otherwise, as when the action removed the element, every
|
|
118
|
+
* popup closes
|
|
119
|
+
*/
|
|
120
|
+
private __closePopups;
|
|
114
121
|
destruct(): any;
|
|
115
122
|
}
|
|
@@ -13,6 +13,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
13
13
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
14
14
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
15
|
};
|
|
16
|
+
var ToolbarButton_1;
|
|
17
|
+
import { Component } from "../../../core/component/component.js";
|
|
16
18
|
import { STATUSES } from "../../../core/component/statuses.js";
|
|
17
19
|
import { KEY_DOWN, KEY_ENTER, KEY_ESC, KEY_SPACE, KEY_UP } from "../../../core/constants.js";
|
|
18
20
|
import { autobind } from "../../../core/decorators/autobind/autobind.js";
|
|
@@ -46,7 +48,7 @@ const FOCUSABLE_SELECTOR = [
|
|
|
46
48
|
'textarea:not([disabled])',
|
|
47
49
|
'[tabindex]:not([tabindex="-1"])'
|
|
48
50
|
].join(',');
|
|
49
|
-
let ToolbarButton = class ToolbarButton extends UIButton {
|
|
51
|
+
let ToolbarButton = ToolbarButton_1 = class ToolbarButton extends UIButton {
|
|
50
52
|
className() {
|
|
51
53
|
return 'ToolbarButton';
|
|
52
54
|
}
|
|
@@ -588,10 +590,11 @@ let ToolbarButton = class ToolbarButton extends UIButton {
|
|
|
588
590
|
if (this.parentElement) {
|
|
589
591
|
this.parentElement.update();
|
|
590
592
|
}
|
|
593
|
+
this.__closePopups();
|
|
591
594
|
/**
|
|
592
595
|
* Fired after calling `button.exec` function
|
|
593
596
|
*/
|
|
594
|
-
(_g = (_f = this.j) === null || _f === void 0 ? void 0 : _f.e) === null || _g === void 0 ? void 0 : _g.fire('
|
|
597
|
+
(_g = (_f = this.j) === null || _f === void 0 ? void 0 : _f.e) === null || _g === void 0 ? void 0 : _g.fire('afterExec');
|
|
595
598
|
}
|
|
596
599
|
if (result !== false) {
|
|
597
600
|
return;
|
|
@@ -607,9 +610,32 @@ let ToolbarButton = class ToolbarButton extends UIButton {
|
|
|
607
610
|
call(isJoditObject(this.j)
|
|
608
611
|
? this.j.execCommand.bind(this.j)
|
|
609
612
|
: this.j.od.execCommand.bind(this.j.od), ctr.command || ctr.name, false, ctr.args && ctr.args[0]);
|
|
610
|
-
this.
|
|
613
|
+
this.__closePopups();
|
|
611
614
|
}
|
|
612
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* After the button's action, a popup that stays open (an element's)
|
|
618
|
+
* keeps its place beside the element, and only the lists the button is
|
|
619
|
+
* in close. Otherwise, as when the action removed the element, every
|
|
620
|
+
* popup closes
|
|
621
|
+
*/
|
|
622
|
+
__closePopups() {
|
|
623
|
+
var _a, _b;
|
|
624
|
+
const openers = [this];
|
|
625
|
+
for (let pe = this.parentElement; pe; pe = pe.parentElement) {
|
|
626
|
+
if (Component.isInstanceOf(pe, Popup) &&
|
|
627
|
+
pe.keepOpen &&
|
|
628
|
+
(!this.target || this.target.isConnected)) {
|
|
629
|
+
openers.forEach(button => button.__closePopup());
|
|
630
|
+
pe.updatePosition();
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
if (Component.isInstanceOf(pe, ToolbarButton_1)) {
|
|
634
|
+
openers.push(pe);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
(_b = (_a = this.j) === null || _a === void 0 ? void 0 : _a.e) === null || _b === void 0 ? void 0 : _b.fire('closeAllPopups');
|
|
638
|
+
}
|
|
613
639
|
destruct() {
|
|
614
640
|
this.__closePopup();
|
|
615
641
|
return super.destruct();
|
|
@@ -642,7 +668,7 @@ __decorate([
|
|
|
642
668
|
__decorate([
|
|
643
669
|
autobind
|
|
644
670
|
], ToolbarButton.prototype, "__closePopup", null);
|
|
645
|
-
ToolbarButton = __decorate([
|
|
671
|
+
ToolbarButton = ToolbarButton_1 = __decorate([
|
|
646
672
|
component
|
|
647
673
|
], ToolbarButton);
|
|
648
674
|
export { ToolbarButton };
|
|
@@ -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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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";
|
|
@@ -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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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 (
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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 (
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
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({
|
|
187
|
+
resolve({
|
|
188
|
+
baseurl: '',
|
|
189
|
+
items: [],
|
|
190
|
+
files: [],
|
|
191
|
+
isImages: []
|
|
192
|
+
});
|
|
189
193
|
}
|
|
190
194
|
}, settle(reject));
|
|
191
195
|
});
|
package/esm/plugins/all.d.ts
CHANGED
|
@@ -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";
|
package/esm/plugins/all.js
CHANGED
|
@@ -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
|
+
}
|