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 | 1×
1×
1×
1×
1907×
1907×
1×
1907×
1907×
1907×
1×
1762×
1762×
1762×
1×
457×
457×
21×
21×
21×
1×
208×
208×
1×
229×
219×
1×
1762×
1×
1×
| define(["require", "exports", "./../base/constant", "./selection-commands", "./../../common/constant"], function (require, exports, CONSTANT, selection_commands_1, EVENTS) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var SelectionBasedExec = (function () {
function SelectionBasedExec(parent) {
this.parent = parent;
this.addEventListener();
}
SelectionBasedExec.prototype.addEventListener = function () {
this.parent.observer.on(CONSTANT.SELECTION_TYPE, this.applySelection, this);
this.parent.observer.on(EVENTS.KEY_DOWN_HANDLER, this.keyDownHandler, this);
this.parent.observer.on(EVENTS.INTERNAL_DESTROY, this.destroy, this);
};
SelectionBasedExec.prototype.removeEventListener = function () {
this.parent.observer.off(CONSTANT.SELECTION_TYPE, this.applySelection);
this.parent.observer.off(EVENTS.KEY_DOWN_HANDLER, this.keyDownHandler);
this.parent.observer.off(EVENTS.INTERNAL_DESTROY, this.destroy);
};
SelectionBasedExec.prototype.keyDownHandler = function (e) {
var validFormats = ['bold', 'italic', 'underline', 'strikethrough', 'superscript',
'subscript', 'uppercase', 'lowercase', 'inlinecode'];
if ((e.event.ctrlKey || e.event.metaKey) && validFormats.indexOf(e.event.action) > -1) {
e.event.preventDefault();
selection_commands_1.SelectionCommands.applyFormat(this.parent.currentDocument, e.event.action, this.parent.editableElement, e.enterAction, this.parent.tableCellSelection);
this.callBack(e, e.event.action);
}
};
SelectionBasedExec.prototype.applySelection = function (e) {
selection_commands_1.SelectionCommands.applyFormat(this.parent.currentDocument, e.subCommand.toLocaleLowerCase(), this.parent.editableElement, e.enterAction, this.parent.tableCellSelection, e.value, e.selector);
this.callBack(e, e.subCommand);
};
SelectionBasedExec.prototype.callBack = function (event, action) {
if (event.callBack) {
event.callBack({
requestType: action,
event: event.event,
editorMode: 'HTML',
range: this.parent.nodeSelection.getRange(this.parent.currentDocument),
elements: this.parent.nodeSelection.getSelectedNodes(this.parent.currentDocument)
});
}
};
SelectionBasedExec.prototype.destroy = function () {
this.removeEventListener();
};
return SelectionBasedExec;
}());
exports.SelectionBasedExec = SelectionBasedExec;
});
|