jodit 4.2.25 → 4.2.27

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 (74) hide show
  1. package/CHANGELOG.md +20 -5
  2. package/es2015/jodit.css +4 -2
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +2 -2
  5. package/es2015/jodit.js +95 -57
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +2 -2
  8. package/es2015/plugins/debug/debug.js +1 -1
  9. package/es2015/plugins/debug/debug.min.js +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  13. package/es2018/jodit.css +4 -2
  14. package/es2018/jodit.fat.min.css +1 -1
  15. package/es2018/jodit.fat.min.js +2 -2
  16. package/es2018/jodit.js +95 -57
  17. package/es2018/jodit.min.css +1 -1
  18. package/es2018/jodit.min.js +2 -2
  19. package/es2018/plugins/debug/debug.js +1 -1
  20. package/es2018/plugins/debug/debug.min.js +1 -1
  21. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  22. package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
  23. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  24. package/es2021/jodit.css +4 -2
  25. package/es2021/jodit.fat.min.css +1 -1
  26. package/es2021/jodit.fat.min.js +2 -2
  27. package/es2021/jodit.js +95 -57
  28. package/es2021/jodit.min.css +1 -1
  29. package/es2021/jodit.min.js +2 -2
  30. package/es2021/plugins/debug/debug.js +1 -1
  31. package/es2021/plugins/debug/debug.min.js +1 -1
  32. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  33. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  34. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  35. package/es2021.en/jodit.css +4 -2
  36. package/es2021.en/jodit.fat.min.css +1 -1
  37. package/es2021.en/jodit.fat.min.js +2 -2
  38. package/es2021.en/jodit.js +95 -57
  39. package/es2021.en/jodit.min.css +1 -1
  40. package/es2021.en/jodit.min.js +2 -2
  41. package/es2021.en/plugins/debug/debug.js +1 -1
  42. package/es2021.en/plugins/debug/debug.min.js +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  44. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  45. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  46. package/es5/jodit.css +11 -6
  47. package/es5/jodit.fat.min.css +1 -1
  48. package/es5/jodit.fat.min.js +2 -2
  49. package/es5/jodit.js +96 -57
  50. package/es5/jodit.min.css +3 -3
  51. package/es5/jodit.min.js +2 -2
  52. package/es5/plugins/debug/debug.js +1 -1
  53. package/es5/plugins/debug/debug.min.js +1 -1
  54. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  55. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  56. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  57. package/esm/core/constants.js +3 -3
  58. package/esm/core/dom/dom.d.ts +2 -1
  59. package/esm/core/dom/dom.js +10 -4
  60. package/esm/core/global.js +4 -1
  61. package/esm/core/helpers/normalize/normalize-key-aliases.js +2 -1
  62. package/esm/core/ui/button/tooltip/tooltip.d.ts +1 -0
  63. package/esm/core/ui/button/tooltip/tooltip.js +11 -5
  64. package/esm/modules/table/table.d.ts +2 -3
  65. package/esm/modules/table/table.js +27 -34
  66. package/esm/plugins/add-new-line/add-new-line.js +4 -1
  67. package/esm/plugins/clean-html/helpers/visitor/filters/fill-empty-paragraph.js +9 -1
  68. package/esm/plugins/hotkeys/hotkeys.js +4 -2
  69. package/esm/plugins/select-cells/select-cells.js +1 -1
  70. package/esm/plugins/table/config.js +19 -3
  71. package/package.json +1 -1
  72. package/types/core/dom/dom.d.ts +2 -1
  73. package/types/core/ui/button/tooltip/tooltip.d.ts +1 -0
  74. package/types/modules/table/table.d.ts +2 -3
package/es2018/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.2.25
4
+ * Version: v4.2.27
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1736,7 +1736,7 @@ __webpack_require__.r(__webpack_exports__);
1736
1736
  * Released under MIT see LICENSE.txt in the project root for license information.
1737
1737
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
1738
1738
  */
1739
- const APP_VERSION = "4.2.25";
1739
+ const APP_VERSION = "4.2.27";
1740
1740
  // prettier-ignore
1741
1741
  const ES = "es2018";
1742
1742
  const IS_ES_MODERN = true;
@@ -1898,8 +1898,8 @@ const KEY_ALIASES = {
1898
1898
  option: 'alt',
1899
1899
  return: 'enter',
1900
1900
  right: 'arrowright',
1901
- space: ' ',
1902
- spacebar: ' ',
1901
+ space: 'space',
1902
+ spacebar: 'space',
1903
1903
  up: 'arrowup',
1904
1904
  win: 'meta',
1905
1905
  windows: 'meta'
@@ -2861,11 +2861,17 @@ class Dom {
2861
2861
  }
2862
2862
  static replace(elm, newTagName, create, withAttributes = false, notMoveContent = false) {
2863
2863
  if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isHTML */ .AH)(newTagName)) {
2864
+ void 0;
2864
2865
  newTagName = create.fromHTML(newTagName);
2865
2866
  }
2866
- const tag = (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isString */ .Kg)(newTagName)
2867
- ? create.element(newTagName)
2868
- : newTagName;
2867
+ let tag;
2868
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isString */ .Kg)(newTagName)) {
2869
+ void 0;
2870
+ tag = create.element(newTagName);
2871
+ }
2872
+ else {
2873
+ tag = newTagName;
2874
+ }
2869
2875
  if (!notMoveContent) {
2870
2876
  while (elm.firstChild) {
2871
2877
  tag.appendChild(elm.firstChild);
@@ -4518,7 +4524,8 @@ function getContainer(jodit, classFunc, tag = 'div', createInsideEditor = false)
4518
4524
  const data = boxes.get(jodit) || {}, key = name + tag;
4519
4525
  const view = (0,jodit_core_helpers_checker_is_view_object__WEBPACK_IMPORTED_MODULE_6__/* .isViewObject */ .h)(jodit) ? jodit : jodit.j;
4520
4526
  if (!data[key]) {
4521
- let c = view.c, body = (0,jodit_core_helpers_checker_is_jodit_object__WEBPACK_IMPORTED_MODULE_7__/* .isJoditObject */ .y)(jodit) && jodit.o.shadowRoot
4527
+ let c = view.c;
4528
+ let body = (0,jodit_core_helpers_checker_is_jodit_object__WEBPACK_IMPORTED_MODULE_7__/* .isJoditObject */ .y)(jodit) && jodit.o.shadowRoot
4522
4529
  ? jodit.o.shadowRoot
4523
4530
  : jodit.od.body;
4524
4531
  if (createInsideEditor &&
@@ -4538,6 +4545,7 @@ function getContainer(jodit, classFunc, tag = 'div', createInsideEditor = false)
4538
4545
  body.appendChild(box);
4539
4546
  data[key] = box;
4540
4547
  jodit.hookStatus('beforeDestruct', () => {
4548
+ view.events.off(box);
4541
4549
  _dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.safeRemove(box);
4542
4550
  delete data[key];
4543
4551
  if (Object.keys(data).length) {
@@ -4545,6 +4553,7 @@ function getContainer(jodit, classFunc, tag = 'div', createInsideEditor = false)
4545
4553
  }
4546
4554
  });
4547
4555
  boxes.set(jodit, data);
4556
+ view.events.fire('getContainer', box);
4548
4557
  }
4549
4558
  data[key].classList.remove('jodit_theme_default', 'jodit_theme_dark');
4550
4559
  data[key].classList.add(`jodit_theme_${view.o.theme || 'default'}`);
@@ -6345,7 +6354,8 @@ function normalizeKeyAliases(keys) {
6345
6354
  ctrl: 2,
6346
6355
  control: 2,
6347
6356
  alt: 3,
6348
- shift: 4
6357
+ shift: 4,
6358
+ space: 5
6349
6359
  };
6350
6360
  return keys
6351
6361
  .replace(/\+\+/g, '+add')
@@ -13422,15 +13432,21 @@ let UITooltip = UITooltip_1 = class UITooltip extends jodit_core_ui_element__WEB
13422
13432
  if (!view.o.textIcons &&
13423
13433
  view.o.showTooltip &&
13424
13434
  !view.o.useNativeTooltip) {
13435
+ this.j.e.on('getContainer', (box) => {
13436
+ this.__onAttach(box);
13437
+ });
13425
13438
  view.hookStatus(jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .STATUSES */ .f.ready, () => {
13426
- // TODO Move it inside __show method. Now it is here because testcase failed with capturing
13427
- (0,jodit_core_global__WEBPACK_IMPORTED_MODULE_3__/* .getContainer */ .My)(this.j, UITooltip_1).appendChild(this.container);
13428
- view.e.on(view.container, 'mouseenter.tooltip', this.__onMouseEnter, {
13429
- capture: true
13430
- });
13439
+ this.__onAttach(this.j.container);
13431
13440
  });
13432
13441
  }
13433
13442
  }
13443
+ __onAttach(container) {
13444
+ // TODO Move it inside __show method. Now it is here because testcase failed with capturing
13445
+ (0,jodit_core_global__WEBPACK_IMPORTED_MODULE_3__/* .getContainer */ .My)(this.j, UITooltip_1).appendChild(this.container);
13446
+ this.j.e.on(container, 'mouseenter.tooltip', this.__onMouseEnter, {
13447
+ capture: true
13448
+ });
13449
+ }
13434
13450
  __addListenersOnEnter() {
13435
13451
  if (this.__listenClose) {
13436
13452
  return;
@@ -22529,46 +22545,39 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22529
22545
  removeRow(table, rowIndex) {
22530
22546
  return Table.__removeRow(table, rowIndex);
22531
22547
  }
22532
- static __appendColumn(table, j, after, create) {
22548
+ /**
22549
+ * Insert column before / after all the columns containing the selected cells
22550
+ */
22551
+ appendColumn(table, selectedCell, insertAfter = true) {
22533
22552
  const box = Table.__formalMatrix(table);
22534
- let i;
22535
- if (j === undefined || j < 0) {
22536
- j = Table.__getColumnsCount(table) - 1;
22537
- }
22538
- for (i = 0; i < box.length; i += 1) {
22539
- const cell = create.element('td');
22540
- const td = box[i][j];
22541
- let added = false;
22542
- if (after) {
22543
- if ((box[i] && td && j + 1 >= box[i].length) ||
22544
- td !== box[i][j + 1]) {
22545
- if (td.nextSibling) {
22546
- jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(td.nextSibling, cell);
22547
- }
22548
- else {
22549
- td.parentNode && td.parentNode.appendChild(cell);
22550
- }
22551
- added = true;
22553
+ if (!insertAfter && jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.isCell(selectedCell.previousElementSibling)) {
22554
+ return this.appendColumn(table, selectedCell.previousElementSibling, true);
22555
+ }
22556
+ const columnIndex = insertAfter
22557
+ ? selectedCell.cellIndex + ((selectedCell.colSpan || 1) - 1)
22558
+ : selectedCell.cellIndex;
22559
+ const newColumnIndex = insertAfter ? columnIndex + 1 : columnIndex;
22560
+ for (let i = 0; i < box.length;) {
22561
+ const cells = box[i];
22562
+ if (cells[columnIndex] !== cells[newColumnIndex] ||
22563
+ columnIndex === newColumnIndex) {
22564
+ const cell = this.j.createInside.element('td');
22565
+ if (insertAfter) {
22566
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.after(cells[columnIndex], cell);
22552
22567
  }
22553
- }
22554
- else {
22555
- if (j - 1 < 0 ||
22556
- (box[i][j] !== box[i][j - 1] && box[i][j].parentNode)) {
22557
- jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(box[i][j], cell);
22558
- added = true;
22568
+ else {
22569
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(cells[columnIndex], cell);
22570
+ }
22571
+ if (cells[columnIndex].rowSpan > 1) {
22572
+ cell.rowSpan = cells[columnIndex].rowSpan;
22559
22573
  }
22560
22574
  }
22561
- if (!added) {
22562
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.attr)(box[i][j], 'colspan', parseInt((0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.attr)(box[i][j], 'colspan') || '1', 10) + 1);
22575
+ else {
22576
+ cells[columnIndex].colSpan += 1;
22563
22577
  }
22578
+ i += cells[columnIndex].rowSpan || 1;
22564
22579
  }
22565
22580
  }
22566
- /**
22567
- * Insert column before / after all the columns containing the selected cells
22568
- */
22569
- appendColumn(table, j, after) {
22570
- return Table.__appendColumn(table, j, after, this.j.createInside);
22571
- }
22572
22581
  static __removeColumn(table, j) {
22573
22582
  const box = Table.__formalMatrix(table);
22574
22583
  let dec;
@@ -22786,7 +22795,7 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22786
22795
  alreadyMerged.delete(first);
22787
22796
  Table.__unmark(__marked);
22788
22797
  Table.__normalizeTable(table);
22789
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.toArray)(table.rows).forEach((tr, index) => {
22798
+ (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.toArray)(table.rows).forEach(tr => {
22790
22799
  if (!tr.cells.length) {
22791
22800
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.safeRemove(tr);
22792
22801
  }
@@ -22795,7 +22804,7 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22795
22804
  }
22796
22805
  }
22797
22806
  /**
22798
- * It combines all of the selected cells into one. The contents of the cells will also be combined
22807
+ * It combines all the selected cells into one. The contents of the cells will also be combined
22799
22808
  */
22800
22809
  mergeSelected(table) {
22801
22810
  return Table.__mergeSelected(table, this.j);
@@ -25151,7 +25160,9 @@ class addNewLine extends jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Plugin {
25151
25160
  editor.e
25152
25161
  .off(editor.editor, '.' + ns)
25153
25162
  .off(editor.container, '.' + ns)
25163
+ .off('.' + ns)
25154
25164
  .on([editor.ow, editor.ew, editor.editor], 'scroll' + '.' + ns, this.__hideForce)
25165
+ .on('finishedCleanHTMLWorker' + '.' + ns, this.__hideForce)
25155
25166
  .on(editor.editor, 'click' + '.' + ns, this.__hide)
25156
25167
  .on(editor.container, 'mouseleave' + '.' + ns, this.__hide)
25157
25168
  .on(editor.editor, 'mousemove' + '.' + ns, this.__onMouseMove);
@@ -25239,7 +25250,8 @@ class addNewLine extends jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Plugin {
25239
25250
  jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(this.__line);
25240
25251
  this.j.e
25241
25252
  .off([this.j.ow, this.j.ew, this.j.editor], '.' + ns)
25242
- .off(this.j.container, '.' + ns);
25253
+ .off(this.j.container, '.' + ns)
25254
+ .off('.' + ns);
25243
25255
  }
25244
25256
  }
25245
25257
  (0,tslib__WEBPACK_IMPORTED_MODULE_5__/* .__decorate */ .Cg)([
@@ -27426,13 +27438,21 @@ function allowAttributes(jodit, nodeElm, hadEffect, allow) {
27426
27438
  */
27427
27439
 
27428
27440
 
27441
+ const TABLE_CONTAINER_TAGS = new Set([
27442
+ 'table',
27443
+ 'tbody',
27444
+ 'thead',
27445
+ 'tfoot',
27446
+ 'tr'
27447
+ ]);
27429
27448
  /**
27430
27449
  * @private
27431
27450
  */
27432
27451
  function fillEmptyParagraph(jodit, nodeElm, hadEffect) {
27433
27452
  if (jodit.o.cleanHTML.fillEmptyParagraph &&
27434
27453
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isBlock(nodeElm) &&
27435
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isEmpty(nodeElm, jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.INSEPARABLE_TAGS)) {
27454
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isEmpty(nodeElm, jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.INSEPARABLE_TAGS) &&
27455
+ !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isTag(nodeElm, TABLE_CONTAINER_TAGS)) {
27436
27456
  const br = jodit.createInside.element('br');
27437
27457
  nodeElm.appendChild(br);
27438
27458
  return true;
@@ -30663,7 +30683,8 @@ class hotkeys extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_3__/* .Plugin *
30663
30683
  constructor() {
30664
30684
  super(...arguments);
30665
30685
  this.onKeyPress = (event) => {
30666
- const special = this.specialKeys[event.which], character = (event.key || String.fromCharCode(event.which)).toLowerCase();
30686
+ const special = this.specialKeys[event.which];
30687
+ const character = (event.key || String.fromCharCode(event.which)).toLowerCase();
30667
30688
  const modif = [special || character];
30668
30689
  ['alt', 'ctrl', 'shift', 'meta'].forEach(specialKey => {
30669
30690
  if (event[specialKey + 'Key'] && special !== specialKey) {
@@ -30757,7 +30778,8 @@ class hotkeys extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_3__/* .Plugin *
30757
30778
  }
30758
30779
  })
30759
30780
  .on('keydown.hotkeys', (event) => {
30760
- const shortcut = this.onKeyPress(event), stop = {
30781
+ const shortcut = this.onKeyPress(event);
30782
+ const stop = {
30761
30783
  shouldStop: true
30762
30784
  };
30763
30785
  const resultOfFire = this.j.e.fire(shortcut + '.hotkey', event.type, stop);
@@ -39105,7 +39127,7 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__/* .Plug
39105
39127
  break;
39106
39128
  case 'addcolumnafter':
39107
39129
  case 'addcolumnbefore':
39108
- this.__tableModule.appendColumn(table, cell.cellIndex, command === 'addcolumnafter');
39130
+ this.__tableModule.appendColumn(table, cell, command === 'addcolumnafter');
39109
39131
  break;
39110
39132
  case 'addrowafter':
39111
39133
  case 'addrowbefore':
@@ -42464,6 +42486,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__/* .Config */ .T.prototype.controls.tab
42464
42486
  }
42465
42487
  },
42466
42488
  popup: (editor, current, close, button) => {
42489
+ editor.editor.normalize();
42490
+ const snapshot = editor.history.snapshot.make();
42467
42491
  const control = button.control;
42468
42492
  const default_rows_count = control.data && control.data.rows ? control.data.rows : 10, default_cols_count = control.data && control.data.cols ? control.data.cols : 10;
42469
42493
  const generateExtraClasses = () => {
@@ -42556,10 +42580,24 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__/* .Config */ .T.prototype.controls.tab
42556
42580
  table.classList.add(className);
42557
42581
  });
42558
42582
  });
42559
- if (editor.editor.firstChild) {
42560
- editor.s.insertNode(crt.text('\n'), false, false);
42583
+ editor.s.restore();
42584
+ editor.s.removeMarkers();
42585
+ editor.editor.normalize();
42586
+ editor.history.snapshot.restore(snapshot);
42587
+ const block = jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.furthest(editor.s.current(), jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.isBlock, editor.editor);
42588
+ if (block && jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.isEmpty(block)) {
42589
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.replace(block, table, undefined, false, true);
42590
+ }
42591
+ else {
42592
+ if (block) {
42593
+ const fake = crt.text('\n');
42594
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.after(block, fake);
42595
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.after(fake, table);
42596
+ }
42597
+ else {
42598
+ editor.s.insertNode(table, false);
42599
+ }
42561
42600
  }
42562
- editor.s.insertNode(table, false);
42563
42601
  if (first_td) {
42564
42602
  editor.s.setCursorIn(first_td);
42565
42603
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.scrollIntoViewIfNeeded)(first_td, editor.editor, editor.ed);