jodit 4.2.14 → 4.2.15

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 (79) hide show
  1. package/es2015/jodit.css +115 -115
  2. package/es2015/jodit.fat.min.css +1 -1
  3. package/es2015/jodit.fat.min.js +2 -2
  4. package/es2015/jodit.js +525 -444
  5. package/es2015/jodit.min.css +1 -1
  6. package/es2015/jodit.min.js +2 -2
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.css +115 -115
  13. package/es2018/jodit.fat.min.css +1 -1
  14. package/es2018/jodit.fat.min.js +2 -2
  15. package/es2018/jodit.js +525 -444
  16. package/es2018/jodit.min.css +1 -1
  17. package/es2018/jodit.min.js +2 -2
  18. package/es2018/plugins/debug/debug.js +1 -1
  19. package/es2018/plugins/debug/debug.min.js +1 -1
  20. package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
  21. package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
  22. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  23. package/es2021/jodit.css +115 -115
  24. package/es2021/jodit.fat.min.css +1 -1
  25. package/es2021/jodit.fat.min.js +2 -2
  26. package/es2021/jodit.js +519 -440
  27. package/es2021/jodit.min.css +1 -1
  28. package/es2021/jodit.min.js +2 -2
  29. package/es2021/plugins/debug/debug.js +1 -1
  30. package/es2021/plugins/debug/debug.min.js +1 -1
  31. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  32. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  33. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  34. package/es2021.en/jodit.css +115 -115
  35. package/es2021.en/jodit.fat.min.css +1 -1
  36. package/es2021.en/jodit.fat.min.js +2 -2
  37. package/es2021.en/jodit.js +519 -440
  38. package/es2021.en/jodit.min.css +1 -1
  39. package/es2021.en/jodit.min.js +2 -2
  40. package/es2021.en/plugins/debug/debug.js +1 -1
  41. package/es2021.en/plugins/debug/debug.min.js +1 -1
  42. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  43. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  44. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  45. package/es5/jodit.css +129 -129
  46. package/es5/jodit.fat.min.css +1 -1
  47. package/es5/jodit.fat.min.js +2 -2
  48. package/es5/jodit.js +542 -460
  49. package/es5/jodit.min.css +3 -3
  50. package/es5/jodit.min.js +2 -2
  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/esm/core/constants.js +1 -1
  57. package/esm/core/selection/helpers/index.d.ts +9 -3
  58. package/esm/core/selection/helpers/index.js +48 -0
  59. package/esm/core/selection/selection.d.ts +6 -1
  60. package/esm/core/selection/selection.js +95 -117
  61. package/esm/index.d.ts +6 -1
  62. package/esm/index.js +3 -2
  63. package/esm/modules/table/table.d.ts +3 -1
  64. package/esm/modules/table/table.js +38 -33
  65. package/esm/modules/uploader/helpers/send-files.js +33 -29
  66. package/esm/plugins/backspace/cases/check-remove-char.js +65 -55
  67. package/esm/plugins/drag-and-drop/drag-and-drop.d.ts +2 -0
  68. package/esm/plugins/drag-and-drop/drag-and-drop.js +43 -36
  69. package/esm/plugins/link/link.js +71 -64
  70. package/esm/plugins/search/helpers/highlight-text-ranges.d.ts +0 -4
  71. package/esm/plugins/search/helpers/highlight-text-ranges.js +58 -49
  72. package/esm/plugins/table-keyboard-navigation/table-keyboard-navigation.js +35 -29
  73. package/package.json +1 -1
  74. package/types/core/selection/helpers/index.d.ts +9 -3
  75. package/types/core/selection/selection.d.ts +6 -1
  76. package/types/index.d.ts +6 -1
  77. package/types/modules/table/table.d.ts +3 -1
  78. package/types/plugins/drag-and-drop/drag-and-drop.d.ts +2 -0
  79. package/types/plugins/search/helpers/highlight-text-ranges.d.ts +0 -4
@@ -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.14
4
+ * Version: v4.2.15
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.14
4
+ * Version: v4.2.15
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.14
4
+ * Version: v4.2.15
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.14
4
+ * Version: v4.2.15
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -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.14
4
+ * Version: v4.2.15
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -3,7 +3,7 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- export const APP_VERSION = "4.2.14";
6
+ export const APP_VERSION = "4.2.15";
7
7
  // prettier-ignore
8
8
  export const ES = "es2020";
9
9
  export const IS_ES_MODERN = true;
@@ -3,8 +3,14 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- /**
7
- * @module selection
8
- */
9
6
  export * from "./move-node-inside-start";
10
7
  export * from "./move-the-node-along-the-edge-outward";
8
+ /**
9
+ * Check if the cursor is at the edge of the string
10
+ * @private
11
+ */
12
+ export declare function cursorInTheEdgeOfString(container: Node, offset: number, start: boolean, end: boolean): boolean;
13
+ export declare function findCorrectCurrentNode(node: Node, range: Range, rightMode: boolean, isCollapsed: boolean, checkChild: boolean, child: (nd: Node) => Node | null): {
14
+ node: Node;
15
+ rightMode: boolean;
16
+ };
@@ -6,5 +6,53 @@
6
6
  /**
7
7
  * @module selection
8
8
  */
9
+ import { INVISIBLE_SPACE_REG_EXP_END as INV_END, INVISIBLE_SPACE_REG_EXP_START as INV_START } from "../../constants.js";
10
+ import { Dom } from "../../dom/dom.js";
9
11
  export * from "./move-node-inside-start.js";
10
12
  export * from "./move-the-node-along-the-edge-outward.js";
13
+ /**
14
+ * Check if the cursor is at the edge of the string
15
+ * @private
16
+ */
17
+ export function cursorInTheEdgeOfString(container, offset, start, end) {
18
+ const text = container.nodeValue?.length ? container.nodeValue : '';
19
+ if (end && text.replace(INV_END(), '').length > offset) {
20
+ return true;
21
+ }
22
+ const inv = INV_START().exec(text);
23
+ return start && ((inv && inv[0].length < offset) || (!inv && offset > 0));
24
+ }
25
+ export function findCorrectCurrentNode(node, range, rightMode, isCollapsed, checkChild, child) {
26
+ node = range.startContainer.childNodes[range.startOffset];
27
+ if (!node) {
28
+ node = range.startContainer.childNodes[range.startOffset - 1];
29
+ rightMode = true;
30
+ }
31
+ if (node && isCollapsed && !Dom.isText(node)) {
32
+ // test Current method - Cursor in the left of some SPAN
33
+ if (!rightMode && Dom.isText(node.previousSibling)) {
34
+ node = node.previousSibling;
35
+ }
36
+ else if (checkChild) {
37
+ let current = child(node);
38
+ while (current) {
39
+ if (current && Dom.isText(current)) {
40
+ node = current;
41
+ break;
42
+ }
43
+ current = child(current);
44
+ }
45
+ }
46
+ }
47
+ if (node && !isCollapsed && !Dom.isText(node)) {
48
+ let leftChild = node, rightChild = node;
49
+ do {
50
+ leftChild = leftChild.firstChild;
51
+ rightChild = rightChild.lastChild;
52
+ } while (leftChild && rightChild && !Dom.isText(leftChild));
53
+ if (leftChild === rightChild && leftChild && Dom.isText(leftChild)) {
54
+ node = leftChild;
55
+ }
56
+ }
57
+ return { node, rightMode };
58
+ }
@@ -125,10 +125,11 @@ export declare class Selection implements ISelect {
125
125
  /**
126
126
  * Returns the current element under the cursor inside editor
127
127
  */
128
- current(checkChild?: boolean): null | Node;
128
+ current(checkChild?: boolean): Nullable<Node>;
129
129
  /**
130
130
  * Insert element in editor
131
131
  *
132
+ * @param node - Node for insert
132
133
  * @param insertCursorAfter - After insert, cursor will move after element
133
134
  * @param fireChange - After insert, editor fire change event. You can prevent this behavior
134
135
  */
@@ -137,6 +138,7 @@ export declare class Selection implements ISelect {
137
138
  * Inserts in the current cursor position some HTML snippet
138
139
  *
139
140
  * @param html - HTML The text to be inserted into the document
141
+ * @param insertCursorAfter - After insert, cursor will move after element
140
142
  * @example
141
143
  * ```javascript
142
144
  * parent.s.insertHTML('<img src="image.png"/>');
@@ -148,6 +150,7 @@ export declare class Selection implements ISelect {
148
150
  *
149
151
  * @param url - URL for image, or HTMLImageElement
150
152
  * @param styles - If specified, it will be applied <code>$(image).css(styles)</code>
153
+ * @param defaultWidth - If specified, it will be applied <code>css('width', defaultWidth)</code>
151
154
  */
152
155
  insertImage(url: string | HTMLImageElement, styles?: Nullable<IDictionary<string>>, defaultWidth?: Nullable<number | string>): void;
153
156
  /**
@@ -188,6 +191,7 @@ export declare class Selection implements ISelect {
188
191
  private setCursorNearWith;
189
192
  /**
190
193
  * Set cursor in the node
194
+ * @param node - Node element
191
195
  * @param inStart - set cursor in start of element
192
196
  */
193
197
  setCursorIn(node: Node, inStart?: boolean): Node;
@@ -197,6 +201,7 @@ export declare class Selection implements ISelect {
197
201
  selectRange(range: Range, focus?: boolean): this;
198
202
  /**
199
203
  * Select node
204
+ * @param node - Node element
200
205
  * @param inward - select all inside
201
206
  */
202
207
  select(node: Node | HTMLElement | HTMLTableElement | HTMLTableCellElement, inward?: boolean): this;
@@ -14,7 +14,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
14
14
  return c > 3 && r && Object.defineProperty(target, key, r), r;
15
15
  };
16
16
  import * as consts from "../constants.js";
17
- import { INSEPARABLE_TAGS, INVISIBLE_SPACE, INVISIBLE_SPACE_REG_EXP_END as INV_END, INVISIBLE_SPACE_REG_EXP_START as INV_START, IS_PROD } from "../constants.js";
17
+ import { INSEPARABLE_TAGS, INVISIBLE_SPACE, IS_PROD } from "../constants.js";
18
18
  import { autobind } from "../decorators/index.js";
19
19
  import { Dom } from "../dom/dom.js";
20
20
  import { $$, attr, call, css, error, getScrollParent, scrollIntoViewIfNeeded, size, toArray } from "../helpers/index.js";
@@ -23,6 +23,7 @@ import { assert } from "../helpers/utils/assert.js";
23
23
  import { moveTheNodeAlongTheEdgeOutward } from "./helpers/move-the-node-along-the-edge-outward.js";
24
24
  import "./interface.js";
25
25
  import { CommitStyle } from "./style/commit-style.js";
26
+ import { cursorInTheEdgeOfString, findCorrectCurrentNode } from "./helpers/index.js";
26
27
  export class Selection {
27
28
  constructor(jodit) {
28
29
  this.jodit = jodit;
@@ -405,63 +406,35 @@ export class Selection {
405
406
  * Returns the current element under the cursor inside editor
406
407
  */
407
408
  current(checkChild = true) {
408
- if (this.j.getRealMode() === consts.MODE_WYSIWYG) {
409
- const sel = this.sel;
410
- if (!sel || sel.rangeCount === 0) {
411
- return null;
412
- }
413
- const range = sel.getRangeAt(0);
414
- let node = range.startContainer, rightMode = false;
415
- const child = (nd) => rightMode ? nd.lastChild : nd.firstChild;
416
- if (Dom.isTag(node, 'br') && sel.isCollapsed) {
417
- return node;
418
- }
419
- if (!Dom.isText(node)) {
420
- node = range.startContainer.childNodes[range.startOffset];
421
- if (!node) {
422
- node =
423
- range.startContainer.childNodes[range.startOffset - 1];
424
- rightMode = true;
425
- }
426
- if (node && sel.isCollapsed && !Dom.isText(node)) {
427
- // test Current method - Cursor in the left of some SPAN
428
- if (!rightMode && Dom.isText(node.previousSibling)) {
429
- node = node.previousSibling;
430
- }
431
- else if (checkChild) {
432
- let current = child(node);
433
- while (current) {
434
- if (current && Dom.isText(current)) {
435
- node = current;
436
- break;
437
- }
438
- current = child(current);
439
- }
440
- }
441
- }
442
- if (node && !sel.isCollapsed && !Dom.isText(node)) {
443
- let leftChild = node, rightChild = node;
444
- do {
445
- leftChild = leftChild.firstChild;
446
- rightChild = rightChild.lastChild;
447
- } while (leftChild && rightChild && !Dom.isText(leftChild));
448
- if (leftChild === rightChild &&
449
- leftChild &&
450
- Dom.isText(leftChild)) {
451
- node = leftChild;
452
- }
453
- }
454
- }
455
- // check - cursor inside editor
456
- if (node && Dom.isOrContains(this.area, node)) {
457
- return node;
458
- }
409
+ if (this.j.getRealMode() !== consts.MODE_WYSIWYG) {
410
+ return null;
411
+ }
412
+ const sel = this.sel;
413
+ if (!sel || sel.rangeCount === 0) {
414
+ return null;
415
+ }
416
+ const range = sel.getRangeAt(0);
417
+ let node = range.startContainer;
418
+ let rightMode = false;
419
+ const child = (nd) => rightMode ? nd.lastChild : nd.firstChild;
420
+ if (Dom.isTag(node, 'br') && sel.isCollapsed) {
421
+ return node;
422
+ }
423
+ if (!Dom.isText(node)) {
424
+ const ret = findCorrectCurrentNode(node, range, rightMode, sel.isCollapsed, checkChild, child);
425
+ node = ret.node;
426
+ rightMode = ret.rightMode;
427
+ }
428
+ // check - cursor inside editor
429
+ if (node && Dom.isOrContains(this.area, node)) {
430
+ return node;
459
431
  }
460
432
  return null;
461
433
  }
462
434
  /**
463
435
  * Insert element in editor
464
436
  *
437
+ * @param node - Node for insert
465
438
  * @param insertCursorAfter - After insert, cursor will move after element
466
439
  * @param fireChange - After insert, editor fire change event. You can prevent this behavior
467
440
  */
@@ -523,6 +496,7 @@ export class Selection {
523
496
  * Inserts in the current cursor position some HTML snippet
524
497
  *
525
498
  * @param html - HTML The text to be inserted into the document
499
+ * @param insertCursorAfter - After insert, cursor will move after element
526
500
  * @example
527
501
  * ```javascript
528
502
  * parent.s.insertHTML('<img src="image.png"/>');
@@ -566,6 +540,7 @@ export class Selection {
566
540
  *
567
541
  * @param url - URL for image, or HTMLImageElement
568
542
  * @param styles - If specified, it will be applied <code>$(image).css(styles)</code>
543
+ * @param defaultWidth - If specified, it will be applied <code>css('width', defaultWidth)</code>
569
544
  */
570
545
  insertImage(url, styles = null, defaultWidth = null) {
571
546
  const image = isString(url) ? this.j.createInside.element('img') : url;
@@ -620,74 +595,81 @@ export class Selection {
620
595
  */
621
596
  eachSelection(callback) {
622
597
  const sel = this.sel;
623
- if (sel && sel.rangeCount) {
624
- const range = sel.getRangeAt(0);
625
- let root = range.commonAncestorContainer;
626
- if (!Dom.isHTMLElement(root)) {
627
- root = root.parentElement;
628
- }
629
- const nodes = [], startOffset = range.startOffset, length = root.childNodes.length, elementOffset = startOffset < length ? startOffset : length - 1;
630
- let start = range.startContainer === this.area
631
- ? root.childNodes[elementOffset]
632
- : range.startContainer, end = range.endContainer === this.area
633
- ? root.childNodes[range.endOffset - 1]
634
- : range.endContainer;
635
- if (Dom.isText(start) &&
636
- start === range.startContainer &&
637
- range.startOffset === start.nodeValue?.length &&
638
- start.nextSibling) {
639
- start = start.nextSibling;
598
+ if (!sel || !sel.rangeCount) {
599
+ return;
600
+ }
601
+ const range = sel.getRangeAt(0);
602
+ let root = range.commonAncestorContainer;
603
+ if (!Dom.isHTMLElement(root)) {
604
+ root = root.parentElement;
605
+ }
606
+ const nodes = [];
607
+ const startOffset = range.startOffset;
608
+ const length = root.childNodes.length;
609
+ const elementOffset = startOffset < length ? startOffset : length - 1;
610
+ let start = range.startContainer === this.area
611
+ ? root.childNodes[elementOffset]
612
+ : range.startContainer;
613
+ let end = range.endContainer === this.area
614
+ ? root.childNodes[range.endOffset - 1]
615
+ : range.endContainer;
616
+ if (Dom.isText(start) &&
617
+ start === range.startContainer &&
618
+ range.startOffset === start.nodeValue?.length &&
619
+ start.nextSibling) {
620
+ start = start.nextSibling;
621
+ }
622
+ if (Dom.isText(end) &&
623
+ end === range.endContainer &&
624
+ range.endOffset === 0 &&
625
+ end.previousSibling) {
626
+ end = end.previousSibling;
627
+ }
628
+ const checkElm = (node) => {
629
+ if (node &&
630
+ node !== root &&
631
+ !Dom.isEmptyTextNode(node) &&
632
+ !isMarker(node)) {
633
+ nodes.push(node);
640
634
  }
641
- if (Dom.isText(end) &&
642
- end === range.endContainer &&
643
- range.endOffset === 0 &&
644
- end.previousSibling) {
645
- end = end.previousSibling;
635
+ };
636
+ checkElm(start);
637
+ if (start !== end && Dom.isOrContains(root, start, true)) {
638
+ Dom.find(start, node => {
639
+ checkElm(node);
640
+ // checks parentElement as well because partial selections are not equal to entire element
641
+ return (node === end ||
642
+ (node && node.contains && node.contains(end)));
643
+ }, root, true, false);
644
+ }
645
+ const forEvery = (current) => {
646
+ if (!Dom.isOrContains(this.j.editor, current, true)) {
647
+ return;
646
648
  }
647
- const checkElm = (node) => {
648
- if (node &&
649
- node !== root &&
650
- !Dom.isEmptyTextNode(node) &&
651
- !isMarker(node)) {
652
- nodes.push(node);
653
- }
654
- };
655
- checkElm(start);
656
- if (start !== end && Dom.isOrContains(root, start, true)) {
657
- Dom.find(start, node => {
658
- checkElm(node);
659
- // checks parentElement as well because partial selections are not equal to entire element
660
- return (node === end ||
661
- (node && node.contains && node.contains(end)));
662
- }, root, true, false);
649
+ if (current.nodeName.match(/^(UL|OL)$/)) {
650
+ return toArray(current.childNodes).forEach(forEvery);
663
651
  }
664
- const forEvery = (current) => {
665
- if (!Dom.isOrContains(this.j.editor, current, true)) {
666
- return;
667
- }
668
- if (current.nodeName.match(/^(UL|OL)$/)) {
669
- return toArray(current.childNodes).forEach(forEvery);
652
+ if (Dom.isTag(current, 'li')) {
653
+ if (current.firstChild) {
654
+ current = current.firstChild;
670
655
  }
671
- if (Dom.isTag(current, 'li')) {
672
- if (current.firstChild) {
673
- current = current.firstChild;
674
- }
675
- else {
676
- const currentB = this.j.createInside.text(INVISIBLE_SPACE);
677
- current.appendChild(currentB);
678
- current = currentB;
679
- }
656
+ else {
657
+ const currentB = this.j.createInside.text(INVISIBLE_SPACE);
658
+ current.appendChild(currentB);
659
+ current = currentB;
680
660
  }
681
- callback(current);
682
- };
683
- if (nodes.length === 0 && Dom.isEmptyTextNode(start)) {
661
+ }
662
+ callback(current);
663
+ };
664
+ if (nodes.length === 0) {
665
+ if (Dom.isEmptyTextNode(start)) {
684
666
  nodes.push(start);
685
667
  }
686
- if (nodes.length === 0 && start.firstChild) {
668
+ if (start.firstChild) {
687
669
  nodes.push(start.firstChild);
688
670
  }
689
- nodes.forEach(forEvery);
690
671
  }
672
+ nodes.forEach(forEvery);
691
673
  }
692
674
  /**
693
675
  * Checks if the cursor is at the end(start) block
@@ -714,13 +696,7 @@ export class Selection {
714
696
  this.j.e.fire('isInvisibleForCursor', elm) === true));
715
697
  // check right offset
716
698
  if (Dom.isText(container)) {
717
- const text = container.nodeValue?.length ? container.nodeValue : '';
718
- if (end && text.replace(INV_END(), '').length > offset) {
719
- return false;
720
- }
721
- const inv = INV_START().exec(text);
722
- if (start &&
723
- ((inv && inv[0].length < offset) || (!inv && offset > 0))) {
699
+ if (cursorInTheEdgeOfString(container, offset, start, end)) {
724
700
  return false;
725
701
  }
726
702
  }
@@ -808,6 +784,7 @@ export class Selection {
808
784
  }
809
785
  /**
810
786
  * Set cursor in the node
787
+ * @param node - Node element
811
788
  * @param inStart - set cursor in start of element
812
789
  */
813
790
  setCursorIn(node, inStart = false) {
@@ -868,6 +845,7 @@ export class Selection {
868
845
  }
869
846
  /**
870
847
  * Select node
848
+ * @param node - Node element
871
849
  * @param inward - select all inside
872
850
  */
873
851
  select(node, inward = false) {
package/esm/index.d.ts CHANGED
@@ -3,8 +3,13 @@
3
3
  * Released under MIT see LICENSE.txt in the project root for license information.
4
4
  * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
5
5
  */
6
- import "./plugins/index";
6
+ /**
7
+ * [[include:README.md]]
8
+ * @packageDocumentation
9
+ * @module jodit
10
+ */
7
11
  import { Jodit as DefaultJodit } from "./jodit";
12
+ import "./plugins/index";
8
13
 
9
14
 
10
15
  export { DefaultJodit as Jodit };
package/esm/index.js CHANGED
@@ -8,14 +8,15 @@
8
8
  * @packageDocumentation
9
9
  * @module jodit
10
10
  */
11
+ // eslint-disable-next-line simple-import-sort/imports
12
+ import { Jodit as DefaultJodit } from "./jodit.js";
11
13
  import { isFunction, isString } from "./core/helpers/checker/index.js";
12
- import "./plugins/index.js";
13
14
  import * as constants from "./core/constants.js";
14
15
  import * as decorators from "./core/decorators/index.js";
15
16
  import * as Modules from "./modules/index.js";
16
17
  import * as Icons from "./styles/icons/index.js";
17
- import { Jodit as DefaultJodit } from "./jodit.js";
18
18
  import Languages from "./languages.js";
19
+ import "./plugins/index.js";
19
20
  // copy constants in Jodit
20
21
  Object.keys(constants).forEach((key) => {
21
22
  DefaultJodit[key] = constants[key];
@@ -38,6 +38,7 @@ export declare class Table extends ViewComponent<IJodit> {
38
38
  private static __formalMatrix;
39
39
  /**
40
40
  * Generate formal table martix columns*rows
41
+ * @param table - Working table
41
42
  * @param callback - if return false cycle break
42
43
  */
43
44
  formalMatrix(table: HTMLTableElement, callback?: (cell: HTMLTableCellElement, row: number, col: number, colSpan: number, rowSpan: number) => false | void): HTMLTableCellElement[][];
@@ -54,7 +55,6 @@ export declare class Table extends ViewComponent<IJodit> {
54
55
  * @param line - Insert a new line after/before this
55
56
  * line contains the selected cell
56
57
  * @param after - Insert a new line after line contains the selected cell
57
- * @param create - Instance of Create class
58
58
  */
59
59
  appendRow(table: HTMLTableElement, line: false | HTMLTableRowElement, after: boolean): void;
60
60
  private static __removeRow;
@@ -78,6 +78,8 @@ export declare class Table extends ViewComponent<IJodit> {
78
78
  */
79
79
  getSelectedBound(table: HTMLTableElement, selectedCells: HTMLTableCellElement[]): number[][];
80
80
  private static __normalizeTable;
81
+ private static __removeExtraColspans;
82
+ private static __removeExtraRowspans;
81
83
  /**
82
84
  * Try recalculate all coluns and rows after change
83
85
  */
@@ -137,6 +137,7 @@ export class Table extends ViewComponent {
137
137
  }
138
138
  /**
139
139
  * Generate formal table martix columns*rows
140
+ * @param table - Working table
140
141
  * @param callback - if return false cycle break
141
142
  */
142
143
  formalMatrix(table, callback) {
@@ -205,7 +206,6 @@ export class Table extends ViewComponent {
205
206
  * @param line - Insert a new line after/before this
206
207
  * line contains the selected cell
207
208
  * @param after - Insert a new line after line contains the selected cell
208
- * @param create - Instance of Create class
209
209
  */
210
210
  appendRow(table, line, after) {
211
211
  return Table.__appendRow(table, line, after, this.j.createInside);
@@ -374,13 +374,36 @@ export class Table extends ViewComponent {
374
374
  return Table.__getSelectedBound(table, selectedCells);
375
375
  }
376
376
  static __normalizeTable(table) {
377
- let i, j, min, not;
378
377
  const __marked = [], box = Table.__formalMatrix(table);
379
- // remove extra colspans
380
- for (j = 0; j < box[0].length; j += 1) {
381
- min = 1000000;
382
- not = false;
383
- for (i = 0; i < box.length; i += 1) {
378
+ Table.__removeExtraColspans(box, __marked);
379
+ Table.__removeExtraRowspans(box, __marked);
380
+ // remove rowspans and colspans equal 1 and empty class
381
+ for (let i = 0; i < box.length; i += 1) {
382
+ for (let j = 0; j < box[i].length; j += 1) {
383
+ if (box[i][j] === undefined) {
384
+ continue; // broken table
385
+ }
386
+ if (box[i][j].hasAttribute('rowspan') &&
387
+ box[i][j].rowSpan === 1) {
388
+ attr(box[i][j], 'rowspan', null);
389
+ }
390
+ if (box[i][j].hasAttribute('colspan') &&
391
+ box[i][j].colSpan === 1) {
392
+ attr(box[i][j], 'colspan', null);
393
+ }
394
+ if (box[i][j].hasAttribute('class') &&
395
+ !attr(box[i][j], 'class')) {
396
+ attr(box[i][j], 'class', null);
397
+ }
398
+ }
399
+ }
400
+ Table.__unmark(__marked);
401
+ }
402
+ static __removeExtraColspans(box, __marked) {
403
+ for (let j = 0; j < box[0].length; j += 1) {
404
+ let min = 1000000;
405
+ let not = false;
406
+ for (let i = 0; i < box.length; i += 1) {
384
407
  if (box[i][j] === undefined) {
385
408
  continue; // broken table
386
409
  }
@@ -391,7 +414,7 @@ export class Table extends ViewComponent {
391
414
  min = Math.min(min, box[i][j].colSpan);
392
415
  }
393
416
  if (!not) {
394
- for (i = 0; i < box.length; i += 1) {
417
+ for (let i = 0; i < box.length; i += 1) {
395
418
  if (box[i][j] === undefined) {
396
419
  continue; // broken table
397
420
  }
@@ -399,10 +422,13 @@ export class Table extends ViewComponent {
399
422
  }
400
423
  }
401
424
  }
402
- // remove extra rowspans
425
+ }
426
+ static __removeExtraRowspans(box, marked) {
427
+ let i = 0;
428
+ let j = 0;
403
429
  for (i = 0; i < box.length; i += 1) {
404
- min = 1000000;
405
- not = false;
430
+ let min = 1000000;
431
+ let not = false;
406
432
  for (j = 0; j < box[i].length; j += 1) {
407
433
  if (box[i][j] === undefined) {
408
434
  continue; // broken table
@@ -418,31 +444,10 @@ export class Table extends ViewComponent {
418
444
  if (box[i][j] === undefined) {
419
445
  continue; // broken table
420
446
  }
421
- Table.__mark(box[i][j], 'rowspan', box[i][j].rowSpan - min + 1, __marked);
422
- }
423
- }
424
- }
425
- // remove rowspans and colspans equal 1 and empty class
426
- for (i = 0; i < box.length; i += 1) {
427
- for (j = 0; j < box[i].length; j += 1) {
428
- if (box[i][j] === undefined) {
429
- continue; // broken table
430
- }
431
- if (box[i][j].hasAttribute('rowspan') &&
432
- box[i][j].rowSpan === 1) {
433
- attr(box[i][j], 'rowspan', null);
434
- }
435
- if (box[i][j].hasAttribute('colspan') &&
436
- box[i][j].colSpan === 1) {
437
- attr(box[i][j], 'colspan', null);
438
- }
439
- if (box[i][j].hasAttribute('class') &&
440
- !attr(box[i][j], 'class')) {
441
- attr(box[i][j], 'class', null);
447
+ Table.__mark(box[i][j], 'rowspan', box[i][j].rowSpan - min + 1, marked);
442
448
  }
443
449
  }
444
450
  }
445
- Table.__unmark(__marked);
446
451
  }
447
452
  /**
448
453
  * Try recalculate all coluns and rows after change