jodit 4.20.2 → 4.20.3
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 +10 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +6 -6
- package/es2015/jodit.js +90 -21
- package/es2015/jodit.min.js +6 -6
- 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 +6 -6
- package/es2018/jodit.min.js +6 -6
- 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 +6 -6
- package/es2021/jodit.js +87 -21
- package/es2021/jodit.min.js +6 -6
- 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 +87 -21
- package/es2021.en/jodit.min.js +6 -6
- 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 +98 -21
- 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.js +1 -1
- package/esm/modules/file-browser/builders/context-menu.js +6 -2
- package/esm/modules/toolbar/factory.js +3 -1
- package/esm/plugins/backspace/cases/check-not-collapsed.js +1 -1
- package/esm/plugins/delete/delete.d.ts +12 -0
- package/esm/plugins/delete/delete.js +66 -4
- package/esm/plugins/delete/interface.d.ts +4 -2
- package/esm/plugins/dtd/after-insert/remove-extra-br.js +7 -1
- package/esm/plugins/placeholder/placeholder.js +3 -1
- package/package.json +1 -1
- package/types/plugins/delete/delete.d.ts +12 -0
- package/types/plugins/delete/interface.d.ts +4 -2
package/es5/polyfills.fat.min.js
CHANGED
package/es5/polyfills.js
CHANGED
package/es5/polyfills.min.js
CHANGED
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.3";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
|
@@ -81,12 +81,13 @@ export default (self) => {
|
|
|
81
81
|
}), temp_content = self.c.div(CLASS_PREVIEW, '<div class="jodit-icon_loader"></div>'), preview_box = self.c.div(CLASS_PREVIEW + '__box'), next = self.c.fromHTML(preview_tpl_next()), prev = self.c.fromHTML(preview_tpl_next('prev', 'left')), addLoadHandler = (src) => {
|
|
82
82
|
const image = self.c.element('img');
|
|
83
83
|
attr(image, 'src', src);
|
|
84
|
+
attr(image, 'alt', ga('data-name'));
|
|
84
85
|
const onload = () => {
|
|
85
86
|
var _a;
|
|
86
87
|
if (self.isInDestruct) {
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
self.e.off(image, 'load');
|
|
90
|
+
self.e.off(image, 'load error');
|
|
90
91
|
Dom.detach(temp_content);
|
|
91
92
|
if (opt.showPreviewNavigation) {
|
|
92
93
|
if (Dom.prevWithClass(item, self.files.getFullElName('item'))) {
|
|
@@ -101,7 +102,10 @@ export default (self) => {
|
|
|
101
102
|
preview.setPosition();
|
|
102
103
|
(_a = self === null || self === void 0 ? void 0 : self.events) === null || _a === void 0 ? void 0 : _a.fire('previewOpenedAndLoaded');
|
|
103
104
|
};
|
|
104
|
-
|
|
105
|
+
// An image that can't load is shown too,
|
|
106
|
+
// broken with the file's name, rather
|
|
107
|
+
// than the loader for good
|
|
108
|
+
self.e.on(image, 'load error', onload);
|
|
105
109
|
if (image.complete) {
|
|
106
110
|
onload();
|
|
107
111
|
}
|
|
@@ -41,5 +41,7 @@ export function makeButton(jodit, control, target = null) {
|
|
|
41
41
|
}
|
|
42
42
|
export function makeSelect(view, control, target = null) {
|
|
43
43
|
const ToolbarSelect = getComponentClass('ToolbarSelect');
|
|
44
|
-
|
|
44
|
+
const select = new ToolbarSelect(view, control, target);
|
|
45
|
+
select.state.tabIndex = view.o.allowTabNavigation ? 0 : -1;
|
|
46
|
+
return select;
|
|
45
47
|
}
|
|
@@ -27,6 +27,18 @@ export declare class deleteCommand extends Plugin {
|
|
|
27
27
|
* Firefox's own delete
|
|
28
28
|
*/
|
|
29
29
|
private __moveEdgesIntoCells;
|
|
30
|
+
/**
|
|
31
|
+
* The formatting elements the deletion takes whole from its start,
|
|
32
|
+
* outermost first: `<strong>` and `<em>` for all of the text in
|
|
33
|
+
* `<strong><em>cd</em></strong>`
|
|
34
|
+
*/
|
|
35
|
+
private __formatTakenWhole;
|
|
36
|
+
/**
|
|
37
|
+
* As the browsers do, the next letter typed keeps the formatting that was
|
|
38
|
+
* deleted whole: empty copies go where it was, round an invisible space,
|
|
39
|
+
* as Bold does at a collapsed caret, and the caret goes inside (#1784)
|
|
40
|
+
*/
|
|
41
|
+
private __keepFormat;
|
|
30
42
|
/**
|
|
31
43
|
* A selection that starts or ends in a table cell clears the selected part
|
|
32
44
|
* of each cell it covers and keeps the cells, as the browsers do.
|
|
@@ -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
|
-
import { NBSP_SPACE } from "../../core/constants.js";
|
|
6
|
+
import { INVISIBLE_SPACE, NBSP_SPACE } from "../../core/constants.js";
|
|
7
7
|
import { Dom } from "../../core/dom/index.js";
|
|
8
8
|
import { pluginSystem } from "../../core/global.js";
|
|
9
9
|
import { call, toArray, trimInv } from "../../core/helpers/index.js";
|
|
@@ -18,6 +18,18 @@ const NOT_EMPTY_CONTENT_TAGS = new Set([
|
|
|
18
18
|
'hr'
|
|
19
19
|
]);
|
|
20
20
|
const KEEPS_SPACES = new Set(['pre', 'pre-wrap', 'break-spaces']);
|
|
21
|
+
/**
|
|
22
|
+
* Formatting that the next letter keeps once all of the text in it is
|
|
23
|
+
* deleted with a key: a formatting tag, or a span with styles of its own.
|
|
24
|
+
* Not a link, which new text isn't added to, or a wrapper such as a video's
|
|
25
|
+
*/
|
|
26
|
+
function keepsFormat(node) {
|
|
27
|
+
return (Dom.isHTMLElement(node) &&
|
|
28
|
+
!node.hasAttribute('contenteditable') &&
|
|
29
|
+
!Dom.isTemporary(node) &&
|
|
30
|
+
(/^(STRONG|B|EM|I|U|S|SUB|SUP)$/.test(node.nodeName) ||
|
|
31
|
+
(Dom.isTag(node, 'span') && node.hasAttribute('style'))));
|
|
32
|
+
}
|
|
21
33
|
/**
|
|
22
34
|
* A plain space beside this neighbor isn't shown: there is none, or it's a
|
|
23
35
|
* line break, a block or text starting (or ending) with a plain space
|
|
@@ -76,7 +88,7 @@ export class deleteCommand extends Plugin {
|
|
|
76
88
|
jodit.s.removeNode(node);
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
__onDeleteCommand() {
|
|
91
|
+
__onDeleteCommand(command, showUI, keepFormat) {
|
|
80
92
|
const { jodit } = this;
|
|
81
93
|
if (jodit.s.isCollapsed()) {
|
|
82
94
|
return;
|
|
@@ -84,6 +96,7 @@ export class deleteCommand extends Plugin {
|
|
|
84
96
|
jodit.s.expandSelection();
|
|
85
97
|
const range = jodit.s.range;
|
|
86
98
|
this.__moveEdgesIntoCells(range);
|
|
99
|
+
const format = keepFormat === true ? this.__formatTakenWhole(range) : [];
|
|
87
100
|
const caret = this.__clearSelectedCells(range);
|
|
88
101
|
if (caret && range.collapsed) {
|
|
89
102
|
jodit.s.selectRange(caret);
|
|
@@ -99,8 +112,13 @@ export class deleteCommand extends Plugin {
|
|
|
99
112
|
this.__keepSpacesVisibleBesideTable(fake);
|
|
100
113
|
range.setStartBefore(fake);
|
|
101
114
|
range.collapse(true);
|
|
102
|
-
|
|
103
|
-
|
|
115
|
+
if (format.length && !caret) {
|
|
116
|
+
this.__keepFormat(format, fake, range);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.__moveCursorInEditableSibling(jodit, leftSibling, fake, range);
|
|
120
|
+
this.__addBrInEmptyBlock(fake, range);
|
|
121
|
+
}
|
|
104
122
|
Dom.safeRemove(fake);
|
|
105
123
|
jodit.s.selectRange(caret !== null && caret !== void 0 ? caret : range);
|
|
106
124
|
return false;
|
|
@@ -126,6 +144,50 @@ export class deleteCommand extends Plugin {
|
|
|
126
144
|
range.setEnd(last, last.childNodes.length);
|
|
127
145
|
}
|
|
128
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* The formatting elements the deletion takes whole from its start,
|
|
149
|
+
* outermost first: `<strong>` and `<em>` for all of the text in
|
|
150
|
+
* `<strong><em>cd</em></strong>`
|
|
151
|
+
*/
|
|
152
|
+
__formatTakenWhole(range) {
|
|
153
|
+
const format = [];
|
|
154
|
+
const whole = this.jodit.s.createRange();
|
|
155
|
+
const { startContainer, startOffset } = range;
|
|
156
|
+
let node = Dom.isText(startContainer)
|
|
157
|
+
? null
|
|
158
|
+
: startContainer.childNodes[startOffset];
|
|
159
|
+
// Through a block taken whole, as a line holding only the word is
|
|
160
|
+
while (Dom.isHTMLElement(node)) {
|
|
161
|
+
whole.selectNode(node);
|
|
162
|
+
if (range.compareBoundaryPoints(Range.END_TO_END, whole) < 0) {
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
if (keepsFormat(node)) {
|
|
166
|
+
format.push(node);
|
|
167
|
+
}
|
|
168
|
+
else if (format.length || !Dom.isBlock(node)) {
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
node = toArray(node.childNodes).find(child => { var _a; return !Dom.isText(child) || trimInv((_a = child.nodeValue) !== null && _a !== void 0 ? _a : ''); });
|
|
172
|
+
}
|
|
173
|
+
return format;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* As the browsers do, the next letter typed keeps the formatting that was
|
|
177
|
+
* deleted whole: empty copies go where it was, round an invisible space,
|
|
178
|
+
* as Bold does at a collapsed caret, and the caret goes inside (#1784)
|
|
179
|
+
*/
|
|
180
|
+
__keepFormat(format, fake, range) {
|
|
181
|
+
const copies = format.map(element => element.cloneNode(false));
|
|
182
|
+
for (let i = 1; i < copies.length; i += 1) {
|
|
183
|
+
Dom.append(copies[i - 1], copies[i]);
|
|
184
|
+
}
|
|
185
|
+
const text = this.jodit.createInside.text(INVISIBLE_SPACE);
|
|
186
|
+
Dom.append(copies[copies.length - 1], text);
|
|
187
|
+
Dom.before(fake, copies[0]);
|
|
188
|
+
range.setStartAfter(text);
|
|
189
|
+
range.collapse(true);
|
|
190
|
+
}
|
|
129
191
|
/**
|
|
130
192
|
* A selection that starts or ends in a table cell clears the selected part
|
|
131
193
|
* of each cell it covers and keeps the cells, as the browsers do.
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
declare module 'jodit/types/jodit' {
|
|
10
10
|
interface IJodit {
|
|
11
11
|
/**
|
|
12
|
-
* Delete plugin: Remove selected text
|
|
12
|
+
* Delete plugin: Remove selected text. With `keepFormat`, as after
|
|
13
|
+
* Backspace or Delete, the next letter keeps the formatting of an
|
|
14
|
+
* element whose text was deleted whole
|
|
13
15
|
*/
|
|
14
|
-
execCommand(command: 'delete'): void;
|
|
16
|
+
execCommand(command: 'delete', showUI?: boolean, keepFormat?: boolean): void;
|
|
15
17
|
}
|
|
16
18
|
}
|
|
@@ -37,7 +37,13 @@ export function removeExtraBr(jodit, node) {
|
|
|
37
37
|
// text; moving it before the `<br>` would put it on a line of its own
|
|
38
38
|
// below the block (#1315)
|
|
39
39
|
if (!Dom.isOrContains(node, jodit.s.range.startContainer)) {
|
|
40
|
-
|
|
40
|
+
// Not with setCursorBefore: the text node it adds for the caret
|
|
41
|
+
// stays after the inserted element once the `<br>` has gone, and
|
|
42
|
+
// Right or End then take the caret into it, out of the element
|
|
43
|
+
const range = jodit.s.createRange();
|
|
44
|
+
range.setStartBefore(br);
|
|
45
|
+
range.collapse(true);
|
|
46
|
+
jodit.s.selectRange(range);
|
|
41
47
|
}
|
|
42
48
|
Dom.safeRemove(br);
|
|
43
49
|
}
|
|
@@ -19,6 +19,7 @@ import { debounce } from "../../core/decorators/index.js";
|
|
|
19
19
|
import { Dom } from "../../core/dom/dom.js";
|
|
20
20
|
import { pluginSystem } from "../../core/global.js";
|
|
21
21
|
import { isMarker } from "../../core/helpers/checker/is-marker.js";
|
|
22
|
+
import { isAnchor } from "../../core/helpers/utils/anchor.js";
|
|
22
23
|
import { attr } from "../../core/helpers/utils/attr.js";
|
|
23
24
|
import { css } from "../../core/helpers/utils/css.js";
|
|
24
25
|
import { Plugin } from "../../core/plugin/plugin.js";
|
|
@@ -51,8 +52,9 @@ function isBlank(root) {
|
|
|
51
52
|
if (Dom.isText(first) && !next) {
|
|
52
53
|
return Dom.isEmptyTextNode(first);
|
|
53
54
|
}
|
|
55
|
+
// An anchor has no text, but it's content, shown as a marker
|
|
54
56
|
return (!next &&
|
|
55
|
-
Dom.each(first, elm => !(Dom.isLeaf(elm) || Dom.isList(elm)) &&
|
|
57
|
+
Dom.each(first, elm => !(Dom.isLeaf(elm) || Dom.isList(elm) || isAnchor(elm)) &&
|
|
56
58
|
(Dom.isEmpty(elm) || Dom.isTag(elm, 'br'))));
|
|
57
59
|
}
|
|
58
60
|
/**
|
package/package.json
CHANGED
|
@@ -27,6 +27,18 @@ export declare class deleteCommand extends Plugin {
|
|
|
27
27
|
* Firefox's own delete
|
|
28
28
|
*/
|
|
29
29
|
private __moveEdgesIntoCells;
|
|
30
|
+
/**
|
|
31
|
+
* The formatting elements the deletion takes whole from its start,
|
|
32
|
+
* outermost first: `<strong>` and `<em>` for all of the text in
|
|
33
|
+
* `<strong><em>cd</em></strong>`
|
|
34
|
+
*/
|
|
35
|
+
private __formatTakenWhole;
|
|
36
|
+
/**
|
|
37
|
+
* As the browsers do, the next letter typed keeps the formatting that was
|
|
38
|
+
* deleted whole: empty copies go where it was, round an invisible space,
|
|
39
|
+
* as Bold does at a collapsed caret, and the caret goes inside (#1784)
|
|
40
|
+
*/
|
|
41
|
+
private __keepFormat;
|
|
30
42
|
/**
|
|
31
43
|
* A selection that starts or ends in a table cell clears the selected part
|
|
32
44
|
* of each cell it covers and keeps the cells, as the browsers do.
|
|
@@ -9,8 +9,10 @@
|
|
|
9
9
|
declare module 'jodit/types/jodit' {
|
|
10
10
|
interface IJodit {
|
|
11
11
|
/**
|
|
12
|
-
* Delete plugin: Remove selected text
|
|
12
|
+
* Delete plugin: Remove selected text. With `keepFormat`, as after
|
|
13
|
+
* Backspace or Delete, the next letter keeps the formatting of an
|
|
14
|
+
* element whose text was deleted whole
|
|
13
15
|
*/
|
|
14
|
-
execCommand(command: 'delete'): void;
|
|
16
|
+
execCommand(command: 'delete', showUI?: boolean, keepFormat?: boolean): void;
|
|
15
17
|
}
|
|
16
18
|
}
|