@syncfusion/ej2-richtexteditor 20.2.50 → 20.3.47

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.
Files changed (150) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/ej2-richtexteditor.min.js +10 -0
  3. package/dist/ej2-richtexteditor.umd.min.js +2 -2
  4. package/dist/ej2-richtexteditor.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-richtexteditor.es2015.js +3799 -402
  6. package/dist/es6/ej2-richtexteditor.es2015.js.map +1 -1
  7. package/dist/es6/ej2-richtexteditor.es5.js +3759 -333
  8. package/dist/es6/ej2-richtexteditor.es5.js.map +1 -1
  9. package/dist/global/ej2-richtexteditor.min.js +2 -2
  10. package/dist/global/ej2-richtexteditor.min.js.map +1 -1
  11. package/dist/global/index.d.ts +1 -1
  12. package/package.json +13 -13
  13. package/src/common/config.js +2 -0
  14. package/src/common/types.d.ts +4 -0
  15. package/src/editor-manager/base/classes.d.ts +16 -0
  16. package/src/editor-manager/base/classes.js +16 -0
  17. package/src/editor-manager/base/constant.d.ts +2 -0
  18. package/src/editor-manager/base/constant.js +2 -0
  19. package/src/editor-manager/base/editor-manager.d.ts +4 -0
  20. package/src/editor-manager/base/editor-manager.js +14 -0
  21. package/src/editor-manager/base/interface.d.ts +2 -0
  22. package/src/editor-manager/plugin/audio.d.ts +32 -0
  23. package/src/editor-manager/plugin/audio.js +133 -0
  24. package/src/editor-manager/plugin/dom-node.js +1 -1
  25. package/src/editor-manager/plugin/image.js +1 -1
  26. package/src/editor-manager/plugin/inserthtml.js +1 -1
  27. package/src/editor-manager/plugin/lists.js +10 -8
  28. package/src/editor-manager/plugin/ms-word-clean-up.js +18 -18
  29. package/src/editor-manager/plugin/nodecutter.d.ts +1 -1
  30. package/src/editor-manager/plugin/nodecutter.js +7 -5
  31. package/src/editor-manager/plugin/selection-commands.js +3 -2
  32. package/src/editor-manager/plugin/table.js +3 -2
  33. package/src/editor-manager/plugin/undo.js +2 -1
  34. package/src/editor-manager/plugin/video.d.ts +34 -0
  35. package/src/editor-manager/plugin/video.js +249 -0
  36. package/src/editor-manager/plugin.d.ts +2 -0
  37. package/src/editor-manager/plugin.js +2 -0
  38. package/src/global.js +1 -1
  39. package/src/rich-text-editor/actions/base-quick-toolbar.js +3 -1
  40. package/src/rich-text-editor/actions/base-toolbar.js +1 -1
  41. package/src/rich-text-editor/actions/dropdown-buttons.d.ts +2 -2
  42. package/src/rich-text-editor/actions/dropdown-buttons.js +14 -11
  43. package/src/rich-text-editor/actions/enter-key.d.ts +1 -0
  44. package/src/rich-text-editor/actions/enter-key.js +157 -103
  45. package/src/rich-text-editor/actions/html-editor.d.ts +1 -1
  46. package/src/rich-text-editor/actions/html-editor.js +57 -9
  47. package/src/rich-text-editor/actions/paste-clean-up.js +2 -1
  48. package/src/rich-text-editor/actions/quick-toolbar.d.ts +2 -0
  49. package/src/rich-text-editor/actions/quick-toolbar.js +52 -6
  50. package/src/rich-text-editor/actions/resize.js +11 -1
  51. package/src/rich-text-editor/actions/toolbar-action.js +2 -1
  52. package/src/rich-text-editor/actions/xhtml-validation.js +1 -1
  53. package/src/rich-text-editor/audio.d.ts +4 -0
  54. package/src/rich-text-editor/audio.js +4 -0
  55. package/src/rich-text-editor/base/classes.d.ts +50 -0
  56. package/src/rich-text-editor/base/classes.js +50 -0
  57. package/src/rich-text-editor/base/constant.d.ts +69 -14
  58. package/src/rich-text-editor/base/constant.js +71 -16
  59. package/src/rich-text-editor/base/enum.d.ts +10 -2
  60. package/src/rich-text-editor/base/enum.js +10 -2
  61. package/src/rich-text-editor/base/interface.d.ts +86 -2
  62. package/src/rich-text-editor/base/interface.js +8 -0
  63. package/src/rich-text-editor/base/rich-text-editor-model.d.ts +130 -29
  64. package/src/rich-text-editor/base/rich-text-editor.d.ts +150 -30
  65. package/src/rich-text-editor/base/rich-text-editor.js +196 -6
  66. package/src/rich-text-editor/formatter/formatter.js +7 -2
  67. package/src/rich-text-editor/models/default-locale.js +46 -4
  68. package/src/rich-text-editor/models/items.d.ts +3 -0
  69. package/src/rich-text-editor/models/items.js +100 -3
  70. package/src/rich-text-editor/models/toolbar-settings-model.d.ts +169 -1
  71. package/src/rich-text-editor/models/toolbar-settings.d.ts +143 -1
  72. package/src/rich-text-editor/models/toolbar-settings.js +88 -0
  73. package/src/rich-text-editor/renderer/audio-module.d.ts +76 -0
  74. package/src/rich-text-editor/renderer/audio-module.js +875 -0
  75. package/src/rich-text-editor/renderer/iframe-content-renderer.js +1 -1
  76. package/src/rich-text-editor/renderer/image-module.js +9 -6
  77. package/src/rich-text-editor/renderer/link-module.js +2 -1
  78. package/src/rich-text-editor/renderer/table-module.d.ts +2 -0
  79. package/src/rich-text-editor/renderer/table-module.js +32 -7
  80. package/src/rich-text-editor/renderer/video-module.d.ts +105 -0
  81. package/src/rich-text-editor/renderer/video-module.js +1422 -0
  82. package/src/rich-text-editor/renderer/view-source.js +1 -0
  83. package/src/rich-text-editor/renderer.d.ts +2 -0
  84. package/src/rich-text-editor/renderer.js +2 -0
  85. package/src/rich-text-editor/video.d.ts +4 -0
  86. package/src/rich-text-editor/video.js +4 -0
  87. package/styles/_all.scss +1 -2
  88. package/styles/bootstrap-dark.css +220 -70
  89. package/styles/bootstrap.css +220 -70
  90. package/styles/bootstrap4.css +220 -70
  91. package/styles/bootstrap5-dark.css +220 -70
  92. package/styles/bootstrap5.css +220 -70
  93. package/styles/fabric-dark.css +220 -70
  94. package/styles/fabric.css +222 -72
  95. package/styles/fluent-dark.css +222 -72
  96. package/styles/fluent.css +222 -72
  97. package/styles/highcontrast-light.css +222 -72
  98. package/styles/highcontrast.css +222 -72
  99. package/styles/material-dark.css +220 -70
  100. package/styles/material.css +220 -70
  101. package/styles/rich-text-editor/_all.scss +1 -1
  102. package/styles/rich-text-editor/_bootstrap-dark-definition.scss +3 -0
  103. package/styles/rich-text-editor/_bootstrap-definition.scss +2 -1
  104. package/styles/rich-text-editor/_bootstrap4-definition.scss +5 -3
  105. package/styles/rich-text-editor/_bootstrap5-definition.scss +8 -3
  106. package/styles/rich-text-editor/_fabric-dark-definition.scss +3 -0
  107. package/styles/rich-text-editor/_fabric-definition.scss +2 -0
  108. package/styles/rich-text-editor/_fluent-definition.scss +8 -3
  109. package/styles/rich-text-editor/_fusionnew-definition.scss +8 -3
  110. package/styles/rich-text-editor/_highcontrast-definition.scss +2 -0
  111. package/styles/rich-text-editor/_highcontrast-light-definition.scss +2 -0
  112. package/styles/rich-text-editor/_layout.scss +116 -74
  113. package/styles/rich-text-editor/_material-dark-definition.scss +3 -0
  114. package/styles/rich-text-editor/_material-definition.scss +2 -0
  115. package/styles/rich-text-editor/_material3-definition.scss +8 -3
  116. package/styles/rich-text-editor/_tailwind-definition.scss +7 -2
  117. package/styles/rich-text-editor/_theme.scss +74 -15
  118. package/styles/rich-text-editor/bootstrap-dark.css +220 -70
  119. package/styles/rich-text-editor/bootstrap.css +220 -70
  120. package/styles/rich-text-editor/bootstrap4.css +220 -70
  121. package/styles/rich-text-editor/bootstrap5-dark.css +220 -70
  122. package/styles/rich-text-editor/bootstrap5.css +220 -70
  123. package/styles/rich-text-editor/fabric-dark.css +220 -70
  124. package/styles/rich-text-editor/fabric.css +222 -72
  125. package/styles/rich-text-editor/fluent-dark.css +222 -72
  126. package/styles/rich-text-editor/fluent.css +222 -72
  127. package/styles/rich-text-editor/highcontrast-light.css +222 -72
  128. package/styles/rich-text-editor/highcontrast.css +222 -72
  129. package/styles/rich-text-editor/icons/_bootstrap-dark.scss +20 -4
  130. package/styles/rich-text-editor/icons/_bootstrap.scss +20 -4
  131. package/styles/rich-text-editor/icons/_bootstrap4.scss +20 -4
  132. package/styles/rich-text-editor/icons/_bootstrap5.scss +20 -4
  133. package/styles/rich-text-editor/icons/_fabric-dark.scss +20 -4
  134. package/styles/rich-text-editor/icons/_fabric.scss +20 -4
  135. package/styles/rich-text-editor/icons/_fluent.scss +20 -4
  136. package/styles/rich-text-editor/icons/_fusionnew.scss +20 -4
  137. package/styles/rich-text-editor/icons/_highcontrast-light.scss +20 -4
  138. package/styles/rich-text-editor/icons/_highcontrast.scss +20 -4
  139. package/styles/rich-text-editor/icons/_material-dark.scss +20 -4
  140. package/styles/rich-text-editor/icons/_material.scss +20 -4
  141. package/styles/rich-text-editor/icons/_material3.scss +20 -4
  142. package/styles/rich-text-editor/icons/_tailwind.scss +20 -4
  143. package/styles/rich-text-editor/material-dark.css +220 -70
  144. package/styles/rich-text-editor/material.css +220 -70
  145. package/styles/rich-text-editor/tailwind-dark.css +220 -70
  146. package/styles/rich-text-editor/tailwind.css +220 -70
  147. package/styles/tailwind-dark.css +220 -70
  148. package/styles/tailwind.css +220 -70
  149. package/.eslintrc.json +0 -244
  150. package/tslint.json +0 -111
@@ -0,0 +1,1422 @@
1
+ import { addClass, detach, EventHandler, isNullOrUndefined, Ajax, formatUnit } from '@syncfusion/ej2-base';
2
+ import { Browser, closest, removeClass, isNullOrUndefined as isNOU } from '@syncfusion/ej2-base';
3
+ import * as events from '../base/constant';
4
+ import * as classes from '../base/classes';
5
+ import { Uploader, TextBox } from '@syncfusion/ej2-inputs';
6
+ import { Button, RadioButton } from '@syncfusion/ej2-buttons';
7
+ import { RenderType } from '../base/enum';
8
+ import { dispatchEvent, parseHtml, hasClass, convertToBlob } from '../base/util';
9
+ import { isIDevice } from '../../common/util';
10
+ var Video = /** @class */ (function () {
11
+ function Video(parent, serviceLocator) {
12
+ this.isVideoUploaded = false;
13
+ this.isAllowedTypes = true;
14
+ this.pageX = null;
15
+ this.pageY = null;
16
+ this.deletedVid = [];
17
+ this.parent = parent;
18
+ this.rteID = parent.element.id;
19
+ this.i10n = serviceLocator.getService('rteLocale');
20
+ this.rendererFactory = serviceLocator.getService('rendererFactory');
21
+ this.dialogRenderObj = serviceLocator.getService('dialogRenderObject');
22
+ this.addEventListener();
23
+ }
24
+ Video.prototype.addEventListener = function () {
25
+ if (this.parent.isDestroyed) {
26
+ return;
27
+ }
28
+ this.parent.on(events.keyDown, this.onKeyDown, this);
29
+ this.parent.on(events.keyUp, this.onKeyUp, this);
30
+ this.parent.on(events.insertVideo, this.insertingVideo, this);
31
+ this.parent.on(events.initialEnd, this.afterRender, this);
32
+ this.parent.on(events.dynamicModule, this.afterRender, this);
33
+ this.parent.on(events.windowResize, this.onWindowResize, this);
34
+ this.parent.on(events.showVideoDialog, this.showDialog, this);
35
+ this.parent.on(events.closeVideoDialog, this.closeDialog, this);
36
+ this.parent.on(events.dropDownSelect, this.alignmentSelect, this);
37
+ this.parent.on(events.videoDelete, this.deleteVideo, this);
38
+ this.parent.on(events.videoToolbarAction, this.onToolbarAction, this);
39
+ this.parent.on(events.editAreaClick, this.editAreaClickHandler, this);
40
+ this.parent.on(events.iframeMouseDown, this.onIframeMouseDown, this);
41
+ this.parent.on(events.videoSize, this.videoSize, this);
42
+ this.parent.on(events.insertCompleted, this.showVideoQuickToolbar, this);
43
+ this.parent.on(events.clearDialogObj, this.clearDialogObj, this);
44
+ this.parent.on(events.destroy, this.removeEventListener, this);
45
+ };
46
+ Video.prototype.removeEventListener = function () {
47
+ if (this.parent.isDestroyed) {
48
+ return;
49
+ }
50
+ this.parent.off(events.keyDown, this.onKeyDown);
51
+ this.parent.off(events.keyUp, this.onKeyUp);
52
+ this.parent.off(events.insertVideo, this.insertingVideo);
53
+ this.parent.off(events.windowResize, this.onWindowResize);
54
+ this.parent.off(events.initialEnd, this.afterRender);
55
+ this.parent.off(events.dynamicModule, this.afterRender);
56
+ this.parent.off(events.showVideoDialog, this.showDialog);
57
+ this.parent.off(events.closeVideoDialog, this.closeDialog);
58
+ this.parent.off(events.dropDownSelect, this.alignmentSelect);
59
+ this.parent.off(events.videoDelete, this.deleteVideo);
60
+ this.parent.off(events.videoToolbarAction, this.onToolbarAction);
61
+ this.parent.off(events.editAreaClick, this.editAreaClickHandler);
62
+ this.parent.off(events.iframeMouseDown, this.onIframeMouseDown);
63
+ this.parent.off(events.videoSize, this.videoSize);
64
+ this.parent.off(events.insertCompleted, this.showVideoQuickToolbar);
65
+ this.parent.off(events.clearDialogObj, this.clearDialogObj);
66
+ this.parent.off(events.destroy, this.removeEventListener);
67
+ if (!isNullOrUndefined(this.contentModule)) {
68
+ EventHandler.remove(this.contentModule.getEditPanel(), Browser.touchEndEvent, this.videoClick);
69
+ this.parent.formatter.editorManager.observer.off(events.checkUndo, this.undoStack);
70
+ if (this.parent.insertVideoSettings.resize) {
71
+ EventHandler.remove(this.parent.contentModule.getEditPanel(), Browser.touchStartEvent, this.resizeStart);
72
+ EventHandler.remove(this.parent.element.ownerDocument, 'mousedown', this.onDocumentClick);
73
+ EventHandler.remove(this.contentModule.getEditPanel(), 'cut', this.onCutHandler);
74
+ }
75
+ }
76
+ };
77
+ Video.prototype.afterRender = function () {
78
+ this.contentModule = this.rendererFactory.getRenderer(RenderType.Content);
79
+ EventHandler.add(this.contentModule.getEditPanel(), Browser.touchEndEvent, this.videoClick, this);
80
+ if (this.parent.insertVideoSettings.resize) {
81
+ EventHandler.add(this.parent.contentModule.getEditPanel(), Browser.touchStartEvent, this.resizeStart, this);
82
+ EventHandler.add(this.parent.element.ownerDocument, 'mousedown', this.onDocumentClick, this);
83
+ EventHandler.add(this.contentModule.getEditPanel(), 'cut', this.onCutHandler, this);
84
+ }
85
+ };
86
+ Video.prototype.clearDialogObj = function () {
87
+ if (this.dialogObj) {
88
+ this.dialogObj.destroy();
89
+ detach(this.dialogObj.element);
90
+ this.dialogObj = null;
91
+ }
92
+ };
93
+ // eslint-disable-next-line
94
+ Video.prototype.onKeyUp = function (event) {
95
+ if (!isNOU(this.deletedVid) && this.deletedVid.length > 0) {
96
+ for (var i = 0; i < this.deletedVid.length; i++) {
97
+ var args = {
98
+ element: this.deletedVid[i],
99
+ src: this.deletedVid[i].tagName !== 'IFRAME' ? this.deletedVid[i].querySelector('source').getAttribute('src') :
100
+ this.deletedVid[i].src
101
+ };
102
+ this.parent.trigger(events.afterMediaDelete, args);
103
+ }
104
+ }
105
+ };
106
+ Video.prototype.undoStack = function (args) {
107
+ if (args.subCommand.toLowerCase() === 'undo' || args.subCommand.toLowerCase() === 'redo') {
108
+ for (var i = 0; i < this.parent.formatter.getUndoRedoStack().length; i++) {
109
+ var temp = this.parent.createElement('div');
110
+ var contentElem = parseHtml(this.parent.formatter.getUndoRedoStack()[i].text);
111
+ temp.appendChild(contentElem);
112
+ var vid = temp.querySelectorAll('video');
113
+ if (temp.querySelector('.e-vid-resize') && vid.length > 0) {
114
+ for (var j = 0; j < vid.length; j++) {
115
+ vid[j].style.outline = '';
116
+ }
117
+ detach(temp.querySelector('.e-vid-resize'));
118
+ this.parent.formatter.getUndoRedoStack()[i].text = temp.innerHTML;
119
+ }
120
+ }
121
+ }
122
+ };
123
+ Video.prototype.onIframeMouseDown = function () {
124
+ if (this.dialogObj) {
125
+ this.dialogObj.hide({ returnValue: true });
126
+ }
127
+ };
128
+ Video.prototype.videoSize = function (e) {
129
+ var _this = this;
130
+ if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
131
+ return;
132
+ }
133
+ this.insertVideo(e);
134
+ if (!isNullOrUndefined(this.dialogObj)) {
135
+ var vidSizeHeader = this.i10n.getConstant('videoSizeHeader');
136
+ var linkUpdate = this.i10n.getConstant('dialogUpdate');
137
+ var dialogContent = this.vidsizeInput(e);
138
+ var selectObj_1 = { args: e.args, selfVideo: this, selection: e.selection, selectNode: e.selectNode };
139
+ this.dialogObj.setProperties({
140
+ height: 'inherit', width: '290px', header: vidSizeHeader, content: dialogContent, position: { X: 'center', Y: 'center' },
141
+ buttons: [{
142
+ // eslint-disable-next-line
143
+ click: function (e) {
144
+ _this.insertSize(selectObj_1);
145
+ },
146
+ buttonModel: {
147
+ content: linkUpdate, cssClass: 'e-flat e-update-size', isPrimary: true
148
+ }
149
+ }]
150
+ });
151
+ this.dialogObj.element.style.maxHeight = 'inherit';
152
+ this.dialogObj.content.querySelector('input').focus();
153
+ }
154
+ };
155
+ Video.prototype.vidsizeInput = function (e) {
156
+ var _this = this;
157
+ var selectNode = e.selectNode[0];
158
+ var vidHeight = this.i10n.getConstant('videoHeight');
159
+ var vidWidth = this.i10n.getConstant('videoWidth');
160
+ var vidSizeWrap = this.parent.createElement('div', { className: 'e-video-sizewrap' });
161
+ var widthVal = isNullOrUndefined(this.changedWidthValue) && (selectNode.style.width.toString() === 'auto' ||
162
+ selectNode.style.width !== '') ? selectNode.style.width : !isNullOrUndefined(this.changedWidthValue) ?
163
+ this.changedWidthValue : (parseInt(selectNode.getClientRects()[0].width.toString(), 10)).toString();
164
+ var heightVal = isNullOrUndefined(this.changedHeightValue) && (selectNode.style.height.toString() === 'auto' ||
165
+ selectNode.style.height !== '') ? selectNode.style.height : !isNullOrUndefined(this.changedHeightValue) ?
166
+ this.changedHeightValue : (parseInt(selectNode.getClientRects()[0].height.toString(), 10)).toString();
167
+ this.changedWidthValue = null;
168
+ this.changedHeightValue = null;
169
+ var content = '<div class="e-rte-label"><label>' + vidWidth +
170
+ '</label></div><div class="e-rte-field"><input type="text" id="vidwidth" class="e-vid-width" value=' +
171
+ widthVal
172
+ + ' /></div>' +
173
+ '<div class="e-rte-label">' + '<label>' + vidHeight + '</label></div><div class="e-rte-field"> ' +
174
+ '<input type="text" id="vidheight" class="e-vid-height" value=' +
175
+ heightVal
176
+ + ' /></div>';
177
+ var contentElem = parseHtml(content);
178
+ vidSizeWrap.appendChild(contentElem);
179
+ var widthNum = new TextBox({
180
+ value: formatUnit(widthVal),
181
+ enableRtl: this.parent.enableRtl,
182
+ input: function (e) {
183
+ _this.inputWidthValue = formatUnit((e.value));
184
+ }
185
+ });
186
+ widthNum.createElement = this.parent.createElement;
187
+ widthNum.appendTo(vidSizeWrap.querySelector('#vidwidth'));
188
+ var heightNum = new TextBox({
189
+ value: formatUnit(heightVal),
190
+ enableRtl: this.parent.enableRtl,
191
+ input: function (e) {
192
+ _this.inputHeightValue = formatUnit((e.value));
193
+ }
194
+ });
195
+ heightNum.createElement = this.parent.createElement;
196
+ heightNum.appendTo(vidSizeWrap.querySelector('#vidheight'));
197
+ return vidSizeWrap;
198
+ };
199
+ Video.prototype.insertSize = function (e) {
200
+ e.selection.restore();
201
+ var proxy = e.selfVideo;
202
+ if (proxy.parent.formatter.getUndoRedoStack().length === 0) {
203
+ proxy.parent.formatter.saveData();
204
+ }
205
+ var dialogEle = proxy.dialogObj.element;
206
+ this.changedWidthValue = this.inputWidthValue;
207
+ this.changedHeightValue = this.inputHeightValue;
208
+ var width = dialogEle.querySelector('.e-vid-width').value;
209
+ var height = dialogEle.parentElement.querySelector('.e-vid-height').value;
210
+ proxy.parent.formatter.process(this.parent, e.args, e.args, {
211
+ width: width, height: height, selectNode: e.selectNode,
212
+ subCommand: e.args.item.subCommand
213
+ });
214
+ if (this.vidResizeDiv) {
215
+ e.selectNode[0] = (e.selectNode[0].tagName === 'VIDEO' || e.selectNode[0].tagName === 'IFRAME') ?
216
+ e.selectNode[0] : e.selectNode[0].querySelector('iframe');
217
+ proxy.vidResizePos(e.selectNode[0], this.vidResizeDiv);
218
+ }
219
+ proxy.dialogObj.hide({ returnValue: true });
220
+ };
221
+ Video.prototype.resizeEnd = function (e) {
222
+ this.resizeBtnInit();
223
+ this.videoEle.parentElement.style.cursor = 'auto';
224
+ if (Browser.isDevice) {
225
+ removeClass([e.target.parentElement], 'e-mob-span');
226
+ }
227
+ var args = { event: e, requestType: 'videos' };
228
+ this.parent.trigger(events.resizeStop, args);
229
+ /* eslint-disable */
230
+ var pageX = this.getPointX(e);
231
+ var pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset +
232
+ this.parent.element.getBoundingClientRect().top + e.clientY : e.pageY;
233
+ /* eslint-enable */
234
+ this.parent.formatter.editorManager.observer.on(events.checkUndo, this.undoStack, this);
235
+ this.parent.formatter.saveData();
236
+ };
237
+ Video.prototype.resizeStart = function (e, ele) {
238
+ var _this = this;
239
+ if (this.parent.readonly) {
240
+ return;
241
+ }
242
+ var target = ele ? ele : !this.isEmbedVidElem(e.target) ? e.target : e.target.querySelector('iframe');
243
+ this.prevSelectedVidEle = this.videoEle;
244
+ if (target.tagName === 'VIDEO' || target.tagName === 'IFRAME') {
245
+ this.parent.preventDefaultResize(e);
246
+ var videoElem = target;
247
+ if (this.vidResizeDiv && this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
248
+ detach(this.vidResizeDiv);
249
+ }
250
+ this.videoResize(videoElem);
251
+ }
252
+ if (target.classList.contains('e-rte-videoboxmark')) {
253
+ if (this.parent.formatter.getUndoRedoStack().length === 0) {
254
+ this.parent.formatter.saveData();
255
+ }
256
+ this.pageX = this.getPointX(e);
257
+ this.pageY = this.getPointY(e);
258
+ e.preventDefault();
259
+ e.stopImmediatePropagation();
260
+ this.resizeBtnInit();
261
+ if (this.quickToolObj) {
262
+ this.quickToolObj.videoQTBar.hidePopup();
263
+ }
264
+ if (target.classList.contains('e-rte-topLeft')) {
265
+ this.resizeBtnStat.topLeft = true;
266
+ }
267
+ if (target.classList.contains('e-rte-topRight')) {
268
+ this.resizeBtnStat.topRight = true;
269
+ }
270
+ if (target.classList.contains('e-rte-botLeft')) {
271
+ this.resizeBtnStat.botLeft = true;
272
+ }
273
+ if (target.classList.contains('e-rte-botRight')) {
274
+ this.resizeBtnStat.botRight = true;
275
+ }
276
+ if (Browser.isDevice && this.contentModule.getEditPanel().contains(this.vidResizeDiv) &&
277
+ !this.vidResizeDiv.classList.contains('e-mob-span')) {
278
+ addClass([this.vidResizeDiv], 'e-mob-span');
279
+ }
280
+ else {
281
+ var args = { event: e, requestType: 'videos' };
282
+ this.parent.trigger(events.resizeStart, args, function (resizeStartArgs) {
283
+ if (resizeStartArgs.cancel) {
284
+ _this.cancelResizeAction();
285
+ }
286
+ });
287
+ }
288
+ EventHandler.add(this.contentModule.getDocument(), Browser.touchEndEvent, this.resizeEnd, this);
289
+ }
290
+ };
291
+ Video.prototype.videoClick = function (e) {
292
+ if (Browser.isDevice) {
293
+ if ((e.target.tagName === 'VIDEO' || this.isEmbedVidElem(e.target))) {
294
+ this.contentModule.getEditPanel().setAttribute('contenteditable', 'false');
295
+ e.target.focus();
296
+ }
297
+ else {
298
+ if (!this.parent.readonly) {
299
+ this.contentModule.getEditPanel().setAttribute('contenteditable', 'true');
300
+ }
301
+ }
302
+ }
303
+ if (e.target.tagName === 'VIDEO' || this.isEmbedVidElem(e.target)) {
304
+ e.preventDefault();
305
+ }
306
+ };
307
+ Video.prototype.onCutHandler = function () {
308
+ if (this.vidResizeDiv && this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
309
+ this.cancelResizeAction();
310
+ }
311
+ };
312
+ Video.prototype.videoResize = function (e) {
313
+ this.resizeBtnInit();
314
+ this.videoEle = e;
315
+ addClass([this.videoEle], 'e-resize');
316
+ this.vidResizeDiv = this.parent.createElement('span', { className: 'e-vid-resize', id: this.rteID + '_vidResize' });
317
+ this.vidResizeDiv.appendChild(this.parent.createElement('span', {
318
+ className: 'e-rte-videoboxmark e-rte-topLeft', styles: 'cursor: nwse-resize'
319
+ }));
320
+ this.vidResizeDiv.appendChild(this.parent.createElement('span', {
321
+ className: 'e-rte-videoboxmark e-rte-topRight', styles: 'cursor: nesw-resize'
322
+ }));
323
+ this.vidResizeDiv.appendChild(this.parent.createElement('span', {
324
+ className: 'e-rte-videoboxmark e-rte-botLeft', styles: 'cursor: nesw-resize'
325
+ }));
326
+ this.vidResizeDiv.appendChild(this.parent.createElement('span', {
327
+ className: 'e-rte-videoboxmark e-rte-botRight', styles: 'cursor: nwse-resize'
328
+ }));
329
+ if (Browser.isDevice) {
330
+ addClass([this.vidResizeDiv], 'e-mob-rte');
331
+ }
332
+ e.style.outline = '2px solid #4a90e2';
333
+ this.vidResizePos(e, this.vidResizeDiv);
334
+ this.resizeVidDupPos(e);
335
+ this.contentModule.getEditPanel().appendChild(this.vidResizeDiv);
336
+ EventHandler.add(this.contentModule.getDocument(), Browser.touchMoveEvent, this.resizing, this);
337
+ };
338
+ Video.prototype.getPointX = function (e) {
339
+ if (e.touches && e.touches.length) {
340
+ return e.touches[0].pageX;
341
+ }
342
+ else {
343
+ return e.pageX;
344
+ }
345
+ };
346
+ Video.prototype.getPointY = function (e) {
347
+ if (e.touches && e.touches.length) {
348
+ return e.touches[0].pageY;
349
+ }
350
+ else {
351
+ return e.pageY;
352
+ }
353
+ };
354
+ Video.prototype.vidResizePos = function (e, vidResizeDiv) {
355
+ if (isNullOrUndefined(vidResizeDiv)) {
356
+ return;
357
+ }
358
+ var pos = this.calcPos(e);
359
+ var top = pos.top;
360
+ var left = pos.left;
361
+ var vidWid = e.width !== 0 && e.width !== 'auto' && e.width !== 'NaN' ? e.width : e.getBoundingClientRect().width;
362
+ var vidHgt = e.height !== 0 && e.height !== 'auto' && e.height !== 'NaN' ? e.height : e.getBoundingClientRect().height;
363
+ var borWid = (Browser.isDevice) ? (4 * parseInt((e.style.outline.slice(-3)), 10)) + 2 :
364
+ (2 * parseInt((e.style.outline.slice(-3)), 10)) + 2; //span border width + video outline width
365
+ var devWid = ((Browser.isDevice) ? 0 : 2); // span border width
366
+ vidResizeDiv.querySelector('.e-rte-botLeft').style.left = (left - borWid) + 'px';
367
+ vidResizeDiv.querySelector('.e-rte-botLeft').style.top = ((parseInt(vidHgt.toString(), 10) - borWid) + top) + 'px';
368
+ vidResizeDiv.querySelector('.e-rte-botRight').style.left = ((parseInt(vidWid.toString(), 10) - (borWid - devWid)) + left) + 'px';
369
+ vidResizeDiv.querySelector('.e-rte-botRight').style.top = ((parseInt(vidHgt.toString(), 10) - borWid) + top) + 'px';
370
+ vidResizeDiv.querySelector('.e-rte-topRight').style.left = ((parseInt(vidWid.toString(), 10) - (borWid - devWid)) + left) + 'px';
371
+ vidResizeDiv.querySelector('.e-rte-topRight').style.top = (top - (borWid)) + 'px';
372
+ vidResizeDiv.querySelector('.e-rte-topLeft').style.left = (left - borWid) + 'px';
373
+ vidResizeDiv.querySelector('.e-rte-topLeft').style.top = (top - borWid) + 'px';
374
+ };
375
+ Video.prototype.calcPos = function (elem) {
376
+ var ignoreOffset = ['TD', 'TH', 'TABLE', 'A'];
377
+ var parentOffset = { top: 0, left: 0 };
378
+ var elementOffset;
379
+ var doc = elem.ownerDocument;
380
+ var offsetParent = ((elem.offsetParent && (elem.offsetParent.classList.contains('e-video-clickelem') ||
381
+ ignoreOffset.indexOf(elem.offsetParent.tagName) > -1)) ? closest(elem, '#' + this.parent.getID() + '_rte-edit-view') : elem.offsetParent) || doc.documentElement;
382
+ while (offsetParent &&
383
+ (offsetParent === doc.body || offsetParent === doc.documentElement) &&
384
+ offsetParent.style.position === 'static') {
385
+ offsetParent = offsetParent.parentNode;
386
+ }
387
+ if (offsetParent && offsetParent !== elem && offsetParent.nodeType === 1) {
388
+ // eslint-disable-next-line
389
+ parentOffset = offsetParent.getBoundingClientRect();
390
+ }
391
+ if (elem && elem.nodeType === 1 && elem.tagName === 'IFRAME') {
392
+ elementOffset = elem.getBoundingClientRect();
393
+ return {
394
+ top: elementOffset.top - parentOffset.top,
395
+ left: elementOffset.left - parentOffset.left
396
+ };
397
+ }
398
+ else {
399
+ return {
400
+ top: elem.offsetTop,
401
+ left: elem.offsetLeft
402
+ };
403
+ }
404
+ };
405
+ Video.prototype.setAspectRatio = function (vid, expectedX, expectedY, e) {
406
+ var vidEleStyle = getComputedStyle(vid);
407
+ if (isNullOrUndefined(vidEleStyle)) {
408
+ return;
409
+ }
410
+ var width = vidEleStyle.width !== '' ? vidEleStyle.width.match(/^\d+(\.\d*)?%$/g) ? parseFloat(vidEleStyle.width) :
411
+ parseInt(vidEleStyle.width, 10) : vid.style.width !== '' ? vid.style.width : vid.width;
412
+ var height = vidEleStyle.height !== '' ? parseInt(vidEleStyle.height, 10) : vid.style.height !== '' ? vid.style.height : vid.height;
413
+ if (width > height) {
414
+ vid.style.minWidth = this.parent.insertVideoSettings.minWidth === 0 ? '140px' : formatUnit(this.parent.insertVideoSettings.minWidth);
415
+ vid.style.minHeight = this.parent.insertVideoSettings.minHeight === 0 ? '50px' : formatUnit(this.parent.insertVideoSettings.minHeight);
416
+ if (this.parent.insertVideoSettings.resizeByPercent) {
417
+ if (parseInt('' + vid.getBoundingClientRect().width + '', 10) !== 0 && parseInt('' + width + '', 10) !== 0) {
418
+ var percentageValue = this.pixToPerc((parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY), (vid.previousElementSibling || vid.parentElement));
419
+ vid.style.width = Math.min(Math.round((percentageValue / vid.getBoundingClientRect().width) * expectedX * 100) / 100, 100) + '%';
420
+ }
421
+ else {
422
+ vid.style.width = this.pixToPerc(parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY, (vid.previousElementSibling || vid.parentElement)) + '%';
423
+ }
424
+ vid.style.height = null;
425
+ vid.removeAttribute('height');
426
+ }
427
+ else if ((vid.style.width === '' && vid.style.height !== '') || (vidEleStyle.width === '' && vidEleStyle.height !== '')) {
428
+ vid.style.height = expectedY + 'px';
429
+ }
430
+ else if ((vid.style.width !== '' && vid.style.height === '') || (vidEleStyle.width !== '' && vidEleStyle.height === '')) {
431
+ var currentWidth = ((parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY) +
432
+ parseInt(width.toString(), 10) / parseInt(height.toString(), 10)) <
433
+ (this.parent.inputElement.getBoundingClientRect().right - 32) ?
434
+ ((parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY) +
435
+ parseInt(width.toString(), 10) / parseInt(height.toString(), 10)) :
436
+ (this.parent.inputElement.getBoundingClientRect().right - 32);
437
+ vid.style.width = currentWidth.toString() + 'px';
438
+ }
439
+ else if (vid.style.width !== '' || vidEleStyle.width !== '') {
440
+ var currentWidth = (parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY) <
441
+ (this.parent.inputElement.getBoundingClientRect().right - 32) ?
442
+ (parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY) :
443
+ (this.parent.inputElement.getBoundingClientRect().right - 32);
444
+ vid.style.width = currentWidth + 'px';
445
+ vid.style.height = expectedY + 'px';
446
+ }
447
+ else {
448
+ vid.setAttribute('width', (parseInt(((parseInt(width.toString(), 10) / parseInt(height.toString(), 10) * expectedY) + parseInt(width.toString(), 10) / parseInt(height.toString(), 10)).toString(), 10)).toString());
449
+ }
450
+ }
451
+ else if (height > width) {
452
+ if (this.parent.insertVideoSettings.resizeByPercent) {
453
+ if (parseInt('' + vid.getBoundingClientRect().width + '', 10) !== 0 && parseInt('' + width + '', 10) !== 0) {
454
+ vid.style.width = Math.min(Math.round((parseInt(width.toString(), 10) / vid.getBoundingClientRect().width) * expectedX * 100) / 100, 100) + '%';
455
+ }
456
+ else {
457
+ vid.style.width = this.pixToPerc((expectedX / parseInt(height.toString(), 10) * expectedY), (vid.previousElementSibling || vid.parentElement)) + '%';
458
+ }
459
+ vid.style.height = null;
460
+ vid.removeAttribute('height');
461
+ }
462
+ else if (vid.style.width !== '' || vidEleStyle.width !== '') {
463
+ vid.style.width = expectedX + 'px';
464
+ vid.style.height = (parseInt(height.toString(), 10) / parseInt(width.toString(), 10) * expectedX) + 'px';
465
+ }
466
+ else {
467
+ vid.setAttribute('width', this.resizeBtnStat.botRight ? (this.getPointX(e.event) - vid.getBoundingClientRect().left).toString() : expectedX.toString());
468
+ }
469
+ }
470
+ else {
471
+ if (this.parent.insertVideoSettings.resizeByPercent) {
472
+ vid.style.width = this.pixToPerc(expectedX, (vid.previousElementSibling || vid.parentElement)) + '%';
473
+ vid.style.height = null;
474
+ vid.removeAttribute('height');
475
+ }
476
+ else {
477
+ vid.style.width = expectedX + 'px';
478
+ vid.style.height = expectedX + 'px';
479
+ }
480
+ }
481
+ };
482
+ Video.prototype.pixToPerc = function (expected, parentEle) {
483
+ return expected / parseFloat(getComputedStyle(parentEle).width) * 100;
484
+ };
485
+ Video.prototype.vidDupMouseMove = function (width, height, e) {
486
+ var _this = this;
487
+ var args = { event: e, requestType: 'videos' };
488
+ this.parent.trigger(events.onResize, args, function (resizingArgs) {
489
+ if (resizingArgs.cancel) {
490
+ _this.cancelResizeAction();
491
+ }
492
+ else {
493
+ if ((parseInt(_this.parent.insertVideoSettings.minWidth, 10) >= parseInt(width, 10) ||
494
+ (parseInt(_this.parent.getInsertVidMaxWidth(), 10) <= parseInt(width, 10) &&
495
+ isNOU(_this.videoEle.style.width)))) {
496
+ return;
497
+ }
498
+ if (!_this.parent.insertVideoSettings.resizeByPercent &&
499
+ (parseInt(_this.parent.insertVideoSettings.minHeight, 10) >= parseInt(height, 10) ||
500
+ parseInt(_this.parent.insertVideoSettings.maxHeight, 10) <= parseInt(height, 10))) {
501
+ return;
502
+ }
503
+ _this.videoEle.parentElement.style.cursor = 'pointer';
504
+ _this.setAspectRatio(_this.videoEle, parseInt(width, 10), parseInt(height, 10), args);
505
+ _this.resizeVidDupPos(_this.videoEle);
506
+ _this.vidResizePos(_this.videoEle, _this.vidResizeDiv);
507
+ _this.parent.setContentHeight('', false);
508
+ }
509
+ });
510
+ };
511
+ Video.prototype.resizing = function (e) {
512
+ if (this.videoEle.offsetWidth >= this.parent.getInsertVidMaxWidth()) {
513
+ this.videoEle.style.maxHeight = this.videoEle.offsetHeight + 'px';
514
+ }
515
+ var pageX = this.getPointX(e);
516
+ var pageY = this.getPointY(e);
517
+ var mouseX = (this.resizeBtnStat.botLeft || this.resizeBtnStat.topLeft) ? -(pageX - this.pageX) : (pageX - this.pageX);
518
+ var mouseY = (this.resizeBtnStat.topLeft || this.resizeBtnStat.topRight) ? -(pageY - this.pageY) : (pageY - this.pageY);
519
+ var width = parseInt(this.vidDupPos.width, 10) + mouseX;
520
+ var height = parseInt(this.vidDupPos.height, 10) + mouseY;
521
+ this.pageX = pageX;
522
+ this.pageY = pageY;
523
+ if (this.resizeBtnStat.botRight) {
524
+ this.vidDupMouseMove(width + 'px', height + 'px', e);
525
+ }
526
+ else if (this.resizeBtnStat.botLeft) {
527
+ this.vidDupMouseMove(width + 'px', height + 'px', e);
528
+ }
529
+ else if (this.resizeBtnStat.topRight) {
530
+ this.vidDupMouseMove(width + 'px', height + 'px', e);
531
+ }
532
+ else if (this.resizeBtnStat.topLeft) {
533
+ this.vidDupMouseMove(width + 'px', height + 'px', e);
534
+ }
535
+ };
536
+ Video.prototype.cancelResizeAction = function () {
537
+ EventHandler.remove(this.contentModule.getDocument(), Browser.touchMoveEvent, this.resizing);
538
+ EventHandler.remove(this.contentModule.getDocument(), Browser.touchEndEvent, this.resizeEnd);
539
+ if (this.videoEle && this.vidResizeDiv && this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
540
+ detach(this.vidResizeDiv);
541
+ this.videoEle.style.outline = '';
542
+ this.vidResizeDiv = null;
543
+ this.pageX = null;
544
+ this.pageY = null;
545
+ }
546
+ };
547
+ Video.prototype.resizeVidDupPos = function (e) {
548
+ this.vidDupPos = {
549
+ width: (e.style.width !== '' && (this.parent.insertVideoSettings &&
550
+ !this.parent.insertVideoSettings.resizeByPercent)) ? this.videoEle.style.width : e.width !== 'auto' && e.width !== 0 && e.width !== 'NaN' ? e.width + 'px' : parseInt(getComputedStyle(e).width, 10) + 'px',
551
+ height: (e.style.height !== '') ? this.videoEle.style.height : e.height !== 'auto' && e.height !== 0 && e.height !== 'NaN' ? e.height + 'px' : parseInt(getComputedStyle(e).height, 10) + 'px'
552
+ };
553
+ };
554
+ Video.prototype.resizeBtnInit = function () {
555
+ return this.resizeBtnStat = { botLeft: false, botRight: false, topRight: false, topLeft: false };
556
+ };
557
+ Video.prototype.onToolbarAction = function (args) {
558
+ if (isIDevice()) {
559
+ this.parent.notify(events.selectionRestore, {});
560
+ }
561
+ var item = args.args.item;
562
+ switch (item.subCommand) {
563
+ case 'VideoReplace':
564
+ this.parent.notify(events.insertVideo, args);
565
+ break;
566
+ case 'VideoRemove':
567
+ this.parent.notify(events.videoDelete, args);
568
+ break;
569
+ case 'VideoDimension':
570
+ this.parent.notify(events.videoSize, args);
571
+ }
572
+ };
573
+ Video.prototype.onKeyDown = function (event) {
574
+ var originalEvent = event.args;
575
+ var range;
576
+ var save;
577
+ var selectNodeEle;
578
+ var selectParentEle;
579
+ this.deletedVid = [];
580
+ var isCursor;
581
+ var keyCodeValues = [27, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
582
+ 44, 45, 9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 38, 39, 40, 91, 92, 93, 144, 145, 182, 183];
583
+ if (this.parent.editorMode === 'HTML') {
584
+ range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
585
+ isCursor = range.startContainer === range.endContainer && range.startOffset === range.endOffset;
586
+ }
587
+ if (!isCursor && this.parent.editorMode === 'HTML' && keyCodeValues.indexOf(originalEvent.which) < 0) {
588
+ var nodes = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
589
+ for (var i = 0; i < nodes.length; i++) {
590
+ if (nodes[i].nodeName === 'VIDEO' || nodes[i].nodeName === 'IFRAME') {
591
+ this.deletedVid.push(nodes[i]);
592
+ }
593
+ }
594
+ }
595
+ if (this.parent.editorMode === 'HTML' && ((originalEvent.which === 8 && originalEvent.code === 'Backspace') ||
596
+ (originalEvent.which === 46 && originalEvent.code === 'Delete'))) {
597
+ var isCursor_1 = range.startContainer === range.endContainer && range.startOffset === range.endOffset;
598
+ if ((originalEvent.which === 8 && originalEvent.code === 'Backspace' && isCursor_1)) {
599
+ this.checkVideoBack(range);
600
+ }
601
+ else if ((originalEvent.which === 46 && originalEvent.code === 'Delete' && isCursor_1)) {
602
+ this.checkVideoDel(range);
603
+ }
604
+ }
605
+ if (!isNullOrUndefined(this.parent.formatter.editorManager.nodeSelection) &&
606
+ originalEvent.code !== 'KeyK') {
607
+ range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
608
+ save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
609
+ selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
610
+ selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
611
+ if (!originalEvent.ctrlKey && originalEvent.key && (originalEvent.key.length === 1 || originalEvent.action === 'enter') &&
612
+ ((selectParentEle[0].tagName === 'VIDEO' || this.isEmbedVidElem(selectParentEle[0]))) &&
613
+ selectParentEle[0].parentElement) {
614
+ var prev = selectParentEle[0].parentElement.childNodes[0];
615
+ if (this.contentModule.getEditPanel().querySelector('.e-vid-resize')) {
616
+ this.removeResizeEle();
617
+ }
618
+ this.parent.formatter.editorManager.nodeSelection.setSelectionText(this.contentModule.getDocument(), prev, prev, prev.textContent.length, prev.textContent.length);
619
+ removeClass([selectParentEle[0]], classes.CLS_VID_FOCUS);
620
+ this.quickToolObj.videoQTBar.hidePopup();
621
+ }
622
+ }
623
+ if (originalEvent.ctrlKey && (originalEvent.keyCode === 89 || originalEvent.keyCode === 90)) {
624
+ this.undoStack({ subCommand: (originalEvent.keyCode === 90 ? 'undo' : 'redo') });
625
+ }
626
+ if (originalEvent.keyCode === 8 || originalEvent.keyCode === 46) {
627
+ if (selectNodeEle && (selectNodeEle[0].nodeName === 'VIDEO' || this.isEmbedVidElem(selectNodeEle[0])) && selectNodeEle.length < 1) {
628
+ originalEvent.preventDefault();
629
+ var event_1 = {
630
+ selectNode: selectNodeEle, selection: save, selectParent: selectParentEle,
631
+ args: {
632
+ item: { command: 'Videos', subCommand: 'VideoRemove' },
633
+ originalEvent: originalEvent
634
+ }
635
+ };
636
+ this.deleteVideo(event_1, originalEvent.keyCode);
637
+ }
638
+ if (this.parent.contentModule.getEditPanel().querySelector('.e-vid-resize')) {
639
+ this.removeResizeEle();
640
+ }
641
+ }
642
+ if (originalEvent.code === 'Backspace') {
643
+ originalEvent.action = 'backspace';
644
+ }
645
+ switch (originalEvent.action) {
646
+ case 'escape':
647
+ if (!isNullOrUndefined(this.dialogObj)) {
648
+ this.dialogObj.close();
649
+ }
650
+ break;
651
+ case 'backspace':
652
+ case 'delete':
653
+ for (var i = 0; i < this.deletedVid.length; i++) {
654
+ var src = this.deletedVid[i].src;
655
+ this.videoRemovePost(src);
656
+ }
657
+ if (this.parent.editorMode !== 'Markdown') {
658
+ if (range.startContainer.nodeType === 3) {
659
+ if (originalEvent.code === 'Backspace') {
660
+ if (range.startContainer.previousElementSibling && range.startOffset === 0 &&
661
+ range.startContainer.previousElementSibling.classList.contains(classes.CLS_VIDEOWRAP)) {
662
+ detach(range.startContainer.previousElementSibling);
663
+ }
664
+ }
665
+ else {
666
+ if (range.startContainer.nextElementSibling &&
667
+ range.endContainer.textContent.length === range.endOffset &&
668
+ range.startContainer.nextElementSibling.classList.contains(classes.CLS_VIDEOWRAP)) {
669
+ detach(range.startContainer.nextElementSibling);
670
+ }
671
+ }
672
+ }
673
+ else if (range.startContainer.nodeType === 1 && (range.startContainer.classList &&
674
+ range.startContainer.classList.contains(classes.CLS_VIDEOWRAP))) {
675
+ detach(range.startContainer);
676
+ }
677
+ }
678
+ break;
679
+ case 'insert-video':
680
+ this.openDialog(true, originalEvent, save, selectNodeEle, selectParentEle);
681
+ originalEvent.preventDefault();
682
+ break;
683
+ }
684
+ };
685
+ Video.prototype.openDialog = function (isInternal, event, selection, ele, parentEle) {
686
+ var range;
687
+ var save;
688
+ var selectNodeEle;
689
+ var selectParentEle;
690
+ if (!isInternal && !isNOU(this.parent.formatter.editorManager.nodeSelection)) {
691
+ range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
692
+ save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
693
+ selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
694
+ selectParentEle = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
695
+ }
696
+ else {
697
+ save = selection;
698
+ selectNodeEle = ele;
699
+ selectParentEle = parentEle;
700
+ }
701
+ if (this.parent.editorMode === 'HTML') {
702
+ this.insertVideo({
703
+ args: {
704
+ item: { command: 'Videos', subCommand: 'Video' },
705
+ originalEvent: event
706
+ },
707
+ selectNode: selectNodeEle,
708
+ selection: save,
709
+ selectParent: selectParentEle
710
+ });
711
+ }
712
+ };
713
+ Video.prototype.showDialog = function () {
714
+ this.openDialog(false);
715
+ };
716
+ Video.prototype.closeDialog = function () {
717
+ if (this.dialogObj) {
718
+ this.dialogObj.hide({ returnValue: true });
719
+ }
720
+ };
721
+ Video.prototype.checkVideoBack = function (range) {
722
+ if (range.startContainer.nodeName === '#text' && range.startOffset === 0 &&
723
+ !isNOU(range.startContainer.previousSibling) && (range.startContainer.previousSibling.nodeName === 'VIDEO' ||
724
+ this.isEmbedVidElem(range.startContainer.previousSibling))) {
725
+ this.deletedVid.push(range.startContainer.previousSibling);
726
+ }
727
+ else if (range.startContainer.nodeName !== '#text' && !isNOU(range.startContainer.childNodes[range.startOffset - 1]) &&
728
+ (range.startContainer.childNodes[range.startOffset - 1].nodeName === 'VIDEO' ||
729
+ this.isEmbedVidElem(range.startContainer.childNodes[range.startOffset - 1]))) {
730
+ this.deletedVid.push(range.startContainer.childNodes[range.startOffset - 1]);
731
+ }
732
+ };
733
+ Video.prototype.checkVideoDel = function (range) {
734
+ if (range.startContainer.nodeName === '#text' && range.startOffset === range.startContainer.textContent.length &&
735
+ !isNOU(range.startContainer.nextSibling) && (range.startContainer.nextSibling.nodeName === 'VIDEO' ||
736
+ this.isEmbedVidElem(range.startContainer.nextSibling))) {
737
+ this.deletedVid.push(range.startContainer.nextSibling);
738
+ }
739
+ else if (range.startContainer.nodeName !== '#text' && !isNOU(range.startContainer.childNodes[range.startOffset]) &&
740
+ (range.startContainer.childNodes[range.startOffset].nodeName === 'VIDEO' ||
741
+ this.isEmbedVidElem(range.startContainer.childNodes[range.startOffset]))) {
742
+ this.deletedVid.push(range.startContainer.childNodes[range.startOffset]);
743
+ }
744
+ };
745
+ Video.prototype.alignmentSelect = function (e) {
746
+ var item = e.item;
747
+ if (!document.body.contains(document.body.querySelector('.e-rte-quick-toolbar')) || item.command !== 'Videos') {
748
+ return;
749
+ }
750
+ var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
751
+ var selectNodeEle = this.parent.formatter.editorManager.nodeSelection.getNodeCollection(range);
752
+ selectNodeEle = (selectNodeEle[0].nodeName === 'VIDEO') ? selectNodeEle : [this.videoEle];
753
+ var args = { args: e, selectNode: selectNodeEle };
754
+ if (this.parent.formatter.getUndoRedoStack().length === 0) {
755
+ this.parent.formatter.saveData();
756
+ }
757
+ switch (item.subCommand) {
758
+ case 'JustifyLeft':
759
+ case 'JustifyCenter':
760
+ case 'JustifyRight':
761
+ this.alignVideo(args, item.subCommand);
762
+ break;
763
+ case 'Inline':
764
+ this.inline(args);
765
+ break;
766
+ case 'Break':
767
+ this.break(args);
768
+ break;
769
+ }
770
+ if (this.quickToolObj && document.body.contains(this.quickToolObj.videoQTBar.element)) {
771
+ this.quickToolObj.videoQTBar.hidePopup();
772
+ removeClass([selectNodeEle[0]], classes.CLS_VID_FOCUS);
773
+ }
774
+ this.cancelResizeAction();
775
+ };
776
+ Video.prototype.deleteVideo = function (e, keyCode) {
777
+ if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
778
+ return;
779
+ }
780
+ if (this.isEmbedVidElem(e.selectNode[0])) {
781
+ e.selectNode[0] = e.selectNode[0].classList.contains(classes.CLS_VID_CLICK_ELEM) ? e.selectNode[0] :
782
+ e.selectNode[0].parentElement;
783
+ }
784
+ var args = {
785
+ element: !this.isEmbedVidElem(e.selectNode[0]) ? e.selectNode[0].querySelector('iframe') :
786
+ e.selectNode[0],
787
+ src: !this.isEmbedVidElem(e.selectNode[0]) ? e.selectNode[0].querySelector('source').getAttribute('src') :
788
+ e.selectNode[0].querySelector('iframe').getAttribute('src')
789
+ };
790
+ if (this.parent.formatter.getUndoRedoStack().length === 0) {
791
+ this.parent.formatter.saveData();
792
+ }
793
+ e.selection.restore();
794
+ this.parent.formatter.process(this.parent, e.args, e.args, {
795
+ selectNode: e.selectNode,
796
+ subCommand: e.args.item.subCommand
797
+ });
798
+ this.videoRemovePost(args.src);
799
+ if (this.quickToolObj && document.body.contains(this.quickToolObj.videoQTBar.element)) {
800
+ this.quickToolObj.videoQTBar.hidePopup();
801
+ }
802
+ this.cancelResizeAction();
803
+ if (isNullOrUndefined(keyCode)) {
804
+ this.parent.trigger(events.afterMediaDelete, args);
805
+ }
806
+ };
807
+ Video.prototype.videoRemovePost = function (src) {
808
+ var proxy = this;
809
+ var absoluteUrl = '';
810
+ if (isNOU(this.parent.insertVideoSettings.removeUrl) || this.parent.insertVideoSettings.removeUrl === '') {
811
+ return;
812
+ }
813
+ if (src.indexOf('http://') > -1 || src.indexOf('https://') > -1) {
814
+ absoluteUrl = src;
815
+ }
816
+ else {
817
+ absoluteUrl = new URL(src, document.baseURI).href;
818
+ }
819
+ this.removingVideoName = absoluteUrl.replace(/^.*[\\\/]/, '');
820
+ var xhr = new XMLHttpRequest();
821
+ xhr.addEventListener('readystatechange', function () {
822
+ if (this.readyState === 4 && this.status === 200) {
823
+ proxy.triggerPost(this.response);
824
+ }
825
+ });
826
+ xhr.open('GET', absoluteUrl);
827
+ xhr.responseType = 'blob';
828
+ xhr.send();
829
+ };
830
+ Video.prototype.triggerPost = function (response) {
831
+ var removeUrl = this.parent.insertVideoSettings.removeUrl;
832
+ if (isNOU(removeUrl) || removeUrl === '') {
833
+ return;
834
+ }
835
+ var file = new File([response], this.removingVideoName);
836
+ var ajax = new Ajax(removeUrl, 'POST', true, null);
837
+ var formData = new FormData();
838
+ formData.append('UploadFiles', file);
839
+ ajax.send(formData);
840
+ };
841
+ Video.prototype.onDocumentClick = function (e) {
842
+ var target = e.target;
843
+ if (target.nodeName === 'VIDEO' || this.isEmbedVidElem(target)) {
844
+ this.videoEle = !this.isEmbedVidElem(target) ? target : target.querySelector('iframe');
845
+ }
846
+ if (!isNullOrUndefined(this.dialogObj) && ((
847
+ // eslint-disable-next-line
848
+ !closest(target, '[id=' + "'" + this.dialogObj.element.id + "'" + ']') && this.parent.toolbarSettings.enable && this.parent.getToolbarElement() &&
849
+ !this.parent.getToolbarElement().contains(e.target)) ||
850
+ (this.parent.getToolbarElement() && this.parent.getToolbarElement().contains(e.target) &&
851
+ !closest(target, '#' + this.parent.getID() + '_toolbar_Video') &&
852
+ !target.querySelector('#' + this.parent.getID() + '_toolbar_Video')))) {
853
+ /* eslint-disable */
854
+ if (e.offsetX > e.target.clientWidth || e.offsetY > e.target.clientHeight) {
855
+ }
856
+ else {
857
+ this.dialogObj.hide({ returnValue: true });
858
+ this.parent.isBlur = true;
859
+ dispatchEvent(this.parent.element, 'focusout');
860
+ }
861
+ /* eslint-enable */
862
+ }
863
+ // if (((e.target as HTMLElement).tagName !== 'VIDEO' || !this.isEmbedVidElem(e.target as HTMLElement)) && this.vidResizeDiv && !(this.quickToolObj &&
864
+ // this.quickToolObj.videoQTBar && this.quickToolObj.videoQTBar.element.contains(e.target as HTMLElement)) &&
865
+ // this.contentModule.getEditPanel().contains(this.vidResizeDiv)) {
866
+ // this.cancelResizeAction();
867
+ // }
868
+ if (this.contentModule.getEditPanel().querySelector('.e-vid-resize')) {
869
+ if (target.tagName !== 'VIDEO' && !this.isEmbedVidElem(target)) {
870
+ this.removeResizeEle();
871
+ }
872
+ if ((target.tagName !== 'VIDEO' && !this.isEmbedVidElem(target)) && !isNOU(this.videoEle)) {
873
+ this.videoEle.style.outline = '';
874
+ }
875
+ else if (!isNOU(this.prevSelectedVidEle) &&
876
+ this.prevSelectedVidEle !== ((target.tagName === 'IFRAME' || target.tagName === 'VIDEO') ? target : target.querySelector('iframe'))) {
877
+ this.prevSelectedVidEle.style.outline = '';
878
+ }
879
+ }
880
+ };
881
+ Video.prototype.removeResizeEle = function () {
882
+ EventHandler.remove(this.contentModule.getDocument(), Browser.touchMoveEvent, this.resizing);
883
+ EventHandler.remove(this.contentModule.getDocument(), Browser.touchEndEvent, this.resizeEnd);
884
+ detach(this.contentModule.getEditPanel().querySelector('.e-vid-resize'));
885
+ };
886
+ Video.prototype.onWindowResize = function () {
887
+ if (!isNOU(this.contentModule) && !isNOU(this.contentModule.getEditPanel().querySelector('.e-vid-resize'))) {
888
+ this.cancelResizeAction();
889
+ }
890
+ };
891
+ Video.prototype.break = function (e) {
892
+ if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
893
+ return;
894
+ }
895
+ var subCommand = (e.args.item) ?
896
+ e.args.item.subCommand : 'Break';
897
+ this.parent.formatter.process(this.parent, e.args, e.args, { selectNode: e.selectNode, subCommand: subCommand });
898
+ };
899
+ Video.prototype.inline = function (e) {
900
+ if (e.selectNode[0].nodeName !== 'VIDEO' && !this.isEmbedVidElem(e.selectNode[0])) {
901
+ return;
902
+ }
903
+ var subCommand = (e.args.item) ?
904
+ e.args.item.subCommand : 'Inline';
905
+ this.parent.formatter.process(this.parent, e.args, e.args, { selectNode: e.selectNode, subCommand: subCommand });
906
+ };
907
+ Video.prototype.alignVideo = function (e, type) {
908
+ var subCommand = (e.args.item) ?
909
+ e.args.item.subCommand : type;
910
+ this.parent.formatter.process(this.parent, e.args, e.args, { selectNode: e.selectNode, subCommand: subCommand });
911
+ };
912
+ Video.prototype.editAreaClickHandler = function (e) {
913
+ if (this.parent.readonly) {
914
+ this.hideVideoQuickToolbar();
915
+ return;
916
+ }
917
+ var args = e.args;
918
+ var showOnRightClick = this.parent.quickToolbarSettings.showOnRightClick;
919
+ if (args.which === 2 || (showOnRightClick && args.which === 1) || (!showOnRightClick && args.which === 3)) {
920
+ if ((showOnRightClick && args.which === 1) && !isNullOrUndefined(args.target) &&
921
+ (args.target.tagName === 'VIDEO' || this.isEmbedVidElem(args.target))) {
922
+ this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
923
+ this.parent.formatter.editorManager.nodeSelection.setSelectionContents(this.contentModule.getDocument(), args.target);
924
+ }
925
+ return;
926
+ }
927
+ if (this.parent.editorMode === 'HTML' && this.parent.quickToolbarModule && this.parent.quickToolbarModule.videoQTBar) {
928
+ this.quickToolObj = this.parent.quickToolbarModule;
929
+ var target = args.target;
930
+ this.contentModule = this.rendererFactory.getRenderer(RenderType.Content);
931
+ var isPopupOpen = this.quickToolObj.videoQTBar.element.classList.contains('e-rte-pop');
932
+ if ((target.nodeName === 'VIDEO' || this.isEmbedVidElem(target)) && this.parent.quickToolbarModule) {
933
+ if (isPopupOpen) {
934
+ return;
935
+ }
936
+ this.parent.formatter.editorManager.nodeSelection.Clear(this.contentModule.getDocument());
937
+ this.parent.formatter.editorManager.nodeSelection.setSelectionContents(this.contentModule.getDocument(), target);
938
+ if (isIDevice()) {
939
+ this.parent.notify(events.selectionSave, e);
940
+ }
941
+ addClass([!this.isEmbedVidElem(target) ? target : target.querySelector('iframe')], classes.CLS_VID_FOCUS);
942
+ this.showVideoQuickToolbar({ args: args, type: 'Videos', elements: [args.target] });
943
+ }
944
+ else {
945
+ this.hideVideoQuickToolbar();
946
+ }
947
+ }
948
+ };
949
+ Video.prototype.showVideoQuickToolbar = function (e) {
950
+ var _this = this;
951
+ if (e.type !== 'Videos' || isNullOrUndefined(this.parent.quickToolbarModule)
952
+ || isNullOrUndefined(this.parent.quickToolbarModule.videoQTBar) || isNullOrUndefined(e.args)) {
953
+ return;
954
+ }
955
+ this.quickToolObj = this.parent.quickToolbarModule;
956
+ var args = e.args;
957
+ var target = e.elements;
958
+ [].forEach.call(e.elements, function (element, index) {
959
+ if (index === 0) {
960
+ target = element;
961
+ }
962
+ });
963
+ if (target.tagName === 'VIDEO' || this.isEmbedVidElem(target)) {
964
+ addClass([(!this.isEmbedVidElem(target) || target.tagName === 'IFRAME') ? target : target.querySelector('iframe')], [classes.CLS_VID_FOCUS]);
965
+ }
966
+ var pageY = (this.parent.iframeSettings.enable) ? window.pageYOffset +
967
+ this.parent.element.getBoundingClientRect().top + args.clientY : args.pageY;
968
+ if (this.parent.quickToolbarModule.videoQTBar) {
969
+ if (e.isNotify) {
970
+ setTimeout(function () {
971
+ _this.parent.formatter.editorManager.nodeSelection.Clear(_this.contentModule.getDocument());
972
+ _this.parent.formatter.editorManager.nodeSelection.setSelectionContents(_this.contentModule.getDocument(), target);
973
+ _this.quickToolObj.videoQTBar.showPopup(args.pageX - 50, pageY + (target.getBoundingClientRect().height / 2) - target.offsetTop, target);
974
+ }, 400);
975
+ }
976
+ else {
977
+ this.quickToolObj.videoQTBar.showPopup(args.pageX - 50, pageY + (target.getBoundingClientRect().height / 2) - target.offsetTop, target);
978
+ }
979
+ }
980
+ };
981
+ Video.prototype.hideVideoQuickToolbar = function () {
982
+ if (!isNullOrUndefined(this.contentModule.getEditPanel().querySelector('.' + classes.CLS_VID_FOCUS))) {
983
+ removeClass([this.contentModule.getEditPanel().querySelector('.' + classes.CLS_VID_FOCUS)], classes.CLS_VID_FOCUS);
984
+ if (this.quickToolObj && this.quickToolObj.videoQTBar && document.body.contains(this.quickToolObj.videoQTBar.element)) {
985
+ this.quickToolObj.videoQTBar.hidePopup();
986
+ }
987
+ }
988
+ };
989
+ Video.prototype.isEmbedVidElem = function (target) {
990
+ if ((target && target.nodeType !== 3 && target.nodeName !== 'BR' && (target.classList && target.classList.contains(classes.CLS_VID_CLICK_ELEM))) ||
991
+ (target && target.nodeName === 'IFRAME')) {
992
+ return true;
993
+ }
994
+ else {
995
+ return false;
996
+ }
997
+ };
998
+ Video.prototype.insertingVideo = function (e) {
999
+ this.insertVideo(e);
1000
+ if (!isNullOrUndefined(this.dialogObj)) {
1001
+ this.dialogObj.element.style.maxHeight = 'inherit';
1002
+ var dialogContent = this.dialogObj.element.querySelector('.e-video-content');
1003
+ if (!isNullOrUndefined(this.parent.insertVideoSettings.path) || this.parent.editorMode === 'HTML') {
1004
+ document.getElementById(this.rteID + '_insertVideo').focus();
1005
+ }
1006
+ else {
1007
+ dialogContent.querySelector('.e-video-url').focus();
1008
+ }
1009
+ }
1010
+ };
1011
+ Video.prototype.insertVideo = function (e) {
1012
+ var _this = this;
1013
+ if (this.dialogObj) {
1014
+ this.dialogObj.hide({ returnValue: true });
1015
+ return;
1016
+ }
1017
+ var videoDialog = this.parent.createElement('div', { className: 'e-rte-video-dialog', id: this.rteID + '_video' });
1018
+ this.parent.element.appendChild(videoDialog);
1019
+ var videoInsert = this.i10n.getConstant('dialogInsert');
1020
+ var videolinkCancel = this.i10n.getConstant('dialogCancel');
1021
+ var videoHeader = this.i10n.getConstant('videoHeader');
1022
+ var selection = e.selection;
1023
+ var selectObj = { selfVideo: this, selection: e.selection, args: e.args, selectParent: e.selectParent };
1024
+ var dialogModel = {
1025
+ header: videoHeader,
1026
+ cssClass: classes.CLS_RTE_ELEMENTS,
1027
+ enableRtl: this.parent.enableRtl,
1028
+ locale: this.parent.locale,
1029
+ showCloseIcon: true, closeOnEscape: true, width: (Browser.isDevice) ? '290px' : '340px', height: 'inherit',
1030
+ position: { X: 'center', Y: (Browser.isDevice) ? 'center' : 'top' },
1031
+ isModal: Browser.isDevice,
1032
+ buttons: [{
1033
+ click: this.insertVideoUrl.bind(selectObj),
1034
+ buttonModel: { content: videoInsert, cssClass: 'e-flat e-insertVideo', isPrimary: true, disabled: true }
1035
+ },
1036
+ {
1037
+ click: function (e) {
1038
+ _this.cancelDialog(e);
1039
+ },
1040
+ buttonModel: { cssClass: 'e-flat e-cancel', content: videolinkCancel }
1041
+ }],
1042
+ target: (Browser.isDevice) ? document.body : this.parent.element,
1043
+ animationSettings: { effect: 'None' },
1044
+ close: function (event) {
1045
+ if (_this.isVideoUploaded) {
1046
+ _this.uploadObj.removing();
1047
+ }
1048
+ _this.parent.isBlur = false;
1049
+ if (event && event.event.returnValue) {
1050
+ if (_this.parent.editorMode === 'HTML') {
1051
+ selection.restore();
1052
+ }
1053
+ }
1054
+ _this.dialogObj.destroy();
1055
+ detach(_this.dialogObj.element);
1056
+ _this.dialogRenderObj.close(event);
1057
+ _this.dialogObj = null;
1058
+ }
1059
+ };
1060
+ var dialogContent = this.parent.createElement('div', { className: 'e-video-content' });
1061
+ if (!isNullOrUndefined(this.parent.insertVideoSettings.path) || this.parent.editorMode === 'HTML') {
1062
+ dialogContent.appendChild(this.videoUpload(e));
1063
+ }
1064
+ var linkHeader = this.parent.createElement('div', { className: 'e-videoheader' });
1065
+ var embedLinkHeader = this.parent.createElement('div', { className: 'e-embed-videoheader' });
1066
+ var linkHeaderText = this.i10n.getConstant('videoLinkHeader');
1067
+ var embedLinkHeaderText = this.i10n.getConstant('embedVideoLinkHeader');
1068
+ if (this.parent.editorMode === 'HTML') {
1069
+ linkHeader.innerHTML = linkHeaderText;
1070
+ embedLinkHeader.innerHTML = embedLinkHeaderText;
1071
+ }
1072
+ dialogContent.appendChild(this.urlPopup(e));
1073
+ if (e.selectNode && e.selectNode[0].nodeType === 1 && (e.selectNode[0].tagName === 'VIDEO' || this.isEmbedVidElem(e.selectNode[0]))) {
1074
+ dialogModel.header = this.parent.localeObj.getConstant('editVideoHeader');
1075
+ dialogModel.content = dialogContent;
1076
+ }
1077
+ else {
1078
+ dialogModel.content = dialogContent;
1079
+ }
1080
+ this.dialogObj = this.dialogRenderObj.render(dialogModel);
1081
+ this.dialogObj.createElement = this.parent.createElement;
1082
+ this.dialogObj.appendTo(videoDialog);
1083
+ if (e.selectNode && e.selectNode[0].nodeType === 1 && (e.selectNode[0].tagName === 'VIDEO' || this.isEmbedVidElem(e.selectNode[0]))
1084
+ && (e.name === 'insertVideo')) {
1085
+ this.dialogObj.element.querySelector('.e-insertVideo').textContent = this.parent.localeObj.getConstant('dialogUpdate');
1086
+ }
1087
+ videoDialog.style.maxHeight = 'inherit';
1088
+ if (this.quickToolObj) {
1089
+ if (this.quickToolObj.videoQTBar && document.body.contains(this.quickToolObj.videoQTBar.element)) {
1090
+ this.quickToolObj.videoQTBar.hidePopup();
1091
+ if (!isNullOrUndefined(e.selectParent)) {
1092
+ removeClass([e.selectParent[0]], classes.CLS_VID_FOCUS);
1093
+ }
1094
+ }
1095
+ if (this.quickToolObj.inlineQTBar && document.body.contains(this.quickToolObj.inlineQTBar.element)) {
1096
+ this.quickToolObj.inlineQTBar.hidePopup();
1097
+ }
1098
+ }
1099
+ };
1100
+ // eslint-disable-next-line
1101
+ Video.prototype.urlPopup = function (e) {
1102
+ var _this = this;
1103
+ var videoUrl = this.parent.createElement('div', { className: 'e-video-url-wrap' });
1104
+ var urlContent = this.parent.createElement('div', { id: 'urlcontent' });
1105
+ var placeUrl = this.i10n.getConstant('videoUrl');
1106
+ var content = '<input id="embedURL" type="radio">' + '<input id="webURL" type="radio" >';
1107
+ var contentElem = parseHtml(content);
1108
+ videoUrl.appendChild(contentElem);
1109
+ videoUrl.appendChild(urlContent);
1110
+ this.embedInputUrl = this.parent.createElement('textarea', {
1111
+ className: 'e-input e-embed-video-url',
1112
+ attrs: { placeholder: 'Paste Embed URL here', type: 'text', tabindex: '-1' }
1113
+ });
1114
+ this.embedInputUrl.addEventListener('keyup', function () {
1115
+ if (!isNOU(_this.embedInputUrl)) {
1116
+ if (_this.embedInputUrl.value.length === 0) {
1117
+ _this.dialogObj.getButtons(0).element.disabled = true;
1118
+ }
1119
+ else {
1120
+ _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
1121
+ }
1122
+ }
1123
+ });
1124
+ this.inputUrl = this.parent.createElement('input', {
1125
+ className: 'e-input e-video-url',
1126
+ attrs: { placeholder: placeUrl, spellcheck: 'false' }
1127
+ });
1128
+ this.inputUrl.addEventListener('input', function () {
1129
+ if (!isNOU(_this.inputUrl)) {
1130
+ if (_this.inputUrl.value.length === 0) {
1131
+ _this.dialogObj.getButtons(0).element.disabled = true;
1132
+ }
1133
+ else {
1134
+ _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
1135
+ }
1136
+ }
1137
+ });
1138
+ var embedUrlBtn = new RadioButton({
1139
+ label: 'Embed URL',
1140
+ checked: true,
1141
+ name: 'URL',
1142
+ created: function () {
1143
+ urlContent.appendChild(_this.embedInputUrl);
1144
+ },
1145
+ change: function () {
1146
+ urlContent.innerHTML = '';
1147
+ _this.inputUrl.value = '';
1148
+ urlContent.appendChild(_this.embedInputUrl);
1149
+ }
1150
+ });
1151
+ embedUrlBtn.appendTo(videoUrl.querySelector('#embedURL'));
1152
+ var webUrlBtn = new RadioButton({
1153
+ label: 'Web URL',
1154
+ name: 'URL',
1155
+ change: function () {
1156
+ urlContent.innerHTML = '';
1157
+ _this.embedInputUrl.value = '';
1158
+ urlContent.appendChild(_this.inputUrl);
1159
+ }
1160
+ });
1161
+ webUrlBtn.appendTo(videoUrl.querySelector('#webURL'));
1162
+ return videoUrl;
1163
+ };
1164
+ Video.prototype.videoUpload = function (e) {
1165
+ var _this = this;
1166
+ var save;
1167
+ var selectParent;
1168
+ // eslint-disable-next-line
1169
+ var proxy = this;
1170
+ var iframe = proxy.parent.iframeSettings.enable;
1171
+ if (proxy.parent.editorMode === 'HTML' && (!iframe && isNullOrUndefined(closest(e.selection.range.startContainer.parentNode, '[id='
1172
+ // eslint-disable-next-line
1173
+ + "'" + this.parent.contentModule.getPanel().id + "'" + ']'))
1174
+ || (iframe && !hasClass(e.selection.range.startContainer.parentNode.ownerDocument.querySelector('body'), 'e-lib')))) {
1175
+ this.contentModule.getEditPanel().focus();
1176
+ var range = this.parent.formatter.editorManager.nodeSelection.getRange(this.parent.contentModule.getDocument());
1177
+ save = this.parent.formatter.editorManager.nodeSelection.save(range, this.parent.contentModule.getDocument());
1178
+ selectParent = this.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
1179
+ }
1180
+ else {
1181
+ save = e.selection;
1182
+ selectParent = e.selectParent;
1183
+ }
1184
+ var uploadParentEle = this.parent.createElement('div', { className: 'e-vid-uploadwrap e-droparea' });
1185
+ var deviceVideoUpMsg = this.i10n.getConstant('videoDeviceUploadMessage');
1186
+ var videoUpMsg = this.i10n.getConstant('videoUploadMessage');
1187
+ var span = this.parent.createElement('span', { className: 'e-droptext' });
1188
+ var spanMsg = this.parent.createElement('span', {
1189
+ className: 'e-rte-upload-text', innerHTML: ((Browser.isDevice) ? deviceVideoUpMsg : videoUpMsg)
1190
+ });
1191
+ span.appendChild(spanMsg);
1192
+ var btnEle = this.parent.createElement('button', {
1193
+ className: 'e-browsebtn', id: this.rteID + '_insertVideo', attrs: { autofocus: 'true', type: 'button' }
1194
+ });
1195
+ span.appendChild(btnEle);
1196
+ uploadParentEle.appendChild(span);
1197
+ var browserMsg = this.i10n.getConstant('browse');
1198
+ var button = new Button({ content: browserMsg, enableRtl: this.parent.enableRtl });
1199
+ button.isStringTemplate = true;
1200
+ button.createElement = this.parent.createElement;
1201
+ button.appendTo(btnEle);
1202
+ var btnClick = (Browser.isDevice) ? span : btnEle;
1203
+ EventHandler.add(btnClick, 'click', this.fileSelect, this);
1204
+ var uploadEle = this.parent.createElement('input', {
1205
+ id: this.rteID + '_upload', attrs: { type: 'File', name: 'UploadFiles' }
1206
+ });
1207
+ uploadParentEle.appendChild(uploadEle);
1208
+ var fileName;
1209
+ var rawFile;
1210
+ var selectArgs;
1211
+ var filesData;
1212
+ var beforeUploadArgs;
1213
+ this.uploadObj = new Uploader({
1214
+ asyncSettings: { saveUrl: this.parent.insertVideoSettings.saveUrl, removeUrl: this.parent.insertVideoSettings.removeUrl },
1215
+ dropArea: span, multiple: false, enableRtl: this.parent.enableRtl,
1216
+ allowedExtensions: this.parent.insertVideoSettings.allowedTypes.toString(),
1217
+ selected: function (e) {
1218
+ proxy.isVideoUploaded = true;
1219
+ selectArgs = e;
1220
+ filesData = e.filesData;
1221
+ if (_this.parent.isServerRendered) {
1222
+ selectArgs = JSON.parse(JSON.stringify(e));
1223
+ e.cancel = true;
1224
+ rawFile = e.filesData;
1225
+ selectArgs.filesData = rawFile;
1226
+ }
1227
+ _this.parent.trigger(events.fileSelected, selectArgs, function (selectArgs) {
1228
+ if (!selectArgs.cancel) {
1229
+ _this.checkExtension(selectArgs.filesData[0]);
1230
+ fileName = selectArgs.filesData[0].name;
1231
+ if (_this.parent.editorMode === 'HTML' && isNullOrUndefined(_this.parent.insertVideoSettings.path)) {
1232
+ var reader_1 = new FileReader();
1233
+ // eslint-disable-next-line
1234
+ reader_1.addEventListener('load', function (e) {
1235
+ var url = _this.parent.insertVideoSettings.saveFormat === 'Base64' ? reader_1.result :
1236
+ URL.createObjectURL(convertToBlob(reader_1.result));
1237
+ proxy.uploadUrl = {
1238
+ url: url, selection: save, fileName: fileName,
1239
+ selectParent: selectParent
1240
+ };
1241
+ proxy.inputUrl.setAttribute('disabled', 'true');
1242
+ proxy.embedInputUrl.setAttribute('disabled', 'true');
1243
+ if (isNullOrUndefined(proxy.parent.insertVideoSettings.saveUrl) && _this.isAllowedTypes
1244
+ && !isNullOrUndefined(_this.dialogObj)) {
1245
+ _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
1246
+ }
1247
+ });
1248
+ reader_1.readAsDataURL(selectArgs.filesData[0].rawFile);
1249
+ }
1250
+ if (_this.parent.isServerRendered) {
1251
+ /* eslint-disable */
1252
+ _this.uploadObj._internalRenderSelect(selectArgs, rawFile);
1253
+ /* eslint-enable */
1254
+ }
1255
+ }
1256
+ });
1257
+ },
1258
+ beforeUpload: function (args) {
1259
+ if (_this.parent.isServerRendered) {
1260
+ beforeUploadArgs = JSON.parse(JSON.stringify(args));
1261
+ beforeUploadArgs.filesData = filesData;
1262
+ args.cancel = true;
1263
+ _this.parent.trigger(events.fileUploading, beforeUploadArgs, function (beforeUploadArgs) {
1264
+ if (beforeUploadArgs.cancel) {
1265
+ return;
1266
+ }
1267
+ /* eslint-disable */
1268
+ _this.uploadObj.currentRequestHeader = beforeUploadArgs.currentRequest ?
1269
+ beforeUploadArgs.currentRequest : _this.uploadObj.currentRequestHeader;
1270
+ _this.uploadObj.customFormDatas = beforeUploadArgs.customFormData && beforeUploadArgs.customFormData.length > 0 ?
1271
+ beforeUploadArgs.customFormData : _this.uploadObj.customFormDatas;
1272
+ _this.uploadObj.uploadFiles(rawFile, null);
1273
+ /* eslint-enable */
1274
+ });
1275
+ }
1276
+ else {
1277
+ _this.parent.trigger(events.beforeFileUpload, args);
1278
+ }
1279
+ },
1280
+ uploading: function (e) {
1281
+ if (!_this.parent.isServerRendered) {
1282
+ _this.parent.trigger(events.fileUploading, e);
1283
+ }
1284
+ },
1285
+ success: function (e) {
1286
+ _this.parent.trigger(events.fileUploadSuccess, e, function (e) {
1287
+ if (!isNullOrUndefined(_this.parent.insertVideoSettings.path)) {
1288
+ var url = _this.parent.insertVideoSettings.path + e.file.name;
1289
+ // eslint-disable-next-line
1290
+ var value = { url: url, selection: save };
1291
+ proxy.uploadUrl = {
1292
+ url: url, selection: save, fileName: fileName, selectParent: selectParent,
1293
+ width: {
1294
+ width: proxy.parent.insertVideoSettings.width, minWidth: proxy.parent.insertVideoSettings.minWidth,
1295
+ maxWidth: proxy.parent.getInsertImgMaxWidth()
1296
+ },
1297
+ height: {
1298
+ height: proxy.parent.insertVideoSettings.height, minHeight: proxy.parent.insertVideoSettings.minHeight,
1299
+ maxHeight: proxy.parent.insertVideoSettings.maxHeight
1300
+ }
1301
+ };
1302
+ //proxy.inputUrl.setAttribute('disabled', 'true');
1303
+ proxy.embedInputUrl.setAttribute('disabled', 'true');
1304
+ }
1305
+ if (e.operation === 'upload' && !isNullOrUndefined(_this.dialogObj)) {
1306
+ _this.dialogObj.getButtons(0).element.removeAttribute('disabled');
1307
+ }
1308
+ });
1309
+ },
1310
+ failure: function (e) {
1311
+ _this.parent.trigger(events.fileUploadFailed, e);
1312
+ },
1313
+ removing: function () {
1314
+ // eslint-disable-next-line
1315
+ _this.parent.trigger(events.fileRemoving, e, function (e) {
1316
+ proxy.isVideoUploaded = false;
1317
+ _this.dialogObj.getButtons(0).element.disabled = true;
1318
+ //proxy.inputUrl.removeAttribute('disabled');
1319
+ proxy.embedInputUrl.removeAttribute('disabled');
1320
+ if (proxy.uploadUrl) {
1321
+ proxy.uploadUrl.url = '';
1322
+ }
1323
+ });
1324
+ }
1325
+ });
1326
+ this.uploadObj.isStringTemplate = true;
1327
+ this.uploadObj.createElement = this.parent.createElement;
1328
+ this.uploadObj.appendTo(uploadEle);
1329
+ return uploadParentEle;
1330
+ };
1331
+ Video.prototype.checkExtension = function (e) {
1332
+ if (this.uploadObj.allowedExtensions) {
1333
+ if (this.uploadObj.allowedExtensions.toLocaleLowerCase().indexOf(('.' + e.type).toLocaleLowerCase()) === -1) {
1334
+ this.dialogObj.getButtons(0).element.setAttribute('disabled', 'disabled');
1335
+ this.isAllowedTypes = false;
1336
+ }
1337
+ else {
1338
+ this.isAllowedTypes = true;
1339
+ }
1340
+ }
1341
+ };
1342
+ Video.prototype.fileSelect = function () {
1343
+ this.dialogObj.element.getElementsByClassName('e-file-select-wrap')[0].querySelector('button').click();
1344
+ return false;
1345
+ };
1346
+ // eslint-disable-next-line
1347
+ Video.prototype.cancelDialog = function (e) {
1348
+ this.parent.isBlur = false;
1349
+ this.dialogObj.hide({ returnValue: true });
1350
+ if (this.isVideoUploaded) {
1351
+ this.uploadObj.removing();
1352
+ }
1353
+ };
1354
+ // eslint-disable-next-line
1355
+ Video.prototype.insertVideoUrl = function (e) {
1356
+ var proxy = this.selfVideo;
1357
+ //let audioSelectParent: Node = proxy.uploadUrl.selectParent[0];
1358
+ proxy.isVideoUploaded = false;
1359
+ var url = proxy.inputUrl.value;
1360
+ var embedUrl = proxy.embedInputUrl.value;
1361
+ if (proxy.parent.formatter.getUndoRedoStack().length === 0) {
1362
+ proxy.parent.formatter.saveData();
1363
+ }
1364
+ if (!isNullOrUndefined(proxy.uploadUrl) && proxy.uploadUrl.url !== '') {
1365
+ proxy.uploadUrl.cssClass = (proxy.parent.insertVideoSettings.layoutOption === 'Inline' ?
1366
+ classes.CLS_VIDEOINLINE : classes.CLS_VIDEOBREAK);
1367
+ proxy.dialogObj.hide({ returnValue: false });
1368
+ proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, proxy.uploadUrl);
1369
+ proxy.uploadUrl.url = '';
1370
+ }
1371
+ else if (proxy.parent.editorMode === 'HTML' && (url !== '' || embedUrl !== '')) {
1372
+ if (proxy.parent.editorMode === 'HTML' && isNullOrUndefined(closest(
1373
+ // eslint-disable-next-line
1374
+ this.selection.range.startContainer.parentNode, '[id=' + "'" + proxy.contentModule.getPanel().id + "'" + ']'))) {
1375
+ proxy.contentModule.getEditPanel().focus();
1376
+ var range = proxy.parent.formatter.editorManager.nodeSelection.getRange(proxy.contentModule.getDocument());
1377
+ this.selection = proxy.parent.formatter.editorManager.nodeSelection.save(range, proxy.contentModule.getDocument());
1378
+ this.selectParent = proxy.parent.formatter.editorManager.nodeSelection.getParentNodeCollection(range);
1379
+ }
1380
+ var name_1 = url !== '' ? url.split('/')[url.split('/').length - 1] : embedUrl;
1381
+ var value = {
1382
+ cssClass: (proxy.parent.insertVideoSettings.layoutOption === 'Inline' ? classes.CLS_VIDEOINLINE : classes.CLS_VIDEOBREAK),
1383
+ url: url, selection: this.selection, fileName: name_1, isEmbedUrl: embedUrl !== '' ? true : false,
1384
+ selectParent: this.selectParent, width: {
1385
+ width: proxy.parent.insertVideoSettings.width, minWidth: proxy.parent.insertVideoSettings.minWidth,
1386
+ maxWidth: proxy.parent.getInsertImgMaxWidth()
1387
+ },
1388
+ height: {
1389
+ height: proxy.parent.insertVideoSettings.height, minHeight: proxy.parent.insertVideoSettings.minHeight,
1390
+ maxHeight: proxy.parent.insertVideoSettings.maxHeight
1391
+ }
1392
+ };
1393
+ proxy.parent.formatter.process(proxy.parent, this.args, this.args.originalEvent, value);
1394
+ proxy.dialogObj.hide({ returnValue: false });
1395
+ }
1396
+ };
1397
+ /* eslint-disable */
1398
+ /**
1399
+ * Destroys the ToolBar.
1400
+ *
1401
+ * @method destroy
1402
+ * @returns {void}
1403
+ * @hidden
1404
+
1405
+ */
1406
+ /* eslint-enable */
1407
+ Video.prototype.destroy = function () {
1408
+ this.prevSelectedVidEle = undefined;
1409
+ this.removeEventListener();
1410
+ };
1411
+ /**
1412
+ * For internal use only - Get the module name.
1413
+ *
1414
+ * @returns {void}
1415
+ * @hidden
1416
+ */
1417
+ Video.prototype.getModuleName = function () {
1418
+ return 'video';
1419
+ };
1420
+ return Video;
1421
+ }());
1422
+ export { Video };