@syncfusion/ej2-richtexteditor 24.2.8 → 24.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.
@@ -6486,6 +6486,9 @@ class BaseQuickToolbar {
6486
6486
  this.parent.disableToolbarItem(this.parent.toolbarSettings.items);
6487
6487
  this.parent.enableToolbarItem(['Undo', 'Redo']);
6488
6488
  }
6489
+ else {
6490
+ this.parent.enableToolbarItem(this.parent.toolbarSettings.items);
6491
+ }
6489
6492
  append([this.element], document.body);
6490
6493
  if (this.parent.showTooltip) {
6491
6494
  this.tooltip = new Tooltip({
@@ -6933,7 +6936,7 @@ class QuickToolbar {
6933
6936
  * @deprecated
6934
6937
  */
6935
6938
  showInlineQTBar(x, y, target) {
6936
- if (isNullOrUndefined(this.parent) || this.parent.readonly || target.tagName.toLowerCase() === 'img') {
6939
+ if (isNullOrUndefined(this.parent) || this.parent.readonly || target.tagName.toLowerCase() === 'img' || this.inlineQTBar.element.querySelector('.e-rte-color-content')) {
6937
6940
  return;
6938
6941
  }
6939
6942
  this.inlineQTBar.showPopup(x, y, target);
@@ -13779,7 +13782,12 @@ class InsertHtml {
13779
13782
  TABLE_BLOCK_TAGS.indexOf(closestParentNode.tagName.toLocaleLowerCase()) !== -1))
13780
13783
  || (node.nodeName.toLowerCase() === 'table' && closestParentNode &&
13781
13784
  TABLE_BLOCK_TAGS.indexOf(closestParentNode.tagName.toLocaleLowerCase()) === -1))) {
13782
- preNode = nodeCutter.GetSpliceNode(range, closestParentNode);
13785
+ if (isCollapsed) {
13786
+ preNode = nodeCutter.SplitNode(range, closestParentNode, true);
13787
+ }
13788
+ else {
13789
+ preNode = nodeCutter.SplitNode(range, closestParentNode, false);
13790
+ }
13783
13791
  sibNode = isNullOrUndefined(preNode.previousSibling) ? preNode.parentNode.previousSibling : preNode.previousSibling;
13784
13792
  if (nodes.length === 1) {
13785
13793
  nodeSelection.setSelectionContents(docElement, preNode);
@@ -13866,6 +13874,9 @@ class InsertHtml {
13866
13874
  let paraElm;
13867
13875
  let previousParent;
13868
13876
  if (!this.contentsDeleted) {
13877
+ if (!isCollapsed && range.startContainer.parentElement.textContent.length === 0 && range.startContainer.nodeName === 'BR' && range.startContainer.parentElement.nodeName === 'P') {
13878
+ editNode.removeChild(range.startContainer.parentElement);
13879
+ }
13869
13880
  range.deleteContents();
13870
13881
  }
13871
13882
  while (node.firstChild) {
@@ -18166,6 +18177,7 @@ class MsWordPaste {
18166
18177
  const elm = createElement('p');
18167
18178
  elm.setAttribute('id', 'MSWord-Content');
18168
18179
  elm.innerHTML = tempHTMLContent;
18180
+ this.addDoubleBr(elm);
18169
18181
  const patern = /class='?Mso|style='[^ ]*\bmso-/i;
18170
18182
  const patern2 = /class="?Mso|style="[^ ]*\bmso-/i;
18171
18183
  const patern3 = /(class="?Mso|class='?Mso|class="?Xl|class='?Xl|class=Xl|style="[^"]*\bmso-|style='[^']*\bmso-|w:WordDocument)/gi;
@@ -18200,6 +18212,26 @@ class MsWordPaste {
18200
18212
  e.callBack(elm.innerHTML);
18201
18213
  }
18202
18214
  }
18215
+ addDoubleBr(elm) {
18216
+ const newline = elm.querySelector('.Apple-interchange-newline');
18217
+ if (!isNullOrUndefined(newline) && Browser.userAgent.indexOf('Chrome') !== -1 && newline.parentElement.nodeName === 'P' && elm !== newline.parentElement) {
18218
+ for (let i = 0; i < elm.childNodes.length; i++) {
18219
+ // eslint-disable-next-line
18220
+ const node = elm.childNodes[i];
18221
+ if (node.nodeType === Node.COMMENT_NODE && node.nodeValue.includes('StartFragment')) {
18222
+ const newElement = document.createElement('p');
18223
+ newElement.innerHTML = '<br>';
18224
+ const cssText = newline.parentElement.style.cssText;
18225
+ const currentStyle = newElement.getAttribute('style') || '';
18226
+ const newStyle = currentStyle + cssText;
18227
+ newElement.setAttribute('style', newStyle);
18228
+ elm.insertBefore(newElement, node.nextSibling);
18229
+ detach(newline);
18230
+ break;
18231
+ }
18232
+ }
18233
+ }
18234
+ }
18203
18235
  cleanList(elm, listTag) {
18204
18236
  const replacableElem = elm.querySelectorAll(listTag + ' div');
18205
18237
  for (let j = replacableElem.length - 1; j >= 0; j--) {
@@ -21414,9 +21446,9 @@ class HtmlEditor {
21414
21446
  const liElement = this.getRangeLiNode(currentRange.startContainer);
21415
21447
  if (liElement.previousElementSibling && liElement.previousElementSibling.childElementCount > 0) {
21416
21448
  this.oldRangeElement = liElement.previousElementSibling.lastElementChild.nodeName === 'BR' ?
21417
- liElement.previousElementSibling : liElement.previousElementSibling.lastElementChild;
21449
+ liElement.previousElementSibling : liElement.previousElementSibling.lastChild;
21418
21450
  if (!isNullOrUndefined(liElement.lastElementChild) && liElement.lastElementChild.nodeName !== 'BR' &&
21419
- isNullOrUndefined(liElement.lastElementChild.previousSibling)) {
21451
+ isNullOrUndefined(liElement.lastElementChild.previousSibling) && liElement.lastChild.nodeName !== "#text") {
21420
21452
  this.rangeElement = liElement.lastElementChild;
21421
21453
  isLiElement = true;
21422
21454
  }
@@ -21441,7 +21473,7 @@ class HtmlEditor {
21441
21473
  ? this.oldRangeElement.lastElementChild.lastElementChild :
21442
21474
  this.oldRangeElement.lastElementChild;
21443
21475
  }
21444
- let lastNode = this.oldRangeElement.lastChild;
21476
+ let lastNode = this.oldRangeElement.lastChild ? this.oldRangeElement.lastChild : this.oldRangeElement;
21445
21477
  while (lastNode.nodeType !== 3 && lastNode.nodeName !== '#text' &&
21446
21478
  lastNode.nodeName !== 'BR') {
21447
21479
  lastNode = lastNode.lastChild;
@@ -21449,12 +21481,17 @@ class HtmlEditor {
21449
21481
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(),
21450
21482
  // eslint-disable-next-line
21451
21483
  lastNode, lastNode.textContent.length);
21452
- if (this.oldRangeElement.querySelectorAll('BR').length === 1) {
21484
+ if (this.oldRangeElement.nodeName !== '#text' && this.oldRangeElement.querySelectorAll('BR').length === 1) {
21453
21485
  detach(this.oldRangeElement.querySelector('BR'));
21454
21486
  }
21455
21487
  if (!isNullOrUndefined(this.rangeElement) && this.oldRangeElement !== this.rangeElement) {
21456
21488
  while (this.rangeElement.firstChild) {
21457
- this.oldRangeElement.appendChild(this.rangeElement.childNodes[0]);
21489
+ if (this.oldRangeElement.nodeName === '#text') {
21490
+ this.oldRangeElement.parentElement.appendChild(this.rangeElement.childNodes[0]);
21491
+ }
21492
+ else {
21493
+ this.oldRangeElement.appendChild(this.rangeElement.childNodes[0]);
21494
+ }
21458
21495
  }
21459
21496
  // eslint-disable-next-line
21460
21497
  !isLiElement ? detach(this.rangeElement) : detach(this.rangeElement.parentElement);
@@ -23915,7 +23952,7 @@ class EmojiPicker {
23915
23952
  this.parent.getToolbar().appendChild(this.popDiv);
23916
23953
  }
23917
23954
  else if (this.parent.inlineMode.enable) {
23918
- this.parent.inputElement.appendChild(this.popDiv);
23955
+ this.parent.element.appendChild(this.popDiv);
23919
23956
  }
23920
23957
  EventHandler.add(this.popDiv, 'keydown', this.onKeyDown, this);
23921
23958
  EventHandler.add(this.popDiv, 'keyup', this.searchFilter, this);
@@ -33076,10 +33113,10 @@ class EnterKeyAction {
33076
33113
  }
33077
33114
  const previousBlockNode = this.parent.formatter.editorManager.domNode.blockNodes()[0].previousSibling;
33078
33115
  const nextBlockNode = this.parent.formatter.editorManager.domNode.blockNodes()[0].nextSibling;
33079
- if (!isNullOrUndefined(previousBlockNode) && previousBlockNode.hasAttribute('style') && previousBlockNode.nodeName !== 'TABLE') {
33116
+ if (!isNullOrUndefined(previousBlockNode) && previousBlockNode.nodeName !== '#text' && previousBlockNode.hasAttribute('style') && previousBlockNode.nodeName !== 'TABLE') {
33080
33117
  insertElem.setAttribute('style', previousBlockNode.getAttribute('style'));
33081
33118
  }
33082
- if (isNullOrUndefined(previousBlockNode) && !isNullOrUndefined(nextBlockNode) && nextBlockNode.hasAttribute('style') && nextBlockNode.nodeName !== 'TABLE') {
33119
+ if (isNullOrUndefined(previousBlockNode) && !isNullOrUndefined(nextBlockNode) && nextBlockNode.nodeName !== '#text' && nextBlockNode.hasAttribute('style') && nextBlockNode.nodeName !== 'TABLE') {
33083
33120
  insertElem.setAttribute('style', nextBlockNode.getAttribute('style'));
33084
33121
  }
33085
33122
  return insertElem;