jodit 4.12.35 → 4.12.36
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 +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +105 -49
- package/es2015/jodit.min.js +2 -2
- 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 +2 -2
- package/es2018/jodit.min.js +2 -2
- 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 +3 -3
- package/es2021/jodit.js +104 -47
- package/es2021/jodit.min.js +3 -3
- 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 +3 -3
- package/es2021.en/jodit.js +104 -47
- package/es2021.en/jodit.min.js +3 -3
- 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 +254 -195
- 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/core/dom/dom.d.ts +35 -12
- package/esm/core/dom/dom.js +42 -20
- package/esm/core/dom/lazy-walker.d.ts +18 -1
- package/esm/core/dom/lazy-walker.js +23 -3
- package/esm/core/selection/helpers/index.d.ts +3 -1
- package/esm/core/selection/helpers/index.js +3 -1
- package/esm/core/selection/selection.d.ts +14 -0
- package/esm/core/selection/selection.js +19 -8
- package/esm/core/selection/style/api/is-same-attributes.d.ts +4 -2
- package/esm/core/selection/style/api/is-same-attributes.js +3 -4
- package/esm/core/selection/style/api/is-suit-element.d.ts +2 -1
- package/esm/core/selection/style/api/is-suit-element.js +2 -1
- package/esm/core/selection/style/api/list/toggle-ordered-list.js +7 -0
- package/esm/core/selection/style/api/toggle-attributes.js +3 -1
- package/esm/core/selection/style/commit-style.d.ts +1 -1
- package/esm/core/selection/style/commit-style.js +2 -2
- package/package.json +1 -1
- package/types/core/dom/dom.d.ts +35 -12
- package/types/core/dom/lazy-walker.d.ts +18 -1
- package/types/core/selection/helpers/index.d.ts +3 -1
- package/types/core/selection/selection.d.ts +14 -0
- package/types/core/selection/style/api/is-same-attributes.d.ts +4 -2
- package/types/core/selection/style/api/is-suit-element.d.ts +2 -1
- package/types/core/selection/style/commit-style.d.ts +1 -1
|
@@ -12,7 +12,8 @@ import type { ICommitStyle, Nullable } from "../../../../types/index";
|
|
|
12
12
|
* @param commitStyle - style commit
|
|
13
13
|
* @param elm - checked item
|
|
14
14
|
* @param strict - strict mode - false - the default tag is suitable for us if it is also in the commit
|
|
15
|
-
* @param strictStyle - strict style mode - true - the element
|
|
15
|
+
* @param strictStyle - strict style mode - true - the element must have the same style keys AND values
|
|
16
|
+
* as in the commit, false - matching style keys are enough
|
|
16
17
|
* @private
|
|
17
18
|
*/
|
|
18
19
|
export declare function isSuitElement(commitStyle: ICommitStyle, elm: Nullable<Node>, strict: boolean, strictStyle?: boolean): elm is HTMLElement;
|
|
@@ -9,7 +9,8 @@ import { isNormalNode } from "./is-normal-node.js";
|
|
|
9
9
|
* @param commitStyle - style commit
|
|
10
10
|
* @param elm - checked item
|
|
11
11
|
* @param strict - strict mode - false - the default tag is suitable for us if it is also in the commit
|
|
12
|
-
* @param strictStyle - strict style mode - true - the element
|
|
12
|
+
* @param strictStyle - strict style mode - true - the element must have the same style keys AND values
|
|
13
|
+
* as in the commit, false - matching style keys are enough
|
|
13
14
|
* @private
|
|
14
15
|
*/
|
|
15
16
|
export function isSuitElement(commitStyle, elm, strict, strictStyle = true) {
|
|
@@ -51,6 +51,13 @@ function unwrapList(mode, list, li, jodit, cs) {
|
|
|
51
51
|
extractSelectedPart(list, li, jodit);
|
|
52
52
|
assert(Dom.isHTMLElement(li.parentElement), 'Element should be inside the list');
|
|
53
53
|
Dom.unwrap(li.parentElement);
|
|
54
|
+
// In the REPLACE mode the content will be immediately wrapped in a `li`
|
|
55
|
+
// of the new list inside `wrapList`, so it should stay in the document.
|
|
56
|
+
// Replacing it with a fragment here would dissolve the content
|
|
57
|
+
// (with `enter: 'br'`) and the new list would never be inserted.
|
|
58
|
+
if (mode === REPLACE) {
|
|
59
|
+
return li;
|
|
60
|
+
}
|
|
54
61
|
return Dom.replace(li, jodit.o.enter.toLowerCase() !== 'br'
|
|
55
62
|
? jodit.o.enter
|
|
56
63
|
: jodit.createInside.fragment(), jodit.createInside);
|
|
@@ -95,7 +95,9 @@ function toggleClass(jodit, value, elm, mode, dry) {
|
|
|
95
95
|
function toggleAttribute(jodit, value, elm, key, dry, mode) {
|
|
96
96
|
assert(isString(value) || isNumber(value) || isBoolean(value) || value == null, 'Attribute value must be a string or number or boolean or null');
|
|
97
97
|
const hook = jodit.e.fire.bind(jodit.e, `${_PREFIX}AfterToggleAttribute`);
|
|
98
|
-
|
|
98
|
+
// `attr()` getter always returns a string, so a number/boolean value
|
|
99
|
+
// must be normalized, otherwise the toggle-off branch is unreachable
|
|
100
|
+
if (attr(elm, key) === (value == null ? value : String(value))) {
|
|
99
101
|
!dry && attr(elm, key, null);
|
|
100
102
|
mode = UNSET;
|
|
101
103
|
!dry && hook(mode, elm, key, value);
|
|
@@ -13,7 +13,7 @@ export class CommitStyle {
|
|
|
13
13
|
if (!data) {
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
return data[key];
|
|
16
|
+
return Boolean(data[key]);
|
|
17
17
|
}
|
|
18
18
|
setApplied(elm, key) {
|
|
19
19
|
var _a;
|
|
@@ -28,7 +28,7 @@ export class CommitStyle {
|
|
|
28
28
|
return this.options.element || this.defaultTag;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* New element is
|
|
31
|
+
* New element is a block element
|
|
32
32
|
*/
|
|
33
33
|
get elementIsBlock() {
|
|
34
34
|
return Boolean(this.options.element && IS_BLOCK.test(this.options.element));
|
package/package.json
CHANGED
package/types/core/dom/dom.d.ts
CHANGED
|
@@ -34,7 +34,11 @@ export declare class Dom {
|
|
|
34
34
|
*/
|
|
35
35
|
static unwrap(node: Node): void;
|
|
36
36
|
/**
|
|
37
|
-
* Call
|
|
37
|
+
* Call callback for all nodes between `start` and `end` in document order
|
|
38
|
+
* (`start` and `end` are not included). Iteration stops when the callback returns `true`.
|
|
39
|
+
*
|
|
40
|
+
* `end` must be positioned after `start` in the document (e.g. selection markers),
|
|
41
|
+
* otherwise iteration will stop only at the end of the tree.
|
|
38
42
|
*/
|
|
39
43
|
static between(start: Node, end: Node, callback: (node: Node) => void | boolean): void;
|
|
40
44
|
/**
|
|
@@ -46,14 +50,18 @@ export declare class Dom {
|
|
|
46
50
|
* @param notMoveContent - false - Move content from elm to newTagName
|
|
47
51
|
* @example
|
|
48
52
|
* ```javascript
|
|
49
|
-
* Jodit.modules.Dom.replace(
|
|
50
|
-
*
|
|
53
|
+
* Jodit.modules.Dom.replace(
|
|
54
|
+
* parent.editor.getElementsByTagName('span')[0],
|
|
55
|
+
* 'p',
|
|
56
|
+
* parent.createInside
|
|
57
|
+
* );
|
|
58
|
+
* // Replace the first <span> element to the <p>
|
|
51
59
|
* ```
|
|
52
60
|
*/
|
|
53
|
-
static replace<T extends HTMLElement>(elm: Node, newTagName: HTMLTagNames): T;
|
|
54
61
|
static replace<T extends HTMLElement>(elm: Node, newTagName: HTMLTagNames, create: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
|
|
55
|
-
static replace<T extends Node>(elm: Node,
|
|
56
|
-
static replace<T extends Node>(elm: Node,
|
|
62
|
+
static replace<T extends Node>(elm: Node, newElement: T, create?: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
|
|
63
|
+
static replace<T extends Node>(elm: Node, html: string, create: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
|
|
64
|
+
static replace<T extends Node>(elm: Node, newTagNameOrElement: HTMLTagNames | T, create: ICreate, withAttributes?: boolean, notMoveContent?: boolean): T;
|
|
57
65
|
/**
|
|
58
66
|
* Checks whether the Node text and blank (in this case it may contain invisible auxiliary characters ,
|
|
59
67
|
* it is also empty )
|
|
@@ -80,9 +88,9 @@ export declare class Dom {
|
|
|
80
88
|
*/
|
|
81
89
|
static isCell(elm: unknown): elm is HTMLTableCellElement;
|
|
82
90
|
/**
|
|
83
|
-
* Check if element is a list
|
|
91
|
+
* Check if element is a list element UL or OL
|
|
84
92
|
*/
|
|
85
|
-
static isList(elm: Nullable<Node>): elm is HTMLOListElement;
|
|
93
|
+
static isList(elm: Nullable<Node>): elm is HTMLUListElement | HTMLOListElement;
|
|
86
94
|
/**
|
|
87
95
|
* Check if element is a part of list element LI
|
|
88
96
|
*/
|
|
@@ -103,7 +111,7 @@ export declare class Dom {
|
|
|
103
111
|
/**
|
|
104
112
|
* Check if element is comment node
|
|
105
113
|
*/
|
|
106
|
-
static isComment(node: Node): node is Comment;
|
|
114
|
+
static isComment(node: Nullable<Node> | false): node is Comment;
|
|
107
115
|
/**
|
|
108
116
|
* Check if element is element node
|
|
109
117
|
*/
|
|
@@ -147,7 +155,9 @@ export declare class Dom {
|
|
|
147
155
|
*/
|
|
148
156
|
static find<T extends Node = Node>(node: Node, condition: NodeCondition, root: HTMLElement, leftToRight?: boolean, withChild?: boolean): Nullable<T>;
|
|
149
157
|
/**
|
|
150
|
-
*
|
|
158
|
+
* Lazily iterate over all nodes what follow after `start` (in document order
|
|
159
|
+
* for `leftToRight = true`, in reverse order otherwise) inside `root`.
|
|
160
|
+
* Ancestors of `start` are not yielded.
|
|
151
161
|
*/
|
|
152
162
|
static nextGen(start: Node, root: HTMLElement, leftToRight?: boolean, withChild?: boolean): Generator<Node>;
|
|
153
163
|
/**
|
|
@@ -159,7 +169,7 @@ export declare class Dom {
|
|
|
159
169
|
* ```javascript
|
|
160
170
|
* Jodit.modules.Dom.each(editor.s.current(), function (node) {
|
|
161
171
|
* if (node.nodeType === Node.TEXT_NODE) {
|
|
162
|
-
* node.nodeValue = node.nodeValue.replace(Jodit.
|
|
172
|
+
* node.nodeValue = node.nodeValue.replace(Jodit.INVISIBLE_SPACE_REG_EXP(), '') // remove all of the text element codes invisible character
|
|
163
173
|
* }
|
|
164
174
|
* });
|
|
165
175
|
* ```
|
|
@@ -183,9 +193,16 @@ export declare class Dom {
|
|
|
183
193
|
* Returns the nearest non-empty neighbor
|
|
184
194
|
*/
|
|
185
195
|
static findNotEmptyNeighbor(node: Node, left: boolean, root: HTMLElement): Nullable<Node>;
|
|
196
|
+
/**
|
|
197
|
+
* Returns the previous (`left = true`) or next sibling of the node
|
|
198
|
+
*/
|
|
186
199
|
static sibling(node: Node, left?: boolean): Nullable<Node>;
|
|
187
200
|
/**
|
|
188
201
|
* It goes through all the elements in ascending order, and checks to see if they meet the predetermined condition
|
|
202
|
+
*
|
|
203
|
+
* The condition is checked for the `node` itself too. The `root` reached
|
|
204
|
+
* while ascending is checked only when `checkRoot = true`
|
|
205
|
+
* (but if `node === root` it is checked in any case).
|
|
189
206
|
*/
|
|
190
207
|
static up<T extends HTMLElement>(node: Nullable<Node>, condition: NodeCondition, root?: Node, checkRoot?: boolean): Nullable<T>;
|
|
191
208
|
/**
|
|
@@ -232,6 +249,12 @@ export declare class Dom {
|
|
|
232
249
|
* Safe remove element from DOM
|
|
233
250
|
*/
|
|
234
251
|
static safeRemove(...nodes: unknown[]): void;
|
|
252
|
+
/**
|
|
253
|
+
* Insert a node into the range and collapse the range to the start of
|
|
254
|
+
* the inserted content. Unlike the native `Range.insertNode` it does not
|
|
255
|
+
* split inseparable elements (BR, HR, IMG etc.) and removes empty text
|
|
256
|
+
* nodes produced by the split of a text container.
|
|
257
|
+
*/
|
|
235
258
|
static safeInsertNode(range: Range, node: Node): void;
|
|
236
259
|
/**
|
|
237
260
|
* Hide element
|
|
@@ -259,7 +282,7 @@ export declare class Dom {
|
|
|
259
282
|
*/
|
|
260
283
|
static isMarker(elm: Nullable<Node>): elm is HTMLElement;
|
|
261
284
|
/**
|
|
262
|
-
*
|
|
285
|
+
* Unwrap temporary elements inside a HTML string (keeps their content)
|
|
263
286
|
*/
|
|
264
287
|
static replaceTemporaryFromString(value: string): string;
|
|
265
288
|
/**
|
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { IAsync, IDestructible } from "../../types/index";
|
|
10
10
|
import { Eventify } from "../event-emitter/eventify";
|
|
11
|
+
/**
|
|
12
|
+
* Walks the DOM tree in small chunks between browser tasks so that even huge
|
|
13
|
+
* documents do not block the main thread.
|
|
14
|
+
*
|
|
15
|
+
* Events:
|
|
16
|
+
* - `visit` - is called for every node; return `true` to mark the pass as
|
|
17
|
+
* "had effect" (it will be passed into the `end` event)
|
|
18
|
+
* - `break` - the pass was interrupted via [[LazyWalker.break]]
|
|
19
|
+
* - `end` - the pass is finished, receives `true` if some `visit` handler returned `true`
|
|
20
|
+
*/
|
|
11
21
|
export declare class LazyWalker extends Eventify<{
|
|
12
22
|
visit: (node: Node) => boolean;
|
|
13
23
|
break: (reason?: string) => void;
|
|
@@ -16,17 +26,24 @@ export declare class LazyWalker extends Eventify<{
|
|
|
16
26
|
private readonly async;
|
|
17
27
|
private readonly options;
|
|
18
28
|
private workNodes;
|
|
29
|
+
/**
|
|
30
|
+
* Starts a new pass over the `root` tree.
|
|
31
|
+
* If a previous pass is still running it will be stopped first.
|
|
32
|
+
*/
|
|
19
33
|
setWork(root: Node): this;
|
|
20
34
|
private hadAffect;
|
|
21
35
|
private isWorked;
|
|
22
36
|
private isFinished;
|
|
23
37
|
constructor(async: IAsync, options?: {
|
|
38
|
+
/** Visit only nodes with this `nodeType` (e.g. `Node.ELEMENT_NODE`) */
|
|
24
39
|
readonly whatToShow?: number;
|
|
40
|
+
/** Walk the tree from the last node to the first */
|
|
25
41
|
readonly reverse?: boolean;
|
|
42
|
+
/** How many nodes are processed per one chunk. Default: 50 */
|
|
26
43
|
readonly timeoutChunkSize?: number;
|
|
44
|
+
/** Delay between chunks in ms */
|
|
27
45
|
readonly timeout?: number;
|
|
28
46
|
});
|
|
29
|
-
private idleId;
|
|
30
47
|
private __schedulerController;
|
|
31
48
|
private _requestStarting;
|
|
32
49
|
break(reason?: string): void;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
export * from "./move-node-inside-start";
|
|
7
7
|
export * from "./move-the-node-along-the-edge-outward";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Despite the name, returns `true` when the cursor is NOT at the checked edge
|
|
10
|
+
* of the text node: there is significant (non invisible-space) text between
|
|
11
|
+
* the offset and the start (`start = true`) or the end (`end = true`) of the string.
|
|
10
12
|
* @private
|
|
11
13
|
*/
|
|
12
14
|
export declare function cursorInTheEdgeOfString(container: Node, offset: number, start: boolean, end: boolean): boolean;
|
|
@@ -90,6 +90,11 @@ export declare class Selection implements ISelect {
|
|
|
90
90
|
* Restores user selections using marker invisible elements in the DOM.
|
|
91
91
|
*/
|
|
92
92
|
restore(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Inserts invisible fake nodes on the boundaries of the current selection
|
|
95
|
+
* and returns them. Unlike [[Select.save]] the selection stays valid while
|
|
96
|
+
* the DOM around it is being modified. Restore it later with [[Select.restoreFakes]].
|
|
97
|
+
*/
|
|
93
98
|
fakes(): [
|
|
94
99
|
] | [
|
|
95
100
|
Node
|
|
@@ -97,6 +102,10 @@ export declare class Selection implements ISelect {
|
|
|
97
102
|
Node,
|
|
98
103
|
Node
|
|
99
104
|
];
|
|
105
|
+
/**
|
|
106
|
+
* Restores the selection previously saved with [[Select.fakes]]
|
|
107
|
+
* and removes the fake nodes (disconnected fakes are ignored).
|
|
108
|
+
*/
|
|
100
109
|
restoreFakes(fakes: [
|
|
101
110
|
] | [
|
|
102
111
|
Node
|
|
@@ -244,5 +253,10 @@ export declare class Selection implements ISelect {
|
|
|
244
253
|
* Split selection on two parts: left and right
|
|
245
254
|
*/
|
|
246
255
|
splitSelection(currentBox: HTMLElement, edge?: Node): Nullable<Element>;
|
|
256
|
+
/**
|
|
257
|
+
* Expands the non-collapsed selection outward: boundaries positioned on the
|
|
258
|
+
* edge of their parents are moved out of them (e.g. `<p><b>|test|</b></p>`
|
|
259
|
+
* becomes `<p>|<b>test</b>|</p>`)
|
|
260
|
+
*/
|
|
247
261
|
expandSelection(): this;
|
|
248
262
|
}
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { IDictionary } from "../../../../types/index";
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Checks that every attribute from `attrs` is present on the element with
|
|
9
|
+
* the same value (one-directional match: extra own attributes of the element
|
|
10
|
+
* are ignored, empty `attrs` matches any element)
|
|
9
11
|
* @private
|
|
10
12
|
*/
|
|
11
|
-
export declare function isSameAttributes(elm: HTMLElement, attrs?: IDictionary):
|
|
13
|
+
export declare function isSameAttributes(elm: HTMLElement, attrs?: IDictionary): boolean;
|
|
12
14
|
export declare function elementsEqualAttributes(elm1: HTMLElement, elm2: HTMLElement): boolean;
|
|
@@ -12,7 +12,8 @@ import type { ICommitStyle, Nullable } from "../../../../types/index";
|
|
|
12
12
|
* @param commitStyle - style commit
|
|
13
13
|
* @param elm - checked item
|
|
14
14
|
* @param strict - strict mode - false - the default tag is suitable for us if it is also in the commit
|
|
15
|
-
* @param strictStyle - strict style mode - true - the element
|
|
15
|
+
* @param strictStyle - strict style mode - true - the element must have the same style keys AND values
|
|
16
|
+
* as in the commit, false - matching style keys are enough
|
|
16
17
|
* @private
|
|
17
18
|
*/
|
|
18
19
|
export declare function isSuitElement(commitStyle: ICommitStyle, elm: Nullable<Node>, strict: boolean, strictStyle?: boolean): elm is HTMLElement;
|