jodit 4.19.11 → 4.19.12

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 (76) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/es2015/jodit.css +33 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +9 -9
  5. package/es2015/jodit.js +83 -34
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +9 -9
  8. package/es2015/plugins/debug/debug.css +1 -1
  9. package/es2015/plugins/debug/debug.js +1 -1
  10. package/es2015/plugins/debug/debug.min.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  13. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  14. package/es2018/jodit.fat.min.css +1 -1
  15. package/es2018/jodit.fat.min.js +9 -9
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +9 -9
  18. package/es2018/plugins/debug/debug.min.js +1 -1
  19. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  20. package/es2021/jodit.css +33 -1
  21. package/es2021/jodit.fat.min.css +1 -1
  22. package/es2021/jodit.fat.min.js +9 -9
  23. package/es2021/jodit.js +82 -32
  24. package/es2021/jodit.min.css +1 -1
  25. package/es2021/jodit.min.js +9 -9
  26. package/es2021/plugins/debug/debug.css +1 -1
  27. package/es2021/plugins/debug/debug.js +1 -1
  28. package/es2021/plugins/debug/debug.min.js +1 -1
  29. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  30. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  31. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  32. package/es2021.en/jodit.css +33 -1
  33. package/es2021.en/jodit.fat.min.css +1 -1
  34. package/es2021.en/jodit.fat.min.js +9 -9
  35. package/es2021.en/jodit.js +82 -32
  36. package/es2021.en/jodit.min.css +1 -1
  37. package/es2021.en/jodit.min.js +10 -10
  38. package/es2021.en/plugins/debug/debug.css +1 -1
  39. package/es2021.en/plugins/debug/debug.js +1 -1
  40. package/es2021.en/plugins/debug/debug.min.js +1 -1
  41. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  42. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  44. package/es5/jodit.css +34 -2
  45. package/es5/jodit.fat.min.css +1 -1
  46. package/es5/jodit.fat.min.js +2 -2
  47. package/es5/jodit.js +101 -34
  48. package/es5/jodit.min.css +3 -3
  49. package/es5/jodit.min.js +2 -2
  50. package/es5/plugins/debug/debug.css +1 -1
  51. package/es5/plugins/debug/debug.js +1 -1
  52. package/es5/plugins/debug/debug.min.js +1 -1
  53. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  56. package/es5/polyfills.fat.min.js +1 -1
  57. package/es5/polyfills.js +1 -1
  58. package/es5/polyfills.min.js +1 -1
  59. package/esm/core/constants.js +1 -1
  60. package/esm/core/ui/button/tooltip/tooltip.d.ts +6 -0
  61. package/esm/core/ui/button/tooltip/tooltip.js +14 -3
  62. package/esm/core/view/view-with-toolbar.js +6 -1
  63. package/esm/plugins/add-new-line/add-new-line.d.ts +5 -0
  64. package/esm/plugins/add-new-line/add-new-line.js +20 -3
  65. package/esm/plugins/delete/delete.d.ts +7 -0
  66. package/esm/plugins/delete/delete.js +22 -0
  67. package/esm/plugins/hr/hr.js +5 -0
  68. package/esm/plugins/media/media.js +8 -5
  69. package/esm/plugins/resizer/resizer.js +4 -1
  70. package/esm/plugins/select-cells/select-cells.d.ts +1 -0
  71. package/esm/plugins/select-cells/select-cells.js +12 -18
  72. package/package.json +1 -1
  73. package/types/core/ui/button/tooltip/tooltip.d.ts +6 -0
  74. package/types/plugins/add-new-line/add-new-line.d.ts +5 -0
  75. package/types/plugins/delete/delete.d.ts +7 -0
  76. package/types/plugins/select-cells/select-cells.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.19.11
4
+ * Version: v4.19.12
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1824,7 +1824,7 @@ __webpack_require__.r(__webpack_exports__);
1824
1824
  * ```
1825
1825
  * @packageDocumentation
1826
1826
  * @module constants
1827
- */ const APP_VERSION = "4.19.11";
1827
+ */ const APP_VERSION = "4.19.12";
1828
1828
  // prettier-ignore
1829
1829
  const ES = "es2021";
1830
1830
  const IS_ES_MODERN = true;
@@ -16023,6 +16023,18 @@ class UITooltip extends jodit_core_ui_element__WEBPACK_IMPORTED_MODULE_9__.UIEle
16023
16023
  render() {
16024
16024
  return '<div><div class="&__content"></div></div>';
16025
16025
  }
16026
+ get __isEnabled() {
16027
+ const { o } = this.j;
16028
+ return !o.textIcons && Boolean(o.showTooltip) && !o.useNativeTooltip;
16029
+ }
16030
+ /**
16031
+ * Show tooltips for the buttons in an element outside the editor's
16032
+ * container, such as a toolbar placed by the `toolbar` option
16033
+ */ attach(container) {
16034
+ if (this.__isEnabled) {
16035
+ this.__onAttach(container);
16036
+ }
16037
+ }
16026
16038
  __onAttach(container) {
16027
16039
  // TODO Move it inside __show method. Now it is here because testcase failed with capturing
16028
16040
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append((0,jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.getContainer)(this.j, UITooltip), this.container);
@@ -16157,7 +16169,7 @@ class UITooltip extends jodit_core_ui_element__WEBPACK_IMPORTED_MODULE_9__.UIEle
16157
16169
  }
16158
16170
  constructor(view){
16159
16171
  super(view), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__isOpened", false), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__attachedContainers", new Set()), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__listenClose", false), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__currentTarget", null), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__delayShowTimeout", 0), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__hideTimeout", 0);
16160
- if (!view.o.textIcons && view.o.showTooltip && !view.o.useNativeTooltip) {
16172
+ if (this.__isEnabled) {
16161
16173
  this.j.e.on('getContainer', (box)=>{
16162
16174
  this.__onAttach(box);
16163
16175
  });
@@ -18476,7 +18488,12 @@ class ViewWithToolbar extends jodit_core_view_view__WEBPACK_IMPORTED_MODULE_11__
18476
18488
  return;
18477
18489
  }
18478
18490
  const buttons = this.o.buttons ? (0,jodit_core_helpers_array__WEBPACK_IMPORTED_MODULE_6__.splitArray)(this.o.buttons) : [];
18479
- this.toolbar?.setRemoveButtons(this.o.removeButtons).build(buttons.concat(this.o.extraButtons || [])).appendTo(this.toolbarContainer);
18491
+ const container = this.toolbarContainer;
18492
+ this.toolbar?.setRemoveButtons(this.o.removeButtons).build(buttons.concat(this.o.extraButtons || [])).appendTo(container);
18493
+ // The toolbar's own element, as editors can share the one it is placed in
18494
+ if (this.toolbar && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isOrContains(this.container, container)) {
18495
+ this.__tooltip.attach(this.toolbar.container);
18496
+ }
18480
18497
  }
18481
18498
  getRegisteredButtonGroups() {
18482
18499
  return this.groupToButtons;
@@ -28438,6 +28455,17 @@ const ns = 'addnewline';
28438
28455
  editor.editor
28439
28456
  ], 'scroll' + '.' + ns, this.__hideForce).on('finishedCleanHTMLWorker' + '.' + ns, this.__hideForce).on(editor.editor, 'click' + '.' + ns, this.__hide).on(editor.container, 'mouseleave' + '.' + ns, this.__hide).on(editor.editor, 'mousemove' + '.' + ns, this.__onMouseMove);
28440
28457
  }
28458
+ /**
28459
+ * An empty line with a `<br>`, as Enter makes, so it keeps its height
28460
+ * without clean-html's fillEmptyParagraph (#1807)
28461
+ */ __newLine() {
28462
+ const { j } = this;
28463
+ const line = j.createInside.element(j.o.enter);
28464
+ if (!jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.isTag(line, 'br')) {
28465
+ jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.append(line, j.createInside.element('br'));
28466
+ }
28467
+ return line;
28468
+ }
28441
28469
  /**
28442
28470
  * A paragraph holding only an embed has no place for the caret, so the
28443
28471
  * arrow keys can't get past one that ends the content, or before one that
@@ -28450,6 +28478,11 @@ const ns = 'addnewline';
28450
28478
  return;
28451
28479
  }
28452
28480
  const { startContainer, startOffset } = editor.s.range;
28481
+ // A caret in the editor itself, as beside a horizontal line, is in no
28482
+ // paragraph, and the browsers can leave it there with text beyond (#1803)
28483
+ if (startContainer === editor.editor) {
28484
+ return;
28485
+ }
28453
28486
  // Once the browser has moved the caret, if it could. With a 0 timeout
28454
28487
  // Jodit would run this at once, before the browser moves it
28455
28488
  editor.async.setTimeout(()=>{
@@ -28458,7 +28491,7 @@ const ns = 'addnewline';
28458
28491
  if (e.defaultPrevented || !editor.s.isInsideArea || !range.collapsed || range.startContainer !== startContainer || range.startOffset !== startOffset || !block || !jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.findNotEmptyNeighbor(block, !forward, editor.editor)) {
28459
28492
  return;
28460
28493
  }
28461
- const p = editor.createInside.element(editor.o.enter);
28494
+ const p = this.__newLine();
28462
28495
  forward ? jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.append(editor.editor, p) : jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.prepend(editor.editor, p);
28463
28496
  editor.s.setCursorIn(p);
28464
28497
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.scrollIntoViewIfNeeded)(p, editor.editor, editor.ed);
@@ -28470,7 +28503,7 @@ const ns = 'addnewline';
28470
28503
  if (!editor.o.readonly && editor.o.addNewLineOnDBLClick && e.target === editor.editor && editor.s.isCollapsed()) {
28471
28504
  const editorBound = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.offset)(editor.editor, editor, editor.ed);
28472
28505
  const top = e.pageY - editor.ew.scrollX;
28473
- const p = editor.createInside.element(editor.o.enter);
28506
+ const p = this.__newLine();
28474
28507
  if (Math.abs(top - editorBound.top) < Math.abs(top - (editorBound.height + editorBound.top)) && editor.editor.firstChild) {
28475
28508
  jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.prepend(editor.editor, p);
28476
28509
  } else {
@@ -28554,7 +28587,7 @@ const ns = 'addnewline';
28554
28587
  return elm != null && jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.isBlock(elm) && !/^(img|table|iframe|hr)$/i.test(elm.nodeName);
28555
28588
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__onClickLine", (e)=>{
28556
28589
  const editor = this.j;
28557
- const p = editor.createInside.element(editor.o.enter);
28590
+ const p = this.__newLine();
28558
28591
  if (this.__isBeforeContent && this.__current && this.__current.parentNode) {
28559
28592
  if (this.__current === editor.editor) {
28560
28593
  jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.prepend(editor.editor, p);
@@ -33287,6 +33320,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33287
33320
  }
33288
33321
  jodit.s.expandSelection();
33289
33322
  const range = jodit.s.range;
33323
+ this.__moveEdgesIntoCells(range);
33290
33324
  const caret = this.__clearSelectedCells(range);
33291
33325
  if (caret && range.collapsed) {
33292
33326
  jodit.s.selectRange(caret);
@@ -33308,6 +33342,22 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33308
33342
  jodit.s.selectRange(caret ?? range);
33309
33343
  return false;
33310
33344
  }
33345
+ /**
33346
+ * Firefox selects cells whole from their row, as after a drag into or out
33347
+ * of a table nested in a cell, and `deleteContents` would remove them. The
33348
+ * edges move into the cells, so their content is cleared instead, as in
33349
+ * Firefox's own delete
33350
+ */ __moveEdgesIntoCells(range) {
33351
+ const { startContainer, startOffset, endContainer, endOffset } = range;
33352
+ const first = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTag(startContainer, 'tr') ? startContainer.childNodes[startOffset] : null;
33353
+ const last = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTag(endContainer, 'tr') ? endContainer.childNodes[endOffset - 1] : null;
33354
+ if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isCell(first)) {
33355
+ range.setStart(first, 0);
33356
+ }
33357
+ if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isCell(last)) {
33358
+ range.setEnd(last, last.childNodes.length);
33359
+ }
33360
+ }
33311
33361
  /**
33312
33362
  * A selection that starts or ends in a table cell clears the selected part
33313
33363
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -36423,6 +36473,11 @@ function hr(editor) {
36423
36473
  return false;
36424
36474
  }
36425
36475
  const p = editor.createInside.element(editor.o.enter);
36476
+ // As Enter's new line has, so it keeps its height without clean-html's
36477
+ // fillEmptyParagraph (#1807)
36478
+ if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(p, 'br')) {
36479
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.append(p, editor.createInside.element('br'));
36480
+ }
36426
36481
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.after(elm, p);
36427
36482
  editor.s.setCursorIn(p);
36428
36483
  return false;
@@ -42505,11 +42560,15 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.mediaWrappers = {};
42505
42560
  });
42506
42561
  (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_4__.attr)(wrapper, 'style', (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_4__.attr)(element, 'style'));
42507
42562
  // The wrapper fits the media, whose size changes as its metadata loads
42508
- // and as it's resized. A percentage width is of the line, so it takes that
42563
+ // and as it's resized. It's inline, as the media is by default, so the
42564
+ // line's text-align still places it, or a block when the media is one.
42565
+ // A percentage width is of the line, so the wrapper is a block that
42566
+ // takes the line, and the media in it follows the text-align it inherits
42509
42567
  const fit = ()=>{
42568
+ const ofLine = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.cssInline)(media, 'width').endsWith('%');
42510
42569
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.css)(wrapper, {
42511
- display: (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.cssInline)(media, 'display') === 'inline-block' ? 'inline-block' : 'block',
42512
- width: (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.cssInline)(media, 'width').endsWith('%') ? '' : 'fit-content',
42570
+ display: !ofLine && /^inline/.test((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.css)(media, 'display').toString()) ? 'inline-block' : 'block',
42571
+ width: ofLine ? '' : 'fit-content',
42513
42572
  height: ''
42514
42573
  });
42515
42574
  };
@@ -45507,8 +45566,11 @@ const IFRAME_WRAPPER = '[data-jodit_iframe_wrapper]';
45507
45566
  // is nothing measurable at all, let the wrapper size itself.
45508
45567
  const width = element.offsetWidth || attrPixelSize(element, 'width');
45509
45568
  const height = element.offsetHeight || attrPixelSize(element, 'height');
45569
+ // The wrapper takes the iframe's place in its line: inline, as an
45570
+ // iframe is by default, so the line's text-align still places it,
45571
+ // or a block when the iframe is one
45510
45572
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.css)(wrapper, {
45511
- display: (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.cssInline)(element, 'display') === 'inline-block' ? 'inline-block' : 'block'
45573
+ display: /^inline/.test((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.css)(element, 'display').toString()) ? 'inline-block' : 'block'
45512
45574
  });
45513
45575
  if (width) {
45514
45576
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.css)(wrapper, 'width', width);
@@ -46818,13 +46880,7 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin
46818
46880
  if (this.j.isLockedNotBy(key)) {
46819
46881
  return;
46820
46882
  }
46821
- // Inside Shadow DOM `document.elementFromPoint` returns the shadow
46822
- // host, so the lookup must start from the shadow root
46823
- const node = (this.j.o.shadowRoot ?? this.j.ed).elementFromPoint(e.clientX, e.clientY);
46824
- const cell = node && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(node, [
46825
- 'td',
46826
- 'th'
46827
- ], table);
46883
+ const cell = this.__cellUnder(e, table);
46828
46884
  if (!cell || !this.__selectedCell) {
46829
46885
  return;
46830
46886
  }
@@ -46867,6 +46923,13 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin
46867
46923
  this.__isSelectionMode = false;
46868
46924
  this.__selectedCell = null;
46869
46925
  }
46926
+ // The cell of this table under the pointer; over a table nested in a cell, the mouse is still in that cell
46927
+ __cellUnder(e, table) {
46928
+ // Inside Shadow DOM `document.elementFromPoint` returns the shadow
46929
+ // host, so the lookup must start from the shadow root
46930
+ const node = (this.j.o.shadowRoot ?? this.j.ed).elementFromPoint(e.clientX, e.clientY);
46931
+ return jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(node, (elm)=>jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.isCell(elm) && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(elm, 'table', table), table);
46932
+ }
46870
46933
  /**
46871
46934
  * Stop a selection process
46872
46935
  */ __onStopSelection(table, e) {
@@ -46875,23 +46938,10 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin
46875
46938
  }
46876
46939
  this.__isSelectionMode = false;
46877
46940
  this.j.unlock();
46878
- // Inside Shadow DOM `document.elementFromPoint` returns the shadow
46879
- // host, so the lookup must start from the shadow root
46880
- const node = (this.j.o.shadowRoot ?? this.j.ed).elementFromPoint(e.clientX, e.clientY);
46881
- if (!node) {
46882
- return;
46883
- }
46884
- const cell = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(node, [
46885
- 'td',
46886
- 'th'
46887
- ], table);
46941
+ const cell = this.__cellUnder(e, table);
46888
46942
  if (!cell) {
46889
46943
  return;
46890
46944
  }
46891
- const ownTable = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(cell, 'table', table);
46892
- if (ownTable && ownTable !== table) {
46893
- return; // Nested tables
46894
- }
46895
46945
  this.__showCellsPopup(table, [
46896
46946
  cell,
46897
46947
  this.__selectedCell