jodit-pro-react 5.5.50 → 5.5.51

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JoditEditor_default
3
- } from "./chunk-L46Q42Q5.mjs";
3
+ } from "./chunk-JS4ICKC5.mjs";
4
4
  export {
5
5
  JoditEditor_default as default
6
6
  };
@@ -193,7 +193,7 @@ var APP_VERSION, ES, IS_ES_MODERN, IS_ES_NEXT, IS_PROD, IS_TEST, FAT_MODE, HOMEP
193
193
  var init_constants = __esm({
194
194
  "node_modules/jodit/esm/core/constants.js"() {
195
195
  "use strict";
196
- APP_VERSION = "4.12.35";
196
+ APP_VERSION = "4.12.37";
197
197
  ES = "es2020";
198
198
  IS_ES_MODERN = true;
199
199
  IS_ES_NEXT = true;
@@ -1585,7 +1585,7 @@ var init_utils = __esm({
1585
1585
  });
1586
1586
 
1587
1587
  // node_modules/jodit/esm/core/dom/dom.js
1588
- var Dom;
1588
+ var TEMP_ELEMENT_REG_EXP, Dom;
1589
1589
  var init_dom = __esm({
1590
1590
  "node_modules/jodit/esm/core/dom/dom.js"() {
1591
1591
  "use strict";
@@ -1605,6 +1605,7 @@ var init_dom = __esm({
1605
1605
  init_data_bind();
1606
1606
  init_error2();
1607
1607
  init_utils();
1608
+ TEMP_ELEMENT_REG_EXP = new RegExp(`<([a-z]+)[^>]+${TEMP_ATTR}[^>]*>(.+?)</\\1>`, "gi");
1608
1609
  Dom = class _Dom {
1609
1610
  constructor() {
1610
1611
  throw new Error("Dom is static module");
@@ -1711,7 +1712,11 @@ var init_dom = __esm({
1711
1712
  }
1712
1713
  }
1713
1714
  /**
1714
- * Call functions for all nodes between `start` and `end`
1715
+ * Call callback for all nodes between `start` and `end` in document order
1716
+ * (`start` and `end` are not included). Iteration stops when the callback returns `true`.
1717
+ *
1718
+ * `end` must be positioned after `start` in the document (e.g. selection markers),
1719
+ * otherwise iteration will stop only at the end of the tree.
1715
1720
  */
1716
1721
  static between(start, end, callback) {
1717
1722
  let next = start;
@@ -1723,6 +1728,9 @@ var init_dom = __esm({
1723
1728
  if (!step2) {
1724
1729
  while (next && !next.nextSibling) {
1725
1730
  next = next.parentNode;
1731
+ if (next === end) {
1732
+ return;
1733
+ }
1726
1734
  }
1727
1735
  step2 = next === null || next === void 0 ? void 0 : next.nextSibling;
1728
1736
  }
@@ -1807,7 +1815,7 @@ var init_dom = __esm({
1807
1815
  return _Dom.isNode(elm) && (elm.nodeName === "TD" || elm.nodeName === "TH");
1808
1816
  }
1809
1817
  /**
1810
- * Check if element is a list element UL or OL
1818
+ * Check if element is a list element UL or OL
1811
1819
  */
1812
1820
  static isList(elm) {
1813
1821
  return _Dom.isTag(elm, LIST_TAGS);
@@ -1856,12 +1864,10 @@ var init_dom = __esm({
1856
1864
  * Check if element is document fragment
1857
1865
  */
1858
1866
  static isFragment(node) {
1859
- var _a2;
1860
1867
  if (!_Dom.isNode(node)) {
1861
1868
  return false;
1862
1869
  }
1863
- const win = (_a2 = node.ownerDocument) === null || _a2 === void 0 ? void 0 : _a2.defaultView;
1864
- return Boolean(win && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE);
1870
+ return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
1865
1871
  }
1866
1872
  /**
1867
1873
  * Check if element is HTMLElement node
@@ -1973,7 +1979,9 @@ var init_dom = __esm({
1973
1979
  return null;
1974
1980
  }
1975
1981
  /**
1976
- * Find next/prev node what `condition(next) === true`
1982
+ * Lazily iterate over all nodes what follow after `start` (in document order
1983
+ * for `leftToRight = true`, in reverse order otherwise) inside `root`.
1984
+ * Ancestors of `start` are not yielded.
1977
1985
  */
1978
1986
  static *nextGen(start, root, leftToRight = true, withChild = true) {
1979
1987
  const stack = [];
@@ -1981,9 +1989,10 @@ var init_dom = __esm({
1981
1989
  do {
1982
1990
  let next = leftToRight ? currentNode.nextSibling : currentNode.previousSibling;
1983
1991
  while (next) {
1984
- stack.unshift(next);
1992
+ stack.push(next);
1985
1993
  next = leftToRight ? next.nextSibling : next.previousSibling;
1986
1994
  }
1995
+ stack.reverse();
1987
1996
  yield* __yieldStar(this.runInStack(start, stack, leftToRight, withChild));
1988
1997
  currentNode = currentNode.parentNode;
1989
1998
  } while (currentNode && currentNode !== root);
@@ -1998,7 +2007,7 @@ var init_dom = __esm({
1998
2007
  * ```javascript
1999
2008
  * Jodit.modules.Dom.each(editor.s.current(), function (node) {
2000
2009
  * if (node.nodeType === Node.TEXT_NODE) {
2001
- * node.nodeValue = node.nodeValue.replace(Jodit.INVISIBLE_SPACE_REG_EX, '') // remove all of the text element codes invisible character
2010
+ * node.nodeValue = node.nodeValue.replace(Jodit.INVISIBLE_SPACE_REG_EXP(), '') // remove all of the text element codes invisible character
2002
2011
  * }
2003
2012
  * });
2004
2013
  * ```
@@ -2081,11 +2090,18 @@ var init_dom = __esm({
2081
2090
  static findNotEmptyNeighbor(node, left, root) {
2082
2091
  return call(left ? _Dom.prev : _Dom.next, node, (n55) => Boolean(n55 && (!(_Dom.isText(n55) || _Dom.isComment(n55)) || trim((n55 === null || n55 === void 0 ? void 0 : n55.nodeValue) || "").length)), root);
2083
2092
  }
2093
+ /**
2094
+ * Returns the previous (`left = true`) or next sibling of the node
2095
+ */
2084
2096
  static sibling(node, left) {
2085
2097
  return left ? node.previousSibling : node.nextSibling;
2086
2098
  }
2087
2099
  /**
2088
2100
  * It goes through all the elements in ascending order, and checks to see if they meet the predetermined condition
2101
+ *
2102
+ * The condition is checked for the `node` itself too. The `root` reached
2103
+ * while ascending is checked only when `checkRoot = true`
2104
+ * (but if `node === root` it is checked in any case).
2089
2105
  */
2090
2106
  static up(node, condition, root, checkRoot = false) {
2091
2107
  let start = node;
@@ -2219,6 +2235,12 @@ var init_dom = __esm({
2219
2235
  static safeRemove(...nodes) {
2220
2236
  nodes.forEach((node) => _Dom.isNode(node) && node.parentNode && node.parentNode.removeChild(node));
2221
2237
  }
2238
+ /**
2239
+ * Insert a node into the range and collapse the range to the start of
2240
+ * the inserted content. Unlike the native `Range.insertNode` it does not
2241
+ * split inseparable elements (BR, HR, IMG etc.) and removes empty text
2242
+ * nodes produced by the split of a text container.
2243
+ */
2222
2244
  static safeInsertNode(range, node) {
2223
2245
  range.collapsed || range.deleteContents();
2224
2246
  const child = _Dom.isFragment(node) ? node.lastChild : node;
@@ -2254,22 +2276,17 @@ var init_dom = __esm({
2254
2276
  }
2255
2277
  }
2256
2278
  static isTag(node, tagNames) {
2279
+ if (Array.isArray(tagNames)) {
2280
+ throw new TypeError("Dom.isTag does not support array");
2281
+ }
2257
2282
  if (!this.isElement(node)) {
2258
2283
  return false;
2259
2284
  }
2260
2285
  const nameL = node.tagName.toLowerCase();
2261
- const nameU = node.tagName.toUpperCase();
2262
2286
  if (tagNames instanceof Set) {
2263
- return tagNames.has(nameL) || tagNames.has(nameU);
2264
- }
2265
- if (Array.isArray(tagNames)) {
2266
- throw new TypeError("Dom.isTag does not support array");
2267
- }
2268
- const tags = tagNames;
2269
- if (nameL === tags || nameU === tags) {
2270
- return true;
2287
+ return tagNames.has(nameL) || tagNames.has(node.tagName.toUpperCase());
2271
2288
  }
2272
- return false;
2289
+ return nameL === tagNames || node.tagName.toUpperCase() === tagNames;
2273
2290
  }
2274
2291
  /**
2275
2292
  * Marks an item as temporary
@@ -2295,10 +2312,10 @@ var init_dom = __esm({
2295
2312
  return _Dom.isNode(elm) && _Dom.isTag(elm, "span") && elm.hasAttribute("data-" + MARKER_CLASS);
2296
2313
  }
2297
2314
  /**
2298
- * Replace temporary elements from string
2315
+ * Unwrap temporary elements inside a HTML string (keeps their content)
2299
2316
  */
2300
2317
  static replaceTemporaryFromString(value) {
2301
- return value.replace(/<([a-z]+)[^>]+data-jodit-temp[^>]+>(.+?)<\/\1>/gi, "$2");
2318
+ return value.replace(TEMP_ELEMENT_REG_EXP, "$2");
2302
2319
  }
2303
2320
  /**
2304
2321
  * Get temporary list
@@ -2755,12 +2772,19 @@ var init_lazy_walker = __esm({
2755
2772
  return c70 > 3 && r62 && Object.defineProperty(target, key3, r62), r62;
2756
2773
  };
2757
2774
  LazyWalker = class extends Eventify {
2775
+ /**
2776
+ * Starts a new pass over the `root` tree.
2777
+ * If a previous pass is still running it will be stopped first.
2778
+ */
2758
2779
  setWork(root) {
2759
2780
  if (this.isWorked) {
2760
2781
  this.break();
2782
+ } else {
2783
+ this.stop();
2761
2784
  }
2762
2785
  this.workNodes = Dom.eachGen(root, !this.options.reverse);
2763
2786
  this.isFinished = false;
2787
+ this.hadAffect = false;
2764
2788
  this._requestStarting();
2765
2789
  return this;
2766
2790
  }
@@ -2772,7 +2796,6 @@ var init_lazy_walker = __esm({
2772
2796
  this.hadAffect = false;
2773
2797
  this.isWorked = false;
2774
2798
  this.isFinished = false;
2775
- this.idleId = 0;
2776
2799
  this.__schedulerController = null;
2777
2800
  }
2778
2801
  _requestStarting() {
@@ -2796,10 +2819,12 @@ var init_lazy_walker = __esm({
2796
2819
  }
2797
2820
  }
2798
2821
  stop() {
2822
+ var _a2;
2799
2823
  this.isWorked = false;
2800
2824
  this.isFinished = true;
2801
2825
  this.workNodes = null;
2802
- this.async.cancelIdleCallback(this.idleId);
2826
+ (_a2 = this.__schedulerController) === null || _a2 === void 0 ? void 0 : _a2.abort();
2827
+ this.__schedulerController = null;
2803
2828
  }
2804
2829
  destruct() {
2805
2830
  super.destruct();
@@ -2811,7 +2836,7 @@ var init_lazy_walker = __esm({
2811
2836
  this.isWorked = true;
2812
2837
  let count = 0;
2813
2838
  const chunkSize = (_a2 = this.options.timeoutChunkSize) !== null && _a2 !== void 0 ? _a2 : 50;
2814
- while (!this.isFinished && count <= chunkSize) {
2839
+ while (!this.isFinished && count < chunkSize) {
2815
2840
  const item = this.workNodes.next();
2816
2841
  count += 1;
2817
2842
  if (this.visitNode(item.value)) {
@@ -17261,9 +17286,6 @@ init_object_size();
17261
17286
  init_utils3();
17262
17287
  init_assert();
17263
17288
  function isSameAttributes(elm, attrs) {
17264
- if (!elm.attributes.length && !size(attrs)) {
17265
- return true;
17266
- }
17267
17289
  if (!size(attrs)) {
17268
17290
  return true;
17269
17291
  }
@@ -17372,7 +17394,7 @@ function toggleClass(jodit, value, elm, mode, dry) {
17372
17394
  function toggleAttribute(jodit, value, elm, key3, dry, mode) {
17373
17395
  assert(isString(value) || isNumber(value) || isBoolean(value) || value == null, "Attribute value must be a string or number or boolean or null");
17374
17396
  const hook2 = jodit.e.fire.bind(jodit.e, `${_PREFIX}AfterToggleAttribute`);
17375
- if (attr(elm, key3) === value) {
17397
+ if (attr(elm, key3) === (value == null ? value : String(value))) {
17376
17398
  !dry && attr(elm, key3, null);
17377
17399
  mode = UNSET;
17378
17400
  !dry && hook2(mode, elm, key3, value);
@@ -17491,6 +17513,9 @@ function unwrapList(mode, list, li, jodit, cs) {
17491
17513
  extractSelectedPart(list, li, jodit);
17492
17514
  assert(Dom.isHTMLElement(li.parentElement), "Element should be inside the list");
17493
17515
  Dom.unwrap(li.parentElement);
17516
+ if (mode === REPLACE) {
17517
+ return li;
17518
+ }
17494
17519
  return Dom.replace(li, jodit.o.enter.toLowerCase() !== "br" ? jodit.o.enter : jodit.createInside.fragment(), jodit.createInside);
17495
17520
  }
17496
17521
 
@@ -17820,7 +17845,7 @@ var CommitStyle = class {
17820
17845
  if (!data) {
17821
17846
  return false;
17822
17847
  }
17823
- return data[key3];
17848
+ return Boolean(data[key3]);
17824
17849
  }
17825
17850
  setApplied(elm, key3) {
17826
17851
  var _a2;
@@ -17835,7 +17860,7 @@ var CommitStyle = class {
17835
17860
  return this.options.element || this.defaultTag;
17836
17861
  }
17837
17862
  /**
17838
- * New element is blocked
17863
+ * New element is a block element
17839
17864
  */
17840
17865
  get elementIsBlock() {
17841
17866
  return Boolean(this.options.element && IS_BLOCK.test(this.options.element));
@@ -18105,7 +18130,7 @@ var Selection = class {
18105
18130
  * Remove all markers
18106
18131
  */
18107
18132
  removeMarkers() {
18108
- Dom.safeRemove.apply(null, this.markers);
18133
+ Dom.safeRemove(...this.markers);
18109
18134
  }
18110
18135
  /**
18111
18136
  * Create marker element
@@ -18161,6 +18186,11 @@ var Selection = class {
18161
18186
  this.selectRange(range);
18162
18187
  }
18163
18188
  }
18189
+ /**
18190
+ * Inserts invisible fake nodes on the boundaries of the current selection
18191
+ * and returns them. Unlike [[Select.save]] the selection stays valid while
18192
+ * the DOM around it is being modified. Restore it later with [[Select.restoreFakes]].
18193
+ */
18164
18194
  fakes() {
18165
18195
  const sel = this.sel;
18166
18196
  if (!sel || !sel.rangeCount) {
@@ -18185,6 +18215,10 @@ var Selection = class {
18185
18215
  this.selectRange(range);
18186
18216
  return result;
18187
18217
  }
18218
+ /**
18219
+ * Restores the selection previously saved with [[Select.fakes]]
18220
+ * and removes the fake nodes (disconnected fakes are ignored).
18221
+ */
18188
18222
  restoreFakes(fakes) {
18189
18223
  var _a2, _b, _c, _d;
18190
18224
  const nodes = fakes.filter((n55) => n55.isConnected);
@@ -18434,7 +18468,6 @@ var Selection = class {
18434
18468
  }
18435
18469
  const node = this.j.createInside.div();
18436
18470
  const fragment = this.j.createInside.fragment();
18437
- let lastChild;
18438
18471
  if (!this.isFocused() && this.j.isEditorMode()) {
18439
18472
  this.focus();
18440
18473
  this.restore();
@@ -18447,12 +18480,10 @@ var Selection = class {
18447
18480
  if (!this.j.isEditorMode() && this.j.e.fire("insertHTML", node.innerHTML) === false) {
18448
18481
  return;
18449
18482
  }
18450
- lastChild = node.lastChild;
18451
- if (!lastChild) {
18483
+ if (!node.lastChild) {
18452
18484
  return;
18453
18485
  }
18454
18486
  while (node.firstChild) {
18455
- lastChild = node.firstChild;
18456
18487
  fragment.appendChild(node.firstChild);
18457
18488
  }
18458
18489
  this.insertNode(fragment, insertCursorAfter, false);
@@ -18555,7 +18586,7 @@ var Selection = class {
18555
18586
  if (Dom.isEmptyTextNode(start)) {
18556
18587
  nodes.push(start);
18557
18588
  }
18558
- if (start.firstChild) {
18589
+ if (start === null || start === void 0 ? void 0 : start.firstChild) {
18559
18590
  nodes.push(start.firstChild);
18560
18591
  }
18561
18592
  }
@@ -18571,8 +18602,7 @@ var Selection = class {
18571
18602
  * @returns true - the cursor is at the end(start) block, null - cursor somewhere outside
18572
18603
  */
18573
18604
  cursorInTheEdge(start, parentBlock, fake = null) {
18574
- var _a2;
18575
- const end = !start, range = (_a2 = this.sel) === null || _a2 === void 0 ? void 0 : _a2.getRangeAt(0);
18605
+ const end = !start, sel = this.sel, range = (sel === null || sel === void 0 ? void 0 : sel.rangeCount) ? sel.getRangeAt(0) : null;
18576
18606
  fake !== null && fake !== void 0 ? fake : fake = this.current(false);
18577
18607
  if (!range || !fake || !Dom.isOrContains(parentBlock, fake, true)) {
18578
18608
  return null;
@@ -18921,6 +18951,11 @@ var Selection = class {
18921
18951
  }
18922
18952
  return currentBox.previousElementSibling;
18923
18953
  }
18954
+ /**
18955
+ * Expands the non-collapsed selection outward: boundaries positioned on the
18956
+ * edge of their parents are moved out of them (e.g. `<p><b>|test|</b></p>`
18957
+ * becomes `<p>|<b>test</b>|</p>`)
18958
+ */
18924
18959
  expandSelection() {
18925
18960
  if (this.isCollapsed()) {
18926
18961
  return this;
@@ -29574,6 +29609,7 @@ var AceEditor = class extends SourceEditor {
29574
29609
  this.instance.setOption("rtlText", true);
29575
29610
  this.instance.setOption("rtl", true);
29576
29611
  }
29612
+ this.instance.setOptions(editor.o.sourceEditorNativeOptions);
29577
29613
  this.instance.setTheme(editor.o.sourceEditorNativeOptions.theme);
29578
29614
  this.instance.renderer.setShowGutter(editor.o.sourceEditorNativeOptions.showGutter);
29579
29615
  this.instance.getSession().setMode(editor.o.sourceEditorNativeOptions.mode);
@@ -2,7 +2,7 @@ import {
2
2
  Config,
3
3
  JoditEditor_default,
4
4
  n
5
- } from "./chunk-L46Q42Q5.mjs";
5
+ } from "./chunk-JS4ICKC5.mjs";
6
6
 
7
7
  // src/index.ts
8
8
  var index_default = JoditEditor_default;