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/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.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 = "es2015";
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')
@@ -13397,15 +13407,21 @@ let UITooltip = UITooltip_1 = class UITooltip extends jodit_core_ui_element__WEB
13397
13407
  if (!view.o.textIcons &&
13398
13408
  view.o.showTooltip &&
13399
13409
  !view.o.useNativeTooltip) {
13410
+ this.j.e.on('getContainer', (box) => {
13411
+ this.__onAttach(box);
13412
+ });
13400
13413
  view.hookStatus(jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .STATUSES */ .f.ready, () => {
13401
- // TODO Move it inside __show method. Now it is here because testcase failed with capturing
13402
- (0,jodit_core_global__WEBPACK_IMPORTED_MODULE_3__/* .getContainer */ .My)(this.j, UITooltip_1).appendChild(this.container);
13403
- view.e.on(view.container, 'mouseenter.tooltip', this.__onMouseEnter, {
13404
- capture: true
13405
- });
13414
+ this.__onAttach(this.j.container);
13406
13415
  });
13407
13416
  }
13408
13417
  }
13418
+ __onAttach(container) {
13419
+ // TODO Move it inside __show method. Now it is here because testcase failed with capturing
13420
+ (0,jodit_core_global__WEBPACK_IMPORTED_MODULE_3__/* .getContainer */ .My)(this.j, UITooltip_1).appendChild(this.container);
13421
+ this.j.e.on(container, 'mouseenter.tooltip', this.__onMouseEnter, {
13422
+ capture: true
13423
+ });
13424
+ }
13409
13425
  __addListenersOnEnter() {
13410
13426
  if (this.__listenClose) {
13411
13427
  return;
@@ -22463,46 +22479,39 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22463
22479
  removeRow(table, rowIndex) {
22464
22480
  return Table.__removeRow(table, rowIndex);
22465
22481
  }
22466
- static __appendColumn(table, j, after, create) {
22482
+ /**
22483
+ * Insert column before / after all the columns containing the selected cells
22484
+ */
22485
+ appendColumn(table, selectedCell, insertAfter = true) {
22467
22486
  const box = Table.__formalMatrix(table);
22468
- let i;
22469
- if (j === undefined || j < 0) {
22470
- j = Table.__getColumnsCount(table) - 1;
22471
- }
22472
- for (i = 0; i < box.length; i += 1) {
22473
- const cell = create.element('td');
22474
- const td = box[i][j];
22475
- let added = false;
22476
- if (after) {
22477
- if ((box[i] && td && j + 1 >= box[i].length) ||
22478
- td !== box[i][j + 1]) {
22479
- if (td.nextSibling) {
22480
- jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(td.nextSibling, cell);
22481
- }
22482
- else {
22483
- td.parentNode && td.parentNode.appendChild(cell);
22484
- }
22485
- added = true;
22487
+ if (!insertAfter && jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.isCell(selectedCell.previousElementSibling)) {
22488
+ return this.appendColumn(table, selectedCell.previousElementSibling, true);
22489
+ }
22490
+ const columnIndex = insertAfter
22491
+ ? selectedCell.cellIndex + ((selectedCell.colSpan || 1) - 1)
22492
+ : selectedCell.cellIndex;
22493
+ const newColumnIndex = insertAfter ? columnIndex + 1 : columnIndex;
22494
+ for (let i = 0; i < box.length;) {
22495
+ const cells = box[i];
22496
+ if (cells[columnIndex] !== cells[newColumnIndex] ||
22497
+ columnIndex === newColumnIndex) {
22498
+ const cell = this.j.createInside.element('td');
22499
+ if (insertAfter) {
22500
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.after(cells[columnIndex], cell);
22486
22501
  }
22487
- }
22488
- else {
22489
- if (j - 1 < 0 ||
22490
- (box[i][j] !== box[i][j - 1] && box[i][j].parentNode)) {
22491
- jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(box[i][j], cell);
22492
- added = true;
22502
+ else {
22503
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(cells[columnIndex], cell);
22504
+ }
22505
+ if (cells[columnIndex].rowSpan > 1) {
22506
+ cell.rowSpan = cells[columnIndex].rowSpan;
22493
22507
  }
22494
22508
  }
22495
- if (!added) {
22496
- (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);
22509
+ else {
22510
+ cells[columnIndex].colSpan += 1;
22497
22511
  }
22512
+ i += cells[columnIndex].rowSpan || 1;
22498
22513
  }
22499
22514
  }
22500
- /**
22501
- * Insert column before / after all the columns containing the selected cells
22502
- */
22503
- appendColumn(table, j, after) {
22504
- return Table.__appendColumn(table, j, after, this.j.createInside);
22505
- }
22506
22515
  static __removeColumn(table, j) {
22507
22516
  const box = Table.__formalMatrix(table);
22508
22517
  let dec;
@@ -22720,7 +22729,7 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22720
22729
  alreadyMerged.delete(first);
22721
22730
  Table.__unmark(__marked);
22722
22731
  Table.__normalizeTable(table);
22723
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.toArray)(table.rows).forEach((tr, index) => {
22732
+ (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.toArray)(table.rows).forEach(tr => {
22724
22733
  if (!tr.cells.length) {
22725
22734
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.safeRemove(tr);
22726
22735
  }
@@ -22729,7 +22738,7 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22729
22738
  }
22730
22739
  }
22731
22740
  /**
22732
- * It combines all of the selected cells into one. The contents of the cells will also be combined
22741
+ * It combines all the selected cells into one. The contents of the cells will also be combined
22733
22742
  */
22734
22743
  mergeSelected(table) {
22735
22744
  return Table.__mergeSelected(table, this.j);
@@ -25070,7 +25079,9 @@ class addNewLine extends jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Plugin {
25070
25079
  editor.e
25071
25080
  .off(editor.editor, '.' + ns)
25072
25081
  .off(editor.container, '.' + ns)
25082
+ .off('.' + ns)
25073
25083
  .on([editor.ow, editor.ew, editor.editor], 'scroll' + '.' + ns, this.__hideForce)
25084
+ .on('finishedCleanHTMLWorker' + '.' + ns, this.__hideForce)
25074
25085
  .on(editor.editor, 'click' + '.' + ns, this.__hide)
25075
25086
  .on(editor.container, 'mouseleave' + '.' + ns, this.__hide)
25076
25087
  .on(editor.editor, 'mousemove' + '.' + ns, this.__onMouseMove);
@@ -25158,7 +25169,8 @@ class addNewLine extends jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Plugin {
25158
25169
  jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(this.__line);
25159
25170
  this.j.e
25160
25171
  .off([this.j.ow, this.j.ew, this.j.editor], '.' + ns)
25161
- .off(this.j.container, '.' + ns);
25172
+ .off(this.j.container, '.' + ns)
25173
+ .off('.' + ns);
25162
25174
  }
25163
25175
  }
25164
25176
  (0,tslib__WEBPACK_IMPORTED_MODULE_5__/* .__decorate */ .Cg)([
@@ -27343,13 +27355,21 @@ function allowAttributes(jodit, nodeElm, hadEffect, allow) {
27343
27355
  */
27344
27356
 
27345
27357
 
27358
+ const TABLE_CONTAINER_TAGS = new Set([
27359
+ 'table',
27360
+ 'tbody',
27361
+ 'thead',
27362
+ 'tfoot',
27363
+ 'tr'
27364
+ ]);
27346
27365
  /**
27347
27366
  * @private
27348
27367
  */
27349
27368
  function fillEmptyParagraph(jodit, nodeElm, hadEffect) {
27350
27369
  if (jodit.o.cleanHTML.fillEmptyParagraph &&
27351
27370
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isBlock(nodeElm) &&
27352
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isEmpty(nodeElm, jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.INSEPARABLE_TAGS)) {
27371
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isEmpty(nodeElm, jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.INSEPARABLE_TAGS) &&
27372
+ !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isTag(nodeElm, TABLE_CONTAINER_TAGS)) {
27353
27373
  const br = jodit.createInside.element('br');
27354
27374
  nodeElm.appendChild(br);
27355
27375
  return true;
@@ -30572,7 +30592,8 @@ class hotkeys extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_3__/* .Plugin *
30572
30592
  constructor() {
30573
30593
  super(...arguments);
30574
30594
  this.onKeyPress = (event) => {
30575
- const special = this.specialKeys[event.which], character = (event.key || String.fromCharCode(event.which)).toLowerCase();
30595
+ const special = this.specialKeys[event.which];
30596
+ const character = (event.key || String.fromCharCode(event.which)).toLowerCase();
30576
30597
  const modif = [special || character];
30577
30598
  ['alt', 'ctrl', 'shift', 'meta'].forEach(specialKey => {
30578
30599
  if (event[specialKey + 'Key'] && special !== specialKey) {
@@ -30666,7 +30687,8 @@ class hotkeys extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_3__/* .Plugin *
30666
30687
  }
30667
30688
  })
30668
30689
  .on('keydown.hotkeys', (event) => {
30669
- const shortcut = this.onKeyPress(event), stop = {
30690
+ const shortcut = this.onKeyPress(event);
30691
+ const stop = {
30670
30692
  shouldStop: true
30671
30693
  };
30672
30694
  const resultOfFire = this.j.e.fire(shortcut + '.hotkey', event.type, stop);
@@ -39050,7 +39072,7 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__/* .Plug
39050
39072
  break;
39051
39073
  case 'addcolumnafter':
39052
39074
  case 'addcolumnbefore':
39053
- this.__tableModule.appendColumn(table, cell.cellIndex, command === 'addcolumnafter');
39075
+ this.__tableModule.appendColumn(table, cell, command === 'addcolumnafter');
39054
39076
  break;
39055
39077
  case 'addrowafter':
39056
39078
  case 'addrowbefore':
@@ -42409,6 +42431,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__/* .Config */ .T.prototype.controls.tab
42409
42431
  }
42410
42432
  },
42411
42433
  popup: (editor, current, close, button) => {
42434
+ editor.editor.normalize();
42435
+ const snapshot = editor.history.snapshot.make();
42412
42436
  const control = button.control;
42413
42437
  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;
42414
42438
  const generateExtraClasses = () => {
@@ -42501,10 +42525,24 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__/* .Config */ .T.prototype.controls.tab
42501
42525
  table.classList.add(className);
42502
42526
  });
42503
42527
  });
42504
- if (editor.editor.firstChild) {
42505
- editor.s.insertNode(crt.text('\n'), false, false);
42528
+ editor.s.restore();
42529
+ editor.s.removeMarkers();
42530
+ editor.editor.normalize();
42531
+ editor.history.snapshot.restore(snapshot);
42532
+ 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);
42533
+ if (block && jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.isEmpty(block)) {
42534
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.replace(block, table, undefined, false, true);
42535
+ }
42536
+ else {
42537
+ if (block) {
42538
+ const fake = crt.text('\n');
42539
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.after(block, fake);
42540
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.after(fake, table);
42541
+ }
42542
+ else {
42543
+ editor.s.insertNode(table, false);
42544
+ }
42506
42545
  }
42507
- editor.s.insertNode(table, false);
42508
42546
  if (first_td) {
42509
42547
  editor.s.setCursorIn(first_td);
42510
42548
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.scrollIntoViewIfNeeded)(first_td, editor.editor, editor.ed);