@syncfusion/ej2-richtexteditor 20.4.50 → 20.4.52

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.
@@ -12649,8 +12649,8 @@ class InsertHtml {
12649
12649
  }
12650
12650
  if (range.startContainer.nodeName === 'BR' && range.startOffset === 0 && range.startOffset === range.endOffset &&
12651
12651
  range.startContainer === range.endContainer) {
12652
- const currentIndex = Array.prototype.slice.call(range.startContainer.parentElement.children).indexOf(range.startContainer);
12653
- nodeSelection.setSelectionText(docElement, range.startContainer.parentElement, range.startContainer.parentElement, currentIndex + 1, currentIndex + 1);
12652
+ const currentIndex = Array.prototype.slice.call(range.startContainer.parentElement.childNodes).indexOf(range.startContainer);
12653
+ nodeSelection.setSelectionText(docElement, range.startContainer.parentElement, range.startContainer.parentElement, currentIndex, currentIndex);
12654
12654
  range = nodeSelection.getRange(docElement);
12655
12655
  }
12656
12656
  const isCursor = range.startOffset === range.endOffset && range.startOffset === 0 &&
@@ -16842,7 +16842,10 @@ class MsWordPaste {
16842
16842
  this.checkVShape(elm);
16843
16843
  let imgElem = elm.querySelectorAll('img');
16844
16844
  for (let i = 0; i < imgElem.length; i++) {
16845
- if (!isNullOrUndefined(imgElem[i].getAttribute('v:shapes')) && imgElem[i].getAttribute('v:shapes').indexOf('Picture') < 0 && imgElem[i].getAttribute('v:shapes').indexOf('Image') < 0) {
16845
+ if (!isNullOrUndefined(imgElem[i].getAttribute('v:shapes')) &&
16846
+ imgElem[i].getAttribute('v:shapes').indexOf('Picture') < 0 &&
16847
+ imgElem[i].getAttribute('v:shapes').indexOf('圖片') < 0 &&
16848
+ imgElem[i].getAttribute('v:shapes').indexOf('Image') < 0) {
16846
16849
  detach(imgElem[i]);
16847
16850
  }
16848
16851
  }
@@ -17862,7 +17865,7 @@ class ToolbarStatus {
17862
17865
  formatCollection.fontname = this.isFontName(docElement, node, fontName);
17863
17866
  }
17864
17867
  if (!formatCollection.fontsize) {
17865
- formatCollection.fontsize = this.isFontSize(node, fontSize);
17868
+ formatCollection.fontsize = this.isFontSize(docElement, node, fontSize);
17866
17869
  }
17867
17870
  if (!formatCollection.backgroundcolor) {
17868
17871
  formatCollection.backgroundcolor = this.isBackgroundColor(node);
@@ -17922,8 +17925,12 @@ class ToolbarStatus {
17922
17925
  return null;
17923
17926
  }
17924
17927
  }
17925
- static isFontSize(node, fontSize) {
17926
- const size = node.style && node.style.fontSize;
17928
+ static isFontSize(docElement, node, fontSize) {
17929
+ let size = node.style && node.style.fontSize;
17930
+ if ((size === null || size === undefined || size === '') && node.nodeType !== 3 &&
17931
+ node.parentElement.classList.contains('e-content')) {
17932
+ size = this.getComputedStyle(docElement, node, 'font-size');
17933
+ }
17927
17934
  if ((size !== null && size !== '' && size !== undefined)
17928
17935
  && (fontSize === null || fontSize === undefined || (fontSize.indexOf(size) > -1))) {
17929
17936
  return size;
@@ -18377,7 +18384,6 @@ class XhtmlValidation {
18377
18384
  this.currentElement = this.parent.inputElement;
18378
18385
  }
18379
18386
  this.clean(this.currentElement);
18380
- this.AddRootElement();
18381
18387
  this.ImageTags();
18382
18388
  this.removeTags();
18383
18389
  this.RemoveUnsupported();
@@ -18424,16 +18430,6 @@ class XhtmlValidation {
18424
18430
  }
18425
18431
  return currentValue;
18426
18432
  }
18427
- AddRootElement() {
18428
- if ((this.currentElement.childNodes.length === 1 && this.currentElement.firstChild.nodeName !== 'DIV') ||
18429
- this.currentElement.childNodes.length > 1) {
18430
- const parentEle = this.parent.createElement('div');
18431
- while (this.currentElement.childNodes.length > 0) {
18432
- parentEle.appendChild(this.currentElement.childNodes[0]);
18433
- }
18434
- this.currentElement.appendChild(parentEle);
18435
- }
18436
- }
18437
18433
  clean(node) {
18438
18434
  for (let n = 0; n < node.childNodes.length; n++) {
18439
18435
  const child = node.childNodes[n];
@@ -19851,7 +19847,7 @@ class PasteCleanup {
19851
19847
  this.radioRender();
19852
19848
  /* eslint-disable */
19853
19849
  if (this.parent.element.offsetHeight < parseInt(this.dialogObj.height.split('px')[0], null)) {
19854
- this.parent.height = parseInt(this.dialogObj.height.split('px')[0], null) + 40;
19850
+ this.parent.setProperties({ height: parseInt(this.dialogObj.height.split('px')[0], null) + 40 });
19855
19851
  /* eslint-enable */
19856
19852
  isHeight = true;
19857
19853
  }
@@ -27225,12 +27221,14 @@ class Table {
27225
27221
  if ((totalwid - actualwid) > 20 && actualwid > 20) {
27226
27222
  const leftColumnWidth = totalwid - actualwid;
27227
27223
  const rightColWidth = actualwid;
27228
- if (!isNullOrUndefined(this.curTable.rows[i].cells[this.colIndex - 1])) {
27229
- this.curTable.rows[i].cells[this.colIndex - 1].style.width =
27224
+ const index = this.curTable.rows[i].cells[i].hasAttribute('colspan') ?
27225
+ parseInt(this.curTable.rows[i].cells[i].getAttribute('colspan'), 10) - 1 : this.colIndex;
27226
+ if (!isNullOrUndefined(this.curTable.rows[i].cells[index - 1])) {
27227
+ this.curTable.rows[i].cells[index - 1].style.width =
27230
27228
  this.convertPixelToPercentage(leftColumnWidth, tableWidth) + '%';
27231
27229
  }
27232
- if (!isNullOrUndefined(this.curTable.rows[i].cells[this.colIndex])) {
27233
- this.curTable.rows[i].cells[this.colIndex].style.width =
27230
+ if (!isNullOrUndefined(this.curTable.rows[i].cells[index])) {
27231
+ this.curTable.rows[i].cells[index].style.width =
27234
27232
  this.convertPixelToPercentage(rightColWidth, tableWidth) + '%';
27235
27233
  }
27236
27234
  }
@@ -28461,7 +28459,7 @@ class EnterKeyAction {
28461
28459
  isTableEnter = blockElement.tagName === 'TD' || blockElement.tagName === 'TBODY' ? false : true;
28462
28460
  }
28463
28461
  if (e.args.which === 13 && e.args.code === 'Enter') {
28464
- if (isNullOrUndefined(this.startNode.closest('LI')) && isNullOrUndefined(this.endNode.closest('LI')) && isTableEnter &&
28462
+ if (isNullOrUndefined(this.startNode.closest('LI,UL,OL')) && isNullOrUndefined(this.endNode.closest('LI,UL,OL')) && isTableEnter &&
28465
28463
  isNullOrUndefined(this.startNode.closest('PRE')) && isNullOrUndefined(this.endNode.closest('PRE'))) {
28466
28464
  const shiftKey = e.args.shiftKey;
28467
28465
  const actionBeginArgs = {
@@ -28753,7 +28751,8 @@ class EnterKeyAction {
28753
28751
  }
28754
28752
  this.removeBRElement(currentParent);
28755
28753
  let currentParentLastChild = currentParent.lastChild;
28756
- while (!isNullOrUndefined(currentParentLastChild) && !(currentParentLastChild.nodeName === '#text' || currentParentLastChild.nodeName === 'BR')) {
28754
+ while (!isNullOrUndefined(currentParentLastChild) && !(currentParentLastChild.nodeName === '#text' || currentParentLastChild.nodeName === 'BR'
28755
+ || currentParentLastChild.nodeName === 'IMG')) {
28757
28756
  currentParentLastChild = currentParentLastChild.lastChild;
28758
28757
  }
28759
28758
  const isLastNodeLength = this.range.startContainer === currentParentLastChild ?
@@ -28761,8 +28760,9 @@ class EnterKeyAction {
28761
28760
  if (currentParent !== this.parent.inputElement &&
28762
28761
  this.parent.formatter.editorManager.domNode.isBlockNode(currentParent) &&
28763
28762
  this.range.startOffset === this.range.endOffset &&
28764
- this.range.startOffset === isLastNodeLength) {
28765
- const focusBRElem = this.parent.createElement('br');
28763
+ (this.range.startOffset === isLastNodeLength ||
28764
+ (currentParent.textContent.trim().length === 0 && currentParent.lastChild.nodeName === 'IMG'))) {
28765
+ let focusBRElem = this.parent.createElement('br');
28766
28766
  if (this.range.startOffset === 0 && this.range.startContainer.nodeName === 'TABLE') {
28767
28767
  this.range.startContainer.parentElement.insertBefore(focusBRElem, this.range.startContainer);
28768
28768
  }
@@ -28770,6 +28770,11 @@ class EnterKeyAction {
28770
28770
  if (currentParentLastChild.nodeName === 'BR' && currentParent.textContent.length === 0) {
28771
28771
  this.parent.formatter.editorManager.domNode.insertAfter(focusBRElem, currentParentLastChild);
28772
28772
  }
28773
+ else if (this.range.startOffset === 0 && this.range.endOffset === 0 &&
28774
+ currentParent.lastChild && currentParent.lastChild.nodeName === 'IMG') {
28775
+ currentParentLastChild.parentElement.insertBefore(focusBRElem, currentParentLastChild);
28776
+ focusBRElem = currentParentLastChild;
28777
+ }
28773
28778
  else {
28774
28779
  const lineBreakBRElem = this.parent.createElement('br');
28775
28780
  this.parent.formatter.editorManager.domNode.insertAfter(focusBRElem, this.range.startContainer);
@@ -29608,6 +29613,7 @@ let RichTextEditor = class RichTextEditor extends Component {
29608
29613
  }
29609
29614
  else {
29610
29615
  value = this.htmlEditorModule.sanitizeHelper(value);
29616
+ value = this.enableXhtml ? this.htmlEditorModule.xhtmlValidation.selfEncloseValidation(value) : value;
29611
29617
  }
29612
29618
  }
29613
29619
  return value;
@@ -30823,7 +30829,9 @@ let RichTextEditor = class RichTextEditor extends Component {
30823
30829
  this.notify(windowResize, null);
30824
30830
  }
30825
30831
  scrollHandler(e) {
30826
- this.notify(scroll, { args: e });
30832
+ if (this.element) {
30833
+ this.notify(scroll, { args: e });
30834
+ }
30827
30835
  }
30828
30836
  contentScrollHandler(e) {
30829
30837
  this.notify(contentscroll, { args: e });
@@ -30884,8 +30892,8 @@ let RichTextEditor = class RichTextEditor extends Component {
30884
30892
  }
30885
30893
  const getTextArea = this.element.querySelector('.e-rte-srctextarea');
30886
30894
  if (this.editorMode === 'HTML') {
30887
- value = (this.inputElement.innerHTML === '<p><br></p>' || this.inputElement.innerHTML === '<div><br></div>' ||
30888
- this.inputElement.innerHTML === '<br>') ? null : this.enableHtmlEncode ?
30895
+ value = (this.inputElement.innerHTML === '<p><br></p>' || this.inputElement.innerHTML === '<div><br></div>'
30896
+ || this.inputElement.innerHTML === '<br>') ? null : this.enableHtmlEncode ?
30889
30897
  this.encode(decode(this.inputElement.innerHTML)) : this.inputElement.innerHTML;
30890
30898
  if (getTextArea && getTextArea.style.display === 'block') {
30891
30899
  value = getTextArea.value;