@syncfusion/ej2-richtexteditor 28.1.36 → 28.1.38

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.
@@ -6179,17 +6179,21 @@ class ToolbarRenderer {
6179
6179
  value: colorpickerValue
6180
6180
  };
6181
6181
  proxy.parent.notify(selectionRestore, {});
6182
- proxy.currentElement.querySelector('.' + CLS_RTE_ELEMENTS).style.borderBottomColor = colorpickerValue;
6182
+ if (proxy.currentElement) {
6183
+ proxy.currentElement.querySelector('.' + CLS_RTE_ELEMENTS).style.borderBottomColor = colorpickerValue;
6184
+ }
6183
6185
  const range = proxy.parent.formatter.editorManager.nodeSelection.getRange(proxy.parent.contentModule.getDocument());
6184
6186
  const closestElement = closest(range.startContainer.parentNode, 'table');
6185
6187
  if ((range.startContainer.nodeName === 'TD' || range.startContainer.nodeName === 'TH' || range.startContainer.nodeName === 'BODY' ||
6186
- closest(range.startContainer.parentNode, 'td,th')) && range.collapsed && args.subCommand === 'BackgroundColor' && (closest(closestElement, '.' + CLS_RTE) || proxy.parent.iframeSettings.enable)) {
6188
+ (range.startContainer.parentNode && closest(range.startContainer.parentNode, 'td,th'))) && range.collapsed && args.subCommand === 'BackgroundColor' && (closestElement && closest(closestElement, '.' + CLS_RTE) || proxy.parent.iframeSettings.enable)) {
6187
6189
  proxy.parent.notify(tableColorPickerChanged, colorPickerArgs);
6188
6190
  }
6189
6191
  else {
6190
6192
  proxy.parent.notify(colorPickerChanged, colorPickerArgs);
6191
6193
  }
6192
- proxy.currentDropdown.toggle();
6194
+ if (proxy.currentDropdown) {
6195
+ proxy.currentDropdown.toggle();
6196
+ }
6193
6197
  },
6194
6198
  beforeModeSwitch: (args) => {
6195
6199
  value = colorPicker.value;
@@ -14477,34 +14481,40 @@ class Table {
14477
14481
  // eslint-disable-next-line
14478
14482
  applyProperties(args, e) {
14479
14483
  const dialogEle = this.editdlgObj.element;
14480
- const table = closest(args.selectNode[0], 'table');
14481
- table.style.width = dialogEle.querySelector('.e-table-width') ? dialogEle.querySelector('.e-table-width').value + 'px'
14482
- : table.style.width;
14483
- if (dialogEle.querySelector('.e-cell-padding') && dialogEle.querySelector('.e-cell-padding').value !== '') {
14484
- const tdElm = table.querySelectorAll('td');
14485
- for (let i = 0; i < tdElm.length; i++) {
14486
- let padVal = '';
14487
- if (tdElm[i].style.padding === '') {
14488
- padVal = tdElm[i].getAttribute('style') + ' padding:' +
14489
- dialogEle.querySelector('.e-cell-padding').value + 'px;';
14484
+ if (dialogEle && args && args.selectNode.length > 0 && args.selectNode[0]) {
14485
+ const selectedElement = (args.selectNode[0] && args.selectNode[0].nodeType === 3 ?
14486
+ args.selectNode[0].parentNode : args.selectNode[0]);
14487
+ const table = selectedElement ? closest(selectedElement, 'table') : null;
14488
+ if (table) {
14489
+ table.style.width = dialogEle.querySelector('.e-table-width') ? dialogEle.querySelector('.e-table-width').value + 'px'
14490
+ : table.style.width;
14491
+ if (dialogEle.querySelector('.e-cell-padding') && dialogEle.querySelector('.e-cell-padding').value !== '') {
14492
+ const tdElm = table.querySelectorAll('td');
14493
+ for (let i = 0; i < tdElm.length; i++) {
14494
+ let padVal = '';
14495
+ if (tdElm[i].style.padding === '') {
14496
+ padVal = tdElm[i].getAttribute('style') + ' padding:' +
14497
+ dialogEle.querySelector('.e-cell-padding').value + 'px;';
14498
+ }
14499
+ else {
14500
+ tdElm[i].style.padding = dialogEle.querySelector('.e-cell-padding').value + 'px';
14501
+ padVal = tdElm[i].getAttribute('style');
14502
+ }
14503
+ tdElm[i].setAttribute('style', padVal);
14504
+ }
14505
+ }
14506
+ table.cellSpacing = dialogEle.querySelector('.e-cell-spacing') ? dialogEle.querySelector('.e-cell-spacing').value
14507
+ : table.cellSpacing;
14508
+ if (!isNullOrUndefined(table.cellSpacing) && table.cellSpacing !== '0') {
14509
+ addClass([table], CLS_TABLE_BORDER);
14490
14510
  }
14491
14511
  else {
14492
- tdElm[i].style.padding = dialogEle.querySelector('.e-cell-padding').value + 'px';
14493
- padVal = tdElm[i].getAttribute('style');
14512
+ removeClassWithAttr([table], CLS_TABLE_BORDER);
14494
14513
  }
14495
- tdElm[i].setAttribute('style', padVal);
14514
+ this.parent.formatter.saveData();
14515
+ this.editdlgObj.hide({ returnValue: true });
14496
14516
  }
14497
14517
  }
14498
- table.cellSpacing = dialogEle.querySelector('.e-cell-spacing') ? dialogEle.querySelector('.e-cell-spacing').value
14499
- : table.cellSpacing;
14500
- if (!isNullOrUndefined(table.cellSpacing) && table.cellSpacing !== '0') {
14501
- addClass([table], CLS_TABLE_BORDER);
14502
- }
14503
- else {
14504
- removeClassWithAttr([table], CLS_TABLE_BORDER);
14505
- }
14506
- this.parent.formatter.saveData();
14507
- this.editdlgObj.hide({ returnValue: true });
14508
14518
  }
14509
14519
  tableDlgContent(e) {
14510
14520
  const selectNode = e.selectParent[0];
@@ -19400,7 +19410,7 @@ class Formatter {
19400
19410
  }
19401
19411
  }
19402
19412
  const command = actionBeginArgs.item.subCommand.toLocaleLowerCase();
19403
- if (command === 'image') {
19413
+ if (command === 'image' || command === 'file' || command === 'replace') {
19404
19414
  value = actionBeginArgs.itemCollection;
19405
19415
  }
19406
19416
  if (command === 'paste' || command === 'cut' || command === 'copy') {
@@ -28587,6 +28597,7 @@ class SelectionCommands {
28587
28597
  }
28588
28598
  else {
28589
28599
  InsertMethods.unwrap(cursorFormat);
28600
+ domSelection.setCursorPoint(docElement, cursorNode, 0);
28590
28601
  }
28591
28602
  }
28592
28603
  else {
@@ -32696,7 +32707,7 @@ class HtmlEditor {
32696
32707
  onSelectionRestore(e) {
32697
32708
  this.parent.isBlur = false;
32698
32709
  this.contentRenderer.getEditPanel().focus({ preventScroll: true });
32699
- if (isNullOrUndefined(e.items) || e.items) {
32710
+ if ((isNullOrUndefined(e.items) || e.items) && (!isNullOrUndefined(this.saveSelection))) {
32700
32711
  this.saveSelection.restore();
32701
32712
  }
32702
32713
  }
@@ -33154,7 +33165,7 @@ class HtmlEditor {
33154
33165
  let checkParent = false;
33155
33166
  if (this.oldRangeElement && this.oldRangeElement.nodeName !== '#text' && this.oldRangeElement.querySelectorAll('BR').length === 1) {
33156
33167
  const brElement = this.oldRangeElement.querySelector('BR');
33157
- if (brElement) {
33168
+ if (brElement && isNullOrUndefined(brElement.nextSibling)) {
33158
33169
  const brParentElement = brElement.parentNode;
33159
33170
  const currentState = this.oldRangeElement.innerHTML;
33160
33171
  this.parent.formatter.saveData(currentState);
@@ -33911,6 +33922,7 @@ class PasteCleanup {
33911
33922
  const isValueNotEmpty = tempDivElem.textContent !== '' || !isNullOrUndefined(tempDivElem.querySelector('img')) ||
33912
33923
  !isNullOrUndefined(tempDivElem.querySelector('table'));
33913
33924
  const imgElements = tempDivElem.querySelectorAll('img');
33925
+ const base = this.parent.contentModule.getDocument().location.origin;
33914
33926
  imgElements.forEach((imgElement) => {
33915
33927
  let imageFileFormat;
33916
33928
  const imgElementSrc = imgElement.getAttribute('src');
@@ -33919,7 +33931,9 @@ class PasteCleanup {
33919
33931
  imageFileFormat = imgElementSrc.split(';')[0].split('/')[1];
33920
33932
  }
33921
33933
  else {
33922
- imageFileFormat = imgElementSrc.split('.').pop().toLowerCase();
33934
+ const parsedUrl = imgElementSrc.indexOf('http') > -1 ? new URL(imgElementSrc) : new URL(imgElementSrc, base);
33935
+ const path = parsedUrl.pathname;
33936
+ imageFileFormat = path.split('.').pop().toLowerCase();
33923
33937
  }
33924
33938
  if (!isNullOrUndefined(imageFileFormat) &&
33925
33939
  allowedTypes.every((type) => imageFileFormat !== type.substring(1).toLowerCase()) &&
@@ -37754,7 +37768,8 @@ class EnterKeyAction {
37754
37768
  && isSplitTextEmpty && !isPreWrapApplied && !isTextWrapApplied;
37755
37769
  const isCursorAtStartPreWrapWithContent = lastCharBeforeCursor === 32
37756
37770
  && (isPreWrapApplied || isTextWrapApplied) && isSplitTextEmpty && hasContentAfterCursor;
37757
- if (isCursorAtStartNonPreWrap || isCursorAtStartPreWrapWithContent) {
37771
+ if ((isCursorAtStartNonPreWrap || isCursorAtStartPreWrapWithContent) &&
37772
+ !this.range.startContainer.previousSibling) {
37758
37773
  isFocusedFirst = true;
37759
37774
  }
37760
37775
  }
@@ -37763,7 +37778,7 @@ class EnterKeyAction {
37763
37778
  }
37764
37779
  this.removeBRElement(nearBlockNode);
37765
37780
  const fireFoxEnterAtMiddle = Browser.userAgent.indexOf('Firefox') !== -1 && this.range.startOffset === 0 && this.range.startContainer === this.range.endContainer &&
37766
- this.range.startContainer.nodeName === '#text' && !this.parent.formatter.editorManager.domNode.isBlockNode(this.range.startContainer.previousSibling) &&
37781
+ this.range.startContainer.nodeName === '#text' && !isNullOrUndefined(this.range.startContainer.previousSibling) && !this.parent.formatter.editorManager.domNode.isBlockNode(this.range.startContainer.previousSibling) &&
37767
37782
  this.range.startContainer.parentElement === this.range.startContainer.previousSibling.parentElement;
37768
37783
  const preventZeroWithSpace = ((this.range.startContainer.nodeName === '#text' && this.range.startContainer.textContent.includes('\u200B') &&
37769
37784
  this.range.startContainer.textContent.trim() === '\u200B') ||