jodit 4.15.5 → 4.15.7

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 (63) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +4 -4
  4. package/es2015/jodit.js +73 -8
  5. package/es2015/jodit.min.js +4 -4
  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 +4 -4
  13. package/es2018/jodit.min.js +4 -4
  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 +4 -4
  18. package/es2021/jodit.js +72 -8
  19. package/es2021/jodit.min.js +4 -4
  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 +4 -4
  28. package/es2021.en/jodit.js +72 -8
  29. package/es2021.en/jodit.min.js +4 -4
  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 +114 -42
  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/config.d.ts +10 -0
  51. package/esm/core/constants.js +1 -1
  52. package/esm/plugins/clean-html/clean-html.d.ts +7 -3
  53. package/esm/plugins/clean-html/clean-html.js +37 -0
  54. package/esm/plugins/clean-html/config.d.ts +10 -0
  55. package/esm/plugins/clean-html/config.js +1 -0
  56. package/esm/plugins/drag-and-drop-element/drag-and-drop-element.d.ts +1 -0
  57. package/esm/plugins/drag-and-drop-element/drag-and-drop-element.js +19 -4
  58. package/esm/plugins/link/link.js +9 -0
  59. package/package.json +1 -1
  60. package/types/config.d.ts +10 -0
  61. package/types/plugins/clean-html/clean-html.d.ts +7 -3
  62. package/types/plugins/clean-html/config.d.ts +10 -0
  63. package/types/plugins/drag-and-drop-element/drag-and-drop-element.d.ts +1 -0
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.15.5
4
+ * Version: v4.15.7
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1779,7 +1779,7 @@ __webpack_require__.r(__webpack_exports__);
1779
1779
  * ```
1780
1780
  * @packageDocumentation
1781
1781
  * @module constants
1782
- */ const APP_VERSION = "4.15.5";
1782
+ */ const APP_VERSION = "4.15.7";
1783
1783
  // prettier-ignore
1784
1784
  const ES = "es2021";
1785
1785
  const IS_ES_MODERN = true;
@@ -28329,7 +28329,8 @@ jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_5__.Icon.set('class-span', (_class_s
28329
28329
 
28330
28330
  /**
28331
28331
  * Clean HTML after removeFormat and insertHorizontalRule command
28332
- */ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin {
28332
+ */ const TRAILING_BR_BLOCKS = 'p, div, li, td, th, h1, h2, h3, h4, h5, h6, blockquote';
28333
+ class cleanHtml extends jodit_core_plugin_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin {
28333
28334
  /** @override */ afterInit(jodit) {}
28334
28335
  get isEditMode() {
28335
28336
  return !(this.j.isInDestruct || !this.j.isEditorMode() || this.j.getReadOnly());
@@ -28388,6 +28389,7 @@ jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_5__.Icon.set('class-span', (_class_s
28388
28389
  * opt-in via `cleanHTML.collapseEmptyValueToEmptyString`. See #1149
28389
28390
  */ onAfterGetValueFromEditor(data) {
28390
28391
  this.__singleQuotesInFontFamily(data);
28392
+ this.__removeTrailingBr(data);
28391
28393
  if (!this.j.o.cleanHTML.collapseEmptyValueToEmptyString) {
28392
28394
  return;
28393
28395
  }
@@ -28402,7 +28404,38 @@ jodit_core_ui_icon__WEBPACK_IMPORTED_MODULE_5__.Icon.set('class-span', (_class_s
28402
28404
  * `style="font-family: "Open Sans", …"` — broken markup. Single quotes
28403
28405
  * survive that round trip. Names that already contain an apostrophe are
28404
28406
  * left alone.
28405
- */ __singleQuotesInFontFamily(data) {
28407
+ */ /**
28408
+ * Drop a `<br>` that is the last node of a block (or of the value) and
28409
+ * follows other content — the caret placeholder browsers leave behind
28410
+ * after typing into an empty block. An empty block (`<p><br></p>`) and a
28411
+ * deliberate empty line (`text<br><br>`) are kept.
28412
+ */ __removeTrailingBr(data) {
28413
+ if (!this.j.o.cleanHTML.removeTrailingBr || !/<br/i.test(data.value)) {
28414
+ return;
28415
+ }
28416
+ const box = this.j.c.div();
28417
+ box.innerHTML = data.value;
28418
+ const blocks = [
28419
+ box,
28420
+ ...box.querySelectorAll(TRAILING_BR_BLOCKS)
28421
+ ];
28422
+ blocks.forEach((block)=>{
28423
+ const last = block.lastChild;
28424
+ if (!jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isTag(last, 'br')) {
28425
+ return;
28426
+ }
28427
+ const prev = last.previousSibling;
28428
+ if (!prev || jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isTag(prev, 'br')) {
28429
+ return;
28430
+ }
28431
+ if (jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isText(prev) && !prev.nodeValue?.trim() && !prev.previousSibling) {
28432
+ return;
28433
+ }
28434
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(last);
28435
+ });
28436
+ data.value = box.innerHTML;
28437
+ }
28438
+ __singleQuotesInFontFamily(data) {
28406
28439
  if (!this.j.o.cleanHTML.singleQuotesInFontFamily || !data.value.includes('&quot;')) {
28407
28440
  return;
28408
28441
  }
@@ -28489,6 +28522,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_1__.Config.prototype.cleanHTML = {
28489
28522
  fillEmptyParagraph: true,
28490
28523
  collapseEmptyValueToEmptyString: false,
28491
28524
  singleQuotesInFontFamily: true,
28525
+ removeTrailingBr: false,
28492
28526
  replaceNBSP: true,
28493
28527
  replaceOldTags: {
28494
28528
  i: 'em',
@@ -30584,6 +30618,11 @@ var DragState = /*#__PURE__*/ (/* unused pure expression or super */ null && (fu
30584
30618
  this.state = 2;
30585
30619
  }
30586
30620
  this.j.e.fire('hidePopup hideResizer');
30621
+ // The ghost lives in the top document (position: fixed), but the
30622
+ // mousemove comes from the editor document. In iframe mode those are
30623
+ // different viewports, so the iframe's own offset has to be added or
30624
+ // the ghost trails the pointer by exactly that distance (#1455).
30625
+ const offset = this.__ghostOffset();
30587
30626
  if (!this.draggable.parentNode) {
30588
30627
  const target = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.dataBind)(this.draggable, 'target');
30589
30628
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.css)(this.draggable, {
@@ -30593,19 +30632,35 @@ var DragState = /*#__PURE__*/ (/* unused pure expression or super */ null && (fu
30593
30632
  position: 'fixed',
30594
30633
  opacity: 0.7,
30595
30634
  display: 'inline-block',
30596
- left: event.clientX,
30597
- top: event.clientY,
30635
+ left: event.clientX + offset.left,
30636
+ top: event.clientY + offset.top,
30598
30637
  width: target?.offsetWidth ?? 100,
30599
30638
  height: target?.offsetHeight ?? 100
30600
30639
  });
30601
30640
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.append((0,jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.getContainer)(this.j, dragAndDropElement), this.draggable);
30602
30641
  }
30603
30642
  ;(0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.css)(this.draggable, {
30604
- left: event.clientX,
30605
- top: event.clientY
30643
+ left: event.clientX + offset.left,
30644
+ top: event.clientY + offset.top
30606
30645
  });
30646
+ // The caret goes into the editor document, so it keeps the raw
30647
+ // (iframe-relative) coordinates.
30607
30648
  this.j.s.insertCursorAtPoint(event.clientX, event.clientY);
30608
30649
  }
30650
+ __ghostOffset() {
30651
+ const iframe = this.j.iframe;
30652
+ if (!iframe) {
30653
+ return {
30654
+ left: 0,
30655
+ top: 0
30656
+ };
30657
+ }
30658
+ const rect = iframe.getBoundingClientRect();
30659
+ return {
30660
+ left: rect.left,
30661
+ top: rect.top
30662
+ };
30663
+ }
30609
30664
  /**
30610
30665
  * Mouseup handler in any place
30611
30666
  */ onDragEnd() {
@@ -36750,6 +36805,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
36750
36805
  jodit.history.snapshot.restore(snapshot);
36751
36806
  const textWasChanged = getSelectionText() !== content_input.value.trim();
36752
36807
  const ci = jodit.createInside;
36808
+ let caretAfter = null;
36753
36809
  if (!link || !jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.isOrContains(jodit.editor, link)) {
36754
36810
  if (!jodit.s.isCollapsed()) {
36755
36811
  const node = jodit.s.current();
@@ -36766,6 +36822,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
36766
36822
  links = [
36767
36823
  a
36768
36824
  ];
36825
+ caretAfter = a;
36769
36826
  }
36770
36827
  links.forEach((link)=>jodit.s.select(link));
36771
36828
  } else {
@@ -36798,6 +36855,13 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
36798
36855
  }
36799
36856
  jodit.e.fire('applyLink', jodit, a, form);
36800
36857
  });
36858
+ // A brand-new link inserted at a collapsed caret used to stay
36859
+ // *selected*. Safari does not paint that selection, so the next
36860
+ // Enter silently replaced the link instead of starting a new line.
36861
+ // Put the caret right after the link instead.
36862
+ if (caretAfter) {
36863
+ jodit.s.setCursorAfter(caretAfter);
36864
+ }
36801
36865
  jodit.synchronizeValues();
36802
36866
  close();
36803
36867
  return false;