@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, Base, Property, Event, NotifyPropertyChanges, KeyboardEvents as KeyboardEvents$1, setStyleAttribute, getUniqueID, append, debounce, Observer, prepend, attributes, getComponent, getEnumValue, Complex, ChildProperty, Component, remove, print, L10n, compile, Touch } from '@syncfusion/ej2-base';
1
+ import { isNullOrUndefined, Browser, addClass, removeClass, selectAll as selectAll$1, createElement, detach, SanitizeHtmlHelper, extend, EventHandler, closest, getInstance, formatUnit, select, Ajax, Base, Property, Event, NotifyPropertyChanges, KeyboardEvents as KeyboardEvents$1, setStyleAttribute, getUniqueID, append, debounce, Observer, prepend, attributes, getComponent, getEnumValue, Complex, ChildProperty, Component, print, L10n, compile, Touch } 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';
@@ -8475,6 +8475,7 @@ class Image$1 {
8475
8475
  let altText;
8476
8476
  let selectArgs;
8477
8477
  let filesData;
8478
+ let previousURL = null;
8478
8479
  this.uploadObj = new Uploader({
8479
8480
  asyncSettings: { saveUrl: this.parent.insertImageSettings.saveUrl, removeUrl: this.parent.insertImageSettings.removeUrl },
8480
8481
  dropArea: span, multiple: false, enableRtl: this.parent.enableRtl, cssClass: this.parent.getCssClass(),
@@ -8530,6 +8531,10 @@ class Image$1 {
8530
8531
  this.parent.trigger(imageUploadSuccess, e, (e) => {
8531
8532
  if (!isNullOrUndefined(this.parent.insertImageSettings.path)) {
8532
8533
  const url = this.parent.insertImageSettings.path + e.file.name;
8534
+ // Update the URL of the previously uploaded image
8535
+ if (!isNullOrUndefined(previousURL) && e.operation === 'upload') {
8536
+ proxy.imageRemovePost(previousURL);
8537
+ }
8533
8538
  proxy.uploadUrl = {
8534
8539
  url: url, selection: save, altText: altText, selectParent: selectParent,
8535
8540
  width: {
@@ -8541,6 +8546,7 @@ class Image$1 {
8541
8546
  }
8542
8547
  };
8543
8548
  proxy.inputUrl.setAttribute('disabled', 'true');
8549
+ previousURL = url;
8544
8550
  }
8545
8551
  if (e.operation === 'upload' && !isNullOrUndefined(this.dialogObj)) {
8546
8552
  this.dialogObj.getButtons(0).element.removeAttribute('disabled');
@@ -20064,13 +20070,11 @@ class MarkdownParser {
20064
20070
  this.observer.on(KEY_DOWN, this.editorKeyDown, this);
20065
20071
  this.observer.on(KEY_UP, this.editorKeyUp, this);
20066
20072
  this.observer.on(MODEL_CHANGED, this.onPropertyChanged, this);
20067
- this.observer.on(INTERNAL_DESTROY, this.destroy, this);
20068
20073
  }
20069
20074
  unwireEvents() {
20070
20075
  this.observer.off(KEY_DOWN, this.editorKeyDown);
20071
20076
  this.observer.off(KEY_UP, this.editorKeyUp);
20072
20077
  this.observer.off(MODEL_CHANGED, this.onPropertyChanged);
20073
- this.observer.off(INTERNAL_DESTROY, this.destroy);
20074
20078
  }
20075
20079
  onPropertyChanged(props) {
20076
20080
  this.observer.notify(MODEL_CHANGED_PLUGIN, props);
@@ -20133,6 +20137,7 @@ class MarkdownParser {
20133
20137
  }
20134
20138
  }
20135
20139
  destroy() {
20140
+ this.observer.notify(INTERNAL_DESTROY, {});
20136
20141
  this.unwireEvents();
20137
20142
  }
20138
20143
  }
@@ -23762,6 +23767,17 @@ class InsertHtml {
23762
23767
  else {
23763
23768
  this.cursorPos(lastSelectionNode, node, nodeSelection, docElement, editNode, enterAction);
23764
23769
  }
23770
+ const spanAligns = editNode.querySelectorAll('span[style*="text-align"]');
23771
+ if (spanAligns.length > 0) {
23772
+ spanAligns.forEach((spanAlign) => {
23773
+ if (!isNullOrUndefined(spanAlign)) {
23774
+ const blockAlign = this.getImmediateBlockNode(spanAlign, null);
23775
+ if (blockAlign && blockAlign.textContent.trim() === spanAlign.textContent.trim()) {
23776
+ blockAlign.style.textAlign = spanAlign.style.textAlign;
23777
+ }
23778
+ }
23779
+ });
23780
+ }
23765
23781
  }
23766
23782
  static placeCursorEnd(lastSelectionNode, node, nodeSelection, docElement, editNode) {
23767
23783
  lastSelectionNode = lastSelectionNode.nodeName === 'BR' ? (isNullOrUndefined(lastSelectionNode.previousSibling) ? lastSelectionNode.parentNode
@@ -30838,7 +30854,9 @@ class HtmlEditor {
30838
30854
  focusNode = currentChildNode[0];
30839
30855
  }
30840
30856
  }
30841
- this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), focusNode, pointer);
30857
+ if (range.startContainer !== focusNode) {
30858
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), focusNode, pointer);
30859
+ }
30842
30860
  }
30843
30861
  const currentElem = this.parent.inputElement.querySelector('.currentStartMark');
30844
30862
  if (!isNullOrUndefined(currentElem)) {
@@ -31161,6 +31179,7 @@ class HtmlEditor {
31161
31179
  }
31162
31180
  else if (brNode) {
31163
31181
  detach(brNode);
31182
+ e.args.preventDefault();
31164
31183
  }
31165
31184
  if (!isNullOrUndefined(this.deleteRangeElement) && (this.deleteOldRangeElement.tagName !== 'OL' && this.deleteOldRangeElement.tagName !== 'UL')
31166
31185
  && this.deleteOldRangeElement !== this.deleteRangeElement) {
@@ -31804,13 +31823,6 @@ class PasteCleanup {
31804
31823
  e.args.preventDefault();
31805
31824
  this.pasteDialog(value, args, isClipboardHTMLDataNull);
31806
31825
  }
31807
- else if (Browser.userAgent.indexOf('Firefox') !== -1 && isNullOrUndefined(file)) {
31808
- this.fireFoxImageUpload();
31809
- }
31810
- }
31811
- else if (!isValueNotEmpty && !this.parent.pasteCleanupSettings.plainText &&
31812
- Browser.userAgent.indexOf('Firefox') !== -1) {
31813
- this.fireFoxImageUpload();
31814
31826
  }
31815
31827
  else if (this.parent.pasteCleanupSettings.plainText) {
31816
31828
  e.args.preventDefault();
@@ -31826,32 +31838,6 @@ class PasteCleanup {
31826
31838
  }
31827
31839
  }
31828
31840
  }
31829
- fireFoxImageUpload() {
31830
- this.fireFoxUploadTime = setTimeout(() => {
31831
- if (Browser.userAgent.indexOf('Firefox') !== -1) {
31832
- let currentFocusNode = this.nodeSelectionObj.getRange(this.contentRenderer.getDocument()).startContainer;
31833
- if (currentFocusNode.nodeName !== '#text') {
31834
- // eslint-disable-next-line
31835
- currentFocusNode = currentFocusNode.childNodes[this.nodeSelectionObj.getRange(this.contentRenderer.getDocument()).startOffset];
31836
- }
31837
- if (currentFocusNode.previousSibling.nodeName === 'IMG') {
31838
- if (!isNullOrUndefined(currentFocusNode.previousSibling.getAttribute('src'))) {
31839
- currentFocusNode.previousSibling.classList.add('pasteContent_Img');
31840
- }
31841
- currentFocusNode.previousSibling.classList.add(CLS_RTE_IMAGE);
31842
- if (this.parent.insertImageSettings.display === 'inline') {
31843
- currentFocusNode.previousSibling.classList.add(CLS_IMGINLINE);
31844
- }
31845
- else {
31846
- currentFocusNode.previousSibling.classList.add(CLS_IMGBREAK);
31847
- }
31848
- currentFocusNode.previousSibling.classList.add();
31849
- this.setImageProperties(currentFocusNode.previousSibling);
31850
- }
31851
- }
31852
- this.imgUploading(this.parent.inputElement);
31853
- }, 500);
31854
- }
31855
31841
  splitBreakLine(value) {
31856
31842
  const enterSplitText = value.split('\n');
31857
31843
  let contentInnerElem = '';
@@ -32063,11 +32049,22 @@ class PasteCleanup {
32063
32049
  this.parent.inputElement.contentEditable = 'true';
32064
32050
  e.element = imgElem;
32065
32051
  e.detectImageSource = ImageInputSource.Pasted;
32066
- this.parent.trigger(imageUploadSuccess, e, (e) => {
32067
- if (!isNullOrUndefined(this.parent.insertImageSettings.path)) {
32068
- const url = this.parent.insertImageSettings.path + e.file.name;
32069
- imgElem.src = url;
32070
- imgElem.setAttribute('alt', e.file.name);
32052
+ uploadObj.filesData.forEach((element) => {
32053
+ if (element.statusCode === '2') {
32054
+ this.parent.trigger(imageUploadSuccess, e, (e) => {
32055
+ if (!isNullOrUndefined(this.parent.insertImageSettings.path)) {
32056
+ const url = this.parent.insertImageSettings.path + e.file.name;
32057
+ imgElem.src = url;
32058
+ imgElem.setAttribute('alt', e.file.name);
32059
+ }
32060
+ });
32061
+ }
32062
+ else if (element.statusCode === '5') {
32063
+ this.parent.trigger(imageRemoving, e, (e) => {
32064
+ if (!isNullOrUndefined(e.element.src)) {
32065
+ e.element.src = '';
32066
+ }
32067
+ });
32071
32068
  }
32072
32069
  });
32073
32070
  popupObj.close();
@@ -35854,6 +35851,7 @@ let RichTextEditor = class RichTextEditor extends Component {
35854
35851
  constructor(options, element) {
35855
35852
  super(options, element);
35856
35853
  this.needsID = true;
35854
+ this.isSelectAll = false;
35857
35855
  }
35858
35856
  /**
35859
35857
  * To provide the array of modules needed for component rendering
@@ -36540,7 +36538,7 @@ let RichTextEditor = class RichTextEditor extends Component {
36540
36538
  let preventingMention = false;
36541
36539
  if (this.editorMode === 'HTML') {
36542
36540
  const range = this.getRange();
36543
- 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");
36541
+ 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");
36544
36542
  }
36545
36543
  const keyboardEventAction = ['insert-link', 'format-copy', 'format-paste', 'insert-image', 'insert-table', 'insert-audio', 'insert-video'];
36546
36544
  if (keyboardEventAction.indexOf(e.action) === -1 &&
@@ -36584,6 +36582,15 @@ let RichTextEditor = class RichTextEditor extends Component {
36584
36582
  if (!isNullOrUndefined(this.placeholder)) {
36585
36583
  this.setPlaceHolder();
36586
36584
  }
36585
+ if (!isNullOrUndefined(e) && !isNullOrUndefined(e.code) && (e.code === 'Backspace' || e.code === 'Delete')) {
36586
+ const range = this.contentModule.getDocument().getSelection().getRangeAt(0);
36587
+ const div = document.createElement('div');
36588
+ div.appendChild(range.cloneContents());
36589
+ const selectedHTML = div.innerHTML;
36590
+ if (selectedHTML === this.inputElement.innerHTML) {
36591
+ this.isSelectAll = true;
36592
+ }
36593
+ }
36587
36594
  }
36588
36595
  keyUp(e) {
36589
36596
  if (this.editorMode === 'HTML') {
@@ -36593,6 +36600,10 @@ let RichTextEditor = class RichTextEditor extends Component {
36593
36600
  const currentRange = this.getRange();
36594
36601
  const selection = this.iframeSettings.enable ? this.contentModule.getPanel().ownerDocument.getSelection() :
36595
36602
  this.contentModule.getDocument().getSelection();
36603
+ if (this.isSelectAll) {
36604
+ this.inputElement.innerHTML = this.enterKey !== 'BR' ? '<' + this.enterKey + '><br></' + this.enterKey + '>' : '<br>';
36605
+ this.isSelectAll = false;
36606
+ }
36596
36607
  if (selection.rangeCount > 0) {
36597
36608
  selection.removeAllRanges();
36598
36609
  selection.addRange(currentRange);
@@ -36887,7 +36898,6 @@ let RichTextEditor = class RichTextEditor extends Component {
36887
36898
  removeClass([this.element], CLS_RTE_HIDDEN);
36888
36899
  }
36889
36900
  else {
36890
- remove(this.inputElement);
36891
36901
  if (this.originalElement.innerHTML.trim() !== '') {
36892
36902
  this.element.innerHTML = this.originalElement.innerHTML.trim();
36893
36903
  this.setProperties({ value: (!isNullOrUndefined(this.initialValue) ? this.initialValue : null) }, true);
@@ -36911,9 +36921,6 @@ let RichTextEditor = class RichTextEditor extends Component {
36911
36921
  }
36912
36922
  }
36913
36923
  }
36914
- if (this.inputElement) {
36915
- this.inputElement = null;
36916
- }
36917
36924
  if (this.rootContainer) {
36918
36925
  this.rootContainer = null;
36919
36926
  }