@syncfusion/ej2-richtexteditor 23.1.39 → 23.1.41

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.
@@ -3554,6 +3554,7 @@ class ToolbarRenderer {
3554
3554
  args.cancel = true;
3555
3555
  return;
3556
3556
  }
3557
+ proxy.parent.notify(selectionRestore, {});
3557
3558
  const element = (args.event) ? args.event.target : null;
3558
3559
  proxy.currentElement = dropDown.element;
3559
3560
  proxy.currentDropdown = dropDown;
@@ -3580,6 +3581,12 @@ class ToolbarRenderer {
3580
3581
  }
3581
3582
  args.element.tabIndex = -1;
3582
3583
  dropDown.element.removeAttribute('type');
3584
+ dropDown.element.onmousedown = () => {
3585
+ proxy.parent.notify(selectionSave, {});
3586
+ };
3587
+ dropDown.element.onkeydown = () => {
3588
+ proxy.parent.notify(selectionSave, {});
3589
+ };
3583
3590
  return dropDown;
3584
3591
  }
3585
3592
  // eslint-disable-next-line
@@ -7836,20 +7843,20 @@ class Formatter {
7836
7843
  }
7837
7844
  if (isNullOrUndefined(args)) {
7838
7845
  const action = event.action;
7846
+ args = {};
7847
+ const items = {
7848
+ originalEvent: event, cancel: false,
7849
+ requestType: action || (event.key + 'Key'),
7850
+ itemCollection: value
7851
+ };
7852
+ extend(args, args, items, true);
7839
7853
  if (action !== 'tab' && action !== 'enter' && action !== 'space' && action !== 'escape') {
7840
- args = {};
7841
7854
  if (self.editorMode === 'Markdown' && action === 'insert-table') {
7842
7855
  value = {
7843
7856
  'headingText': self.localeObj.getConstant('TableHeadingText'),
7844
7857
  'colText': self.localeObj.getConstant('TableColText')
7845
7858
  };
7846
7859
  }
7847
- const items = {
7848
- originalEvent: event, cancel: false,
7849
- requestType: action || (event.key + 'Key'),
7850
- itemCollection: value
7851
- };
7852
- extend(args, args, items, true);
7853
7860
  self.trigger(actionBegin, args, (actionBeginArgs) => {
7854
7861
  if (actionBeginArgs.cancel) {
7855
7862
  if (action === 'paste' || action === 'cut' || action === 'copy') {
@@ -7858,20 +7865,22 @@ class Formatter {
7858
7865
  }
7859
7866
  });
7860
7867
  }
7861
- const isTableModule = isNullOrUndefined(self.tableModule) ? true : self.tableModule ?
7862
- self.tableModule.ensureInsideTableList : false;
7863
- if ((event.which === 9 && isTableModule) || event.which !== 9) {
7864
- if (event.which === 13 && self.editorMode === 'HTML') {
7865
- value = {
7866
- 'enterAction': self.enterKey
7867
- };
7868
+ if (!args.cancel) {
7869
+ const isTableModule = isNullOrUndefined(self.tableModule) ? true : self.tableModule ?
7870
+ self.tableModule.ensureInsideTableList : false;
7871
+ if ((event.which === 9 && isTableModule) || event.which !== 9) {
7872
+ if (event.which === 13 && self.editorMode === 'HTML') {
7873
+ value = {
7874
+ 'enterAction': self.enterKey
7875
+ };
7876
+ }
7877
+ this.editorManager.observer.notify((event.type === 'keydown' ? KEY_DOWN : KEY_UP), {
7878
+ event: event,
7879
+ callBack: this.onSuccess.bind(this, self),
7880
+ value: value,
7881
+ enterAction: self.enterKey
7882
+ });
7868
7883
  }
7869
- this.editorManager.observer.notify((event.type === 'keydown' ? KEY_DOWN : KEY_UP), {
7870
- event: event,
7871
- callBack: this.onSuccess.bind(this, self),
7872
- value: value,
7873
- enterAction: self.enterKey
7874
- });
7875
7884
  }
7876
7885
  }
7877
7886
  else if (!isNullOrUndefined(args) && args.item.command && args.item.subCommand && ((args.item.command !== args.item.subCommand
@@ -12565,7 +12574,7 @@ class NodeCutter {
12565
12574
  node = parent.childNodes[index];
12566
12575
  fragment = this.spliceEmptyNode(fragment, false);
12567
12576
  if (fragment && fragment.childNodes.length > 0) {
12568
- const isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG'
12577
+ const isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG' && !(fragment.querySelectorAll('img').length > 0)
12569
12578
  && this.isRteElm(fragment) && fragment.textContent === '') ? true : false;
12570
12579
  if (!isEmpty) {
12571
12580
  if (node) {
@@ -13431,6 +13440,10 @@ class InsertHtml {
13431
13440
  : lastSelectionNode.previousSibling) : lastSelectionNode;
13432
13441
  while (!isNullOrUndefined(lastSelectionNode) && lastSelectionNode.nodeName !== '#text' && lastSelectionNode.nodeName !== 'IMG' &&
13433
13442
  lastSelectionNode.nodeName !== 'BR' && lastSelectionNode.nodeName !== 'HR') {
13443
+ if (!isNullOrUndefined(lastSelectionNode.lastChild) && (lastSelectionNode.lastChild.nodeName === 'P' && lastSelectionNode.lastChild.innerHTML === '')) {
13444
+ const lineBreak = createElement('br');
13445
+ lastSelectionNode.lastChild.appendChild(lineBreak);
13446
+ }
13434
13447
  lastSelectionNode = lastSelectionNode.lastChild;
13435
13448
  }
13436
13449
  lastSelectionNode = isNullOrUndefined(lastSelectionNode) ? node : lastSelectionNode;
@@ -17729,8 +17742,10 @@ class MsWordPaste {
17729
17742
  else {
17730
17743
  continue;
17731
17744
  }
17732
- isCroppedImage = this.extractCropValue('cropl', fullImg[i]) > 0 &&
17733
- this.extractCropValue('cropt', fullImg[i]) > 0 ? true : false;
17745
+ isCroppedImage = ((this.extractCropValue('cropl', fullImg[i]) > 0 &&
17746
+ this.extractCropValue('cropt', fullImg[i]) > 0) ||
17747
+ (this.extractCropValue('cropr', fullImg[i]) > 0 &&
17748
+ this.extractCropValue('cropb', fullImg[i]))) ? true : false;
17734
17749
  if (isCroppedImage) {
17735
17750
  goalWidth = this.extractCropValue('wgoal', fullImg[i]);
17736
17751
  goalHeight = this.extractCropValue('hgoal', fullImg[i]);
@@ -17757,7 +17772,7 @@ class MsWordPaste {
17757
17772
  }
17758
17773
  extractCropValue(crop, rtfData) {
17759
17774
  // eslint-disable-next-line security/detect-non-literal-regexp
17760
- const result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace('\r\n\\', '\\'))[1];
17775
+ const result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace(/\r\n\\/g, '\\'))[1];
17761
17776
  return parseInt(result, 10);
17762
17777
  }
17763
17778
  removeClassName(elm) {
@@ -19119,10 +19134,15 @@ class FormatPainterActions {
19119
19134
  return this.INVALID_TAGS.indexOf(node.tagName) > -1;
19120
19135
  }
19121
19136
  findCurrentContext(parentElem) {
19122
- if (closest(parentElem, 'p')) {
19137
+ const closestParagraph = closest(parentElem, 'p');
19138
+ const closestList = closest(parentElem, 'li');
19139
+ if (closestParagraph && !closestList) {
19123
19140
  return 'Text';
19124
19141
  }
19125
19142
  else if (closest(parentElem, 'li')) {
19143
+ if (!isNullOrUndefined(closestParagraph) && !isNullOrUndefined(closestList) && closestParagraph.textContent.trim() !== closestList.textContent.trim()) {
19144
+ return 'Text';
19145
+ }
19126
19146
  return 'List';
19127
19147
  }
19128
19148
  else if (closest(parentElem, 'td') || closest(parentElem, 'tr') || closest(parentElem, 'th')) {
@@ -19180,7 +19200,7 @@ class FormatPainterActions {
19180
19200
  const cloneElementNode = isNullOrUndefined(cloneListParentNode) ? element : element.firstChild;
19181
19201
  for (let index = 0; index < nodes.length; index++) {
19182
19202
  if (this.INVALID_TAGS.indexOf(nodes[index].nodeName) > -1 ||
19183
- nodes[index].querySelectorAll('a,img,audio,video,iframe').length > 0) {
19203
+ nodes[index].querySelectorAll('img,audio,video,iframe').length > 0) {
19184
19204
  continue;
19185
19205
  }
19186
19206
  const cloneParentNode = cloneElementNode.cloneNode(false);
@@ -20258,7 +20278,7 @@ class HtmlEditor {
20258
20278
  detach(currentChildNode[i]);
20259
20279
  i--;
20260
20280
  }
20261
- if (focusNode.textContent.replace(regEx, '') === currentChildNode[i].textContent) {
20281
+ if (!isNullOrUndefined(currentChildNode[i]) && focusNode.textContent.replace(regEx, '') === currentChildNode[i].textContent) {
20262
20282
  pointer = focusNode.textContent.length > 1 ?
20263
20283
  (focusNode.textContent === currentChildNode[i].textContent ? pointer :
20264
20284
  pointer - (focusNode.textContent.length - focusNode.textContent.replace(regEx, '').length)) :
@@ -29605,7 +29625,7 @@ class Table {
29605
29625
  }
29606
29626
  removeResizeElement() {
29607
29627
  const item = this.parent.contentModule.getEditPanel().
29608
- querySelectorAll('.e-column-resize, .e-row-resize, .e-table-box');
29628
+ querySelectorAll('.e-column-resize, .e-row-resize, .e-table-box, .e-table-rhelper');
29609
29629
  if (item.length > 0) {
29610
29630
  for (let i = 0; i < item.length; i++) {
29611
29631
  detach(item[i]);
@@ -31440,7 +31460,7 @@ class EnterKeyAction {
31440
31460
  }
31441
31461
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), insertElem.nextElementSibling, 0);
31442
31462
  }
31443
- else if (nearBlockNode.textContent.length === 0 && !(!isNullOrUndefined(nearBlockNode.childNodes[0]) && nearBlockNode.childNodes[0].nodeName === 'IMG')) {
31463
+ else if (nearBlockNode.textContent.length === 0 && !(!isNullOrUndefined(nearBlockNode.childNodes[0]) && nearBlockNode.childNodes[0].nodeName === 'IMG') && !(nearBlockNode.querySelectorAll('img').length > 0)) {
31444
31464
  if (!isNullOrUndefined(nearBlockNode.children[0]) && nearBlockNode.children[0].tagName !== 'BR') {
31445
31465
  const newElem = this.parent.formatter.editorManager.nodeCutter.SplitNode(this.range, nearBlockNode, false).cloneNode(true);
31446
31466
  this.parent.formatter.editorManager.domNode.insertAfter(newElem, nearBlockNode);
@@ -32378,13 +32398,13 @@ let RichTextEditor = class RichTextEditor extends Component {
32378
32398
  this.formatter.editorManager.nodeSelection.setCursorPoint(this.contentModule.getDocument(), range.startContainer, range.startOffset);
32379
32399
  }
32380
32400
  }
32381
- const notFormatPainterCopy = !isNullOrUndefined(e.action) && e.action !== 'format-copy';
32382
- if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy) {
32401
+ const notFormatPainterCopy = isNullOrUndefined(e.action) ? true : (e.action !== 'format-copy' ? true : false);
32402
+ if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy && !(e.altKey || e.shiftKey || (e.altKey && e.shiftKey && e.which == 67))) {
32383
32403
  this.formatter.saveData();
32384
32404
  }
32385
32405
  if (e.action !== 'insert-link' &&
32386
32406
  e.action !== 'format-copy' && e.action !== 'format-paste' &&
32387
- (!e.target || (e.target.classList.contains('e-mention') && e.code !== 'Tab')) &&
32407
+ (!e.target || !(e.target.classList.contains('e-mention') && e.code === 'Tab')) &&
32388
32408
  (e.action && e.action !== 'paste' && e.action !== 'space'
32389
32409
  || e.which === 9 || (e.code === 'Backspace' && e.which === 8))) {
32390
32410
  let FormatPainterEscapeAction = false;