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/es2015/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
  */
@@ -1830,7 +1830,7 @@ __webpack_require__.r(__webpack_exports__);
1830
1830
  * ```
1831
1831
  * @packageDocumentation
1832
1832
  * @module constants
1833
- */ const APP_VERSION = "4.19.11";
1833
+ */ const APP_VERSION = "4.19.12";
1834
1834
  // prettier-ignore
1835
1835
  const ES = "es2015";
1836
1836
  const IS_ES_MODERN = true;
@@ -16149,6 +16149,18 @@ class UITooltip extends jodit_core_ui_element__WEBPACK_IMPORTED_MODULE_9__.UIEle
16149
16149
  render() {
16150
16150
  return '<div><div class="&__content"></div></div>';
16151
16151
  }
16152
+ get __isEnabled() {
16153
+ const { o } = this.j;
16154
+ return !o.textIcons && Boolean(o.showTooltip) && !o.useNativeTooltip;
16155
+ }
16156
+ /**
16157
+ * Show tooltips for the buttons in an element outside the editor's
16158
+ * container, such as a toolbar placed by the `toolbar` option
16159
+ */ attach(container) {
16160
+ if (this.__isEnabled) {
16161
+ this.__onAttach(container);
16162
+ }
16163
+ }
16152
16164
  __onAttach(container) {
16153
16165
  // TODO Move it inside __show method. Now it is here because testcase failed with capturing
16154
16166
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.append((0,jodit_core_global__WEBPACK_IMPORTED_MODULE_5__.getContainer)(this.j, UITooltip), this.container);
@@ -16283,7 +16295,7 @@ class UITooltip extends jodit_core_ui_element__WEBPACK_IMPORTED_MODULE_9__.UIEle
16283
16295
  }
16284
16296
  constructor(view){
16285
16297
  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);
16286
- if (!view.o.textIcons && view.o.showTooltip && !view.o.useNativeTooltip) {
16298
+ if (this.__isEnabled) {
16287
16299
  this.j.e.on('getContainer', (box)=>{
16288
16300
  this.__onAttach(box);
16289
16301
  });
@@ -18629,7 +18641,12 @@ class ViewWithToolbar extends jodit_core_view_view__WEBPACK_IMPORTED_MODULE_11__
18629
18641
  return;
18630
18642
  }
18631
18643
  const buttons = this.o.buttons ? (0,jodit_core_helpers_array__WEBPACK_IMPORTED_MODULE_6__.splitArray)(this.o.buttons) : [];
18632
- (_this_toolbar = this.toolbar) === null || _this_toolbar === void 0 ? void 0 : _this_toolbar.setRemoveButtons(this.o.removeButtons).build(buttons.concat(this.o.extraButtons || [])).appendTo(this.toolbarContainer);
18644
+ const container = this.toolbarContainer;
18645
+ (_this_toolbar = this.toolbar) === null || _this_toolbar === void 0 ? void 0 : _this_toolbar.setRemoveButtons(this.o.removeButtons).build(buttons.concat(this.o.extraButtons || [])).appendTo(container);
18646
+ // The toolbar's own element, as editors can share the one it is placed in
18647
+ if (this.toolbar && !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_5__.Dom.isOrContains(this.container, container)) {
18648
+ this.__tooltip.attach(this.toolbar.container);
18649
+ }
18633
18650
  }
18634
18651
  getRegisteredButtonGroups() {
18635
18652
  return this.groupToButtons;
@@ -28676,6 +28693,17 @@ const ns = 'addnewline';
28676
28693
  editor.editor
28677
28694
  ], '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);
28678
28695
  }
28696
+ /**
28697
+ * An empty line with a `<br>`, as Enter makes, so it keeps its height
28698
+ * without clean-html's fillEmptyParagraph (#1807)
28699
+ */ __newLine() {
28700
+ const { j } = this;
28701
+ const line = j.createInside.element(j.o.enter);
28702
+ if (!jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.isTag(line, 'br')) {
28703
+ jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.append(line, j.createInside.element('br'));
28704
+ }
28705
+ return line;
28706
+ }
28679
28707
  /**
28680
28708
  * A paragraph holding only an embed has no place for the caret, so the
28681
28709
  * arrow keys can't get past one that ends the content, or before one that
@@ -28688,6 +28716,11 @@ const ns = 'addnewline';
28688
28716
  return;
28689
28717
  }
28690
28718
  const { startContainer, startOffset } = editor.s.range;
28719
+ // A caret in the editor itself, as beside a horizontal line, is in no
28720
+ // paragraph, and the browsers can leave it there with text beyond (#1803)
28721
+ if (startContainer === editor.editor) {
28722
+ return;
28723
+ }
28691
28724
  // Once the browser has moved the caret, if it could. With a 0 timeout
28692
28725
  // Jodit would run this at once, before the browser moves it
28693
28726
  editor.async.setTimeout(()=>{
@@ -28696,7 +28729,7 @@ const ns = 'addnewline';
28696
28729
  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)) {
28697
28730
  return;
28698
28731
  }
28699
- const p = editor.createInside.element(editor.o.enter);
28732
+ const p = this.__newLine();
28700
28733
  forward ? jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.append(editor.editor, p) : jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.prepend(editor.editor, p);
28701
28734
  editor.s.setCursorIn(p);
28702
28735
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.scrollIntoViewIfNeeded)(p, editor.editor, editor.ed);
@@ -28708,7 +28741,7 @@ const ns = 'addnewline';
28708
28741
  if (!editor.o.readonly && editor.o.addNewLineOnDBLClick && e.target === editor.editor && editor.s.isCollapsed()) {
28709
28742
  const editorBound = (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_5__.offset)(editor.editor, editor, editor.ed);
28710
28743
  const top = e.pageY - editor.ew.scrollX;
28711
- const p = editor.createInside.element(editor.o.enter);
28744
+ const p = this.__newLine();
28712
28745
  if (Math.abs(top - editorBound.top) < Math.abs(top - (editorBound.height + editorBound.top)) && editor.editor.firstChild) {
28713
28746
  jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.prepend(editor.editor, p);
28714
28747
  } else {
@@ -28793,7 +28826,7 @@ const ns = 'addnewline';
28793
28826
  return elm != null && jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.isBlock(elm) && !/^(img|table|iframe|hr)$/i.test(elm.nodeName);
28794
28827
  }), (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "__onClickLine", (e)=>{
28795
28828
  const editor = this.j;
28796
- const p = editor.createInside.element(editor.o.enter);
28829
+ const p = this.__newLine();
28797
28830
  if (this.__isBeforeContent && this.__current && this.__current.parentNode) {
28798
28831
  if (this.__current === editor.editor) {
28799
28832
  jodit_modules__WEBPACK_IMPORTED_MODULE_7__.Dom.prepend(editor.editor, p);
@@ -33550,6 +33583,7 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33550
33583
  }
33551
33584
  jodit.s.expandSelection();
33552
33585
  const range = jodit.s.range;
33586
+ this.__moveEdgesIntoCells(range);
33553
33587
  const caret = this.__clearSelectedCells(range);
33554
33588
  if (caret && range.collapsed) {
33555
33589
  jodit.s.selectRange(caret);
@@ -33571,6 +33605,22 @@ class deleteCommand extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_6__.Plugi
33571
33605
  jodit.s.selectRange(caret !== null && caret !== void 0 ? caret : range);
33572
33606
  return false;
33573
33607
  }
33608
+ /**
33609
+ * Firefox selects cells whole from their row, as after a drag into or out
33610
+ * of a table nested in a cell, and `deleteContents` would remove them. The
33611
+ * edges move into the cells, so their content is cleared instead, as in
33612
+ * Firefox's own delete
33613
+ */ __moveEdgesIntoCells(range) {
33614
+ const { startContainer, startOffset, endContainer, endOffset } = range;
33615
+ const first = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTag(startContainer, 'tr') ? startContainer.childNodes[startOffset] : null;
33616
+ const last = jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isTag(endContainer, 'tr') ? endContainer.childNodes[endOffset - 1] : null;
33617
+ if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isCell(first)) {
33618
+ range.setStart(first, 0);
33619
+ }
33620
+ if (jodit_core_dom__WEBPACK_IMPORTED_MODULE_2__.Dom.isCell(last)) {
33621
+ range.setEnd(last, last.childNodes.length);
33622
+ }
33623
+ }
33574
33624
  /**
33575
33625
  * A selection that starts or ends in a table cell clears the selected part
33576
33626
  * of each cell it covers and keeps the cells, as the browsers do.
@@ -36723,6 +36773,11 @@ function hr(editor) {
36723
36773
  return false;
36724
36774
  }
36725
36775
  const p = editor.createInside.element(editor.o.enter);
36776
+ // As Enter's new line has, so it keeps its height without clean-html's
36777
+ // fillEmptyParagraph (#1807)
36778
+ if (!jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.isTag(p, 'br')) {
36779
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.append(p, editor.createInside.element('br'));
36780
+ }
36726
36781
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__.Dom.after(elm, p);
36727
36782
  editor.s.setCursorIn(p);
36728
36783
  return false;
@@ -42865,11 +42920,15 @@ jodit_config__WEBPACK_IMPORTED_MODULE_0__.Config.prototype.mediaWrappers = {};
42865
42920
  });
42866
42921
  (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_4__.attr)(wrapper, 'style', (0,jodit_core_helpers_utils__WEBPACK_IMPORTED_MODULE_4__.attr)(element, 'style'));
42867
42922
  // The wrapper fits the media, whose size changes as its metadata loads
42868
- // and as it's resized. A percentage width is of the line, so it takes that
42923
+ // and as it's resized. It's inline, as the media is by default, so the
42924
+ // line's text-align still places it, or a block when the media is one.
42925
+ // A percentage width is of the line, so the wrapper is a block that
42926
+ // takes the line, and the media in it follows the text-align it inherits
42869
42927
  const fit = ()=>{
42928
+ const ofLine = (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.cssInline)(media, 'width').endsWith('%');
42870
42929
  (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.css)(wrapper, {
42871
- display: (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.cssInline)(media, 'display') === 'inline-block' ? 'inline-block' : 'block',
42872
- width: (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.cssInline)(media, 'width').endsWith('%') ? '' : 'fit-content',
42930
+ display: !ofLine && /^inline/.test((0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_5__.css)(media, 'display').toString()) ? 'inline-block' : 'block',
42931
+ width: ofLine ? '' : 'fit-content',
42873
42932
  height: ''
42874
42933
  });
42875
42934
  };
@@ -45889,8 +45948,11 @@ const IFRAME_WRAPPER = '[data-jodit_iframe_wrapper]';
45889
45948
  // is nothing measurable at all, let the wrapper size itself.
45890
45949
  const width = element.offsetWidth || attrPixelSize(element, 'width');
45891
45950
  const height = element.offsetHeight || attrPixelSize(element, 'height');
45951
+ // The wrapper takes the iframe's place in its line: inline, as an
45952
+ // iframe is by default, so the line's text-align still places it,
45953
+ // or a block when the iframe is one
45892
45954
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.css)(wrapper, {
45893
- display: (0,jodit_core_helpers_utils_css__WEBPACK_IMPORTED_MODULE_8__.cssInline)(element, 'display') === 'inline-block' ? 'inline-block' : 'block'
45955
+ display: /^inline/.test((0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.css)(element, 'display').toString()) ? 'inline-block' : 'block'
45894
45956
  });
45895
45957
  if (width) {
45896
45958
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_6__.css)(wrapper, 'width', width);
@@ -47224,20 +47286,13 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin
47224
47286
  /**
47225
47287
  * Mouse move inside the table
47226
47288
  */ __onMove(table, e) {
47227
- var _this_j_o_shadowRoot;
47228
47289
  if (this.j.o.readonly && !this.j.isLocked) {
47229
47290
  return;
47230
47291
  }
47231
47292
  if (this.j.isLockedNotBy(key)) {
47232
47293
  return;
47233
47294
  }
47234
- // Inside Shadow DOM `document.elementFromPoint` returns the shadow
47235
- // host, so the lookup must start from the shadow root
47236
- const node = ((_this_j_o_shadowRoot = this.j.o.shadowRoot) !== null && _this_j_o_shadowRoot !== void 0 ? _this_j_o_shadowRoot : this.j.ed).elementFromPoint(e.clientX, e.clientY);
47237
- const cell = node && jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(node, [
47238
- 'td',
47239
- 'th'
47240
- ], table);
47295
+ const cell = this.__cellUnder(e, table);
47241
47296
  if (!cell || !this.__selectedCell) {
47242
47297
  return;
47243
47298
  }
@@ -47282,32 +47337,26 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_7__.Plugin
47282
47337
  this.__isSelectionMode = false;
47283
47338
  this.__selectedCell = null;
47284
47339
  }
47340
+ // The cell of this table under the pointer; over a table nested in a cell, the mouse is still in that cell
47341
+ __cellUnder(e, table) {
47342
+ var _this_j_o_shadowRoot;
47343
+ // Inside Shadow DOM `document.elementFromPoint` returns the shadow
47344
+ // host, so the lookup must start from the shadow root
47345
+ const node = ((_this_j_o_shadowRoot = this.j.o.shadowRoot) !== null && _this_j_o_shadowRoot !== void 0 ? _this_j_o_shadowRoot : this.j.ed).elementFromPoint(e.clientX, e.clientY);
47346
+ 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);
47347
+ }
47285
47348
  /**
47286
47349
  * Stop a selection process
47287
47350
  */ __onStopSelection(table, e) {
47288
- var _this_j_o_shadowRoot;
47289
47351
  if (!this.__selectedCell) {
47290
47352
  return;
47291
47353
  }
47292
47354
  this.__isSelectionMode = false;
47293
47355
  this.j.unlock();
47294
- // Inside Shadow DOM `document.elementFromPoint` returns the shadow
47295
- // host, so the lookup must start from the shadow root
47296
- const node = ((_this_j_o_shadowRoot = this.j.o.shadowRoot) !== null && _this_j_o_shadowRoot !== void 0 ? _this_j_o_shadowRoot : this.j.ed).elementFromPoint(e.clientX, e.clientY);
47297
- if (!node) {
47298
- return;
47299
- }
47300
- const cell = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(node, [
47301
- 'td',
47302
- 'th'
47303
- ], table);
47356
+ const cell = this.__cellUnder(e, table);
47304
47357
  if (!cell) {
47305
47358
  return;
47306
47359
  }
47307
- const ownTable = jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_4__.Dom.closest(cell, 'table', table);
47308
- if (ownTable && ownTable !== table) {
47309
- return; // Nested tables
47310
- }
47311
47360
  this.__showCellsPopup(table, [
47312
47361
  cell,
47313
47362
  this.__selectedCell