@syncfusion/ej2-richtexteditor 23.2.7-52849 → 24.1.41-569781
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/.eslintrc.json +260 -0
- package/CHANGELOG.md +177 -1
- package/dist/ej2-richtexteditor.umd.min.js +1 -1
- package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es2015.js +2919 -1147
- package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es5.js +2906 -1133
- package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
- package/package.json +13 -13
- package/src/common/config.d.ts +7 -0
- package/src/common/config.js +12 -1
- package/src/common/constant.d.ts +6 -0
- package/src/common/constant.js +6 -0
- package/src/common/interface.d.ts +12 -0
- package/src/common/types.d.ts +6 -0
- package/src/common/util.d.ts +6 -0
- package/src/common/util.js +61 -20
- package/src/editor-manager/base/constant.d.ts +6 -0
- package/src/editor-manager/base/constant.js +6 -0
- package/src/editor-manager/base/editor-manager.d.ts +5 -0
- package/src/editor-manager/base/editor-manager.js +59 -0
- package/src/editor-manager/base/interface.d.ts +8 -0
- package/src/editor-manager/plugin/audio.js +13 -3
- package/src/editor-manager/plugin/dom-node.d.ts +5 -1
- package/src/editor-manager/plugin/dom-node.js +169 -28
- package/src/editor-manager/plugin/format-painter-actions.d.ts +1 -0
- package/src/editor-manager/plugin/format-painter-actions.js +19 -1
- package/src/editor-manager/plugin/formats.d.ts +1 -0
- package/src/editor-manager/plugin/formats.js +38 -3
- package/src/editor-manager/plugin/image.js +38 -15
- package/src/editor-manager/plugin/inserthtml.d.ts +1 -0
- package/src/editor-manager/plugin/inserthtml.js +67 -7
- package/src/editor-manager/plugin/link.js +4 -1
- package/src/editor-manager/plugin/lists.js +121 -65
- package/src/editor-manager/plugin/ms-word-clean-up.d.ts +3 -0
- package/src/editor-manager/plugin/ms-word-clean-up.js +215 -85
- package/src/editor-manager/plugin/nodecutter.js +2 -2
- package/src/editor-manager/plugin/selection-commands.d.ts +1 -0
- package/src/editor-manager/plugin/selection-commands.js +165 -3
- package/src/editor-manager/plugin/table.d.ts +0 -1
- package/src/editor-manager/plugin/table.js +33 -30
- package/src/editor-manager/plugin/toolbar-status.d.ts +2 -2
- package/src/editor-manager/plugin/toolbar-status.js +20 -10
- package/src/editor-manager/plugin/undo.d.ts +1 -0
- package/src/editor-manager/plugin/undo.js +21 -1
- package/src/rich-text-editor/actions/base-quick-toolbar.d.ts +3 -3
- package/src/rich-text-editor/actions/base-quick-toolbar.js +66 -15
- package/src/rich-text-editor/actions/base-toolbar.js +32 -34
- package/src/rich-text-editor/actions/color-picker.d.ts +1 -0
- package/src/rich-text-editor/actions/color-picker.js +13 -3
- package/src/rich-text-editor/actions/count.js +1 -1
- package/src/rich-text-editor/actions/dropdown-buttons.js +25 -4
- package/src/rich-text-editor/actions/emoji-picker.js +15 -6
- package/src/rich-text-editor/actions/enter-key.js +6 -4
- package/src/rich-text-editor/actions/file-manager.js +1 -1
- package/src/rich-text-editor/actions/format-painter.js +1 -1
- package/src/rich-text-editor/actions/full-screen.js +5 -4
- package/src/rich-text-editor/actions/html-editor.d.ts +2 -0
- package/src/rich-text-editor/actions/html-editor.js +127 -17
- package/src/rich-text-editor/actions/keyboard.js +3 -1
- package/src/rich-text-editor/actions/markdown-editor.js +3 -1
- package/src/rich-text-editor/actions/paste-clean-up.d.ts +5 -0
- package/src/rich-text-editor/actions/paste-clean-up.js +156 -28
- package/src/rich-text-editor/actions/quick-toolbar.d.ts +7 -0
- package/src/rich-text-editor/actions/quick-toolbar.js +45 -11
- package/src/rich-text-editor/actions/resize.js +2 -1
- package/src/rich-text-editor/actions/toolbar-action.js +1 -1
- package/src/rich-text-editor/actions/toolbar.d.ts +3 -3
- package/src/rich-text-editor/actions/toolbar.js +35 -96
- package/src/rich-text-editor/base/classes.d.ts +5 -5
- package/src/rich-text-editor/base/classes.js +5 -5
- package/src/rich-text-editor/base/constant.d.ts +46 -1
- package/src/rich-text-editor/base/constant.js +215 -1
- package/src/rich-text-editor/base/interface.d.ts +47 -3
- package/src/rich-text-editor/base/rich-text-editor-model.d.ts +3 -3
- package/src/rich-text-editor/base/rich-text-editor.d.ts +16 -4
- package/src/rich-text-editor/base/rich-text-editor.js +196 -100
- package/src/rich-text-editor/base/util.d.ts +4 -0
- package/src/rich-text-editor/base/util.js +57 -5
- package/src/rich-text-editor/formatter/formatter.js +15 -4
- package/src/rich-text-editor/models/default-locale.js +31 -25
- package/src/rich-text-editor/models/items.js +3 -3
- package/src/rich-text-editor/models/toolbar-settings-model.d.ts +1 -1
- package/src/rich-text-editor/models/toolbar-settings.d.ts +1 -1
- package/src/rich-text-editor/models/toolbar-settings.js +1 -1
- package/src/rich-text-editor/renderer/audio-module.d.ts +1 -0
- package/src/rich-text-editor/renderer/audio-module.js +13 -0
- package/src/rich-text-editor/renderer/dialog-renderer.d.ts +2 -0
- package/src/rich-text-editor/renderer/dialog-renderer.js +22 -2
- package/src/rich-text-editor/renderer/iframe-content-renderer.js +2 -1
- package/src/rich-text-editor/renderer/image-module.d.ts +9 -1
- package/src/rich-text-editor/renderer/image-module.js +244 -212
- package/src/rich-text-editor/renderer/link-module.js +53 -24
- package/src/rich-text-editor/renderer/table-module.d.ts +10 -1
- package/src/rich-text-editor/renderer/table-module.js +330 -165
- package/src/rich-text-editor/renderer/toolbar-renderer.d.ts +4 -6
- package/src/rich-text-editor/renderer/toolbar-renderer.js +105 -106
- package/src/rich-text-editor/renderer/video-module.d.ts +3 -0
- package/src/rich-text-editor/renderer/video-module.js +61 -34
- package/src/rich-text-editor/renderer/view-source.d.ts +1 -0
- package/src/rich-text-editor/renderer/view-source.js +15 -5
- package/src/selection/selection.js +3 -0
- package/styles/bootstrap-dark.css +345 -99
- package/styles/bootstrap.css +353 -108
- package/styles/bootstrap4.css +337 -95
- package/styles/bootstrap5-dark.css +343 -96
- package/styles/bootstrap5.css +343 -96
- package/styles/fabric-dark.css +331 -89
- package/styles/fabric.css +332 -90
- package/styles/fluent-dark.css +342 -92
- package/styles/fluent.css +342 -92
- package/styles/highcontrast-light.css +331 -89
- package/styles/highcontrast.css +335 -90
- package/styles/material-dark.css +337 -90
- package/styles/material.css +337 -90
- package/styles/material3-dark.css +347 -99
- package/styles/material3.css +347 -99
- package/styles/rich-text-editor/_bds-definition.scss +279 -0
- package/styles/rich-text-editor/_bootstrap-dark-definition.scss +14 -10
- package/styles/rich-text-editor/_bootstrap-definition.scss +20 -17
- package/styles/rich-text-editor/_bootstrap4-definition.scss +11 -7
- package/styles/rich-text-editor/_bootstrap5-definition.scss +8 -4
- package/styles/rich-text-editor/_fabric-dark-definition.scss +6 -2
- package/styles/rich-text-editor/_fabric-definition.scss +7 -3
- package/styles/rich-text-editor/_fluent-definition.scss +9 -5
- package/styles/rich-text-editor/_fusionnew-definition.scss +7 -3
- package/styles/rich-text-editor/_highcontrast-definition.scss +7 -3
- package/styles/rich-text-editor/_highcontrast-light-definition.scss +6 -2
- package/styles/rich-text-editor/_layout.scss +208 -31
- package/styles/rich-text-editor/_material-dark-definition.scss +6 -2
- package/styles/rich-text-editor/_material-definition.scss +6 -2
- package/styles/rich-text-editor/_material3-definition.scss +16 -12
- package/styles/rich-text-editor/_tailwind-definition.scss +25 -21
- package/styles/rich-text-editor/_theme.scss +93 -24
- package/styles/rich-text-editor/bootstrap-dark.css +345 -99
- package/styles/rich-text-editor/bootstrap.css +353 -108
- package/styles/rich-text-editor/bootstrap4.css +337 -95
- package/styles/rich-text-editor/bootstrap5-dark.css +343 -96
- package/styles/rich-text-editor/bootstrap5.css +343 -96
- package/styles/rich-text-editor/fabric-dark.css +331 -89
- package/styles/rich-text-editor/fabric.css +332 -90
- package/styles/rich-text-editor/fluent-dark.css +342 -92
- package/styles/rich-text-editor/fluent.css +342 -92
- package/styles/rich-text-editor/highcontrast-light.css +331 -89
- package/styles/rich-text-editor/highcontrast.css +335 -90
- package/styles/rich-text-editor/icons/_bds.scss +348 -0
- package/styles/rich-text-editor/icons/_bootstrap-dark.scss +4 -4
- package/styles/rich-text-editor/icons/_bootstrap.scss +4 -4
- package/styles/rich-text-editor/icons/_bootstrap4.scss +4 -4
- package/styles/rich-text-editor/icons/_bootstrap5.scss +4 -4
- package/styles/rich-text-editor/icons/_fabric-dark.scss +4 -4
- package/styles/rich-text-editor/icons/_fabric.scss +4 -4
- package/styles/rich-text-editor/icons/_fluent.scss +4 -4
- package/styles/rich-text-editor/icons/_fusionnew.scss +3 -3
- package/styles/rich-text-editor/icons/_highcontrast-light.scss +4 -4
- package/styles/rich-text-editor/icons/_highcontrast.scss +4 -4
- package/styles/rich-text-editor/icons/_material-dark.scss +4 -4
- package/styles/rich-text-editor/icons/_material.scss +4 -4
- package/styles/rich-text-editor/icons/_material3.scss +4 -4
- package/styles/rich-text-editor/icons/_tailwind.scss +4 -4
- package/styles/rich-text-editor/material-dark.css +337 -90
- package/styles/rich-text-editor/material.css +337 -90
- package/styles/rich-text-editor/material3-dark.css +347 -99
- package/styles/rich-text-editor/material3.css +347 -99
- package/styles/rich-text-editor/tailwind-dark.css +386 -116
- package/styles/rich-text-editor/tailwind.css +386 -116
- package/styles/tailwind-dark.css +386 -116
- package/styles/tailwind.css +386 -116
- package/.github/PULL_REQUEST_TEMPLATE/Bug.md +0 -41
- package/.github/PULL_REQUEST_TEMPLATE/Feature.md +0 -27
- package/src/global.d.ts +0 -1
|
@@ -28,7 +28,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
28
28
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
29
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
30
|
};
|
|
31
|
-
import { Component, EventHandler, Complex, Browser, addClass,
|
|
31
|
+
import { Component, EventHandler, Complex, Browser, addClass, detach } from '@syncfusion/ej2-base';
|
|
32
32
|
import { Property, NotifyPropertyChanges, formatUnit, L10n, closest } from '@syncfusion/ej2-base';
|
|
33
33
|
import { setStyleAttribute, Event, removeClass, print as printWindow, attributes } from '@syncfusion/ej2-base';
|
|
34
34
|
import { isNullOrUndefined as isNOU, compile, append, extend, debounce } from '@syncfusion/ej2-base';
|
|
@@ -97,6 +97,14 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
97
97
|
member: 'image',
|
|
98
98
|
args: [this, this.serviceLocator]
|
|
99
99
|
});
|
|
100
|
+
modules.push({
|
|
101
|
+
member: 'audio',
|
|
102
|
+
args: [this, this.serviceLocator]
|
|
103
|
+
});
|
|
104
|
+
modules.push({
|
|
105
|
+
member: 'video',
|
|
106
|
+
args: [this, this.serviceLocator]
|
|
107
|
+
});
|
|
100
108
|
if (this.quickToolbarSettings.enable) {
|
|
101
109
|
modules.push({ member: 'quickToolbar', args: [this, this.serviceLocator] });
|
|
102
110
|
}
|
|
@@ -110,14 +118,6 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
110
118
|
if (this.editorMode === 'HTML') {
|
|
111
119
|
modules.push({ member: 'htmlEditor', args: [this, this.serviceLocator] });
|
|
112
120
|
modules.push({ member: 'pasteCleanup', args: [this, this.serviceLocator] });
|
|
113
|
-
modules.push({
|
|
114
|
-
member: 'audio',
|
|
115
|
-
args: [this, this.serviceLocator]
|
|
116
|
-
});
|
|
117
|
-
modules.push({
|
|
118
|
-
member: 'video',
|
|
119
|
-
args: [this, this.serviceLocator]
|
|
120
|
-
});
|
|
121
121
|
modules.push({
|
|
122
122
|
member: 'formatPainter',
|
|
123
123
|
args: [this]
|
|
@@ -149,7 +149,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
149
149
|
else {
|
|
150
150
|
if (this.getToolbar()) {
|
|
151
151
|
removeClass(this.getToolbar().querySelectorAll('.' + classes.CLS_ACTIVE), classes.CLS_ACTIVE);
|
|
152
|
-
removeClass([this.getToolbar()], [classes.CLS_TB_FLOAT
|
|
152
|
+
removeClass([this.getToolbar().parentElement], [classes.CLS_TB_FLOAT]);
|
|
153
153
|
}
|
|
154
154
|
addClass([this.element], classes.CLS_DISABLED);
|
|
155
155
|
this.element.tabIndex = -1;
|
|
@@ -390,7 +390,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
390
390
|
if (tool.command === 'InsertText') {
|
|
391
391
|
currentInsertContentLength = value.length;
|
|
392
392
|
}
|
|
393
|
-
var currentLength = this.getText().trim().length;
|
|
393
|
+
var currentLength = this.getText().trim().replace(/(\r\n|\n|\r|\t)/gm, '').replace(/\u200B/g, '').length;
|
|
394
394
|
var selectionLength = this.getSelection().length;
|
|
395
395
|
var totalLength = (currentLength - selectionLength) + currentInsertContentLength;
|
|
396
396
|
if (!(this.maxLength === -1 || totalLength <= this.maxLength)) {
|
|
@@ -551,6 +551,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
551
551
|
* @deprecated
|
|
552
552
|
*/
|
|
553
553
|
RichTextEditor.prototype.render = function () {
|
|
554
|
+
this.value = (!(this.editorMode === 'Markdown') && !isNOU(this.value)) ? this.addAnchorAriaLabel(this.value) : this.value;
|
|
554
555
|
if (this.value && !this.valueTemplate) {
|
|
555
556
|
this.setProperties({ value: this.serializeValue(this.value) }, true);
|
|
556
557
|
}
|
|
@@ -565,17 +566,17 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
565
566
|
if (this.enableXhtml) {
|
|
566
567
|
this.setProperties({ value: this.getXhtml() }, true);
|
|
567
568
|
}
|
|
568
|
-
if (this.toolbarSettings.enable && this.toolbarSettings.type === 'Expand' && !isNOU(this.getToolbar()) &&
|
|
569
|
+
if (this.toolbarSettings.enable && (this.toolbarSettings.type === 'Expand' || this.toolbarSettings.type === 'MultiRow' || this.toolbarSettings.type === 'Scrollable') && !isNOU(this.getToolbar()) &&
|
|
569
570
|
(this.toolbarSettings.items.indexOf('Undo') > -1 && this.toolbarSettings.items.indexOf('Redo') > -1)) {
|
|
570
571
|
this.disableToolbarItem(['Undo', 'Redo']);
|
|
571
572
|
}
|
|
572
|
-
this.setContentHeight();
|
|
573
|
+
this.setContentHeight('Init');
|
|
573
574
|
if (this.value !== null) {
|
|
574
575
|
this.valueContainer.defaultValue = this.value;
|
|
575
576
|
}
|
|
576
577
|
// eslint-disable-next-line
|
|
577
578
|
(this.enabled && !this.readonly) ? this.eventInitializer() : this.unWireEvents();
|
|
578
|
-
this.notify(events.bindCssClass, { cssClass: this.
|
|
579
|
+
this.notify(events.bindCssClass, { cssClass: this.getCssClass() });
|
|
579
580
|
this.addAudioVideoWrapper();
|
|
580
581
|
this.notify(events.tableclass, {});
|
|
581
582
|
this.renderComplete();
|
|
@@ -666,7 +667,13 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
666
667
|
range.endContainer;
|
|
667
668
|
var closestLI = closest(endNode, 'LI');
|
|
668
669
|
var isDetached = false;
|
|
669
|
-
|
|
670
|
+
var currentRangeEndOffset = range.endOffset;
|
|
671
|
+
if (currentEndContainer.nodeType === Node.TEXT_NODE) {
|
|
672
|
+
if (currentEndContainer.textContent.charAt(currentRangeEndOffset - 1) === '\uFEFF') {
|
|
673
|
+
currentRangeEndOffset--;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
if (!isNOU(closestLI) && endNode.textContent.trim().length === currentRangeEndOffset &&
|
|
670
677
|
!range.collapsed && isNOU(endNode.nextElementSibling)) {
|
|
671
678
|
for (var i = 0; i < closestLI.childNodes.length; i++) {
|
|
672
679
|
if (closestLI.childNodes[i].nodeName === '#text' && closestLI.childNodes[i].textContent.trim().length === 0) {
|
|
@@ -745,12 +752,12 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
745
752
|
}
|
|
746
753
|
var notFormatPainterCopy = isNOU(e.action) ? true : (e.action !== 'format-copy' ? true : false);
|
|
747
754
|
if (this.formatter.getUndoRedoStack().length === 0 && notFormatPainterCopy &&
|
|
748
|
-
!(e.altKey || e.shiftKey || (e.altKey && e.shiftKey && e.which
|
|
755
|
+
!(e.altKey || e.shiftKey || (e.altKey && e.shiftKey && e.which == 67))) {
|
|
749
756
|
this.formatter.saveData();
|
|
750
757
|
}
|
|
751
758
|
if (e.action !== 'insert-link' &&
|
|
752
759
|
e.action !== 'format-copy' && e.action !== 'format-paste' &&
|
|
753
|
-
(!e.target || !(e.target.classList.contains('e-mention') && e.code === 'Tab')) &&
|
|
760
|
+
(!e.target || !(e.target.classList.contains('e-mention') && !isNOU(document.querySelector('#' + e.target.id + '_popup.e-popup-open')) && e.code === 'Tab')) &&
|
|
754
761
|
(e.action && e.action !== 'paste' && e.action !== 'space'
|
|
755
762
|
|| e.which === 9 || (e.code === 'Backspace' && e.which === 8))) {
|
|
756
763
|
var FormatPainterEscapeAction = false;
|
|
@@ -758,14 +765,26 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
758
765
|
FormatPainterEscapeAction = this.formatPainterModule.previousAction === 'escape';
|
|
759
766
|
}
|
|
760
767
|
if (!FormatPainterEscapeAction) {
|
|
761
|
-
this.
|
|
768
|
+
if (this.editorMode === 'HTML' && (e.action === 'increase-fontsize' || e.action === 'decrease-fontsize')) {
|
|
769
|
+
this.notify(events.onHandleFontsizeChange, { member: 'onHandleFontsizeChange', args: e });
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
this.formatter.process(this, null, e);
|
|
773
|
+
}
|
|
762
774
|
}
|
|
763
775
|
switch (e.action) {
|
|
764
776
|
case 'toolbar-focus':
|
|
765
777
|
if (this.toolbarSettings.enable && this.getToolbarElement()) {
|
|
766
778
|
var firstActiveItem = this.getToolbarElement().querySelector('.e-toolbar-item:not(.e-overlay)[title]');
|
|
767
|
-
|
|
768
|
-
|
|
779
|
+
var quickToolbarElem = this.getRenderedQuickToolbarElem();
|
|
780
|
+
if (quickToolbarElem) {
|
|
781
|
+
firstActiveItem = quickToolbarElem.querySelector('.e-toolbar-item:not(.e-overlay)[title]');
|
|
782
|
+
}
|
|
783
|
+
if (firstActiveItem) {
|
|
784
|
+
var firstChild = firstActiveItem.firstElementChild;
|
|
785
|
+
firstChild.removeAttribute('tabindex');
|
|
786
|
+
firstChild.focus();
|
|
787
|
+
}
|
|
769
788
|
}
|
|
770
789
|
break;
|
|
771
790
|
case 'escape':
|
|
@@ -784,11 +803,22 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
784
803
|
this.setPlaceHolder();
|
|
785
804
|
}
|
|
786
805
|
}
|
|
806
|
+
this.notify(events.afterKeyDown, { member: 'afterKeyDown', args: e });
|
|
787
807
|
this.autoResize();
|
|
788
808
|
};
|
|
789
809
|
RichTextEditor.prototype.keyUp = function (e) {
|
|
790
810
|
if (this.editorMode === 'HTML') {
|
|
791
811
|
var range = this.getRange();
|
|
812
|
+
if (!isNOU(e) && !isNOU(e.code) && (e.code === 'Backspace' || e.code === 'Delete')) {
|
|
813
|
+
// To prevent the reformatting the content removed browser behavior.
|
|
814
|
+
var currentRange = this.getRange();
|
|
815
|
+
var selection = this.iframeSettings.enable ? this.contentModule.getPanel().ownerDocument.getSelection() :
|
|
816
|
+
this.contentModule.getDocument().getSelection();
|
|
817
|
+
if (selection.rangeCount > 0) {
|
|
818
|
+
selection.removeAllRanges();
|
|
819
|
+
selection.addRange(currentRange);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
792
822
|
if (Browser.userAgent.indexOf('Firefox') !== -1 && range.startContainer.nodeName === '#text' &&
|
|
793
823
|
range.startContainer.parentElement === this.inputElement && this.enterKey !== 'BR') {
|
|
794
824
|
var range_1 = this.getRange();
|
|
@@ -810,11 +840,11 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
810
840
|
var formatPainterCopy = e.key === 'C' && e.altKey && e.shiftKey;
|
|
811
841
|
var formatPainterPaste = e.key === 'V' && e.altKey && e.shiftKey;
|
|
812
842
|
if ((!formatPainterCopy && !formatPainterPaste) && ((e.key !== 'shift' && !e.ctrlKey) && e.key && e.key.length === 1 || allowedKeys) || (this.editorMode === 'Markdown'
|
|
813
|
-
&& ((e.key !== 'shift' && !e.ctrlKey) && e.key && e.key.length === 1 || allowedKeys)) && !this.inlineMode.enable) {
|
|
843
|
+
&& ((e.key !== 'shift' && !e.ctrlKey) && e.key && e.key.length === 1 || allowedKeys)) || (this.autoSaveOnIdle && Browser.isDevice) && !this.inlineMode.enable) {
|
|
814
844
|
this.formatter.onKeyHandler(this, e);
|
|
815
845
|
}
|
|
816
846
|
if (this.inputElement && this.inputElement.textContent.length !== 0
|
|
817
|
-
|| this.element.querySelectorAll('.e-toolbar-item.e-active').length > 0) {
|
|
847
|
+
|| this.element.querySelectorAll('.e-toolbar-item.e-active').length > 0 || this.formatter.getUndoRedoStack().length > 0) {
|
|
818
848
|
this.notify(events.toolbarRefresh, { args: e });
|
|
819
849
|
}
|
|
820
850
|
if (!isNOU(this.placeholder)) {
|
|
@@ -888,11 +918,14 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
888
918
|
clientX: touch.clientX, clientY: touch.clientY }
|
|
889
919
|
});
|
|
890
920
|
if (this.inputElement && ((this.editorMode === 'HTML' && this.inputElement.textContent.length !== 0) ||
|
|
891
|
-
(this.editorMode === 'Markdown' && this.inputElement.value.length !== 0)) ||
|
|
892
|
-
|
|
893
|
-
(e.target.
|
|
894
|
-
e.target.
|
|
895
|
-
e.target.
|
|
921
|
+
(this.editorMode === 'Markdown' && this.inputElement.value.length !== 0)) ||
|
|
922
|
+
(e.target && !isNOU(closest(e.target, 'table'))) ||
|
|
923
|
+
(e.target && (e.target.nodeName === 'VIDEO' ||
|
|
924
|
+
e.target.querySelectorAll('.' + classes.CLS_VIDEOWRAP).length > 0) ||
|
|
925
|
+
(e.target && e.target.nodeName !== 'BR' &&
|
|
926
|
+
(e.target.classList.contains(classes.CLS_AUDIOWRAP) ||
|
|
927
|
+
e.target.classList.contains(classes.CLS_CLICKELEM) ||
|
|
928
|
+
e.target.classList.contains(classes.CLS_VID_CLICK_ELEM))))) {
|
|
896
929
|
this.notify(events.toolbarRefresh, { args: e });
|
|
897
930
|
}
|
|
898
931
|
this.triggerEditArea(e);
|
|
@@ -907,19 +940,6 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
907
940
|
}
|
|
908
941
|
}
|
|
909
942
|
this.notifyMouseUp(e);
|
|
910
|
-
if (e.detail === 3) {
|
|
911
|
-
var range = this.getRange();
|
|
912
|
-
var selection = this.formatter.editorManager.domNode.getSelection();
|
|
913
|
-
if (/\s+$/.test(selection.toString())) {
|
|
914
|
-
if (!isNOU(range.startContainer.parentElement) && (!isNOU(range.startContainer.parentElement.nextSibling) &&
|
|
915
|
-
(range.startContainer.parentElement.nextSibling.nodeType !== 3 ||
|
|
916
|
-
/\s+$/.test(range.startContainer.parentElement.nextSibling.textContent)) || range.startOffset === range.endOffset)
|
|
917
|
-
|| range.startContainer.parentElement.tagName.toLocaleLowerCase() === 'li') {
|
|
918
|
-
range.setStart(range.startContainer, range.startOffset);
|
|
919
|
-
range.setEnd(range.startContainer, range.startContainer.textContent.length);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
943
|
};
|
|
924
944
|
/**
|
|
925
945
|
* @param {Function} module - specifies the module function.
|
|
@@ -960,10 +980,10 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
960
980
|
requestType: 'Paste'
|
|
961
981
|
};
|
|
962
982
|
this.trigger(events.actionBegin, evenArgs, function (pasteArgs) {
|
|
963
|
-
var currentLength = _this.
|
|
983
|
+
var currentLength = _this.getText().replace(/(\r\n|\n|\r|\t)/gm, '').replace(/\u200B/g, '').length;
|
|
964
984
|
var selectionLength = _this.getSelection().length;
|
|
965
985
|
var pastedContentLength = (isNOU(e) || isNOU(e.clipboardData))
|
|
966
|
-
? 0 : e.clipboardData.getData('text/plain').length;
|
|
986
|
+
? 0 : e.clipboardData.getData('text/plain').replace(/(\r\n|\n|\r|\t)/gm, '').replace(/\u200B/g, '').length;
|
|
967
987
|
var totalLength = (currentLength - selectionLength) + pastedContentLength;
|
|
968
988
|
if (_this.editorMode === 'Markdown') {
|
|
969
989
|
var args_1 = { requestType: 'Paste', editorMode: _this.editorMode, event: e };
|
|
@@ -981,6 +1001,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
981
1001
|
_this.notify(events.pasteClean, { args: e });
|
|
982
1002
|
}
|
|
983
1003
|
else {
|
|
1004
|
+
console.warn('[WARNING] :: Module "pasteCleanup" is not available in RichTextEditor component! You either misspelled the module name or forgot to load it.');
|
|
984
1005
|
var args_2 = { requestType: 'Paste', editorMode: _this.editorMode, event: e };
|
|
985
1006
|
var value = null;
|
|
986
1007
|
var htmlValue = false;
|
|
@@ -1275,7 +1296,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1275
1296
|
break;
|
|
1276
1297
|
case 'height':
|
|
1277
1298
|
this.setHeight(newProp[prop]);
|
|
1278
|
-
this.setContentHeight();
|
|
1299
|
+
this.setContentHeight('Init');
|
|
1279
1300
|
this.autoResize();
|
|
1280
1301
|
break;
|
|
1281
1302
|
case 'readonly':
|
|
@@ -1322,11 +1343,11 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1322
1343
|
break;
|
|
1323
1344
|
case 'inlineMode':
|
|
1324
1345
|
this.notify(events.modelChanged, { module: 'quickToolbar', newProp: newProp, oldProp: oldProp });
|
|
1325
|
-
this.setContentHeight();
|
|
1346
|
+
this.setContentHeight('Init');
|
|
1326
1347
|
break;
|
|
1327
1348
|
case 'toolbarSettings':
|
|
1328
1349
|
this.notify(events.modelChanged, { module: 'toolbar', newProp: newProp, oldProp: oldProp });
|
|
1329
|
-
this.setContentHeight();
|
|
1350
|
+
this.setContentHeight('Init');
|
|
1330
1351
|
break;
|
|
1331
1352
|
case 'maxLength':
|
|
1332
1353
|
if (this.showCharCount) {
|
|
@@ -1395,7 +1416,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1395
1416
|
RichTextEditor.prototype.updatePanelValue = function () {
|
|
1396
1417
|
var value = this.value;
|
|
1397
1418
|
value = (this.enableHtmlEncode && this.value) ? decode(value) : value;
|
|
1398
|
-
var getTextArea = this.element.querySelector('.
|
|
1419
|
+
var getTextArea = this.element.querySelector('.' + classes.CLS_RTE_SOURCE_CODE_TXTAREA);
|
|
1399
1420
|
if (value) {
|
|
1400
1421
|
if (getTextArea && getTextArea.style.display === 'block') {
|
|
1401
1422
|
getTextArea.value = this.value;
|
|
@@ -1403,7 +1424,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1403
1424
|
if (this.valueContainer) {
|
|
1404
1425
|
this.valueContainer.value = (this.enableHtmlEncode) ? this.value : value;
|
|
1405
1426
|
}
|
|
1406
|
-
if (this.editorMode === 'HTML' && this.inputElement && this.inputElement.innerHTML.
|
|
1427
|
+
if (this.editorMode === 'HTML' && this.inputElement && this.inputElement.innerHTML.trim() !== value.trim()) {
|
|
1407
1428
|
this.inputElement.innerHTML = value;
|
|
1408
1429
|
}
|
|
1409
1430
|
else if (this.editorMode === 'Markdown' && this.inputElement
|
|
@@ -1424,9 +1445,6 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1424
1445
|
}
|
|
1425
1446
|
else {
|
|
1426
1447
|
this.inputElement.innerHTML = '<p><br/></p>';
|
|
1427
|
-
if (value === '' && this.formatter && this.inputElement) {
|
|
1428
|
-
this.formatter.editorManager.nodeSelection.setCursorPoint(this.contentModule.getDocument(), this.inputElement.firstElementChild, this.inputElement.firstElementChild.childElementCount);
|
|
1429
|
-
}
|
|
1430
1448
|
}
|
|
1431
1449
|
}
|
|
1432
1450
|
else {
|
|
@@ -1488,7 +1506,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1488
1506
|
this.inputElement.setAttribute('placeholder', this.placeholder);
|
|
1489
1507
|
}
|
|
1490
1508
|
}
|
|
1491
|
-
if (this.placeholder && this.iframeSettings.enable) {
|
|
1509
|
+
if (this.placeholder && this.iframeSettings.enable && this.inputElement) {
|
|
1492
1510
|
if (this.inputElement.textContent.length === 0 && this.inputElement.childNodes.length < 2 && !isNOU(this.inputElement.firstChild) && (this.inputElement.firstChild.nodeName === 'BR' ||
|
|
1493
1511
|
((this.inputElement.firstChild.nodeName === 'P' || this.inputElement.firstChild.nodeName === 'DIV') && !isNOU(this.inputElement.firstChild.firstChild) &&
|
|
1494
1512
|
this.inputElement.firstChild.firstChild.nodeName === 'BR'))) {
|
|
@@ -1675,10 +1693,10 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1675
1693
|
if (this.iframeSettings.resources) {
|
|
1676
1694
|
var styleSrc = this.iframeSettings.resources.styles;
|
|
1677
1695
|
var scriptSrc = this.iframeSettings.resources.scripts;
|
|
1678
|
-
if (this.iframeSettings.resources.scripts.length > 0) {
|
|
1696
|
+
if (!isNOU(this.iframeSettings.resources.scripts) && this.iframeSettings.resources.scripts.length > 0) {
|
|
1679
1697
|
this.InjectSheet(true, scriptSrc);
|
|
1680
1698
|
}
|
|
1681
|
-
if (this.iframeSettings.resources.styles.length > 0) {
|
|
1699
|
+
if (!isNOU(this.iframeSettings.resources.styles) && this.iframeSettings.resources.styles.length > 0) {
|
|
1682
1700
|
this.InjectSheet(false, styleSrc);
|
|
1683
1701
|
}
|
|
1684
1702
|
}
|
|
@@ -1792,6 +1810,13 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1792
1810
|
var imgPadding = 12;
|
|
1793
1811
|
var imgResizeBorder = 2;
|
|
1794
1812
|
var editEle = this.contentModule.getEditPanel();
|
|
1813
|
+
if (this.editorMode === "HTML" && !isNOU(this.formatter.editorManager.nodeSelection) && !isNOU(this.formatter.editorManager.nodeSelection.range)) {
|
|
1814
|
+
var currentRange = this.formatter.editorManager.nodeSelection.range;
|
|
1815
|
+
if (currentRange.startContainer.nodeType !== 3 && currentRange.startContainer.closest &&
|
|
1816
|
+
!isNOU(currentRange.startContainer.closest('TD'))) {
|
|
1817
|
+
editEle = currentRange.startContainer;
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1795
1820
|
var eleStyle = window.getComputedStyle(editEle);
|
|
1796
1821
|
var editEleMaxWidth = editEle.offsetWidth - (imgPadding + imgResizeBorder +
|
|
1797
1822
|
parseFloat(eleStyle.paddingLeft.split('px')[0]) + parseFloat(eleStyle.paddingRight.split('px')[0]) +
|
|
@@ -1828,12 +1853,9 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1828
1853
|
*/
|
|
1829
1854
|
RichTextEditor.prototype.setContentHeight = function (target, isExpand) {
|
|
1830
1855
|
var heightValue;
|
|
1831
|
-
var topValue = 0;
|
|
1832
1856
|
var rteHeightPercent;
|
|
1833
1857
|
var heightPercent = typeof (this.height) === 'string' && this.height.indexOf('%') > -1;
|
|
1834
|
-
var cntEle =
|
|
1835
|
-
this.sourceCodeModule.getPanel().parentElement.style.display === 'block') ? this.sourceCodeModule.getPanel().parentElement :
|
|
1836
|
-
this.contentModule.getPanel();
|
|
1858
|
+
var cntEle = this.contentModule.getPanel();
|
|
1837
1859
|
var rteHeight = this.element.offsetHeight;
|
|
1838
1860
|
if (rteHeight === 0 && this.height !== 'auto' && !this.getToolbar()) {
|
|
1839
1861
|
rteHeight = parseInt(this.height, 10);
|
|
@@ -1845,39 +1867,36 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
1845
1867
|
var rzHandle = this.element.querySelector('.' + classes.CLS_RTE_RES_HANDLE);
|
|
1846
1868
|
var rzHeight = this.enableResize ? (!isNOU(rzHandle) ? (rzHandle.offsetHeight + 8) : 0) : 0;
|
|
1847
1869
|
var expandPopHeight = this.getToolbar() ? this.toolbarModule.getExpandTBarPopHeight() : 0;
|
|
1848
|
-
if (this.
|
|
1849
|
-
|
|
1850
|
-
topValue = (!this.toolbarSettings.enableFloating) ? expandPopHeight : 0;
|
|
1870
|
+
if (target && target !== 'Toolbar' && expandPopHeight && this.element.querySelectorAll('.e-toolbar-extended.e-popup-open').length > 0) {
|
|
1871
|
+
tbHeight = tbHeight - expandPopHeight;
|
|
1851
1872
|
}
|
|
1852
|
-
|
|
1853
|
-
if (
|
|
1854
|
-
heightValue = 'auto';
|
|
1873
|
+
if (this.toolbarSettings.type === ToolbarType.Expand) {
|
|
1874
|
+
if (isExpand) {
|
|
1875
|
+
heightValue = (this.height === 'auto' && this.element.style.height === 'auto') ? 'auto' : rteHeight - (tbHeight + expandPopHeight + rzHeight) + 'px';
|
|
1855
1876
|
}
|
|
1856
1877
|
else {
|
|
1857
|
-
heightValue =
|
|
1878
|
+
heightValue = (this.height === 'auto' && this.element.style.height === 'auto') ? 'auto' : rteHeight - (tbHeight - expandPopHeight + rzHeight) + 'px';
|
|
1858
1879
|
}
|
|
1859
1880
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1881
|
+
else {
|
|
1882
|
+
heightValue = (this.height === 'auto' && this.element.style.height === 'auto') ? 'auto' : rteHeight - tbHeight + 'px';
|
|
1883
|
+
}
|
|
1884
|
+
var finalHeight = heightPercent && rteHeightPercent ? rteHeightPercent : heightValue;
|
|
1885
|
+
switch (target) {
|
|
1886
|
+
case 'Init':
|
|
1887
|
+
case 'Toolbar':
|
|
1888
|
+
case 'WindowResize':
|
|
1889
|
+
case 'Refresh':
|
|
1890
|
+
if (this.element.querySelectorAll('.e-source-content').length > 0 && this.element.querySelector('.e-source-content').style.display === 'block') {
|
|
1891
|
+
setStyleAttribute(this.element.querySelector('.e-source-content'), { height: finalHeight });
|
|
1864
1892
|
}
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
if (target === 'windowResize' && heightPercent) {
|
|
1868
|
-
//cntEle hide the borderBottom of RichTextEditor. so removed the 2px of cntEle height.
|
|
1869
|
-
heightValue = parseInt(heightValue, 10) - 2 + 'px';
|
|
1893
|
+
else {
|
|
1894
|
+
setStyleAttribute(cntEle, { height: finalHeight });
|
|
1870
1895
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
var codeElement = select('.' + classes.CLS_RTE_CONTENT, this.element);
|
|
1876
|
-
setStyleAttribute(codeElement, { height: heightValue, marginTop: topValue + 'px' });
|
|
1877
|
-
}
|
|
1878
|
-
if (this.toolbarSettings.enableFloating && this.getToolbar() && !this.inlineMode.enable) {
|
|
1879
|
-
var tbWrapHeight = (isExpand ? (tbHeight + expandPopHeight) : tbHeight) + 'px';
|
|
1880
|
-
setStyleAttribute(this.getToolbar().parentElement, { height: tbWrapHeight });
|
|
1896
|
+
break;
|
|
1897
|
+
case 'Resize':
|
|
1898
|
+
setStyleAttribute(cntEle, { height: finalHeight });
|
|
1899
|
+
break;
|
|
1881
1900
|
}
|
|
1882
1901
|
if (rzHeight === 0) {
|
|
1883
1902
|
this.autoResize();
|
|
@@ -2026,11 +2045,22 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2026
2045
|
RichTextEditor.prototype.getID = function () {
|
|
2027
2046
|
return (this.originalElement.tagName === 'TEXTAREA' ? this.valueContainer.id : this.element.id);
|
|
2028
2047
|
};
|
|
2048
|
+
/**
|
|
2049
|
+
* @returns {void}
|
|
2050
|
+
* getCssClass method
|
|
2051
|
+
*
|
|
2052
|
+
* @hidden
|
|
2053
|
+
* @deprecated
|
|
2054
|
+
*/
|
|
2055
|
+
RichTextEditor.prototype.getCssClass = function (isSpace) {
|
|
2056
|
+
return (isNOU(this.cssClass) ? '' : isSpace ? ' ' + this.cssClass : this.cssClass);
|
|
2057
|
+
};
|
|
2029
2058
|
RichTextEditor.prototype.mouseDownHandler = function (e) {
|
|
2030
2059
|
var touch = (e.touches ? e.changedTouches[0] : e);
|
|
2031
2060
|
addClass([this.element], [classes.CLS_FOCUS]);
|
|
2032
2061
|
this.preventDefaultResize(e);
|
|
2033
2062
|
this.notify(events.mouseDown, { args: e });
|
|
2063
|
+
this.formatter.editorManager.observer.notify(events.mouseDown, { args: e });
|
|
2034
2064
|
this.clickPoints = { clientX: touch.clientX, clientY: touch.clientY };
|
|
2035
2065
|
};
|
|
2036
2066
|
RichTextEditor.prototype.preventImgResize = function (e) {
|
|
@@ -2069,18 +2099,14 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2069
2099
|
RichTextEditor.prototype.resizeHandler = function () {
|
|
2070
2100
|
var isExpand = false;
|
|
2071
2101
|
if (!document.body.contains(this.element)) {
|
|
2072
|
-
document.defaultView.removeEventListener('resize', this.onResizeHandler, true);
|
|
2102
|
+
document.defaultView.removeEventListener('resize', debounce(this.onResizeHandler, 10), true);
|
|
2073
2103
|
return;
|
|
2074
2104
|
}
|
|
2075
2105
|
if (this.toolbarSettings.enable && !this.inlineMode.enable) {
|
|
2076
2106
|
this.toolbarModule.refreshToolbarOverflow();
|
|
2077
2107
|
isExpand = this.toolbarModule.baseToolbar.toolbarObj.element.classList.contains(classes.CLS_EXPAND_OPEN);
|
|
2078
2108
|
}
|
|
2079
|
-
|
|
2080
|
-
// When resize the window,border bottom of cntEle and this.element border visible separatly.so none the cntEle borderBottom.
|
|
2081
|
-
this.contentModule.getPanel().style.borderBottom = 'none';
|
|
2082
|
-
}
|
|
2083
|
-
this.setContentHeight('windowResize', isExpand);
|
|
2109
|
+
this.setContentHeight('WindowResize', isExpand);
|
|
2084
2110
|
this.notify(events.windowResize, null);
|
|
2085
2111
|
};
|
|
2086
2112
|
RichTextEditor.prototype.scrollHandler = function (e) {
|
|
@@ -2137,7 +2163,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2137
2163
|
};
|
|
2138
2164
|
RichTextEditor.prototype.getUpdatedValue = function () {
|
|
2139
2165
|
var value;
|
|
2140
|
-
var getTextArea = this.element.querySelector('.
|
|
2166
|
+
var getTextArea = this.element.querySelector('.' + classes.CLS_RTE_SOURCE_CODE_TXTAREA);
|
|
2141
2167
|
if (this.editorMode === 'HTML') {
|
|
2142
2168
|
value = (this.inputElement.innerHTML === '<p><br></p>' || this.inputElement.innerHTML === '<div><br></div>' ||
|
|
2143
2169
|
this.inputElement.innerHTML === '<br>') ? null : this.enableHtmlEncode ?
|
|
@@ -2168,6 +2194,21 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2168
2194
|
clearTimeout(this.idleInterval);
|
|
2169
2195
|
this.idleInterval = setTimeout(this.updateValueOnIdle.bind(this), 0);
|
|
2170
2196
|
};
|
|
2197
|
+
RichTextEditor.prototype.cleanupResizeElements = function (args) {
|
|
2198
|
+
var value = this.removeResizeElement(args.value);
|
|
2199
|
+
args.callBack(value);
|
|
2200
|
+
};
|
|
2201
|
+
RichTextEditor.prototype.addAnchorAriaLabel = function (value) {
|
|
2202
|
+
var valueElementWrapper = document.createElement("div");
|
|
2203
|
+
valueElementWrapper.innerHTML = value;
|
|
2204
|
+
var item = valueElementWrapper.querySelectorAll("a");
|
|
2205
|
+
if (item.length > 0) {
|
|
2206
|
+
for (var i = 0; i < item.length; i++) {
|
|
2207
|
+
(item[i].hasAttribute("target") && item[i].getAttribute("target") === '_blank') ? item[i].setAttribute("aria-label", this.serviceLocator.getService('rteLocale').getConstant("linkAriaLabel")) : item[i];
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
return valueElementWrapper.innerHTML;
|
|
2211
|
+
};
|
|
2171
2212
|
RichTextEditor.prototype.removeResizeElement = function (value) {
|
|
2172
2213
|
var valueElementWrapper = document.createElement("div");
|
|
2173
2214
|
valueElementWrapper.innerHTML = value;
|
|
@@ -2177,6 +2218,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2177
2218
|
detach(item[i]);
|
|
2178
2219
|
}
|
|
2179
2220
|
}
|
|
2221
|
+
this.removeSelectionClassStates(valueElementWrapper);
|
|
2180
2222
|
return valueElementWrapper.innerHTML;
|
|
2181
2223
|
};
|
|
2182
2224
|
RichTextEditor.prototype.updateStatus = function (e) {
|
|
@@ -2200,6 +2242,10 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2200
2242
|
this.isRTE = false;
|
|
2201
2243
|
}
|
|
2202
2244
|
this.notify(events.docClick, { args: e });
|
|
2245
|
+
var hideQuickToolbarChecker = this.quickToolbarModule && !this.inlineMode.enable && isNOU(this.quickToolbarModule.inlineQTBar);
|
|
2246
|
+
if ((hideQuickToolbarChecker && !isNOU(closest(target, '.' + 'e-toolbar-wrapper'))) || (hideQuickToolbarChecker && (!isNOU(closest(target, '.e-rte-table-resize')) || !isNOU(closest(target, '.e-table-box'))))) {
|
|
2247
|
+
this.quickToolbarModule.hideQuickToolbars();
|
|
2248
|
+
}
|
|
2203
2249
|
if (Browser.info.name !== 'msie' && e.detail > 3) {
|
|
2204
2250
|
e.preventDefault();
|
|
2205
2251
|
}
|
|
@@ -2208,6 +2254,12 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2208
2254
|
var trg = e.relatedTarget;
|
|
2209
2255
|
if (trg) {
|
|
2210
2256
|
var rteElement = closest(trg, '.' + classes.CLS_RTE);
|
|
2257
|
+
if (!rteElement && this.iframeSettings.enable) {
|
|
2258
|
+
var iframeElement = this.element.querySelector('#' + this.getID() + '_rte-view');
|
|
2259
|
+
if (iframeElement && iframeElement.contentWindow.document.body.contains(trg)) {
|
|
2260
|
+
rteElement = closest(iframeElement, '.' + classes.CLS_RTE);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2211
2263
|
if (rteElement && rteElement === this.element) {
|
|
2212
2264
|
this.isBlur = false;
|
|
2213
2265
|
if (trg === this.getToolbarElement()) {
|
|
@@ -2224,6 +2276,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2224
2276
|
}
|
|
2225
2277
|
if (this.isBlur && isNOU(trg)) {
|
|
2226
2278
|
removeClass([this.element], [classes.CLS_FOCUS]);
|
|
2279
|
+
this.removeSelectionClassStates(this.inputElement);
|
|
2227
2280
|
this.notify(events.focusChange, {});
|
|
2228
2281
|
var value = this.getUpdatedValue();
|
|
2229
2282
|
this.setProperties({ value: value });
|
|
@@ -2342,9 +2395,10 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2342
2395
|
this.triggerEditArea(e.originalEvent);
|
|
2343
2396
|
};
|
|
2344
2397
|
RichTextEditor.prototype.contextHandler = function (e) {
|
|
2345
|
-
var closestElem = closest(e.target, 'a, table, img');
|
|
2398
|
+
var closestElem = closest(e.target, 'a, table, img, video, audio');
|
|
2346
2399
|
if (this.inlineMode.onSelection === false || (!isNOU(closestElem) && this.inputElement.contains(closestElem)
|
|
2347
|
-
&& (closestElem.tagName === 'IMG' || closestElem.tagName === 'TABLE' || closestElem.tagName === 'A'
|
|
2400
|
+
&& (closestElem.tagName === 'IMG' || closestElem.tagName === 'TABLE' || closestElem.tagName === 'A' ||
|
|
2401
|
+
closestElem.tagName.toLowerCase() === 'video' || closestElem.tagName.toLowerCase() === 'audio'))) {
|
|
2348
2402
|
e.preventDefault();
|
|
2349
2403
|
}
|
|
2350
2404
|
};
|
|
@@ -2366,10 +2420,8 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2366
2420
|
}, 0);
|
|
2367
2421
|
}
|
|
2368
2422
|
else if (this.iframeSettings.enable) {
|
|
2369
|
-
var
|
|
2370
|
-
|
|
2371
|
-
_this.setAutoHeight(iframeElement_1);
|
|
2372
|
-
}, 100);
|
|
2423
|
+
var iframeElement = this.element.querySelector('#' + this.getID() + '_rte-view');
|
|
2424
|
+
this.setAutoHeight(iframeElement);
|
|
2373
2425
|
this.inputElement.style.overflow = 'hidden';
|
|
2374
2426
|
}
|
|
2375
2427
|
}
|
|
@@ -2378,10 +2430,21 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2378
2430
|
}
|
|
2379
2431
|
};
|
|
2380
2432
|
RichTextEditor.prototype.setAutoHeight = function (element) {
|
|
2381
|
-
if (!isNOU(element)) {
|
|
2433
|
+
if (!isNOU(element) && !this.iframeSettings.enable) {
|
|
2382
2434
|
element.style.height = this.inputElement.scrollHeight + 'px';
|
|
2383
2435
|
element.style.overflow = 'hidden';
|
|
2384
2436
|
}
|
|
2437
|
+
else if (!isNOU(element) && !isNOU(element.parentElement) && this.iframeSettings.enable) {
|
|
2438
|
+
var newRange = this.getRange();
|
|
2439
|
+
element.style.height = 'auto';
|
|
2440
|
+
var newHeight = element.contentDocument.body.scrollHeight + 'px';
|
|
2441
|
+
element.style.height = newHeight;
|
|
2442
|
+
element.style.overflow = 'hidden';
|
|
2443
|
+
// 16 px added for padding doesn't affect the editor height
|
|
2444
|
+
if (newRange.startContainer.nodeName !== '#text' && newRange.startContainer.nodeName !== 'BODY' && window.innerHeight < newRange.startContainer.getBoundingClientRect().top + element.getBoundingClientRect().top + 16) {
|
|
2445
|
+
newRange.startContainer.scrollIntoView(false);
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2385
2448
|
};
|
|
2386
2449
|
RichTextEditor.prototype.wireEvents = function () {
|
|
2387
2450
|
this.element.addEventListener('focusin', this.onFocusHandler, true);
|
|
@@ -2389,6 +2452,8 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2389
2452
|
this.on(events.contentChanged, this.contentChanged, this);
|
|
2390
2453
|
this.on(events.resizeInitialized, this.updateResizeFlag, this);
|
|
2391
2454
|
this.on(events.updateTbItemsStatus, this.updateStatus, this);
|
|
2455
|
+
this.on(events.cleanupResizeElements, this.cleanupResizeElements, this);
|
|
2456
|
+
this.on(events.updateValueOnIdle, this.updateValueOnIdle, this);
|
|
2392
2457
|
if (this.readonly && this.enabled) {
|
|
2393
2458
|
return;
|
|
2394
2459
|
}
|
|
@@ -2397,7 +2462,7 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2397
2462
|
RichTextEditor.prototype.restrict = function (e) {
|
|
2398
2463
|
if (this.maxLength >= 0) {
|
|
2399
2464
|
var element = this.editorMode === 'Markdown' ? this.contentModule.getText() :
|
|
2400
|
-
(
|
|
2465
|
+
(this.getText().replace(/(\r\n|\n|\r|\t)/gm, '').replace(/\u200B/g, ''));
|
|
2401
2466
|
if (!element) {
|
|
2402
2467
|
return;
|
|
2403
2468
|
}
|
|
@@ -2429,11 +2494,12 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2429
2494
|
}
|
|
2430
2495
|
EventHandler.add(this.inputElement, 'keyup', this.keyUp, this);
|
|
2431
2496
|
EventHandler.add(this.inputElement, 'paste', this.onPaste, this);
|
|
2497
|
+
EventHandler.add(this.inputElement, 'content-changed', this.contentChanged, this);
|
|
2432
2498
|
EventHandler.add(this.inputElement, Browser.touchEndEvent, debounce(this.mouseUp, 30), this);
|
|
2433
2499
|
EventHandler.add(this.inputElement, Browser.touchStartEvent, this.mouseDownHandler, this);
|
|
2434
2500
|
this.wireContextEvent();
|
|
2435
2501
|
this.formatter.editorManager.observer.on(CONSTANT.KEY_DOWN_HANDLER, this.editorKeyDown, this);
|
|
2436
|
-
this.element.ownerDocument.defaultView.addEventListener('resize', this.onResizeHandler, true);
|
|
2502
|
+
this.element.ownerDocument.defaultView.addEventListener('resize', debounce(this.onResizeHandler, 10), true);
|
|
2437
2503
|
if (this.iframeSettings.enable) {
|
|
2438
2504
|
EventHandler.add(this.inputElement, 'focusin', this.focusHandler, this);
|
|
2439
2505
|
EventHandler.add(this.inputElement, 'focusout', this.blurHandler, this);
|
|
@@ -2475,6 +2541,8 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2475
2541
|
this.off(events.contentChanged, this.contentChanged);
|
|
2476
2542
|
this.off(events.resizeInitialized, this.updateResizeFlag);
|
|
2477
2543
|
this.off(events.updateTbItemsStatus, this.updateStatus);
|
|
2544
|
+
this.off(events.cleanupResizeElements, this.cleanupResizeElements);
|
|
2545
|
+
this.off(events.updateValueOnIdle, this.updateValueOnIdle);
|
|
2478
2546
|
if (this.readonly && this.enabled) {
|
|
2479
2547
|
return;
|
|
2480
2548
|
}
|
|
@@ -2490,13 +2558,14 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2490
2558
|
}
|
|
2491
2559
|
EventHandler.remove(this.inputElement, 'keyup', this.keyUp);
|
|
2492
2560
|
EventHandler.remove(this.inputElement, 'paste', this.onPaste);
|
|
2561
|
+
EventHandler.remove(this.inputElement, 'content-changed', this.contentChanged);
|
|
2493
2562
|
EventHandler.remove(this.inputElement, Browser.touchEndEvent, debounce(this.mouseUp, 30));
|
|
2494
2563
|
EventHandler.remove(this.inputElement, Browser.touchStartEvent, this.mouseDownHandler);
|
|
2495
2564
|
this.unWireContextEvent();
|
|
2496
2565
|
if (this.formatter) {
|
|
2497
2566
|
this.formatter.editorManager.observer.off(CONSTANT.KEY_DOWN_HANDLER, this.editorKeyDown);
|
|
2498
2567
|
}
|
|
2499
|
-
this.element.ownerDocument.defaultView.removeEventListener('resize', this.onResizeHandler, true);
|
|
2568
|
+
this.element.ownerDocument.defaultView.removeEventListener('resize', debounce(this.onResizeHandler, 10), true);
|
|
2500
2569
|
if (this.iframeSettings.enable) {
|
|
2501
2570
|
EventHandler.remove(this.inputElement, 'focusin', this.focusHandler);
|
|
2502
2571
|
EventHandler.remove(this.inputElement, 'focusout', this.blurHandler);
|
|
@@ -2543,6 +2612,33 @@ var RichTextEditor = /** @class */ (function (_super) {
|
|
|
2543
2612
|
}
|
|
2544
2613
|
}
|
|
2545
2614
|
};
|
|
2615
|
+
RichTextEditor.prototype.removeSelectionClassStates = function (element) {
|
|
2616
|
+
var classNames = [classes.CLS_IMG_FOCUS, classes.CLS_TABLE_SEL, classes.CLS_VID_FOCUS, classes.CLS_AUD_FOCUS];
|
|
2617
|
+
for (var i = 0; i < classNames.length; i++) {
|
|
2618
|
+
var item = element.querySelectorAll('.' + classNames[i]);
|
|
2619
|
+
removeClass(item, classNames[i]);
|
|
2620
|
+
if (item.length === 0) {
|
|
2621
|
+
continue;
|
|
2622
|
+
}
|
|
2623
|
+
for (var j = 0; j < item.length; j++) {
|
|
2624
|
+
if (item[j].classList.length === 0) {
|
|
2625
|
+
item[j].removeAttribute('class');
|
|
2626
|
+
}
|
|
2627
|
+
if (item[j].nodeName === 'IMG' && item[j].style.outline !== '') {
|
|
2628
|
+
item[j].style.outline = '';
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
}
|
|
2632
|
+
};
|
|
2633
|
+
RichTextEditor.prototype.getRenderedQuickToolbarElem = function () {
|
|
2634
|
+
var quickToolbars = this.quickToolbarModule.getQuickToolbarInstance();
|
|
2635
|
+
for (var i = 0; i < quickToolbars.length; i++) {
|
|
2636
|
+
if (quickToolbars[i] && quickToolbars[i].isRendered) {
|
|
2637
|
+
return quickToolbars[i].element;
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
return null;
|
|
2641
|
+
};
|
|
2546
2642
|
__decorate([
|
|
2547
2643
|
Complex({}, ToolbarSettings)
|
|
2548
2644
|
], RichTextEditor.prototype, "toolbarSettings", void 0);
|