@syncfusion/ej2-richtexteditor 25.2.4 → 25.2.6

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +34 -2
  2. package/dist/ej2-richtexteditor.min.js +2 -2
  3. package/dist/ej2-richtexteditor.umd.min.js +2 -2
  4. package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-richtexteditor.es2015.js +362 -130
  6. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-richtexteditor.es5.js +360 -127
  8. package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
  9. package/dist/global/ej2-richtexteditor.min.js +2 -2
  10. package/dist/global/ej2-richtexteditor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +11 -11
  13. package/src/common/interface.d.ts +14 -0
  14. package/src/common/util.js +4 -1
  15. package/src/editor-manager/base/editor-manager.js +5 -3
  16. package/src/editor-manager/plugin/alignments.js +3 -0
  17. package/src/editor-manager/plugin/dom-node.d.ts +20 -0
  18. package/src/editor-manager/plugin/dom-node.js +104 -1
  19. package/src/editor-manager/plugin/formats.js +1 -1
  20. package/src/editor-manager/plugin/indents.js +3 -0
  21. package/src/editor-manager/plugin/lists.d.ts +0 -1
  22. package/src/editor-manager/plugin/lists.js +55 -78
  23. package/src/editor-manager/plugin/ms-word-clean-up.js +1 -1
  24. package/src/rich-text-editor/actions/enter-key.d.ts +5 -0
  25. package/src/rich-text-editor/actions/enter-key.js +98 -13
  26. package/src/rich-text-editor/actions/full-screen.js +0 -6
  27. package/src/rich-text-editor/actions/html-editor.d.ts +1 -0
  28. package/src/rich-text-editor/actions/html-editor.js +63 -10
  29. package/src/rich-text-editor/actions/paste-clean-up.js +2 -1
  30. package/src/rich-text-editor/base/rich-text-editor.d.ts +1 -0
  31. package/src/rich-text-editor/base/rich-text-editor.js +12 -1
  32. package/src/rich-text-editor/renderer/image-module.js +3 -3
  33. package/src/rich-text-editor/renderer/toolbar-renderer.js +7 -9
@@ -4574,11 +4574,14 @@ function nestedListCleanUp(range) {
4574
4574
  item.remove();
4575
4575
  });
4576
4576
  }
4577
+ else {
4578
+ break;
4579
+ }
4577
4580
  }
4578
4581
  let liElem = (range.startContainer.nodeName === "#text" ? range.startContainer.parentElement : range.startContainer).querySelectorAll("li");
4579
4582
  if (liElem.length > 0) {
4580
4583
  liElem.forEach((item) => {
4581
- if (item.firstChild.nodeName === "OL" || item.firstChild.nodeName === "UL") {
4584
+ if (!isNullOrUndefined(item.firstChild) && (item.firstChild.nodeName === "OL" || item.firstChild.nodeName === "UL")) {
4582
4585
  item.style.listStyleType = "none";
4583
4586
  }
4584
4587
  });
@@ -5449,8 +5452,6 @@ class ToolbarRenderer {
5449
5452
  target: colorPicker.element.parentElement, cssClass: css,
5450
5453
  enablePersistence: this.parent.enablePersistence, enableRtl: this.parent.enableRtl,
5451
5454
  beforeOpen: (dropDownArgs) => {
5452
- colorPicker.inline = true;
5453
- colorPicker.dataBind();
5454
5455
  if (proxy.parent.readonly || !proxy.parent.enabled) {
5455
5456
  dropDownArgs.cancel = true;
5456
5457
  return;
@@ -5588,14 +5589,18 @@ class ToolbarRenderer {
5588
5589
  const colorPicker = new ColorPicker({
5589
5590
  enablePersistence: this.parent.enablePersistence,
5590
5591
  enableRtl: this.parent.enableRtl,
5591
- inline: false,
5592
- value: '#fff',
5592
+ inline: true,
5593
+ value: null,
5594
+ cssClass: ((item === 'backgroundcolor') ? CLS_BACKGROUND_COLOR_PICKER : CLS_FONT_COLOR_PICKER) + ' ' + args.cssClass + ' ' + 'e-rte-picker-init',
5593
5595
  created: () => {
5594
5596
  const value = (item === 'backgroundcolor') ? proxy.parent.backgroundColor.default : proxy.parent.fontColor.default;
5595
- colorPicker.setProperties({ value: value });
5597
+ colorPicker.cssClass = ((item === 'backgroundcolor') ? CLS_BACKGROUND_COLOR_PICKER : CLS_FONT_COLOR_PICKER) + ' ' + args.cssClass;
5598
+ colorPicker.value = value;
5596
5599
  },
5597
5600
  mode: ((item === 'backgroundcolor') ? proxy.parent.backgroundColor.mode : proxy.parent.fontColor.mode),
5598
5601
  modeSwitcher: ((item === 'backgroundcolor') ? proxy.parent.backgroundColor.modeSwitcher : proxy.parent.fontColor.modeSwitcher),
5602
+ presetColors: (item === 'backgroundcolor') ? this.parent.backgroundColor.colorCode : this.parent.fontColor.colorCode,
5603
+ columns: (item === 'backgroundcolor') ? this.parent.backgroundColor.columns : this.parent.fontColor.columns,
5599
5604
  beforeTileRender: (args) => {
5600
5605
  args.element.classList.add(CLS_COLOR_PALETTE);
5601
5606
  args.element.classList.add(CLS_CUSTOM_TILE);
@@ -5640,10 +5645,6 @@ class ToolbarRenderer {
5640
5645
  }
5641
5646
  });
5642
5647
  colorPicker.isStringTemplate = true;
5643
- colorPicker.columns = (item === 'backgroundcolor') ? this.parent.backgroundColor.columns : this.parent.fontColor.columns;
5644
- colorPicker.presetColors = (item === 'backgroundcolor') ? this.parent.backgroundColor.colorCode :
5645
- this.parent.fontColor.colorCode;
5646
- colorPicker.cssClass = ((item === 'backgroundcolor') ? CLS_BACKGROUND_COLOR_PICKER : CLS_FONT_COLOR_PICKER) + ' ' + args.cssClass;
5647
5648
  colorPicker.createElement = this.parent.createElement;
5648
5649
  colorPicker.appendTo(document.getElementById(args.target));
5649
5650
  return colorPicker;
@@ -12600,6 +12601,109 @@ class DOMNode {
12600
12601
  }
12601
12602
  return null;
12602
12603
  }
12604
+ /**
12605
+ * Method to wrap the inline and text node with block node.
12606
+ *
12607
+ * @param {HTMLElement} node - specifies the element sent to wrap the node around it with block nodes.
12608
+ * @param {string} wrapperElement - specifies which block nodes to wrap around.
12609
+ * @returns {HTMLElement} - returns the wrapped element.
12610
+ * @hidden
12611
+ * @deprecated
12612
+ */
12613
+ gatherElementsAround(node, wrapperElement) {
12614
+ const newWrapElem = createElement(wrapperElement);
12615
+ // Insert the new div element before the current node.
12616
+ let currentNode = node.previousSibling;
12617
+ const currentNodeParent = node.parentElement;
12618
+ if (currentNodeParent.className === 'e-editor-select-start') {
12619
+ currentNodeParent.parentNode.insertBefore(newWrapElem, currentNodeParent);
12620
+ }
12621
+ else if (currentNodeParent) {
12622
+ currentNodeParent.insertBefore(newWrapElem, node);
12623
+ }
12624
+ let i = 0;
12625
+ while (currentNode !== null && currentNode.nodeName !== 'BR' &&
12626
+ !this.isBlockNode(currentNode)) {
12627
+ const prevSibling = currentNode.previousSibling;
12628
+ if (currentNode.nodeType === 3 || currentNode.nodeType === 1) {
12629
+ if (i === 0) {
12630
+ newWrapElem.appendChild(currentNode);
12631
+ }
12632
+ else {
12633
+ newWrapElem.insertBefore(currentNode, newWrapElem.firstChild);
12634
+ }
12635
+ }
12636
+ currentNode = prevSibling;
12637
+ i++;
12638
+ }
12639
+ // Add the current node to the new div
12640
+ newWrapElem.appendChild(node);
12641
+ // Gather text and inline elements after the currentNode
12642
+ currentNode = newWrapElem.nextSibling ? newWrapElem.nextSibling :
12643
+ newWrapElem.parentElement.nextSibling;
12644
+ while (currentNode !== null && currentNode.nodeName !== 'BR' &&
12645
+ !this.isBlockNode(currentNode)) {
12646
+ const nextSibling = currentNode.nextSibling ?
12647
+ currentNode.nextSibling : currentNode.parentElement.nextSibling;
12648
+ if (currentNode.nodeType === 3 || currentNode.nodeType === 1) {
12649
+ newWrapElem.appendChild(currentNode);
12650
+ }
12651
+ currentNode = nextSibling;
12652
+ }
12653
+ return newWrapElem;
12654
+ }
12655
+ /**
12656
+ * Method to convert all the inline nodes between the selection to block nodes.
12657
+ *
12658
+ * @param {Node[]} selectedNodes - specifies the nodes of the start and end selection.
12659
+ * @param {boolean} fromList - specifies if the method is called from list module.
12660
+ * @returns {Node[]} - returns the selected list of elements as block nodes.
12661
+ * @hidden
12662
+ * @deprecated
12663
+ */
12664
+ convertToBlockNodes(selectedNodes, fromList) {
12665
+ if (selectedNodes.length > 1) {
12666
+ let i = 0;
12667
+ let currentSelectedNode = selectedNodes[0];
12668
+ while (!isNullOrUndefined(currentSelectedNode)) {
12669
+ if (currentSelectedNode.nodeName === 'BR') {
12670
+ const nextNode = currentSelectedNode.nextSibling;
12671
+ detach(currentSelectedNode);
12672
+ currentSelectedNode = nextNode;
12673
+ }
12674
+ if (!isNullOrUndefined(currentSelectedNode)) {
12675
+ if (fromList) {
12676
+ selectedNodes[i] = currentSelectedNode.nodeName === 'LI' || this.isBlockNode(currentSelectedNode) ?
12677
+ currentSelectedNode :
12678
+ this.gatherElementsAround(currentSelectedNode, (fromList ? 'p' : 'div'));
12679
+ }
12680
+ else {
12681
+ selectedNodes[i] = !this.isBlockNode(selectedNodes[i]) ?
12682
+ this.gatherElementsAround(currentSelectedNode, (fromList ? 'p' : 'div')) :
12683
+ selectedNodes[i];
12684
+ }
12685
+ const currentProcessNode = selectedNodes[i].nodeName === 'LI' ? selectedNodes[i].parentElement : selectedNodes[i];
12686
+ const currentElementCheckNode = currentProcessNode.nodeName === '#text' ? currentProcessNode.parentElement : currentProcessNode;
12687
+ currentSelectedNode = !isNullOrUndefined(currentElementCheckNode.querySelector('.e-editor-select-end')) ||
12688
+ !isNullOrUndefined(closest(currentSelectedNode, '.e-editor-select-end')) ?
12689
+ null : currentProcessNode.nextSibling;
12690
+ if (currentSelectedNode === null && !isNullOrUndefined(currentProcessNode.nextSibling) && currentProcessNode.nextSibling.nodeName === 'BR') {
12691
+ detach(currentProcessNode.nextSibling);
12692
+ }
12693
+ }
12694
+ i++;
12695
+ }
12696
+ }
12697
+ else {
12698
+ if (!this.isBlockNode(selectedNodes[0])) {
12699
+ selectedNodes[0] = this.gatherElementsAround(selectedNodes[0], (fromList ? 'p' : 'div'));
12700
+ if (!isNullOrUndefined(selectedNodes[0].nextSibling) && (selectedNodes[0].nextSibling.nodeName === 'BR')) {
12701
+ detach(selectedNodes[0].nextSibling);
12702
+ }
12703
+ }
12704
+ }
12705
+ return selectedNodes;
12706
+ }
12603
12707
  /**
12604
12708
  * blockNodes method
12605
12709
  *
@@ -13107,7 +13211,7 @@ class Lists {
13107
13211
  e.event.preventDefault();
13108
13212
  }
13109
13213
  }
13110
- onKeyUp() {
13214
+ onKeyUp(e) {
13111
13215
  if (!isNullOrUndefined(this.commonLIParent) && !isNullOrUndefined(this.commonLIParent.querySelector('.removeList'))) {
13112
13216
  const currentLIElem = this.commonLIParent.querySelector('.removeList');
13113
13217
  while (!isNullOrUndefined(currentLIElem.firstChild)) {
@@ -13115,6 +13219,14 @@ class Lists {
13115
13219
  }
13116
13220
  detach(currentLIElem);
13117
13221
  }
13222
+ if (e.event.keyCode === 13) {
13223
+ const listElements = this.parent.editableElement.querySelectorAll('UL, OL');
13224
+ for (let i = 0; i < listElements.length; i++) {
13225
+ if (!isNullOrUndefined(listElements[i]) && !isNullOrUndefined(listElements[i].parentElement) && !isNullOrUndefined(listElements[i].previousElementSibling) && (listElements[i].parentElement.nodeName === 'UL' || listElements[i].parentElement.nodeName === 'OL')) {
13226
+ listElements[i].previousElementSibling.appendChild(listElements[i]);
13227
+ }
13228
+ }
13229
+ }
13118
13230
  }
13119
13231
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13120
13232
  firstListBackSpace(range, _e) {
@@ -13356,6 +13468,8 @@ class Lists {
13356
13468
  else {
13357
13469
  if (prevSibling.tagName === 'LI') {
13358
13470
  const nestedElement = createElement(elements[i].parentNode.tagName);
13471
+ nestedElement.style.listStyleType =
13472
+ elements[i].parentNode.style.listStyleType;
13359
13473
  append([nestedElement], prevSibling);
13360
13474
  append([elements[i]], nestedElement);
13361
13475
  }
@@ -13405,39 +13519,7 @@ class Lists {
13405
13519
  let listsNodes = this.domNode.blockNodes(true);
13406
13520
  if (e.enterAction === 'BR') {
13407
13521
  this.setSelectionBRConfig();
13408
- const selectedNodes = this.parent.domNode.blockNodes();
13409
- if (selectedNodes.length > 1) {
13410
- let i = 0;
13411
- let currentAlignmentNode = selectedNodes[0];
13412
- while (!isNullOrUndefined(currentAlignmentNode)) {
13413
- if (currentAlignmentNode.nodeName === 'BR') {
13414
- const nextNode = currentAlignmentNode.nextSibling;
13415
- detach(currentAlignmentNode);
13416
- currentAlignmentNode = nextNode;
13417
- }
13418
- if (!isNullOrUndefined(currentAlignmentNode)) {
13419
- selectedNodes[i] = currentAlignmentNode.nodeName === 'LI' || this.parent.domNode.isBlockNode(currentAlignmentNode) ?
13420
- currentAlignmentNode : this.gatherElementsAround(currentAlignmentNode);
13421
- const currentSelectNode = selectedNodes[i].nodeName === 'LI' ? selectedNodes[i].parentElement : selectedNodes[i];
13422
- const currentElementCheckNode = currentAlignmentNode.nodeName === '#text' ? currentAlignmentNode.parentElement : currentAlignmentNode;
13423
- currentAlignmentNode = !isNullOrUndefined(currentElementCheckNode.querySelector('.e-editor-select-end')) ||
13424
- !isNullOrUndefined(closest(currentAlignmentNode, '.e-editor-select-end')) ?
13425
- null : currentSelectNode.nextSibling;
13426
- if (currentAlignmentNode === null && !isNullOrUndefined(currentSelectNode.nextSibling) && currentSelectNode.nextSibling.nodeName === 'BR') {
13427
- detach(currentSelectNode.nextSibling);
13428
- }
13429
- }
13430
- i++;
13431
- }
13432
- }
13433
- else {
13434
- if (!this.parent.domNode.isBlockNode(selectedNodes[0])) {
13435
- selectedNodes[0] = this.gatherElementsAround(selectedNodes[0]);
13436
- if (!isNullOrUndefined(selectedNodes[0].nextSibling) && (selectedNodes[0].nextSibling.nodeName === 'BR')) {
13437
- detach(selectedNodes[0].nextSibling);
13438
- }
13439
- }
13440
- }
13522
+ this.parent.domNode.convertToBlockNodes(this.parent.domNode.blockNodes(), true);
13441
13523
  this.setSelectionBRConfig();
13442
13524
  listsNodes = this.parent.domNode.blockNodes();
13443
13525
  }
@@ -13494,7 +13576,7 @@ class Lists {
13494
13576
  }
13495
13577
  let elemAtt;
13496
13578
  elements[i].style.removeProperty('margin-left');
13497
- elemAtt = elements[i].tagName === 'IMG' ? '' : this.domNode.attributes(elements[i]);
13579
+ elemAtt = elements[i].tagName === 'IMG' || elements[i].classList.contains('e-editor-select-start') ? '' : this.domNode.attributes(elements[i]);
13498
13580
  if (elements[i].getAttribute('contenteditable') === 'true'
13499
13581
  && elements[i].childNodes.length === 1 && elements[i].childNodes[0].nodeName === 'TABLE') {
13500
13582
  const listEle = document.createElement(type);
@@ -13615,6 +13697,13 @@ class Lists {
13615
13697
  for (let c = 0; c < liParents.length; c++) {
13616
13698
  const node = liParents[c];
13617
13699
  let toFindtopOlUl = true;
13700
+ let containsListElements = node;
13701
+ while (containsListElements.parentElement) {
13702
+ if (containsListElements.parentElement && containsListElements.parentElement.tagName !== 'LI' && containsListElements.parentElement.tagName !== 'OL' && containsListElements.parentElement.tagName !== 'UL') {
13703
+ break;
13704
+ }
13705
+ containsListElements = containsListElements.parentElement;
13706
+ }
13618
13707
  if (toFindtopOlUl && (liParents[c].parentElement.parentElement.nodeName === 'OL' || liParents[c].parentElement.parentElement.nodeName === 'UL')) {
13619
13708
  toFindtopOlUl = false;
13620
13709
  const preElement = liParents[c].parentElement.parentElement;
@@ -13634,9 +13723,43 @@ class Lists {
13634
13723
  node.previousElementSibling.lastChild.append(node);
13635
13724
  }
13636
13725
  }
13726
+ else if (this.domNode.isList(node.previousElementSibling) && containsListElements.contains(node.previousElementSibling) && ((node.tagName === 'OL' || node.tagName === 'UL') && (node.previousElementSibling.nodeName === 'OL' || node.previousElementSibling.nodeName === 'UL'))) {
13727
+ const contentNodes = this.domNode.contents(node);
13728
+ for (let f = 0; f < contentNodes.length; f++) {
13729
+ node.previousElementSibling.appendChild(contentNodes[f]);
13730
+ }
13731
+ node.parentNode.removeChild(node);
13732
+ }
13637
13733
  }
13638
13734
  if (firstNodeOL) {
13639
13735
  firstNodeOL.style.listStyleType = listStyleType;
13736
+ const range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
13737
+ let listOlUlElements = [];
13738
+ if (range.commonAncestorContainer.nodeName === 'UL' || range.commonAncestorContainer.nodeName === 'OL') {
13739
+ if (range.commonAncestorContainer instanceof Element) {
13740
+ listOlUlElements.push(range.commonAncestorContainer);
13741
+ }
13742
+ listOlUlElements = listOlUlElements.concat(Array.from(range.commonAncestorContainer.querySelectorAll('ol, ul')));
13743
+ }
13744
+ else {
13745
+ listOlUlElements = Array.from(range.commonAncestorContainer.querySelectorAll('ol, ul'));
13746
+ }
13747
+ for (let k = 0; k < listOlUlElements.length; k++) {
13748
+ let listStyle;
13749
+ let listElements = listOlUlElements[k];
13750
+ while (listElements) {
13751
+ if (listElements.nodeName === 'OL' || listElements.nodeName === 'OL') {
13752
+ if (listElements.style.listStyleType !== '' && listElements.style.listStyleType !== 'none' && listElements.nodeName !== 'LI') {
13753
+ listStyle = listElements.style.listStyleType;
13754
+ }
13755
+ else if (!isNullOrUndefined(listStyle) && (listElements.style.listStyleType === '' || listElements.style.listStyleType === 'none') &&
13756
+ listElements.nodeName !== 'LI' && (listElements.nodeName === 'UL' || listElements.nodeName === 'OL')) {
13757
+ listElements.style.listStyleType = listStyle;
13758
+ }
13759
+ }
13760
+ listElements = listElements.querySelector('UL,OL');
13761
+ }
13762
+ }
13640
13763
  }
13641
13764
  }
13642
13765
  findUnSelected(temp, elements) {
@@ -13739,7 +13862,7 @@ class Lists {
13739
13862
  parentNode.removeAttribute("style");
13740
13863
  }
13741
13864
  }
13742
- const wrapper = '<' + DEFAULT_TAG + wrapperclass + this.domNode.attributes(element) + '></' + DEFAULT_TAG + '>';
13865
+ const wrapper = '<' + e.enterAction + wrapperclass + this.domNode.attributes(element) + '></' + e.enterAction + '>';
13743
13866
  if (e.enterAction !== 'BR') {
13744
13867
  this.domNode.wrapInner(element, this.domNode.parseHTMLFragment(wrapper));
13745
13868
  }
@@ -13813,48 +13936,6 @@ class Lists {
13813
13936
  closeTag(type) {
13814
13937
  return this.domNode.parseHTMLFragment('<span class="e-rte-list-close-' + type.toLowerCase() + '"></span>');
13815
13938
  }
13816
- gatherElementsAround(node) {
13817
- const pWrap = document.createElement('p');
13818
- // Insert the new div before the current node
13819
- let currentNode = node.previousSibling;
13820
- const classNode = node.parentNode;
13821
- if (classNode.className === 'e-editor-select-start') {
13822
- node.parentNode.parentNode.insertBefore(pWrap, node.parentNode);
13823
- }
13824
- else if (node.parentNode) {
13825
- node.parentNode.insertBefore(pWrap, node);
13826
- }
13827
- // Gather text and inline elements before the currentNode
13828
- let i = 0;
13829
- while (currentNode !== null && currentNode.nodeName !== 'BR' &&
13830
- !this.parent.domNode.isBlockNode(currentNode)) {
13831
- const prevSibling = currentNode.previousSibling;
13832
- if (currentNode.nodeType === 3 || currentNode.nodeType === 1) {
13833
- if (i === 0) {
13834
- pWrap.appendChild(currentNode);
13835
- }
13836
- else {
13837
- pWrap.insertBefore(currentNode, pWrap.firstChild);
13838
- }
13839
- }
13840
- currentNode = prevSibling;
13841
- i++;
13842
- }
13843
- // Add the current node to the new p
13844
- pWrap.appendChild(node);
13845
- // Gather text and inline elements after the currentNode
13846
- currentNode = pWrap.nextSibling ? pWrap.nextSibling : pWrap.parentElement.nextSibling;
13847
- while (currentNode !== null && currentNode.nodeName !== 'BR' &&
13848
- !this.parent.domNode.isBlockNode(currentNode)) {
13849
- const nextSibling = currentNode.nextSibling ?
13850
- currentNode.nextSibling : currentNode.parentElement.nextSibling;
13851
- if (currentNode.nodeType === 3 || currentNode.nodeType === 1) {
13852
- pWrap.appendChild(currentNode);
13853
- }
13854
- currentNode = nextSibling;
13855
- }
13856
- return pWrap;
13857
- }
13858
13939
  }
13859
13940
 
13860
13941
  /**
@@ -14189,8 +14270,8 @@ class Formats {
14189
14270
  }
14190
14271
  }
14191
14272
  }
14192
- if (e.enterAction !== 'BR' && !isNullOrUndefined(range.startContainer) && !isNullOrUndefined(range.startContainer.parentElement) && range.startContainer === range.endContainer && range.startContainer.nodeName === '#text' && range.startContainer.parentElement.classList.contains("e-content") && range.startContainer.parentElement.isContentEditable) {
14193
- let pTag = createElement(e.enterAction);
14273
+ if (e.enterAction !== 'BR' && !isNullOrUndefined(range.startContainer) && !isNullOrUndefined(range.startContainer.parentElement) && range.startContainer === range.endContainer && range.startContainer.nodeName === '#text' && range.startContainer.parentElement.classList.contains('e-content') && range.startContainer.parentElement.isContentEditable) {
14274
+ const pTag = createElement(e.enterAction);
14194
14275
  range.startContainer.parentElement.insertBefore(pTag, range.startContainer);
14195
14276
  pTag.appendChild(range.startContainer);
14196
14277
  this.parent.nodeSelection.setCursorPoint(this.parent.currentDocument, pTag, 1);
@@ -15530,7 +15611,10 @@ class Alignments {
15530
15611
  let save = this.parent.nodeSelection.save(range, this.parent.currentDocument);
15531
15612
  if (!isTableAlign) {
15532
15613
  this.parent.domNode.setMarker(save);
15533
- const alignmentNodes = this.parent.domNode.blockNodes();
15614
+ let alignmentNodes = this.parent.domNode.blockNodes();
15615
+ if (e.enterAction === 'BR') {
15616
+ alignmentNodes = this.parent.domNode.convertToBlockNodes(alignmentNodes, false);
15617
+ }
15534
15618
  for (let i = 0; i < alignmentNodes.length; i++) {
15535
15619
  const parentNode = alignmentNodes[i];
15536
15620
  setStyleAttribute(parentNode, { 'text-align': this.alignments[e.subCommand] });
@@ -15612,7 +15696,10 @@ class Indents {
15612
15696
  const range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
15613
15697
  let save = this.parent.nodeSelection.save(range, this.parent.currentDocument);
15614
15698
  this.parent.domNode.setMarker(save);
15615
- const indentsNodes = this.parent.domNode.blockNodes();
15699
+ let indentsNodes = this.parent.domNode.blockNodes();
15700
+ if (e.enterAction === 'BR') {
15701
+ indentsNodes = this.parent.domNode.convertToBlockNodes(indentsNodes, false);
15702
+ }
15616
15703
  const parentNodes = indentsNodes.slice();
15617
15704
  const listsNodes = [];
15618
15705
  for (let i = 0; i < parentNodes.length; i++) {
@@ -19894,7 +19981,7 @@ class MsWordPaste {
19894
19981
  !isNormalList) {
19895
19982
  prevList = null;
19896
19983
  }
19897
- const pElement = createElement('p', { className: 'MsoNormal' });
19984
+ const pElement = createElement('p', { className: 'MsoNoSpacing' });
19898
19985
  pElement.innerHTML = collection[index].content.join(' ');
19899
19986
  if ((collection[index].nestedLevel === 1) &&
19900
19987
  (listCount === 0 || lfo !== collection[index].listFormatOverride) &&
@@ -20970,12 +21057,14 @@ class EditorManager {
20970
21057
  case 'alignments':
20971
21058
  this.observer.notify(ALIGNMENT_TYPE, {
20972
21059
  subCommand: value, event: event, callBack: callBack,
20973
- selector: selector,
20974
- value: exeValue
21060
+ selector: selector, value: exeValue, enterAction: enterAction
20975
21061
  });
20976
21062
  break;
20977
21063
  case 'indents':
20978
- this.observer.notify(INDENT_TYPE, { subCommand: value, event: event, callBack: callBack, selector: selector });
21064
+ this.observer.notify(INDENT_TYPE, {
21065
+ subCommand: value, event: event, callBack: callBack,
21066
+ selector: selector, enterAction: enterAction
21067
+ });
20979
21068
  break;
20980
21069
  case 'links':
20981
21070
  this.observer.notify(LINK, { command: command, value: value, item: exeValue, event: event, callBack: callBack });
@@ -21921,25 +22010,54 @@ class HtmlEditor {
21921
22010
  this.deleteCleanup(e, currentRange);
21922
22011
  }
21923
22012
  if (args.keyCode === 9 && this.parent.enableTabKey) {
22013
+ this.parent.formatter.saveData(e);
21924
22014
  if (!isNullOrUndefined(args.target) && isNullOrUndefined(closest(args.target, '.e-rte-toolbar'))) {
21925
22015
  const range = this.nodeSelectionObj.getRange(this.contentRenderer.getDocument());
21926
22016
  const parentNode = this.nodeSelectionObj.getParentNodeCollection(range);
21927
22017
  if (!((parentNode[0].nodeName === 'LI' || closest(parentNode[0], 'li') ||
21928
- closest(parentNode[0], 'table')) && range.startOffset === 0)) {
22018
+ closest(parentNode[0], 'table')))) {
21929
22019
  args.preventDefault();
21930
- if (!args.shiftKey) {
21931
- InsertHtml.Insert(this.contentRenderer.getDocument(), '&nbsp;&nbsp;&nbsp;&nbsp;');
21932
- this.rangeCollection.push(this.nodeSelectionObj.getRange(this.contentRenderer.getDocument()));
22020
+ const selection = this.contentRenderer.getDocument().getSelection().getRangeAt(0);
22021
+ let alignmentNodes = this.parent.formatter.editorManager.domNode.blockNodes();
22022
+ if (this.parent.enterKey === 'BR') {
22023
+ if (selection.startOffset !== selection.endOffset && selection.startOffset === 0) {
22024
+ let save = this.nodeSelectionObj.save(range, this.contentRenderer.getDocument());
22025
+ this.parent.formatter.editorManager.domNode.setMarker(save);
22026
+ alignmentNodes = this.parent.formatter.editorManager.domNode.blockNodes();
22027
+ this.parent.formatter.editorManager.domNode.convertToBlockNodes(alignmentNodes, false);
22028
+ this.marginTabAdd(args.shiftKey, alignmentNodes);
22029
+ save = this.parent.formatter.editorManager.domNode.saveMarker(save);
22030
+ save.restore();
22031
+ }
22032
+ else {
22033
+ InsertHtml.Insert(this.contentRenderer.getDocument(), '&nbsp;&nbsp;&nbsp;&nbsp;');
22034
+ this.rangeCollection.push(this.nodeSelectionObj.getRange(this.contentRenderer.getDocument()));
22035
+ }
21933
22036
  }
21934
- else if (this.rangeCollection.length > 0 &&
21935
- this.rangeCollection[this.rangeCollection.length - 1].startContainer.textContent.length === 4) {
21936
- const textCont = this.rangeCollection[this.rangeCollection.length - 1].startContainer;
21937
- this.nodeSelectionObj.setSelectionText(this.contentRenderer.getDocument(), textCont, textCont, 0, textCont.textContent.length);
21938
- InsertHtml.Insert(this.contentRenderer.getDocument(), document.createTextNode(''));
21939
- this.rangeCollection.pop();
22037
+ else {
22038
+ if (!args.shiftKey) {
22039
+ if (selection.startOffset !== selection.endOffset && selection.startOffset === 0) {
22040
+ this.marginTabAdd(args.shiftKey, alignmentNodes);
22041
+ }
22042
+ else {
22043
+ InsertHtml.Insert(this.contentRenderer.getDocument(), '&nbsp;&nbsp;&nbsp;&nbsp;');
22044
+ this.rangeCollection.push(this.nodeSelectionObj.getRange(this.contentRenderer.getDocument()));
22045
+ }
22046
+ }
22047
+ else if (this.rangeCollection.length > 0 &&
22048
+ this.rangeCollection[this.rangeCollection.length - 1].startContainer.textContent.length === 4) {
22049
+ const textCont = this.rangeCollection[this.rangeCollection.length - 1].startContainer;
22050
+ this.nodeSelectionObj.setSelectionText(this.contentRenderer.getDocument(), textCont, textCont, 0, textCont.textContent.length);
22051
+ InsertHtml.Insert(this.contentRenderer.getDocument(), document.createTextNode(''));
22052
+ this.rangeCollection.pop();
22053
+ }
22054
+ else {
22055
+ this.marginTabAdd(args.shiftKey, alignmentNodes);
22056
+ }
21940
22057
  }
21941
22058
  }
21942
22059
  }
22060
+ this.parent.formatter.saveData(e);
21943
22061
  }
21944
22062
  if (e.args.action === 'space' ||
21945
22063
  e.args.action === 'enter' ||
@@ -22601,6 +22719,30 @@ class HtmlEditor {
22601
22719
  getSelectedHtml(e) {
22602
22720
  e.callBack(this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument()).toString());
22603
22721
  }
22722
+ marginTabAdd(val, alignmentNodes) {
22723
+ for (let index = 0; index < alignmentNodes.length; index++) {
22724
+ const element = alignmentNodes[index];
22725
+ if (element.closest('li')) {
22726
+ continue;
22727
+ }
22728
+ if (element.style.marginLeft) {
22729
+ let count$$1 = parseInt(element.style.marginLeft, 10);
22730
+ if (val) {
22731
+ count$$1 -= 20;
22732
+ }
22733
+ else {
22734
+ count$$1 += 20;
22735
+ }
22736
+ element.style.marginLeft = count$$1.toString() + 'px';
22737
+ if (element.style.marginLeft === '0px') {
22738
+ element.removeAttribute('style');
22739
+ }
22740
+ }
22741
+ else if (!val) {
22742
+ element.style.marginLeft = '20px';
22743
+ }
22744
+ }
22745
+ }
22604
22746
  }
22605
22747
 
22606
22748
  /**
@@ -23254,7 +23396,8 @@ class PasteCleanup {
23254
23396
  clipBoardElem = this.allowedStyle(clipBoardElem);
23255
23397
  }
23256
23398
  this.saveSelection.restore();
23257
- clipBoardElem.innerHTML = this.sanitizeHelper(clipBoardElem.innerHTML);
23399
+ const newText = clipBoardElem.innerHTML.split("&").join("&amp;");
23400
+ clipBoardElem.innerHTML = this.sanitizeHelper(newText);
23258
23401
  const allImg = clipBoardElem.querySelectorAll('img');
23259
23402
  for (let i = 0; i < allImg.length; i++) {
23260
23403
  if (!isNullOrUndefined(allImg[i].getAttribute('src'))) {
@@ -24162,9 +24305,6 @@ class FullScreen {
24162
24305
  && !isNullOrUndefined(this.parent.quickToolbarModule)) {
24163
24306
  this.parent.quickToolbarModule.hideQuickToolbars();
24164
24307
  }
24165
- if (this.parent.showTooltip && !isNullOrUndefined(document.querySelector('.e-tooltip-wrap'))) {
24166
- this.parent.notify(destroyTooltip, { args: event });
24167
- }
24168
24308
  this.scrollableParent = getScrollableParent(this.parent.element);
24169
24309
  if (!this.parent.element.classList.contains(CLS_FULL_SCREEN)) {
24170
24310
  const evenArgs = {
@@ -24216,9 +24356,6 @@ class FullScreen {
24216
24356
  && !isNullOrUndefined(this.parent.quickToolbarModule)) {
24217
24357
  this.parent.quickToolbarModule.hideQuickToolbars();
24218
24358
  }
24219
- if (this.parent.showTooltip && !isNullOrUndefined(document.querySelector('.e-tooltip-wrap'))) {
24220
- this.parent.notify(destroyTooltip, { args: event });
24221
- }
24222
24359
  if (this.parent.element.classList.contains(CLS_FULL_SCREEN)) {
24223
24360
  const evenArgs = {
24224
24361
  cancel: false,
@@ -26619,13 +26756,13 @@ class Image$1 {
26619
26756
  selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
26620
26757
  if (!originalEvent.ctrlKey && originalEvent.key && (originalEvent.key.length === 1 || originalEvent.action === 'enter') &&
26621
26758
  (!isNullOrUndefined(selectParentEle[0]) && selectParentEle[0].tagName === 'IMG') && selectParentEle[0].parentElement) {
26622
- const prev = selectParentEle[0].parentElement.childNodes[0];
26623
26759
  if (this.contentModule.getEditPanel().querySelector('.e-img-resize')) {
26624
26760
  this.removeResizeEle();
26625
26761
  }
26626
- this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), prev, prev, prev.textContent.length, prev.textContent.length);
26627
26762
  removeClass([selectParentEle[0]], 'e-img-focus');
26628
- this.quickToolObj.imageQTBar.hidePopup();
26763
+ if (this.quickToolObj && this.quickToolObj.imageQTBar) {
26764
+ this.quickToolObj.imageQTBar.hidePopup();
26765
+ }
26629
26766
  }
26630
26767
  }
26631
26768
  if (originalEvent.ctrlKey && (originalEvent.keyCode === 89 || originalEvent.keyCode === 90)) {
@@ -33403,16 +33540,18 @@ class EnterKeyAction {
33403
33540
  this.getRangeNode();
33404
33541
  let isTableEnter = true;
33405
33542
  this.formatTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote'];
33406
- const isCursorAtTableEnd = this.range.collapsed && (this.range.startContainer.nodeType === 1) &&
33407
- this.range.startContainer.isContentEditable &&
33408
- this.range.startContainer.childNodes[this.range.startOffset - 1] &&
33409
- this.range.startContainer.childNodes[this.range.startOffset - 1].nodeName === 'TABLE';
33410
- const isCursorAtTableStart = this.range.collapsed && (this.range.startContainer.nodeType === 1) &&
33411
- this.range.startContainer.isContentEditable && this.range.startContainer.childNodes[this.range.startOffset] &&
33412
- this.range.startContainer.childNodes[this.range.startOffset].nodeName === 'TABLE';
33413
- if (isCursorAtTableEnd || isCursorAtTableStart) {
33414
- this.handleCursorAtTableSide(e, isCursorAtTableStart, isCursorAtTableEnd);
33415
- return;
33543
+ const tableImagCursor = this.processedTableImageCursor();
33544
+ if (tableImagCursor.start || tableImagCursor.end) {
33545
+ if (tableImagCursor.startName === 'TABLE' || tableImagCursor.endName === 'TABLE') { // Default browser action prevented and hanled manually.
33546
+ this.handleCursorAtTableSide(e, tableImagCursor.start, tableImagCursor.end);
33547
+ return;
33548
+ }
33549
+ }
33550
+ if (tableImagCursor.start || tableImagCursor.end || this.range.startContainer.nodeName === 'IMG') {
33551
+ if (this.parent.enterKey === 'BR' && (tableImagCursor.startName === 'IMG' || tableImagCursor.endName === 'IMG' || this.range.startContainer.nodeName === 'IMG')) { // Default browser action prevented and hanled manually.
33552
+ this.handleEnterKeyAtImageSide(e, tableImagCursor.start, tableImagCursor.end);
33553
+ return;
33554
+ }
33416
33555
  }
33417
33556
  if (!isNullOrUndefined(this.startNode.closest('TABLE')) && !isNullOrUndefined(this.endNode.closest('TABLE'))) {
33418
33557
  isTableEnter = false;
@@ -33780,7 +33919,6 @@ class EnterKeyAction {
33780
33919
  const outerBRElem = this.parent.createElement('br');
33781
33920
  if (this.range.startOffset === 0 && this.range.endOffset === 0 &&
33782
33921
  !isNullOrUndefined(currentParent.previousSibling) && currentParent.previousSibling.nodeName === 'BR' && currentParent.nodeName !== 'P' && currentParent.nodeName !== 'DIV') {
33783
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33784
33922
  newElem = this.parent.formatter.editorManager.nodeCutter.SplitNode(this.range, currentParent, false).cloneNode(true);
33785
33923
  this.parent.formatter.editorManager.domNode.insertAfter(outerBRElem, currentParent);
33786
33924
  this.insertFocusContent();
@@ -33810,7 +33948,7 @@ class EnterKeyAction {
33810
33948
  }
33811
33949
  e.args.preventDefault();
33812
33950
  }
33813
- this.parent.trigger(actionComplete, { requestType: shiftKey ? 'ShiftEnterAction' : 'EnterAction', args: e.args });
33951
+ this.triggerActionComplete(e, shiftKey);
33814
33952
  }
33815
33953
  });
33816
33954
  }
@@ -33880,6 +34018,9 @@ class EnterKeyAction {
33880
34018
  }
33881
34019
  return insertElem;
33882
34020
  }
34021
+ triggerActionComplete(e, shiftKey) {
34022
+ this.parent.trigger(actionComplete, { requestType: shiftKey ? 'ShiftEnterAction' : 'EnterAction', args: e.args });
34023
+ }
33883
34024
  handleCursorAtTableSide(e, isStart, isEnd) {
33884
34025
  if (this.parent.enterKey !== 'BR') {
33885
34026
  const shiftKey = e.args.shiftKey;
@@ -33909,11 +34050,91 @@ class EnterKeyAction {
33909
34050
  }
33910
34051
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), newElement, 0);
33911
34052
  e.args.preventDefault();
33912
- this.parent.trigger(actionComplete, { requestType: shiftKey ? 'ShiftEnterAction' : 'EnterAction', args: e.args });
34053
+ this.triggerActionComplete(e, shiftKey);
33913
34054
  }
33914
34055
  });
33915
34056
  }
33916
34057
  }
34058
+ handleEnterKeyAtImageSide(e, isStart, isEnd) {
34059
+ const actionBeginArgs = {
34060
+ cancel: false,
34061
+ name: actionBegin,
34062
+ requestType: e.args.shiftKey ? 'ShiftEnterAction' : 'EnterAction',
34063
+ originalEvent: e.args
34064
+ };
34065
+ let directRange = false;
34066
+ if (this.range.startContainer.nodeName === 'IMG' && this.range.startOffset === 0) {
34067
+ directRange = true;
34068
+ }
34069
+ this.parent.trigger(actionBegin, actionBeginArgs, (actionBeginArgs) => {
34070
+ if (!actionBeginArgs.cancel) {
34071
+ if (this.parent.enterKey === 'BR') {
34072
+ const newElement = this.parent.createElement('BR');
34073
+ let imageElement;
34074
+ if (directRange) {
34075
+ imageElement = this.range.startContainer;
34076
+ imageElement.parentElement.insertBefore(newElement, imageElement);
34077
+ this.parent.formatter.editorManager.nodeSelection.
34078
+ setCursorPoint(this.parent.contentModule.getDocument(), imageElement, 0);
34079
+ }
34080
+ if (isStart) {
34081
+ imageElement = this.range.startContainer.childNodes[this.range.startOffset];
34082
+ imageElement.parentElement.insertBefore(newElement, imageElement);
34083
+ this.parent.formatter.editorManager.nodeSelection.
34084
+ setCursorPoint(this.parent.contentModule.getDocument(), imageElement, 0);
34085
+ }
34086
+ if (isEnd) {
34087
+ imageElement = this.range.startContainer.childNodes[this.range.startOffset - 1];
34088
+ if (!isNullOrUndefined(imageElement.nextSibling)) {
34089
+ imageElement.parentElement.insertBefore(newElement, imageElement.nextSibling);
34090
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), newElement.nextSibling, 0);
34091
+ }
34092
+ else if (isNullOrUndefined(imageElement.nextSibling)) {
34093
+ imageElement.parentElement.appendChild(newElement);
34094
+ const brElement = this.parent.createElement('BR');
34095
+ imageElement.parentElement.appendChild(brElement);
34096
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), brElement, 0);
34097
+ }
34098
+ }
34099
+ e.args.preventDefault();
34100
+ this.triggerActionComplete(e, e.args.shiftKey);
34101
+ }
34102
+ }
34103
+ });
34104
+ }
34105
+ isTableOrImageStart() {
34106
+ const customHandlerElements = ['IMG', 'TABLE'];
34107
+ const startContainer = this.range.startContainer;
34108
+ const startOffset = this.range.startOffset;
34109
+ const isCursorAtStart = this.range.collapsed && (startContainer.nodeType === 1) &&
34110
+ startContainer.isContentEditable && startContainer.childNodes[startOffset] &&
34111
+ (customHandlerElements.indexOf(startContainer.childNodes[startOffset].nodeName) > -1);
34112
+ if (isCursorAtStart) {
34113
+ return { start: isCursorAtStart, startNodeName: startContainer.childNodes[startOffset].nodeName };
34114
+ }
34115
+ else {
34116
+ return { start: false, startNodeName: '' };
34117
+ }
34118
+ }
34119
+ isTableOrImageEnd() {
34120
+ const customHandlerElements = ['IMG', 'TABLE'];
34121
+ const startContainer = this.range.startContainer;
34122
+ const startOffset = this.range.startOffset;
34123
+ const isCursorAtEnd = this.range.collapsed && (startContainer.nodeType === 1) &&
34124
+ startContainer.isContentEditable && startContainer.childNodes[startOffset - 1] &&
34125
+ (customHandlerElements.indexOf(startContainer.childNodes[startOffset - 1].nodeName) > -1);
34126
+ if (isCursorAtEnd) {
34127
+ return { end: isCursorAtEnd, endNodeName: startContainer.childNodes[startOffset - 1].nodeName };
34128
+ }
34129
+ else {
34130
+ return { end: false, endNodeName: '' };
34131
+ }
34132
+ }
34133
+ processedTableImageCursor() {
34134
+ const { start, startNodeName } = this.isTableOrImageStart();
34135
+ const { end, endNodeName } = this.isTableOrImageEnd();
34136
+ return { start, startName: startNodeName, end, endName: endNodeName };
34137
+ }
33917
34138
  }
33918
34139
 
33919
34140
  var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
@@ -35285,7 +35506,7 @@ let RichTextEditor = class RichTextEditor extends Component {
35285
35506
  }
35286
35507
  }
35287
35508
  updatePanelValue() {
35288
- let value = this.value;
35509
+ let value = this.listOrderCorrection(this.value);
35289
35510
  value = (this.enableHtmlEncode && this.value) ? decode(value) : value;
35290
35511
  const getTextArea = this.element.querySelector('.' + CLS_RTE_SOURCE_CODE_TXTAREA);
35291
35512
  if (value) {
@@ -35329,6 +35550,17 @@ let RichTextEditor = class RichTextEditor extends Component {
35329
35550
  this.countModule.refresh();
35330
35551
  }
35331
35552
  }
35553
+ listOrderCorrection(value) {
35554
+ const valueElementWrapper = this.createElement('div');
35555
+ valueElementWrapper.innerHTML = value;
35556
+ const listElements = valueElementWrapper.querySelectorAll('UL, OL');
35557
+ for (let i = 0; i < listElements.length; i++) {
35558
+ if (!isNullOrUndefined(listElements[i]) && !isNullOrUndefined(listElements[i].parentElement) && !isNullOrUndefined(listElements[i].previousElementSibling) && (listElements[i].parentElement.nodeName === 'UL' || listElements[i].parentElement.nodeName === 'OL')) {
35559
+ listElements[i].previousElementSibling.appendChild(listElements[i]);
35560
+ }
35561
+ }
35562
+ return valueElementWrapper.innerHTML;
35563
+ }
35332
35564
  setHeight(height) {
35333
35565
  if (height !== 'auto') {
35334
35566
  this.element.style.height = formatUnit(height);