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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215 | 1×
1×
1×
1×
1×
28×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
7×
7×
2×
2×
1×
1×
1×
1×
1×
1×
1×
1×
1×
1×
7×
1×
1×
1×
1×
1×
9×
9×
1×
1×
1×
66×
1×
80×
1×
1×
1×
1×
2×
2×
1×
1×
| define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var FontHelper = (function () {
function FontHelper() {
}
FontHelper.getHighlightColorItems = function (localObj, id) {
return [
{ id: id + '_yellow', text: localObj.getConstant('Yellow'), backgroundColor: 'rgb(255, 255, 0)' },
{ id: id + '_bright-green', text: localObj.getConstant('Bright Green'), backgroundColor: 'rgb(0, 255, 0)' },
{ id: id + '_turquoise', text: localObj.getConstant('Turquoise'), backgroundColor: 'rgb(0, 255, 255)' },
{ id: id + '_pink', text: localObj.getConstant('Pink'), backgroundColor: 'rgb(255, 0, 255)' },
{ id: id + '_blue', text: localObj.getConstant('Blue'), backgroundColor: 'rgb(0, 0, 255)' },
{ id: id + '_red', text: localObj.getConstant('Red'), backgroundColor: 'rgb(255, 0, 0)' },
{ id: id + '_dark-blue', text: localObj.getConstant('Dark Blue'), backgroundColor: 'rgb(0, 0, 128)' },
{ id: id + '_teal', text: localObj.getConstant('Teal'), backgroundColor: 'rgb(0, 128, 128)' },
{ id: id + '_green', text: localObj.getConstant('Green'), backgroundColor: 'rgb(0, 128, 0)' },
{ id: id + '_violet', text: localObj.getConstant('Violet'), backgroundColor: 'rgb(128, 0, 128)' },
{ id: id + '_dark-red', text: localObj.getConstant('Dark Red'), backgroundColor: 'rgb(128, 0, 0)' },
{ id: id + '_dark-yellow', text: localObj.getConstant('Dark Yellow'), backgroundColor: 'rgb(128, 128, 0)' },
{ id: id + '_gray-50', text: localObj.getConstant('Gray 50'), backgroundColor: 'rgb(128, 128, 128)' },
{ id: id + '_gray-25', text: localObj.getConstant('Gray 25'), backgroundColor: 'rgb(192, 192, 192)' },
{ id: id + '_black', text: localObj.getConstant('Black'), backgroundColor: 'rgb(0, 0, 0)' },
{ id: id + '_no-color', text: localObj.getConstant('No color'), backgroundColor: 'transparent' }
];
};
FontHelper.getHighlightColor = function (color) {
switch (color) {
case 'rgb(255, 255, 0)':
return 'Yellow';
case 'rgb(0, 255, 0)':
return 'BrightGreen';
case 'rgb(0, 255, 255)':
return 'Turquoise';
case 'rgb(255, 0, 255)':
return 'Pink';
case 'rgb(0, 0, 255)':
return 'Blue';
case 'rgb(255, 0, 0)':
return 'Red';
case 'rgb(0, 0, 128)':
return 'DarkBlue';
case 'rgb(0, 128, 128)':
return 'Teal';
case 'rgb(0, 128, 0)':
return 'Green';
case 'rgb(128, 0, 128)':
return 'Violet';
case 'rgb(128, 0, 0)':
return 'DarkRed';
case 'rgb(128, 128, 0)':
return 'DarkYellow';
case 'rgb(128, 128, 128)':
return 'Gray50';
case 'rgb(192, 192, 192)':
return 'Gray25';
case 'rgb(0, 0, 0)':
return 'Black';
default:
return 'NoColor';
}
};
FontHelper.getBackgroundColorFromHighlightColor = function (highlightColor) {
switch (highlightColor) {
case 'Yellow':
return 'rgb(255, 255, 0)';
case 'BrightGreen':
return 'rgb(0, 255, 0)';
case 'Turquoise':
return 'rgb(0, 255, 255)';
case 'Pink':
return 'rgb(255, 0, 255)';
case 'Blue':
return 'rgb(0, 0, 255)';
case 'Red':
return 'rgb(255, 0, 0)';
case 'DarkBlue':
return 'rgb(0, 0, 128)';
case 'Teal':
return 'rgb(0, 128, 128)';
case 'Green':
return 'rgb(0, 128, 0)';
case 'Violet':
return 'rgb(128, 0, 128)';
case 'DarkRed':
return 'rgb(128, 0, 0)';
case 'DarkYellow':
return 'rgb(128, 128, 0)';
case 'Gray50':
return 'rgb(128, 128, 128)';
case 'Gray25':
return 'rgb(192, 192, 192)';
case 'Black':
return 'rgb(0, 0, 0)';
default:
return 'transparent';
}
};
FontHelper.applyHighlightColor = function (documentEditor, color) {
Eif (documentEditor.selectionModule && documentEditor.selectionModule.characterFormat) {
var highlightColor = FontHelper.getHighlightColor(color);
documentEditor.selectionModule.characterFormat.highlightColor = highlightColor;
documentEditor.focusIn();
}
return color;
};
FontHelper.applyFontFormatting = function (documentEditor, action) {
Iif (documentEditor.isReadOnly || !documentEditor.editorModule) {
return;
}
switch (action) {
case 'bold':
documentEditor.editorModule.toggleBold();
break;
case 'italic':
documentEditor.editorModule.toggleItalic();
break;
case 'underline':
documentEditor.editorModule.toggleUnderline('Single');
break;
case 'strikethrough':
documentEditor.editorModule.toggleStrikethrough();
break;
case 'superscript':
documentEditor.selection.characterFormat.baselineAlignment =
documentEditor.selection.characterFormat.baselineAlignment === 'Superscript' ? 'Normal' : 'Superscript';
break;
case 'subscript':
documentEditor.selection.characterFormat.baselineAlignment =
documentEditor.selection.characterFormat.baselineAlignment === 'Subscript' ? 'Normal' : 'Subscript';
break;
case 'clearFormat':
documentEditor.editorModule.clearFormatting();
break;
}
documentEditor.focusIn();
};
FontHelper.applyChangeCase = function (documentEditor, localObj, caseType) {
if (documentEditor.isReadOnly || !documentEditor.editorModule) {
return;
}
switch (caseType) {
case localObj.getConstant('SentenceCase'):
documentEditor.editorModule.changeCase('SentenceCase');
break;
case localObj.getConstant('UPPERCASE'):
documentEditor.editorModule.changeCase('Uppercase');
break;
case localObj.getConstant('Lowercase'):
documentEditor.editorModule.changeCase('Lowercase');
break;
case localObj.getConstant('CapitalizeEachWord'):
documentEditor.editorModule.changeCase('CapitalizeEachWord');
break;
case localObj.getConstant('ToggleCase'):
documentEditor.editorModule.changeCase('ToggleCase');
break;
}
documentEditor.focusIn();
};
FontHelper.changeFontFamily = function (documentEditor, fontFamily) {
Eif (!documentEditor.isReadOnly && documentEditor.selection) {
documentEditor.selection.characterFormat.fontFamily = fontFamily;
}
};
FontHelper.changeFontSize = function (documentEditor, fontSize) {
Eif (!documentEditor.isReadOnly && documentEditor.selection) {
documentEditor.selection.characterFormat.fontSize = typeof fontSize === 'string' ?
parseInt(fontSize, 10) : fontSize;
}
};
FontHelper.changeFontColor = function (documentEditor, color) {
if (!documentEditor.isReadOnly && documentEditor.selection) {
documentEditor.selection.characterFormat.fontColor = color;
}
};
FontHelper.updateToggleButtonState = function (button, isActive) {
if (button) {
if (isActive) {
button.classList.add('e-active');
button.setAttribute('aria-pressed', 'true');
}
else {
button.classList.remove('e-active');
button.setAttribute('aria-pressed', 'false');
}
}
};
FontHelper.getFontSizeItems = function () {
return ['8', '9', '10', '11', '12', '14', '16', '18', '20', '22', '24', '26', '28', '36', '48', '72', '96'];
};
FontHelper.getChangeCaseItems = function (localObj, commonId) {
return [
{ text: localObj.getConstant('SentenceCase'), id: commonId + '_sentencecase' },
{ text: localObj.getConstant('UPPERCASE'), id: commonId + '_uppercase' },
{ text: localObj.getConstant('Lowercase'), id: commonId + '_lowercase' },
{ text: localObj.getConstant('CapitalizeEachWord'), id: commonId + '_capitalizeEachWord' },
{ text: localObj.getConstant('ToggleCase'), id: commonId + '_togglecase' }
];
};
FontHelper.increaseFontSize = function (documentEditor) {
Eif (!documentEditor.isReadOnlyMode || documentEditor.selection.isInlineFormFillMode()) {
documentEditor.editor.onApplyCharacterFormat('fontSize', 'increment', true);
}
};
FontHelper.decreaseFontSize = function (documentEditor) {
Eif (!documentEditor.isReadOnlyMode || documentEditor.selection.isInlineFormFillMode()) {
documentEditor.editor.onApplyCharacterFormat('fontSize', 'decrement', true);
}
};
return FontHelper;
}());
exports.FontHelper = FontHelper;
});
|