@syncfusion/ej2-richtexteditor 25.1.42 → 25.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +26 -4
  2. package/dist/ej2-richtexteditor.min.js +2 -2
  3. package/dist/ej2-richtexteditor.umd.min.js +2 -2
  4. package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-richtexteditor.es2015.js +110 -24
  6. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-richtexteditor.es5.js +115 -26
  8. package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
  9. package/dist/global/ej2-richtexteditor.min.js +2 -2
  10. package/dist/global/ej2-richtexteditor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +12 -12
  13. package/src/common/util.d.ts +8 -0
  14. package/src/common/util.js +52 -0
  15. package/src/editor-manager/plugin/dom-node.js +1 -1
  16. package/src/editor-manager/plugin/ms-word-clean-up.js +2 -2
  17. package/src/editor-manager/plugin/undo.js +3 -1
  18. package/src/rich-text-editor/actions/html-editor.js +2 -10
  19. package/src/rich-text-editor/actions/paste-clean-up.d.ts +1 -0
  20. package/src/rich-text-editor/actions/paste-clean-up.js +52 -12
  21. package/src/rich-text-editor/base/rich-text-editor.d.ts +1 -0
  22. package/src/rich-text-editor/base/rich-text-editor.js +6 -2
  23. package/styles/bootstrap-dark.css +3 -6
  24. package/styles/bootstrap.css +3 -6
  25. package/styles/bootstrap4.css +3 -6
  26. package/styles/bootstrap5-dark.css +3 -6
  27. package/styles/bootstrap5.css +3 -6
  28. package/styles/fabric-dark.css +3 -6
  29. package/styles/fabric.css +3 -6
  30. package/styles/fluent-dark.css +3 -6
  31. package/styles/fluent.css +3 -6
  32. package/styles/highcontrast-light.css +3 -6
  33. package/styles/highcontrast.css +3 -6
  34. package/styles/material-dark.css +3 -6
  35. package/styles/material.css +3 -6
  36. package/styles/material3-dark.css +3 -6
  37. package/styles/material3.css +3 -6
  38. package/styles/rich-text-editor/_layout.scss +3 -6
  39. package/styles/rich-text-editor/bootstrap-dark.css +3 -6
  40. package/styles/rich-text-editor/bootstrap.css +3 -6
  41. package/styles/rich-text-editor/bootstrap4.css +3 -6
  42. package/styles/rich-text-editor/bootstrap5-dark.css +3 -6
  43. package/styles/rich-text-editor/bootstrap5.css +3 -6
  44. package/styles/rich-text-editor/fabric-dark.css +3 -6
  45. package/styles/rich-text-editor/fabric.css +3 -6
  46. package/styles/rich-text-editor/fluent-dark.css +3 -6
  47. package/styles/rich-text-editor/fluent.css +3 -6
  48. package/styles/rich-text-editor/highcontrast-light.css +3 -6
  49. package/styles/rich-text-editor/highcontrast.css +3 -6
  50. package/styles/rich-text-editor/material-dark.css +3 -6
  51. package/styles/rich-text-editor/material.css +3 -6
  52. package/styles/rich-text-editor/material3-dark.css +3 -6
  53. package/styles/rich-text-editor/material3.css +3 -6
  54. package/styles/rich-text-editor/tailwind-dark.css +3 -6
  55. package/styles/rich-text-editor/tailwind.css +3 -6
  56. package/styles/tailwind-dark.css +3 -6
  57. package/styles/tailwind.css +3 -6
@@ -4476,6 +4476,10 @@ function updateTextNode$1(value, enterAction) {
4476
4476
  tableElm[i].classList.remove('e-rte-paste-onenote-table');
4477
4477
  continue;
4478
4478
  }
4479
+ else if (tableElm[i].classList.contains('e-rte-paste-html-table')) {
4480
+ tableElm[i].classList.remove('e-rte-paste-html-table');
4481
+ continue;
4482
+ }
4479
4483
  }
4480
4484
  }
4481
4485
  var imageElm = resultElm.querySelectorAll('img');
@@ -4580,6 +4584,54 @@ function nestedListCleanUp(range) {
4580
4584
  }
4581
4585
  }
4582
4586
  }
4587
+ /**
4588
+ * Method to scroll the content to the cursor position
4589
+ *
4590
+ * @param {Document} document - specifies the document.
4591
+ * @param {HTMLElement | HTMLBodyElement} inputElement - specifies the input element.
4592
+ * @returns {void}
4593
+ */
4594
+ function scrollToCursor(document, inputElement) {
4595
+ var rootElement = inputElement.nodeName === 'BODY' ?
4596
+ inputElement.ownerDocument.defaultView.frameElement.closest('.e-richtexteditor') :
4597
+ inputElement.closest('.e-richtexteditor');
4598
+ var height = rootElement.style.height;
4599
+ if (document.getSelection().rangeCount === 0) {
4600
+ return;
4601
+ }
4602
+ var range = document.getSelection().getRangeAt(0);
4603
+ var finalFocusElement = range.startContainer.nodeName === '#text' ? range.startContainer.parentElement :
4604
+ range.startContainer;
4605
+ var rect = finalFocusElement.getBoundingClientRect();
4606
+ var cursorTop = rect.top;
4607
+ var cursorBottom = rect.bottom;
4608
+ var rootRect = rootElement.getBoundingClientRect();
4609
+ var hasMargin = rootElement.querySelectorAll('.e-count-enabled, .e-resize-enabled').length > 0;
4610
+ if (inputElement.nodeName === 'BODY') {
4611
+ if (height === 'auto') {
4612
+ if (window.innerHeight < cursorTop) {
4613
+ finalFocusElement.scrollIntoView(false);
4614
+ }
4615
+ }
4616
+ else {
4617
+ if (cursorTop > inputElement.getBoundingClientRect().height) {
4618
+ finalFocusElement.scrollIntoView({ block: 'nearest', inline: 'nearest' });
4619
+ }
4620
+ }
4621
+ }
4622
+ else {
4623
+ if (height === 'auto') {
4624
+ if (window.innerHeight < cursorTop) {
4625
+ finalFocusElement.scrollIntoView({ block: 'end', inline: 'nearest' });
4626
+ }
4627
+ }
4628
+ else {
4629
+ if (cursorBottom > rootRect.bottom) {
4630
+ rootElement.querySelector('.e-rte-content').scrollTop += (cursorBottom - rootRect.bottom) + (hasMargin ? 20 : 0);
4631
+ }
4632
+ }
4633
+ }
4634
+ }
4583
4635
 
4584
4636
  /**
4585
4637
  * Update Toolbar Status
@@ -12296,7 +12348,7 @@ var DOMNode = /** @__PURE__ @class */ (function () {
12296
12348
  DOMNode.prototype.unWrap = function (element) {
12297
12349
  var parent = element.parentNode;
12298
12350
  var unWrapNode = [];
12299
- while (element.firstChild) {
12351
+ while (element.firstChild && (element.previousSibling !== this.parent.querySelector('.e-mention-chip') || element.textContent !== ' ')) {
12300
12352
  unWrapNode.push(element.firstChild);
12301
12353
  parent.insertBefore(element.firstChild, element);
12302
12354
  }
@@ -19083,6 +19135,7 @@ var UndoRedoManager = /** @__PURE__ @class */ (function () {
19083
19135
  this.parent.editableElement.innerHTML = '';
19084
19136
  this.parent.editableElement.appendChild(removedContent.cloneNode(true));
19085
19137
  this.parent.editableElement.focus();
19138
+ scrollToCursor(this.parent.currentDocument, this.parent.editableElement);
19086
19139
  if (isIDevice$1()) {
19087
19140
  setEditFrameFocus(this.parent.editableElement, e.selector);
19088
19141
  }
@@ -19115,6 +19168,7 @@ var UndoRedoManager = /** @__PURE__ @class */ (function () {
19115
19168
  this.parent.editableElement.innerHTML = '';
19116
19169
  this.parent.editableElement.appendChild(addedContent.cloneNode(true));
19117
19170
  this.parent.editableElement.focus();
19171
+ scrollToCursor(this.parent.currentDocument, this.parent.editableElement);
19118
19172
  if (isIDevice$1()) {
19119
19173
  setEditFrameFocus(this.parent.editableElement, e.selector);
19120
19174
  }
@@ -19216,9 +19270,9 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
19216
19270
  var patern2 = /class="?Mso|style="[^ ]*\bmso-/i;
19217
19271
  var patern3 = /(class="?Mso|class='?Mso|class="?Xl|class='?Xl|class=Xl|style="[^"]*\bmso-|style='[^']*\bmso-|w:WordDocument)/gi;
19218
19272
  var pattern4 = /style='mso-width-source:/i;
19273
+ var source = this.findSource(elm);
19219
19274
  if (patern.test(tempHTMLContent) || patern2.test(tempHTMLContent) || patern3.test(tempHTMLContent) ||
19220
19275
  pattern4.test(tempHTMLContent)) {
19221
- var source = this.findSource(elm);
19222
19276
  tempHTMLContent = tempHTMLContent.replace(/<img[^>]+>/i, '');
19223
19277
  this.addListClass(elm);
19224
19278
  listNodes = this.cleanUp(elm, listNodes);
@@ -19243,7 +19297,7 @@ var MsWordPaste = /** @__PURE__ @class */ (function () {
19243
19297
  e.callBack(elm.innerHTML, this.cropImageDimensions, source);
19244
19298
  }
19245
19299
  else {
19246
- e.callBack(elm.innerHTML);
19300
+ e.callBack(elm.innerHTML, null, source);
19247
19301
  }
19248
19302
  };
19249
19303
  MsWordPaste.prototype.addDoubleBr = function (elm) {
@@ -21972,15 +22026,7 @@ var HtmlEditor = /** @__PURE__ @class */ (function () {
21972
22026
  }
21973
22027
  else {
21974
22028
  this.parent.notify(enterHandler, { args: e.args });
21975
- var newRange = this.parent.getRange();
21976
- if (!isNullOrUndefined(newRange.startContainer) && this.parent.height !== 'auto' && newRange.startContainer.nodeName !== '#text'
21977
- && !this.parent.iframeSettings.enable && newRange.startContainer.getBoundingClientRect().bottom > this.parent.element.getBoundingClientRect().bottom) {
21978
- this.parent.element.querySelector('.e-rte-content').scrollTop += newRange.startContainer.getBoundingClientRect().bottom - this.parent.element.getBoundingClientRect().bottom;
21979
- }
21980
- else if (!isNullOrUndefined(newRange.startContainer) && this.parent.height === 'auto' && newRange.startContainer.nodeName !== '#text'
21981
- && !this.parent.iframeSettings.enable && window.innerHeight < newRange.startContainer.getBoundingClientRect().top) {
21982
- newRange.startContainer.scrollIntoView({ block: 'end', inline: 'nearest' });
21983
- }
22029
+ scrollToCursor(this.parent.contentModule.getDocument(), this.parent.inputElement);
21984
22030
  }
21985
22031
  }
21986
22032
  }
@@ -23017,7 +23063,9 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
23017
23063
  popupObj.close();
23018
23064
  }
23019
23065
  this.parent.trigger(imageUploadFailed, e);
23020
- uploadObj.destroy();
23066
+ if (uploadObj && document.body.contains(uploadObj.element)) {
23067
+ uploadObj.destroy();
23068
+ }
23021
23069
  };
23022
23070
  PasteCleanup.prototype.popupClose = function (popupObj, uploadObj, imgElem, e) {
23023
23071
  var _this = this;
@@ -23033,7 +23081,7 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
23033
23081
  });
23034
23082
  popupObj.close();
23035
23083
  imgElem.style.opacity = '1';
23036
- if (!uploadObj.isDestroyed) {
23084
+ if (uploadObj && document.body.contains(uploadObj.element)) {
23037
23085
  uploadObj.destroy();
23038
23086
  }
23039
23087
  this.toolbarEnableDisable(false);
@@ -23333,16 +23381,42 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
23333
23381
  extend(args, { elements: returnArgs.elements, imageElements: returnArgs.imgElem }, true);
23334
23382
  _this.parent.formatter.onSuccess(_this.parent, args);
23335
23383
  }, clipBoardElem, null, null, this.parent.enterKey);
23384
+ scrollToCursor(this.parent.contentModule.getDocument(), this.parent.inputElement);
23336
23385
  this.removeTempClass();
23337
23386
  this.parent.notify(toolbarRefresh, {});
23338
23387
  this.cropImageHandler(this.parent.inputElement);
23339
23388
  }
23340
23389
  };
23390
+ PasteCleanup.prototype.convertBlobToBase64 = function (element) {
23391
+ var imgElem = element.querySelectorAll('img');
23392
+ var _loop_1 = function (i) {
23393
+ if (imgElem[i].getAttribute('src') &&
23394
+ imgElem[i].getAttribute('src').startsWith("blob")) {
23395
+ var blobImageUrl = imgElem[i].getAttribute('src');
23396
+ var img_1 = new Image();
23397
+ var onImageLoadEvent_1 = function () {
23398
+ var canvas = document.createElement('canvas');
23399
+ var ctx = canvas.getContext('2d');
23400
+ canvas.width = img_1.width;
23401
+ canvas.height = img_1.height;
23402
+ ctx.drawImage(img_1, 0, 0);
23403
+ var base64String = canvas.toDataURL('image/png');
23404
+ imgElem[i].src = base64String;
23405
+ img_1.removeEventListener('load', onImageLoadEvent_1);
23406
+ };
23407
+ img_1.src = blobImageUrl;
23408
+ img_1.addEventListener('load', onImageLoadEvent_1);
23409
+ }
23410
+ };
23411
+ for (var i = 0; i < imgElem.length; i++) {
23412
+ _loop_1(i);
23413
+ }
23414
+ };
23341
23415
  PasteCleanup.prototype.cropImageHandler = function (element) {
23342
23416
  var _this = this;
23343
23417
  var allImgElm = element.querySelectorAll('.e-img-cropped');
23344
23418
  if (allImgElm.length > 0) {
23345
- var _loop_1 = function (i) {
23419
+ var _loop_2 = function (i) {
23346
23420
  if (allImgElm[i].getAttribute('src').split(',')[0].indexOf('base64') >= 0) {
23347
23421
  var image_1 = new Image();
23348
23422
  image_1.src = allImgElm[i].getAttribute('src');
@@ -23376,26 +23450,37 @@ var PasteCleanup = /** @__PURE__ @class */ (function () {
23376
23450
  }
23377
23451
  };
23378
23452
  for (var i = 0; i < allImgElm.length; i++) {
23379
- _loop_1(i);
23453
+ _loop_2(i);
23380
23454
  }
23381
23455
  }
23382
23456
  else {
23383
- this.imgUploading(this.parent.inputElement);
23384
- if (this.parent.iframeSettings.enable) {
23385
- this.parent.updateValue();
23457
+ if (!isNullOrUndefined(this.parent.insertImageSettings.saveUrl) && !isNullOrUndefined(this.parent.insertImageSettings.path) && !isNullOrUndefined(this.parent.inputElement.querySelectorAll("img")) && this.parent.inputElement.querySelectorAll("img")[0].src.startsWith("blob")) {
23458
+ this.convertBlobToBase64(this.parent.inputElement);
23459
+ setTimeout(function () {
23460
+ _this.imgUploading(_this.parent.inputElement);
23461
+ if (_this.parent.iframeSettings.enable) {
23462
+ _this.parent.updateValue();
23463
+ }
23464
+ }, 20);
23465
+ }
23466
+ else {
23467
+ this.imgUploading(this.parent.inputElement);
23468
+ if (this.parent.iframeSettings.enable) {
23469
+ this.parent.updateValue();
23470
+ }
23386
23471
  }
23387
23472
  }
23388
23473
  };
23389
23474
  PasteCleanup.prototype.addTableClass = function (element, source) {
23390
- source = isNullOrUndefined(source) ? '' : source;
23391
23475
  var tableElement = element.querySelectorAll('table');
23392
23476
  for (var i = 0; i < tableElement.length; i++) {
23393
- if (!tableElement[i].classList.contains('e-rte-table') && (source === 'html' || source === '')) {
23394
- tableElement[i].classList.add('e-rte-table');
23395
- }
23396
- else if (source && source !== 'html') {
23477
+ var isMSTeamsTable = tableElement[i].parentElement.nodeName === 'FIGURE';
23478
+ if (this.parent.pasteCleanupSettings.keepFormat && source && !isMSTeamsTable) {
23397
23479
  tableElement[i].classList.add('e-rte-paste-' + source + '-table');
23398
23480
  }
23481
+ else if (!tableElement[i].classList.contains('e-rte-table')) {
23482
+ tableElement[i].classList.add('e-rte-table');
23483
+ }
23399
23484
  }
23400
23485
  return element;
23401
23486
  };
@@ -34289,6 +34374,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
34289
34374
  this.persistData();
34290
34375
  setStyleAttribute(this.element, { 'width': formatUnit(this.width) });
34291
34376
  attributes(this.element, { role: 'application', 'aria-label': 'Rich Text Editor' });
34377
+ this.beforeRenderClassValue = this.element.getAttribute('class');
34292
34378
  };
34293
34379
  RichTextEditor.prototype.persistData = function () {
34294
34380
  if (this.enablePersistence && this.originalElement.tagName === 'TEXTAREA') {
@@ -35161,6 +35247,10 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
35161
35247
  if (this.isDestroyed || !this.isRendered) {
35162
35248
  return;
35163
35249
  }
35250
+ this.element.className = this.beforeRenderClassValue;
35251
+ this.removeHtmlAttributes();
35252
+ this.removeAttributes();
35253
+ this.beforeRenderClassValue = null;
35164
35254
  if (!isNullOrUndefined(this.timeInterval)) {
35165
35255
  clearInterval(this.timeInterval);
35166
35256
  this.timeInterval = null;
@@ -35228,8 +35318,6 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
35228
35318
  }
35229
35319
  }
35230
35320
  }
35231
- this.removeHtmlAttributes();
35232
- this.removeAttributes();
35233
35321
  _super.prototype.destroy.call(this);
35234
35322
  this.isRendered = false;
35235
35323
  };
@@ -35260,6 +35348,7 @@ var RichTextEditor = /** @__PURE__ @class */ (function (_super) {
35260
35348
  this.element.removeAttribute('aria-disabled');
35261
35349
  this.element.removeAttribute('role');
35262
35350
  this.element.removeAttribute('tabindex');
35351
+ this.element.removeAttribute('aria-label');
35263
35352
  };
35264
35353
  RichTextEditor.prototype.destroyDependentModules = function () {
35265
35354
  /* destroy dependent modules */