@syncfusion/ej2-richtexteditor 23.1.40 → 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.
@@ -3550,6 +3550,7 @@ var ToolbarRenderer = /** @__PURE__ @class */ (function () {
3550
3550
  args.cancel = true;
3551
3551
  return;
3552
3552
  }
3553
+ proxy.parent.notify(selectionRestore, {});
3553
3554
  var element = (args.event) ? args.event.target : null;
3554
3555
  proxy.currentElement = dropDown.element;
3555
3556
  proxy.currentDropdown = dropDown;
@@ -3576,6 +3577,12 @@ var ToolbarRenderer = /** @__PURE__ @class */ (function () {
3576
3577
  }
3577
3578
  args.element.tabIndex = -1;
3578
3579
  dropDown.element.removeAttribute('type');
3580
+ dropDown.element.onmousedown = function () {
3581
+ proxy.parent.notify(selectionSave, {});
3582
+ };
3583
+ dropDown.element.onkeydown = function () {
3584
+ proxy.parent.notify(selectionSave, {});
3585
+ };
3579
3586
  return dropDown;
3580
3587
  };
3581
3588
  // eslint-disable-next-line
@@ -7894,20 +7901,20 @@ var Formatter = /** @__PURE__ @class */ (function () {
7894
7901
  }
7895
7902
  if (isNullOrUndefined(args)) {
7896
7903
  var action_1 = event.action;
7904
+ args = {};
7905
+ var items = {
7906
+ originalEvent: event, cancel: false,
7907
+ requestType: action_1 || (event.key + 'Key'),
7908
+ itemCollection: value
7909
+ };
7910
+ extend(args, args, items, true);
7897
7911
  if (action_1 !== 'tab' && action_1 !== 'enter' && action_1 !== 'space' && action_1 !== 'escape') {
7898
- args = {};
7899
7912
  if (self.editorMode === 'Markdown' && action_1 === 'insert-table') {
7900
7913
  value = {
7901
7914
  'headingText': self.localeObj.getConstant('TableHeadingText'),
7902
7915
  'colText': self.localeObj.getConstant('TableColText')
7903
7916
  };
7904
7917
  }
7905
- var items = {
7906
- originalEvent: event, cancel: false,
7907
- requestType: action_1 || (event.key + 'Key'),
7908
- itemCollection: value
7909
- };
7910
- extend(args, args, items, true);
7911
7918
  self.trigger(actionBegin, args, function (actionBeginArgs) {
7912
7919
  if (actionBeginArgs.cancel) {
7913
7920
  if (action_1 === 'paste' || action_1 === 'cut' || action_1 === 'copy') {
@@ -7916,20 +7923,22 @@ var Formatter = /** @__PURE__ @class */ (function () {
7916
7923
  }
7917
7924
  });
7918
7925
  }
7919
- var isTableModule = isNullOrUndefined(self.tableModule) ? true : self.tableModule ?
7920
- self.tableModule.ensureInsideTableList : false;
7921
- if ((event.which === 9 && isTableModule) || event.which !== 9) {
7922
- if (event.which === 13 && self.editorMode === 'HTML') {
7923
- value = {
7924
- 'enterAction': self.enterKey
7925
- };
7926
+ if (!args.cancel) {
7927
+ var isTableModule = isNullOrUndefined(self.tableModule) ? true : self.tableModule ?
7928
+ self.tableModule.ensureInsideTableList : false;
7929
+ if ((event.which === 9 && isTableModule) || event.which !== 9) {
7930
+ if (event.which === 13 && self.editorMode === 'HTML') {
7931
+ value = {
7932
+ 'enterAction': self.enterKey
7933
+ };
7934
+ }
7935
+ this.editorManager.observer.notify((event.type === 'keydown' ? KEY_DOWN : KEY_UP), {
7936
+ event: event,
7937
+ callBack: this.onSuccess.bind(this, self),
7938
+ value: value,
7939
+ enterAction: self.enterKey
7940
+ });
7926
7941
  }
7927
- this.editorManager.observer.notify((event.type === 'keydown' ? KEY_DOWN : KEY_UP), {
7928
- event: event,
7929
- callBack: this.onSuccess.bind(this, self),
7930
- value: value,
7931
- enterAction: self.enterKey
7932
- });
7933
7942
  }
7934
7943
  }
7935
7944
  else if (!isNullOrUndefined(args) && args.item.command && args.item.subCommand && ((args.item.command !== args.item.subCommand
@@ -12659,7 +12668,7 @@ var NodeCutter = /** @__PURE__ @class */ (function () {
12659
12668
  node = parent_1.childNodes[index];
12660
12669
  fragment = this.spliceEmptyNode(fragment, false);
12661
12670
  if (fragment && fragment.childNodes.length > 0) {
12662
- var isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG'
12671
+ var isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG' && !(fragment.querySelectorAll('img').length > 0)
12663
12672
  && this.isRteElm(fragment) && fragment.textContent === '') ? true : false;
12664
12673
  if (!isEmpty) {
12665
12674
  if (node) {
@@ -13529,6 +13538,10 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
13529
13538
  : lastSelectionNode.previousSibling) : lastSelectionNode;
13530
13539
  while (!isNullOrUndefined(lastSelectionNode) && lastSelectionNode.nodeName !== '#text' && lastSelectionNode.nodeName !== 'IMG' &&
13531
13540
  lastSelectionNode.nodeName !== 'BR' && lastSelectionNode.nodeName !== 'HR') {
13541
+ if (!isNullOrUndefined(lastSelectionNode.lastChild) && (lastSelectionNode.lastChild.nodeName === 'P' && lastSelectionNode.lastChild.innerHTML === '')) {
13542
+ var lineBreak = createElement('br');
13543
+ lastSelectionNode.lastChild.appendChild(lineBreak);
13544
+ }
13532
13545
  lastSelectionNode = lastSelectionNode.lastChild;
13533
13546
  }
13534
13547
  lastSelectionNode = isNullOrUndefined(lastSelectionNode) ? node : lastSelectionNode;
@@ -17855,8 +17868,10 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17855
17868
  else {
17856
17869
  continue;
17857
17870
  }
17858
- isCroppedImage = this.extractCropValue('cropl', fullImg[i]) > 0 &&
17859
- this.extractCropValue('cropt', fullImg[i]) > 0 ? true : false;
17871
+ isCroppedImage = ((this.extractCropValue('cropl', fullImg[i]) > 0 &&
17872
+ this.extractCropValue('cropt', fullImg[i]) > 0) ||
17873
+ (this.extractCropValue('cropr', fullImg[i]) > 0 &&
17874
+ this.extractCropValue('cropb', fullImg[i]))) ? true : false;
17860
17875
  if (isCroppedImage) {
17861
17876
  goalWidth = this.extractCropValue('wgoal', fullImg[i]);
17862
17877
  goalHeight = this.extractCropValue('hgoal', fullImg[i]);
@@ -17883,7 +17898,7 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17883
17898
  };
17884
17899
  MsWordPaste.prototype.extractCropValue = function (crop, rtfData) {
17885
17900
  // eslint-disable-next-line security/detect-non-literal-regexp
17886
- var result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace('\r\n\\', '\\'))[1];
17901
+ var result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace(/\r\n\\/g, '\\'))[1];
17887
17902
  return parseInt(result, 10);
17888
17903
  };
17889
17904
  MsWordPaste.prototype.removeClassName = function (elm) {
@@ -19251,10 +19266,15 @@ var FormatPainterActions = /** @__PURE__ @class */ (function () {
19251
19266
  return this.INVALID_TAGS.indexOf(node.tagName) > -1;
19252
19267
  };
19253
19268
  FormatPainterActions.prototype.findCurrentContext = function (parentElem) {
19254
- if (closest(parentElem, 'p')) {
19269
+ var closestParagraph = closest(parentElem, 'p');
19270
+ var closestList = closest(parentElem, 'li');
19271
+ if (closestParagraph && !closestList) {
19255
19272
  return 'Text';
19256
19273
  }
19257
19274
  else if (closest(parentElem, 'li')) {
19275
+ if (!isNullOrUndefined(closestParagraph) && !isNullOrUndefined(closestList) && closestParagraph.textContent.trim() !== closestList.textContent.trim()) {
19276
+ return 'Text';
19277
+ }
19258
19278
  return 'List';
19259
19279
  }
19260
19280
  else if (closest(parentElem, 'td') || closest(parentElem, 'tr') || closest(parentElem, 'th')) {
@@ -19312,7 +19332,7 @@ var FormatPainterActions = /** @__PURE__ @class */ (function () {
19312
19332
  var cloneElementNode = isNullOrUndefined(cloneListParentNode) ? element : element.firstChild;
19313
19333
  for (var index = 0; index < nodes.length; index++) {
19314
19334
  if (this.INVALID_TAGS.indexOf(nodes[index].nodeName) > -1 ||
19315
- nodes[index].querySelectorAll('a,img,audio,video,iframe').length > 0) {
19335
+ nodes[index].querySelectorAll('img,audio,video,iframe').length > 0) {
19316
19336
  continue;
19317
19337
  }
19318
19338
  var cloneParentNode = cloneElementNode.cloneNode(false);
@@ -20332,7 +20352,7 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
20332
20352
  detach(currentChildNode[i]);
20333
20353
  i--;
20334
20354
  }
20335
- if (focusNode.textContent.replace(regEx, '') === currentChildNode[i].textContent) {
20355
+ if (!isNullOrUndefined(currentChildNode[i]) && focusNode.textContent.replace(regEx, '') === currentChildNode[i].textContent) {
20336
20356
  pointer = focusNode.textContent.length > 1 ?
20337
20357
  (focusNode.textContent === currentChildNode[i].textContent ? pointer :
20338
20358
  pointer - (focusNode.textContent.length - focusNode.textContent.replace(regEx, '').length)) :
@@ -31724,7 +31744,7 @@ var EnterKeyAction = /** @__PURE__ @class */ (function () {
31724
31744
  }
31725
31745
  _this.parent.formatter.editorManager.nodeSelection.setCursorPoint(_this.parent.contentModule.getDocument(), insertElem.nextElementSibling, 0);
31726
31746
  }
31727
- else if (nearBlockNode.textContent.length === 0 && !(!isNullOrUndefined(nearBlockNode.childNodes[0]) && nearBlockNode.childNodes[0].nodeName === 'IMG')) {
31747
+ else if (nearBlockNode.textContent.length === 0 && !(!isNullOrUndefined(nearBlockNode.childNodes[0]) && nearBlockNode.childNodes[0].nodeName === 'IMG') && !(nearBlockNode.querySelectorAll('img').length > 0)) {
31728
31748
  if (!isNullOrUndefined(nearBlockNode.children[0]) && nearBlockNode.children[0].tagName !== 'BR') {
31729
31749
  var newElem = _this.parent.formatter.editorManager.nodeCutter.SplitNode(_this.range, nearBlockNode, false).cloneNode(true);
31730
31750
  _this.parent.formatter.editorManager.domNode.insertAfter(newElem, nearBlockNode);
@@ -32690,13 +32710,13 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
32690
32710
  this.formatter.editorManager.nodeSelection.setCursorPoint(this.contentModule.getDocument(), range.startContainer, range.startOffset);
32691
32711
  }
32692
32712
  }
32693
- var notFormatPainterCopy = !isNullOrUndefined(e.action) && e.action !== 'format-copy';
32694
- if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy) {
32713
+ var notFormatPainterCopy = isNullOrUndefined(e.action) ? true : (e.action !== 'format-copy' ? true : false);
32714
+ if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy && !(e.altKey || e.shiftKey || (e.altKey && e.shiftKey && e.which == 67))) {
32695
32715
  this.formatter.saveData();
32696
32716
  }
32697
32717
  if (e.action !== 'insert-link' &&
32698
32718
  e.action !== 'format-copy' && e.action !== 'format-paste' &&
32699
- (!e.target || (e.target.classList.contains('e-mention') && e.code !== 'Tab')) &&
32719
+ (!e.target || !(e.target.classList.contains('e-mention') && e.code === 'Tab')) &&
32700
32720
  (e.action && e.action !== 'paste' && e.action !== 'space'
32701
32721
  || e.which === 9 || (e.code === 'Backspace' && e.which === 8))) {
32702
32722
  var FormatPainterEscapeAction = false;