@syncfusion/ej2-richtexteditor 23.1.41 → 23.1.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.
@@ -3358,10 +3358,10 @@ var ToolbarRenderer = /** @__PURE__ @class */ (function () {
3358
3358
  if (!this.parent.enabled) {
3359
3359
  return;
3360
3360
  }
3361
+ this.parent.trigger('toolbarClick', args);
3361
3362
  if (!this.parent.readonly || isNullOrUndefined(args.item)) {
3362
3363
  this.parent.notify(toolbarClick, args);
3363
3364
  }
3364
- this.parent.trigger('toolbarClick', args);
3365
3365
  };
3366
3366
  ToolbarRenderer.prototype.dropDownSelected = function (args) {
3367
3367
  this.parent.notify(dropDownSelect, args);
@@ -4821,6 +4821,7 @@ var ToolbarAction = /** @__PURE__ @class */ (function () {
4821
4821
  */
4822
4822
  var Toolbar$2 = /** @__PURE__ @class */ (function () {
4823
4823
  function Toolbar$$1(parent, serviceLocator) {
4824
+ this.tools = {};
4824
4825
  this.parent = parent;
4825
4826
  this.isToolbar = false;
4826
4827
  this.locator = serviceLocator;
@@ -13538,7 +13539,8 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
13538
13539
  : lastSelectionNode.previousSibling) : lastSelectionNode;
13539
13540
  while (!isNullOrUndefined(lastSelectionNode) && lastSelectionNode.nodeName !== '#text' && lastSelectionNode.nodeName !== 'IMG' &&
13540
13541
  lastSelectionNode.nodeName !== 'BR' && lastSelectionNode.nodeName !== 'HR') {
13541
- if (!isNullOrUndefined(lastSelectionNode.lastChild) && (lastSelectionNode.lastChild.nodeName === 'P' && lastSelectionNode.lastChild.innerHTML === '')) {
13542
+ if (!isNullOrUndefined(lastSelectionNode.lastChild) && (lastSelectionNode.lastChild.nodeName === 'P' &&
13543
+ lastSelectionNode.lastChild.innerHTML === '')) {
13542
13544
  var lineBreak = createElement('br');
13543
13545
  lastSelectionNode.lastChild.appendChild(lineBreak);
13544
13546
  }
@@ -14009,7 +14011,7 @@ var LinkCommand = /** @__PURE__ @class */ (function () {
14009
14011
  for (var i = 0; i < blockNodes.length; i++) {
14010
14012
  var linkNode = blockNodes[i].querySelectorAll('a');
14011
14013
  for (var j = 0; j < linkNode.length; j++) {
14012
- if (document.getSelection().containsNode(linkNode[j], true)) {
14014
+ if (this.parent.currentDocument.getSelection().containsNode(linkNode[j], true)) {
14013
14015
  linkNode[j].outerHTML = linkNode[j].innerHTML;
14014
14016
  }
14015
14017
  }
@@ -17870,8 +17872,8 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17870
17872
  }
17871
17873
  isCroppedImage = ((this.extractCropValue('cropl', fullImg[i]) > 0 &&
17872
17874
  this.extractCropValue('cropt', fullImg[i]) > 0) ||
17873
- (this.extractCropValue('cropr', fullImg[i]) > 0 &&
17874
- this.extractCropValue('cropb', fullImg[i]))) ? true : false;
17875
+ this.extractCropValue('cropr', fullImg[i]) > 0 ||
17876
+ this.extractCropValue('cropb', fullImg[i])) ? true : false;
17875
17877
  if (isCroppedImage) {
17876
17878
  goalWidth = this.extractCropValue('wgoal', fullImg[i]);
17877
17879
  goalHeight = this.extractCropValue('hgoal', fullImg[i]);
@@ -17898,7 +17900,7 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17898
17900
  };
17899
17901
  MsWordPaste.prototype.extractCropValue = function (crop, rtfData) {
17900
17902
  // eslint-disable-next-line security/detect-non-literal-regexp
17901
- var result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace(/\r\n\\/g, '\\'))[1];
17903
+ var result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace(/\r\n\\/g, '\\').replace(/\n/g, '\\'))[1];
17902
17904
  return parseInt(result, 10);
17903
17905
  };
17904
17906
  MsWordPaste.prototype.removeClassName = function (elm) {
@@ -17937,6 +17939,10 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17937
17939
  return removableElement;
17938
17940
  };
17939
17941
  MsWordPaste.prototype.removeUnwantedElements = function (elm) {
17942
+ var styleElm = elm.querySelector('style');
17943
+ if (!isNullOrUndefined(styleElm)) {
17944
+ detach(styleElm);
17945
+ }
17940
17946
  var innerElement = elm.innerHTML;
17941
17947
  for (var i = 0; i < this.removableElements.length; i++) {
17942
17948
  // eslint-disable-next-line security/detect-non-literal-regexp
@@ -18234,10 +18240,8 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
18234
18240
  }
18235
18241
  if (!isNullOrUndefined(listNodes[i].getAttribute('style'))) {
18236
18242
  listNodes[i].setAttribute('style', listNodes[i].getAttribute('style').replace('text-align:start;', ''));
18237
- if (listNodes[i].style.textAlign !== '') {
18238
- listNodes[i].setAttribute('style', 'text-align:' + listNodes[i].style.textAlign);
18239
- currentListStyle = listNodes[i].getAttribute('style');
18240
- }
18243
+ listNodes[i].style.textIndent = '';
18244
+ currentListStyle = listNodes[i].getAttribute('style');
18241
18245
  }
18242
18246
  collection.push({
18243
18247
  listType: type, content: tempNode, nestedLevel: level, class: currentClassName,
@@ -18445,8 +18449,7 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
18445
18449
  }
18446
18450
  }
18447
18451
  prevList.setAttribute('class', collection[index].class);
18448
- var currentStyle = prevList.getAttribute('style');
18449
- prevList.setAttribute('style', (!isNullOrUndefined(currentStyle) ? currentStyle : ''));
18452
+ prevList.setAttribute('style', (!isNullOrUndefined(collection[index].listStyle) ? collection[index].listStyle : ''));
18450
18453
  pLevel = collection[index].nestedLevel;
18451
18454
  listCount++;
18452
18455
  if (!isNullOrUndefined(collection[index].start)) {
@@ -18894,7 +18897,7 @@ var EmojiPickerAction = /** @__PURE__ @class */ (function () {
18894
18897
  };
18895
18898
  EmojiPickerAction.prototype.emojiInsert = function (args) {
18896
18899
  var node = document.createTextNode(args.value);
18897
- var selection = window.getSelection();
18900
+ var selection = this.parent.currentDocument.getSelection();
18898
18901
  var range = selection.getRangeAt(0);
18899
18902
  var cursorPos = range.startOffset;
18900
18903
  for (var i = cursorPos - 1; i >= cursorPos - 15; i--) {
@@ -22934,7 +22937,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
22934
22937
  }
22935
22938
  else if (isNullOrUndefined(args.x) && isNullOrUndefined(args.y) && !this.parent.inlineMode.enable && isNullOrUndefined(this.parent.quickToolbarSettings.text)) {
22936
22939
  target = this.parent.inputElement;
22937
- if (window.getSelection().rangeCount > 0) {
22940
+ if (this.parent.contentModule.getDocument().getSelection().rangeCount > 0) {
22938
22941
  var coordinates = this.getCoordinates();
22939
22942
  xValue = coordinates.left;
22940
22943
  yValue = coordinates.top;
@@ -22942,7 +22945,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
22942
22945
  }
22943
22946
  else if (isNullOrUndefined(args.x) && isNullOrUndefined(args.y) && (this.parent.inlineMode.enable || !isNullOrUndefined(this.parent.quickToolbarSettings.text))) {
22944
22947
  this.parent.notify(hidePopup, {});
22945
- if (window.getSelection().rangeCount > 0) {
22948
+ if (this.parent.contentModule.getDocument().getSelection().rangeCount > 0) {
22946
22949
  var coordinates = this.getCoordinates();
22947
22950
  xValue = coordinates.left;
22948
22951
  yValue = coordinates.top;
@@ -23531,7 +23534,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
23531
23534
  };
23532
23535
  EmojiPicker.prototype.onkeyPress = function (e) {
23533
23536
  var originalEvent = e.args;
23534
- var selection = window.getSelection();
23537
+ var selection = this.parent.contentModule.getDocument().getSelection();
23535
23538
  if (selection.rangeCount <= 0) {
23536
23539
  return;
23537
23540
  }
@@ -23561,7 +23564,10 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
23561
23564
  };
23562
23565
  EmojiPicker.prototype.onkeyUp = function (e) {
23563
23566
  var originalEvent = e.args;
23564
- var selection = window.getSelection();
23567
+ var selection = this.parent.contentModule.getDocument().getSelection();
23568
+ if (selection.rangeCount <= 0) {
23569
+ return;
23570
+ }
23565
23571
  var range = selection.getRangeAt(0);
23566
23572
  var cursorPos = range.startOffset;
23567
23573
  // eslint-disable-next-line
@@ -23584,7 +23590,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
23584
23590
  };
23585
23591
  EmojiPicker.prototype.getCoordinates = function () {
23586
23592
  var coordinates;
23587
- var selection = window.getSelection();
23593
+ var selection = this.parent.contentModule.getDocument().getSelection();
23588
23594
  var range = selection.getRangeAt(0);
23589
23595
  var firstChild;
23590
23596
  if (range.startContainer.nodeName === 'P' || range.startContainer.nodeName === 'DIV') {
@@ -32711,7 +32717,8 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
32711
32717
  }
32712
32718
  }
32713
32719
  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))) {
32720
+ if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy &&
32721
+ !(e.altKey || e.shiftKey || (e.altKey && e.shiftKey && e.which === 67))) {
32715
32722
  this.formatter.saveData();
32716
32723
  }
32717
32724
  if (e.action !== 'insert-link' &&
@@ -33831,8 +33838,8 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
33831
33838
  }
33832
33839
  else {
33833
33840
  if (target === 'windowResize' && heightPercent) {
33834
- // cntEle hide the borderBottom of RichTextEditor. so removed the 2px of cntEle height.
33835
- heightValue = parseInt(heightValue) - 2 + 'px';
33841
+ //cntEle hide the borderBottom of RichTextEditor. so removed the 2px of cntEle height.
33842
+ heightValue = parseInt(heightValue, 10) - 2 + 'px';
33836
33843
  }
33837
33844
  setStyleAttribute(cntEle, { height: heightValue, marginTop: topValue + 'px' });
33838
33845
  }
@@ -33856,7 +33863,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
33856
33863
  * @public
33857
33864
  */
33858
33865
  RichTextEditor.prototype.getHtml = function () {
33859
- var htmlValue = this.contentModule.getEditPanel().innerHTML;
33866
+ var htmlValue = this.removeResizeElement(this.contentModule.getEditPanel().innerHTML);
33860
33867
  return (this.enableXhtml && (htmlValue === '<p><br></p>' || htmlValue === '<div><br></div>' ||
33861
33868
  htmlValue === '<br>') ? null : this.serializeValue(htmlValue));
33862
33869
  };
@@ -33867,7 +33874,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
33867
33874
  * @public
33868
33875
  */
33869
33876
  RichTextEditor.prototype.getXhtml = function () {
33870
- var currentValue = this.value;
33877
+ var currentValue = this.removeResizeElement(this.value);
33871
33878
  if (!isNullOrUndefined(currentValue) && this.enableXhtml) {
33872
33879
  currentValue = this.htmlEditorModule.xhtmlValidation.selfEncloseValidation(currentValue);
33873
33880
  }
@@ -34108,14 +34115,11 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34108
34115
  };
34109
34116
  RichTextEditor.prototype.getUpdatedValue = function () {
34110
34117
  var value;
34111
- if (!isNullOrUndefined(this.tableModule)) {
34112
- this.tableModule.removeResizeElement();
34113
- }
34114
34118
  var getTextArea = this.element.querySelector('.e-rte-srctextarea');
34115
34119
  if (this.editorMode === 'HTML') {
34116
34120
  value = (this.inputElement.innerHTML === '<p><br></p>' || this.inputElement.innerHTML === '<div><br></div>' ||
34117
34121
  this.inputElement.innerHTML === '<br>') ? null : this.enableHtmlEncode ?
34118
- this.encode(decode(this.inputElement.innerHTML)) : this.inputElement.innerHTML;
34122
+ this.encode(decode(this.removeResizeElement(this.inputElement.innerHTML))) : this.inputElement.innerHTML;
34119
34123
  if (getTextArea && getTextArea.style.display === 'block') {
34120
34124
  value = getTextArea.value;
34121
34125
  }
@@ -34124,6 +34128,9 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34124
34128
  value = this.inputElement.value === '' ? null :
34125
34129
  this.inputElement.value;
34126
34130
  }
34131
+ if (value != null && !this.enableHtmlEncode) {
34132
+ value = this.removeResizeElement(value);
34133
+ }
34127
34134
  return value;
34128
34135
  };
34129
34136
  RichTextEditor.prototype.updateValueOnIdle = function () {
@@ -34139,6 +34146,17 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34139
34146
  clearTimeout(this.idleInterval);
34140
34147
  this.idleInterval = setTimeout(this.updateValueOnIdle.bind(this), 0);
34141
34148
  };
34149
+ RichTextEditor.prototype.removeResizeElement = function (value) {
34150
+ var valueElementWrapper = document.createElement("div");
34151
+ valueElementWrapper.innerHTML = value;
34152
+ var item = valueElementWrapper.querySelectorAll('.e-column-resize, .e-row-resize, .e-table-box, .e-table-rhelper, .e-img-resize');
34153
+ if (item.length > 0) {
34154
+ for (var i = 0; i < item.length; i++) {
34155
+ detach(item[i]);
34156
+ }
34157
+ }
34158
+ return valueElementWrapper.innerHTML;
34159
+ };
34142
34160
  RichTextEditor.prototype.updateStatus = function (e) {
34143
34161
  if (!isNullOrUndefined(e.html) || !isNullOrUndefined(e.markdown)) {
34144
34162
  var status_1 = this.formatter.editorManager.undoRedoManager.getUndoStatus();
@@ -34187,6 +34205,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34187
34205
  this.notify(focusChange, {});
34188
34206
  var value = this.getUpdatedValue();
34189
34207
  this.setProperties({ value: value });
34208
+ this.valueContainer.value = this.value;
34190
34209
  this.notify(toolbarRefresh, { args: e, documentNode: document });
34191
34210
  this.isValueChangeBlurhandler = true;
34192
34211
  this.invokeChangeEvent();