@syncfusion/ej2-richtexteditor 26.1.41 → 26.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.
@@ -1,4 +1,4 @@
1
- import { isNullOrUndefined, Browser, addClass, removeClass, selectAll as selectAll$1, createElement, detach, SanitizeHtmlHelper, extend, EventHandler, closest, getInstance, formatUnit, select, Ajax, Property, Event, NotifyPropertyChanges, Base, KeyboardEvents as KeyboardEvents$1, setStyleAttribute, getUniqueID, append, debounce, Observer, prepend, attributes, getComponent, getEnumValue, ChildProperty, Complex, remove, print, L10n, compile, Touch, Component } from '@syncfusion/ej2-base';
1
+ import { isNullOrUndefined, Browser, addClass, removeClass, selectAll as selectAll$1, createElement, detach, SanitizeHtmlHelper, extend, EventHandler, closest, getInstance, formatUnit, select, Ajax, Property, Event, NotifyPropertyChanges, Base, KeyboardEvents as KeyboardEvents$1, setStyleAttribute, getUniqueID, append, debounce, Observer, prepend, attributes, getComponent, getEnumValue, ChildProperty, Complex, print, L10n, compile, Touch, Component } from '@syncfusion/ej2-base';
2
2
  import { Toolbar as Toolbar$1 } from '@syncfusion/ej2-navigations';
3
3
  import { DropDownButton } from '@syncfusion/ej2-splitbuttons';
4
4
  import { Tooltip, Popup, Dialog, isCollide, getScrollableParent } from '@syncfusion/ej2-popups';
@@ -8499,6 +8499,7 @@ var Image$1 = /** @__PURE__ @class */ (function () {
8499
8499
  var altText;
8500
8500
  var selectArgs;
8501
8501
  var filesData;
8502
+ var previousURL = null;
8502
8503
  this.uploadObj = new Uploader({
8503
8504
  asyncSettings: { saveUrl: this.parent.insertImageSettings.saveUrl, removeUrl: this.parent.insertImageSettings.removeUrl },
8504
8505
  dropArea: span, multiple: false, enableRtl: this.parent.enableRtl, cssClass: this.parent.getCssClass(),
@@ -8554,6 +8555,10 @@ var Image$1 = /** @__PURE__ @class */ (function () {
8554
8555
  _this.parent.trigger(imageUploadSuccess, e, function (e) {
8555
8556
  if (!isNullOrUndefined(_this.parent.insertImageSettings.path)) {
8556
8557
  var url = _this.parent.insertImageSettings.path + e.file.name;
8558
+ // Update the URL of the previously uploaded image
8559
+ if (!isNullOrUndefined(previousURL) && e.operation === 'upload') {
8560
+ proxy.imageRemovePost(previousURL);
8561
+ }
8557
8562
  proxy.uploadUrl = {
8558
8563
  url: url, selection: save, altText: altText, selectParent: selectParent,
8559
8564
  width: {
@@ -8565,6 +8570,7 @@ var Image$1 = /** @__PURE__ @class */ (function () {
8565
8570
  }
8566
8571
  };
8567
8572
  proxy.inputUrl.setAttribute('disabled', 'true');
8573
+ previousURL = url;
8568
8574
  }
8569
8575
  if (e.operation === 'upload' && !isNullOrUndefined(_this.dialogObj)) {
8570
8576
  _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
@@ -20092,13 +20098,11 @@ var MarkdownParser = /** @__PURE__ @class */ (function () {
20092
20098
  this.observer.on(KEY_DOWN, this.editorKeyDown, this);
20093
20099
  this.observer.on(KEY_UP, this.editorKeyUp, this);
20094
20100
  this.observer.on(MODEL_CHANGED, this.onPropertyChanged, this);
20095
- this.observer.on(INTERNAL_DESTROY, this.destroy, this);
20096
20101
  };
20097
20102
  MarkdownParser.prototype.unwireEvents = function () {
20098
20103
  this.observer.off(KEY_DOWN, this.editorKeyDown);
20099
20104
  this.observer.off(KEY_UP, this.editorKeyUp);
20100
20105
  this.observer.off(MODEL_CHANGED, this.onPropertyChanged);
20101
- this.observer.off(INTERNAL_DESTROY, this.destroy);
20102
20106
  };
20103
20107
  MarkdownParser.prototype.onPropertyChanged = function (props) {
20104
20108
  this.observer.notify(MODEL_CHANGED_PLUGIN, props);
@@ -20161,6 +20165,7 @@ var MarkdownParser = /** @__PURE__ @class */ (function () {
20161
20165
  }
20162
20166
  };
20163
20167
  MarkdownParser.prototype.destroy = function () {
20168
+ this.observer.notify(INTERNAL_DESTROY, {});
20164
20169
  this.unwireEvents();
20165
20170
  };
20166
20171
  return MarkdownParser;
@@ -23652,6 +23657,7 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
23652
23657
  return null;
23653
23658
  };
23654
23659
  InsertHtml.pasteInsertHTML = function (nodes, node, range, nodeSelection, nodeCutter, docElement, isCollapsed, closestParentNode, editNode, enterAction) {
23660
+ var _this = this;
23655
23661
  var isCursor = range.startOffset === range.endOffset &&
23656
23662
  range.startContainer === range.endContainer;
23657
23663
  if (isCursor && range.startContainer === editNode && editNode.textContent === '') {
@@ -23818,6 +23824,17 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
23818
23824
  else {
23819
23825
  this.cursorPos(lastSelectionNode, node, nodeSelection, docElement, editNode, enterAction);
23820
23826
  }
23827
+ var spanAligns = editNode.querySelectorAll('span[style*="text-align"]');
23828
+ if (spanAligns.length > 0) {
23829
+ spanAligns.forEach(function (spanAlign) {
23830
+ if (!isNullOrUndefined(spanAlign)) {
23831
+ var blockAlign = _this.getImmediateBlockNode(spanAlign, null);
23832
+ if (blockAlign && blockAlign.textContent.trim() === spanAlign.textContent.trim()) {
23833
+ blockAlign.style.textAlign = spanAlign.style.textAlign;
23834
+ }
23835
+ }
23836
+ });
23837
+ }
23821
23838
  };
23822
23839
  InsertHtml.placeCursorEnd = function (lastSelectionNode, node, nodeSelection, docElement, editNode) {
23823
23840
  lastSelectionNode = lastSelectionNode.nodeName === 'BR' ? (isNullOrUndefined(lastSelectionNode.previousSibling) ? lastSelectionNode.parentNode
@@ -30948,7 +30965,9 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
30948
30965
  focusNode = currentChildNode[0];
30949
30966
  }
30950
30967
  }
30951
- this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), focusNode, pointer);
30968
+ if (range.startContainer !== focusNode) {
30969
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), focusNode, pointer);
30970
+ }
30952
30971
  }
30953
30972
  var currentElem = this.parent.inputElement.querySelector('.currentStartMark');
30954
30973
  if (!isNullOrUndefined(currentElem)) {
@@ -31272,6 +31291,7 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
31272
31291
  }
31273
31292
  else if (brNode) {
31274
31293
  detach(brNode);
31294
+ e.args.preventDefault();
31275
31295
  }
31276
31296
  if (!isNullOrUndefined(this.deleteRangeElement) && (this.deleteOldRangeElement.tagName !== 'OL' && this.deleteOldRangeElement.tagName !== 'UL')
31277
31297
  && this.deleteOldRangeElement !== this.deleteRangeElement) {
@@ -31918,13 +31938,6 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
31918
31938
  e.args.preventDefault();
31919
31939
  this.pasteDialog(value, args, isClipboardHTMLDataNull);
31920
31940
  }
31921
- else if (Browser.userAgent.indexOf('Firefox') !== -1 && isNullOrUndefined(file)) {
31922
- this.fireFoxImageUpload();
31923
- }
31924
- }
31925
- else if (!isValueNotEmpty && !this.parent.pasteCleanupSettings.plainText &&
31926
- Browser.userAgent.indexOf('Firefox') !== -1) {
31927
- this.fireFoxImageUpload();
31928
31941
  }
31929
31942
  else if (this.parent.pasteCleanupSettings.plainText) {
31930
31943
  e.args.preventDefault();
@@ -31940,33 +31953,6 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
31940
31953
  }
31941
31954
  }
31942
31955
  };
31943
- PasteCleanup.prototype.fireFoxImageUpload = function () {
31944
- var _this = this;
31945
- this.fireFoxUploadTime = setTimeout(function () {
31946
- if (Browser.userAgent.indexOf('Firefox') !== -1) {
31947
- var currentFocusNode = _this.nodeSelectionObj.getRange(_this.contentRenderer.getDocument()).startContainer;
31948
- if (currentFocusNode.nodeName !== '#text') {
31949
- // eslint-disable-next-line
31950
- currentFocusNode = currentFocusNode.childNodes[_this.nodeSelectionObj.getRange(_this.contentRenderer.getDocument()).startOffset];
31951
- }
31952
- if (currentFocusNode.previousSibling.nodeName === 'IMG') {
31953
- if (!isNullOrUndefined(currentFocusNode.previousSibling.getAttribute('src'))) {
31954
- currentFocusNode.previousSibling.classList.add('pasteContent_Img');
31955
- }
31956
- currentFocusNode.previousSibling.classList.add(CLS_RTE_IMAGE);
31957
- if (_this.parent.insertImageSettings.display === 'inline') {
31958
- currentFocusNode.previousSibling.classList.add(CLS_IMGINLINE);
31959
- }
31960
- else {
31961
- currentFocusNode.previousSibling.classList.add(CLS_IMGBREAK);
31962
- }
31963
- currentFocusNode.previousSibling.classList.add();
31964
- _this.setImageProperties(currentFocusNode.previousSibling);
31965
- }
31966
- }
31967
- _this.imgUploading(_this.parent.inputElement);
31968
- }, 500);
31969
- };
31970
31956
  PasteCleanup.prototype.splitBreakLine = function (value) {
31971
31957
  var enterSplitText = value.split('\n');
31972
31958
  var contentInnerElem = '';
@@ -32180,11 +32166,22 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
32180
32166
  this.parent.inputElement.contentEditable = 'true';
32181
32167
  e.element = imgElem;
32182
32168
  e.detectImageSource = ImageInputSource.Pasted;
32183
- this.parent.trigger(imageUploadSuccess, e, function (e) {
32184
- if (!isNullOrUndefined(_this.parent.insertImageSettings.path)) {
32185
- var url = _this.parent.insertImageSettings.path + e.file.name;
32186
- imgElem.src = url;
32187
- imgElem.setAttribute('alt', e.file.name);
32169
+ uploadObj.filesData.forEach(function (element) {
32170
+ if (element.statusCode === '2') {
32171
+ _this.parent.trigger(imageUploadSuccess, e, function (e) {
32172
+ if (!isNullOrUndefined(_this.parent.insertImageSettings.path)) {
32173
+ var url = _this.parent.insertImageSettings.path + e.file.name;
32174
+ imgElem.src = url;
32175
+ imgElem.setAttribute('alt', e.file.name);
32176
+ }
32177
+ });
32178
+ }
32179
+ else if (element.statusCode === '5') {
32180
+ _this.parent.trigger(imageRemoving, e, function (e) {
32181
+ if (!isNullOrUndefined(e.element.src)) {
32182
+ e.element.src = '';
32183
+ }
32184
+ });
32188
32185
  }
32189
32186
  });
32190
32187
  popupObj.close();
@@ -36163,6 +36160,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
36163
36160
  function RichTextEditor(options, element) {
36164
36161
  var _this = _super.call(this, options, element) || this;
36165
36162
  _this.needsID = true;
36163
+ _this.isSelectAll = false;
36166
36164
  return _this;
36167
36165
  }
36168
36166
  /**
@@ -36851,7 +36849,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
36851
36849
  var preventingMention = false;
36852
36850
  if (this.editorMode === 'HTML') {
36853
36851
  var range = this.getRange();
36854
- preventingMention = !isNullOrUndefined(range.startContainer) && range.startContainer === range.endContainer && range.endContainer.childNodes.length > 1 && !isNullOrUndefined(range.startContainer.childNodes[range.startOffset - 1]) && range.startContainer.childNodes[range.startOffset - 1].nodeName === '#text' && !isNullOrUndefined(range.startContainer.childNodes[range.startOffset - 1].previousSibling) && range.startContainer.childNodes[range.startOffset - 1].textContent.charCodeAt(0) === 32 && range.startContainer.childNodes[1].previousSibling.classList.contains("e-mention-chip");
36852
+ preventingMention = !isNullOrUndefined(range.startContainer) && range.startContainer === range.endContainer && range.endContainer.childNodes.length > 1 && !isNullOrUndefined(range.startContainer.childNodes[range.startOffset - 1]) && range.startContainer.childNodes[range.startOffset - 1].nodeName === '#text' && !isNullOrUndefined(range.startContainer.childNodes[range.startOffset - 1].previousSibling) && range.startContainer.childNodes[range.startOffset - 1].textContent.charCodeAt(0) === 32 && range.startContainer.childNodes[range.startOffset - 1].previousSibling.classList.contains("e-mention-chip");
36855
36853
  }
36856
36854
  var keyboardEventAction = ['insert-link', 'format-copy', 'format-paste', 'insert-image', 'insert-table', 'insert-audio', 'insert-video'];
36857
36855
  if (keyboardEventAction.indexOf(e.action) === -1 &&
@@ -36895,6 +36893,15 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
36895
36893
  if (!isNullOrUndefined(this.placeholder)) {
36896
36894
  this.setPlaceHolder();
36897
36895
  }
36896
+ if (!isNullOrUndefined(e) && !isNullOrUndefined(e.code) && (e.code === 'Backspace' || e.code === 'Delete')) {
36897
+ var range = this.contentModule.getDocument().getSelection().getRangeAt(0);
36898
+ var div = document.createElement('div');
36899
+ div.appendChild(range.cloneContents());
36900
+ var selectedHTML = div.innerHTML;
36901
+ if (selectedHTML === this.inputElement.innerHTML) {
36902
+ this.isSelectAll = true;
36903
+ }
36904
+ }
36898
36905
  };
36899
36906
  RichTextEditor.prototype.keyUp = function (e) {
36900
36907
  if (this.editorMode === 'HTML') {
@@ -36904,6 +36911,10 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
36904
36911
  var currentRange = this.getRange();
36905
36912
  var selection = this.iframeSettings.enable ? this.contentModule.getPanel().ownerDocument.getSelection() :
36906
36913
  this.contentModule.getDocument().getSelection();
36914
+ if (this.isSelectAll) {
36915
+ this.inputElement.innerHTML = this.enterKey !== 'BR' ? '<' + this.enterKey + '><br></' + this.enterKey + '>' : '<br>';
36916
+ this.isSelectAll = false;
36917
+ }
36907
36918
  if (selection.rangeCount > 0) {
36908
36919
  selection.removeAllRanges();
36909
36920
  selection.addRange(currentRange);
@@ -37199,7 +37210,6 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
37199
37210
  removeClass([this.element], CLS_RTE_HIDDEN);
37200
37211
  }
37201
37212
  else {
37202
- remove(this.inputElement);
37203
37213
  if (this.originalElement.innerHTML.trim() !== '') {
37204
37214
  this.element.innerHTML = this.originalElement.innerHTML.trim();
37205
37215
  this.setProperties({ value: (!isNullOrUndefined(this.initialValue) ? this.initialValue : null) }, true);
@@ -37223,9 +37233,6 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
37223
37233
  }
37224
37234
  }
37225
37235
  }
37226
- if (this.inputElement) {
37227
- this.inputElement = null;
37228
- }
37229
37236
  if (this.rootContainer) {
37230
37237
  this.rootContainer = null;
37231
37238
  }