@syncfusion/ej2-richtexteditor 23.1.43 → 23.2.4

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.
@@ -2897,7 +2897,7 @@ function setToolbarStatus(e, isPopToolbar, self) {
2897
2897
  var formatItems$$1 = e.parent.format.types;
2898
2898
  var formatContent = isNullOrUndefined(e.parent.format.default) ? formatItems$$1[0].text :
2899
2899
  e.parent.format.default;
2900
- result = getDropDownValue(formatItems$$1, value, 'subCommand', 'text');
2900
+ result = value === 'empty' ? '' : getDropDownValue(formatItems$$1, value, 'subCommand', 'text');
2901
2901
  dropDown.formatDropDown.content = ('<span style="display: inline-flex;' +
2902
2902
  'width:' + e.parent.format.width + '" >' +
2903
2903
  '<span class="e-rte-dropdown-btn-text' + (isNullOrUndefined(e.parent.cssClass) ? '' : ' ' + e.parent.cssClass) + '">'
@@ -2923,7 +2923,7 @@ function setToolbarStatus(e, isPopToolbar, self) {
2923
2923
  break;
2924
2924
  }
2925
2925
  var fontNameItems = e.parent.fontFamily.items;
2926
- result = getDropDownValue(fontNameItems, value, 'value', 'text');
2926
+ result = value === 'empty' ? '' : getDropDownValue(fontNameItems, value, 'value', 'text');
2927
2927
  var fontNameContent = isNullOrUndefined(e.parent.fontFamily.default) ? fontNameItems[0].text :
2928
2928
  e.parent.fontFamily.default;
2929
2929
  var name_1 = (isNullOrUndefined(result) ? fontNameContent : result);
@@ -2942,7 +2942,7 @@ function setToolbarStatus(e, isPopToolbar, self) {
2942
2942
  var fontSizeItems = e.parent.fontSize.items;
2943
2943
  var fontSizeContent = isNullOrUndefined(e.parent.fontSize.default) ? fontSizeItems[1].text :
2944
2944
  e.parent.fontSize.default;
2945
- result = getDropDownValue(fontSizeItems, (value === '' ? fontSizeContent.replace(/\s/g, '') : value), 'value', 'text');
2945
+ result = value === 'empty' ? '' : getDropDownValue(fontSizeItems, (value === '' ? fontSizeContent.replace(/\s/g, '') : value), 'value', 'text');
2946
2946
  dropDown.fontSizeDropDown.content = ('<span style="display: inline-flex;' +
2947
2947
  'width:' + e.parent.fontSize.width + '" >' +
2948
2948
  '<span class="e-rte-dropdown-btn-text' + (isNullOrUndefined(e.parent.cssClass) ? '' : ' ' + e.parent.cssClass) + '">'
@@ -13698,14 +13698,18 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
13698
13698
  };
13699
13699
  InsertHtml.removeEmptyElements = function (element) {
13700
13700
  var emptyElements = element.querySelectorAll(':empty');
13701
- 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++) {
13702
13706
  var lineWithDiv = true;
13703
- if (emptyElements[i].tagName === 'DIV') {
13704
- lineWithDiv = emptyElements[i].style.borderBottom === 'none' ||
13705
- 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;
13706
13710
  }
13707
- if (SELF_CLOSING_TAGS.indexOf(emptyElements[i].tagName.toLowerCase()) < 0 && lineWithDiv) {
13708
- 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]);
13709
13713
  if (!isNullOrUndefined(detachableElement)) {
13710
13714
  detach(detachableElement);
13711
13715
  }
@@ -13821,6 +13825,12 @@ var LinkCommand = /** @__PURE__ @class */ (function () {
13821
13825
  || e.event.keyCode === 13) || e.item.action === 'Paste' || range.collapsed || text) {
13822
13826
  var anchor = this.createAchorNode(e);
13823
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;
13824
13834
  e.item.selection.restore();
13825
13835
  InsertHtml.Insert(this.parent.currentDocument, anchor, this.parent.editableElement);
13826
13836
  if (e.event && e.event.type === 'keydown' && (e.event.keyCode === 32
@@ -16498,7 +16508,14 @@ var SelectionCommands = /** @__PURE__ @class */ (function () {
16498
16508
  }
16499
16509
  var formatNodeStyles = formatNode.getAttribute('style');
16500
16510
  var formatNodeTagName = formatNode.tagName;
16501
- var child = InsertMethods.unwrap(formatNode);
16511
+ var child;
16512
+ if (formatNodeTagName === 'A' && format === 'underline') {
16513
+ formatNode.style.textDecoration = 'none';
16514
+ child = [formatNode];
16515
+ }
16516
+ else {
16517
+ child = InsertMethods.unwrap(formatNode);
16518
+ }
16502
16519
  if (child[0] && !isFontStyle) {
16503
16520
  var nodeTraverse = child[index] ? child[index] : child[0];
16504
16521
  var textNode = nodeTraverse;
@@ -18613,12 +18630,18 @@ var ToolbarStatus = /** @__PURE__ @class */ (function () {
18613
18630
  if ((index === 0 && formatCollection.fontcolor) || !formatCollection.fontcolor) {
18614
18631
  nodeCollection.fontcolor = formatCollection.fontcolor;
18615
18632
  }
18616
- if ((index === 0 && formatCollection.fontname) || !formatCollection.fontname) {
18633
+ if (index === 0 && formatCollection.fontname) {
18617
18634
  nodeCollection.fontname = formatCollection.fontname;
18618
18635
  }
18619
- if ((index === 0 && formatCollection.fontsize) || !formatCollection.fontsize) {
18636
+ else {
18637
+ nodeCollection.fontname = formatCollection.fontname === nodeCollection.fontname ? formatCollection.fontname : 'empty';
18638
+ }
18639
+ if (index === 0 && formatCollection.fontsize) {
18620
18640
  nodeCollection.fontsize = formatCollection.fontsize;
18621
18641
  }
18642
+ else {
18643
+ nodeCollection.fontsize = formatCollection.fontsize === nodeCollection.fontsize ? formatCollection.fontsize : 'empty';
18644
+ }
18622
18645
  if ((index === 0 && formatCollection.backgroundcolor) || !formatCollection.backgroundcolor) {
18623
18646
  nodeCollection.backgroundcolor = formatCollection.backgroundcolor;
18624
18647
  }
@@ -18631,9 +18654,12 @@ var ToolbarStatus = /** @__PURE__ @class */ (function () {
18631
18654
  if ((index === 0 && formatCollection.alignments) || !formatCollection.alignments) {
18632
18655
  nodeCollection.alignments = formatCollection.alignments;
18633
18656
  }
18634
- if ((index === 0 && formatCollection.formats) || !formatCollection.formats) {
18657
+ if (index === 0 && formatCollection.formats) {
18635
18658
  nodeCollection.formats = formatCollection.formats;
18636
18659
  }
18660
+ else {
18661
+ nodeCollection.formats = formatCollection.formats === nodeCollection.formats ? formatCollection.formats : 'empty';
18662
+ }
18637
18663
  if ((index === 0 && formatCollection.createlink) || !formatCollection.createlink) {
18638
18664
  nodeCollection.createlink = formatCollection.createlink;
18639
18665
  }
@@ -25336,9 +25362,10 @@ var Image$1 = /** @__PURE__ @class */ (function () {
25336
25362
  var getAlt = (e.selectNode[0].getAttribute('alt') === null) ? '' :
25337
25363
  e.selectNode[0].getAttribute('alt');
25338
25364
  var content = '<div class="e-rte-field' + ' ' + this.parent.cssClass + '">' +
25339
- '<input type="text" spellcheck="false" value="' + getAlt + '" class="e-input e-img-alt' + ' ' + this.parent.cssClass + '" placeholder="' + altText + '"/>' +
25365
+ '<input type="text" spellcheck="false" class="e-input e-img-alt' + ' ' + this.parent.cssClass + '" placeholder="' + altText + '"/>' +
25340
25366
  '</div>';
25341
25367
  var contentElem = parseHtml(content);
25368
+ contentElem.querySelector('input').setAttribute('value', getAlt);
25342
25369
  altWrap.appendChild(contentElem);
25343
25370
  var inputAlt = altWrap.querySelector('.e-img-alt');
25344
25371
  var altArgs_1 = {
@@ -25874,14 +25901,12 @@ var Image$1 = /** @__PURE__ @class */ (function () {
25874
25901
  this.changedWidthValue = null;
25875
25902
  this.changedHeightValue = null;
25876
25903
  var content = '<div class="e-rte-label' + ' ' + this.parent.cssClass + '"><label>' + imgWidth +
25877
- '</label></div><div class="e-rte-field' + ' ' + this.parent.cssClass + '"><input type="text" id="imgwidth" class="e-img-width' + ' ' + this.parent.cssClass + '" value=' +
25878
- widthVal
25879
- + ' /></div>' +
25904
+ '</label></div><div class="e-rte-field' + ' ' + this.parent.cssClass + '"><input type="text" id="imgwidth" class="e-img-width' + ' ' + this.parent.cssClass + '/></div>' +
25880
25905
  '<div class="e-rte-label' + ' ' + this.parent.cssClass + '">' + '<label>' + imgHeight + '</label></div><div class="e-rte-field' + ' ' + this.parent.cssClass + '"> ' +
25881
- '<input type="text" id="imgheight" class="e-img-height' + ' ' + this.parent.cssClass + '" value=' +
25882
- heightVal
25883
- + ' /></div>';
25906
+ '<input type="text" id="imgheight" class="e-img-height' + ' ' + this.parent.cssClass + '"/></div>';
25884
25907
  var contentElem = parseHtml(content);
25908
+ contentElem.getElementById('imgwidth').setAttribute('value', widthVal);
25909
+ contentElem.getElementById('imgheight').setAttribute('value', heightVal);
25885
25910
  imgSizeWrap.appendChild(contentElem);
25886
25911
  this.widthNum = new TextBox({
25887
25912
  value: formatUnit(widthVal),
@@ -31995,6 +32020,14 @@ var EnterKeyAction = /** @__PURE__ @class */ (function () {
31995
32020
  else if ((this.parent.enterKey === 'P' && !shiftKey) || (this.parent.shiftEnterKey === 'P' && shiftKey)) {
31996
32021
  insertElem = this.parent.createElement('p');
31997
32022
  }
32023
+ var previousBlockNode = this.parent.formatter.editorManager.domNode.blockNodes()[0].previousSibling;
32024
+ var nextBlockNode = this.parent.formatter.editorManager.domNode.blockNodes()[0].nextSibling;
32025
+ if (!isNullOrUndefined(previousBlockNode) && previousBlockNode.hasAttribute('style')) {
32026
+ insertElem.setAttribute('style', previousBlockNode.getAttribute('style'));
32027
+ }
32028
+ if (isNullOrUndefined(previousBlockNode) && !isNullOrUndefined(nextBlockNode) && nextBlockNode.hasAttribute('style')) {
32029
+ insertElem.setAttribute('style', nextBlockNode.getAttribute('style'));
32030
+ }
31998
32031
  return insertElem;
31999
32032
  };
32000
32033
  return EnterKeyAction;