@syncfusion/ej2-richtexteditor 27.2.2 → 27.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.
@@ -3055,11 +3055,11 @@ let formatsLocale = [
3055
3055
  let numberFormatListLocale = [
3056
3056
  { locale: 'numberFormatListNone', value: 'none' },
3057
3057
  { locale: 'numberFormatListNumber', value: 'decimal' },
3058
- { locale: 'numberFormatListLowerAlpha', value: 'lower-alpha' },
3059
- { locale: 'numberFormatListUpperAlpha', value: 'upper-alpha' },
3060
- { locale: 'numberFormatListLowerRoman', value: 'lower-roman' },
3061
- { locale: 'numberFormatListUpperRoman', value: 'upper-roman' },
3062
- { locale: 'numberFormatListLowerGreek', value: 'lower-greek' }
3058
+ { locale: 'numberFormatListLowerAlpha', value: 'lowerAlpha' },
3059
+ { locale: 'numberFormatListUpperAlpha', value: 'upperAlpha' },
3060
+ { locale: 'numberFormatListLowerRoman', value: 'lowerRoman' },
3061
+ { locale: 'numberFormatListUpperRoman', value: 'upperRoman' },
3062
+ { locale: 'numberFormatListLowerGreek', value: 'lowerGreek' }
3063
3063
  ];
3064
3064
  let bulletFormatListLocale = [
3065
3065
  { locale: 'bulletFormatListNone', value: 'none' },
@@ -3135,6 +3135,9 @@ function hasClass(element, className) {
3135
3135
  function getDropDownValue(items, value, type, returnType) {
3136
3136
  let data;
3137
3137
  let result;
3138
+ if (items.length === 0 && value === 'FontSize') {
3139
+ return 'Font Size';
3140
+ }
3138
3141
  for (let k = 0; k < items.length; k++) {
3139
3142
  if (type === 'value' && items[k].value.toLocaleLowerCase() === value.toLocaleLowerCase()) {
3140
3143
  data = items[k];
@@ -3282,7 +3285,7 @@ function setToolbarStatus(e, isPopToolbar, self) {
3282
3285
  }
3283
3286
  const fontNameItems = e.parent.fontFamily.items;
3284
3287
  result = value === 'empty' ? '' : getDropDownValue(fontNameItems, value, 'value', 'text');
3285
- const fontNameContent = isNullOrUndefined(e.parent.fontFamily.default) ? fontNameItems[0].text :
3288
+ const fontNameContent = isNullOrUndefined(e.parent.fontFamily.default) ? (fontNameItems.length === 0) ? self.serviceLocator.getService('rteLocale').getConstant('fontName') : fontNameItems[0].text :
3286
3289
  e.parent.fontFamily.default;
3287
3290
  const name = (isNullOrUndefined(result) ? fontNameContent : result) === 'Default' ? self.serviceLocator.getService('rteLocale').getConstant('fontName')
3288
3291
  : (isNullOrUndefined(result) ? fontNameContent : result);
@@ -3299,9 +3302,9 @@ function setToolbarStatus(e, isPopToolbar, self) {
3299
3302
  break;
3300
3303
  }
3301
3304
  const fontSizeItems = e.parent.fontSize.items;
3302
- const fontSizeContent = isNullOrUndefined(e.parent.fontSize.default) ? fontSizeItems[0].text :
3305
+ const fontSizeContent = isNullOrUndefined(e.parent.fontSize.default) ? (fontSizeItems.length === 0) ? self.serviceLocator.getService('rteLocale').getConstant('fontSize') : fontSizeItems[0].text :
3303
3306
  e.parent.fontSize.default;
3304
- const fontSizeToolbarText = getDropDownValue(fontSizeItems, (value === '' ? fontSizeContent.replace(/\s/g, '') : value), (fontSizeContent.replace(/\s/g, '') === fontSizeItems[0].text && value === '') ? 'text' : 'value', 'text');
3307
+ const fontSizeToolbarText = getDropDownValue(fontSizeItems, (value === '' ? fontSizeContent.replace(/\s/g, '') : value), (fontSizeItems.length > 0 && fontSizeItems[0] && fontSizeContent.replace(/\s/g, '') === fontSizeItems[0].text && value === '') ? 'text' : 'value', 'text');
3305
3308
  result = value === 'empty' ? '' : (fontSizeToolbarText === 'Default') ? self.serviceLocator.getService('rteLocale').getConstant('fontSize') : fontSizeToolbarText;
3306
3309
  dropDown.fontSizeDropDown.content = ('<span style="display: inline-flex;' +
3307
3310
  'width:' + e.parent.fontSize.width + '" >' +
@@ -5676,7 +5679,7 @@ class ToolbarRenderer {
5676
5679
  alignEle = alignEle.parentElement;
5677
5680
  }
5678
5681
  const alignStyle = window.getComputedStyle(alignEle).textAlign;
5679
- if (args.items[0].command === 'Alignments') {
5682
+ if (!isNullOrUndefined(args.items[0]) && args.items[0].command === 'Alignments') {
5680
5683
  if ((args.items[0].text === 'Align Left' && (alignStyle === 'left') || alignStyle === 'start')) {
5681
5684
  addClass([args.element.childNodes[0]], 'e-active');
5682
5685
  break;
@@ -5699,7 +5702,7 @@ class ToolbarRenderer {
5699
5702
  //image preselect
5700
5703
  const closestNode = startNode.closest('img');
5701
5704
  const imageEle = closestNode ? closestNode : startNode.querySelector('img');
5702
- if (args.items[0].command === 'Images') {
5705
+ if (!isNullOrUndefined(args.items[0]) && args.items[0].command === 'Images') {
5703
5706
  if (!isNullOrUndefined(imageEle)) {
5704
5707
  let index;
5705
5708
  if (imageEle.classList.contains('e-imgleft') || imageEle.classList.contains('e-imginline')) {
@@ -5717,7 +5720,7 @@ class ToolbarRenderer {
5717
5720
  }
5718
5721
  }
5719
5722
  //Formats preselect
5720
- if (args.items[0].command === 'Formats' || args.items[0].command === 'Font') {
5723
+ if (!isNullOrUndefined(args.items[0]) && (args.items[0].command === 'Formats' || args.items[0].command === 'Font')) {
5721
5724
  const fontName = [];
5722
5725
  const formats = [];
5723
5726
  let hasUpdatedActive = false;
@@ -8745,9 +8748,17 @@ class Image$1 {
8745
8748
  }
8746
8749
  };
8747
8750
  proxy.inputUrl.setAttribute('disabled', 'true');
8748
- if (isNullOrUndefined(proxy.parent.insertImageSettings.saveUrl) && this.isAllowedTypes
8749
- && !isNullOrUndefined(this.dialogObj) && selectArgs.filesData[0].size <= this.uploadObj.maxFileSize) {
8750
- this.dialogObj.getButtons(0).element.removeAttribute('disabled');
8751
+ if (!isNullOrUndefined(this.dialogObj)) {
8752
+ const button = this.dialogObj.getButtons(0);
8753
+ if (!isNullOrUndefined(button)) {
8754
+ if (isNullOrUndefined(proxy.parent.insertImageSettings.saveUrl) && this.isAllowedTypes
8755
+ && selectArgs.filesData[0].size <= this.uploadObj.maxFileSize) {
8756
+ button.element.removeAttribute('disabled');
8757
+ }
8758
+ else {
8759
+ button.element.setAttribute('disabled', 'true');
8760
+ }
8761
+ }
8751
8762
  }
8752
8763
  });
8753
8764
  reader.readAsDataURL(selectArgs.filesData[0].rawFile);
@@ -16166,11 +16177,11 @@ class DropDownButtons {
16166
16177
  command: { value: 'Font', enumerable: true }, subCommand: { value: 'FontName', enumerable: true }
16167
16178
  });
16168
16179
  });
16169
- const fontNameContent = isNullOrUndefined(this.parent.fontFamily.default) ? fontItem[0].text :
16180
+ const fontNameContent = isNullOrUndefined(this.parent.fontFamily.default) ? fontItem.length === 0 ? '' : fontItem[0].text :
16170
16181
  this.parent.fontFamily.default;
16171
16182
  this.fontNameDropDown = this.toolbarRenderer.renderDropDownButton({
16172
16183
  iconCss: ((type === 'quick') ? 'e-font-name e-icons' : ''),
16173
- content: this.dropdownContent(this.parent.fontFamily.width, type, ((type === 'quick') ? '' : (getDropDownValue(fontItem, fontNameContent, 'text', 'text') === 'Default' ? this.i10n.getConstant('fontName') : getDropDownValue(fontItem, fontNameContent, 'text', 'text')))),
16184
+ content: this.dropdownContent(this.parent.fontFamily.width, type, ((fontItem.length === 0) ? this.i10n.getConstant('fontName') : (type === 'quick') ? '' : (getDropDownValue(fontItem, fontNameContent, 'text', 'text') === 'Default' ? this.i10n.getConstant('fontName') : getDropDownValue(fontItem, fontNameContent, 'text', 'text')))),
16174
16185
  cssClass: CLS_DROPDOWN_POPUP + ' ' + CLS_DROPDOWN_ITEMS + ' ' + CLS_FONT_NAME_TB_BTN,
16175
16186
  itemName: 'FontName', items: fontItem, element: targetElement
16176
16187
  });
@@ -16189,11 +16200,11 @@ class DropDownButtons {
16189
16200
  command: { value: 'Font', enumerable: true }, subCommand: { value: 'FontSize', enumerable: true }
16190
16201
  });
16191
16202
  });
16192
- const fontSizeContent = isNullOrUndefined(this.parent.fontSize.default) ? fontsize[0].text :
16203
+ const fontSizeContent = isNullOrUndefined(this.parent.fontSize.default) ? fontsize.length === 0 ? '' : fontsize[0].text :
16193
16204
  this.parent.fontSize.default;
16194
16205
  const fontSizeDropDownContent = ((fontSizeContent === 'Default') ? getDropDownValue(fontsize, fontSizeContent.replace(/\s/g, ''), 'text', 'text') : getDropDownValue(fontsize, fontSizeContent.replace(/\s/g, ''), 'value', 'text'));
16195
16206
  this.fontSizeDropDown = this.toolbarRenderer.renderDropDownButton({
16196
- content: this.dropdownContent(this.parent.fontSize.width, type, getFormattedFontSize((fontSizeDropDownContent === 'Default') ? this.i10n.getConstant('fontSize') : fontSizeDropDownContent)),
16207
+ content: this.dropdownContent(this.parent.fontSize.width, type, fontsize.length === 0 ? this.i10n.getConstant('fontSize') : (getFormattedFontSize((fontSizeDropDownContent === 'Default') ? this.i10n.getConstant('fontSize') : fontSizeDropDownContent))),
16197
16208
  cssClass: CLS_DROPDOWN_POPUP + ' ' + CLS_DROPDOWN_ITEMS + ' ' + CLS_FONT_SIZE_TB_BTN,
16198
16209
  itemName: 'FontSize', items: fontsize, element: targetElement
16199
16210
  });
@@ -17068,6 +17079,13 @@ class Toolbar {
17068
17079
  target: this.tbElement,
17069
17080
  cssClass: this.parent.getCssClass()
17070
17081
  });
17082
+ if (this.parent.element.classList.contains('e-rte-full-screen')) {
17083
+ this.updateItem({
17084
+ targetItem: 'Maximize',
17085
+ updateItem: 'Minimize',
17086
+ baseToolbar: this.parent.getBaseToolbarObject()
17087
+ });
17088
+ }
17071
17089
  if (!this.parent.inlineMode.enable) {
17072
17090
  if (this.parent.toolbarSettings.enableFloating) {
17073
17091
  this.checkIsTransformChild();
@@ -23870,7 +23888,7 @@ class NodeCutter {
23870
23888
  fragment = this.spliceEmptyNode(fragment, false);
23871
23889
  if (fragment && fragment.childNodes.length > 0) {
23872
23890
  const isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG' && !(fragment.querySelectorAll('img').length > 0)
23873
- && this.isRteElm(fragment) && fragment.textContent.trim() === '' && fragment.textContent !== ' ' && fragment.textContent.charCodeAt(0) !== 160) ? true : false;
23891
+ && this.isRteElm(fragment) && fragment.textContent.trim() === '' && fragment.textContent.charCodeAt(0) !== 32 && fragment.textContent.charCodeAt(0) !== 160) ? true : false;
23874
23892
  if (!isEmpty) {
23875
23893
  if (node) {
23876
23894
  InsertMethods.AppendBefore(fragment, node);
@@ -23891,11 +23909,16 @@ class NodeCutter {
23891
23909
  fragment = this.spliceEmptyNode(fragment, true);
23892
23910
  if (fragment && fragment.childNodes.length > 0) {
23893
23911
  const isEmpty = (fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName !== 'IMG'
23894
- && this.isRteElm(fragment) && fragment.textContent.trim() === '' && fragment.textContent !== ' ' && fragment.textContent.charCodeAt(0) !== 160) ? true : false;
23912
+ && this.isRteElm(fragment) && fragment.textContent.trim() === '' && fragment.textContent.charCodeAt(0) !== 32 && fragment.textContent.charCodeAt(0) !== 160) ? true : false;
23895
23913
  if (!isEmpty) {
23896
23914
  if (node) {
23897
23915
  InsertMethods.AppendBefore(fragment, node, true);
23898
23916
  }
23917
+ else if (parent.childNodes.length > 1 && parent.childNodes.length !== index) {
23918
+ node = parent.childNodes[parent.childNodes.length - 1];
23919
+ InsertMethods.AppendBefore(fragment, node, true);
23920
+ node = node.nextSibling;
23921
+ }
23899
23922
  else {
23900
23923
  parent.appendChild(fragment);
23901
23924
  const divNode = document.createElement('div');
@@ -28123,8 +28146,10 @@ class SelectionCommands {
28123
28146
  range.startContainer.textContent.substring(range.startOffset, range.startContainer.textContent.length) :
28124
28147
  range.startContainer.textContent;
28125
28148
  const nodeText = nodes[index].textContent;
28149
+ const isParentNodeSameAsParentElement = nodes[0].parentElement.nodeName === nodes[0].parentElement.parentElement.nodeName;
28126
28150
  if (!(range.startContainer === range.endContainer && range.startOffset === 0
28127
- && range.endOffset === range.startContainer.length)) {
28151
+ && range.endOffset === range.startContainer.length
28152
+ && (range.startContainer.textContent === formatNode.textContent || isParentNodeSameAsParentElement))) {
28128
28153
  const nodeIndex = [];
28129
28154
  let cloneNode = nodes[index];
28130
28155
  const clonedElement = cloneNode;
@@ -28145,10 +28170,19 @@ class SelectionCommands {
28145
28170
  if (!isCursor) {
28146
28171
  while (cloneNode && cloneNode.childNodes.length > 0 && ((nodeIndex.length - 1) >= 0)
28147
28172
  && (cloneNode.childNodes.length > nodeIndex[nodeIndex.length - 1])) {
28148
- cloneNode = cloneNode.childNodes[nodeIndex[nodeIndex.length - 1]];
28149
- nodeIndex.pop();
28173
+ if (cloneNode.childNodes.length > 1 && nodeIndex.length > 1) {
28174
+ cloneNode = cloneNode.childNodes[nodeIndex[nodeIndex.length - 2]];
28175
+ break;
28176
+ }
28177
+ else {
28178
+ cloneNode = cloneNode.childNodes[nodeIndex[nodeIndex.length - 1]];
28179
+ nodeIndex.pop();
28180
+ }
28150
28181
  }
28151
28182
  if (nodes[index].nodeName !== 'BR') {
28183
+ while (cloneNode.nodeType === 1 && cloneNode.childNodes.length > 0) {
28184
+ cloneNode = cloneNode.childNodes[0];
28185
+ }
28152
28186
  if (cloneNode.nodeType === 3 && !(isCursor && cloneNode.nodeValue === '')) {
28153
28187
  nodes[index] = cloneNode;
28154
28188
  }
@@ -32415,7 +32449,10 @@ class HtmlEditor {
32415
32449
  const editorValue = currentRange.startContainer.textContent.slice(0, currentRange.startOffset);
32416
32450
  const orderedList = this.isOrderedList(editorValue);
32417
32451
  const unOrderedList = this.isUnOrderedList(editorValue);
32418
- const hasSplitedText = this.hasMultipleTextNode(currentRange);
32452
+ let hasSplitedText = false;
32453
+ if (orderedList || unOrderedList) {
32454
+ hasSplitedText = this.hasMultipleTextNode(currentRange);
32455
+ }
32419
32456
  if (!hasSplitedText && (orderedList && !unOrderedList || unOrderedList && !orderedList)) {
32420
32457
  const eventArgs = {
32421
32458
  callBack: null,
@@ -32485,6 +32522,11 @@ class HtmlEditor {
32485
32522
  hasMultipleTextNode(range) {
32486
32523
  if (range && range.startContainer && range.startContainer.parentNode) {
32487
32524
  const parentNode = range.startContainer.parentNode;
32525
+ if (range.startContainer.previousElementSibling &&
32526
+ range.startContainer.previousElementSibling.classList.contains('e-mention-chip')
32527
+ && !range.startContainer.previousElementSibling.isContentEditable) {
32528
+ return true;
32529
+ }
32488
32530
  if (this.parent.enterKey === 'BR' || closest(parentNode, 'table')) {
32489
32531
  return false;
32490
32532
  }
@@ -32570,10 +32612,21 @@ class HtmlEditor {
32570
32612
  // eslint-disable-next-line
32571
32613
  lastNode, lastNode.textContent.length);
32572
32614
  }
32573
- if (this.oldRangeElement.nodeName !== '#text' && this.oldRangeElement.querySelectorAll('BR').length === 1) {
32574
- detach(this.oldRangeElement.querySelector('BR'));
32615
+ let checkParent = false;
32616
+ if (this.oldRangeElement && this.oldRangeElement.nodeName !== '#text' && this.oldRangeElement.querySelectorAll('BR').length === 1) {
32617
+ const brElement = this.oldRangeElement.querySelector('BR');
32618
+ if (brElement) {
32619
+ const brParentElement = brElement.parentNode;
32620
+ const currentState = this.oldRangeElement.innerHTML;
32621
+ this.parent.formatter.saveData(currentState);
32622
+ detach(brElement);
32623
+ if (brParentElement && brParentElement.childNodes.length === 0) {
32624
+ detach(brParentElement);
32625
+ checkParent = true;
32626
+ }
32627
+ }
32575
32628
  }
32576
- if (!isNullOrUndefined(this.rangeElement) && this.oldRangeElement !== this.rangeElement) {
32629
+ if (!isNullOrUndefined(this.rangeElement) && this.oldRangeElement !== this.rangeElement && !checkParent) {
32577
32630
  while (this.rangeElement.firstChild) {
32578
32631
  if (this.oldRangeElement.nodeName === '#text') {
32579
32632
  this.oldRangeElement.parentElement.appendChild(this.rangeElement.childNodes[0]);
@@ -37024,13 +37077,21 @@ class EnterKeyAction {
37024
37077
  }
37025
37078
  let isMediaNode = false; // To check the image audio and video node cases
37026
37079
  let isFocusedFirst = false;
37080
+ const parentElement = this.range.startContainer.parentElement;
37081
+ const isPreWrapApplied = parentElement ? this.parent.contentModule.getDocument().defaultView.getComputedStyle(this.range.startContainer.parentElement, null).getPropertyValue('white-space') === 'pre-wrap' : false;
37027
37082
  if (this.range.startOffset !== 0 && this.range.endOffset !== 0 &&
37028
37083
  this.range.startContainer === this.range.endContainer && !(!isNullOrUndefined(nearBlockNode.childNodes[0])
37029
37084
  && (nearBlockNode.childNodes[0].nodeName === 'IMG' || nearBlockNode.querySelectorAll('img, audio, video').length > 0))) {
37030
37085
  const startNodeText = this.range.startContainer.textContent;
37031
37086
  const splitFirstText = startNodeText.substring(0, this.range.startOffset);
37032
- // eslint-disable-next-line max-len
37033
- if (splitFirstText.charCodeAt(this.range.startOffset - 1) !== 160 && splitFirstText.trim().length === 0) {
37087
+ const lastCharBeforeCursor = splitFirstText.charCodeAt(this.range.startOffset - 1);
37088
+ const isSplitTextEmpty = splitFirstText.trim().length === 0;
37089
+ const hasContentAfterCursor = startNodeText.slice(this.range.startOffset).trim().length !== 0;
37090
+ const isCursorAtStartNonPreWrap = lastCharBeforeCursor !== 160
37091
+ && isSplitTextEmpty && !isPreWrapApplied;
37092
+ const isCursorAtStartPreWrapWithContent = lastCharBeforeCursor === 32
37093
+ && isPreWrapApplied && isSplitTextEmpty && hasContentAfterCursor;
37094
+ if (isCursorAtStartNonPreWrap || isCursorAtStartPreWrapWithContent) {
37034
37095
  isFocusedFirst = true;
37035
37096
  }
37036
37097
  }