-
Notifications
You must be signed in to change notification settings - Fork 10
/
rich-text-editor.t.font.html
82 lines (76 loc) · 2.56 KB
/
rich-text-editor.t.font.html
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
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Demo</title>
<link href="rich-text-editor.min.css" rel="stylesheet">
</head>
<body>
<h1>Custom Tool: Font</h1>
<p><textarea>Lorem ipsum dolor sit amet.</textarea></p>
<script src="rich-text-editor.min.js"></script>
<script>
var editor = new RTE(document.querySelector('textarea')),
font_sizes = [
false, // inherit
125,
150,
175,
200,
250,
275,
300,
25,
50,
75
],
font_sizes_count = font_sizes.length,
font_sizes_i = 0,
font_faces = [
false, // inherit
'arial,sans-serif',
'times new roman,serif',
'georgia,serif',
'verdana,sans-serif',
'tahoma,sans-serif',
'trebuchet ms,sans-serif',
'courier new,courier,monospace'
],
font_faces_count = font_faces.length,
font_faces_i = 0;
// font size
editor.t('font', ['Font Size', 'svg:M2 8v-2h6v2h-2v4.656h-2v-4.656h-2zM6 2.656h8.656v2h-3.313v8h-2v-8h-3.344v-2z'], function() {
var font = this.e('span') || this.w('span', 1); // force wrap
++font_sizes_i;
if (font_sizes_i > font_sizes_count - 1) {
font_sizes_i = 0;
}
if (font_sizes_i !== 0) {
font.style.fontSize = font_sizes[font_sizes_i] + '%';
} else {
font.style.fontSize = "";
if (!font.getAttribute('style')) {
this.w('span', 0); // force unwrap
}
}
}, -1);
// font family
editor.t('font', ['Font Family', 'svg:M10.625 12.344h1.406l-3.406-8.688h-1.25l-3.406 8.688h1.406l0.75-2h3.75zM13.344 1.344c0.719 0 1.313 0.594 1.313 1.313v10.688c0 0.719-0.594 1.313-1.313 1.313h-10.688c-0.719 0-1.313-0.594-1.313-1.313v-10.688c0-0.719 0.594-1.313 1.313-1.313h10.688zM6.625 9l1.375-3.688 1.375 3.688h-2.75z'], function() {
var font = this.e('span') || this.w('span', 1); // force wrap
++font_faces_i;
if (font_faces_i > font_faces_count - 1) {
font_faces_i = 0;
}
if (font_faces_i !== 0) {
font.style.fontFamily = font_faces[font_faces_i];
} else {
font.style.fontFamily = "";
if (!font.getAttribute('style')) {
this.w('span', 0); // force unwrap
}
}
}, -1);
</script>
</body>
</html>