jodit 4.6.6 → 4.6.11
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 +41 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +161 -25
- 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.css +1 -1
- package/es2018/jodit.fat.min.js +2 -2
- package/es2018/jodit.js +161 -25
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/debug/debug.css +1 -1
- package/es2018/plugins/debug/debug.js +1 -1
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.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 +2 -2
- package/es2021/jodit.js +161 -25
- package/es2021/jodit.min.js +2 -2
- 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 +2 -2
- package/es2021.en/jodit.js +161 -25
- package/es2021.en/jodit.min.js +2 -2
- 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/415.fat.min.js +1 -1
- package/es5/415.min.js +1 -1
- package/es5/5.fat.min.js +1 -1
- package/es5/5.min.js +1 -1
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +161 -25
- 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/esm/core/constants.js +1 -1
- package/esm/core/helpers/array/index.d.ts +1 -0
- package/esm/core/helpers/array/index.js +1 -0
- package/esm/core/helpers/array/reconcile-arrays.d.ts +54 -0
- package/esm/core/helpers/array/reconcile-arrays.js +103 -0
- package/esm/core/ui/group/group.d.ts +4 -2
- package/esm/core/ui/group/group.js +31 -14
- package/esm/types/ui.d.ts +4 -1
- package/package.json +1 -1
- package/types/core/helpers/array/index.d.ts +1 -0
- package/types/core/helpers/array/reconcile-arrays.d.ts +54 -0
- package/types/core/ui/group/group.d.ts +4 -2
- package/types/types/ui.d.ts +4 -1
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-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
|
-
export const APP_VERSION = "4.6.
|
|
6
|
+
export const APP_VERSION = "4.6.11";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
|
@@ -0,0 +1,54 @@
|
|
|
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-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @module helpers/array
|
|
8
|
+
*/
|
|
9
|
+
export interface ReconcileResult<T> {
|
|
10
|
+
added: T[];
|
|
11
|
+
removed: T[];
|
|
12
|
+
kept: T[];
|
|
13
|
+
moved: Array<{
|
|
14
|
+
item: T;
|
|
15
|
+
from: number;
|
|
16
|
+
to: number;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reconciles two arrays and returns the differences
|
|
21
|
+
* @param oldArray - The original array
|
|
22
|
+
* @param newArray - The new array to compare against
|
|
23
|
+
* @param keyFn - Optional function to generate unique keys for items (for object comparison)
|
|
24
|
+
* @returns Object containing added, removed, kept and moved items
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const old = [1, 2, 3, 4];
|
|
29
|
+
* const new = [2, 4, 5, 1];
|
|
30
|
+
* const result = reconcileArrays(old, new);
|
|
31
|
+
* // result.added = [5]
|
|
32
|
+
* // result.removed = [3]
|
|
33
|
+
* // result.kept = [2, 4, 1]
|
|
34
|
+
* // result.moved = [{item: 1, from: 0, to: 3}]
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const old = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
|
|
40
|
+
* const new = [{id: 2, name: 'b'}, {id: 3, name: 'c'}];
|
|
41
|
+
* const result = reconcileArrays(old, new, item => item.id);
|
|
42
|
+
* // result.added = [{id: 3, name: 'c'}]
|
|
43
|
+
* // result.removed = [{id: 1, name: 'a'}]
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function reconcileArrays<T>(oldArray: T[], newArray: T[], keyFn?: (item: T) => string | number): ReconcileResult<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Applies reconciliation patches to transform one array into another
|
|
49
|
+
* @param oldArray - The original array to transform
|
|
50
|
+
* @param newArray - The target array structure
|
|
51
|
+
* @param keyFn - Optional function to generate unique keys for items
|
|
52
|
+
* @returns New array matching the structure of newArray
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyArrayReconciliation<T>(oldArray: T[], newArray: T[], keyFn?: (item: T) => string | number): T[];
|
|
@@ -0,0 +1,103 @@
|
|
|
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-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Reconciles two arrays and returns the differences
|
|
8
|
+
* @param oldArray - The original array
|
|
9
|
+
* @param newArray - The new array to compare against
|
|
10
|
+
* @param keyFn - Optional function to generate unique keys for items (for object comparison)
|
|
11
|
+
* @returns Object containing added, removed, kept and moved items
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const old = [1, 2, 3, 4];
|
|
16
|
+
* const new = [2, 4, 5, 1];
|
|
17
|
+
* const result = reconcileArrays(old, new);
|
|
18
|
+
* // result.added = [5]
|
|
19
|
+
* // result.removed = [3]
|
|
20
|
+
* // result.kept = [2, 4, 1]
|
|
21
|
+
* // result.moved = [{item: 1, from: 0, to: 3}]
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const old = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
|
|
27
|
+
* const new = [{id: 2, name: 'b'}, {id: 3, name: 'c'}];
|
|
28
|
+
* const result = reconcileArrays(old, new, item => item.id);
|
|
29
|
+
* // result.added = [{id: 3, name: 'c'}]
|
|
30
|
+
* // result.removed = [{id: 1, name: 'a'}]
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function reconcileArrays(oldArray, newArray, keyFn) {
|
|
34
|
+
const getKey = keyFn || ((item) => item);
|
|
35
|
+
const oldMap = new Map();
|
|
36
|
+
const newMap = new Map();
|
|
37
|
+
oldArray.forEach((item, index) => {
|
|
38
|
+
oldMap.set(getKey(item), { item, index });
|
|
39
|
+
});
|
|
40
|
+
newArray.forEach((item, index) => {
|
|
41
|
+
newMap.set(getKey(item), { item, index });
|
|
42
|
+
});
|
|
43
|
+
const added = [];
|
|
44
|
+
const removed = [];
|
|
45
|
+
const kept = [];
|
|
46
|
+
const moved = [];
|
|
47
|
+
// Find removed items
|
|
48
|
+
oldMap.forEach((value, key) => {
|
|
49
|
+
if (!newMap.has(key)) {
|
|
50
|
+
removed.push(value.item);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
// Find added items and track kept/moved items
|
|
54
|
+
newMap.forEach((value, key) => {
|
|
55
|
+
const oldItem = oldMap.get(key);
|
|
56
|
+
if (!oldItem) {
|
|
57
|
+
added.push(value.item);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
kept.push(value.item);
|
|
61
|
+
if (oldItem.index !== value.index) {
|
|
62
|
+
moved.push({
|
|
63
|
+
item: value.item,
|
|
64
|
+
from: oldItem.index,
|
|
65
|
+
to: value.index
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
added,
|
|
72
|
+
removed,
|
|
73
|
+
kept,
|
|
74
|
+
moved
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Applies reconciliation patches to transform one array into another
|
|
79
|
+
* @param oldArray - The original array to transform
|
|
80
|
+
* @param newArray - The target array structure
|
|
81
|
+
* @param keyFn - Optional function to generate unique keys for items
|
|
82
|
+
* @returns New array matching the structure of newArray
|
|
83
|
+
*/
|
|
84
|
+
export function applyArrayReconciliation(oldArray, newArray, keyFn) {
|
|
85
|
+
const result = reconcileArrays(oldArray, newArray, keyFn);
|
|
86
|
+
const output = [];
|
|
87
|
+
// Build the new array based on newArray order
|
|
88
|
+
newArray.forEach(item => {
|
|
89
|
+
const key = keyFn ? keyFn(item) : item;
|
|
90
|
+
const isNew = result.added.some(addedItem => (keyFn ? keyFn(addedItem) : addedItem) === key);
|
|
91
|
+
if (isNew) {
|
|
92
|
+
output.push(item);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Use the old item reference if it exists
|
|
96
|
+
const oldItem = oldArray.find(oldItem => (keyFn ? keyFn(oldItem) : oldItem) === key);
|
|
97
|
+
if (oldItem !== undefined) {
|
|
98
|
+
output.push(oldItem);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return output;
|
|
103
|
+
}
|
|
@@ -30,13 +30,15 @@ export declare class UIGroup<T extends IViewBased = IViewBased> extends UIElemen
|
|
|
30
30
|
/**
|
|
31
31
|
* Append new element into group
|
|
32
32
|
*/
|
|
33
|
-
append(elm: IUIElement
|
|
33
|
+
append(elm: IUIElement, index?: number): this;
|
|
34
|
+
append(elm: IUIElement, distElement?: string): this;
|
|
35
|
+
append(elm: IUIElement[], distElement?: string): this;
|
|
34
36
|
/** @override */
|
|
35
37
|
afterSetMod(name: string, value: ModType): void;
|
|
36
38
|
/**
|
|
37
39
|
* Allow set another container for the box of all children
|
|
38
40
|
*/
|
|
39
|
-
protected appendChildToContainer(childContainer: HTMLElement): void;
|
|
41
|
+
protected appendChildToContainer(childContainer: HTMLElement, index?: number): void;
|
|
40
42
|
/**
|
|
41
43
|
* Remove element from group
|
|
42
44
|
*/
|
|
@@ -18,7 +18,6 @@ import { Component } from "../../component/component.js";
|
|
|
18
18
|
import { component, watch } from "../../decorators/index.js";
|
|
19
19
|
import { Dom } from "../../dom/dom.js";
|
|
20
20
|
import { isArray } from "../../helpers/index.js";
|
|
21
|
-
import { assert } from "../../helpers/utils/assert.js";
|
|
22
21
|
import { UIElement } from "../element.js";
|
|
23
22
|
let UIGroup = UIGroup_1 = class UIGroup extends UIElement {
|
|
24
23
|
className() {
|
|
@@ -53,25 +52,35 @@ let UIGroup = UIGroup_1 = class UIGroup extends UIElement {
|
|
|
53
52
|
this.elements.forEach(elm => elm.update());
|
|
54
53
|
this.setMod('size', this.buttonSize);
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
append(elms, distElementOrIndex) {
|
|
56
|
+
if (isArray(elms)) {
|
|
57
|
+
if (typeof distElementOrIndex === 'number') {
|
|
58
|
+
throw new Error('You can not use index when append array of elements');
|
|
59
|
+
}
|
|
60
|
+
elms.forEach(item => this.append(item, distElementOrIndex));
|
|
62
61
|
return this;
|
|
63
62
|
}
|
|
64
|
-
|
|
63
|
+
const elm = elms;
|
|
64
|
+
let index = undefined;
|
|
65
|
+
if (typeof distElementOrIndex === 'number') {
|
|
66
|
+
index = Math.min(Math.max(0, distElementOrIndex), this.elements.length);
|
|
67
|
+
this.elements.splice(index, 0, elm);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this.elements.push(elm);
|
|
71
|
+
}
|
|
65
72
|
if (elm.name) {
|
|
66
73
|
elm.container.classList.add(this.getFullElName(elm.name));
|
|
67
74
|
}
|
|
68
|
-
if (
|
|
69
|
-
const distElm = this.getElm(
|
|
70
|
-
|
|
75
|
+
if (distElementOrIndex && typeof distElementOrIndex === 'string') {
|
|
76
|
+
const distElm = this.getElm(distElementOrIndex);
|
|
77
|
+
if (distElm == null) {
|
|
78
|
+
throw new Error('Element does not exist');
|
|
79
|
+
}
|
|
71
80
|
distElm.appendChild(elm.container);
|
|
72
81
|
}
|
|
73
82
|
else {
|
|
74
|
-
this.appendChildToContainer(elm.container);
|
|
83
|
+
this.appendChildToContainer(elm.container, index);
|
|
75
84
|
}
|
|
76
85
|
elm.parentElement = this;
|
|
77
86
|
return this;
|
|
@@ -85,8 +94,16 @@ let UIGroup = UIGroup_1 = class UIGroup extends UIElement {
|
|
|
85
94
|
/**
|
|
86
95
|
* Allow set another container for the box of all children
|
|
87
96
|
*/
|
|
88
|
-
appendChildToContainer(childContainer) {
|
|
89
|
-
|
|
97
|
+
appendChildToContainer(childContainer, index) {
|
|
98
|
+
if (index === undefined ||
|
|
99
|
+
index < 0 ||
|
|
100
|
+
index > this.elements.length - 1 ||
|
|
101
|
+
this.container.children[index] == null) {
|
|
102
|
+
this.container.appendChild(childContainer);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.container.insertBefore(childContainer, this.container.children[index]);
|
|
106
|
+
}
|
|
90
107
|
}
|
|
91
108
|
/**
|
|
92
109
|
* Remove element from group
|
package/esm/types/ui.d.ts
CHANGED
|
@@ -59,7 +59,10 @@ export interface IUIButton extends IViewComponent, IUIElement, IFocusable {
|
|
|
59
59
|
export interface IUIGroup extends IUIElement {
|
|
60
60
|
readonly elements: IUIElement[];
|
|
61
61
|
readonly allChildren: IUIElement[];
|
|
62
|
-
append(elm: IUIElement
|
|
62
|
+
append(elm: IUIElement, index?: number): this;
|
|
63
|
+
append(elm: IUIElement, distElement?: string): this;
|
|
64
|
+
append(elms: IUIElement[], distElement?: string): this;
|
|
65
|
+
append(elm: IUIElement | IUIElement[], distElementOrIndex?: string | number): this;
|
|
63
66
|
remove(elm: IUIElement): this;
|
|
64
67
|
clear(): this;
|
|
65
68
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
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-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* @module helpers/array
|
|
8
|
+
*/
|
|
9
|
+
export interface ReconcileResult<T> {
|
|
10
|
+
added: T[];
|
|
11
|
+
removed: T[];
|
|
12
|
+
kept: T[];
|
|
13
|
+
moved: Array<{
|
|
14
|
+
item: T;
|
|
15
|
+
from: number;
|
|
16
|
+
to: number;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reconciles two arrays and returns the differences
|
|
21
|
+
* @param oldArray - The original array
|
|
22
|
+
* @param newArray - The new array to compare against
|
|
23
|
+
* @param keyFn - Optional function to generate unique keys for items (for object comparison)
|
|
24
|
+
* @returns Object containing added, removed, kept and moved items
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const old = [1, 2, 3, 4];
|
|
29
|
+
* const new = [2, 4, 5, 1];
|
|
30
|
+
* const result = reconcileArrays(old, new);
|
|
31
|
+
* // result.added = [5]
|
|
32
|
+
* // result.removed = [3]
|
|
33
|
+
* // result.kept = [2, 4, 1]
|
|
34
|
+
* // result.moved = [{item: 1, from: 0, to: 3}]
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const old = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
|
|
40
|
+
* const new = [{id: 2, name: 'b'}, {id: 3, name: 'c'}];
|
|
41
|
+
* const result = reconcileArrays(old, new, item => item.id);
|
|
42
|
+
* // result.added = [{id: 3, name: 'c'}]
|
|
43
|
+
* // result.removed = [{id: 1, name: 'a'}]
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function reconcileArrays<T>(oldArray: T[], newArray: T[], keyFn?: (item: T) => string | number): ReconcileResult<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Applies reconciliation patches to transform one array into another
|
|
49
|
+
* @param oldArray - The original array to transform
|
|
50
|
+
* @param newArray - The target array structure
|
|
51
|
+
* @param keyFn - Optional function to generate unique keys for items
|
|
52
|
+
* @returns New array matching the structure of newArray
|
|
53
|
+
*/
|
|
54
|
+
export declare function applyArrayReconciliation<T>(oldArray: T[], newArray: T[], keyFn?: (item: T) => string | number): T[];
|
|
@@ -30,13 +30,15 @@ export declare class UIGroup<T extends IViewBased = IViewBased> extends UIElemen
|
|
|
30
30
|
/**
|
|
31
31
|
* Append new element into group
|
|
32
32
|
*/
|
|
33
|
-
append(elm: IUIElement
|
|
33
|
+
append(elm: IUIElement, index?: number): this;
|
|
34
|
+
append(elm: IUIElement, distElement?: string): this;
|
|
35
|
+
append(elm: IUIElement[], distElement?: string): this;
|
|
34
36
|
/** @override */
|
|
35
37
|
afterSetMod(name: string, value: ModType): void;
|
|
36
38
|
/**
|
|
37
39
|
* Allow set another container for the box of all children
|
|
38
40
|
*/
|
|
39
|
-
protected appendChildToContainer(childContainer: HTMLElement): void;
|
|
41
|
+
protected appendChildToContainer(childContainer: HTMLElement, index?: number): void;
|
|
40
42
|
/**
|
|
41
43
|
* Remove element from group
|
|
42
44
|
*/
|
package/types/types/ui.d.ts
CHANGED
|
@@ -59,7 +59,10 @@ export interface IUIButton extends IViewComponent, IUIElement, IFocusable {
|
|
|
59
59
|
export interface IUIGroup extends IUIElement {
|
|
60
60
|
readonly elements: IUIElement[];
|
|
61
61
|
readonly allChildren: IUIElement[];
|
|
62
|
-
append(elm: IUIElement
|
|
62
|
+
append(elm: IUIElement, index?: number): this;
|
|
63
|
+
append(elm: IUIElement, distElement?: string): this;
|
|
64
|
+
append(elms: IUIElement[], distElement?: string): this;
|
|
65
|
+
append(elm: IUIElement | IUIElement[], distElementOrIndex?: string | number): this;
|
|
63
66
|
remove(elm: IUIElement): this;
|
|
64
67
|
clear(): this;
|
|
65
68
|
}
|