@syncfusion/ej2-richtexteditor 20.1.48 → 20.1.52

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.
@@ -4232,7 +4232,7 @@ class Toolbar$2 {
4232
4232
  if ((parent.bottom < (floatOffset + tbHeight + topValue)) || parent.bottom < 0 || parent.top > floatOffset + topValue) {
4233
4233
  isFloat = false;
4234
4234
  }
4235
- else if (parent.top < floatOffset) {
4235
+ else if (parent.top < floatOffset || parent.top < floatOffset + topValue) {
4236
4236
  isFloat = true;
4237
4237
  }
4238
4238
  }
@@ -11360,7 +11360,7 @@ class NodeCutter {
11360
11360
  fragment = this.spliceEmptyNode(fragment, true);
11361
11361
  if (fragment && fragment.childNodes.length > 0) {
11362
11362
  const isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG'
11363
- && this.isImgElm(fragment) && fragment.textContent.trim() === '') ? true : false;
11363
+ && this.isImgElm(fragment) && fragment.textContent === '') ? true : false;
11364
11364
  if (!isEmpty) {
11365
11365
  if (node) {
11366
11366
  InsertMethods.AppendBefore(fragment, node, true);
@@ -11411,7 +11411,7 @@ class NodeCutter {
11411
11411
  else if (len > -1) {
11412
11412
  this.spliceEmptyNode(fragment.childNodes[0], isStart);
11413
11413
  }
11414
- else if (fragment.nodeType !== 3 && fragment.nodeType !== 11) {
11414
+ else if (fragment.nodeType !== 3 && fragment.nodeType !== 11 && fragment.nodeName !== 'IMG') {
11415
11415
  fragment.parentNode.removeChild(fragment);
11416
11416
  }
11417
11417
  return fragment;
@@ -12233,7 +12233,8 @@ class InsertHtml {
12233
12233
  tempSpan.parentNode.replaceChild(node, tempSpan);
12234
12234
  }
12235
12235
  else {
12236
- let currentNode = nodes[nodes.length - 1];
12236
+ const nodeSelection = new NodeSelection();
12237
+ let currentNode = this.getNodeCollection(range, nodeSelection, node)[this.getNodeCollection(range, nodeSelection, node).length - 1];
12237
12238
  let splitedElm;
12238
12239
  if ((currentNode.nodeName === 'BR' || currentNode.nodeName === 'HR') && !isNullOrUndefined(currentNode.parentElement) &&
12239
12240
  currentNode.parentElement.textContent.trim().length === 0) {
@@ -13311,11 +13312,11 @@ class TableCommand {
13311
13312
  for (let i = 0; i < emptyUl.length; i++) {
13312
13313
  detach(emptyUl[i]);
13313
13314
  }
13314
- let emptyLiChild = this.parent.editableElement.querySelectorAll('li *:empty');
13315
+ let emptyLiChild = this.parent.editableElement.querySelectorAll('li *:empty:not(img)');
13315
13316
  for (let i = 0; i < emptyLiChild.length; i++) {
13316
13317
  detach(emptyLiChild[i]);
13317
13318
  if (emptyLiChild.length === i + 1) {
13318
- emptyLiChild = this.parent.editableElement.querySelectorAll('li *:empty');
13319
+ emptyLiChild = this.parent.editableElement.querySelectorAll('li *:empty:not(img)');
13319
13320
  i = -1;
13320
13321
  }
13321
13322
  }
@@ -14398,12 +14399,18 @@ class SelectionCommands {
14398
14399
  let preventRestore = false;
14399
14400
  const isFontStyle = (['fontcolor', 'fontname', 'fontsize', 'backgroundcolor'].indexOf(format) > -1);
14400
14401
  if (range.collapsed) {
14402
+ let currentFormatNode = isFormatted.getFormattedNode(range.startContainer, format, endNode);
14403
+ let currentSelector = !isNullOrUndefined(currentFormatNode) ?
14404
+ (currentFormatNode.getAttribute('style') === null ? currentFormatNode.nodeName :
14405
+ currentFormatNode.nodeName + `[style='` + currentFormatNode.getAttribute('style') + `']`) : null;
14401
14406
  if (nodes.length > 0) {
14402
14407
  isCollapsed = true;
14403
14408
  range = nodeCutter.GetCursorRange(docElement, range, nodes[0]);
14404
14409
  }
14405
- else if (range.startContainer.nodeType === 3 && range.startContainer.parentElement.childElementCount > 0 &&
14406
- range.startOffset > 0 && range.startContainer.parentElement.firstElementChild.tagName.toLowerCase() !== 'br') {
14410
+ else if (range.startContainer.nodeType === 3 && ((range.startContainer.parentElement.childElementCount > 0 &&
14411
+ range.startOffset > 0 && range.startContainer.parentElement.firstElementChild.tagName.toLowerCase() !== 'br') ||
14412
+ !isNullOrUndefined(currentFormatNode) && currentFormatNode === (range.startContainer.parentElement.closest(currentSelector)) &&
14413
+ ((range.startContainer.parentElement.closest(currentSelector)).textContent.replace(new RegExp(String.fromCharCode(8203), 'g'), '').trim().length != 0))) {
14407
14414
  isCollapsed = true;
14408
14415
  range = nodeCutter.GetCursorRange(docElement, range, range.startContainer);
14409
14416
  nodes.push(range.startContainer);
@@ -15327,7 +15334,7 @@ class UndoRedoManager {
15327
15334
  */
15328
15335
  saveData(e) {
15329
15336
  let range = new NodeSelection().getRange(this.parent.currentDocument);
15330
- let currentContainer = range.startContainer;
15337
+ let currentContainer = this.parent.editableElement === range.startContainer.parentElement ? range.startContainer.parentElement : range.startContainer;
15331
15338
  for (let i = currentContainer.childNodes.length - 1; i >= 0; i--) {
15332
15339
  if (!isNullOrUndefined(currentContainer.childNodes[i]) && currentContainer.childNodes[i].nodeName === '#text' &&
15333
15340
  currentContainer.childNodes[i].textContent.length === 0 && currentContainer.childNodes[i].nodeName !== 'IMG' &&
@@ -16158,7 +16165,7 @@ class InsertTextExec {
16158
16165
  }
16159
16166
  insertText(e) {
16160
16167
  const node = document.createTextNode(e.value);
16161
- InsertHtml.Insert(this.parent.currentDocument, node);
16168
+ InsertHtml.Insert(this.parent.currentDocument, node, this.parent.editableElement);
16162
16169
  if (e.callBack) {
16163
16170
  e.callBack({
16164
16171
  requestType: e.subCommand,
@@ -20311,14 +20318,10 @@ class Image {
20311
20318
  img.style.height = null;
20312
20319
  img.removeAttribute('height');
20313
20320
  }
20314
- else if (img.style.width !== '') {
20321
+ else {
20315
20322
  img.style.width = expectedX + 'px';
20316
20323
  img.style.height = expectedX + 'px';
20317
20324
  }
20318
- else {
20319
- img.setAttribute('width', expectedX.toString());
20320
- img.setAttribute('height', expectedX.toString());
20321
- }
20322
20325
  }
20323
20326
  }
20324
20327
  pixToPerc(expected, parentEle) {
@@ -23223,7 +23226,7 @@ class Table {
23223
23226
  EventHandler.remove(this.contentModule.getEditPanel(), 'mouseover', this.resizeHelper);
23224
23227
  }
23225
23228
  const widthType = this.curTable.style.width.indexOf('%') > -1;
23226
- this.curTable.style.width = widthType ? this.convertPixelToPercentage(tableWidth + mouseX, rteWidth) + '%'
23229
+ this.curTable.style.width = widthType && !this.curTable.closest('TD') ? this.convertPixelToPercentage(tableWidth + mouseX, rteWidth) + '%'
23227
23230
  : tableWidth + mouseX + 'px';
23228
23231
  this.curTable.style.height = tableHeight + mouseY + 'px';
23229
23232
  tableReBox.classList.add('e-rbox-select');
@@ -24530,8 +24533,9 @@ class EnterKeyAction {
24530
24533
  }
24531
24534
  removeBRElement(currentElement) {
24532
24535
  if (Browser.userAgent.indexOf('Firefox') != -1 &&
24533
- this.range.endOffset === currentElement.textContent.length &&
24534
- currentElement.lastChild.nodeName === 'BR') {
24536
+ this.range.endOffset === currentElement.textContent.length && (currentElement.textContent.length !== 0 ||
24537
+ currentElement.querySelectorAll('BR').length > 1) &&
24538
+ !isNullOrUndefined(currentElement.lastChild) && currentElement.lastChild.nodeName === 'BR') {
24535
24539
  detach(currentElement.lastChild);
24536
24540
  }
24537
24541
  }
@@ -25255,6 +25259,10 @@ let RichTextEditor = class RichTextEditor extends Component {
25255
25259
  ? 0 : e.clipboardData.getData('text/plain').length;
25256
25260
  const totalLength = (currentLength - selectionLength) + pastedContentLength;
25257
25261
  if (this.editorMode === 'Markdown') {
25262
+ const args = { requestType: 'Paste', editorMode: this.editorMode, event: e };
25263
+ setTimeout(() => {
25264
+ this.formatter.onSuccess(this, args);
25265
+ }, 0);
25258
25266
  if (!(this.maxLength === -1 || totalLength <= this.maxLength)) {
25259
25267
  e.preventDefault();
25260
25268
  }