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
package/es2021/jodit.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
  */
@@ -1843,7 +1843,7 @@ __webpack_require__.r(__webpack_exports__);
1843
1843
  * ```
1844
1844
  * @packageDocumentation
1845
1845
  * @module constants
1846
- */ const APP_VERSION = "4.13.23";
1846
+ */ const APP_VERSION = "4.13.25";
1847
1847
  // prettier-ignore
1848
1848
  const ES = "es2021";
1849
1849
  const IS_ES_MODERN = true;
@@ -2441,20 +2441,41 @@ class Create {
2441
2441
  return value;
2442
2442
  };
2443
2443
  }
2444
+ function getOwnerDocument(component) {
2445
+ const od = component.od;
2446
+ return od ?? document;
2447
+ }
2444
2448
  function cacheHTML(target, _, descriptor) {
2445
2449
  const fn = descriptor.value;
2446
2450
  if (!(0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__.isFunction)(fn)) {
2447
2451
  throw (0,jodit_core_helpers_utils_error_error__WEBPACK_IMPORTED_MODULE_3__.error)('Handler must be a Function');
2448
2452
  }
2449
2453
  let useCache = true;
2450
- const cached = new WeakMap();
2454
+ /**
2455
+ * The cache is keyed by the owner document first and only then by the
2456
+ * component class. A page can create editors inside different documents
2457
+ * (iframes) and destroy those documents later: a template cached from a
2458
+ * dead document would otherwise be cloned for every subsequent editor,
2459
+ * whose buttons then never react to clicks.
2460
+ */ const cached = new WeakMap();
2451
2461
  descriptor.value = function(...attrs) {
2452
- if (useCache && cached.has(this.constructor)) {
2453
- return cached.get(this.constructor)?.cloneNode(true);
2462
+ const doc = getOwnerDocument(this);
2463
+ const docCache = cached.get(doc);
2464
+ if (useCache && docCache?.has(this.constructor)) {
2465
+ return docCache.get(this.constructor)?.cloneNode(true);
2454
2466
  }
2455
2467
  const value = fn.apply(this, attrs);
2456
2468
  if (useCache && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isElement(value)) {
2457
- cached.set(this.constructor, value);
2469
+ if (docCache) {
2470
+ docCache.set(this.constructor, value);
2471
+ } else {
2472
+ cached.set(doc, new WeakMap([
2473
+ [
2474
+ this.constructor,
2475
+ value
2476
+ ]
2477
+ ]));
2478
+ }
2458
2479
  }
2459
2480
  return useCache ? value.cloneNode(true) : value;
2460
2481
  };
@@ -11985,6 +12006,7 @@ if (jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.globalDocument) {
11985
12006
  "use strict";
11986
12007
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11987
12008
  /* harmony export */ FiniteStateMachine: function() { return /* reexport safe */ _finite_state_machine__WEBPACK_IMPORTED_MODULE_1__.FiniteStateMachine; },
12009
+ /* harmony export */ WRAP_NODES: function() { return /* reexport safe */ _wrap__WEBPACK_IMPORTED_MODULE_13__.WRAP_NODES; },
11988
12010
  /* harmony export */ extractSelectedPart: function() { return /* reexport safe */ _extract__WEBPACK_IMPORTED_MODULE_0__.extractSelectedPart; },
11989
12011
  /* harmony export */ getSuitChild: function() { return /* reexport safe */ _get_suit_child__WEBPACK_IMPORTED_MODULE_2__.getSuitChild; },
11990
12012
  /* harmony export */ getSuitParent: function() { return /* reexport safe */ _get_suit_parent__WEBPACK_IMPORTED_MODULE_3__.getSuitParent; },
@@ -12647,6 +12669,7 @@ function toggleAttribute(jodit, value, elm, key, dry, mode) {
12647
12669
 
12648
12670
  "use strict";
12649
12671
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12672
+ /* harmony export */ WRAP_NODES: function() { return /* binding */ WRAP_NODES; },
12650
12673
  /* harmony export */ wrap: function() { return /* binding */ wrap; }
12651
12674
  /* harmony export */ });
12652
12675
  /* harmony import */ var jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(27795);
@@ -12701,7 +12724,7 @@ const WRAP_NODES = new Set([
12701
12724
  * otherwise it wraps free text in an element.
12702
12725
  */ function findOrCreateWrapper(commitStyle, font, jodit) {
12703
12726
  if (commitStyle.elementIsBlock) {
12704
- const box = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.up(font, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isBlock(node) && !jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(node, WRAP_NODES), jodit.editor);
12727
+ const box = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.up(font, (node)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isBlock(node) && !jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(node, WRAP_NODES) && !hasBlockChildren(node), jodit.editor);
12705
12728
  if (box) {
12706
12729
  return box;
12707
12730
  }
@@ -12710,6 +12733,13 @@ const WRAP_NODES = new Set([
12710
12733
  (0,jodit_core_helpers_utils_attr__WEBPACK_IMPORTED_MODULE_1__.attr)(font, 'size', null);
12711
12734
  return font;
12712
12735
  }
12736
+ /**
12737
+ * A block that itself contains block-level children is a layout container:
12738
+ * replacing it wholesale would merge all its blocks into the new element,
12739
+ * so the selection must be wrapped in a new block inside it instead.
12740
+ */ function hasBlockChildren(node) {
12741
+ return Array.from(node.childNodes).some((child)=>jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isBlock(child));
12742
+ }
12713
12743
 
12714
12744
 
12715
12745
  /***/ }),
@@ -13096,13 +13126,25 @@ const transactions = {
13096
13126
  },
13097
13127
  [states.UNWRAP]: {
13098
13128
  exec (value) {
13099
- if (value.element.attributes.length && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isTag(value.element, value.style.element)) {
13129
+ const { element, style, jodit } = value;
13130
+ if (element.attributes.length && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isTag(element, style.element)) {
13131
+ return {
13132
+ ...value,
13133
+ next: states.REPLACE_DEFAULT
13134
+ };
13135
+ }
13136
+ // Unwrapping a block inside a container (e.g. an h3 inside a div)
13137
+ // leaves bare inline content there: the wrapNodes plugin restores
13138
+ // paragraphs only at the editor root. Replace such a block with
13139
+ // the default tag instead.
13140
+ const parent = element.parentElement;
13141
+ if (style.elementIsBlock && !style.elementIsDefault && parent && parent !== jodit.editor && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isBlock(parent) && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.isTag(parent, jodit_core_selection_style_api__WEBPACK_IMPORTED_MODULE_3__.WRAP_NODES)) {
13100
13142
  return {
13101
13143
  ...value,
13102
13144
  next: states.REPLACE_DEFAULT
13103
13145
  };
13104
13146
  }
13105
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.unwrap(value.element);
13147
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__.Dom.unwrap(element);
13106
13148
  return {
13107
13149
  ...value,
13108
13150
  mode: jodit_core_selection_style_constants__WEBPACK_IMPORTED_MODULE_4__.UNWRAP,