@syncfusion/ej2-richtexteditor 19.4.54 → 19.4.55

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;
@@ -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
  }
@@ -17302,7 +17326,9 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
17302
17326
  this.parent.formatter.editorManager.nodeSelection.setCursorPoint(this.parent.contentModule.getDocument(), range.startContainer, pointer);
17303
17327
  }
17304
17328
  if (!isNullOrUndefined(range.startContainer.previousSibling) && !isNullOrUndefined(range.startContainer.previousSibling.parentElement) &&
17305
- 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) {
17306
17332
  range.startContainer.previousSibling.textContent = range.startContainer.previousSibling.textContent.replace(regEx, '');
17307
17333
  }
17308
17334
  if (range.endContainer.textContent.charCodeAt(range.endOffset) === 8203) {
@@ -21803,7 +21829,8 @@ var Image = /** @__PURE__ @class */ (function () {
21803
21829
  if (activePopupElement) {
21804
21830
  activePopupElement.classList.add(CLS_HIDE);
21805
21831
  }
21806
- 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
21807
21834
  if (e.dataTransfer.files.length > 1) {
21808
21835
  return;
21809
21836
  }
@@ -21826,7 +21853,6 @@ var Image = /** @__PURE__ @class */ (function () {
21826
21853
  }
21827
21854
  else { //For internal image drag and drop
21828
21855
  var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
21829
- var imgElement = this.parent.inputElement.ownerDocument.querySelector('.' + CLS_RTE_DRAG_IMAGE);
21830
21856
  if (imgElement && imgElement.tagName === 'IMG') {
21831
21857
  if (imgElement.nextElementSibling) {
21832
21858
  if (imgElement.nextElementSibling.classList.contains(CLS_IMG_INNER)) {
@@ -22955,7 +22981,7 @@ var Table = /** @__PURE__ @class */ (function () {
22955
22981
  return;
22956
22982
  }
22957
22983
  var target = e.target || e.targetTouches[0].target;
22958
- var closestTable = closest(target, 'table');
22984
+ var closestTable = closest(target, 'table.e-rte-table');
22959
22985
  if (!isNullOrUndefined(this.curTable) && !isNullOrUndefined(closestTable) && closestTable !== this.curTable) {
22960
22986
  this.removeResizeElement();
22961
22987
  this.removeHelper(e);