@syncfusion/ej2-richtexteditor 23.1.41 → 23.1.44

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
  }
@@ -13696,14 +13698,18 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
13696
13698
  };
13697
13699
  InsertHtml.removeEmptyElements = function (element) {
13698
13700
  var emptyElements = element.querySelectorAll(':empty');
13699
- for (var i = 0; i < emptyElements.length; i++) {
13701
+ var nonSvgEmptyElements = Array.from(emptyElements).filter(function (element) {
13702
+ // Check if the element is an SVG element or an ancestor of an SVG element
13703
+ return !element.closest('svg') && !element.closest('canvas');
13704
+ });
13705
+ for (var i = 0; i < nonSvgEmptyElements.length; i++) {
13700
13706
  var lineWithDiv = true;
13701
- if (emptyElements[i].tagName === 'DIV') {
13702
- lineWithDiv = emptyElements[i].style.borderBottom === 'none' ||
13703
- emptyElements[i].style.borderBottom === '' ? true : false;
13707
+ if (nonSvgEmptyElements[i].tagName === 'DIV') {
13708
+ lineWithDiv = nonSvgEmptyElements[i].style.borderBottom === 'none' ||
13709
+ nonSvgEmptyElements[i].style.borderBottom === '' ? true : false;
13704
13710
  }
13705
- if (SELF_CLOSING_TAGS.indexOf(emptyElements[i].tagName.toLowerCase()) < 0 && lineWithDiv) {
13706
- var detachableElement = this.findDetachEmptyElem(emptyElements[i]);
13711
+ if (SELF_CLOSING_TAGS.indexOf(nonSvgEmptyElements[i].tagName.toLowerCase()) < 0 && lineWithDiv) {
13712
+ var detachableElement = this.findDetachEmptyElem(nonSvgEmptyElements[i]);
13707
13713
  if (!isNullOrUndefined(detachableElement)) {
13708
13714
  detach(detachableElement);
13709
13715
  }
@@ -13819,6 +13825,12 @@ var LinkCommand = /** @__PURE__ @class */ (function () {
13819
13825
  || e.event.keyCode === 13) || e.item.action === 'Paste' || range.collapsed || text) {
13820
13826
  var anchor = this.createAchorNode(e);
13821
13827
  anchor.innerText = e.item.text === '' ? e.item.url : e.item.text;
13828
+ var text_1 = anchor.innerText;
13829
+ // Replace spaces with non-breaking spaces
13830
+ var modifiedText = text_1.replace(/ +/g, function (match) {
13831
+ return '\u00A0'.repeat(match.length);
13832
+ });
13833
+ anchor.innerText = modifiedText;
13822
13834
  e.item.selection.restore();
13823
13835
  InsertHtml.Insert(this.parent.currentDocument, anchor, this.parent.editableElement);
13824
13836
  if (e.event && e.event.type === 'keydown' && (e.event.keyCode === 32
@@ -14009,7 +14021,7 @@ var LinkCommand = /** @__PURE__ @class */ (function () {
14009
14021
  for (var i = 0; i < blockNodes.length; i++) {
14010
14022
  var linkNode = blockNodes[i].querySelectorAll('a');
14011
14023
  for (var j = 0; j < linkNode.length; j++) {
14012
- if (document.getSelection().containsNode(linkNode[j], true)) {
14024
+ if (this.parent.currentDocument.getSelection().containsNode(linkNode[j], true)) {
14013
14025
  linkNode[j].outerHTML = linkNode[j].innerHTML;
14014
14026
  }
14015
14027
  }
@@ -17870,8 +17882,8 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17870
17882
  }
17871
17883
  isCroppedImage = ((this.extractCropValue('cropl', fullImg[i]) > 0 &&
17872
17884
  this.extractCropValue('cropt', fullImg[i]) > 0) ||
17873
- (this.extractCropValue('cropr', fullImg[i]) > 0 &&
17874
- this.extractCropValue('cropb', fullImg[i]))) ? true : false;
17885
+ this.extractCropValue('cropr', fullImg[i]) > 0 ||
17886
+ this.extractCropValue('cropb', fullImg[i])) ? true : false;
17875
17887
  if (isCroppedImage) {
17876
17888
  goalWidth = this.extractCropValue('wgoal', fullImg[i]);
17877
17889
  goalHeight = this.extractCropValue('hgoal', fullImg[i]);
@@ -17898,7 +17910,7 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17898
17910
  };
17899
17911
  MsWordPaste.prototype.extractCropValue = function (crop, rtfData) {
17900
17912
  // eslint-disable-next-line security/detect-non-literal-regexp
17901
- var result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace(/\r\n\\/g, '\\'))[1];
17913
+ var result = new RegExp('\\\\pic' + crop + '(\\-?\\d+)\\\\').exec(rtfData.replace(/\r\n\\/g, '\\').replace(/\n/g, '\\'))[1];
17902
17914
  return parseInt(result, 10);
17903
17915
  };
17904
17916
  MsWordPaste.prototype.removeClassName = function (elm) {
@@ -17937,6 +17949,10 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
17937
17949
  return removableElement;
17938
17950
  };
17939
17951
  MsWordPaste.prototype.removeUnwantedElements = function (elm) {
17952
+ var styleElm = elm.querySelector('style');
17953
+ if (!isNullOrUndefined(styleElm)) {
17954
+ detach(styleElm);
17955
+ }
17940
17956
  var innerElement = elm.innerHTML;
17941
17957
  for (var i = 0; i < this.removableElements.length; i++) {
17942
17958
  // eslint-disable-next-line security/detect-non-literal-regexp
@@ -18234,10 +18250,8 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
18234
18250
  }
18235
18251
  if (!isNullOrUndefined(listNodes[i].getAttribute('style'))) {
18236
18252
  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
- }
18253
+ listNodes[i].style.textIndent = '';
18254
+ currentListStyle = listNodes[i].getAttribute('style');
18241
18255
  }
18242
18256
  collection.push({
18243
18257
  listType: type, content: tempNode, nestedLevel: level, class: currentClassName,
@@ -18445,8 +18459,7 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
18445
18459
  }
18446
18460
  }
18447
18461
  prevList.setAttribute('class', collection[index].class);
18448
- var currentStyle = prevList.getAttribute('style');
18449
- prevList.setAttribute('style', (!isNullOrUndefined(currentStyle) ? currentStyle : ''));
18462
+ prevList.setAttribute('style', (!isNullOrUndefined(collection[index].listStyle) ? collection[index].listStyle : ''));
18450
18463
  pLevel = collection[index].nestedLevel;
18451
18464
  listCount++;
18452
18465
  if (!isNullOrUndefined(collection[index].start)) {
@@ -18894,7 +18907,7 @@ var EmojiPickerAction = /** @__PURE__ @class */ (function () {
18894
18907
  };
18895
18908
  EmojiPickerAction.prototype.emojiInsert = function (args) {
18896
18909
  var node = document.createTextNode(args.value);
18897
- var selection = window.getSelection();
18910
+ var selection = this.parent.currentDocument.getSelection();
18898
18911
  var range = selection.getRangeAt(0);
18899
18912
  var cursorPos = range.startOffset;
18900
18913
  for (var i = cursorPos - 1; i >= cursorPos - 15; i--) {
@@ -22934,7 +22947,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
22934
22947
  }
22935
22948
  else if (isNullOrUndefined(args.x) && isNullOrUndefined(args.y) && !this.parent.inlineMode.enable && isNullOrUndefined(this.parent.quickToolbarSettings.text)) {
22936
22949
  target = this.parent.inputElement;
22937
- if (window.getSelection().rangeCount > 0) {
22950
+ if (this.parent.contentModule.getDocument().getSelection().rangeCount > 0) {
22938
22951
  var coordinates = this.getCoordinates();
22939
22952
  xValue = coordinates.left;
22940
22953
  yValue = coordinates.top;
@@ -22942,7 +22955,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
22942
22955
  }
22943
22956
  else if (isNullOrUndefined(args.x) && isNullOrUndefined(args.y) && (this.parent.inlineMode.enable || !isNullOrUndefined(this.parent.quickToolbarSettings.text))) {
22944
22957
  this.parent.notify(hidePopup, {});
22945
- if (window.getSelection().rangeCount > 0) {
22958
+ if (this.parent.contentModule.getDocument().getSelection().rangeCount > 0) {
22946
22959
  var coordinates = this.getCoordinates();
22947
22960
  xValue = coordinates.left;
22948
22961
  yValue = coordinates.top;
@@ -23531,7 +23544,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
23531
23544
  };
23532
23545
  EmojiPicker.prototype.onkeyPress = function (e) {
23533
23546
  var originalEvent = e.args;
23534
- var selection = window.getSelection();
23547
+ var selection = this.parent.contentModule.getDocument().getSelection();
23535
23548
  if (selection.rangeCount <= 0) {
23536
23549
  return;
23537
23550
  }
@@ -23561,7 +23574,10 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
23561
23574
  };
23562
23575
  EmojiPicker.prototype.onkeyUp = function (e) {
23563
23576
  var originalEvent = e.args;
23564
- var selection = window.getSelection();
23577
+ var selection = this.parent.contentModule.getDocument().getSelection();
23578
+ if (selection.rangeCount <= 0) {
23579
+ return;
23580
+ }
23565
23581
  var range = selection.getRangeAt(0);
23566
23582
  var cursorPos = range.startOffset;
23567
23583
  // eslint-disable-next-line
@@ -23584,7 +23600,7 @@ var EmojiPicker = /** @__PURE__ @class */ (function () {
23584
23600
  };
23585
23601
  EmojiPicker.prototype.getCoordinates = function () {
23586
23602
  var coordinates;
23587
- var selection = window.getSelection();
23603
+ var selection = this.parent.contentModule.getDocument().getSelection();
23588
23604
  var range = selection.getRangeAt(0);
23589
23605
  var firstChild;
23590
23606
  if (range.startContainer.nodeName === 'P' || range.startContainer.nodeName === 'DIV') {
@@ -25330,9 +25346,10 @@ var Image$1 = /** @__PURE__ @class */ (function () {
25330
25346
  var getAlt = (e.selectNode[0].getAttribute('alt') === null) ? '' :
25331
25347
  e.selectNode[0].getAttribute('alt');
25332
25348
  var content = '<div class="e-rte-field' + ' ' + this.parent.cssClass + '">' +
25333
- '<input type="text" spellcheck="false" value="' + getAlt + '" class="e-input e-img-alt' + ' ' + this.parent.cssClass + '" placeholder="' + altText + '"/>' +
25349
+ '<input type="text" spellcheck="false" class="e-input e-img-alt' + ' ' + this.parent.cssClass + '" placeholder="' + altText + '"/>' +
25334
25350
  '</div>';
25335
25351
  var contentElem = parseHtml(content);
25352
+ contentElem.querySelector('input').setAttribute('value', getAlt);
25336
25353
  altWrap.appendChild(contentElem);
25337
25354
  var inputAlt = altWrap.querySelector('.e-img-alt');
25338
25355
  var altArgs_1 = {
@@ -25868,14 +25885,12 @@ var Image$1 = /** @__PURE__ @class */ (function () {
25868
25885
  this.changedWidthValue = null;
25869
25886
  this.changedHeightValue = null;
25870
25887
  var content = '<div class="e-rte-label' + ' ' + this.parent.cssClass + '"><label>' + imgWidth +
25871
- '</label></div><div class="e-rte-field' + ' ' + this.parent.cssClass + '"><input type="text" id="imgwidth" class="e-img-width' + ' ' + this.parent.cssClass + '" value=' +
25872
- widthVal
25873
- + ' /></div>' +
25888
+ '</label></div><div class="e-rte-field' + ' ' + this.parent.cssClass + '"><input type="text" id="imgwidth" class="e-img-width' + ' ' + this.parent.cssClass + '/></div>' +
25874
25889
  '<div class="e-rte-label' + ' ' + this.parent.cssClass + '">' + '<label>' + imgHeight + '</label></div><div class="e-rte-field' + ' ' + this.parent.cssClass + '"> ' +
25875
- '<input type="text" id="imgheight" class="e-img-height' + ' ' + this.parent.cssClass + '" value=' +
25876
- heightVal
25877
- + ' /></div>';
25890
+ '<input type="text" id="imgheight" class="e-img-height' + ' ' + this.parent.cssClass + '"/></div>';
25878
25891
  var contentElem = parseHtml(content);
25892
+ contentElem.getElementById('imgwidth').setAttribute('value', widthVal);
25893
+ contentElem.getElementById('imgheight').setAttribute('value', heightVal);
25879
25894
  imgSizeWrap.appendChild(contentElem);
25880
25895
  this.widthNum = new TextBox({
25881
25896
  value: formatUnit(widthVal),
@@ -31989,6 +32004,14 @@ var EnterKeyAction = /** @__PURE__ @class */ (function () {
31989
32004
  else if ((this.parent.enterKey === 'P' && !shiftKey) || (this.parent.shiftEnterKey === 'P' && shiftKey)) {
31990
32005
  insertElem = this.parent.createElement('p');
31991
32006
  }
32007
+ var previousBlockNode = this.parent.formatter.editorManager.domNode.blockNodes()[0].previousSibling;
32008
+ var nextBlockNode = this.parent.formatter.editorManager.domNode.blockNodes()[0].nextSibling;
32009
+ if (!isNullOrUndefined(previousBlockNode) && previousBlockNode.hasAttribute('style')) {
32010
+ insertElem.setAttribute('style', previousBlockNode.getAttribute('style'));
32011
+ }
32012
+ if (isNullOrUndefined(previousBlockNode) && !isNullOrUndefined(nextBlockNode) && nextBlockNode.hasAttribute('style')) {
32013
+ insertElem.setAttribute('style', nextBlockNode.getAttribute('style'));
32014
+ }
31992
32015
  return insertElem;
31993
32016
  };
31994
32017
  return EnterKeyAction;
@@ -32711,7 +32734,8 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
32711
32734
  }
32712
32735
  }
32713
32736
  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))) {
32737
+ if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy &&
32738
+ !(e.altKey || e.shiftKey || (e.altKey && e.shiftKey && e.which === 67))) {
32715
32739
  this.formatter.saveData();
32716
32740
  }
32717
32741
  if (e.action !== 'insert-link' &&
@@ -33831,8 +33855,8 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
33831
33855
  }
33832
33856
  else {
33833
33857
  if (target === 'windowResize' && heightPercent) {
33834
- // cntEle hide the borderBottom of RichTextEditor. so removed the 2px of cntEle height.
33835
- heightValue = parseInt(heightValue) - 2 + 'px';
33858
+ //cntEle hide the borderBottom of RichTextEditor. so removed the 2px of cntEle height.
33859
+ heightValue = parseInt(heightValue, 10) - 2 + 'px';
33836
33860
  }
33837
33861
  setStyleAttribute(cntEle, { height: heightValue, marginTop: topValue + 'px' });
33838
33862
  }
@@ -33856,7 +33880,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
33856
33880
  * @public
33857
33881
  */
33858
33882
  RichTextEditor.prototype.getHtml = function () {
33859
- var htmlValue = this.contentModule.getEditPanel().innerHTML;
33883
+ var htmlValue = this.removeResizeElement(this.contentModule.getEditPanel().innerHTML);
33860
33884
  return (this.enableXhtml && (htmlValue === '<p><br></p>' || htmlValue === '<div><br></div>' ||
33861
33885
  htmlValue === '<br>') ? null : this.serializeValue(htmlValue));
33862
33886
  };
@@ -33867,7 +33891,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
33867
33891
  * @public
33868
33892
  */
33869
33893
  RichTextEditor.prototype.getXhtml = function () {
33870
- var currentValue = this.value;
33894
+ var currentValue = this.removeResizeElement(this.value);
33871
33895
  if (!isNullOrUndefined(currentValue) && this.enableXhtml) {
33872
33896
  currentValue = this.htmlEditorModule.xhtmlValidation.selfEncloseValidation(currentValue);
33873
33897
  }
@@ -34108,14 +34132,11 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34108
34132
  };
34109
34133
  RichTextEditor.prototype.getUpdatedValue = function () {
34110
34134
  var value;
34111
- if (!isNullOrUndefined(this.tableModule)) {
34112
- this.tableModule.removeResizeElement();
34113
- }
34114
34135
  var getTextArea = this.element.querySelector('.e-rte-srctextarea');
34115
34136
  if (this.editorMode === 'HTML') {
34116
34137
  value = (this.inputElement.innerHTML === '<p><br></p>' || this.inputElement.innerHTML === '<div><br></div>' ||
34117
34138
  this.inputElement.innerHTML === '<br>') ? null : this.enableHtmlEncode ?
34118
- this.encode(decode(this.inputElement.innerHTML)) : this.inputElement.innerHTML;
34139
+ this.encode(decode(this.removeResizeElement(this.inputElement.innerHTML))) : this.inputElement.innerHTML;
34119
34140
  if (getTextArea && getTextArea.style.display === 'block') {
34120
34141
  value = getTextArea.value;
34121
34142
  }
@@ -34124,6 +34145,9 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34124
34145
  value = this.inputElement.value === '' ? null :
34125
34146
  this.inputElement.value;
34126
34147
  }
34148
+ if (value != null && !this.enableHtmlEncode) {
34149
+ value = this.removeResizeElement(value);
34150
+ }
34127
34151
  return value;
34128
34152
  };
34129
34153
  RichTextEditor.prototype.updateValueOnIdle = function () {
@@ -34139,6 +34163,17 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34139
34163
  clearTimeout(this.idleInterval);
34140
34164
  this.idleInterval = setTimeout(this.updateValueOnIdle.bind(this), 0);
34141
34165
  };
34166
+ RichTextEditor.prototype.removeResizeElement = function (value) {
34167
+ var valueElementWrapper = document.createElement("div");
34168
+ valueElementWrapper.innerHTML = value;
34169
+ var item = valueElementWrapper.querySelectorAll('.e-column-resize, .e-row-resize, .e-table-box, .e-table-rhelper, .e-img-resize');
34170
+ if (item.length > 0) {
34171
+ for (var i = 0; i < item.length; i++) {
34172
+ detach(item[i]);
34173
+ }
34174
+ }
34175
+ return valueElementWrapper.innerHTML;
34176
+ };
34142
34177
  RichTextEditor.prototype.updateStatus = function (e) {
34143
34178
  if (!isNullOrUndefined(e.html) || !isNullOrUndefined(e.markdown)) {
34144
34179
  var status_1 = this.formatter.editorManager.undoRedoManager.getUndoStatus();
@@ -34187,6 +34222,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34187
34222
  this.notify(focusChange, {});
34188
34223
  var value = this.getUpdatedValue();
34189
34224
  this.setProperties({ value: value });
34225
+ this.valueContainer.value = this.value;
34190
34226
  this.notify(toolbarRefresh, { args: e, documentNode: document });
34191
34227
  this.isValueChangeBlurhandler = true;
34192
34228
  this.invokeChangeEvent();