@syncfusion/ej2-richtexteditor 21.2.5 → 21.2.8

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.
@@ -14858,7 +14858,7 @@ class TableCommand {
14858
14858
  const colIndex = Array.prototype.indexOf.call(selectedCell.parentNode.childNodes, selectedCell);
14859
14859
  this.curTable = closest(selectedCell, 'table');
14860
14860
  let currentRow;
14861
- let allCells = this.getCorrespondingColumns();
14861
+ const allCells = this.getCorrespondingColumns();
14862
14862
  const minMaxIndex = this.getSelectedCellMinMaxIndex(allCells);
14863
14863
  let maxI;
14864
14864
  let j;
@@ -14876,10 +14876,13 @@ class TableCommand {
14876
14876
  /* eslint-disable */
14877
14877
  if (1 === rowSpanVal) {
14878
14878
  allCells[maxI][j].removeAttribute('rowspan');
14879
- const cell = allCells[maxI][j].cloneNode(true);
14880
- allCells = this.getCorrespondingColumns();
14881
- if (allCells[rowSpanVal][j] && allCells[rowSpanVal][j].parentElement) {
14882
- allCells[rowSpanVal][j].parentElement.insertBefore(cell, allCells[rowSpanVal][j]);
14879
+ const cell = this.getMergedRow(this.getCorrespondingColumns())[j];
14880
+ if (cell) {
14881
+ const cloneNode = cell.cloneNode(true);
14882
+ cloneNode.innerHTML = '<br>';
14883
+ if (cell.parentElement) {
14884
+ cell.parentElement.insertBefore(cloneNode, cell);
14885
+ }
14883
14886
  }
14884
14887
  }
14885
14888
  else {
@@ -14929,6 +14932,15 @@ class TableCommand {
14929
14932
  });
14930
14933
  }
14931
14934
  }
14935
+ getMergedRow(cells) {
14936
+ let mergedRow;
14937
+ for (let i = 0; i < cells.length; i++) {
14938
+ if (cells[i].length !== this.curTable.rows[0].childNodes.length) {
14939
+ mergedRow = cells[i];
14940
+ }
14941
+ }
14942
+ return mergedRow;
14943
+ }
14932
14944
  removeTable(e) {
14933
14945
  let selectedCell = e.item.selection.range.startContainer;
14934
14946
  selectedCell = (selectedCell.nodeType === 3) ? selectedCell.parentNode : selectedCell;
@@ -15570,9 +15582,12 @@ class IsFormatted {
15570
15582
  const validTags = ['u'];
15571
15583
  if (validTags.indexOf(node.nodeName.toLowerCase()) !== -1) {
15572
15584
  return true;
15585
+ /* eslint-disable */
15573
15586
  }
15574
15587
  else if (this.inlineTags.indexOf(node.nodeName.toLowerCase()) !== -1 &&
15575
- node.style && node.style.textDecoration === 'underline') {
15588
+ node.style && (node.style.textDecoration === 'underline' ||
15589
+ node.style.textDecorationLine === 'underline')) {
15590
+ /* eslint-enable */
15576
15591
  return true;
15577
15592
  }
15578
15593
  else {
@@ -15591,9 +15606,12 @@ class IsFormatted {
15591
15606
  const validTags = ['del', 'strike'];
15592
15607
  if (validTags.indexOf(node.nodeName.toLowerCase()) !== -1) {
15593
15608
  return true;
15609
+ /* eslint-disable */
15594
15610
  }
15595
15611
  else if (this.inlineTags.indexOf(node.nodeName.toLowerCase()) !== -1 &&
15596
- node.style && node.style.textDecoration === 'line-through') {
15612
+ node.style && (node.style.textDecoration === 'line-through' ||
15613
+ node.style.textDecorationLine === 'line-through')) {
15614
+ /* eslint-enable */
15597
15615
  return true;
15598
15616
  }
15599
15617
  else {
@@ -17071,6 +17089,7 @@ class MsWordPaste {
17071
17089
  this.removingComments(elm);
17072
17090
  this.removeUnwantedElements(elm);
17073
17091
  this.removeEmptyElements(elm);
17092
+ this.removeEmptyAnchorTag(elm);
17074
17093
  this.breakLineAddition(elm);
17075
17094
  this.removeClassName(elm);
17076
17095
  if (pattern4.test(tempHTMLContent)) {
@@ -17124,7 +17143,8 @@ class MsWordPaste {
17124
17143
  imgElem[i].getAttribute('v:shapes').indexOf('Picture') < 0 &&
17125
17144
  imgElem[i].getAttribute('v:shapes').indexOf('圖片') < 0 &&
17126
17145
  imgElem[i].getAttribute('v:shapes').indexOf('Grafik') < 0 &&
17127
- imgElem[i].getAttribute('v:shapes').indexOf('Image') < 0) {
17146
+ imgElem[i].getAttribute('v:shapes').indexOf('Image') < 0 &&
17147
+ imgElem[i].getAttribute('v:shapes').indexOf('Graphic') < 0) {
17128
17148
  detach(imgElem[i]);
17129
17149
  }
17130
17150
  }
@@ -17297,6 +17317,7 @@ class MsWordPaste {
17297
17317
  if (!isNullOrUndefined(element.parentElement)) {
17298
17318
  if (element.parentElement.textContent.trim() === '' &&
17299
17319
  element.parentElement.getAttribute('id') !== 'MSWord-Content' &&
17320
+ !(this.hasParentWithClass(element, 'MsoListParagraph')) &&
17300
17321
  isNullOrUndefined(element.parentElement.querySelector('img'))) {
17301
17322
  removableElement = this.findDetachEmptyElem(element.parentElement);
17302
17323
  }
@@ -17309,6 +17330,16 @@ class MsWordPaste {
17309
17330
  }
17310
17331
  return removableElement;
17311
17332
  }
17333
+ hasParentWithClass(element, className) {
17334
+ let currentParentElem = element.parentElement;
17335
+ while (!isNullOrUndefined(currentParentElem)) {
17336
+ if (currentParentElem.classList.contains(className)) {
17337
+ return true;
17338
+ }
17339
+ currentParentElem = currentParentElem.parentElement;
17340
+ }
17341
+ return false;
17342
+ }
17312
17343
  removeEmptyElements(element) {
17313
17344
  const emptyElements = element.querySelectorAll(':empty');
17314
17345
  for (let i = 0; i < emptyElements.length; i++) {
@@ -17459,7 +17490,7 @@ class MsWordPaste {
17459
17490
  }
17460
17491
  else if (allNodes[index].className &&
17461
17492
  allNodes[index].className.toLowerCase().indexOf('msolistparagraph') !== -1 &&
17462
- allNodes[index].childElementCount !== 1 && !isNullOrUndefined(allNodes[index].getAttribute('style')) &&
17493
+ !isNullOrUndefined(allNodes[index].getAttribute('style')) &&
17463
17494
  allNodes[index].getAttribute('style').indexOf('mso-list:') >= 0) {
17464
17495
  if (allNodes[index].className.indexOf('MsoListParagraphCxSpFirst') >= 0 && listNodes.length > 0 &&
17465
17496
  listNodes[listNodes.length - 1] !== null) {
@@ -17640,6 +17671,19 @@ class MsWordPaste {
17640
17671
  let listCount = 0;
17641
17672
  let elem;
17642
17673
  for (let index = 0; index < collection.length; index++) {
17674
+ const listClass = ['MsoListParagraphCxSpFirst', 'MsoListParagraphCxSpMiddle', 'MsoListParagraphCxSpLast'];
17675
+ let isNormalList = false;
17676
+ for (let i = 0; i < listClass.length; i++) {
17677
+ if (listClass[i].indexOf(collection[index].class) >= 0) {
17678
+ isNormalList = true;
17679
+ break;
17680
+ }
17681
+ }
17682
+ if (!isNullOrUndefined(prevList) && index != 0 &&
17683
+ collection[index - 1].listType !== collection[index].listType &&
17684
+ !isNormalList) {
17685
+ prevList = null;
17686
+ }
17643
17687
  const pElement = createElement('p');
17644
17688
  pElement.innerHTML = collection[index].content.join(' ');
17645
17689
  if ((collection[index].nestedLevel === 1) && listCount === 0 && collection[index].content) {
@@ -17750,28 +17794,29 @@ class MsWordPaste {
17750
17794
  this.listContents.push(pushContent);
17751
17795
  }
17752
17796
  else {
17753
- const styleNodes = ['b', 'em'];
17754
- if (firstChild.childNodes.length > 0 && (firstChild.querySelectorAll('b').length > 0
17755
- || firstChild.querySelectorAll('em').length > 0)) {
17756
- for (let i = 0; i < firstChild.childNodes.length; i++) {
17757
- const nodeName = firstChild.childNodes[i].nodeName.toLowerCase();
17758
- if (firstChild.childNodes[i].textContent.trim().length > 1 && styleNodes.indexOf(nodeName) !== -1) {
17759
- pushContent = '<' + nodeName + '>' + firstChild.childNodes[i].textContent + '</' + nodeName + '>';
17760
- this.listContents.push(pushContent);
17761
- }
17762
- else if (firstChild.childNodes[i].textContent.trim().length === 1) {
17763
- this.listContents.push(firstChild.childNodes[i].textContent.trim());
17764
- }
17797
+ //Add to support separate list which looks like same list and also to add all tags as it is inside list
17798
+ if (firstChild.childNodes.length > 0) {
17799
+ let listOrder = firstChild.querySelector('span[style="mso-list:Ignore"]');
17800
+ if (!isNullOrUndefined(listOrder)) {
17801
+ this.listContents.push(listOrder.textContent.trim());
17802
+ detach(listOrder);
17803
+ this.removingComments(elem);
17804
+ this.removeUnwantedElements(elem);
17765
17805
  }
17766
17806
  }
17767
- else {
17768
- pushContent = firstChild.textContent.trim();
17769
- this.listContents.push(pushContent);
17770
- }
17771
17807
  }
17772
- detach(firstChild);
17773
17808
  this.listContents.push(elem.innerHTML);
17774
17809
  }
17810
+ removeEmptyAnchorTag(element) {
17811
+ const removableElement = element.querySelectorAll('a:not([href])');
17812
+ for (let j = removableElement.length - 1; j >= 0; j--) {
17813
+ const parentElem = removableElement[j].parentNode;
17814
+ while (removableElement[j].firstChild) {
17815
+ parentElem.insertBefore(removableElement[j].firstChild, removableElement[j]);
17816
+ }
17817
+ parentElem.removeChild(removableElement[j]);
17818
+ }
17819
+ }
17775
17820
  }
17776
17821
 
17777
17822
  /**
@@ -19432,7 +19477,8 @@ class HtmlEditor {
19432
19477
  range.startContainer.nodeName === '#text' ? range.startContainer.parentElement !== this.parent.inputElement ? range.startContainer.parentElement.classList.add('currentStartMark')
19433
19478
  : isRootParent = true : range.startContainer.classList.add('currentStartMark');
19434
19479
  if (range.startContainer.textContent.charCodeAt(0) === 8203) {
19435
- pointer = range.startOffset === 0 ? range.startOffset : range.startOffset - 1;
19480
+ pointer = range.startOffset === 0 ? range.startOffset :
19481
+ range.startContainer.textContent.replace(regEx, '').trim().length !== 0 ? range.startOffset - 1 : 0;
19436
19482
  range.startContainer.textContent = range.startContainer.textContent.replace(regEx, '');
19437
19483
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), range.startContainer, pointer);
19438
19484
  }
@@ -19646,7 +19692,7 @@ class HtmlEditor {
19646
19692
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(),
19647
19693
  // eslint-disable-next-line
19648
19694
  this.oldRangeElement, this.oldRangeElement.childNodes.length);
19649
- if (this.oldRangeElement.querySelector('BR')) {
19695
+ if (this.oldRangeElement.querySelectorAll('BR').length === 1) {
19650
19696
  detach(this.oldRangeElement.querySelector('BR'));
19651
19697
  }
19652
19698
  if (!isNullOrUndefined(this.rangeElement) && this.oldRangeElement !== this.rangeElement) {
@@ -20504,7 +20550,6 @@ class PasteCleanup {
20504
20550
  statusCode: '1'
20505
20551
  }];
20506
20552
  this.uploadObj.createFileList(fileData);
20507
- this.uploadObj.filesData.push(fileData[0]);
20508
20553
  /* eslint-enable */
20509
20554
  rawFile = fileData;
20510
20555
  this.uploadObj.upload(fileData);
@@ -20580,6 +20625,7 @@ class PasteCleanup {
20580
20625
  * @deprecated
20581
20626
  */
20582
20627
  imageFormatting(pasteArgs, imgElement) {
20628
+ imgElement.elements[0].classList.add('pasteContent_Img');
20583
20629
  const imageElement = this.parent.createElement('span');
20584
20630
  imageElement.appendChild(imgElement.elements[0]);
20585
20631
  const imageValue = imageElement.innerHTML;
@@ -30642,6 +30688,7 @@ let RichTextEditor = class RichTextEditor extends Component {
30642
30688
  }
30643
30689
  if (e.action !== 'insert-link' &&
30644
30690
  e.action !== 'format-copy' && e.action !== 'format-paste' &&
30691
+ (!e.target || !e.target.classList.contains('e-mention')) &&
30645
30692
  (e.action && e.action !== 'paste' && e.action !== 'space'
30646
30693
  || e.which === 9 || (e.code === 'Backspace' && e.which === 8))) {
30647
30694
  let FormatPainterEscapeAction = false;