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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155 | 1×
1×
1×
1×
1748×
1748×
1748×
1748×
1748×
1×
1748×
1748×
1748×
1748×
1748×
1×
3×
3×
2×
2×
1×
1×
3×
1×
1×
9×
9×
9×
9×
1×
596×
596×
124×
118×
124×
2×
124×
1×
143×
143×
143×
143×
143×
143×
9×
9×
9×
9×
9×
125×
125×
125×
125×
125×
7×
7×
125×
2×
2×
2×
2×
2×
7×
7×
7×
143×
143×
143×
143×
132×
143×
143×
143×
143×
1×
143×
11×
132×
123×
1×
150×
150×
150×
129×
21×
9×
1×
316×
7×
1×
7×
7×
1×
3476×
1729×
1747×
1747×
1747×
1747×
1747×
1747×
1747×
1747×
1747×
1747×
1×
32470×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../base/constant"], function (require, exports, ej2_base_1, events) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FormatPainter = (function () {
function FormatPainter(parent) {
this.isSticky = false;
this.isActive = false;
this.parent = parent;
this.addEventListener();
this.isDestroyed = false;
}
FormatPainter.prototype.addEventListener = function () {
this.parent.on(events.formatPainterClick, this.toolbarClick, this);
this.parent.on(events.formatPainterDoubleClick, this.toolbarDoubleClick, this);
this.parent.on(events.editAreaClick, this.editAreaClick, this);
this.parent.on(events.keyDown, this.onKeyDown, this);
this.parent.on(events.destroy, this.destroy, this);
};
FormatPainter.prototype.toolbarClick = function (clickargs) {
this.parent.focusIn();
if (!this.isSticky) {
this.isActive = true;
this.actionHandler(clickargs, 'click');
}
else {
clickargs.args.action = 'escape';
this.actionHandler(clickargs, 'keyBoard');
}
if (this.parent.quickToolbarModule && !ej2_base_1.isNullOrUndefined(this.parent.quickToolbarSettings.text) &&
this.parent.element.ownerDocument.contains(this.parent.quickToolbarModule.textQTBar.element)) {
this.parent.quickToolbarModule.textQTBar.hidePopup();
}
};
FormatPainter.prototype.toolbarDoubleClick = function (args) {
this.isActive = true;
this.isSticky = true;
this.parent.focusIn();
this.actionHandler(args, 'dbClick');
};
FormatPainter.prototype.onKeyDown = function (event) {
var originalEvent = event.args;
if (!ej2_base_1.isNullOrUndefined(originalEvent) && !ej2_base_1.isNullOrUndefined(originalEvent.action) && (originalEvent.action === 'format-copy' || originalEvent.action === 'format-paste')
|| (originalEvent.action === 'escape' && (this.previousAction === 'format-copy' || this.previousAction === 'format-paste'))) {
if ((originalEvent.action === 'format-copy' || originalEvent.action === 'format-paste')) {
originalEvent.stopPropagation();
}
if (ej2_base_1.Browser.userAgent.indexOf('Firefox') !== -1) {
originalEvent.preventDefault();
}
this.actionHandler(event, 'keyBoard');
}
};
FormatPainter.prototype.actionHandler = function (event, type) {
var action;
var isKeyboard = false;
var originalEvent;
var args;
var item;
switch (type) {
case 'dbClick':
args = event.args;
item = args.item;
originalEvent = event.args.originalEvent;
action = 'format-copy';
break;
case 'keyBoard':
args = null;
originalEvent = event.args;
isKeyboard = true;
action = event.args.action;
if (action === 'escape') {
this.isSticky = false;
this.isActive = false;
}
break;
case 'click':
args = event.args;
item = args.item;
originalEvent = event.args.originalEvent;
action = 'format-copy';
break;
case 'docClick':
originalEvent = event;
action = 'format-paste';
break;
}
this.updateCursor(isKeyboard);
var enable = type === 'docClick' || action === 'escape' ? false : true;
this.updateToolbarBtn(enable);
if (ej2_base_1.isNullOrUndefined(item)) {
item = {
command: 'FormatPainter',
subCommand: 'FormatPainter'
};
}
var actionBeginArgs = {
requestType: 'FormatPainter', originalEvent: originalEvent, name: action, item: item
};
var value = {
formatPainterAction: action
};
this.parent.formatter.process(this.parent, actionBeginArgs, originalEvent, value);
this.previousAction = action;
};
FormatPainter.prototype.updateCursor = function (isKeyboard) {
if (!this.parent.inputElement.classList.contains('e-rte-cursor-brush') && !isKeyboard) {
ej2_base_1.addClass([this.parent.inputElement], 'e-rte-cursor-brush');
}
else if (!this.isSticky) {
ej2_base_1.removeClass([this.parent.inputElement], 'e-rte-cursor-brush');
}
};
FormatPainter.prototype.updateToolbarBtn = function (enable) {
Eif (!ej2_base_1.isNullOrUndefined(this.parent.element.querySelector('.e-rte-format-painter'))) {
var toolbarBtn = this.parent.element.querySelector('.e-rte-format-painter').parentElement.parentElement;
if (enable) {
ej2_base_1.addClass([toolbarBtn], 'e-active');
}
else if (!this.isSticky) {
ej2_base_1.removeClass([toolbarBtn], 'e-active');
}
}
};
FormatPainter.prototype.editAreaClick = function (args) {
if (this.isActive) {
if (!this.isSticky) {
this.isActive = false;
}
this.actionHandler(args, 'docClick');
this.updateToolbarBtn(false);
}
};
FormatPainter.prototype.destroy = function () {
if (this.isDestroyed) {
return;
}
this.parent.off(events.formatPainterClick, this.toolbarClick);
this.parent.off(events.editAreaClick, this.editAreaClick);
this.parent.off(events.formatPainterDoubleClick, this.toolbarDoubleClick);
this.parent.off(events.keyDown, this.onKeyDown);
this.parent.off(events.destroy, this.destroy);
this.parent = null;
this.isSticky = null;
this.isActive = null;
this.previousAction = null;
this.isDestroyed = true;
};
FormatPainter.prototype.getModuleName = function () {
return 'formatPainter';
};
return FormatPainter;
}());
exports.FormatPainter = FormatPainter;
});
|