@syncfusion/ej2-richtexteditor 22.1.39 → 22.2.9

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.
@@ -10257,7 +10257,7 @@ const CLEAR_TYPE = 'clear-type';
10257
10257
  *
10258
10258
  * @hidden
10259
10259
  */
10260
- const SELF_CLOSING_TAGS = ['area', 'base', 'br', 'embed', 'hr', 'img', 'input', 'param', 'source', 'track', 'wbr', 'iframe', 'td'];
10260
+ const SELF_CLOSING_TAGS = ['area', 'base', 'br', 'embed', 'hr', 'img', 'input', 'param', 'source', 'track', 'wbr', 'iframe', 'td', 'table'];
10261
10261
 
10262
10262
  /**
10263
10263
  * `Selection` module is used to handle RTE Selections.
@@ -13031,6 +13031,14 @@ class InsertHtml {
13031
13031
  nodeSelection.setSelectionText(docElement, range.startContainer.children[0], range.startContainer.children[0], 0, 0);
13032
13032
  range = nodeSelection.getRange(docElement);
13033
13033
  }
13034
+ if (range.startContainer === editNode && range.startContainer === range.endContainer && range.startOffset === 0 &&
13035
+ range.startOffset === range.endOffset && editNode.textContent.trim().length > 0) {
13036
+ const focusNode = this.findFirstTextNode(range.startContainer);
13037
+ if (!isNullOrUndefined(focusNode)) {
13038
+ nodeSelection.setSelectionText(docElement, focusNode, focusNode, 0, 0);
13039
+ range = nodeSelection.getRange(docElement);
13040
+ }
13041
+ }
13034
13042
  if (range.startContainer.nodeName === 'BR' && range.startOffset === 0 && range.startOffset === range.endOffset &&
13035
13043
  range.startContainer === range.endContainer) {
13036
13044
  const currentIndex = Array.prototype.slice.call(range.startContainer.parentElement.childNodes).indexOf(range.startContainer);
@@ -13158,6 +13166,18 @@ class InsertHtml {
13158
13166
  }
13159
13167
  }
13160
13168
  }
13169
+ static findFirstTextNode(node) {
13170
+ if (node.nodeType === Node.TEXT_NODE) {
13171
+ return node;
13172
+ }
13173
+ for (let i = 0; i < node.childNodes.length; i++) {
13174
+ const textNode = this.findFirstTextNode(node.childNodes[i]);
13175
+ if (!isNullOrUndefined(textNode)) {
13176
+ return textNode;
13177
+ }
13178
+ }
13179
+ return null;
13180
+ }
13161
13181
  static pasteInsertHTML(nodes, node, range, nodeSelection, nodeCutter, docElement, isCollapsed, closestParentNode, editNode, enterAction) {
13162
13182
  const isCursor = range.startOffset === range.endOffset &&
13163
13183
  range.startContainer === range.endContainer;
@@ -18143,7 +18163,11 @@ class MsWordPaste {
18143
18163
  else {
18144
18164
  //Add to support separate list which looks like same list and also to add all tags as it is inside list
18145
18165
  if (firstChild.childNodes.length > 0) {
18146
- const listOrder = firstChild.querySelector('span[style="mso-list:Ignore"]');
18166
+ let listIgnoreTag = firstChild.querySelectorAll('[style*="mso-list"]');
18167
+ for (let i = 0; i < listIgnoreTag.length; i++) {
18168
+ listIgnoreTag[i].setAttribute('style', listIgnoreTag[i].getAttribute('style').replace(/\n/g, ""));
18169
+ }
18170
+ let listOrder = firstChild.querySelector('span[style="mso-list:Ignore"]');
18147
18171
  if (!isNullOrUndefined(listOrder)) {
18148
18172
  this.listContents.push(listOrder.textContent.trim());
18149
18173
  detach(listOrder);
@@ -20223,8 +20247,9 @@ class HtmlEditor {
20223
20247
  currentRange.startContainer.parentElement.tagName !== 'TD' && currentRange.startContainer.parentElement.tagName !== 'TH' &&
20224
20248
  isPreviousNotContentEditable) {
20225
20249
  const checkNode = currentRange.startContainer.nodeName === '#text' ? currentRange.startContainer.parentElement : currentRange.startContainer;
20226
- if (!this.parent.formatter.editorManager.domNode.isBlockNode(checkNode) &&
20227
- !isNullOrUndefined(checkNode.previousSibling) && checkNode.previousSibling.nodeName === 'BR') {
20250
+ if ((!this.parent.formatter.editorManager.domNode.isBlockNode(checkNode) &&
20251
+ !isNullOrUndefined(checkNode.previousSibling) && checkNode.previousSibling.nodeName === 'BR') ||
20252
+ (!isNullOrUndefined(currentRange.startContainer.previousSibling) && currentRange.startContainer.previousSibling.nodeName === 'BR')) {
20228
20253
  return;
20229
20254
  }
20230
20255
  this.rangeElement = this.getRootBlockNode(currentRange.startContainer);
@@ -21430,6 +21455,7 @@ class PasteCleanup {
21430
21455
  }
21431
21456
  this.parent.trigger(afterPasteCleanup, { value: clipBoardElem.innerHTML, filesData: filesData }, (updatedArgs) => { value = updatedArgs.value; });
21432
21457
  clipBoardElem.innerHTML = value;
21458
+ clipBoardElem = this.addTableClass(clipBoardElem);
21433
21459
  this.parent.formatter.editorManager.execCommand('inserthtml', 'pasteCleanup', args, (returnArgs) => {
21434
21460
  extend(args, { elements: returnArgs.elements, imageElements: returnArgs.imgElem }, true);
21435
21461
  this.parent.formatter.onSuccess(this.parent, args);
@@ -21442,6 +21468,15 @@ class PasteCleanup {
21442
21468
  }
21443
21469
  }
21444
21470
  }
21471
+ addTableClass(element) {
21472
+ const tableElement = element.querySelectorAll('table');
21473
+ for (let i = 0; i < tableElement.length; i++) {
21474
+ if (!tableElement[i].classList.contains('e-rte-table')) {
21475
+ tableElement[i].classList.add('e-rte-table');
21476
+ }
21477
+ }
21478
+ return element;
21479
+ }
21445
21480
  setImageProperties(allImg) {
21446
21481
  if (this.parent.insertImageSettings.width !== 'auto') {
21447
21482
  allImg.setAttribute('width', this.parent.insertImageSettings.width);
@@ -29646,7 +29681,13 @@ class Table {
29646
29681
  if (this.resizeBtnStat.column) {
29647
29682
  const width = parseFloat(this.columnEle.offsetWidth.toString());
29648
29683
  const cellRow = this.curTable.rows[0].cells[0].nodeName === 'TH' ? 1 : 0;
29649
- const currentTableWidth = parseFloat(this.curTable.style.width.split('%')[0]);
29684
+ let currentTableWidth;
29685
+ if (this.curTable.style.width != '') {
29686
+ currentTableWidth = parseFloat(this.curTable.style.width.split('%')[0]);
29687
+ }
29688
+ else {
29689
+ currentTableWidth = this.getCurrentTableWidth(this.curTable.offsetWidth, this.parent.inputElement.offsetWidth);
29690
+ }
29650
29691
  const currentColumnCellWidth = parseFloat(this.curTable.rows[cellRow].cells[this.colIndex >= this.curTable.rows[cellRow].cells.length ? this.curTable.rows[cellRow].cells.length - 1 : this.colIndex].style.width.split('%')[0]);
29651
29692
  if (this.currentColumnResize === 'first') {
29652
29693
  mouseX = mouseX - 0.75; //This was done for to make the gripper and the table first/last column will be close.
@@ -29801,6 +29842,11 @@ class Table {
29801
29842
  }
29802
29843
  });
29803
29844
  }
29845
+ getCurrentTableWidth(tableWidth, parentWidth) {
29846
+ let currentTableWidth = 0;
29847
+ currentTableWidth = tableWidth / parentWidth * 100;
29848
+ return currentTableWidth;
29849
+ }
29804
29850
  findFirstLastColCells(table, isFirst) {
29805
29851
  const resultColumns = [];
29806
29852
  const rows = table.querySelectorAll('tr');
@@ -32946,9 +32992,10 @@ let RichTextEditor = class RichTextEditor extends Component {
32946
32992
  if (!initial) {
32947
32993
  if (this.readonly && this.enabled) {
32948
32994
  this.unbindEvents();
32995
+ this.unWireEvents();
32949
32996
  }
32950
32997
  else if (this.enabled) {
32951
- this.bindEvents();
32998
+ this.wireEvents();
32952
32999
  }
32953
33000
  }
32954
33001
  }