jodit-pro-react 5.6.15 → 5.6.17

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-WUAETI7F.mjs";
3
+ } from "./chunk-FF2BFLM6.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.15.5";
196
+ APP_VERSION = "4.15.8";
197
197
  ES = "es2020";
198
198
  IS_ES_MODERN = true;
199
199
  IS_ES_NEXT = true;
@@ -21814,6 +21814,7 @@ Config.prototype.cleanHTML = {
21814
21814
  fillEmptyParagraph: true,
21815
21815
  collapseEmptyValueToEmptyString: false,
21816
21816
  singleQuotesInFontFamily: true,
21817
+ removeTrailingBr: false,
21817
21818
  replaceNBSP: true,
21818
21819
  replaceOldTags: {
21819
21820
  i: "em",
@@ -22267,7 +22268,10 @@ function isRemovableNode(jodit, node, current, allow, deny) {
22267
22268
  return false;
22268
22269
  }
22269
22270
  const liveCaret = jodit.s.isCollapsed() ? jodit.s.range.startContainer : null;
22270
- return Dom.isElement(node) && node.nodeName.match(IS_INLINE) != null && !Dom.isTemporary(node) && trimInv(node.innerHTML).length === 0 && (current == null || !Dom.isOrContains(node, current)) && (liveCaret == null || !Dom.isOrContains(node, liveCaret));
22271
+ return Dom.isElement(node) && node.nodeName.match(IS_INLINE) != null && !Dom.isTemporary(node) && !isFragmentTarget(node) && trimInv(node.innerHTML).length === 0 && (current == null || !Dom.isOrContains(node, current)) && (liveCaret == null || !Dom.isOrContains(node, liveCaret));
22272
+ }
22273
+ function isFragmentTarget(element) {
22274
+ return element.hasAttribute("id") || element.nodeName === "A" && element.hasAttribute("name");
22271
22275
  }
22272
22276
 
22273
22277
  // node_modules/jodit/esm/plugins/clean-html/helpers/visitor/visit-node-walker.js
@@ -22303,6 +22307,7 @@ var __decorate39 = function(decorators, target, key3, desc) {
22303
22307
  r71 = (c69 < 3 ? d55(r71) : c69 > 3 ? d55(target, key3, r71) : d55(target, key3)) || r71;
22304
22308
  return c69 > 3 && r71 && Object.defineProperty(target, key3, r71), r71;
22305
22309
  };
22310
+ var TRAILING_BR_BLOCKS = "p, div, li, td, th, h1, h2, h3, h4, h5, h6, blockquote";
22306
22311
  var cleanHtml = class extends Plugin {
22307
22312
  constructor() {
22308
22313
  super(...arguments);
@@ -22377,6 +22382,7 @@ var cleanHtml = class extends Plugin {
22377
22382
  */
22378
22383
  onAfterGetValueFromEditor(data) {
22379
22384
  this.__singleQuotesInFontFamily(data);
22385
+ this.__removeTrailingBr(data);
22380
22386
  if (!this.j.o.cleanHTML.collapseEmptyValueToEmptyString) {
22381
22387
  return;
22382
22388
  }
@@ -22392,6 +22398,39 @@ var cleanHtml = class extends Plugin {
22392
22398
  * survive that round trip. Names that already contain an apostrophe are
22393
22399
  * left alone.
22394
22400
  */
22401
+ /**
22402
+ * Drop a `<br>` that is the last node of a block (or of the value) and
22403
+ * follows other content — the caret placeholder browsers leave behind
22404
+ * after typing into an empty block. An empty block (`<p><br></p>`) and a
22405
+ * deliberate empty line (`text<br><br>`) are kept.
22406
+ */
22407
+ __removeTrailingBr(data) {
22408
+ if (!this.j.o.cleanHTML.removeTrailingBr || !/<br/i.test(data.value)) {
22409
+ return;
22410
+ }
22411
+ const box = this.j.c.div();
22412
+ box.innerHTML = data.value;
22413
+ const blocks = [
22414
+ box,
22415
+ ...box.querySelectorAll(TRAILING_BR_BLOCKS)
22416
+ ];
22417
+ blocks.forEach((block) => {
22418
+ var _a2;
22419
+ const last = block.lastChild;
22420
+ if (!Dom.isTag(last, "br")) {
22421
+ return;
22422
+ }
22423
+ const prev = last.previousSibling;
22424
+ if (!prev || Dom.isTag(prev, "br")) {
22425
+ return;
22426
+ }
22427
+ if (Dom.isText(prev) && !((_a2 = prev.nodeValue) === null || _a2 === void 0 ? void 0 : _a2.trim()) && !prev.previousSibling) {
22428
+ return;
22429
+ }
22430
+ Dom.safeRemove(last);
22431
+ });
22432
+ data.value = box.innerHTML;
22433
+ }
22395
22434
  __singleQuotesInFontFamily(data) {
22396
22435
  if (!this.j.o.cleanHTML.singleQuotesInFontFamily || !data.value.includes("&quot;")) {
22397
22436
  return;
@@ -23441,6 +23480,7 @@ var dragAndDropElement = class _dragAndDropElement extends Plugin {
23441
23480
  this.state = DragState.DRAGGING;
23442
23481
  }
23443
23482
  this.j.e.fire("hidePopup hideResizer");
23483
+ const offset2 = this.__ghostOffset();
23444
23484
  if (!this.draggable.parentNode) {
23445
23485
  const target = dataBind(this.draggable, "target");
23446
23486
  css(this.draggable, {
@@ -23450,19 +23490,27 @@ var dragAndDropElement = class _dragAndDropElement extends Plugin {
23450
23490
  position: "fixed",
23451
23491
  opacity: 0.7,
23452
23492
  display: "inline-block",
23453
- left: event.clientX,
23454
- top: event.clientY,
23493
+ left: event.clientX + offset2.left,
23494
+ top: event.clientY + offset2.top,
23455
23495
  width: (_a2 = target === null || target === void 0 ? void 0 : target.offsetWidth) !== null && _a2 !== void 0 ? _a2 : 100,
23456
23496
  height: (_b = target === null || target === void 0 ? void 0 : target.offsetHeight) !== null && _b !== void 0 ? _b : 100
23457
23497
  });
23458
23498
  Dom.append(getContainer(this.j, _dragAndDropElement), this.draggable);
23459
23499
  }
23460
23500
  css(this.draggable, {
23461
- left: event.clientX,
23462
- top: event.clientY
23501
+ left: event.clientX + offset2.left,
23502
+ top: event.clientY + offset2.top
23463
23503
  });
23464
23504
  this.j.s.insertCursorAtPoint(event.clientX, event.clientY);
23465
23505
  }
23506
+ __ghostOffset() {
23507
+ const iframe2 = this.j.iframe;
23508
+ if (!iframe2) {
23509
+ return { left: 0, top: 0 };
23510
+ }
23511
+ const rect = iframe2.getBoundingClientRect();
23512
+ return { left: rect.left, top: rect.top };
23513
+ }
23466
23514
  /**
23467
23515
  * Mouseup handler in any place
23468
23516
  */
@@ -27295,6 +27343,7 @@ var link = class extends Plugin {
27295
27343
  jodit.history.snapshot.restore(snapshot);
27296
27344
  const textWasChanged = getSelectionText() !== content_input.value.trim();
27297
27345
  const ci = jodit.createInside;
27346
+ let caretAfter = null;
27298
27347
  if (!link2 || !Dom.isOrContains(jodit.editor, link2)) {
27299
27348
  if (!jodit.s.isCollapsed()) {
27300
27349
  const node = jodit.s.current();
@@ -27307,6 +27356,7 @@ var link = class extends Plugin {
27307
27356
  const a76 = ci.element("a");
27308
27357
  jodit.s.insertNode(a76, false, false);
27309
27358
  links = [a76];
27359
+ caretAfter = a76;
27310
27360
  }
27311
27361
  links.forEach((link3) => jodit.s.select(link3));
27312
27362
  } else {
@@ -27337,6 +27387,9 @@ var link = class extends Plugin {
27337
27387
  }
27338
27388
  jodit.e.fire("applyLink", jodit, a76, form2);
27339
27389
  });
27390
+ if (caretAfter) {
27391
+ jodit.s.setCursorAfter(caretAfter);
27392
+ }
27340
27393
  jodit.synchronizeValues();
27341
27394
  close();
27342
27395
  return false;
@@ -27527,8 +27580,10 @@ function media(editor) {
27527
27580
  pluginSystem.add("media", media);
27528
27581
 
27529
27582
  // node_modules/jodit/esm/plugins/mobile/mobile.js
27583
+ init_dom();
27530
27584
  init_global2();
27531
27585
  init_helpers();
27586
+ init_is_string();
27532
27587
 
27533
27588
  // node_modules/jodit/esm/plugins/mobile/config.js
27534
27589
  init_constants();
@@ -27715,6 +27770,17 @@ function fitToButtons(list, editor) {
27715
27770
  }
27716
27771
  return cleaned;
27717
27772
  }
27773
+ function adaptiveWidth(editor) {
27774
+ var _a2;
27775
+ const { toolbar } = editor.o;
27776
+ if (isString(toolbar) || Dom.isHTMLElement(toolbar)) {
27777
+ const width = editor.toolbarContainer.offsetWidth;
27778
+ if (width) {
27779
+ return width;
27780
+ }
27781
+ }
27782
+ return ((_a2 = editor.container.parentElement) !== null && _a2 !== void 0 ? _a2 : editor.container).offsetWidth;
27783
+ }
27718
27784
  function mobile(editor) {
27719
27785
  let timeout = 0, store2 = splitArray(editor.o.buttons);
27720
27786
  if (editor.o.mobileTapTimeout) {
@@ -27743,13 +27809,16 @@ function mobile(editor) {
27743
27809
  });
27744
27810
  if (editor.o.toolbarAdaptive) {
27745
27811
  editor.e.on("resize afterInit recalcAdaptive changePlace afterAddPlace", () => {
27746
- var _a2, _b;
27812
+ var _a2;
27747
27813
  if (!editor.o.toolbar) {
27748
27814
  return;
27749
27815
  }
27750
- const width = ((_a2 = editor.container.parentElement) !== null && _a2 !== void 0 ? _a2 : editor.container).offsetWidth;
27751
27816
  const newStore = (() => {
27752
- if (editor.isFullSize || width >= editor.o.sizeLG) {
27817
+ if (editor.isFullSize) {
27818
+ return splitArray(editor.o.buttons);
27819
+ }
27820
+ const width = adaptiveWidth(editor);
27821
+ if (width >= editor.o.sizeLG) {
27753
27822
  return splitArray(editor.o.buttons);
27754
27823
  }
27755
27824
  if (width >= editor.o.sizeMD) {
@@ -27763,7 +27832,7 @@ function mobile(editor) {
27763
27832
  if (newStore.toString() !== store2.toString()) {
27764
27833
  store2 = newStore;
27765
27834
  editor.e.fire("closeAllPopups");
27766
- (_b = editor.toolbar) === null || _b === void 0 ? void 0 : _b.setRemoveButtons(editor.o.removeButtons).build(store2.concat(editor.o.extraButtons));
27835
+ (_a2 = editor.toolbar) === null || _a2 === void 0 ? void 0 : _a2.setRemoveButtons(editor.o.removeButtons).build(store2.concat(editor.o.extraButtons));
27767
27836
  }
27768
27837
  }).on(editor.ow, "load resize", () => editor.e.fire("recalcAdaptive"));
27769
27838
  }
@@ -2,7 +2,7 @@ import {
2
2
  Config,
3
3
  JoditEditor_default,
4
4
  n
5
- } from "./chunk-WUAETI7F.mjs";
5
+ } from "./chunk-FF2BFLM6.mjs";
6
6
 
7
7
  // src/index.ts
8
8
  var index_default = JoditEditor_default;