jodit-pro-react 5.5.36 → 5.5.37

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-JEVJ5NDX.mjs";
3
+ } from "./chunk-BUSY7HMW.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.17";
196
+ APP_VERSION = "4.12.18";
197
197
  ES = "es2020";
198
198
  IS_ES_MODERN = true;
199
199
  IS_ES_NEXT = true;
@@ -3868,6 +3868,9 @@ var init_extend = __esm({
3868
3868
  });
3869
3869
 
3870
3870
  // node_modules/jodit/esm/core/helpers/utils/config-proto.js
3871
+ function isUnsafeProtoKey(key3) {
3872
+ return UNSAFE_PROTO_KEYS.indexOf(key3) !== -1;
3873
+ }
3871
3874
  function ConfigProto(options2, proto, deep = 0) {
3872
3875
  if (Object.getPrototypeOf(options2) !== Object.prototype) {
3873
3876
  return options2;
@@ -3886,6 +3889,9 @@ function ConfigProto(options2, proto, deep = 0) {
3886
3889
  }
3887
3890
  const newOpt = {};
3888
3891
  Object.keys(options2).forEach((key3) => {
3892
+ if (isUnsafeProtoKey(key3)) {
3893
+ return;
3894
+ }
3889
3895
  const opt = options2[key3], protoKey = proto ? proto[key3] : null;
3890
3896
  if (isPlainObject(opt) && isPlainObject(protoKey) && !isAtom(opt)) {
3891
3897
  newOpt[key3] = ConfigProto(opt, protoKey, deep + 1);
@@ -3908,6 +3914,9 @@ function ConfigFlatten(obj) {
3908
3914
  }
3909
3915
  function ConfigMerge(target, source2) {
3910
3916
  Object.keys(source2).forEach((key3) => {
3917
+ if (isUnsafeProtoKey(key3)) {
3918
+ return;
3919
+ }
3911
3920
  const srcVal = source2[key3];
3912
3921
  const tgtVal = target[key3];
3913
3922
  if (isPlainObject(srcVal) && isPlainObject(tgtVal) && !isAtom(srcVal)) {
@@ -3923,6 +3932,7 @@ function ConfigDeepFlatten(obj) {
3923
3932
  return app;
3924
3933
  }, {});
3925
3934
  }
3935
+ var UNSAFE_PROTO_KEYS;
3926
3936
  var init_config_proto = __esm({
3927
3937
  "node_modules/jodit/esm/core/helpers/utils/config-proto.js"() {
3928
3938
  "use strict";
@@ -3933,6 +3943,7 @@ var init_config_proto = __esm({
3933
3943
  init_config();
3934
3944
  init_extend();
3935
3945
  init_utils();
3946
+ UNSAFE_PROTO_KEYS = ["__proto__", "constructor", "prototype"];
3936
3947
  }
3937
3948
  });
3938
3949
 
@@ -20259,7 +20270,8 @@ function isRemovableNode(jodit, node, current, allow, deny) {
20259
20270
  if (!jodit.o.cleanHTML.removeEmptyElements) {
20260
20271
  return false;
20261
20272
  }
20262
- return Dom.isElement(node) && node.nodeName.match(IS_INLINE) != null && !Dom.isTemporary(node) && trimInv(node.innerHTML).length === 0 && (current == null || !Dom.isOrContains(node, current));
20273
+ const liveCaret = jodit.s.isCollapsed() ? jodit.s.range.startContainer : null;
20274
+ 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));
20263
20275
  }
20264
20276
 
20265
20277
  // node_modules/jodit/esm/plugins/clean-html/helpers/visitor/visit-node-walker.js
@@ -21342,11 +21354,32 @@ var dragAndDropElement = class _dragAndDropElement extends Plugin {
21342
21354
  /** @override */
21343
21355
  afterInit() {
21344
21356
  this.dragList = this.j.o.draggableTags ? splitArray(this.j.o.draggableTags).filter(Boolean).map((item) => item.toLowerCase()) : [];
21357
+ this.j.e.on("startDragElement", this.onStartDragElement);
21345
21358
  if (!this.dragList.length) {
21346
21359
  return;
21347
21360
  }
21348
21361
  this.j.e.on("mousedown dragstart", this.onDragStart);
21349
21362
  }
21363
+ /**
21364
+ * Start dragging a specific element programmatically.
21365
+ *
21366
+ * Allows a separate UI element (for example a drag handle/anchor shown next
21367
+ * to a block) to initiate the drag without the user pressing directly on the
21368
+ * draggable element itself.
21369
+ *
21370
+ * @example
21371
+ * ```js
21372
+ * handle.addEventListener('mousedown', e => {
21373
+ * editor.e.fire('startDragElement', preBlock, e);
21374
+ * });
21375
+ * ```
21376
+ */
21377
+ onStartDragElement(element, event) {
21378
+ if (this.isInDestruct || this.state > DragState.IDLE || !element) {
21379
+ return;
21380
+ }
21381
+ this.startDragging(element, event);
21382
+ }
21350
21383
  /**
21351
21384
  * Drag start handler
21352
21385
  */
@@ -21369,11 +21402,19 @@ var dragAndDropElement = class _dragAndDropElement extends Plugin {
21369
21402
  if (Dom.isTag(lastTarget.parentElement, "a") && lastTarget.parentElement.firstChild === lastTarget && lastTarget.parentElement.lastChild === lastTarget) {
21370
21403
  lastTarget = lastTarget.parentElement;
21371
21404
  }
21405
+ this.startDragging(lastTarget, event);
21406
+ }
21407
+ /**
21408
+ * Prepare the ghost element and switch to the waiting state.
21409
+ * Shared by the native mousedown handler and the programmatic
21410
+ * `startDragElement` event handler.
21411
+ */
21412
+ startDragging(target, event) {
21372
21413
  this.startX = event.clientX;
21373
21414
  this.startY = event.clientY;
21374
21415
  this.isCopyMode = ctrlKey(event);
21375
- this.draggable = lastTarget.cloneNode(true);
21376
- dataBind(this.draggable, "target", lastTarget);
21416
+ this.draggable = target.cloneNode(true);
21417
+ dataBind(this.draggable, "target", target);
21377
21418
  this.state = DragState.WAIT_DRAGGING;
21378
21419
  this.addDragListeners();
21379
21420
  }
@@ -21446,6 +21487,11 @@ var dragAndDropElement = class _dragAndDropElement extends Plugin {
21446
21487
  }
21447
21488
  const { parentElement } = fragment;
21448
21489
  this.j.s.insertNode(fragment, true, false);
21490
+ [fragment.previousSibling, fragment.nextSibling].forEach((node) => {
21491
+ if (Dom.isEmptyTextNode(node)) {
21492
+ Dom.safeRemove(node);
21493
+ }
21494
+ });
21449
21495
  if (parentElement && Dom.isEmpty(parentElement) && !Dom.isCell(parentElement)) {
21450
21496
  Dom.safeRemove(parentElement);
21451
21497
  }
@@ -21469,10 +21515,13 @@ var dragAndDropElement = class _dragAndDropElement extends Plugin {
21469
21515
  /** @override */
21470
21516
  beforeDestruct() {
21471
21517
  this.onDragEnd();
21472
- this.j.e.off("mousedown dragstart", this.onDragStart);
21518
+ this.j.e.off("mousedown dragstart", this.onDragStart).off("startDragElement", this.onStartDragElement);
21473
21519
  this.removeDragListeners();
21474
21520
  }
21475
21521
  };
21522
+ __decorate41([
21523
+ autobind
21524
+ ], dragAndDropElement.prototype, "onStartDragElement", null);
21476
21525
  __decorate41([
21477
21526
  autobind
21478
21527
  ], dragAndDropElement.prototype, "onDragStart", null);
@@ -21710,12 +21759,14 @@ var enter = class extends Plugin {
21710
21759
  if (beforeEnter !== void 0) {
21711
21760
  return beforeEnter;
21712
21761
  }
21713
- if (!editor.s.isCollapsed()) {
21714
- editor.execCommand("Delete");
21715
- }
21716
- editor.s.focus();
21717
- this.onEnter(event);
21718
- editor.e.fire("afterEnter", event);
21762
+ editor.history.snapshot.transaction(() => {
21763
+ if (!editor.s.isCollapsed()) {
21764
+ editor.execCommand("Delete");
21765
+ }
21766
+ editor.s.focus();
21767
+ this.onEnter(event);
21768
+ editor.e.fire("afterEnter", event);
21769
+ });
21719
21770
  editor.synchronizeValues();
21720
21771
  return false;
21721
21772
  }
@@ -28299,6 +28350,7 @@ __decorate61([
28299
28350
  pluginSystem.add("search", search);
28300
28351
 
28301
28352
  // node_modules/jodit/esm/plugins/select/select.js
28353
+ init_constants();
28302
28354
  init_decorators();
28303
28355
  init_dom();
28304
28356
  init_global2();
@@ -28407,6 +28459,34 @@ var select = class extends Plugin {
28407
28459
  s48.setCursorAfter(text);
28408
28460
  }
28409
28461
  }
28462
+ /**
28463
+ * Keep pending inline formatting after a click. Toggling Bold/Italic/etc. on
28464
+ * a collapsed cursor leaves empty marker elements with the caret inside; a
28465
+ * click puts the caret right before them (outside), so they get cleaned up
28466
+ * and the formatting is lost. Move the caret back into the innermost marker
28467
+ * so the next typed character keeps every pending format (#1291).
28468
+ */
28469
+ onClickKeepPendingFormat() {
28470
+ var _a2, _b;
28471
+ const { s: s48 } = this.j;
28472
+ const range = s48.range;
28473
+ if (!range.collapsed || !Dom.isText(range.startContainer)) {
28474
+ return;
28475
+ }
28476
+ const text = range.startContainer;
28477
+ if (range.startOffset !== ((_b = (_a2 = text.nodeValue) === null || _a2 === void 0 ? void 0 : _a2.length) !== null && _b !== void 0 ? _b : 0)) {
28478
+ return;
28479
+ }
28480
+ const marker = text.nextSibling;
28481
+ if (!Dom.isElement(marker) || !marker.nodeName.match(IS_INLINE) || !Dom.isEmpty(marker)) {
28482
+ return;
28483
+ }
28484
+ let inner = marker;
28485
+ while (Dom.isElement(inner.firstElementChild) && inner.firstElementChild.nodeName.match(IS_INLINE)) {
28486
+ inner = inner.firstElementChild;
28487
+ }
28488
+ s48.setCursorIn(inner);
28489
+ }
28410
28490
  /**
28411
28491
  * Normalize selection after triple click
28412
28492
  */
@@ -28446,6 +28526,9 @@ __decorate62([
28446
28526
  __decorate62([
28447
28527
  watch([":click"])
28448
28528
  ], select.prototype, "onClickRightOfNestedListItem", null);
28529
+ __decorate62([
28530
+ watch([":click"])
28531
+ ], select.prototype, "onClickKeepPendingFormat", null);
28449
28532
  __decorate62([
28450
28533
  watch([":click"])
28451
28534
  ], select.prototype, "onTripleClickNormalizeSelection", null);
@@ -2,7 +2,7 @@ import {
2
2
  Config,
3
3
  JoditEditor_default,
4
4
  n
5
- } from "./chunk-JEVJ5NDX.mjs";
5
+ } from "./chunk-BUSY7HMW.mjs";
6
6
 
7
7
  // src/index.ts
8
8
  var index_default = JoditEditor_default;