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
|
@@ -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,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);
|
|
@@ -20,7 +20,7 @@ declare module 'jodit/config' {
|
|
|
20
20
|
* Jodit.make('#editor', {
|
|
21
21
|
* file: {
|
|
22
22
|
* defaultHandlerSuccess(data) {
|
|
23
|
-
* data.
|
|
23
|
+
* data.items.forEach(({ file }) => {
|
|
24
24
|
* this.s.insertHTML(`<a class="file" href="${data.baseurl + file}">${file}</a>`);
|
|
25
25
|
* });
|
|
26
26
|
* }
|
package/esm/plugins/file/file.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Dom } from "../../core/dom/dom.js";
|
|
|
7
7
|
import { pluginSystem } from "../../core/global.js";
|
|
8
8
|
import { attr } from "../../core/helpers/utils/attr.js";
|
|
9
9
|
import { Config } from "../../config.js";
|
|
10
|
+
import { getItems } from "../../modules/uploader/helpers/normalize-uploader-data.js";
|
|
10
11
|
import { FileSelectorWidget } from "../../modules/widget/index.js";
|
|
11
12
|
/**
|
|
12
13
|
* Selected text becomes the link's text, as the Link button does, instead
|
|
@@ -30,14 +31,14 @@ function wrapSelectionInLink(editor, href, title = '') {
|
|
|
30
31
|
return true;
|
|
31
32
|
}
|
|
32
33
|
function insertLinks(data) {
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
const href =
|
|
34
|
+
const { baseurl } = data;
|
|
35
|
+
getItems(data).forEach(({ file }) => {
|
|
36
|
+
const href = baseurl + file;
|
|
36
37
|
if (wrapSelectionInLink(this, href)) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
const link = this.createInside.element('a', { href });
|
|
40
|
-
link.textContent = this.o.uploader.getDisplayName.call(this.uploader,
|
|
41
|
+
link.textContent = this.o.uploader.getDisplayName.call(this.uploader, baseurl, file);
|
|
41
42
|
this.s.insertNode(link);
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -71,8 +72,7 @@ Config.prototype.controls.file = {
|
|
|
71
72
|
}
|
|
72
73
|
return FileSelectorWidget(editor, {
|
|
73
74
|
filebrowser: (data) => {
|
|
74
|
-
data.
|
|
75
|
-
data.files.forEach(file => insert(data.baseurl + file));
|
|
75
|
+
getItems(data).forEach(({ file }) => insert(data.baseurl + file));
|
|
76
76
|
close();
|
|
77
77
|
},
|
|
78
78
|
upload: (data) => {
|
|
@@ -9,6 +9,7 @@ import { $$ } from "../../core/helpers/index.js";
|
|
|
9
9
|
import { attr } from "../../core/helpers/utils/attr.js";
|
|
10
10
|
import { Icon } from "../../core/ui/icon.js";
|
|
11
11
|
import { Config } from "../../config.js";
|
|
12
|
+
import { getItems } from "../../modules/uploader/helpers/normalize-uploader-data.js";
|
|
12
13
|
import { FileSelectorWidget } from "../../modules/widget/index.js";
|
|
13
14
|
import imageIcon from "./image.svg.js";
|
|
14
15
|
Icon.set('image', imageIcon);
|
|
@@ -27,8 +28,7 @@ Config.prototype.controls.image = {
|
|
|
27
28
|
return FileSelectorWidget(editor, {
|
|
28
29
|
filebrowser: (data) => {
|
|
29
30
|
editor.s.restore();
|
|
30
|
-
data.
|
|
31
|
-
data.files.forEach(file => editor.s.insertImage(data.baseurl + file, null, editor.o.imageDefaultWidth));
|
|
31
|
+
getItems(data).forEach(({ file }) => editor.s.insertImage(data.baseurl + file, null, editor.o.imageDefaultWidth));
|
|
32
32
|
close();
|
|
33
33
|
},
|
|
34
34
|
upload: true,
|
|
@@ -425,10 +425,9 @@ export class imageCaption extends Plugin {
|
|
|
425
425
|
const fresh = this.__freshCaption(wrapper);
|
|
426
426
|
this.__unrecorded(() => fresh ? this.__restore(fresh) : this.__uncaption(wrapper, image));
|
|
427
427
|
// The click opened the image's popup below the caption, so it
|
|
428
|
-
//
|
|
428
|
+
// moves below the image, as after the popup's Caption button
|
|
429
429
|
if (clicked) {
|
|
430
430
|
j.e.fire('recalcPositionPopup');
|
|
431
|
-
j.e.fire('closeAllPopups');
|
|
432
431
|
}
|
|
433
432
|
}, 1);
|
|
434
433
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
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 { isArray } from "../../../core/helpers/checker/is-array.js";
|
|
7
6
|
import { position } from "../../../core/helpers/size/position.js";
|
|
8
7
|
import { Popup } from "../../../core/ui/popup/popup.js";
|
|
8
|
+
import { getItems } from "../../../modules/uploader/helpers/normalize-uploader-data.js";
|
|
9
9
|
import { FileSelectorWidget } from "../../../modules/widget/file-selector/file-selector.js";
|
|
10
10
|
/** @private */
|
|
11
11
|
export function openImagePopup(j, dialog, state, button) {
|
|
@@ -17,15 +17,16 @@ export function openImagePopup(j, dialog, state, button) {
|
|
|
17
17
|
popup
|
|
18
18
|
.setContent(FileSelectorWidget(j, {
|
|
19
19
|
upload: (data) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const [item] = getItems(data);
|
|
21
|
+
if (item) {
|
|
22
|
+
state.values.imageSrc = data.baseurl + item.file;
|
|
23
23
|
}
|
|
24
24
|
closePopup();
|
|
25
25
|
},
|
|
26
26
|
filebrowser: async (data) => {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const [item] = data ? getItems(data) : [];
|
|
28
|
+
if (item) {
|
|
29
|
+
state.values.imageSrc = item.file;
|
|
29
30
|
closePopup();
|
|
30
31
|
}
|
|
31
32
|
}
|
package/esm/plugins/index.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";
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @module plugins/inline-popup
|
|
8
8
|
*/
|
|
9
|
-
import type { IControlType, IDictionary, IJodit } from "../../../types/index";
|
|
9
|
+
import type { IControlType, IDictionary, IJodit, IUIElement } from "../../../types/index";
|
|
10
10
|
declare module 'jodit/config' {
|
|
11
11
|
interface Config {
|
|
12
12
|
/**
|
|
13
13
|
* Element-specific popup toolbars. Keys are tag names (e.g. `img`, `a`, `cells`)
|
|
14
14
|
* and values are button lists or factory functions that return them.
|
|
15
15
|
*/
|
|
16
|
-
popup: IDictionary<Array<IControlType | string> | ((editor: IJodit, target: HTMLElement | undefined, close: () => void) => Array<IControlType | string> | HTMLElement | string)>;
|
|
16
|
+
popup: IDictionary<Array<IControlType | string> | ((editor: IJodit, target: HTMLElement | undefined, close: () => void) => Array<IControlType | string> | HTMLElement | IUIElement | string)>;
|
|
17
17
|
/**
|
|
18
18
|
* List of button names to exclude from the inline toolbar
|
|
19
19
|
*/
|
|
@@ -26,6 +26,12 @@ declare module 'jodit/config' {
|
|
|
26
26
|
* Show an inline toolbar when the user selects text
|
|
27
27
|
*/
|
|
28
28
|
toolbarInlineForSelection: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Keep an inline toolbar open after one of its buttons runs, beside its
|
|
31
|
+
* element or the selection. A list the button opened still closes.
|
|
32
|
+
* `false` closes the toolbar after every button
|
|
33
|
+
*/
|
|
34
|
+
toolbarInlineKeepOpen: boolean;
|
|
29
35
|
/**
|
|
30
36
|
* CSS selector or array of selectors for elements that should not trigger the inline toolbar
|
|
31
37
|
*/
|
|
@@ -22,6 +22,7 @@ import * as th from "../icons/th.svg.js";
|
|
|
22
22
|
import * as thList from "../icons/th-list.svg.js";
|
|
23
23
|
Config.prototype.toolbarInline = true;
|
|
24
24
|
Config.prototype.toolbarInlineForSelection = false;
|
|
25
|
+
Config.prototype.toolbarInlineKeepOpen = true;
|
|
25
26
|
Config.prototype.toolbarInlineDisableFor = [];
|
|
26
27
|
Config.prototype.toolbarInlineDisabledButtons = ['source'];
|
|
27
28
|
Icon.set('addcolumn', addcolumn.default)
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Dom } from "../../../../core/dom/dom.js";
|
|
7
7
|
import { isJoditObject, isString } from "../../../../core/helpers/checker/index.js";
|
|
8
|
-
import { position } from "../../../../core/helpers/size/position.js";
|
|
9
8
|
import { css } from "../../../../core/helpers/utils/css.js";
|
|
10
9
|
const cmd = (control) => control.args && isString(control.args[0])
|
|
11
10
|
? control.args[0].toLowerCase()
|
|
@@ -88,15 +87,6 @@ export default [
|
|
|
88
87
|
return;
|
|
89
88
|
}
|
|
90
89
|
editor.execCommand('tableheaderrow', false, table);
|
|
91
|
-
const [cell] = editor
|
|
92
|
-
.getInstance('Table', editor.o)
|
|
93
|
-
.getAllSelectedCells();
|
|
94
|
-
// Beside the cell that replaced the one it opened for
|
|
95
|
-
if (cell) {
|
|
96
|
-
editor.e.fire('showPopup', table, () => position(cell, editor), 'cells');
|
|
97
|
-
}
|
|
98
|
-
// The popup stays open, so the button shows the new state
|
|
99
|
-
return true;
|
|
100
90
|
},
|
|
101
91
|
isActive: (editor, button) => Dom.isTag(button.target, 'table') &&
|
|
102
92
|
editor
|
|
@@ -106,7 +106,7 @@ export default [
|
|
|
106
106
|
const caption = editor.e.fire('toggleImageCaption', image);
|
|
107
107
|
editor.synchronizeValues();
|
|
108
108
|
if (Dom.isHTMLElement(caption)) {
|
|
109
|
-
editor.e.fire('hideResizer');
|
|
109
|
+
editor.e.fire('hidePopup hideResizer');
|
|
110
110
|
editor.s.setCursorIn(caption);
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
@@ -29,6 +29,7 @@ export declare class inlinePopup extends Plugin {
|
|
|
29
29
|
* Show inline popup with some toolbar
|
|
30
30
|
*
|
|
31
31
|
* @param type - selection, img, a etc.
|
|
32
|
+
* @param force - make the popup again for the same target
|
|
32
33
|
*/
|
|
33
34
|
private showPopup;
|
|
34
35
|
private previousTarget?;
|
|
@@ -59,20 +60,9 @@ export declare class inlinePopup extends Plugin {
|
|
|
59
60
|
/** @override **/
|
|
60
61
|
protected afterInit(jodit: IJodit): void;
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
-
* command fires `closeAllPopups`, the toolbar should be shown again
|
|
64
|
-
* while the selection is still there. See #1238
|
|
63
|
+
* Follow the element once a control has moved it, as the alignments do
|
|
65
64
|
*/
|
|
66
|
-
private __reopenSelectionPopup;
|
|
67
|
-
/**
|
|
68
|
-
* The alignment controls fire `recalcPositionPopup` once they have moved
|
|
69
|
-
* the element, and their button then fires `closeAllPopups`. The popup
|
|
70
|
-
* opens again beside the element, as the selection toolbar does
|
|
71
|
-
*/
|
|
72
|
-
private __reopenFor;
|
|
73
65
|
protected onRecalcPositionPopup(): void;
|
|
74
|
-
private __onDocumentMouseDown;
|
|
75
|
-
private __onCloseAllPopups;
|
|
76
66
|
/**
|
|
77
67
|
* The selection rect comes from the editor document — in iframe mode its
|
|
78
68
|
* coordinates are iframe-local, while the popup lives in the host
|
|
@@ -88,6 +78,13 @@ export declare class inlinePopup extends Plugin {
|
|
|
88
78
|
* Selection change handler
|
|
89
79
|
*/
|
|
90
80
|
private onSelectionChange;
|
|
81
|
+
/**
|
|
82
|
+
* The selection holds more than a line break. A double click past the end
|
|
83
|
+
* of a line, or a drag from there into the next, selects only the break,
|
|
84
|
+
* with any rule, video or empty line it crosses: it starts at the end of a
|
|
85
|
+
* line, after everything in it, and holds no text that shows
|
|
86
|
+
*/
|
|
87
|
+
private __hasSelectedContent;
|
|
91
88
|
/**
|
|
92
89
|
* In not collapsed selection - only one image
|
|
93
90
|
*/
|