@syncfusion/ej2-richtexteditor 20.4.42 → 20.4.43

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.
@@ -12848,52 +12848,62 @@ class InsertHtml {
12848
12848
  }
12849
12849
  }
12850
12850
  else {
12851
- this.insertTempNode(range, node, nodes, nodeCutter, editNode);
12852
- let isFirstTextNode = true;
12853
- let isPreviousInlineElem;
12854
- let paraElm;
12855
- let previousParent;
12856
- if (!this.contentsDeleted) {
12857
- range.deleteContents();
12858
- }
12859
- while (node.firstChild) {
12860
- if (node.firstChild.nodeName === '#text' && node.firstChild.textContent.trim() === '') {
12861
- detach(node.firstChild);
12862
- continue;
12851
+ let parentElem = range.startContainer;
12852
+ while (!isNullOrUndefined(parentElem) && parentElem.nodeName !== 'PRE' && parentElem !== editNode) {
12853
+ parentElem = parentElem.parentElement;
12854
+ }
12855
+ if (!isNullOrUndefined(node) && !isNullOrUndefined(parentElem) && parentElem.nodeName === 'PRE') {
12856
+ range.insertNode(node);
12857
+ lastSelectionNode = node.lastChild;
12858
+ }
12859
+ else {
12860
+ this.insertTempNode(range, node, nodes, nodeCutter, editNode);
12861
+ let isFirstTextNode = true;
12862
+ let isPreviousInlineElem;
12863
+ let paraElm;
12864
+ let previousParent;
12865
+ if (!this.contentsDeleted) {
12866
+ range.deleteContents();
12863
12867
  }
12864
- if (node.firstChild.nodeName === '#text' && isFirstTextNode ||
12865
- (this.inlineNode.indexOf(node.firstChild.nodeName.toLocaleLowerCase()) >= 0 && isFirstTextNode)) {
12866
- lastSelectionNode = node.firstChild;
12867
- if (isNullOrUndefined(node.previousElementSibling)) {
12868
- const firstParaElm = createElement('p');
12869
- node.parentElement.insertBefore(firstParaElm, node);
12868
+ while (node.firstChild) {
12869
+ if (node.firstChild.nodeName === '#text' && node.firstChild.textContent.trim() === '') {
12870
+ detach(node.firstChild);
12871
+ continue;
12870
12872
  }
12871
- node.previousElementSibling.appendChild(node.firstChild);
12872
- }
12873
- else {
12874
- lastSelectionNode = node.firstChild;
12875
- if (node.firstChild.nodeName === '#text' ||
12876
- (this.inlineNode.indexOf(node.firstChild.nodeName.toLocaleLowerCase()) >= 0)) {
12877
- if (!isPreviousInlineElem) {
12878
- paraElm = createElement('p');
12879
- paraElm.appendChild(node.firstChild);
12880
- fragment.appendChild(paraElm);
12873
+ if (node.firstChild.nodeName === '#text' && isFirstTextNode ||
12874
+ (this.inlineNode.indexOf(node.firstChild.nodeName.toLocaleLowerCase()) >= 0 && isFirstTextNode)) {
12875
+ lastSelectionNode = node.firstChild;
12876
+ if (isNullOrUndefined(node.previousElementSibling)) {
12877
+ const firstParaElm = createElement('p');
12878
+ node.parentElement.insertBefore(firstParaElm, node);
12881
12879
  }
12882
- else {
12883
- previousParent.appendChild(node.firstChild);
12884
- fragment.appendChild(previousParent);
12885
- }
12886
- previousParent = paraElm;
12887
- isPreviousInlineElem = true;
12880
+ node.previousElementSibling.appendChild(node.firstChild);
12888
12881
  }
12889
12882
  else {
12890
- fragment.appendChild(node.firstChild);
12891
- isPreviousInlineElem = false;
12883
+ lastSelectionNode = node.firstChild;
12884
+ if (node.firstChild.nodeName === '#text' ||
12885
+ (this.inlineNode.indexOf(node.firstChild.nodeName.toLocaleLowerCase()) >= 0)) {
12886
+ if (!isPreviousInlineElem) {
12887
+ paraElm = createElement('p');
12888
+ paraElm.appendChild(node.firstChild);
12889
+ fragment.appendChild(paraElm);
12890
+ }
12891
+ else {
12892
+ previousParent.appendChild(node.firstChild);
12893
+ fragment.appendChild(previousParent);
12894
+ }
12895
+ previousParent = paraElm;
12896
+ isPreviousInlineElem = true;
12897
+ }
12898
+ else {
12899
+ fragment.appendChild(node.firstChild);
12900
+ isPreviousInlineElem = false;
12901
+ }
12902
+ isFirstTextNode = false;
12892
12903
  }
12893
- isFirstTextNode = false;
12894
12904
  }
12905
+ node.parentNode.replaceChild(fragment, node);
12895
12906
  }
12896
- node.parentNode.replaceChild(fragment, node);
12897
12907
  }
12898
12908
  if (lastSelectionNode.nodeName === '#text') {
12899
12909
  this.placeCursorEnd(lastSelectionNode, node, nodeSelection, docElement, editNode);
@@ -18500,10 +18510,12 @@ class HtmlEditor {
18500
18510
  // eslint-disable-next-line
18501
18511
  const regEx = new RegExp(String.fromCharCode(8203), 'g');
18502
18512
  let pointer;
18513
+ let isRootParent = false;
18503
18514
  if (restrictKeys.indexOf(args.keyCode) < 0 && !args.shiftKey && !args.ctrlKey && !args.altKey) {
18504
18515
  pointer = range.startOffset;
18505
18516
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
18506
- range.startContainer.nodeName === '#text' ? range.startContainer.parentElement.classList.add('currentStartMark') : range.startContainer.classList.add('currentStartMark');
18517
+ range.startContainer.nodeName === '#text' ? range.startContainer.parentElement !== this.parent.inputElement ? range.startContainer.parentElement.classList.add('currentStartMark')
18518
+ : isRootParent = true : range.startContainer.classList.add('currentStartMark');
18507
18519
  if (range.startContainer.textContent.charCodeAt(0) === 8203) {
18508
18520
  pointer = range.startOffset === 0 ? range.startOffset : range.startOffset - 1;
18509
18521
  range.startContainer.textContent = range.startContainer.textContent.replace(regEx, '');
@@ -18512,7 +18524,7 @@ class HtmlEditor {
18512
18524
  const previousLength = this.parent.inputElement.innerHTML.length;
18513
18525
  const currentLength = this.parent.inputElement.innerHTML.replace(regEx, '').length;
18514
18526
  let focusNode = range.startContainer;
18515
- if (previousLength > currentLength) {
18527
+ if (previousLength > currentLength && !isRootParent) {
18516
18528
  let currentChild = this.parent.inputElement.firstChild;
18517
18529
  while (!isNullOrUndefined(currentChild) && currentChild.textContent.replace(regEx, '').trim().length > 0) {
18518
18530
  currentChild.innerHTML = currentChild.innerHTML.replace(regEx, '');
@@ -21784,6 +21796,10 @@ class Image {
21784
21796
  });
21785
21797
  }
21786
21798
  resizing(e) {
21799
+ if (!this.parent) {
21800
+ this.cancelResizeAction();
21801
+ return;
21802
+ }
21787
21803
  if (this.imgEle.offsetWidth >= this.parent.getInsertImgMaxWidth()) {
21788
21804
  this.imgEle.style.maxHeight = this.imgEle.offsetHeight + 'px';
21789
21805
  }
@@ -26635,9 +26651,10 @@ class Table {
26635
26651
  const range = this.parent.formatter.editorManager.nodeSelection.getRange(this.contentModule.getDocument());
26636
26652
  this.parent.formatter.editorManager.nodeSelection.save(range, this.contentModule.getDocument());
26637
26653
  this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
26654
+ const pageX = (this.parent.iframeSettings.enable) ? window.pageXOffset + this.parent.element.getBoundingClientRect().left + args.clientX : args.pageX;
26638
26655
  const pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset +
26639
26656
  this.parent.element.getBoundingClientRect().top + args.clientY : args.pageY;
26640
- this.quickToolObj.tableQTBar.showPopup(args.pageX, pageY, target);
26657
+ this.quickToolObj.tableQTBar.showPopup(pageX, pageY, target);
26641
26658
  this.parent.formatter.editorManager.nodeSelection.restore();
26642
26659
  }
26643
26660
  else {