@syncfusion/ej2-richtexteditor 19.3.55 → 19.3.57

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.
@@ -5714,7 +5714,7 @@ class QuickToolbar {
5714
5714
  * @deprecated
5715
5715
  */
5716
5716
  showInlineQTBar(x, y, target) {
5717
- if (this.parent.readonly) {
5717
+ if (this.parent.readonly || target.tagName.toLowerCase() === "img") {
5718
5718
  return;
5719
5719
  }
5720
5720
  this.inlineQTBar.showPopup(x, y, target);
@@ -6853,7 +6853,7 @@ class Formatter {
6853
6853
  || ((args.item.subCommand === 'FontName' || args.item.subCommand === 'FontSize') && args.name === 'dropDownSelect')
6854
6854
  || ((args.item.subCommand === 'BackgroundColor' || args.item.subCommand === 'FontColor')
6855
6855
  && args.name === 'colorPickerChanged'))) {
6856
- extend(args, args, { requestType: args.item.subCommand, cancel: false, itemCollection: value }, true);
6856
+ extend(args, args, { requestType: args.item.subCommand, cancel: false, itemCollection: value, selectType: args.name }, true);
6857
6857
  self.trigger(actionBegin, args, (actionBeginArgs) => {
6858
6858
  if (!actionBeginArgs.cancel) {
6859
6859
  if (this.getUndoRedoStack().length === 0 && actionBeginArgs.item.command !== 'Links'
@@ -6871,8 +6871,8 @@ class Formatter {
6871
6871
  }
6872
6872
  else {
6873
6873
  this.editorManager.observer.notify(checkUndo, { subCommand: actionBeginArgs.item.subCommand });
6874
- this.editorManager.execCommand(actionBeginArgs.item.command, actionBeginArgs.item.subCommand, event, this.onSuccess.bind(this, self), actionBeginArgs.item.value, actionBeginArgs.item.subCommand === 'Pre' && args.name === 'dropDownSelect' ?
6875
- { name: args.name } : value, ('#' + self.getID() + ' iframe'), self.enterKey);
6874
+ this.editorManager.execCommand(actionBeginArgs.item.command, actionBeginArgs.item.subCommand, event, this.onSuccess.bind(this, self), actionBeginArgs.item.value, actionBeginArgs.item.subCommand === 'Pre' && actionBeginArgs.selectType === 'dropDownSelect' ?
6875
+ { name: actionBeginArgs.selectType } : value, ('#' + self.getID() + ' iframe'), self.enterKey);
6876
6876
  }
6877
6877
  }
6878
6878
  });
@@ -9343,7 +9343,8 @@ class NodeSelection {
9343
9343
  || range.startContainer;
9344
9344
  const endNode = range.endContainer.childNodes[(range.endOffset > 0) ? (range.endOffset - 1) : range.endOffset]
9345
9345
  || range.endContainer;
9346
- if (startNode === endNode && startNode.childNodes.length === 0) {
9346
+ if ((startNode === endNode || (startNode.nodeName === 'BR' && startNode === range.endContainer.childNodes[range.endOffset])) &&
9347
+ startNode.childNodes.length === 0) {
9347
9348
  return [startNode];
9348
9349
  }
9349
9350
  if (range.startOffset === range.endOffset && range.startOffset !== 0 && range.startContainer.nodeName === 'PRE') {
@@ -12197,7 +12198,15 @@ class InsertHtml {
12197
12198
  tempSpan.parentNode.replaceChild(node, tempSpan);
12198
12199
  }
12199
12200
  else {
12200
- const splitedElm = nodeCutter.GetSpliceNode(range, blockNode);
12201
+ let currentNode = nodes[nodes.length - 1];
12202
+ let splitedElm;
12203
+ if ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR') && !isNullOrUndefined(currentNode.parentElement) &&
12204
+ currentNode.parentElement.textContent.trim().length === 0 && !node.classList.contains('pasteContent')) {
12205
+ splitedElm = currentNode;
12206
+ }
12207
+ else {
12208
+ splitedElm = nodeCutter.GetSpliceNode(range, blockNode);
12209
+ }
12201
12210
  splitedElm.parentNode.replaceChild(node, splitedElm);
12202
12211
  }
12203
12212
  }
@@ -17214,7 +17223,7 @@ class HtmlEditor {
17214
17223
  e.args.action === 'enter' ||
17215
17224
  e.args.keyCode === 13) {
17216
17225
  this.spaceLink(e.args);
17217
- if (this.parent.editorMode === 'HTML' && !((this.parent.shiftEnterKey === 'BR' && e.args.shiftKey))) {
17226
+ if (this.parent.editorMode === 'HTML') {
17218
17227
  this.parent.notify(enterHandler, { args: e.args });
17219
17228
  }
17220
17229
  }
@@ -17491,7 +17500,7 @@ class HtmlEditor {
17491
17500
  const divElement = this.parent.createElement('div');
17492
17501
  divElement.setAttribute('class', 'pasteContent');
17493
17502
  divElement.style.display = 'inline';
17494
- divElement.innerHTML = contentInnerElem;
17503
+ divElement.innerHTML = contentInnerElem.replace('&para', '&para');
17495
17504
  const paraElem = divElement.querySelectorAll('span, p');
17496
17505
  for (let i = 0; i < paraElem.length; i++) {
17497
17506
  const splitTextContent = paraElem[i].innerHTML.split(' ');
@@ -20115,10 +20124,14 @@ class Image {
20115
20124
  img.style.height = expectedY + 'px';
20116
20125
  }
20117
20126
  else if (img.style.width !== '' && img.style.height === '') {
20118
- img.style.width = ((width / height * expectedY) + width / height).toString() + 'px';
20127
+ let currentWidth = ((width / height * expectedY) + width / height) < (this.parent.inputElement.getBoundingClientRect().right - 32) ?
20128
+ ((width / height * expectedY) + width / height) : (this.parent.inputElement.getBoundingClientRect().right - 32);
20129
+ img.style.width = currentWidth.toString() + 'px';
20119
20130
  }
20120
20131
  else if (img.style.width !== '') {
20121
- img.style.width = (width / height * expectedY) + 'px';
20132
+ let currentWidth = (width / height * expectedY) < (this.parent.inputElement.getBoundingClientRect().right - 32) ?
20133
+ (width / height * expectedY) : (this.parent.inputElement.getBoundingClientRect().right - 32);
20134
+ img.style.width = currentWidth + 'px';
20122
20135
  img.style.height = expectedY + 'px';
20123
20136
  }
20124
20137
  else {
@@ -20226,7 +20239,7 @@ class Image {
20226
20239
  }
20227
20240
  resizeImgDupPos(e) {
20228
20241
  this.imgDupPos = {
20229
- width: (e.style.height !== '') ? this.imgEle.style.width : e.width + 'px',
20242
+ width: (e.style.width !== '') ? this.imgEle.style.width : e.width + 'px',
20230
20243
  height: (e.style.height !== '') ? this.imgEle.style.height : e.height + 'px'
20231
20244
  };
20232
20245
  }
@@ -20394,6 +20407,27 @@ class Image {
20394
20407
  const src = this.deletedImg[i].src;
20395
20408
  this.imageRemovePost(src);
20396
20409
  }
20410
+ if (range.startContainer.nodeType === 3) {
20411
+ if (originalEvent.code === 'Backspace') {
20412
+ if (range.startContainer.previousElementSibling && range.startOffset === 0 &&
20413
+ range.startContainer.previousElementSibling.classList.contains(CLS_CAPTION) &&
20414
+ range.startContainer.previousElementSibling.classList.contains(CLS_CAPINLINE)) {
20415
+ detach(range.startContainer.previousElementSibling);
20416
+ }
20417
+ }
20418
+ else {
20419
+ if (range.startContainer.nextElementSibling &&
20420
+ range.endContainer.textContent.length === range.endOffset &&
20421
+ range.startContainer.nextElementSibling.classList.contains(CLS_CAPTION) &&
20422
+ range.startContainer.nextElementSibling.classList.contains(CLS_CAPINLINE)) {
20423
+ detach(range.startContainer.nextElementSibling);
20424
+ }
20425
+ }
20426
+ }
20427
+ else if ((range.startContainer.nodeType === 1 &&
20428
+ range.startContainer.querySelector('.' + CLS_CAPTION + '.' + CLS_CAPINLINE))) {
20429
+ detach(range.startContainer.querySelector('.' + CLS_CAPTION + '.' + CLS_CAPINLINE));
20430
+ }
20397
20431
  break;
20398
20432
  case 'insert-image':
20399
20433
  this.openDialog(true, originalEvent, save, selectNodeEle, selectParentEle);
@@ -20598,7 +20632,7 @@ class Image {
20598
20632
  const target = args.target;
20599
20633
  this.contentModule = this.rendererFactory.getRenderer(RenderType.Content);
20600
20634
  const isPopupOpen = this.quickToolObj.imageQTBar.element.classList.contains('e-rte-pop');
20601
- if (target.nodeName === 'IMG' && this.parent.quickToolbarModule && this.parent.getRange().startOffset === this.parent.getRange().endOffset) {
20635
+ if (target.nodeName === 'IMG' && this.parent.quickToolbarModule) {
20602
20636
  if (isPopupOpen) {
20603
20637
  return;
20604
20638
  }
@@ -20837,6 +20871,9 @@ class Image {
20837
20871
  imageRemovePost(src) {
20838
20872
  const proxy = this;
20839
20873
  let absoluteUrl = '';
20874
+ if (isNullOrUndefined(this.parent.insertImageSettings.removeUrl) || this.parent.insertImageSettings.removeUrl === '') {
20875
+ return;
20876
+ }
20840
20877
  if (src.indexOf('http://') > -1 || src.indexOf('https://') > -1) {
20841
20878
  absoluteUrl = src;
20842
20879
  }
@@ -21673,6 +21710,7 @@ class Image {
21673
21710
  imageTag.addEventListener('load', () => {
21674
21711
  this.parent.trigger(actionComplete, e);
21675
21712
  });
21713
+ detach(parentElement);
21676
21714
  }
21677
21715
  /**
21678
21716
  * Rendering uploader and popup for drag and drop
@@ -21707,6 +21745,9 @@ class Image {
21707
21745
  this.popupObj.destroy();
21708
21746
  detach(this.popupObj.element);
21709
21747
  this.popupObj = null;
21748
+ if (!this.parent.inlineMode.enable) {
21749
+ this.parent.toolbarModule.baseToolbar.toolbarObj.disable(false);
21750
+ }
21710
21751
  }
21711
21752
  });
21712
21753
  this.popupObj.element.style.display = 'none';
@@ -21738,6 +21779,10 @@ class Image {
21738
21779
  isUploading = false;
21739
21780
  detach(imageElement);
21740
21781
  this.popupObj.close();
21782
+ this.quickToolObj.imageQTBar.hidePopup();
21783
+ setTimeout(() => {
21784
+ this.uploadObj.destroy();
21785
+ }, 900);
21741
21786
  },
21742
21787
  beforeUpload: (args) => {
21743
21788
  if (this.parent.isServerRendered) {
@@ -21749,6 +21794,9 @@ class Image {
21749
21794
  if (beforeUploadArgs.cancel) {
21750
21795
  return;
21751
21796
  }
21797
+ if (!this.parent.inlineMode.enable) {
21798
+ this.parent.toolbarModule.baseToolbar.toolbarObj.disable(true);
21799
+ }
21752
21800
  /* eslint-disable */
21753
21801
  this.uploadObj.currentRequestHeader = beforeUploadArgs.currentRequest ?
21754
21802
  beforeUploadArgs.currentRequest : this.uploadObj.currentRequestHeader;
@@ -21761,6 +21809,9 @@ class Image {
21761
21809
  }
21762
21810
  else {
21763
21811
  this.parent.trigger(beforeImageUpload, args);
21812
+ if (!this.parent.inlineMode.enable) {
21813
+ this.parent.toolbarModule.baseToolbar.toolbarObj.disable(true);
21814
+ }
21764
21815
  }
21765
21816
  },
21766
21817
  uploading: (e) => {
@@ -21803,6 +21854,9 @@ class Image {
21803
21854
  }, 900);
21804
21855
  },
21805
21856
  success: (e) => {
21857
+ if (e.operation === "cancel") {
21858
+ return;
21859
+ }
21806
21860
  isUploading = false;
21807
21861
  this.parent.inputElement.contentEditable = 'true';
21808
21862
  const args = {
@@ -24102,12 +24156,13 @@ class EnterKeyAction {
24102
24156
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), this.range.startContainer.childNodes[this.range.startOffset], 0);
24103
24157
  this.getRangeNode();
24104
24158
  }
24105
- if (this.parent.enterKey === 'P' || this.parent.enterKey === 'DIV' ||
24159
+ if ((this.parent.enterKey === 'P' && !shiftKey) || (this.parent.enterKey === 'DIV' && !shiftKey) ||
24106
24160
  (this.parent.shiftEnterKey === 'P' && shiftKey) ||
24107
24161
  (this.parent.shiftEnterKey === 'DIV' && shiftKey)) {
24108
24162
  const nearBlockNode = this.parent.formatter.editorManager.domNode.blockParentNode(this.startNode);
24109
24163
  let isImageNode = false;
24110
- if (this.range.startOffset === 0 && this.range.endOffset === 0 && !(!isNullOrUndefined(this.range.startContainer.previousSibling) && this.range.startContainer.previousSibling.nodeName === 'IMG')) {
24164
+ if (this.range.startOffset === 0 && this.range.endOffset === 0 && !(!isNullOrUndefined(this.range.startContainer.previousSibling) &&
24165
+ (this.range.startContainer.previousSibling.nodeName === 'IMG' || this.range.startContainer.previousSibling.nodeName === 'BR'))) {
24111
24166
  let isNearBlockLengthZero;
24112
24167
  let newElem;
24113
24168
  if (this.range.startContainer.nodeName === 'IMG') {
@@ -24181,7 +24236,7 @@ class EnterKeyAction {
24181
24236
  }
24182
24237
  e.args.preventDefault();
24183
24238
  }
24184
- if (this.parent.enterKey === 'BR' && !shiftKey) {
24239
+ if ((this.parent.enterKey === 'BR' && !shiftKey) || (this.parent.shiftEnterKey === 'BR' && shiftKey)) {
24185
24240
  let currentParent;
24186
24241
  if (!this.parent.formatter.editorManager.domNode.isBlockNode(this.startNode)) {
24187
24242
  let currentNode = this.startNode;
@@ -24196,11 +24251,16 @@ class EnterKeyAction {
24196
24251
  else {
24197
24252
  currentParent = this.startNode;
24198
24253
  }
24199
- let isEmptyBrInserted = false;
24254
+ let currentParentLastChild = currentParent.lastChild;
24255
+ while (!isNullOrUndefined(currentParentLastChild) && !(currentParentLastChild.nodeName === '#text')) {
24256
+ currentParentLastChild = currentParentLastChild.lastChild;
24257
+ }
24258
+ const isLastNodeLength = this.range.startContainer === currentParentLastChild ?
24259
+ this.range.startContainer.textContent.length : currentParent.textContent.length;
24200
24260
  if (currentParent !== this.parent.inputElement &&
24201
24261
  this.parent.formatter.editorManager.domNode.isBlockNode(currentParent) &&
24202
24262
  this.range.startOffset === this.range.endOffset &&
24203
- this.range.startOffset === currentParent.textContent.length) {
24263
+ this.range.startOffset === isLastNodeLength) {
24204
24264
  const outerBRElem = this.parent.createElement('br');
24205
24265
  this.parent.formatter.editorManager.domNode.insertAfter(outerBRElem, currentParent);
24206
24266
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), outerBRElem, 0);
@@ -24227,37 +24287,15 @@ class EnterKeyAction {
24227
24287
  currentFocusElem = currentFocusElem.lastChild;
24228
24288
  }
24229
24289
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), currentFocusElem, 0);
24230
- isEmptyBrInserted = true;
24290
+
24231
24291
  }
24232
24292
  else {
24233
- newElem = this.parent.formatter.editorManager.nodeCutter.SplitNode(this.range, currentParent, true);
24234
- newElem.parentElement.insertBefore(outerBRElem, newElem);
24235
- this.insertFocusContent();
24293
+ this.insertBRElement();
24236
24294
  }
24237
24295
  }
24238
24296
  }
24239
24297
  else {
24240
- const brElm = this.parent.createElement('br');
24241
- if (this.startNode.nodeName === 'BR' && this.endNode.nodeName === 'BR' && this.range.startOffset === 0 && this.range.startOffset === this.range.endOffset) {
24242
- this.parent.formatter.editorManager.domNode.insertAfter(brElm, this.startNode);
24243
- isEmptyBrInserted = true;
24244
- }
24245
- else {
24246
- if (this.startNode === this.parent.inputElement && !isNullOrUndefined(this.range.startContainer.previousSibling) &&
24247
- this.range.startContainer.previousSibling.nodeName === 'BR' && this.range.startContainer.textContent.length === 0) {
24248
- isEmptyBrInserted = true;
24249
- }
24250
- this.range.insertNode(brElm);
24251
- }
24252
- if (isEmptyBrInserted || (!isNullOrUndefined(brElm.nextElementSibling) && brElm.nextElementSibling.tagName === 'BR') || (!isNullOrUndefined(brElm.nextSibling) && brElm.nextSibling.textContent.length > 0)) {
24253
- this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), !isNullOrUndefined(brElm.nextSibling) ? brElm.nextSibling : brElm, 0);
24254
- isEmptyBrInserted = false;
24255
- }
24256
- else {
24257
- const brElm2 = this.parent.createElement('br');
24258
- this.range.insertNode(brElm2);
24259
- this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), brElm, 0);
24260
- }
24298
+ this.insertBRElement();
24261
24299
  }
24262
24300
  e.args.preventDefault();
24263
24301
  }
@@ -24267,6 +24305,30 @@ class EnterKeyAction {
24267
24305
  }
24268
24306
  }
24269
24307
  }
24308
+ insertBRElement() {
24309
+ let isEmptyBrInserted = false;
24310
+ const brElm = this.parent.createElement('br');
24311
+ if (this.startNode.nodeName === 'BR' && this.endNode.nodeName === 'BR' && this.range.startOffset === 0 && this.range.startOffset === this.range.endOffset) {
24312
+ this.parent.formatter.editorManager.domNode.insertAfter(brElm, this.startNode);
24313
+ isEmptyBrInserted = true;
24314
+ }
24315
+ else {
24316
+ if (this.startNode === this.parent.inputElement && !isNullOrUndefined(this.range.startContainer.previousSibling) &&
24317
+ this.range.startContainer.previousSibling.nodeName === 'BR' && this.range.startContainer.textContent.length === 0) {
24318
+ isEmptyBrInserted = true;
24319
+ }
24320
+ this.range.insertNode(brElm);
24321
+ }
24322
+ if (isEmptyBrInserted || (!isNullOrUndefined(brElm.nextElementSibling) && brElm.nextElementSibling.tagName === 'BR') || (!isNullOrUndefined(brElm.nextSibling) && brElm.nextSibling.textContent.length > 0)) {
24323
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), !isNullOrUndefined(brElm.nextSibling) ? brElm.nextSibling : brElm, 0);
24324
+ isEmptyBrInserted = false;
24325
+ }
24326
+ else {
24327
+ const brElm2 = this.parent.createElement('br');
24328
+ this.range.insertNode(brElm2);
24329
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), brElm, 0);
24330
+ }
24331
+ }
24270
24332
  insertFocusContent() {
24271
24333
  if (this.range.startContainer.textContent.length === 0) {
24272
24334
  if (this.range.startContainer.nodeName === '#text') {