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 | 1×
1×
1×
1×
1892×
1892×
1892×
1×
1892×
1892×
1892×
1×
1747×
1747×
1747×
1×
452×
2×
2×
2×
2×
2×
2×
1×
91×
91×
91×
91×
91×
91×
91×
2×
91×
91×
91×
186×
70×
70×
116×
35×
35×
91×
42×
42×
42×
91×
81×
81×
81×
81×
53×
53×
28×
28×
91×
91×
91×
91×
91×
25×
1×
1747×
1×
1×
| define(["require", "exports", "./../base/constant", "./../../common/constant", "../../common/util"], function (require, exports, CONSTANT, EVENTS, util_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Indents = (function () {
function Indents(parent) {
this.indentValue = 20;
this.parent = parent;
this.addEventListener();
}
Indents.prototype.addEventListener = function () {
this.parent.observer.on(CONSTANT.INDENT_TYPE, this.applyIndents, this);
this.parent.observer.on(EVENTS.KEY_DOWN_HANDLER, this.onKeyDown, this);
this.parent.observer.on(EVENTS.INTERNAL_DESTROY, this.destroy, this);
};
Indents.prototype.removeEventListener = function () {
this.parent.observer.off(CONSTANT.INDENT_TYPE, this.applyIndents);
this.parent.observer.off(EVENTS.KEY_DOWN_HANDLER, this.onKeyDown);
this.parent.observer.off(EVENTS.INTERNAL_DESTROY, this.destroy);
};
Indents.prototype.onKeyDown = function (e) {
switch (e.event.action) {
case 'indents':
this.applyIndents({ subCommand: 'Indent', callBack: e.callBack });
e.event.preventDefault();
break;
case 'outdents':
this.applyIndents({ subCommand: 'Outdent', callBack: e.callBack });
e.event.preventDefault();
break;
}
};
Indents.prototype.applyIndents = function (e) {
var editEle = this.parent.editableElement;
var isRtl = editEle.classList.contains('e-rtl');
var range = this.parent.nodeSelection.getRange(this.parent.currentDocument);
var save = this.parent.nodeSelection.save(range, this.parent.currentDocument);
this.parent.domNode.setMarker(save);
var indentsNodes = this.parent.domNode.blockNodes();
if (e.enterAction === 'BR') {
indentsNodes = this.parent.domNode.convertToBlockNodes(indentsNodes, false);
}
var parentNodes = indentsNodes.slice();
var listsNodes = [];
for (var i = 0; i < parentNodes.length; i++) {
if (parentNodes[i].tagName !== 'LI' && 'LI' === parentNodes[i].parentNode.tagName) {
indentsNodes.splice(indentsNodes.indexOf(parentNodes[i]), 1);
listsNodes.push(parentNodes[i].parentNode);
}
else if (parentNodes[i].tagName === 'LI') {
indentsNodes.splice(indentsNodes.indexOf(parentNodes[i]), 1);
listsNodes.push(parentNodes[i]);
}
}
if (listsNodes.length > 0) {
this.parent.observer.notify(EVENTS.KEY_DOWN_HANDLER, {
event: {
preventDefault: function () {
return;
},
stopPropagation: function () {
return;
},
shiftKey: (e.subCommand === 'Indent' ? false : true),
which: 9,
action: 'indent'
}
});
}
for (var i = 0; i < indentsNodes.length; i++) {
var parentNode = indentsNodes[i];
var marginLeftOrRight = isRtl ? parentNode.style.marginRight : parentNode.style.marginLeft;
var indentsValue = void 0;
if (e.subCommand === 'Indent') {
indentsValue = marginLeftOrRight === '' ? this.indentValue + 'px' : parseInt(marginLeftOrRight, null) + this.indentValue + 'px';
isRtl ? (parentNode.style.marginRight = indentsValue) : (parentNode.style.marginLeft = indentsValue);
}
else {
indentsValue = (marginLeftOrRight === '' || marginLeftOrRight === '0px' || marginLeftOrRight === '0in') ? '' : parseInt(marginLeftOrRight, null) - this.indentValue + 'px';
isRtl ? (parentNode.style.marginRight = indentsValue) : (parentNode.style.marginLeft = indentsValue);
}
}
editEle.focus({ preventScroll: true });
Iif (util_1.isIDevice()) {
util_1.setEditFrameFocus(editEle, e.selector);
}
save = this.parent.domNode.saveMarker(save);
save.restore();
if (e.callBack) {
e.callBack({
requestType: e.subCommand,
editorMode: 'HTML',
event: e.event,
range: this.parent.nodeSelection.getRange(this.parent.currentDocument),
elements: this.parent.domNode.blockNodes()
});
}
};
Indents.prototype.destroy = function () {
this.removeEventListener();
};
return Indents;
}());
exports.Indents = Indents;
});
|