jodit 4.13.23 → 4.13.25
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 +12 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +51 -10
- 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 +51 -9
- 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 +51 -9
- 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 +53 -10
- 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/decorators/cache/cache.js +21 -3
- package/esm/core/selection/style/api/wrap.d.ts +2 -1
- package/esm/core/selection/style/api/wrap.js +12 -2
- package/esm/core/selection/style/transactions.js +18 -4
- package/package.json +1 -1
- package/types/core/selection/style/api/wrap.d.ts +2 -1
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.13.
|
|
6
|
+
export const APP_VERSION = "4.13.25";
|
|
7
7
|
// prettier-ignore
|
|
8
8
|
export const ES = "es2020";
|
|
9
9
|
export const IS_ES_MODERN = true;
|
|
@@ -133,21 +133,39 @@ export function cache(_, name, descriptor) {
|
|
|
133
133
|
return value;
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
+
function getOwnerDocument(component) {
|
|
137
|
+
const od = component.od;
|
|
138
|
+
return od !== null && od !== void 0 ? od : document;
|
|
139
|
+
}
|
|
136
140
|
export function cacheHTML(target, _, descriptor) {
|
|
137
141
|
const fn = descriptor.value;
|
|
138
142
|
if (!isFunction(fn)) {
|
|
139
143
|
throw error('Handler must be a Function');
|
|
140
144
|
}
|
|
141
145
|
let useCache = true;
|
|
146
|
+
/**
|
|
147
|
+
* The cache is keyed by the owner document first and only then by the
|
|
148
|
+
* component class. A page can create editors inside different documents
|
|
149
|
+
* (iframes) and destroy those documents later: a template cached from a
|
|
150
|
+
* dead document would otherwise be cloned for every subsequent editor,
|
|
151
|
+
* whose buttons then never react to clicks.
|
|
152
|
+
*/
|
|
142
153
|
const cached = new WeakMap();
|
|
143
154
|
descriptor.value = function (...attrs) {
|
|
144
155
|
var _a;
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
const doc = getOwnerDocument(this);
|
|
157
|
+
const docCache = cached.get(doc);
|
|
158
|
+
if (useCache && (docCache === null || docCache === void 0 ? void 0 : docCache.has(this.constructor))) {
|
|
159
|
+
return (_a = docCache.get(this.constructor)) === null || _a === void 0 ? void 0 : _a.cloneNode(true);
|
|
147
160
|
}
|
|
148
161
|
const value = fn.apply(this, attrs);
|
|
149
162
|
if (useCache && Dom.isElement(value)) {
|
|
150
|
-
|
|
163
|
+
if (docCache) {
|
|
164
|
+
docCache.set(this.constructor, value);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
cached.set(doc, new WeakMap([[this.constructor, value]]));
|
|
168
|
+
}
|
|
151
169
|
}
|
|
152
170
|
return useCache ? value.cloneNode(true) : value;
|
|
153
171
|
};
|
|
@@ -3,9 +3,10 @@
|
|
|
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 type { ICommitStyle, IJodit } from "../../../../types/index";
|
|
6
|
+
import type { HTMLTagNames, ICommitStyle, IJodit } from "../../../../types/index";
|
|
7
7
|
/**
|
|
8
8
|
* Replaces the parent tag with the applicable one, or wraps the text and also replaces the tag
|
|
9
9
|
* @private
|
|
10
10
|
*/
|
|
11
11
|
export declare function wrap(commitStyle: ICommitStyle, font: HTMLElement, jodit: IJodit): HTMLElement;
|
|
12
|
+
export declare const WRAP_NODES: Set<HTMLTagNames>;
|
|
@@ -32,7 +32,7 @@ export function wrap(commitStyle, font, jodit) {
|
|
|
32
32
|
}
|
|
33
33
|
return newWrapper;
|
|
34
34
|
}
|
|
35
|
-
const WRAP_NODES = new Set([
|
|
35
|
+
export const WRAP_NODES = new Set([
|
|
36
36
|
'td',
|
|
37
37
|
'th',
|
|
38
38
|
'tr',
|
|
@@ -48,7 +48,9 @@ const WRAP_NODES = new Set([
|
|
|
48
48
|
*/
|
|
49
49
|
function findOrCreateWrapper(commitStyle, font, jodit) {
|
|
50
50
|
if (commitStyle.elementIsBlock) {
|
|
51
|
-
const box = Dom.up(font, node => Dom.isBlock(node) &&
|
|
51
|
+
const box = Dom.up(font, node => Dom.isBlock(node) &&
|
|
52
|
+
!Dom.isTag(node, WRAP_NODES) &&
|
|
53
|
+
!hasBlockChildren(node), jodit.editor);
|
|
52
54
|
if (box) {
|
|
53
55
|
return box;
|
|
54
56
|
}
|
|
@@ -57,3 +59,11 @@ function findOrCreateWrapper(commitStyle, font, jodit) {
|
|
|
57
59
|
attr(font, 'size', null);
|
|
58
60
|
return font;
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* A block that itself contains block-level children is a layout container:
|
|
64
|
+
* replacing it wholesale would merge all its blocks into the new element,
|
|
65
|
+
* so the selection must be wrapped in a new block inside it instead.
|
|
66
|
+
*/
|
|
67
|
+
function hasBlockChildren(node) {
|
|
68
|
+
return Array.from(node.childNodes).some(child => Dom.isBlock(child));
|
|
69
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { LIST_TAGS } from "../../constants.js";
|
|
7
7
|
import { Dom } from "../../dom/dom.js";
|
|
8
8
|
import { assert } from "../../helpers/utils/assert.js";
|
|
9
|
-
import { extractSelectedPart, getSuitChild, getSuitParent, isInsideInvisibleElement, suitableClosest, toggleAttributes, toggleOrderedList, unwrapChildren, wrap } from "./api/index.js";
|
|
9
|
+
import { extractSelectedPart, getSuitChild, getSuitParent, isInsideInvisibleElement, suitableClosest, toggleAttributes, toggleOrderedList, unwrapChildren, wrap, WRAP_NODES } from "./api/index.js";
|
|
10
10
|
import { INITIAL, REPLACE, UNSET, UNWRAP, WRAP } from "./constants.js";
|
|
11
11
|
export const states = {
|
|
12
12
|
START: 'START',
|
|
@@ -162,11 +162,25 @@ export const transactions = {
|
|
|
162
162
|
},
|
|
163
163
|
[states.UNWRAP]: {
|
|
164
164
|
exec(value) {
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
const { element, style, jodit } = value;
|
|
166
|
+
if (element.attributes.length &&
|
|
167
|
+
Dom.isTag(element, style.element)) {
|
|
168
|
+
return { ...value, next: states.REPLACE_DEFAULT };
|
|
169
|
+
}
|
|
170
|
+
// Unwrapping a block inside a container (e.g. an h3 inside a div)
|
|
171
|
+
// leaves bare inline content there: the wrapNodes plugin restores
|
|
172
|
+
// paragraphs only at the editor root. Replace such a block with
|
|
173
|
+
// the default tag instead.
|
|
174
|
+
const parent = element.parentElement;
|
|
175
|
+
if (style.elementIsBlock &&
|
|
176
|
+
!style.elementIsDefault &&
|
|
177
|
+
parent &&
|
|
178
|
+
parent !== jodit.editor &&
|
|
179
|
+
Dom.isBlock(parent) &&
|
|
180
|
+
!Dom.isTag(parent, WRAP_NODES)) {
|
|
167
181
|
return { ...value, next: states.REPLACE_DEFAULT };
|
|
168
182
|
}
|
|
169
|
-
Dom.unwrap(
|
|
183
|
+
Dom.unwrap(element);
|
|
170
184
|
return { ...value, mode: UNWRAP, next: states.END };
|
|
171
185
|
}
|
|
172
186
|
},
|
package/package.json
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
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 type { ICommitStyle, IJodit } from "../../../../types/index";
|
|
6
|
+
import type { HTMLTagNames, ICommitStyle, IJodit } from "../../../../types/index";
|
|
7
7
|
/**
|
|
8
8
|
* Replaces the parent tag with the applicable one, or wraps the text and also replaces the tag
|
|
9
9
|
* @private
|
|
10
10
|
*/
|
|
11
11
|
export declare function wrap(commitStyle: ICommitStyle, font: HTMLElement, jodit: IJodit): HTMLElement;
|
|
12
|
+
export declare const WRAP_NODES: Set<HTMLTagNames>;
|