@syncfusion/ej2-richtexteditor 27.2.3 → 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.
- package/dist/ej2-richtexteditor.min.js +2 -2
- package/dist/ej2-richtexteditor.umd.min.js +2 -2
- package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es2015.js +46 -16
- package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es5.js +46 -16
- package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
- package/dist/global/ej2-richtexteditor.min.js +2 -2
- package/dist/global/ej2-richtexteditor.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +9 -9
- package/src/editor-manager/plugin/nodecutter.js +5 -0
- package/src/editor-manager/plugin/selection-commands.js +14 -3
- package/src/rich-text-editor/actions/dropdown-buttons.js +4 -4
- package/src/rich-text-editor/actions/html-editor.js +14 -3
- package/src/rich-text-editor/base/util.js +6 -3
- package/src/rich-text-editor/renderer/toolbar-renderer.js +3 -3
|
@@ -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;
|
|
@@ -16174,11 +16177,11 @@ class DropDownButtons {
|
|
|
16174
16177
|
command: { value: 'Font', enumerable: true }, subCommand: { value: 'FontName', enumerable: true }
|
|
16175
16178
|
});
|
|
16176
16179
|
});
|
|
16177
|
-
const fontNameContent = isNullOrUndefined(this.parent.fontFamily.default) ? fontItem[0].text :
|
|
16180
|
+
const fontNameContent = isNullOrUndefined(this.parent.fontFamily.default) ? fontItem.length === 0 ? '' : fontItem[0].text :
|
|
16178
16181
|
this.parent.fontFamily.default;
|
|
16179
16182
|
this.fontNameDropDown = this.toolbarRenderer.renderDropDownButton({
|
|
16180
16183
|
iconCss: ((type === 'quick') ? 'e-font-name e-icons' : ''),
|
|
16181
|
-
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')))),
|
|
16182
16185
|
cssClass: CLS_DROPDOWN_POPUP + ' ' + CLS_DROPDOWN_ITEMS + ' ' + CLS_FONT_NAME_TB_BTN,
|
|
16183
16186
|
itemName: 'FontName', items: fontItem, element: targetElement
|
|
16184
16187
|
});
|
|
@@ -16197,11 +16200,11 @@ class DropDownButtons {
|
|
|
16197
16200
|
command: { value: 'Font', enumerable: true }, subCommand: { value: 'FontSize', enumerable: true }
|
|
16198
16201
|
});
|
|
16199
16202
|
});
|
|
16200
|
-
const fontSizeContent = isNullOrUndefined(this.parent.fontSize.default) ? fontsize[0].text :
|
|
16203
|
+
const fontSizeContent = isNullOrUndefined(this.parent.fontSize.default) ? fontsize.length === 0 ? '' : fontsize[0].text :
|
|
16201
16204
|
this.parent.fontSize.default;
|
|
16202
16205
|
const fontSizeDropDownContent = ((fontSizeContent === 'Default') ? getDropDownValue(fontsize, fontSizeContent.replace(/\s/g, ''), 'text', 'text') : getDropDownValue(fontsize, fontSizeContent.replace(/\s/g, ''), 'value', 'text'));
|
|
16203
16206
|
this.fontSizeDropDown = this.toolbarRenderer.renderDropDownButton({
|
|
16204
|
-
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))),
|
|
16205
16208
|
cssClass: CLS_DROPDOWN_POPUP + ' ' + CLS_DROPDOWN_ITEMS + ' ' + CLS_FONT_SIZE_TB_BTN,
|
|
16206
16209
|
itemName: 'FontSize', items: fontsize, element: targetElement
|
|
16207
16210
|
});
|
|
@@ -23911,6 +23914,11 @@ class NodeCutter {
|
|
|
23911
23914
|
if (node) {
|
|
23912
23915
|
InsertMethods.AppendBefore(fragment, node, true);
|
|
23913
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
|
+
}
|
|
23914
23922
|
else {
|
|
23915
23923
|
parent.appendChild(fragment);
|
|
23916
23924
|
const divNode = document.createElement('div');
|
|
@@ -28138,8 +28146,10 @@ class SelectionCommands {
|
|
|
28138
28146
|
range.startContainer.textContent.substring(range.startOffset, range.startContainer.textContent.length) :
|
|
28139
28147
|
range.startContainer.textContent;
|
|
28140
28148
|
const nodeText = nodes[index].textContent;
|
|
28149
|
+
const isParentNodeSameAsParentElement = nodes[0].parentElement.nodeName === nodes[0].parentElement.parentElement.nodeName;
|
|
28141
28150
|
if (!(range.startContainer === range.endContainer && range.startOffset === 0
|
|
28142
|
-
&& range.endOffset === range.startContainer.length
|
|
28151
|
+
&& range.endOffset === range.startContainer.length
|
|
28152
|
+
&& (range.startContainer.textContent === formatNode.textContent || isParentNodeSameAsParentElement))) {
|
|
28143
28153
|
const nodeIndex = [];
|
|
28144
28154
|
let cloneNode = nodes[index];
|
|
28145
28155
|
const clonedElement = cloneNode;
|
|
@@ -28160,10 +28170,19 @@ class SelectionCommands {
|
|
|
28160
28170
|
if (!isCursor) {
|
|
28161
28171
|
while (cloneNode && cloneNode.childNodes.length > 0 && ((nodeIndex.length - 1) >= 0)
|
|
28162
28172
|
&& (cloneNode.childNodes.length > nodeIndex[nodeIndex.length - 1])) {
|
|
28163
|
-
|
|
28164
|
-
|
|
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
|
+
}
|
|
28165
28181
|
}
|
|
28166
28182
|
if (nodes[index].nodeName !== 'BR') {
|
|
28183
|
+
while (cloneNode.nodeType === 1 && cloneNode.childNodes.length > 0) {
|
|
28184
|
+
cloneNode = cloneNode.childNodes[0];
|
|
28185
|
+
}
|
|
28167
28186
|
if (cloneNode.nodeType === 3 && !(isCursor && cloneNode.nodeValue === '')) {
|
|
28168
28187
|
nodes[index] = cloneNode;
|
|
28169
28188
|
}
|
|
@@ -32593,10 +32612,21 @@ class HtmlEditor {
|
|
|
32593
32612
|
// eslint-disable-next-line
|
|
32594
32613
|
lastNode, lastNode.textContent.length);
|
|
32595
32614
|
}
|
|
32596
|
-
|
|
32597
|
-
|
|
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
|
+
}
|
|
32598
32628
|
}
|
|
32599
|
-
if (!isNullOrUndefined(this.rangeElement) && this.oldRangeElement !== this.rangeElement) {
|
|
32629
|
+
if (!isNullOrUndefined(this.rangeElement) && this.oldRangeElement !== this.rangeElement && !checkParent) {
|
|
32600
32630
|
while (this.rangeElement.firstChild) {
|
|
32601
32631
|
if (this.oldRangeElement.nodeName === '#text') {
|
|
32602
32632
|
this.oldRangeElement.parentElement.appendChild(this.rangeElement.childNodes[0]);
|