@syncfusion/ej2-richtexteditor 23.2.6 → 23.2.7

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.
@@ -3345,7 +3345,7 @@ class ToolbarRenderer {
3345
3345
  }
3346
3346
  destroyTooltip() {
3347
3347
  if (!isNullOrUndefined(document.querySelector('.e-tooltip-wrap')) && !isNullOrUndefined(document.querySelector(' [data-tooltip-id]'))) {
3348
- const tooltipTargetEle = document.querySelector('#' + (this.parent.element).id + ' [data-tooltip-id]');
3348
+ const tooltipTargetEle = this.parent.element.querySelector('[data-tooltip-id]');
3349
3349
  const event = new MouseEvent('mouseleave', { bubbles: true, cancelable: true });
3350
3350
  tooltipTargetEle.dispatchEvent(event);
3351
3351
  }
@@ -3505,17 +3505,86 @@ class ToolbarRenderer {
3505
3505
  return;
3506
3506
  }
3507
3507
  // eslint-disable-next-line
3508
- for (let index = 0; index < args.element.childNodes.length; index++) {
3509
- const divNode = this.parent.createElement('div');
3510
- divNode.innerHTML = dropDown.content.trim();
3511
- if (divNode.textContent.trim() !== ''
3512
- && args.element.childNodes[index].textContent.trim() === divNode.textContent.trim()) {
3513
- if (!args.element.childNodes[index].classList.contains('e-active')) {
3514
- addClass([args.element.childNodes[index]], 'e-active');
3508
+ // Table styles dropdown preselect
3509
+ if (proxy.parent.editorMode !== 'Markdown') {
3510
+ const startNode = proxy.parent.getRange().startContainer.parentElement;
3511
+ const tableEle = startNode.closest('table');
3512
+ const trow = startNode.closest('tr');
3513
+ if (!isNullOrUndefined(tableEle) && tableEle.classList.contains('e-dashed-border')) {
3514
+ for (let index = 0; index < args.element.childNodes.length; index++) {
3515
+ if (args.element.childNodes[index].classList.contains('e-dashed-borders')) {
3516
+ addClass([args.element.childNodes[index]], 'e-active');
3517
+ }
3515
3518
  }
3516
3519
  }
3517
- else {
3518
- removeClass([args.element.childNodes[index]], 'e-active');
3520
+ else if (!isNullOrUndefined(tableEle) && !tableEle.classList.contains('e-dashed-border') && tableEle.classList.contains('e-alternate-rows') && window.getComputedStyle(trow).backgroundColor !== '') {
3521
+ for (let index = 0; index < args.element.childNodes.length; index++) {
3522
+ if (args.element.childNodes[index].classList.contains('e-alternate-rows')) {
3523
+ addClass([args.element.childNodes[index]], 'e-active');
3524
+ }
3525
+ }
3526
+ }
3527
+ //Alignments preselect
3528
+ let alignEle = proxy.parent.getRange().startContainer;
3529
+ while (alignEle !== proxy.parent.element.querySelector('.e-content') && !isNullOrUndefined(alignEle.parentElement)) {
3530
+ if (alignEle.nodeName === '#text') {
3531
+ alignEle = alignEle.parentElement;
3532
+ }
3533
+ const alignStyle = window.getComputedStyle(alignEle).textAlign;
3534
+ if (args.items[0].command === 'Alignments') {
3535
+ if ((args.items[0].text === 'Align Left' && (alignStyle === 'left') || alignStyle === 'start')) {
3536
+ addClass([args.element.childNodes[0]], 'e-active');
3537
+ break;
3538
+ }
3539
+ else if (args.items[1].text === 'Align Center' && alignStyle === 'center') {
3540
+ addClass([args.element.childNodes[1]], 'e-active');
3541
+ break;
3542
+ }
3543
+ else if (args.items[2].text === 'Align Right' && alignStyle === 'right') {
3544
+ addClass([args.element.childNodes[2]], 'e-active');
3545
+ break;
3546
+ }
3547
+ else if (args.items[3].text === 'Align Justify' && alignStyle === 'justify') {
3548
+ addClass([args.element.childNodes[3]], 'e-active');
3549
+ break;
3550
+ }
3551
+ }
3552
+ alignEle = alignEle.parentElement;
3553
+ }
3554
+ //image preselect
3555
+ const imageEle = startNode.closest('img') ? startNode.closest('img') : startNode.querySelector('img');
3556
+ if (args.items[0].command === 'Images') {
3557
+ if (!isNullOrUndefined(imageEle)) {
3558
+ let index;
3559
+ if (imageEle.classList.contains('e-imgleft') || imageEle.classList.contains('e-imginline')) {
3560
+ index = 0;
3561
+ }
3562
+ else if (imageEle.classList.contains('e-imgcenter') || imageEle.classList.contains('e-imgbreak')) {
3563
+ index = 1;
3564
+ }
3565
+ else if (imageEle.classList.contains('e-imgright')) {
3566
+ index = 2;
3567
+ }
3568
+ if (!isNullOrUndefined(args.element.childNodes[index])) {
3569
+ addClass([args.element.childNodes[index]], 'e-active');
3570
+ }
3571
+ }
3572
+ }
3573
+ //Formats preselect
3574
+ if (args.items[0].command === 'Formats') {
3575
+ for (let index = 0; index < args.element.childNodes.length; index++) {
3576
+ const divNode = this.parent.createElement('div');
3577
+ divNode.innerHTML = dropDown.content.trim();
3578
+ if (divNode.textContent.trim() !== ''
3579
+ && args.element.childNodes[index].textContent.trim() === divNode.textContent.trim()) {
3580
+ if (!args.element.childNodes[index].classList.contains('e-active')) {
3581
+ addClass([args.element.childNodes[index]], 'e-active');
3582
+ }
3583
+ }
3584
+ else {
3585
+ removeClass([args.element.childNodes[index]], 'e-active');
3586
+ }
3587
+ }
3519
3588
  }
3520
3589
  }
3521
3590
  proxy.parent.notify(beforeDropDownOpen, args);
@@ -13586,7 +13655,9 @@ class InsertHtml {
13586
13655
  static findDetachEmptyElem(element) {
13587
13656
  let removableElement;
13588
13657
  if (!isNullOrUndefined(element.parentElement)) {
13589
- if (element.parentElement.textContent.trim() === '' && element.parentElement.contentEditable !== 'true' &&
13658
+ const hasNbsp = element.parentElement.textContent.length > 0 && element.parentElement.textContent.match(/\u00a0/g)
13659
+ && element.parentElement.textContent.match(/\u00a0/g).length > 0;
13660
+ if (!hasNbsp && element.parentElement.textContent.trim() === '' && element.parentElement.contentEditable !== 'true' &&
13590
13661
  isNullOrUndefined(element.parentElement.querySelector('img'))) {
13591
13662
  removableElement = this.findDetachEmptyElem(element.parentElement);
13592
13663
  }
@@ -17813,7 +17884,9 @@ class MsWordPaste {
17813
17884
  isNullOrUndefined(allElements[i].nextElementSibling)))) {
17814
17885
  const detachableElement = this.findDetachElem(allElements[i]);
17815
17886
  const brElement = createElement('br');
17816
- if (!isNullOrUndefined(detachableElement.parentElement)) {
17887
+ const hasNbsp = detachableElement.textContent.length > 0 && detachableElement.textContent.match(/\u00a0/g)
17888
+ && detachableElement.textContent.match(/\u00a0/g).length > 0;
17889
+ if (!hasNbsp && !isNullOrUndefined(detachableElement.parentElement)) {
17817
17890
  detachableElement.parentElement.insertBefore(brElement, detachableElement);
17818
17891
  detach(detachableElement);
17819
17892
  }
@@ -17852,7 +17925,9 @@ class MsWordPaste {
17852
17925
  findDetachEmptyElem(element) {
17853
17926
  let removableElement;
17854
17927
  if (!isNullOrUndefined(element.parentElement)) {
17855
- if (element.parentElement.textContent.trim() === '' &&
17928
+ const hasNbsp = element.parentElement.textContent.length > 0 && element.parentElement.textContent.match(/\u00a0/g)
17929
+ && element.parentElement.textContent.match(/\u00a0/g).length > 0;
17930
+ if (!hasNbsp && element.parentElement.textContent.trim() === '' &&
17856
17931
  element.parentElement.getAttribute('id') !== 'MSWord-Content' &&
17857
17932
  !(this.hasParentWithClass(element, 'MsoListParagraph')) &&
17858
17933
  isNullOrUndefined(element.parentElement.querySelector('img'))) {
@@ -21265,7 +21340,7 @@ class PasteCleanup {
21265
21340
  const popupEle = this.parent.createElement('div');
21266
21341
  this.parent.element.appendChild(popupEle);
21267
21342
  const contentEle = this.parent.createElement('input', {
21268
- id: this.parent.element.id + '_upload', attrs: { type: 'File', name: 'UploadFiles' }
21343
+ id: this.parent.getID() + '_upload', attrs: { type: 'File', name: 'UploadFiles' }
21269
21344
  });
21270
21345
  const offsetY = this.parent.iframeSettings.enable ? -50 : -90;
21271
21346
  this.popupObj = new Popup(popupEle, {
@@ -21885,7 +21960,9 @@ class PasteCleanup {
21885
21960
  findDetachEmptyElem(element) {
21886
21961
  let removableElement;
21887
21962
  if (!isNullOrUndefined(element.parentElement)) {
21888
- if (element.parentElement.textContent.trim() === '' &&
21963
+ const hasNbsp = element.parentElement.textContent.length > 0 && element.parentElement.textContent.match(/\u00a0/g)
21964
+ && element.parentElement.textContent.match(/\u00a0/g).length > 0;
21965
+ if (!hasNbsp && element.parentElement.textContent.trim() === '' &&
21889
21966
  element.parentElement.getAttribute('class') !== 'pasteContent') {
21890
21967
  removableElement = this.findDetachEmptyElem(element.parentElement);
21891
21968
  }
@@ -25222,7 +25299,6 @@ class Image$1 {
25222
25299
  width: '290px',
25223
25300
  header: this.parent.localeObj.getConstant('imageInsertLinkHeader'),
25224
25301
  content: linkWrap,
25225
- position: { X: 'center', Y: 'center' },
25226
25302
  buttons: [{
25227
25303
  // eslint-disable-next-line
25228
25304
  click: (e) => {
@@ -25271,7 +25347,7 @@ class Image$1 {
25271
25347
  alt: inputAlt
25272
25348
  };
25273
25349
  this.dialogObj.setProperties({
25274
- height: 'inherit', width: '290px', header: altHeader, content: altWrap, position: { X: 'center', Y: 'center' },
25350
+ height: 'inherit', width: '290px', header: altHeader, content: altWrap,
25275
25351
  buttons: [{
25276
25352
  // eslint-disable-next-line
25277
25353
  click: (e) => {
@@ -25497,7 +25573,7 @@ class Image$1 {
25497
25573
  const dialogContent = this.imgsizeInput(e);
25498
25574
  const selectObj = { args: e.args, selfImage: this, selection: e.selection, selectNode: e.selectNode };
25499
25575
  this.dialogObj.setProperties({
25500
- height: (Browser.isDevice) ? '300px' : 'inherit', width: '290px', header: imgSizeHeader, content: dialogContent, position: { X: 'center', Y: 'center' },
25576
+ height: (Browser.isDevice) ? '300px' : 'inherit', width: '290px', header: imgSizeHeader, content: dialogContent,
25501
25577
  buttons: [{
25502
25578
  // eslint-disable-next-line
25503
25579
  click: (e) => {
@@ -25562,7 +25638,6 @@ class Image$1 {
25562
25638
  enableRtl: this.parent.enableRtl,
25563
25639
  locale: this.parent.locale,
25564
25640
  showCloseIcon: true, closeOnEscape: true, width: (Browser.isDevice) ? '290px' : '340px',
25565
- position: { X: 'center', Y: (Browser.isDevice) ? 'center' : 'top' },
25566
25641
  isModal: Browser.isDevice,
25567
25642
  buttons: [{
25568
25643
  click: this.insertImageUrl.bind(selectObj),
@@ -27043,7 +27118,6 @@ class Audio {
27043
27118
  enableRtl: this.parent.enableRtl,
27044
27119
  locale: this.parent.locale,
27045
27120
  showCloseIcon: true, closeOnEscape: true, width: (Browser.isDevice) ? '290px' : '340px',
27046
- position: { X: 'center', Y: (Browser.isDevice) ? 'center' : 'top' },
27047
27121
  isModal: Browser.isDevice,
27048
27122
  buttons: [{
27049
27123
  click: this.insertAudioUrl.bind(selectObj),
@@ -27472,7 +27546,7 @@ class Video {
27472
27546
  const dialogContent = this.vidsizeInput(e);
27473
27547
  const selectObj = { args: e.args, selfVideo: this, selection: e.selection, selectNode: e.selectNode };
27474
27548
  this.dialogObj.setProperties({
27475
- height: 'inherit', width: '290px', header: vidSizeHeader, content: dialogContent, position: { X: 'center', Y: 'center' },
27549
+ height: 'inherit', width: '290px', header: vidSizeHeader, content: dialogContent,
27476
27550
  buttons: [{
27477
27551
  // eslint-disable-next-line
27478
27552
  click: (e) => {
@@ -28372,7 +28446,6 @@ class Video {
28372
28446
  enableRtl: this.parent.enableRtl,
28373
28447
  locale: this.parent.locale,
28374
28448
  showCloseIcon: true, closeOnEscape: true, width: (Browser.isDevice) ? '290px' : '340px',
28375
- position: { X: 'center', Y: (Browser.isDevice) ? 'center' : 'top' },
28376
28449
  isModal: Browser.isDevice,
28377
28450
  buttons: [{
28378
28451
  click: this.insertVideoUrl.bind(selectObj),
@@ -28852,13 +28925,13 @@ class ViewSource {
28852
28925
  this.parent.updateValueData();
28853
28926
  if (this.parent.iframeSettings.enable) {
28854
28927
  let rteContent;
28855
- if (isNullOrUndefined(this.parent.element.querySelector('#' + this.parent.element.id + '_source-view'))) {
28928
+ if (isNullOrUndefined(this.parent.element.querySelector('#' + this.parent.getID() + '_source-view'))) {
28856
28929
  rteContent = this.parent.createElement('div', {
28857
- className: 'e-source-content', id: this.parent.element.id + '_source-view'
28930
+ className: 'e-source-content', id: this.parent.getID() + '_source-view'
28858
28931
  });
28859
28932
  }
28860
28933
  else {
28861
- rteContent = this.parent.element.querySelector('#' + this.parent.element.id + '_source-view');
28934
+ rteContent = this.parent.element.querySelector('#' + this.parent.getID() + '_source-view');
28862
28935
  }
28863
28936
  rteContent.appendChild(this.previewElement);
28864
28937
  this.parent.element.appendChild(rteContent);
@@ -29038,6 +29111,7 @@ class Table {
29038
29111
  this.parent.on(tableToolbarAction, this.onToolbarAction, this);
29039
29112
  this.parent.on(dropDownSelect, this.dropdownSelect, this);
29040
29113
  this.parent.on(keyDown, this.keyDown, this);
29114
+ this.parent.on(keyUp, this.keyUp, this);
29041
29115
  this.parent.on(mouseUp, this.selectionTable, this);
29042
29116
  this.parent.on(tableModulekeyUp, this.tableModulekeyUp, this);
29043
29117
  this.parent.on(bindCssClass, this.setCssClass, this);
@@ -29060,6 +29134,7 @@ class Table {
29060
29134
  this.parent.off(dropDownSelect, this.dropdownSelect);
29061
29135
  this.parent.off(mouseDown, this.cellSelect);
29062
29136
  this.parent.off(tableColorPickerChanged, this.setBGColor);
29137
+ this.parent.off(keyUp, this.keyUp);
29063
29138
  this.parent.off(keyDown, this.keyDown);
29064
29139
  this.parent.off(mouseUp, this.selectionTable);
29065
29140
  this.parent.off(tableModulekeyUp, this.tableModulekeyUp);
@@ -29164,6 +29239,12 @@ class Table {
29164
29239
  this.parent.formatter.process(this.parent, e, e, { selection: selectCell, subCommand: e.item.subCommand });
29165
29240
  this.hideTableQuickToolbar();
29166
29241
  }
29242
+ keyUp(e) {
29243
+ const target = e.args.target;
29244
+ if (e.args.key.toLocaleLowerCase() === 'escape' && target && target.classList && (this.popupObj && !closest(target, '[id=' + "'" + this.popupObj.element.id + "'" + ']')) && this.popupObj) {
29245
+ this.popupObj.hide();
29246
+ }
29247
+ }
29167
29248
  keyDown(e) {
29168
29249
  const event = e.args;
29169
29250
  // eslint-disable-next-line
@@ -30565,6 +30646,7 @@ class DialogRenderer {
30565
30646
  let dlgObj;
30566
30647
  e.beforeOpen = this.beforeOpen.bind(this);
30567
30648
  e.open = this.open.bind(this);
30649
+ e.position = { X: 'center', Y: this.getDialogPosition() };
30568
30650
  if (isNullOrUndefined(e.close)) {
30569
30651
  e.close = this.close.bind(this);
30570
30652
  }
@@ -30609,6 +30691,16 @@ class DialogRenderer {
30609
30691
  }
30610
30692
  });
30611
30693
  }
30694
+ getDialogPosition() {
30695
+ let distanceFromVisibleTop = this.parent.element.getBoundingClientRect().top;
30696
+ if (distanceFromVisibleTop < 0) {
30697
+ distanceFromVisibleTop = Math.abs(distanceFromVisibleTop);
30698
+ return distanceFromVisibleTop.toString();
30699
+ }
30700
+ else {
30701
+ return 'top';
30702
+ }
30703
+ }
30612
30704
  /**
30613
30705
  * dialog close method
30614
30706
  *
@@ -31661,7 +31753,7 @@ class EnterKeyAction {
31661
31753
  let newElem;
31662
31754
  const outerBRElem = this.parent.createElement('br');
31663
31755
  if (this.range.startOffset === 0 && this.range.endOffset === 0 &&
31664
- !isNullOrUndefined(currentParent.previousSibling) && currentParent.previousSibling.nodeName === 'BR') {
31756
+ !isNullOrUndefined(currentParent.previousSibling) && currentParent.previousSibling.nodeName === 'BR' && currentParent.nodeName !== 'P' && currentParent.nodeName !== 'DIV') {
31665
31757
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
31666
31758
  newElem = this.parent.formatter.editorManager.nodeCutter.SplitNode(this.range, currentParent, false).cloneNode(true);
31667
31759
  this.parent.formatter.editorManager.domNode.insertAfter(outerBRElem, currentParent);