@syncfusion/ej2-richtexteditor 19.4.53 → 19.4.56

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.
@@ -10924,6 +10924,14 @@ var Lists = /** @__PURE__ @class */ (function () {
10924
10924
  };
10925
10925
  Lists.prototype.applyListsHandler = function (e) {
10926
10926
  var range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
10927
+ if (range.startContainer === range.endContainer && range.startContainer === this.parent.editableElement &&
10928
+ range.startOffset === range.endOffset && range.startOffset === 0 &&
10929
+ this.parent.editableElement.textContent.length === 0 && (this.parent.editableElement.childNodes[0].nodeName != 'TABLE' &&
10930
+ this.parent.editableElement.childNodes[0].nodeName != 'IMG')) {
10931
+ var focusNode = range.startContainer.childNodes[0];
10932
+ this.parent.nodeSelection.setSelectionText(this.parent.currentDocument, focusNode, focusNode, 0, 0);
10933
+ range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
10934
+ }
10927
10935
  this.saveSelection = this.parent.nodeSelection.save(range, this.parent.currentDocument);
10928
10936
  this.currentAction = e.subCommand;
10929
10937
  this.currentAction = e.subCommand = this.currentAction === 'NumberFormatList' ? 'OL' : this.currentAction === 'BulletFormatList' ? 'UL' : this.currentAction;
@@ -12299,7 +12307,7 @@ var InsertHtml = /** @__PURE__ @class */ (function () {
12299
12307
  var currentNode = nodes[nodes.length - 1];
12300
12308
  var splitedElm = void 0;
12301
12309
  if ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR') && !isNullOrUndefined(currentNode.parentElement) &&
12302
- currentNode.parentElement.textContent.trim().length === 0 && !node.classList.contains('pasteContent')) {
12310
+ currentNode.parentElement.textContent.trim().length === 0) {
12303
12311
  splitedElm = currentNode;
12304
12312
  }
12305
12313
  else {
@@ -12463,6 +12471,11 @@ var LinkCommand = /** @__PURE__ @class */ (function () {
12463
12471
  else {
12464
12472
  var domSelection = new NodeSelection();
12465
12473
  var range = domSelection.getRange(this.parent.currentDocument);
12474
+ if (range.endContainer.nodeName === '#text' && range.startContainer.textContent.length === (range.endOffset + 1) &&
12475
+ range.endContainer.textContent.charAt(range.endOffset) === ' ' && range.endContainer.nextSibling.nodeName === 'A') {
12476
+ domSelection.setSelectionText(this.parent.currentDocument, range.startContainer, range.endContainer, range.startOffset, range.endOffset + 1);
12477
+ range = domSelection.getRange(this.parent.currentDocument);
12478
+ }
12466
12479
  var text = isNullOrUndefined(e.item.text) ? true : e.item.text.replace(/ /g, '').localeCompare(range.toString()
12467
12480
  .replace(/\n/g, ' ').replace(/ /g, '')) < 0;
12468
12481
  if (e.event && e.event.type === 'keydown' && (e.event.keyCode === 32
@@ -13120,7 +13133,12 @@ var ImageCommand = /** @__PURE__ @class */ (function () {
13120
13133
  ImageCommand.prototype.removeImage = function (e) {
13121
13134
  if (closest(e.item.selectNode[0], 'a')) {
13122
13135
  if (e.item.selectNode[0].parentElement.nodeName === 'A' && !isNullOrUndefined(e.item.selectNode[0].parentElement.innerText)) {
13123
- detach(e.item.selectNode[0]);
13136
+ if (!isNullOrUndefined(closest(e.item.selectNode[0], '.' + CLASS_CAPTION))) {
13137
+ detach(closest(e.item.selectNode[0], '.' + CLASS_CAPTION));
13138
+ }
13139
+ else {
13140
+ detach(e.item.selectNode[0]);
13141
+ }
13124
13142
  }
13125
13143
  else {
13126
13144
  detach(closest(e.item.selectNode[0], 'a'));
@@ -14531,6 +14549,7 @@ var SelectionCommands = /** @__PURE__ @class */ (function () {
14531
14549
  };
14532
14550
  SelectionCommands.insertCursorNode = function (docElement, domSelection, range, isFormatted, nodeCutter, format, value, endNode) {
14533
14551
  var cursorNodes = domSelection.getNodeCollection(range);
14552
+ var domNode = new DOMNode(endNode, docElement);
14534
14553
  var cursorFormat = (cursorNodes.length > 0) ?
14535
14554
  (cursorNodes.length > 1 && range.startContainer === range.endContainer) ?
14536
14555
  this.getCursorFormat(isFormatted, cursorNodes, format, endNode) :
@@ -14538,11 +14557,16 @@ var SelectionCommands = /** @__PURE__ @class */ (function () {
14538
14557
  var cursorNode = null;
14539
14558
  if (cursorFormat) {
14540
14559
  cursorNode = cursorNodes[0];
14541
- if (cursorFormat.firstChild.textContent.charCodeAt(0) === 8203) {
14560
+ if (cursorFormat.firstChild.textContent.charCodeAt(0) === 8203 && cursorFormat.firstChild.nodeType === 3) {
14542
14561
  var regEx = new RegExp(String.fromCharCode(8203), 'g');
14543
14562
  var emptySpaceNode = void 0;
14544
14563
  if (cursorFormat.firstChild === cursorNode) {
14545
- cursorNode.textContent = cursorNode.textContent.replace(regEx, '');
14564
+ cursorNode.textContent = (cursorFormat.parentElement && (domNode.isBlockNode(cursorFormat.parentElement) &&
14565
+ cursorFormat.parentElement.textContent.length <= 1 ? cursorFormat.parentElement.childElementCount > 1 :
14566
+ cursorFormat.childElementCount === 0) &&
14567
+ (cursorFormat.parentElement.textContent.length > 1 ||
14568
+ cursorFormat.parentElement.firstChild && cursorFormat.parentElement.firstChild.nodeType === 1) ?
14569
+ cursorNode.textContent : cursorNode.textContent.replace(regEx, ''));
14546
14570
  emptySpaceNode = cursorNode;
14547
14571
 
14548
14572
  }
@@ -17216,6 +17240,7 @@ var XhtmlValidation = /** @__PURE__ @class */ (function () {
17216
17240
  var HtmlEditor = /** @__PURE__ @class */ (function () {
17217
17241
  function HtmlEditor(parent, serviceLocator) {
17218
17242
  this.rangeCollection = [];
17243
+ this.isImageDelete = false;
17219
17244
  this.parent = parent;
17220
17245
  this.locator = serviceLocator;
17221
17246
  this.renderFactory = this.locator.getService('rendererFactory');
@@ -17301,7 +17326,9 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
17301
17326
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), range.startContainer, pointer);
17302
17327
  }
17303
17328
  if (!isNullOrUndefined(range.startContainer.previousSibling) && !isNullOrUndefined(range.startContainer.previousSibling.parentElement) &&
17304
- range.startContainer.parentElement === range.startContainer.previousSibling.parentElement && range.startContainer.previousSibling.textContent.charCodeAt(0) === 8203) {
17329
+ range.startContainer.parentElement === range.startContainer.previousSibling.parentElement &&
17330
+ range.startContainer.previousSibling.textContent.charCodeAt(0) === 8203 &&
17331
+ range.startContainer.previousSibling.textContent.length <= 1) {
17305
17332
  range.startContainer.previousSibling.textContent = range.startContainer.previousSibling.textContent.replace(regEx, '');
17306
17333
  }
17307
17334
  if (range.endContainer.textContent.charCodeAt(range.endOffset) === 8203) {
@@ -17389,7 +17416,9 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
17389
17416
  this.oldRangeElement = null;
17390
17417
  this.deleteRangeElement = null;
17391
17418
  this.deleteOldRangeElement = null;
17392
- args.preventDefault();
17419
+ if (!this.isImageDelete) {
17420
+ args.preventDefault();
17421
+ }
17393
17422
  }
17394
17423
  };
17395
17424
  HtmlEditor.prototype.isOrderedList = function (editorValue) {
@@ -17513,7 +17542,15 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
17513
17542
  return;
17514
17543
  }
17515
17544
  else {
17516
- this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), this.deleteRangeElement, this.deleteRangeElement.childNodes.length);
17545
+ if (currentRange.startOffset === 0 && currentRange.endOffset === 1 &&
17546
+ this.deleteRangeElement.childNodes[0].nodeName === 'IMG') {
17547
+ this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.parent.contentModule.getDocument(), this.deleteRangeElement, this.deleteRangeElement, 0, 1);
17548
+ this.isImageDelete = true;
17549
+ }
17550
+ else {
17551
+ this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), this.deleteRangeElement, this.deleteRangeElement.childNodes.length);
17552
+ this.isImageDelete = false;
17553
+ }
17517
17554
  if (this.deleteRangeElement.querySelector('BR')) {
17518
17555
  detach(this.deleteRangeElement.querySelector('BR'));
17519
17556
  }
@@ -18095,6 +18132,11 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
18095
18132
  }
18096
18133
  }
18097
18134
  };
18135
+ PasteCleanup.prototype.toolbarEnableDisable = function (state) {
18136
+ if (!this.parent.inlineMode.enable) {
18137
+ this.parent.toolbarModule.baseToolbar.toolbarObj.disable(state);
18138
+ }
18139
+ };
18098
18140
  PasteCleanup.prototype.uploadMethod = function (fileList, imgElem) {
18099
18141
  var _this = this;
18100
18142
  var uploadEle = document.createElement('div');
@@ -18171,6 +18213,7 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
18171
18213
  if (beforeUploadArgs.cancel) {
18172
18214
  return;
18173
18215
  }
18216
+ _this.toolbarEnableDisable(true);
18174
18217
  /* eslint-disable */
18175
18218
  uploadObj.currentRequestHeader = beforeUploadArgs.currentRequest ?
18176
18219
  beforeUploadArgs.currentRequest : uploadObj.currentRequestHeader;
@@ -18182,6 +18225,7 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
18182
18225
  }
18183
18226
  else {
18184
18227
  _this.parent.trigger(beforeImageUpload, args);
18228
+ _this.toolbarEnableDisable(true);
18185
18229
  }
18186
18230
  },
18187
18231
  // eslint-disable-next-line
@@ -18254,6 +18298,7 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
18254
18298
  popupObj.close();
18255
18299
  imgElem.style.opacity = '1';
18256
18300
  uploadObj.destroy();
18301
+ this.toolbarEnableDisable(false);
18257
18302
  };
18258
18303
  PasteCleanup.prototype.refreshPopup = function (imageElement, popupObj) {
18259
18304
  var imgPosition = this.parent.iframeSettings.enable ? this.parent.element.offsetTop +
@@ -21784,7 +21829,8 @@ var Image = /** @__PURE__ @class */ (function () {
21784
21829
  if (activePopupElement) {
21785
21830
  activePopupElement.classList.add(CLS_HIDE);
21786
21831
  }
21787
- if (e.dataTransfer.files.length > 0) { //For external image drag and drop
21832
+ var imgElement = this.parent.inputElement.ownerDocument.querySelector('.' + CLS_RTE_DRAG_IMAGE);
21833
+ if (e.dataTransfer.files.length > 0 && imgElement === null) { //For external image drag and drop
21788
21834
  if (e.dataTransfer.files.length > 1) {
21789
21835
  return;
21790
21836
  }
@@ -21807,7 +21853,6 @@ var Image = /** @__PURE__ @class */ (function () {
21807
21853
  }
21808
21854
  else { //For internal image drag and drop
21809
21855
  var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
21810
- var imgElement = this.parent.inputElement.ownerDocument.querySelector('.' + CLS_RTE_DRAG_IMAGE);
21811
21856
  if (imgElement && imgElement.tagName === 'IMG') {
21812
21857
  if (imgElement.nextElementSibling) {
21813
21858
  if (imgElement.nextElementSibling.classList.contains(CLS_IMG_INNER)) {
@@ -22936,7 +22981,7 @@ var Table = /** @__PURE__ @class */ (function () {
22936
22981
  return;
22937
22982
  }
22938
22983
  var target = e.target || e.targetTouches[0].target;
22939
- var closestTable = closest(target, 'table');
22984
+ var closestTable = closest(target, 'table.e-rte-table');
22940
22985
  if (!isNullOrUndefined(this.curTable) && !isNullOrUndefined(closestTable) && closestTable !== this.curTable) {
22941
22986
  this.removeResizeElement();
22942
22987
  this.removeHelper(e);
@@ -24481,6 +24526,7 @@ var EnterKeyAction = /** @__PURE__ @class */ (function () {
24481
24526
  else if (_this.range.startOffset === 0 && _this.range.endOffset === 0) {
24482
24527
  isFocusedFirst = true;
24483
24528
  }
24529
+ _this.removeBRElement(nearBlockNode);
24484
24530
  if (((_this.range.startOffset === 0 && _this.range.endOffset === 0) || isFocusedFirst) &&
24485
24531
  !(!isNullOrUndefined(_this.range.startContainer.previousSibling) &&
24486
24532
  (_this.range.startContainer.previousSibling.nodeName === 'IMG' || _this.range.startContainer.previousSibling.nodeName === 'BR'))) {
@@ -24584,6 +24630,7 @@ var EnterKeyAction = /** @__PURE__ @class */ (function () {
24584
24630
  else {
24585
24631
  currentParent = _this.startNode;
24586
24632
  }
24633
+ _this.removeBRElement(currentParent);
24587
24634
  var currentParentLastChild = currentParent.lastChild;
24588
24635
  while (!isNullOrUndefined(currentParentLastChild) && !(currentParentLastChild.nodeName === '#text' || currentParentLastChild.nodeName === 'BR')) {
24589
24636
  currentParentLastChild = currentParentLastChild.lastChild;
@@ -24645,6 +24692,13 @@ var EnterKeyAction = /** @__PURE__ @class */ (function () {
24645
24692
  }
24646
24693
  }
24647
24694
  };
24695
+ EnterKeyAction.prototype.removeBRElement = function (currentElement) {
24696
+ if (Browser.userAgent.indexOf('Firefox') != -1 &&
24697
+ this.range.endOffset === currentElement.textContent.length &&
24698
+ currentElement.lastChild.nodeName === 'BR') {
24699
+ detach(currentElement.lastChild);
24700
+ }
24701
+ };
24648
24702
  EnterKeyAction.prototype.insertBRElement = function () {
24649
24703
  var isEmptyBrInserted = false;
24650
24704
  var brElm = this.parent.createElement('br');
@@ -25128,6 +25182,27 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
25128
25182
  RichTextEditor.prototype.eventInitializer = function () {
25129
25183
  this.wireEvents();
25130
25184
  };
25185
+ RichTextEditor.prototype.cleanList = function (e) {
25186
+ var range = this.getRange();
25187
+ var currentStartContainer = range.startContainer;
25188
+ var currentEndContainer = range.endContainer;
25189
+ var currentStartOffset = range.startOffset;
25190
+ var isSameContainer = currentStartContainer === currentEndContainer ? true : false;
25191
+ var currentEndOffset;
25192
+ var endNode = range.endContainer.nodeName === '#text' ? range.endContainer.parentElement :
25193
+ range.endContainer;
25194
+ var closestLI = closest(endNode, 'LI');
25195
+ if (!isNullOrUndefined(closestLI) && endNode.textContent.length === range.endOffset &&
25196
+ !range.collapsed) {
25197
+ closestLI.textContent = closestLI.textContent.trim();
25198
+ currentEndOffset = closestLI.textContent.length - 1;
25199
+ var currentLastElem = closestLI;
25200
+ while (currentLastElem.nodeName !== '#text') {
25201
+ currentLastElem = currentLastElem.lastChild;
25202
+ }
25203
+ this.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), isSameContainer ? currentLastElem : currentStartContainer, currentLastElem, currentStartOffset, currentLastElem.textContent.length);
25204
+ }
25205
+ };
25131
25206
  /**
25132
25207
  * For internal use only - keydown the event handler;
25133
25208
  *
@@ -25140,6 +25215,9 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
25140
25215
  RichTextEditor.prototype.keyDown = function (e) {
25141
25216
  this.notify(keyDown, { member: 'keydown', args: e });
25142
25217
  this.restrict(e);
25218
+ if (this.editorMode === 'HTML') {
25219
+ this.cleanList(e);
25220
+ }
25143
25221
  if (this.editorMode === 'HTML' && ((e.which === 8 && e.code === 'Backspace') || (e.which === 46 && e.code === 'Delete'))) {
25144
25222
  var range = this.getRange();
25145
25223
  var startNode = range.startContainer.nodeName === '#text' ? range.startContainer.parentElement :