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.
Files changed (56) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +2 -2
  4. package/es2015/jodit.js +51 -10
  5. package/es2015/jodit.min.js +2 -2
  6. package/es2015/plugins/debug/debug.css +1 -1
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.fat.min.js +2 -2
  13. package/es2018/jodit.min.js +2 -2
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +3 -3
  18. package/es2021/jodit.js +51 -9
  19. package/es2021/jodit.min.js +3 -3
  20. package/es2021/plugins/debug/debug.css +1 -1
  21. package/es2021/plugins/debug/debug.js +1 -1
  22. package/es2021/plugins/debug/debug.min.js +1 -1
  23. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +3 -3
  28. package/es2021.en/jodit.js +51 -9
  29. package/es2021.en/jodit.min.js +3 -3
  30. package/es2021.en/plugins/debug/debug.css +1 -1
  31. package/es2021.en/plugins/debug/debug.js +1 -1
  32. package/es2021.en/plugins/debug/debug.min.js +1 -1
  33. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +53 -10
  39. package/es5/jodit.min.css +2 -2
  40. package/es5/jodit.min.js +2 -2
  41. package/es5/plugins/debug/debug.css +1 -1
  42. package/es5/plugins/debug/debug.js +1 -1
  43. package/es5/plugins/debug/debug.min.js +1 -1
  44. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  47. package/es5/polyfills.fat.min.js +1 -1
  48. package/es5/polyfills.js +1 -1
  49. package/es5/polyfills.min.js +1 -1
  50. package/esm/core/constants.js +1 -1
  51. package/esm/core/decorators/cache/cache.js +21 -3
  52. package/esm/core/selection/style/api/wrap.d.ts +2 -1
  53. package/esm/core/selection/style/api/wrap.js +12 -2
  54. package/esm/core/selection/style/transactions.js +18 -4
  55. package/package.json +1 -1
  56. package/types/core/selection/style/api/wrap.d.ts +2 -1
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
package/es5/polyfills.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.13.23
4
+ * Version: v4.13.25
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.23";
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
- if (useCache && cached.has(this.constructor)) {
146
- return (_a = cached.get(this.constructor)) === null || _a === void 0 ? void 0 : _a.cloneNode(true);
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
- cached.set(this.constructor, value);
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) && !Dom.isTag(node, WRAP_NODES), jodit.editor);
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
- if (value.element.attributes.length &&
166
- Dom.isTag(value.element, value.style.element)) {
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(value.element);
183
+ Dom.unwrap(element);
170
184
  return { ...value, mode: UNWRAP, next: states.END };
171
185
  }
172
186
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit",
3
- "version": "4.13.23",
3
+ "version": "4.13.25",
4
4
  "description": "Jodit is an awesome and useful wysiwyg editor with filebrowser",
5
5
  "main": "esm/index.js",
6
6
  "types": "types/index.d.ts",
@@ -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>;