jodit 4.20.4 → 4.20.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +4 -4
- package/es2015/jodit.js +72 -27
- package/es2015/jodit.min.js +4 -4
- 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 +4 -4
- package/es2018/jodit.min.js +4 -4
- 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 +4 -4
- package/es2021/jodit.js +72 -27
- package/es2021/jodit.min.js +4 -4
- 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 +6 -6
- package/es2021.en/jodit.js +72 -27
- package/es2021.en/jodit.min.js +4 -4
- 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 +93 -26
- 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/config.d.ts +2 -0
- package/esm/core/constants.js +1 -1
- package/esm/plugins/clean-html/clean-html.d.ts +1 -0
- package/esm/plugins/clean-html/clean-html.js +15 -0
- package/esm/plugins/file/file.js +12 -1
- package/esm/plugins/link/config.d.ts +2 -0
- package/esm/plugins/link/config.js +1 -0
- package/esm/plugins/link/link.js +49 -23
- package/esm/plugins/link/template.js +4 -4
- package/package.json +1 -1
- package/types/config.d.ts +2 -0
- package/types/plugins/clean-html/clean-html.d.ts +1 -0
- package/types/plugins/link/config.d.ts +2 -0
package/es5/polyfills.fat.min.js
CHANGED
package/es5/polyfills.js
CHANGED
package/es5/polyfills.min.js
CHANGED
package/esm/config.d.ts
CHANGED
|
@@ -1559,6 +1559,8 @@ interface Config {
|
|
|
1559
1559
|
*/
|
|
1560
1560
|
formTemplate: (editor: IJodit) => string | HTMLElement | IUIForm;
|
|
1561
1561
|
formClassName?: string;
|
|
1562
|
+
/** Content field format in the link form. Default: text. */
|
|
1563
|
+
contentMode: 'text' | 'html';
|
|
1562
1564
|
/**
|
|
1563
1565
|
* Follow link address after dblclick
|
|
1564
1566
|
*/
|
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.20.
|
|
6
|
+
export const APP_VERSION = "4.20.5";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
|
@@ -80,6 +80,7 @@ export declare class cleanHtml extends Plugin {
|
|
|
80
80
|
private __removeTrailingBr;
|
|
81
81
|
private __singleQuotesInFontFamily;
|
|
82
82
|
protected onSafeHTML(sandBox: HTMLElement): void;
|
|
83
|
+
protected onCleanHTML(sandBox: HTMLElement): void;
|
|
83
84
|
/** @override */
|
|
84
85
|
protected beforeDestruct(): void;
|
|
85
86
|
}
|
|
@@ -47,6 +47,7 @@ export class cleanHtml extends Plugin {
|
|
|
47
47
|
// sanitises them.
|
|
48
48
|
jodit.e
|
|
49
49
|
.on('safeHTML', this.onSafeHTML)
|
|
50
|
+
.on('cleanHTML', this.onCleanHTML)
|
|
50
51
|
.on('beforeSetNativeEditorValue', this.onBeforeSetNativeEditorValue)
|
|
51
52
|
.on('afterSetNativeEditorValue', this.onAfterSetNativeEditorValue);
|
|
52
53
|
}
|
|
@@ -244,10 +245,21 @@ export class cleanHtml extends Plugin {
|
|
|
244
245
|
}
|
|
245
246
|
safeHTML(sandBox, this.j.o.cleanHTML);
|
|
246
247
|
}
|
|
248
|
+
onCleanHTML(sandBox) {
|
|
249
|
+
const allow = getHash(this.j.o.cleanHTML.allowTags);
|
|
250
|
+
const deny = getHash(this.j.o.cleanHTML.denyTags);
|
|
251
|
+
const nodes = Array.from(sandBox.querySelectorAll('*'));
|
|
252
|
+
for (const node of nodes) {
|
|
253
|
+
if (Dom.isOrContains(sandBox, node)) {
|
|
254
|
+
visitNodeWalker(this.j, node, allow, deny, null);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
247
258
|
/** @override */
|
|
248
259
|
beforeDestruct() {
|
|
249
260
|
this.j.e
|
|
250
261
|
.off('safeHTML', this.onSafeHTML)
|
|
262
|
+
.off('cleanHTML', this.onCleanHTML)
|
|
251
263
|
.off('beforeSetNativeEditorValue', this.onBeforeSetNativeEditorValue)
|
|
252
264
|
.off('afterSetNativeEditorValue', this.onAfterSetNativeEditorValue);
|
|
253
265
|
this.walker.destruct();
|
|
@@ -277,4 +289,7 @@ __decorate([
|
|
|
277
289
|
__decorate([
|
|
278
290
|
autobind
|
|
279
291
|
], cleanHtml.prototype, "onSafeHTML", null);
|
|
292
|
+
__decorate([
|
|
293
|
+
autobind
|
|
294
|
+
], cleanHtml.prototype, "onCleanHTML", null);
|
|
280
295
|
pluginSystem.add('cleanHtml', cleanHtml);
|
package/esm/plugins/file/file.js
CHANGED
|
@@ -49,14 +49,25 @@ Config.prototype.controls.file = {
|
|
|
49
49
|
popup: (editor, current, close) => {
|
|
50
50
|
// The popup's first field takes the focus, so the selection the
|
|
51
51
|
// popup was opened for is kept and put back before the link goes in
|
|
52
|
-
|
|
52
|
+
let selected = editor.s.isCollapsed() ? null : editor.s.range;
|
|
53
53
|
const restoreSelection = () => {
|
|
54
54
|
if (selected) {
|
|
55
55
|
editor.s.selectRange(selected);
|
|
56
|
+
selected = null;
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
59
|
const insert = (url, title = '') => {
|
|
59
60
|
restoreSelection();
|
|
61
|
+
if (sourceAnchor && Dom.isOrContains(editor.editor, sourceAnchor)) {
|
|
62
|
+
attr(sourceAnchor, 'href', url);
|
|
63
|
+
if (title) {
|
|
64
|
+
attr(sourceAnchor, 'title', title);
|
|
65
|
+
}
|
|
66
|
+
editor.s.setCursorAfter(sourceAnchor);
|
|
67
|
+
sourceAnchor = null;
|
|
68
|
+
editor.synchronizeValues();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
60
71
|
if (wrapSelectionInLink(editor, url, title)) {
|
|
61
72
|
return;
|
|
62
73
|
}
|
|
@@ -15,6 +15,8 @@ declare module 'jodit/config' {
|
|
|
15
15
|
*/
|
|
16
16
|
formTemplate: (editor: IJodit) => string | HTMLElement | IUIForm;
|
|
17
17
|
formClassName?: string;
|
|
18
|
+
/** Content field format in the link form. Default: text. */
|
|
19
|
+
contentMode: 'text' | 'html';
|
|
18
20
|
/**
|
|
19
21
|
* Follow link address after dblclick
|
|
20
22
|
*/
|
package/esm/plugins/link/link.js
CHANGED
|
@@ -17,7 +17,7 @@ import { KEY_BACKSPACE, KEY_DOWN, KEY_ESC, KEY_TAB, KEY_UP } from "../../core/co
|
|
|
17
17
|
import { autobind } from "../../core/decorators/index.js";
|
|
18
18
|
import { Dom } from "../../core/dom/index.js";
|
|
19
19
|
import { pluginSystem, uniqueUid } from "../../core/global.js";
|
|
20
|
-
import { attr, call, convertMediaUrlToVideoEmbed, getAnchorName, getAnchors, isString, isURL, position, prepareEmbedCode, refs, stripTags } from "../../core/helpers/index.js";
|
|
20
|
+
import { attr, call, convertMediaUrlToVideoEmbed, getAnchorName, getAnchors, htmlspecialchars, isString, isURL, position, prepareEmbedCode, refs, safeHTML, stripTags } from "../../core/helpers/index.js";
|
|
21
21
|
import { Plugin } from "../../core/plugin/index.js";
|
|
22
22
|
import { UIElement } from "../../core/ui/element.js";
|
|
23
23
|
import { Icon } from "../../core/ui/icon.js";
|
|
@@ -137,7 +137,7 @@ export class link extends Plugin {
|
|
|
137
137
|
__generateForm(current, close) {
|
|
138
138
|
const { jodit } = this;
|
|
139
139
|
const i18n = jodit.i18n.bind(jodit);
|
|
140
|
-
const { openInNewTabCheckbox, openInNewTabCheckboxDefaultChecked, noFollowCheckbox, formTemplate, formClassName, modeClassName } = jodit.o.link;
|
|
140
|
+
const { openInNewTabCheckbox, openInNewTabCheckboxDefaultChecked, noFollowCheckbox, formTemplate, formClassName, modeClassName, contentMode } = jodit.o.link;
|
|
141
141
|
const html = formTemplate(jodit);
|
|
142
142
|
const form = isString(html)
|
|
143
143
|
? jodit.c.fromHTML(html, {
|
|
@@ -150,7 +150,7 @@ export class link extends Plugin {
|
|
|
150
150
|
const { insert, unlink, content_input_box } = elements;
|
|
151
151
|
const { target_checkbox, nofollow_checkbox, url_input } = elements;
|
|
152
152
|
const currentElement = current;
|
|
153
|
-
const isImageContent = Dom.isImage(currentElement);
|
|
153
|
+
const isImageContent = contentMode !== 'html' && Dom.isImage(currentElement);
|
|
154
154
|
let { content_input } = elements;
|
|
155
155
|
const { className_input } = elements, { className_select } = elements, { aria_label_input } = elements;
|
|
156
156
|
if (!content_input) {
|
|
@@ -166,9 +166,14 @@ export class link extends Plugin {
|
|
|
166
166
|
Dom.hide(content_input_box);
|
|
167
167
|
}
|
|
168
168
|
let link;
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
const getSelectionContent = () => {
|
|
170
|
+
if (contentMode === 'html') {
|
|
171
|
+
return link ? link.innerHTML : jodit.s.html;
|
|
172
|
+
}
|
|
173
|
+
return link
|
|
174
|
+
? link.innerText
|
|
175
|
+
: stripTags(jodit.s.range.cloneContents(), jodit.ed);
|
|
176
|
+
};
|
|
172
177
|
if (current && Dom.closest(current, 'a', jodit.editor)) {
|
|
173
178
|
link = Dom.closest(current, 'a', jodit.editor);
|
|
174
179
|
}
|
|
@@ -176,8 +181,9 @@ export class link extends Plugin {
|
|
|
176
181
|
link = false;
|
|
177
182
|
}
|
|
178
183
|
if (!isImageContent && current) {
|
|
179
|
-
content_input.value =
|
|
184
|
+
content_input.value = getSelectionContent();
|
|
180
185
|
}
|
|
186
|
+
const initialContent = content_input.value;
|
|
181
187
|
if (aria_label_input) {
|
|
182
188
|
aria_label_input.value = link ? attr(link, 'aria-label') || '' : '';
|
|
183
189
|
}
|
|
@@ -202,7 +208,9 @@ export class link extends Plugin {
|
|
|
202
208
|
url_input &&
|
|
203
209
|
!isImageContent &&
|
|
204
210
|
!url_input.value.trim()) {
|
|
205
|
-
url_input.value = guessUrlFromText(
|
|
211
|
+
url_input.value = guessUrlFromText(contentMode === 'html'
|
|
212
|
+
? stripTags(content_input.value, jodit.ed)
|
|
213
|
+
: content_input.value);
|
|
206
214
|
}
|
|
207
215
|
if (openInNewTabCheckbox && target_checkbox) {
|
|
208
216
|
target_checkbox.checked = openInNewTabCheckboxDefaultChecked;
|
|
@@ -234,7 +242,7 @@ export class link extends Plugin {
|
|
|
234
242
|
jodit.s.removeMarkers();
|
|
235
243
|
jodit.editor.normalize();
|
|
236
244
|
jodit.history.snapshot.restore(snapshot);
|
|
237
|
-
const
|
|
245
|
+
const contentWasChanged = initialContent !== content_input.value;
|
|
238
246
|
const ci = jodit.createInside;
|
|
239
247
|
let caretAfter = null;
|
|
240
248
|
if (!link || !Dom.isOrContains(jodit.editor, link)) {
|
|
@@ -262,7 +270,7 @@ export class link extends Plugin {
|
|
|
262
270
|
attr(a, 'href', url_input.value);
|
|
263
271
|
writeClasses(modeClassName, className_input, className_select, a);
|
|
264
272
|
if (!isImageContent) {
|
|
265
|
-
|
|
273
|
+
writeContent(jodit, a, content_input.value, contentWasChanged, url_input.value, contentMode);
|
|
266
274
|
}
|
|
267
275
|
if (openInNewTabCheckbox && target_checkbox) {
|
|
268
276
|
attr(a, 'target', target_checkbox.checked ? '_blank' : null);
|
|
@@ -537,7 +545,10 @@ function addAnchorList(jodit, url, content, isImage) {
|
|
|
537
545
|
url.value = '#' + name;
|
|
538
546
|
if (!isImage &&
|
|
539
547
|
(!content.value.trim() || content.value === filled)) {
|
|
540
|
-
content.value = filled =
|
|
548
|
+
content.value = filled =
|
|
549
|
+
jodit.o.link.contentMode === 'html'
|
|
550
|
+
? htmlspecialchars(text)
|
|
551
|
+
: text;
|
|
541
552
|
}
|
|
542
553
|
url.focus();
|
|
543
554
|
});
|
|
@@ -690,18 +701,33 @@ function readClassnames(modeClassName, className_input, link, className_select)
|
|
|
690
701
|
break;
|
|
691
702
|
}
|
|
692
703
|
}
|
|
693
|
-
function
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
if (textWasChanged) {
|
|
697
|
-
newContent = content_input.value;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
else {
|
|
701
|
-
newContent = url_input.value;
|
|
704
|
+
function writeContent(editor, anchor, value, changed, url, mode) {
|
|
705
|
+
if (!changed && anchor.hasChildNodes()) {
|
|
706
|
+
return;
|
|
702
707
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
708
|
+
if (mode === 'text' || !value.trim()) {
|
|
709
|
+
anchor.textContent = value.trim() ? value : url;
|
|
710
|
+
return;
|
|
706
711
|
}
|
|
712
|
+
const sandboxDocument = editor.od.implementation.createHTMLDocument('');
|
|
713
|
+
const sandbox = sandboxDocument.createElement('div');
|
|
714
|
+
sandbox.innerHTML = value;
|
|
715
|
+
editor.e.fire('safeHTML', sandbox);
|
|
716
|
+
sanitizeLinkHTML(sandbox);
|
|
717
|
+
sandboxDocument.body.appendChild(sandbox);
|
|
718
|
+
editor.e.fire('cleanHTML', sandbox);
|
|
719
|
+
sanitizeLinkHTML(sandbox);
|
|
720
|
+
sandbox.querySelectorAll('a').forEach(link => Dom.unwrap(link));
|
|
721
|
+
Dom.detach(anchor);
|
|
722
|
+
Dom.moveContent(sandbox, anchor);
|
|
723
|
+
}
|
|
724
|
+
function sanitizeLinkHTML(sandbox) {
|
|
725
|
+
sandbox
|
|
726
|
+
.querySelectorAll('script,style,iframe,frame,frameset,object,embed,base,link,meta,template')
|
|
727
|
+
.forEach(node => Dom.safeRemove(node));
|
|
728
|
+
safeHTML(sandbox, {
|
|
729
|
+
removeEventAttributes: true,
|
|
730
|
+
removeOnError: true,
|
|
731
|
+
safeJavaScriptLink: true
|
|
732
|
+
});
|
|
707
733
|
}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
import { UIButton } from "../../core/ui/button/index.js";
|
|
7
|
-
import { UIBlock, UICheckbox, UIForm, UIInput, UISelect } from "../../core/ui/form/index.js";
|
|
7
|
+
import { UIBlock, UICheckbox, UIForm, UIInput, UISelect, UITextArea } from "../../core/ui/form/index.js";
|
|
8
8
|
export const formTemplate = (editor) => {
|
|
9
|
-
const { openInNewTabCheckbox, noFollowCheckbox, ariaLabelInput, modeClassName, selectSizeClassName, selectMultipleClassName, selectOptionsClassName } = editor.o.link;
|
|
9
|
+
const { openInNewTabCheckbox, noFollowCheckbox, ariaLabelInput, modeClassName, contentMode, selectSizeClassName, selectMultipleClassName, selectOptionsClassName } = editor.o.link;
|
|
10
10
|
return new UIForm(editor, [
|
|
11
11
|
new UIBlock(editor, [
|
|
12
12
|
new UIInput(editor, {
|
|
@@ -30,10 +30,10 @@ export const formTemplate = (editor) => {
|
|
|
30
30
|
])
|
|
31
31
|
: null,
|
|
32
32
|
new UIBlock(editor, [
|
|
33
|
-
new UIInput(editor, {
|
|
33
|
+
new (contentMode === 'html' ? UITextArea : UIInput)(editor, {
|
|
34
34
|
name: 'content',
|
|
35
35
|
ref: 'content_input',
|
|
36
|
-
label: 'Text'
|
|
36
|
+
label: contentMode === 'html' ? 'HTML' : 'Text'
|
|
37
37
|
})
|
|
38
38
|
], {
|
|
39
39
|
ref: 'content_input_box'
|
package/package.json
CHANGED
package/types/config.d.ts
CHANGED
|
@@ -1559,6 +1559,8 @@ interface Config {
|
|
|
1559
1559
|
*/
|
|
1560
1560
|
formTemplate: (editor: IJodit) => string | HTMLElement | IUIForm;
|
|
1561
1561
|
formClassName?: string;
|
|
1562
|
+
/** Content field format in the link form. Default: text. */
|
|
1563
|
+
contentMode: 'text' | 'html';
|
|
1562
1564
|
/**
|
|
1563
1565
|
* Follow link address after dblclick
|
|
1564
1566
|
*/
|
|
@@ -80,6 +80,7 @@ export declare class cleanHtml extends Plugin {
|
|
|
80
80
|
private __removeTrailingBr;
|
|
81
81
|
private __singleQuotesInFontFamily;
|
|
82
82
|
protected onSafeHTML(sandBox: HTMLElement): void;
|
|
83
|
+
protected onCleanHTML(sandBox: HTMLElement): void;
|
|
83
84
|
/** @override */
|
|
84
85
|
protected beforeDestruct(): void;
|
|
85
86
|
}
|
|
@@ -15,6 +15,8 @@ declare module 'jodit/config' {
|
|
|
15
15
|
*/
|
|
16
16
|
formTemplate: (editor: IJodit) => string | HTMLElement | IUIForm;
|
|
17
17
|
formClassName?: string;
|
|
18
|
+
/** Content field format in the link form. Default: text. */
|
|
19
|
+
contentMode: 'text' | 'html';
|
|
18
20
|
/**
|
|
19
21
|
* Follow link address after dblclick
|
|
20
22
|
*/
|