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/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.2.25
4
+ * Version: v4.2.27
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -1737,7 +1737,7 @@ __webpack_require__.r(__webpack_exports__);
1737
1737
  * Released under MIT see LICENSE.txt in the project root for license information.
1738
1738
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
1739
1739
  */
1740
- const APP_VERSION = "4.2.25";
1740
+ const APP_VERSION = "4.2.27";
1741
1741
  // prettier-ignore
1742
1742
  const ES = "es2021";
1743
1743
  const IS_ES_MODERN = true;
@@ -1899,8 +1899,8 @@ const KEY_ALIASES = {
1899
1899
  option: 'alt',
1900
1900
  return: 'enter',
1901
1901
  right: 'arrowright',
1902
- space: ' ',
1903
- spacebar: ' ',
1902
+ space: 'space',
1903
+ spacebar: 'space',
1904
1904
  up: 'arrowup',
1905
1905
  win: 'meta',
1906
1906
  windows: 'meta'
@@ -2858,11 +2858,17 @@ class Dom {
2858
2858
  }
2859
2859
  static replace(elm, newTagName, create, withAttributes = false, notMoveContent = false) {
2860
2860
  if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isHTML */ .AH)(newTagName)) {
2861
+ void 0;
2861
2862
  newTagName = create.fromHTML(newTagName);
2862
2863
  }
2863
- const tag = (0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isString */ .Kg)(newTagName)
2864
- ? create.element(newTagName)
2865
- : newTagName;
2864
+ let tag;
2865
+ if ((0,jodit_core_helpers_checker__WEBPACK_IMPORTED_MODULE_2__/* .isString */ .Kg)(newTagName)) {
2866
+ void 0;
2867
+ tag = create.element(newTagName);
2868
+ }
2869
+ else {
2870
+ tag = newTagName;
2871
+ }
2866
2872
  if (!notMoveContent) {
2867
2873
  while (elm.firstChild) {
2868
2874
  tag.appendChild(elm.firstChild);
@@ -4503,7 +4509,8 @@ function getContainer(jodit, classFunc, tag = 'div', createInsideEditor = false)
4503
4509
  const data = boxes.get(jodit) || {}, key = name + tag;
4504
4510
  const view = (0,jodit_core_helpers_checker_is_view_object__WEBPACK_IMPORTED_MODULE_6__/* .isViewObject */ .h)(jodit) ? jodit : jodit.j;
4505
4511
  if (!data[key]) {
4506
- let c = view.c, body = (0,jodit_core_helpers_checker_is_jodit_object__WEBPACK_IMPORTED_MODULE_7__/* .isJoditObject */ .y)(jodit) && jodit.o.shadowRoot
4512
+ let c = view.c;
4513
+ let body = (0,jodit_core_helpers_checker_is_jodit_object__WEBPACK_IMPORTED_MODULE_7__/* .isJoditObject */ .y)(jodit) && jodit.o.shadowRoot
4507
4514
  ? jodit.o.shadowRoot
4508
4515
  : jodit.od.body;
4509
4516
  if (createInsideEditor &&
@@ -4523,6 +4530,7 @@ function getContainer(jodit, classFunc, tag = 'div', createInsideEditor = false)
4523
4530
  body.appendChild(box);
4524
4531
  data[key] = box;
4525
4532
  jodit.hookStatus('beforeDestruct', () => {
4533
+ view.events.off(box);
4526
4534
  _dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.safeRemove(box);
4527
4535
  delete data[key];
4528
4536
  if (Object.keys(data).length) {
@@ -4530,6 +4538,7 @@ function getContainer(jodit, classFunc, tag = 'div', createInsideEditor = false)
4530
4538
  }
4531
4539
  });
4532
4540
  boxes.set(jodit, data);
4541
+ view.events.fire('getContainer', box);
4533
4542
  }
4534
4543
  data[key].classList.remove('jodit_theme_default', 'jodit_theme_dark');
4535
4544
  data[key].classList.add(`jodit_theme_${view.o.theme || 'default'}`);
@@ -6329,7 +6338,8 @@ function normalizeKeyAliases(keys) {
6329
6338
  ctrl: 2,
6330
6339
  control: 2,
6331
6340
  alt: 3,
6332
- shift: 4
6341
+ shift: 4,
6342
+ space: 5
6333
6343
  };
6334
6344
  return keys
6335
6345
  .replace(/\+\+/g, '+add')
@@ -13380,15 +13390,21 @@ let UITooltip = UITooltip_1 = class UITooltip extends jodit_core_ui_element__WEB
13380
13390
  if (!view.o.textIcons &&
13381
13391
  view.o.showTooltip &&
13382
13392
  !view.o.useNativeTooltip) {
13393
+ this.j.e.on('getContainer', (box) => {
13394
+ this.__onAttach(box);
13395
+ });
13383
13396
  view.hookStatus(jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .STATUSES */ .f.ready, () => {
13384
- // TODO Move it inside __show method. Now it is here because testcase failed with capturing
13385
- (0,jodit_core_global__WEBPACK_IMPORTED_MODULE_3__/* .getContainer */ .My)(this.j, UITooltip_1).appendChild(this.container);
13386
- view.e.on(view.container, 'mouseenter.tooltip', this.__onMouseEnter, {
13387
- capture: true
13388
- });
13397
+ this.__onAttach(this.j.container);
13389
13398
  });
13390
13399
  }
13391
13400
  }
13401
+ __onAttach(container) {
13402
+ // TODO Move it inside __show method. Now it is here because testcase failed with capturing
13403
+ (0,jodit_core_global__WEBPACK_IMPORTED_MODULE_3__/* .getContainer */ .My)(this.j, UITooltip_1).appendChild(this.container);
13404
+ this.j.e.on(container, 'mouseenter.tooltip', this.__onMouseEnter, {
13405
+ capture: true
13406
+ });
13407
+ }
13392
13408
  __addListenersOnEnter() {
13393
13409
  if (this.__listenClose) {
13394
13410
  return;
@@ -22460,46 +22476,39 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22460
22476
  removeRow(table, rowIndex) {
22461
22477
  return Table.__removeRow(table, rowIndex);
22462
22478
  }
22463
- static __appendColumn(table, j, after, create) {
22479
+ /**
22480
+ * Insert column before / after all the columns containing the selected cells
22481
+ */
22482
+ appendColumn(table, selectedCell, insertAfter = true) {
22464
22483
  const box = Table.__formalMatrix(table);
22465
- let i;
22466
- if (j === undefined || j < 0) {
22467
- j = Table.__getColumnsCount(table) - 1;
22468
- }
22469
- for (i = 0; i < box.length; i += 1) {
22470
- const cell = create.element('td');
22471
- const td = box[i][j];
22472
- let added = false;
22473
- if (after) {
22474
- if ((box[i] && td && j + 1 >= box[i].length) ||
22475
- td !== box[i][j + 1]) {
22476
- if (td.nextSibling) {
22477
- jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(td.nextSibling, cell);
22478
- }
22479
- else {
22480
- td.parentNode && td.parentNode.appendChild(cell);
22481
- }
22482
- added = true;
22484
+ if (!insertAfter && jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.isCell(selectedCell.previousElementSibling)) {
22485
+ return this.appendColumn(table, selectedCell.previousElementSibling, true);
22486
+ }
22487
+ const columnIndex = insertAfter
22488
+ ? selectedCell.cellIndex + ((selectedCell.colSpan || 1) - 1)
22489
+ : selectedCell.cellIndex;
22490
+ const newColumnIndex = insertAfter ? columnIndex + 1 : columnIndex;
22491
+ for (let i = 0; i < box.length;) {
22492
+ const cells = box[i];
22493
+ if (cells[columnIndex] !== cells[newColumnIndex] ||
22494
+ columnIndex === newColumnIndex) {
22495
+ const cell = this.j.createInside.element('td');
22496
+ if (insertAfter) {
22497
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.after(cells[columnIndex], cell);
22483
22498
  }
22484
- }
22485
- else {
22486
- if (j - 1 < 0 ||
22487
- (box[i][j] !== box[i][j - 1] && box[i][j].parentNode)) {
22488
- jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(box[i][j], cell);
22489
- added = true;
22499
+ else {
22500
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.before(cells[columnIndex], cell);
22501
+ }
22502
+ if (cells[columnIndex].rowSpan > 1) {
22503
+ cell.rowSpan = cells[columnIndex].rowSpan;
22490
22504
  }
22491
22505
  }
22492
- if (!added) {
22493
- (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);
22506
+ else {
22507
+ cells[columnIndex].colSpan += 1;
22494
22508
  }
22509
+ i += cells[columnIndex].rowSpan || 1;
22495
22510
  }
22496
22511
  }
22497
- /**
22498
- * Insert column before / after all the columns containing the selected cells
22499
- */
22500
- appendColumn(table, j, after) {
22501
- return Table.__appendColumn(table, j, after, this.j.createInside);
22502
- }
22503
22512
  static __removeColumn(table, j) {
22504
22513
  const box = Table.__formalMatrix(table);
22505
22514
  let dec;
@@ -22717,7 +22726,7 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22717
22726
  alreadyMerged.delete(first);
22718
22727
  Table.__unmark(__marked);
22719
22728
  Table.__normalizeTable(table);
22720
- (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.toArray)(table.rows).forEach((tr, index) => {
22729
+ (0,jodit_core_helpers___WEBPACK_IMPORTED_MODULE_5__.toArray)(table.rows).forEach(tr => {
22721
22730
  if (!tr.cells.length) {
22722
22731
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__/* .Dom */ .J.safeRemove(tr);
22723
22732
  }
@@ -22726,7 +22735,7 @@ class Table extends jodit_core_component__WEBPACK_IMPORTED_MODULE_0__/* .ViewCom
22726
22735
  }
22727
22736
  }
22728
22737
  /**
22729
- * It combines all of the selected cells into one. The contents of the cells will also be combined
22738
+ * It combines all the selected cells into one. The contents of the cells will also be combined
22730
22739
  */
22731
22740
  mergeSelected(table) {
22732
22741
  return Table.__mergeSelected(table, this.j);
@@ -25068,7 +25077,9 @@ class addNewLine extends jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Plugin {
25068
25077
  editor.e
25069
25078
  .off(editor.editor, '.' + ns)
25070
25079
  .off(editor.container, '.' + ns)
25080
+ .off('.' + ns)
25071
25081
  .on([editor.ow, editor.ew, editor.editor], 'scroll' + '.' + ns, this.__hideForce)
25082
+ .on('finishedCleanHTMLWorker' + '.' + ns, this.__hideForce)
25072
25083
  .on(editor.editor, 'click' + '.' + ns, this.__hide)
25073
25084
  .on(editor.container, 'mouseleave' + '.' + ns, this.__hide)
25074
25085
  .on(editor.editor, 'mousemove' + '.' + ns, this.__onMouseMove);
@@ -25156,7 +25167,8 @@ class addNewLine extends jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Plugin {
25156
25167
  jodit_modules__WEBPACK_IMPORTED_MODULE_3__.Dom.safeRemove(this.__line);
25157
25168
  this.j.e
25158
25169
  .off([this.j.ow, this.j.ew, this.j.editor], '.' + ns)
25159
- .off(this.j.container, '.' + ns);
25170
+ .off(this.j.container, '.' + ns)
25171
+ .off('.' + ns);
25160
25172
  }
25161
25173
  }
25162
25174
  (0,tslib__WEBPACK_IMPORTED_MODULE_5__/* .__decorate */ .Cg)([
@@ -27338,13 +27350,21 @@ function allowAttributes(jodit, nodeElm, hadEffect, allow) {
27338
27350
  */
27339
27351
 
27340
27352
 
27353
+ const TABLE_CONTAINER_TAGS = new Set([
27354
+ 'table',
27355
+ 'tbody',
27356
+ 'thead',
27357
+ 'tfoot',
27358
+ 'tr'
27359
+ ]);
27341
27360
  /**
27342
27361
  * @private
27343
27362
  */
27344
27363
  function fillEmptyParagraph(jodit, nodeElm, hadEffect) {
27345
27364
  if (jodit.o.cleanHTML.fillEmptyParagraph &&
27346
27365
  jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isBlock(nodeElm) &&
27347
- jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isEmpty(nodeElm, jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.INSEPARABLE_TAGS)) {
27366
+ jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isEmpty(nodeElm, jodit_core_constants__WEBPACK_IMPORTED_MODULE_0__.INSEPARABLE_TAGS) &&
27367
+ !jodit_core_dom_dom__WEBPACK_IMPORTED_MODULE_1__/* .Dom */ .J.isTag(nodeElm, TABLE_CONTAINER_TAGS)) {
27348
27368
  const br = jodit.createInside.element('br');
27349
27369
  nodeElm.appendChild(br);
27350
27370
  return true;
@@ -30563,7 +30583,8 @@ class hotkeys extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_3__/* .Plugin *
30563
30583
  constructor() {
30564
30584
  super(...arguments);
30565
30585
  this.onKeyPress = (event) => {
30566
- const special = this.specialKeys[event.which], character = (event.key || String.fromCharCode(event.which)).toLowerCase();
30586
+ const special = this.specialKeys[event.which];
30587
+ const character = (event.key || String.fromCharCode(event.which)).toLowerCase();
30567
30588
  const modif = [special || character];
30568
30589
  ['alt', 'ctrl', 'shift', 'meta'].forEach(specialKey => {
30569
30590
  if (event[specialKey + 'Key'] && special !== specialKey) {
@@ -30657,7 +30678,8 @@ class hotkeys extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_3__/* .Plugin *
30657
30678
  }
30658
30679
  })
30659
30680
  .on('keydown.hotkeys', (event) => {
30660
- const shortcut = this.onKeyPress(event), stop = {
30681
+ const shortcut = this.onKeyPress(event);
30682
+ const stop = {
30661
30683
  shouldStop: true
30662
30684
  };
30663
30685
  const resultOfFire = this.j.e.fire(shortcut + '.hotkey', event.type, stop);
@@ -38988,7 +39010,7 @@ class selectCells extends jodit_core_plugin__WEBPACK_IMPORTED_MODULE_5__/* .Plug
38988
39010
  break;
38989
39011
  case 'addcolumnafter':
38990
39012
  case 'addcolumnbefore':
38991
- this.__tableModule.appendColumn(table, cell.cellIndex, command === 'addcolumnafter');
39013
+ this.__tableModule.appendColumn(table, cell, command === 'addcolumnafter');
38992
39014
  break;
38993
39015
  case 'addrowafter':
38994
39016
  case 'addrowbefore':
@@ -42331,6 +42353,8 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__/* .Config */ .T.prototype.controls.tab
42331
42353
  }
42332
42354
  },
42333
42355
  popup: (editor, current, close, button) => {
42356
+ editor.editor.normalize();
42357
+ const snapshot = editor.history.snapshot.make();
42334
42358
  const control = button.control;
42335
42359
  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;
42336
42360
  const generateExtraClasses = () => {
@@ -42423,10 +42447,24 @@ jodit_config__WEBPACK_IMPORTED_MODULE_4__/* .Config */ .T.prototype.controls.tab
42423
42447
  table.classList.add(className);
42424
42448
  });
42425
42449
  });
42426
- if (editor.editor.firstChild) {
42427
- editor.s.insertNode(crt.text('\n'), false, false);
42450
+ editor.s.restore();
42451
+ editor.s.removeMarkers();
42452
+ editor.editor.normalize();
42453
+ editor.history.snapshot.restore(snapshot);
42454
+ 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);
42455
+ if (block && jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.isEmpty(block)) {
42456
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.replace(block, table, undefined, false, true);
42457
+ }
42458
+ else {
42459
+ if (block) {
42460
+ const fake = crt.text('\n');
42461
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.after(block, fake);
42462
+ jodit_core_dom__WEBPACK_IMPORTED_MODULE_0__/* .Dom */ .J.after(fake, table);
42463
+ }
42464
+ else {
42465
+ editor.s.insertNode(table, false);
42466
+ }
42428
42467
  }
42429
- editor.s.insertNode(table, false);
42430
42468
  if (first_td) {
42431
42469
  editor.s.setCursorIn(first_td);
42432
42470
  (0,jodit_core_helpers__WEBPACK_IMPORTED_MODULE_1__.scrollIntoViewIfNeeded)(first_td, editor.editor, editor.ed);