| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117 | 1×
1×
1×
1×
1390×
1×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1390×
1×
1829×
1×
1066×
1×
171×
1×
14×
1×
85×
1×
195×
1×
1051×
1051×
1050×
1050×
871×
179×
1×
79×
79×
79×
79×
79×
68×
1×
747×
1×
39×
1×
85×
1×
4×
1×
1×
1×
1×
1×
1×
1390×
1390×
1×
1×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../../common/utils/index", "../../common/constant", "../../common/constant"], function (require, exports, ej2_base_1, index_1, constants, constant_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var EventManager = (function () {
function EventManager(editor) {
this.editor = editor;
}
EventManager.prototype.wireGlobalEvents = function () {
ej2_base_1.EventHandler.add(document, 'selectionchange', this.handleEditorSelection, this);
ej2_base_1.EventHandler.add(document, 'mousedown', this.handleDocumentClickActions, this);
ej2_base_1.EventHandler.add(document, 'mousemove', this.handleMouseMoveActions, this);
ej2_base_1.EventHandler.add(window, 'resize', this.onResizeHandler, this);
ej2_base_1.EventHandler.add(this.editor.element, 'mouseup', this.handleMouseUpActions, this);
ej2_base_1.EventHandler.add(this.editor.element, 'mousedown', this.handleMouseDownActions, this);
ej2_base_1.EventHandler.add(this.editor.element, 'input', this.handleEditorInputActions, this);
ej2_base_1.EventHandler.add(this.editor.element, 'keydown', this.handleKeydownActions, this);
ej2_base_1.EventHandler.add(this.editor.element, 'click', this.handleEditorClickActions, this);
ej2_base_1.EventHandler.add(this.editor.element, 'copy', this.clipboardActionHandler, this);
ej2_base_1.EventHandler.add(this.editor.element, 'cut', this.clipboardActionHandler, this);
ej2_base_1.EventHandler.add(this.editor.element, 'paste', this.clipboardActionHandler, this);
ej2_base_1.EventHandler.add(this.editor.blockContainer, 'focus', this.handleEditorFocusActions, this);
ej2_base_1.EventHandler.add(this.editor.blockContainer, 'blur', this.handleEditorBlurActions, this);
this.editor.on(constant_1.events.destroy, this.destroy, this);
};
EventManager.prototype.unWireGlobalEvents = function () {
ej2_base_1.EventHandler.remove(document, 'selectionchange', this.handleEditorSelection);
ej2_base_1.EventHandler.remove(document, 'mousedown', this.handleDocumentClickActions);
ej2_base_1.EventHandler.remove(document, 'mousemove', this.handleMouseMoveActions);
ej2_base_1.EventHandler.remove(window, 'resize', this.onResizeHandler);
ej2_base_1.EventHandler.remove(this.editor.element, 'mouseup', this.handleMouseUpActions);
ej2_base_1.EventHandler.remove(this.editor.element, 'mousedown', this.handleMouseDownActions);
ej2_base_1.EventHandler.remove(this.editor.element, 'input', this.handleEditorInputActions);
ej2_base_1.EventHandler.remove(this.editor.element, 'keydown', this.handleKeydownActions);
ej2_base_1.EventHandler.remove(this.editor.element, 'click', this.handleEditorClickActions);
ej2_base_1.EventHandler.remove(this.editor.element, 'copy', this.clipboardActionHandler);
ej2_base_1.EventHandler.remove(this.editor.element, 'cut', this.clipboardActionHandler);
ej2_base_1.EventHandler.remove(this.editor.element, 'paste', this.clipboardActionHandler);
ej2_base_1.EventHandler.remove(this.editor.blockContainer, 'focus', this.handleEditorFocusActions);
ej2_base_1.EventHandler.remove(this.editor.blockContainer, 'blur', this.handleEditorBlurActions);
this.editor.off(constant_1.events.destroy, this.destroy);
};
EventManager.prototype.triggerBlockChangeEvent = function (args) {
this.editor.trigger('blockChanged', args);
};
EventManager.prototype.handleEditorSelection = function () {
this.editor.intermediate.processActions('selectionchange');
};
EventManager.prototype.handleMouseMoveActions = function (moveEvent) {
this.editor.intermediate.processActions('mousemove', moveEvent);
};
EventManager.prototype.handleEditorInputActions = function (inputEvent) {
this.editor.intermediate.processActions('input', inputEvent);
};
EventManager.prototype.handleDocumentClickActions = function (clickEvent) {
this.editor.intermediate.processActions('documentClick', clickEvent);
};
EventManager.prototype.handleEditorClickActions = function (clickEvent) {
this.editor.intermediate.processActions('editorClick', clickEvent);
};
EventManager.prototype.handleEditorFocusActions = function (focusEvent) {
var _this = this;
setTimeout(function () {
var range = index_1.getSelectedRange();
if (!range || !_this.editor.blockManager.currentFocusedBlock) {
return;
}
_this.editor.trigger('focus', {
event: focusEvent,
blockId: _this.editor.blockManager.currentFocusedBlock.id,
selectionRange: [range.startOffset, range.endOffset]
});
}, 200);
};
EventManager.prototype.handleEditorBlurActions = function (blurEvent) {
var inlineTbarPopup = document.querySelector('#' + this.editor.element.id + constants.INLINE_TBAR_POPUP_ID);
var contextMenuPopup = document.querySelector('#' + this.editor.element.id + constants.BLOCKEDITOR_CONTEXTMENU_ID);
var shouldPreventBlurAction = (inlineTbarPopup && inlineTbarPopup.contains(blurEvent.relatedTarget))
|| (contextMenuPopup && contextMenuPopup.contains(blurEvent.relatedTarget));
var block = this.editor.blockManager.currentFocusedBlock;
if (!shouldPreventBlurAction) {
this.editor.trigger('blur', {
event: blurEvent,
blockId: block ? block.id : ''
});
}
};
EventManager.prototype.handleKeydownActions = function (keyEvent) {
this.editor.intermediate.processActions('keydown', keyEvent);
};
EventManager.prototype.handleMouseUpActions = function (mouseEvent) {
this.editor.intermediate.processActions('mouseup', mouseEvent);
};
EventManager.prototype.handleMouseDownActions = function (mouseEvent) {
this.editor.intermediate.processActions('mousedown', mouseEvent);
};
EventManager.prototype.clipboardActionHandler = function (e) {
this.editor.intermediate.processActions('clipboardAction', e);
};
EventManager.prototype.onResizeHandler = function () {
var _this = this;
clearTimeout(this.resizeTimer);
this.resizeTimer = setTimeout(function () {
_this.editor.intermediate.processActions('resize');
}, 10);
};
EventManager.prototype.destroy = function () {
this.unWireGlobalEvents();
if (!ej2_base_1.isNullOrUndefined(this.resizeTimer)) {
clearInterval(this.resizeTimer);
this.resizeTimer = null;
}
};
return EventManager;
}());
exports.EventManager = EventManager;
});
|