@syncfusion/ej2-richtexteditor 21.2.9 → 22.1.34
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 +1 -0
- package/CHANGELOG.md +30 -0
- 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 +1592 -196
- package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
- package/dist/es6/ej2-richtexteditor.es5.js +1605 -199
- 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 +12 -12
- package/src/common/config.js +2 -2
- package/src/common/constant.d.ts +6 -0
- package/src/common/constant.js +6 -0
- package/src/common/interface.d.ts +2 -2
- package/src/common/util.js +2 -0
- package/src/editor-manager/base/editor-manager.d.ts +4 -3
- package/src/editor-manager/base/editor-manager.js +6 -1
- package/src/editor-manager/base/interface.d.ts +44 -9
- package/src/editor-manager/plugin/clearformat.d.ts +1 -0
- package/src/editor-manager/plugin/clearformat.js +1 -0
- package/src/editor-manager/plugin/dom-node.js +10 -6
- package/src/editor-manager/plugin/emoji-picker-action.d.ts +8 -0
- package/src/editor-manager/plugin/emoji-picker-action.js +62 -0
- package/src/editor-manager/plugin/format-painter-actions.d.ts +19 -36
- package/src/editor-manager/plugin/format-painter-actions.js +224 -81
- package/src/editor-manager/plugin/inserthtml.js +6 -1
- package/src/editor-manager/plugin/link.js +1 -1
- package/src/editor-manager/plugin/ms-word-clean-up.d.ts +3 -0
- package/src/editor-manager/plugin/ms-word-clean-up.js +66 -14
- package/src/editor-manager/plugin/selection-commands.d.ts +2 -1
- package/src/editor-manager/plugin/selection-commands.js +48 -23
- package/src/editor-manager/plugin/table.js +2 -2
- package/src/editor-manager/plugin/toolbar-status.js +6 -0
- package/src/editor-manager/plugin/undo.d.ts +1 -0
- package/src/editor-manager/plugin/undo.js +26 -5
- package/src/editor-manager/plugin.d.ts +1 -0
- package/src/editor-manager/plugin.js +1 -0
- package/src/global.js +1 -1
- package/src/rich-text-editor/actions/base-quick-toolbar.js +10 -3
- package/src/rich-text-editor/actions/base-toolbar.js +3 -2
- package/src/rich-text-editor/actions/emoji-picker.d.ts +48 -0
- package/src/rich-text-editor/actions/emoji-picker.js +778 -0
- package/src/rich-text-editor/actions/enter-key.js +2 -2
- package/src/rich-text-editor/actions/execute-command-callback.js +3 -1
- package/src/rich-text-editor/actions/file-manager.js +1 -0
- package/src/rich-text-editor/actions/format-painter.d.ts +2 -2
- package/src/rich-text-editor/actions/format-painter.js +11 -9
- package/src/rich-text-editor/actions/full-screen.js +6 -0
- package/src/rich-text-editor/actions/html-editor.js +17 -3
- package/src/rich-text-editor/actions/paste-clean-up.js +1 -0
- package/src/rich-text-editor/actions/resize.js +1 -1
- package/src/rich-text-editor/actions.d.ts +1 -0
- package/src/rich-text-editor/actions.js +1 -0
- package/src/rich-text-editor/base/constant.d.ts +10 -0
- package/src/rich-text-editor/base/constant.js +10 -0
- package/src/rich-text-editor/base/enum.d.ts +0 -4
- package/src/rich-text-editor/base/interface.d.ts +48 -6
- package/src/rich-text-editor/base/rich-text-editor-model.d.ts +13 -7
- package/src/rich-text-editor/base/rich-text-editor.d.ts +27 -7
- package/src/rich-text-editor/base/rich-text-editor.js +42 -12
- package/src/rich-text-editor/base/util.js +2 -2
- package/src/rich-text-editor/formatter/formatter.js +7 -5
- package/src/rich-text-editor/models/default-locale.js +14 -2
- package/src/rich-text-editor/models/items.d.ts +2 -1
- package/src/rich-text-editor/models/items.js +188 -1
- package/src/rich-text-editor/models/toolbar-settings-model.d.ts +212 -9
- package/src/rich-text-editor/models/toolbar-settings.d.ts +209 -11
- package/src/rich-text-editor/models/toolbar-settings.js +23 -6
- package/src/rich-text-editor/renderer/audio-module.js +3 -3
- package/src/rich-text-editor/renderer/iframe-content-renderer.js +1 -1
- package/src/rich-text-editor/renderer/image-module.js +11 -6
- package/src/rich-text-editor/renderer/toolbar-renderer.d.ts +2 -0
- package/src/rich-text-editor/renderer/toolbar-renderer.js +7 -2
- package/src/rich-text-editor/renderer/video-module.js +14 -9
- package/styles/bootstrap-dark.css +299 -137
- package/styles/bootstrap.css +305 -140
- package/styles/bootstrap4.css +304 -133
- package/styles/bootstrap5-dark.css +310 -165
- package/styles/bootstrap5.css +310 -165
- package/styles/fabric-dark.css +297 -136
- package/styles/fabric.css +294 -133
- package/styles/fluent-dark.css +311 -170
- package/styles/fluent.css +311 -170
- package/styles/highcontrast-light.css +289 -128
- package/styles/highcontrast.css +296 -135
- package/styles/material-dark.css +295 -129
- package/styles/material.css +300 -134
- package/styles/material3-dark.css +3082 -0
- package/styles/material3-dark.scss +3 -0
- package/styles/material3.css +3138 -0
- package/styles/material3.scss +3 -0
- package/styles/rich-text-editor/_bootstrap-dark-definition.scss +54 -12
- package/styles/rich-text-editor/_bootstrap-definition.scss +57 -13
- package/styles/rich-text-editor/_bootstrap4-definition.scss +50 -7
- package/styles/rich-text-editor/_bootstrap5-definition.scss +56 -13
- package/styles/rich-text-editor/_fabric-dark-definition.scss +53 -10
- package/styles/rich-text-editor/_fabric-definition.scss +52 -9
- package/styles/rich-text-editor/_fluent-definition.scss +56 -15
- package/styles/rich-text-editor/_fusionnew-definition.scss +46 -4
- package/styles/rich-text-editor/_highcontrast-definition.scss +52 -9
- package/styles/rich-text-editor/_highcontrast-light-definition.scss +48 -5
- package/styles/rich-text-editor/_layout.scss +280 -68
- package/styles/rich-text-editor/_material-dark-definition.scss +48 -5
- package/styles/rich-text-editor/_material-definition.scss +50 -6
- package/styles/rich-text-editor/_material3-dark-definition.scss +1 -0
- package/styles/rich-text-editor/_material3-definition.scss +262 -0
- package/styles/rich-text-editor/_tailwind-definition.scss +63 -23
- package/styles/rich-text-editor/_theme.scss +103 -19
- package/styles/rich-text-editor/bootstrap-dark.css +299 -137
- package/styles/rich-text-editor/bootstrap.css +305 -140
- package/styles/rich-text-editor/bootstrap4.css +304 -133
- package/styles/rich-text-editor/bootstrap5-dark.css +310 -165
- package/styles/rich-text-editor/bootstrap5.css +310 -165
- package/styles/rich-text-editor/fabric-dark.css +297 -136
- package/styles/rich-text-editor/fabric.css +294 -133
- package/styles/rich-text-editor/fluent-dark.css +311 -170
- package/styles/rich-text-editor/fluent.css +311 -170
- package/styles/rich-text-editor/highcontrast-light.css +289 -128
- package/styles/rich-text-editor/highcontrast.css +296 -135
- package/styles/rich-text-editor/icons/_bootstrap-dark.scss +1 -1
- package/styles/rich-text-editor/icons/_bootstrap.scss +1 -1
- package/styles/rich-text-editor/icons/_bootstrap4.scss +1 -1
- package/styles/rich-text-editor/icons/_bootstrap5.scss +1 -1
- package/styles/rich-text-editor/icons/_fabric-dark.scss +1 -1
- package/styles/rich-text-editor/icons/_fabric.scss +1 -1
- package/styles/rich-text-editor/icons/_fluent.scss +1 -1
- package/styles/rich-text-editor/icons/_fusionnew.scss +1 -1
- package/styles/rich-text-editor/icons/_highcontrast-light.scss +1 -1
- package/styles/rich-text-editor/icons/_highcontrast.scss +1 -1
- package/styles/rich-text-editor/icons/_material-dark.scss +1 -1
- package/styles/rich-text-editor/icons/_material.scss +1 -1
- package/styles/rich-text-editor/icons/_material3-dark.scss +1 -0
- package/styles/rich-text-editor/icons/_material3.scss +1 -1
- package/styles/rich-text-editor/icons/_tailwind.scss +1 -1
- package/styles/rich-text-editor/material-dark.css +295 -129
- package/styles/rich-text-editor/material.css +300 -134
- package/styles/rich-text-editor/material3-dark.css +3082 -0
- package/styles/rich-text-editor/material3-dark.scss +5 -0
- package/styles/rich-text-editor/material3.css +3138 -0
- package/styles/rich-text-editor/material3.scss +5 -0
- package/styles/rich-text-editor/tailwind-dark.css +313 -157
- package/styles/rich-text-editor/tailwind.css +313 -157
- package/styles/tailwind-dark.css +313 -157
- package/styles/tailwind.css +313 -157
|
@@ -0,0 +1,778 @@
|
|
|
1
|
+
import * as events from '../base/constant';
|
|
2
|
+
import { detach, addClass, isNullOrUndefined as isNOU, removeClass, closest, createElement, EventHandler } from '@syncfusion/ej2-base';
|
|
3
|
+
import { Popup } from '@syncfusion/ej2-popups';
|
|
4
|
+
import { Toolbar } from '@syncfusion/ej2-navigations';
|
|
5
|
+
import { BaseToolbar } from './base-toolbar';
|
|
6
|
+
import { TextBox } from '@syncfusion/ej2-inputs';
|
|
7
|
+
var EmojiPicker = /** @class */ (function () {
|
|
8
|
+
function EmojiPicker(parent, serviceLocator) {
|
|
9
|
+
this.parent = parent;
|
|
10
|
+
this.locator = serviceLocator;
|
|
11
|
+
this.i10n = serviceLocator.getService('rteLocale');
|
|
12
|
+
this.renderFactory = this.locator.getService('rendererFactory');
|
|
13
|
+
this.baseToolbar = new BaseToolbar(this.parent, this.locator);
|
|
14
|
+
this.addEventListener();
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Destroys the Count.
|
|
18
|
+
*
|
|
19
|
+
* @function destroy
|
|
20
|
+
* @returns {void}
|
|
21
|
+
* @hidden
|
|
22
|
+
|
|
23
|
+
*/
|
|
24
|
+
EmojiPicker.prototype.destroy = function () {
|
|
25
|
+
this.removeEventListener();
|
|
26
|
+
};
|
|
27
|
+
EmojiPicker.prototype.addEventListener = function () {
|
|
28
|
+
this.parent.on(events.emojiPicker, this.toolbarClick, this);
|
|
29
|
+
this.parent.on(events.docClick, this.docClick, this);
|
|
30
|
+
this.parent.on(events.keyDown, this.onkeyPress, this);
|
|
31
|
+
this.parent.on(events.keyUp, this.onkeyUp, this);
|
|
32
|
+
this.parent.on(events.contentscroll, this.contentscroll, this);
|
|
33
|
+
this.parent.on(events.scroll, this.contentscroll, this);
|
|
34
|
+
};
|
|
35
|
+
// eslint-disable-next-line
|
|
36
|
+
EmojiPicker.prototype.toolbarClick = function (args) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
var _a, _b;
|
|
39
|
+
var spanElement = this.parent.element.querySelector('.e-emoji');
|
|
40
|
+
this.divElement = spanElement.closest('div');
|
|
41
|
+
var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
|
|
42
|
+
this.save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
|
|
43
|
+
this.clickEvent = args.args;
|
|
44
|
+
var emojiPicker = this.parent.emojiPickerSettings.iconsSet;
|
|
45
|
+
if (this.popupObj) {
|
|
46
|
+
removeClass([this.divElement], 'e-active');
|
|
47
|
+
if (this.popupObj.element.querySelector('.e-rte-emoji-search') || !this.parent.emojiPickerSettings.showSearchBox) {
|
|
48
|
+
this.popupObj.hide();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.popupObj.hide();
|
|
52
|
+
}
|
|
53
|
+
this.popDiv = this.parent.createElement('div', { className: 'e-rte-emojipicker-popup', id: this.parent.getID() + '_emojiPicker' });
|
|
54
|
+
this.parent.getToolbar().appendChild(this.popDiv);
|
|
55
|
+
EventHandler.add(this.popDiv, 'keydown', this.onKeyDown, this);
|
|
56
|
+
EventHandler.add(this.popDiv, 'keyup', this.searchFilter, this);
|
|
57
|
+
var extendEle = this.parent.element.querySelector('.e-toolbar-extended');
|
|
58
|
+
var zIndex;
|
|
59
|
+
if (!isNOU(extendEle)) {
|
|
60
|
+
var computedStyle = window.getComputedStyle(extendEle);
|
|
61
|
+
zIndex = computedStyle.getPropertyValue('z-index');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
zIndex = '10001';
|
|
65
|
+
}
|
|
66
|
+
var target;
|
|
67
|
+
var xValue;
|
|
68
|
+
var yValue;
|
|
69
|
+
if (!isNOU(args.args)) {
|
|
70
|
+
target = args.args.originalEvent.target;
|
|
71
|
+
target = target.classList.contains('e-toolbar-item') ? target.firstChild : target.parentElement;
|
|
72
|
+
xValue = 'left';
|
|
73
|
+
yValue = 'bottom';
|
|
74
|
+
}
|
|
75
|
+
else if (isNOU(args.x) && isNOU(args.y)) {
|
|
76
|
+
target = this.parent.inputElement;
|
|
77
|
+
if (window.getSelection().rangeCount > 0) {
|
|
78
|
+
var coordinates = this.getCoordinates();
|
|
79
|
+
xValue = coordinates.left;
|
|
80
|
+
yValue = coordinates.top;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
target = this.parent.inputElement;
|
|
85
|
+
xValue = args.x;
|
|
86
|
+
yValue = args.y;
|
|
87
|
+
}
|
|
88
|
+
this.popupObj = new Popup(this.popDiv, {
|
|
89
|
+
targetType: 'relative',
|
|
90
|
+
relateTo: target,
|
|
91
|
+
collision: { X: 'fit', Y: 'none' },
|
|
92
|
+
offsetY: 8,
|
|
93
|
+
viewPortElement: this.parent.element,
|
|
94
|
+
position: { X: xValue, Y: yValue },
|
|
95
|
+
enableRtl: this.parent.enableRtl,
|
|
96
|
+
zIndex: parseInt(zIndex, 10) + 1,
|
|
97
|
+
actionOnScroll: 'hide',
|
|
98
|
+
// eslint-disable-next-line
|
|
99
|
+
close: function (event) {
|
|
100
|
+
_this.parent.isBlur = false;
|
|
101
|
+
_this.popupObj.destroy();
|
|
102
|
+
detach(_this.popupObj.element);
|
|
103
|
+
_this.popupObj = null;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
addClass([this.popupObj.element], 'e-popup-open');
|
|
107
|
+
this.popupObj.refreshPosition(target);
|
|
108
|
+
// header search element
|
|
109
|
+
if ((!isNOU(args.args) || (isNOU(args.x) && isNOU(args.y))) && this.parent.emojiPickerSettings.showSearchBox) {
|
|
110
|
+
var inputEle = createElement('input', { id: 'e-rte-emoji-search', className: 'e-rte-emoji-search' });
|
|
111
|
+
this.popDiv.append(inputEle);
|
|
112
|
+
var inputobj = new TextBox({
|
|
113
|
+
placeholder: this.i10n.getConstant('emojiPickerTypeToFind'),
|
|
114
|
+
showClearButton: true
|
|
115
|
+
});
|
|
116
|
+
inputobj.appendTo(inputEle);
|
|
117
|
+
inputEle.focus();
|
|
118
|
+
}
|
|
119
|
+
var closeIcon = this.popupObj.element.querySelector('.e-clear-icon');
|
|
120
|
+
if (!isNOU(closeIcon)) {
|
|
121
|
+
EventHandler.add(closeIcon, 'mousedown', this.searchFilter, this);
|
|
122
|
+
}
|
|
123
|
+
// Header emoji toolbar div
|
|
124
|
+
var emojiToolBar = this.parent.createElement('div', { className: 'e-rte-emojipicker-toolbar' });
|
|
125
|
+
this.popDiv.appendChild(emojiToolBar);
|
|
126
|
+
var pushToolBar = [];
|
|
127
|
+
for (var i = 0; i < this.parent.emojiPickerSettings.iconsSet.length; i++) {
|
|
128
|
+
if (!isNOU(this.parent.emojiPickerSettings.iconsSet[i].iconCss)) {
|
|
129
|
+
pushToolBar.push({ prefixIcon: this.parent.emojiPickerSettings.iconsSet[i].iconCss, htmlAttributes: (_a = {}, _a['title'] = this.parent.emojiPickerSettings.iconsSet[i].name, _a) });
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
pushToolBar.push({ text: '&#x' + this.parent.emojiPickerSettings.iconsSet[i].code + ';', htmlAttributes: (_b = {}, _b['title'] = this.parent.emojiPickerSettings.iconsSet[i].name, _b) });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var toolbarObj = new Toolbar({
|
|
136
|
+
items: pushToolBar,
|
|
137
|
+
clicked: this.emojiToolbarClick.bind(this)
|
|
138
|
+
});
|
|
139
|
+
toolbarObj.appendTo(emojiToolBar);
|
|
140
|
+
// emoji btn div
|
|
141
|
+
var emojiBtnDiv = this.parent.createElement('div', { className: 'e-rte-emojipicker-btn' });
|
|
142
|
+
this.popDiv.appendChild(emojiBtnDiv);
|
|
143
|
+
var height;
|
|
144
|
+
var popupBorder = window.getComputedStyle(this.popDiv);
|
|
145
|
+
if ((isNOU(args.args) && !(isNOU(args.x) && isNOU(args.y))) || !this.parent.emojiPickerSettings.showSearchBox) {
|
|
146
|
+
height = (this.popDiv.getBoundingClientRect().height - emojiToolBar.getBoundingClientRect().height - (2 * parseFloat(popupBorder.borderWidth))) + 'px';
|
|
147
|
+
emojiBtnDiv.style.setProperty('height', height, 'important');
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
var inputELe = this.parent.element.querySelector('.e-rte-emoji-search').parentElement;
|
|
151
|
+
var getComputedStyle_1 = window.getComputedStyle(inputELe);
|
|
152
|
+
height = (this.popDiv.getBoundingClientRect().height - emojiToolBar.getBoundingClientRect().height
|
|
153
|
+
- inputELe.getBoundingClientRect().height
|
|
154
|
+
- parseFloat(getComputedStyle_1.marginTop) - parseFloat(getComputedStyle_1.marginBottom)
|
|
155
|
+
- (2 * parseFloat(popupBorder.borderWidth))) + 'px';
|
|
156
|
+
emojiBtnDiv.style.setProperty('height', height, 'important');
|
|
157
|
+
}
|
|
158
|
+
for (var i = 0; i < emojiPicker.length; i++) {
|
|
159
|
+
var emojiGroupDiv = this.parent.createElement('div', { className: 'e-rte-emojipicker-group' });
|
|
160
|
+
emojiBtnDiv.appendChild(emojiGroupDiv);
|
|
161
|
+
var emojiName = this.parent.createElement('div', { className: 'e-rte-emojipicker-name' });
|
|
162
|
+
emojiName.innerText = this.parent.emojiPickerSettings.iconsSet[i].name;
|
|
163
|
+
emojiName.setAttribute('aria-label', this.parent.emojiPickerSettings.iconsSet[i].name);
|
|
164
|
+
emojiGroupDiv.appendChild(emojiName);
|
|
165
|
+
var emojiBtn = this.parent.createElement('div', { className: 'e-rte-emojipickerbtn-group' });
|
|
166
|
+
emojiGroupDiv.appendChild(emojiBtn);
|
|
167
|
+
for (var j = 0; j < emojiPicker[i].icons.length; j++) {
|
|
168
|
+
var button = this.parent.createElement('button', { className: 'e-btn ' + ' ' + 'e-control' });
|
|
169
|
+
button.innerHTML = this.buttoncode(this.parent.emojiPickerSettings.iconsSet[i].icons[j].code);
|
|
170
|
+
button.setAttribute('aria-label', (this.parent.emojiPickerSettings.iconsSet[i].icons[j].desc));
|
|
171
|
+
button.setAttribute('title', (this.parent.emojiPickerSettings.iconsSet[i].icons[j].desc));
|
|
172
|
+
emojiBtn.appendChild(button);
|
|
173
|
+
if (button.innerHTML.length > 2) {
|
|
174
|
+
button.style.fontSize = '17px';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
EventHandler.add(emojiBtnDiv, 'scroll', this.scrollEvent, this);
|
|
179
|
+
EventHandler.add(emojiBtnDiv, 'click', this.emojiBtnClick, this);
|
|
180
|
+
var emojiButtons = this.parent.element.querySelectorAll('.e-rte-emojipicker-btn button');
|
|
181
|
+
if (isNOU(this.parent.element.querySelector('.e-rte-emoji-search')) && !isNOU(args.args)) {
|
|
182
|
+
emojiButtons[0].focus();
|
|
183
|
+
addClass([emojiButtons[0]], 'e-focus');
|
|
184
|
+
}
|
|
185
|
+
var popup = this.parent.element.querySelector('.e-rte-emojipicker-btn');
|
|
186
|
+
var toolbarName = this.parent.element.querySelectorAll('.e-rte-emojipicker-toolbar button');
|
|
187
|
+
var scrollTop;
|
|
188
|
+
if (!isNOU(popup)) {
|
|
189
|
+
scrollTop = Math.round(popup.scrollTop);
|
|
190
|
+
}
|
|
191
|
+
for (var i = 0; i < toolbarName.length; i++) {
|
|
192
|
+
/* eslint-disable */
|
|
193
|
+
if (toolbarName[i].classList.contains('e-selected')) {
|
|
194
|
+
removeClass([toolbarName[i]], 'e-selected');
|
|
195
|
+
}
|
|
196
|
+
/* eslint-enable */
|
|
197
|
+
}
|
|
198
|
+
if (scrollTop < toolbarName[0].offsetHeight) {
|
|
199
|
+
addClass([toolbarName[0]], 'e-selected');
|
|
200
|
+
}
|
|
201
|
+
if (this.popupObj) {
|
|
202
|
+
addClass([this.divElement], 'e-active');
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
EmojiPicker.prototype.buttoncode = function (value) {
|
|
206
|
+
var valueLength = value.split('-');
|
|
207
|
+
// eslint-disable-next-line
|
|
208
|
+
var joinedEmoji = valueLength.map(function (cp) { return String.fromCodePoint(parseInt(cp, 16)); }).join('\u200D');
|
|
209
|
+
return joinedEmoji;
|
|
210
|
+
};
|
|
211
|
+
EmojiPicker.prototype.docClick = function (e) {
|
|
212
|
+
var target = e.args.target;
|
|
213
|
+
if (target && target.classList && ((this.popupObj && !closest(target, '[id=' + '\'' + this.popupObj.element.id + '\'' + ']')))
|
|
214
|
+
&& (!target.classList.contains('e-emoji') && !target.classList.contains('e-toolbar-item'))) {
|
|
215
|
+
if (this.popupObj) {
|
|
216
|
+
removeClass([this.divElement], 'e-active');
|
|
217
|
+
this.popupObj.hide();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
EmojiPicker.prototype.scrollEvent = function () {
|
|
222
|
+
var popup = this.parent.element.querySelector('.e-rte-emojipicker-btn');
|
|
223
|
+
var emojiSet = this.parent.element.querySelectorAll('.e-rte-emojipicker-group');
|
|
224
|
+
var toolbarName = this.parent.element.querySelectorAll('.e-rte-emojipicker-toolbar button');
|
|
225
|
+
var scrollTop;
|
|
226
|
+
if (!isNOU(popup)) {
|
|
227
|
+
scrollTop = Math.round(popup.scrollTop);
|
|
228
|
+
}
|
|
229
|
+
var firstSetWidth = 0;
|
|
230
|
+
for (var j = 0; j < toolbarName.length; j++) {
|
|
231
|
+
if (scrollTop < toolbarName[0].offsetHeight) {
|
|
232
|
+
if (!isNOU(toolbarName[j + 1])) {
|
|
233
|
+
removeClass([toolbarName[j + 1]], 'e-selected');
|
|
234
|
+
}
|
|
235
|
+
addClass([toolbarName[0]], 'e-selected');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
for (var i = 0; i < emojiSet.length; i++) {
|
|
239
|
+
// eslint-disable-next-line
|
|
240
|
+
firstSetWidth += Math.round(emojiSet[i].offsetHeight);
|
|
241
|
+
if (scrollTop >= firstSetWidth) {
|
|
242
|
+
for (var k = 0; k < toolbarName.length; k++) {
|
|
243
|
+
/* eslint-disable */
|
|
244
|
+
if (toolbarName[k].classList.contains('e-selected')) {
|
|
245
|
+
removeClass([toolbarName[k]], 'e-selected');
|
|
246
|
+
}
|
|
247
|
+
/* eslint-enable */
|
|
248
|
+
}
|
|
249
|
+
if (!isNOU(toolbarName[i + 1])) {
|
|
250
|
+
addClass([toolbarName[i + 1]], 'e-selected');
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
EmojiPicker.prototype.contentscroll = function () {
|
|
256
|
+
if (isNOU(this.clickEvent) && this.popupObj) {
|
|
257
|
+
removeClass([this.divElement], 'e-active');
|
|
258
|
+
this.popupObj.hide();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
EmojiPicker.prototype.emojiToolbarClick = function (e) {
|
|
263
|
+
var args = {
|
|
264
|
+
// eslint-disable-next-line
|
|
265
|
+
text: e.item.htmlAttributes.title,
|
|
266
|
+
};
|
|
267
|
+
var currentEleName = args.text;
|
|
268
|
+
var emojiGroups = this.parent.element.querySelectorAll('.e-rte-emojipicker-group');
|
|
269
|
+
var emojiButtons = this.parent.element.querySelectorAll('.e-rte-emojipicker-btn button');
|
|
270
|
+
var toolbarName = this.parent.element.querySelectorAll('.e-rte-emojipicker-toolbar button');
|
|
271
|
+
for (var i = 0; i < toolbarName.length; i++) {
|
|
272
|
+
/* eslint-disable */
|
|
273
|
+
if (toolbarName[i].classList.contains('e-selected')) {
|
|
274
|
+
removeClass([toolbarName[i]], 'e-selected');
|
|
275
|
+
}
|
|
276
|
+
/* eslint-enable */
|
|
277
|
+
}
|
|
278
|
+
for (var i = 0; i < emojiButtons.length; i++) {
|
|
279
|
+
if (emojiButtons[i].classList.contains('e-focus')) {
|
|
280
|
+
removeClass([emojiButtons[i]], 'e-focus');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
// Loop through the selected elements and perform the same operation on each element
|
|
284
|
+
var emojiGroupsheight = this.parent.element.querySelector('.e-rte-emojipicker-btn');
|
|
285
|
+
var emojiHeight = 0;
|
|
286
|
+
// eslint-disable-next-line
|
|
287
|
+
emojiGroups.forEach(function (group) {
|
|
288
|
+
var childNodes = group.childNodes[0];
|
|
289
|
+
var focusBtn = group.childNodes[1].childNodes[0];
|
|
290
|
+
var ariaLabel = childNodes.getAttribute('aria-label');
|
|
291
|
+
if (currentEleName === ariaLabel) {
|
|
292
|
+
if (childNodes) {
|
|
293
|
+
emojiGroupsheight.scrollTop = emojiHeight + 10;
|
|
294
|
+
addClass([focusBtn], 'e-focus');
|
|
295
|
+
focusBtn.focus();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
emojiHeight += group.scrollHeight;
|
|
300
|
+
removeClass([focusBtn], 'e-focus');
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
};
|
|
304
|
+
EmojiPicker.prototype.onKeyDown = function (e) {
|
|
305
|
+
// Select all emoji buttons
|
|
306
|
+
var emojiButtons = this.parent.element.querySelectorAll('.e-rte-emojipicker-btn button');
|
|
307
|
+
var emojiGroups = this.parent.element.querySelectorAll('.e-rte-emojipickerbtn-group');
|
|
308
|
+
var searchKeyHandler = this.parent.element.querySelector('.e-rte-emojisearch-btn button');
|
|
309
|
+
if (e.keyCode === 27) {
|
|
310
|
+
if (this.popupObj) {
|
|
311
|
+
removeClass([this.divElement], 'e-active');
|
|
312
|
+
this.popupObj.hide();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (e.keyCode === 13) {
|
|
316
|
+
var activeEle = document.activeElement;
|
|
317
|
+
if (activeEle.classList.contains('e-btn')) {
|
|
318
|
+
this.emojiBtnClick(e);
|
|
319
|
+
e.preventDefault();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
var srcElement = e.srcElement;
|
|
323
|
+
if (!isNOU(srcElement)) {
|
|
324
|
+
if (srcElement.classList.contains('e-rte-emoji-search') && e.keyCode === 40) {
|
|
325
|
+
for (var i = 0; i < emojiButtons.length; i++) {
|
|
326
|
+
if (emojiButtons[i].classList.contains('e-focus')) {
|
|
327
|
+
removeClass([emojiButtons[i]], 'e-focus');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (!isNOU(searchKeyHandler)) {
|
|
333
|
+
this.filterKeyHandler(e);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
for (var i = 0; i < emojiButtons.length; i++) {
|
|
337
|
+
var focusIndex = i;
|
|
338
|
+
if (emojiButtons[i].classList.contains('e-focus')) {
|
|
339
|
+
if (e.keyCode === 40) {
|
|
340
|
+
// Move focus to next row if there is one
|
|
341
|
+
if (emojiButtons.length - 4 > i) {
|
|
342
|
+
var count = 0;
|
|
343
|
+
for (var j = 0; j < emojiGroups.length; j++) {
|
|
344
|
+
for (var k = 0; k < emojiGroups[j].childNodes.length; k++) {
|
|
345
|
+
// eslint-disable-next-line
|
|
346
|
+
var childNodes = emojiGroups[j].childNodes[k];
|
|
347
|
+
if (childNodes.classList.contains('e-focus') && count !== 1) {
|
|
348
|
+
var currentIndex = k;
|
|
349
|
+
var lastChild = emojiGroups[j].lastChild;
|
|
350
|
+
var lastRowIndex = Math.floor((k) % 6);
|
|
351
|
+
var lastEleLength = emojiGroups[j].childNodes.length - 1;
|
|
352
|
+
var lastEleIndex = Math.floor((lastEleLength) % 6);
|
|
353
|
+
if (currentIndex !== -1) {
|
|
354
|
+
var nextRowIndex = currentIndex + 6;
|
|
355
|
+
if (!isNOU(emojiGroups[j].childNodes[nextRowIndex])) {
|
|
356
|
+
// next row has six buttons
|
|
357
|
+
// handle focus change here
|
|
358
|
+
var firstFocusEle = emojiButtons[i];
|
|
359
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
360
|
+
var focusEle = emojiButtons[focusIndex += 6];
|
|
361
|
+
addClass([focusEle], 'e-focus');
|
|
362
|
+
focusEle.focus();
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
else if (isNOU(emojiGroups[j].childNodes[nextRowIndex]) && !lastChild.classList.contains('e-focus') && lastEleIndex < lastRowIndex) {
|
|
366
|
+
var firstFocusEle = emojiButtons[i];
|
|
367
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
368
|
+
var focusEle = emojiGroups[j].lastChild;
|
|
369
|
+
addClass([focusEle], 'e-focus');
|
|
370
|
+
focusEle.focus();
|
|
371
|
+
count = 1;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
var firstFocusEle = emojiButtons[i];
|
|
376
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
377
|
+
var focusEle = emojiGroups[j + 1]
|
|
378
|
+
.childNodes[lastRowIndex];
|
|
379
|
+
addClass([focusEle], 'e-focus');
|
|
380
|
+
focusEle.focus();
|
|
381
|
+
count = 1;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
else if (e.keyCode === 38) {
|
|
392
|
+
// Move focus to previous row if there is one
|
|
393
|
+
if (i >= 6) {
|
|
394
|
+
var count = 0;
|
|
395
|
+
for (var j = 0; j < emojiGroups.length; j++) {
|
|
396
|
+
for (var k = 0; k < emojiGroups[j].childNodes.length; k++) {
|
|
397
|
+
var childNodes = emojiGroups[j].childNodes[k];
|
|
398
|
+
if (childNodes.classList.contains('e-focus') && count !== 1) {
|
|
399
|
+
// eslint-disable-next-line
|
|
400
|
+
var currentIndex = k;
|
|
401
|
+
var previousRowLength = isNOU(emojiGroups[j - 1]) ? null :
|
|
402
|
+
emojiGroups[j - 1].childNodes.length % 6 || 6;
|
|
403
|
+
if (currentIndex !== -1) {
|
|
404
|
+
var previousRowIndex = currentIndex - 6;
|
|
405
|
+
if (!isNOU(emojiGroups[j].childNodes[previousRowIndex])) {
|
|
406
|
+
// previous row has six buttons
|
|
407
|
+
// handle focus change here
|
|
408
|
+
var firstFocusEle = emojiButtons[i];
|
|
409
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
410
|
+
var focusEle = emojiButtons[focusIndex -= 6];
|
|
411
|
+
addClass([focusEle], 'e-focus');
|
|
412
|
+
focusEle.focus();
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
else if (isNOU(emojiGroups[j - 1].childNodes[emojiGroups[j - 1]
|
|
416
|
+
.childNodes.length - (previousRowLength - k)])) {
|
|
417
|
+
var firstFocusEle = emojiButtons[i];
|
|
418
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
419
|
+
var focusEle = emojiGroups[j - 1].lastChild;
|
|
420
|
+
addClass([focusEle], 'e-focus');
|
|
421
|
+
focusEle.focus();
|
|
422
|
+
count = 1;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
// previous row has less than six buttons
|
|
427
|
+
// handle focus change here
|
|
428
|
+
var firstFocusEle = emojiButtons[i];
|
|
429
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
430
|
+
var focusEle = emojiGroups[j - 1].childNodes[emojiGroups[j - 1].
|
|
431
|
+
childNodes.length - (previousRowLength - k)];
|
|
432
|
+
addClass([focusEle], 'e-focus');
|
|
433
|
+
focusEle.focus();
|
|
434
|
+
count = 1;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
var firstFocusEle = emojiButtons[i];
|
|
444
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
445
|
+
var focusEle = emojiButtons[focusIndex -= 1];
|
|
446
|
+
var inputELe = this.popupObj.element.querySelector('.e-rte-emoji-search');
|
|
447
|
+
if (isNOU(focusEle) && !isNOU(inputELe)) {
|
|
448
|
+
inputELe.focus();
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
addClass([focusEle], 'e-focus');
|
|
452
|
+
focusEle.focus();
|
|
453
|
+
}
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
else if (e.keyCode === 39) {
|
|
457
|
+
// Move focus to next button in current row
|
|
458
|
+
if (emojiButtons.length !== i + 1) {
|
|
459
|
+
var firstFocusEle = emojiButtons[i];
|
|
460
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
461
|
+
var focusEle = emojiButtons[focusIndex += 1];
|
|
462
|
+
addClass([focusEle], 'e-focus');
|
|
463
|
+
emojiButtons[focusIndex].focus();
|
|
464
|
+
}
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
else if (e.keyCode === 37) {
|
|
468
|
+
// Move focus to previous button in current row
|
|
469
|
+
if (i > 0) {
|
|
470
|
+
var firstFocusEle = emojiButtons[i];
|
|
471
|
+
removeClass([firstFocusEle], 'e-focus');
|
|
472
|
+
var focusEle = emojiButtons[focusIndex -= 1];
|
|
473
|
+
addClass([focusEle], 'e-focus');
|
|
474
|
+
emojiButtons[focusIndex].focus();
|
|
475
|
+
}
|
|
476
|
+
break;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (e.keyCode === 40) {
|
|
482
|
+
var firstFocusEle = this.parent.element.querySelector('.e-focus');
|
|
483
|
+
if (isNOU(firstFocusEle)) {
|
|
484
|
+
var focusEle = emojiButtons[0];
|
|
485
|
+
addClass([focusEle], 'e-focus');
|
|
486
|
+
emojiButtons[0].focus();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
EmojiPicker.prototype.filterKeyHandler = function (e) {
|
|
491
|
+
var emojiButtons = this.parent.element.querySelectorAll('.e-rte-emojisearch-btn button');
|
|
492
|
+
var firstFocusEle = this.parent.element.querySelector('.e-focus');
|
|
493
|
+
if (isNOU(firstFocusEle) && e.keyCode === 40) {
|
|
494
|
+
var focusEle = emojiButtons[0];
|
|
495
|
+
addClass([focusEle], 'e-focus');
|
|
496
|
+
emojiButtons[0].focus();
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
for (var i = 0; i < emojiButtons.length; i++) {
|
|
500
|
+
var focusIndex = i;
|
|
501
|
+
// eslint-disable-next-line
|
|
502
|
+
var childNodes = emojiButtons[i];
|
|
503
|
+
if (childNodes.classList.contains('e-focus')) {
|
|
504
|
+
if (e.keyCode === 38) {
|
|
505
|
+
if (i >= 6) {
|
|
506
|
+
var firstFocusEle_1 = emojiButtons[i];
|
|
507
|
+
removeClass([firstFocusEle_1], 'e-focus');
|
|
508
|
+
var focusEle = emojiButtons[focusIndex -= 6];
|
|
509
|
+
addClass([focusEle], 'e-focus');
|
|
510
|
+
focusEle.focus();
|
|
511
|
+
break;
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
var firstFocusEle_2 = emojiButtons[i];
|
|
515
|
+
removeClass([firstFocusEle_2], 'e-focus');
|
|
516
|
+
var focusEle = emojiButtons[focusIndex -= 1];
|
|
517
|
+
var inputELe = this.popupObj.element.querySelector('.e-rte-emoji-search');
|
|
518
|
+
if (isNOU(focusEle) && !isNOU(inputELe)) {
|
|
519
|
+
inputELe.focus();
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
addClass([focusEle], 'e-focus');
|
|
523
|
+
focusEle.focus();
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
else if (e.keyCode === 40) {
|
|
527
|
+
if (emojiButtons.length - 6 > i) {
|
|
528
|
+
var firstFocusEle_3 = emojiButtons[i];
|
|
529
|
+
removeClass([firstFocusEle_3], 'e-focus');
|
|
530
|
+
var focusEle = emojiButtons[focusIndex += 6];
|
|
531
|
+
addClass([focusEle], 'e-focus');
|
|
532
|
+
focusEle.focus();
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
else if (e.keyCode === 39) {
|
|
537
|
+
if (emojiButtons.length !== i + 1) {
|
|
538
|
+
var firstFocusEle_4 = emojiButtons[i];
|
|
539
|
+
removeClass([firstFocusEle_4], 'e-focus');
|
|
540
|
+
var focusEle = emojiButtons[focusIndex += 1];
|
|
541
|
+
addClass([focusEle], 'e-focus');
|
|
542
|
+
emojiButtons[focusIndex].focus();
|
|
543
|
+
}
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
else if (e.keyCode === 37) {
|
|
547
|
+
if (i > 0) {
|
|
548
|
+
var firstFocusEle_5 = emojiButtons[i];
|
|
549
|
+
removeClass([firstFocusEle_5], 'e-focus');
|
|
550
|
+
var focusEle = emojiButtons[focusIndex -= 1];
|
|
551
|
+
addClass([focusEle], 'e-focus');
|
|
552
|
+
emojiButtons[focusIndex].focus();
|
|
553
|
+
break;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
EmojiPicker.prototype.searchFilter = function (e, value) {
|
|
561
|
+
var inputElement = this.parent.element.querySelector('.e-rte-emoji-search');
|
|
562
|
+
var contentELe = this.parent.element.querySelector('.e-content');
|
|
563
|
+
if (document.activeElement === inputElement || document.activeElement === contentELe) {
|
|
564
|
+
var trimmedStr = void 0;
|
|
565
|
+
if (value !== ':' && !isNOU(value)) {
|
|
566
|
+
trimmedStr = value.replace(/^:/, '');
|
|
567
|
+
}
|
|
568
|
+
else if (!isNOU(value)) {
|
|
569
|
+
trimmedStr = value;
|
|
570
|
+
}
|
|
571
|
+
var inputValue = isNOU(inputElement) ? trimmedStr : inputElement.value;
|
|
572
|
+
var emojiButtons = this.parent.element.querySelectorAll('.e-rte-emojipicker-btn button');
|
|
573
|
+
var emojipickerAll = this.parent.element.querySelector('.e-rte-emojipicker-btn');
|
|
574
|
+
var emojiGroups = this.parent.element.querySelectorAll('.e-rte-emojipicker-group');
|
|
575
|
+
var toolbarGroup = this.parent.element.querySelector('.e-rte-emojipicker-toolbar');
|
|
576
|
+
var excludedDiv_1 = this.parent.element.querySelector('.e-rte-emojisearch-btn');
|
|
577
|
+
var firstChild = this.popDiv.childNodes[0];
|
|
578
|
+
var getComputedStyle_2 = window.getComputedStyle(firstChild);
|
|
579
|
+
var inputHeight = firstChild.nodeName === 'SPAN' ? (firstChild.getBoundingClientRect().height + parseFloat(getComputedStyle_2.marginTop) +
|
|
580
|
+
parseFloat(getComputedStyle_2.marginBottom)) : 0;
|
|
581
|
+
var popupBorder = window.getComputedStyle(this.popDiv);
|
|
582
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
583
|
+
var filteredButtons = isNOU(excludedDiv_1) ? emojiButtons :
|
|
584
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
585
|
+
Array.from(emojiButtons).filter(function (button) { return !excludedDiv_1.contains(button); });
|
|
586
|
+
if (inputValue === '' || value === ':') {
|
|
587
|
+
toolbarGroup.style.display = '';
|
|
588
|
+
emojipickerAll.style.height = (this.popDiv.getBoundingClientRect().height - toolbarGroup.getBoundingClientRect().height - inputHeight - (2 * parseFloat(popupBorder.borderWidth))) + 'px';
|
|
589
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
590
|
+
emojiGroups.forEach(function (element) {
|
|
591
|
+
element.style.display = '';
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
596
|
+
emojiGroups.forEach(function (element) {
|
|
597
|
+
element.style.display = 'none';
|
|
598
|
+
});
|
|
599
|
+
toolbarGroup.style.display = 'none';
|
|
600
|
+
emojipickerAll.style.height = (this.popDiv.getBoundingClientRect().height - inputHeight - (2 * parseFloat(popupBorder.borderWidth))) + 'px';
|
|
601
|
+
}
|
|
602
|
+
var emojiBtnDiv = this.parent.createElement('div', { className: 'e-rte-emojisearch-btn' });
|
|
603
|
+
var emojis = this.parent.element.querySelector('.e-rte-emojisearch-btn');
|
|
604
|
+
if (emojis) {
|
|
605
|
+
emojis.remove();
|
|
606
|
+
}
|
|
607
|
+
var noEmojiObj = this.parent.createElement('div', { className: 'e-rte-emojiSearch-noEmoji' });
|
|
608
|
+
var noEMoji = true;
|
|
609
|
+
for (var i = 0; i < filteredButtons.length; i++) {
|
|
610
|
+
if (!isNOU(filteredButtons[i].getAttribute('title'))) {
|
|
611
|
+
var title = filteredButtons[i].getAttribute('title').toLowerCase();
|
|
612
|
+
var titleLength = title.split(' ');
|
|
613
|
+
for (var j = 0; j < titleLength.length; j++) {
|
|
614
|
+
if (titleLength[j].startsWith(inputValue.toLowerCase()) && inputValue !== '') {
|
|
615
|
+
var emoji = filteredButtons[i].cloneNode(true);
|
|
616
|
+
emojiBtnDiv.appendChild(emoji);
|
|
617
|
+
noEMoji = false;
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (noEMoji && !this.parent.element.querySelector('.e-rte-emojiSearch-noEmoji') && (inputValue !== '' && value !== ':')) {
|
|
624
|
+
noEmojiObj.innerHTML = '<span style="color: rgba(0, 0, 0, 0.75); font-weight: 500; font-size: 16px;">' + this.i10n.getConstant('emojiPickerNoResultFound') + ' 😥 </span>' + '<br>' + '<span style="color: rgba(0, 0, 0, 0.75);"> ' + this.i10n.getConstant('emojiPickerTrySomethingElse') + ' ? </span>';
|
|
625
|
+
noEmojiObj.style.margin = '55px';
|
|
626
|
+
emojipickerAll.appendChild(noEmojiObj);
|
|
627
|
+
}
|
|
628
|
+
else if (!noEMoji && this.parent.element.querySelector('.e-rte-emojiSearch-noEmoji') || (inputValue === '' && value === ':')) {
|
|
629
|
+
emojipickerAll.removeChild(this.parent.element.querySelector('.e-rte-emojiSearch-noEmoji'));
|
|
630
|
+
}
|
|
631
|
+
emojipickerAll.appendChild(emojiBtnDiv);
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
EmojiPicker.prototype.emojiBtnClick = function (e) {
|
|
638
|
+
var event = new MouseEvent('mouseleave', { bubbles: true, cancelable: true });
|
|
639
|
+
// Includes the emote button element tooltip and toolbar tooltip
|
|
640
|
+
var emotePickerTooltips = this.parent.element.querySelectorAll('.e-rte-emojipicker-popup [data-tooltip-id]');
|
|
641
|
+
for (var i = 0; i < emotePickerTooltips.length; i++) {
|
|
642
|
+
emotePickerTooltips[i].dispatchEvent(event);
|
|
643
|
+
}
|
|
644
|
+
var targetEle = e.target;
|
|
645
|
+
if (targetEle.tagName !== 'BUTTON') {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
targetEle.focus();
|
|
649
|
+
if (!isNOU(this.clickEvent)) {
|
|
650
|
+
this.save.restore();
|
|
651
|
+
}
|
|
652
|
+
if (this.popupObj) {
|
|
653
|
+
removeClass([this.divElement], 'e-active');
|
|
654
|
+
this.popupObj.hide();
|
|
655
|
+
}
|
|
656
|
+
var originalEvent = e;
|
|
657
|
+
this.parent.formatter.process(this.parent, {
|
|
658
|
+
item: {
|
|
659
|
+
'command': 'EmojiPicker',
|
|
660
|
+
'subCommand': 'EmojiPicker',
|
|
661
|
+
value: targetEle.innerHTML
|
|
662
|
+
}
|
|
663
|
+
}, e, originalEvent);
|
|
664
|
+
};
|
|
665
|
+
EmojiPicker.prototype.onkeyPress = function (e) {
|
|
666
|
+
var originalEvent = e.args;
|
|
667
|
+
var selection = window.getSelection();
|
|
668
|
+
if (selection.rangeCount <= 0) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
var range = selection.getRangeAt(0);
|
|
672
|
+
var cursorPos = range.startOffset;
|
|
673
|
+
var prevChar = selection.focusNode.textContent.substring(cursorPos - 1, cursorPos);
|
|
674
|
+
var isPrevSpace = /\s/.test(prevChar);
|
|
675
|
+
var isPrevColon = selection.focusNode.textContent.substring(cursorPos - 1, cursorPos) === ':';
|
|
676
|
+
var colon = selection.focusNode.textContent.charAt(cursorPos - 1) === ':';
|
|
677
|
+
if (originalEvent.keyCode === 186 && originalEvent.shiftKey && (isPrevSpace || selection.focusOffset === 0)) {
|
|
678
|
+
var coordinates = this.getCoordinates();
|
|
679
|
+
this.parent.showEmojiPicker(coordinates.left, coordinates.top);
|
|
680
|
+
}
|
|
681
|
+
if (originalEvent.keyCode === 8 && colon && this.popupObj) {
|
|
682
|
+
removeClass([this.divElement], 'e-active');
|
|
683
|
+
this.popupObj.hide();
|
|
684
|
+
}
|
|
685
|
+
if (originalEvent.keyCode === 32 && isPrevColon && this.popupObj) {
|
|
686
|
+
removeClass([this.divElement], 'e-active');
|
|
687
|
+
this.popupObj.hide();
|
|
688
|
+
}
|
|
689
|
+
if (this.popupObj && (originalEvent.keyCode === 37 || originalEvent.keyCode === 38 || originalEvent.keyCode === 39
|
|
690
|
+
|| originalEvent.keyCode === 27 || originalEvent.keyCode === 40)) {
|
|
691
|
+
this.onKeyDown(originalEvent);
|
|
692
|
+
originalEvent.preventDefault();
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
EmojiPicker.prototype.onkeyUp = function (e) {
|
|
696
|
+
var originalEvent = e.args;
|
|
697
|
+
var selection = window.getSelection();
|
|
698
|
+
var range = selection.getRangeAt(0);
|
|
699
|
+
var cursorPos = range.startOffset;
|
|
700
|
+
// eslint-disable-next-line
|
|
701
|
+
var selectedValue;
|
|
702
|
+
var count = 0;
|
|
703
|
+
for (var i = cursorPos - 1; i >= cursorPos - 15; i--) {
|
|
704
|
+
var prevChar = selection.focusNode.textContent.substring(i - 1, i);
|
|
705
|
+
var isPrevSpace = /:$/.test(prevChar);
|
|
706
|
+
if (isPrevSpace && !isNOU(this.popDiv) && count === 0) {
|
|
707
|
+
selectedValue = range.startContainer.textContent.substring(i - 1, cursorPos);
|
|
708
|
+
this.searchFilter(originalEvent, selectedValue);
|
|
709
|
+
count = 1;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
var colon = selection.focusNode.textContent.substring(cursorPos - 1, cursorPos);
|
|
713
|
+
if (colon === ':' && !isNOU(this.popupObj)) {
|
|
714
|
+
selectedValue = colon;
|
|
715
|
+
this.searchFilter(originalEvent, selectedValue);
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
EmojiPicker.prototype.getCoordinates = function () {
|
|
719
|
+
var coordinates;
|
|
720
|
+
var selection = window.getSelection();
|
|
721
|
+
var range = selection.getRangeAt(0);
|
|
722
|
+
var firstChild;
|
|
723
|
+
if (range.startContainer.nodeName === 'P' || range.startContainer.nodeName === 'DIV') {
|
|
724
|
+
if (range.startContainer.childNodes[0].nodeName !== '#text') {
|
|
725
|
+
firstChild = range.startContainer.childNodes[0];
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
// eslint-disable-next-line
|
|
729
|
+
var rect = isNOU(firstChild) ? range.getBoundingClientRect() : firstChild.getBoundingClientRect();
|
|
730
|
+
var rteContent = this.parent.element.querySelector('.e-rte-content');
|
|
731
|
+
var rteEle = this.parent.element;
|
|
732
|
+
var toolbarHeight = rteEle.offsetHeight - rteContent.offsetHeight;
|
|
733
|
+
var cursorTop = rect.top - this.parent.inputElement.getBoundingClientRect().top;
|
|
734
|
+
var cursorLeft = rect.left - this.parent.inputElement.getBoundingClientRect().left;
|
|
735
|
+
var screenHeight = window.innerHeight;
|
|
736
|
+
var popupHeight = 330;
|
|
737
|
+
var popupTop = cursorTop;
|
|
738
|
+
var popupLeft = cursorLeft + rect.width;
|
|
739
|
+
if (rteEle.getBoundingClientRect().top < 0) {
|
|
740
|
+
popupTop = popupTop + rteContent.getBoundingClientRect().top - toolbarHeight;
|
|
741
|
+
}
|
|
742
|
+
if (rect.top < popupHeight) {
|
|
743
|
+
// eslint-disable-next-line
|
|
744
|
+
popupTop = popupTop;
|
|
745
|
+
}
|
|
746
|
+
else if (rect.top + popupHeight > screenHeight) {
|
|
747
|
+
popupTop -= popupHeight + 20;
|
|
748
|
+
}
|
|
749
|
+
if (this.parent.inputElement) {
|
|
750
|
+
coordinates = {
|
|
751
|
+
top: popupTop + 60,
|
|
752
|
+
left: popupLeft + 8
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
return coordinates;
|
|
756
|
+
};
|
|
757
|
+
EmojiPicker.prototype.removeEventListener = function () {
|
|
758
|
+
if (this.parent.isDestroyed) {
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
this.parent.off(events.emojiPicker, this.toolbarClick);
|
|
762
|
+
this.parent.off(events.docClick, this.docClick);
|
|
763
|
+
this.parent.off(events.keyDown, this.onkeyPress);
|
|
764
|
+
this.parent.off(events.keyUp, this.onkeyUp);
|
|
765
|
+
this.parent.off(events.contentscroll, this.contentscroll);
|
|
766
|
+
this.parent.off(events.scroll, this.contentscroll);
|
|
767
|
+
};
|
|
768
|
+
/**
|
|
769
|
+
* For internal use only - Get the module name.
|
|
770
|
+
*
|
|
771
|
+
* @returns {string} - returns the string value
|
|
772
|
+
*/
|
|
773
|
+
EmojiPicker.prototype.getModuleName = function () {
|
|
774
|
+
return 'emojiPicker';
|
|
775
|
+
};
|
|
776
|
+
return EmojiPicker;
|
|
777
|
+
}());
|
|
778
|
+
export { EmojiPicker };
|