jodit 4.20.1 → 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 +22 -0
- package/es2015/jodit.css +68 -9
- package/es2015/jodit.fat.min.css +1 -1
- package/es2015/jodit.fat.min.js +10 -10
- package/es2015/jodit.js +309 -72
- package/es2015/jodit.min.css +1 -1
- package/es2015/jodit.min.js +7 -7
- 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 +10 -10
- package/es2018/jodit.min.css +1 -1
- package/es2018/jodit.min.js +7 -7
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +68 -9
- package/es2021/jodit.fat.min.css +1 -1
- package/es2021/jodit.fat.min.js +11 -11
- package/es2021/jodit.js +302 -72
- package/es2021/jodit.min.css +1 -1
- package/es2021/jodit.min.js +7 -7
- 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 +68 -9
- package/es2021.en/jodit.fat.min.css +1 -1
- package/es2021.en/jodit.fat.min.js +19 -19
- package/es2021.en/jodit.js +302 -72
- package/es2021.en/jodit.min.css +1 -1
- package/es2021.en/jodit.min.js +19 -19
- 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 +45 -2
- package/es5/jodit.fat.min.css +1 -1
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +358 -74
- 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/core/constants.js +1 -1
- package/esm/modules/file-browser/builders/context-menu.js +6 -2
- package/esm/modules/toolbar/button/button.d.ts +10 -0
- package/esm/modules/toolbar/button/button.js +17 -2
- package/esm/modules/toolbar/button/select/select.d.ts +6 -0
- package/esm/modules/toolbar/button/select/select.js +18 -0
- package/esm/modules/toolbar/factory.js +3 -1
- package/esm/modules/widget/color-picker/color-picker.js +76 -18
- package/esm/plugins/anchor/anchor.d.ts +11 -0
- package/esm/plugins/anchor/anchor.js +84 -8
- 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/fullsize/config.js +2 -0
- package/esm/plugins/hr/hr.js +0 -1
- package/esm/plugins/line-height/config.js +0 -1
- package/esm/plugins/placeholder/placeholder.js +3 -1
- package/esm/types/toolbar.d.ts +2 -0
- package/package.json +1 -1
- package/types/modules/toolbar/button/button.d.ts +10 -0
- package/types/modules/toolbar/button/select/select.d.ts +6 -0
- package/types/plugins/anchor/anchor.d.ts +11 -0
- package/types/plugins/delete/delete.d.ts +12 -0
- package/types/plugins/delete/interface.d.ts +4 -2
- package/types/types/toolbar.d.ts +2 -0
|
@@ -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
|
}
|
|
@@ -15,6 +15,8 @@ Config.prototype.controls.fullsize = {
|
|
|
15
15
|
exec: (editor) => {
|
|
16
16
|
editor.toggleFullSize();
|
|
17
17
|
},
|
|
18
|
+
// Makes it a toggle. `update` sets the state, which holds while the editor doesn't have the focus
|
|
19
|
+
isActive: (editor) => editor.isFullSize,
|
|
18
20
|
update(editor, button) {
|
|
19
21
|
const mode = editor.isFullSize ? 'shrink' : 'fullsize';
|
|
20
22
|
button.state.activated = editor.isFullSize;
|
package/esm/plugins/hr/hr.js
CHANGED
|
@@ -11,7 +11,6 @@ Config.prototype.defaultLineHeight = null;
|
|
|
11
11
|
Icon.set('line-height', lineHeightIcon);
|
|
12
12
|
Config.prototype.controls.lineHeight = {
|
|
13
13
|
command: 'applyLineHeight',
|
|
14
|
-
tags: ['ol'],
|
|
15
14
|
tooltip: 'Line height',
|
|
16
15
|
list: [1, 1.1, 1.2, 1.3, 1.4, 1.5, 2],
|
|
17
16
|
exec: (editor, event, { control }) => memorizeExec(editor, event, { control }, (value) => value)
|
|
@@ -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/esm/types/toolbar.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ interface IControlType<T extends IViewBased = IJodit | IViewBased | IFileBrowser
|
|
|
25
25
|
/**
|
|
26
26
|
* You can use it function for control - active/not active button
|
|
27
27
|
*
|
|
28
|
+
* A button with `isActive`, `tags` or `css` is a toggle, with `aria-pressed`
|
|
29
|
+
*
|
|
28
30
|
* @see copyformat plugin
|
|
29
31
|
* @example
|
|
30
32
|
* ```javascript
|
package/package.json
CHANGED
|
@@ -47,6 +47,16 @@ export declare class ToolbarButton<T extends IViewBased = IViewBased> extends UI
|
|
|
47
47
|
* Calculates whether an element is blocked for the user
|
|
48
48
|
*/
|
|
49
49
|
private __calculateDisabledStatus;
|
|
50
|
+
/**
|
|
51
|
+
* A button that its control can show as on is a toggle, and says whether
|
|
52
|
+
* it's pressed
|
|
53
|
+
*/
|
|
54
|
+
protected get isToggle(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The pressed look comes from the mod, as any button looks pressed while
|
|
57
|
+
* its list is open, and the container is a `listitem`, which can't have
|
|
58
|
+
* `aria-pressed`
|
|
59
|
+
*/
|
|
50
60
|
protected onChangeActivated(): void;
|
|
51
61
|
protected onChangeText(): void;
|
|
52
62
|
protected onChangeTabIndex(): void;
|
|
@@ -10,5 +10,11 @@ import type { IViewBased } from "../../../../types/index";
|
|
|
10
10
|
import { ToolbarButton } from "../button";
|
|
11
11
|
export declare class ToolbarSelect<T extends IViewBased = IViewBased> extends ToolbarButton<T> {
|
|
12
12
|
className(): string;
|
|
13
|
+
protected get isToggle(): boolean;
|
|
13
14
|
update(): void;
|
|
15
|
+
/**
|
|
16
|
+
* The button shows only the value, so its name says which control it
|
|
17
|
+
* is too: "Font size, 16px"
|
|
18
|
+
*/
|
|
19
|
+
protected updateAriaLabel(): void;
|
|
14
20
|
}
|
|
@@ -35,6 +35,11 @@ export declare class anchor extends Plugin {
|
|
|
35
35
|
protected onAfterGetValueFromEditor(data: {
|
|
36
36
|
value: string;
|
|
37
37
|
}): void;
|
|
38
|
+
/**
|
|
39
|
+
* A pasted or dropped copy of an anchor the document already has gets the
|
|
40
|
+
* next free name, as `fees-2`, and the links that came with it follow it
|
|
41
|
+
*/
|
|
42
|
+
protected onBeforePasteInsert(html: unknown): string | void;
|
|
38
43
|
/**
|
|
39
44
|
* The form that names a new anchor, or renames or removes `target`
|
|
40
45
|
*/
|
|
@@ -62,6 +67,12 @@ export declare class anchor extends Plugin {
|
|
|
62
67
|
* something else by the old one, as they do after a copy is pasted
|
|
63
68
|
*/
|
|
64
69
|
private __rename;
|
|
70
|
+
/**
|
|
71
|
+
* Gives each anchor in `root` whose name the document already has the
|
|
72
|
+
* next free one, avoiding the names in `root` too, and points the links
|
|
73
|
+
* in `root` to it at the new name. Whether any was renamed
|
|
74
|
+
*/
|
|
75
|
+
private __renameCopies;
|
|
65
76
|
/** @override */
|
|
66
77
|
protected beforeDestruct(jodit: IJodit): void;
|
|
67
78
|
}
|
|
@@ -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
|
}
|
package/types/types/toolbar.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ interface IControlType<T extends IViewBased = IJodit | IViewBased | IFileBrowser
|
|
|
25
25
|
/**
|
|
26
26
|
* You can use it function for control - active/not active button
|
|
27
27
|
*
|
|
28
|
+
* A button with `isActive`, `tags` or `css` is a toggle, with `aria-pressed`
|
|
29
|
+
*
|
|
28
30
|
* @see copyformat plugin
|
|
29
31
|
* @example
|
|
30
32
|
* ```javascript
|