-
Notifications
You must be signed in to change notification settings - Fork 1
/
Text.ts
93 lines (77 loc) · 1.92 KB
/
Text.ts
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
import { Tool } from '../Tool';
export abstract class BoldTool extends Tool {
name = 'Bold';
tags = ['b', 'strong'];
keys = ['Ctrl', 'B'];
command = 'bold';
}
export abstract class ItalicTool extends Tool {
name = 'Italic';
tags = ['i', 'em'];
keys = ['Ctrl', 'I'];
command = 'italic';
}
export abstract class UnderlineTool extends Tool {
name = 'Underline';
tags = ['u'];
keys = ['Ctrl', 'U'];
command = 'underline';
}
export abstract class StrikeThroughTool extends Tool {
name = 'Strike through';
tags = ['s', 'del', 'strike'];
command = 'strikeThrough';
}
const HeadingCommand = document.queryCommandSupported('heading')
? 'heading'
: 'formatBlock';
export abstract class H1Tool extends Tool {
name = 'H1';
tags = ['h1'];
command = HeadingCommand;
execute(editor: HTMLElement) {
this.edit(editor, 'H1');
}
}
export abstract class H2Tool extends Tool {
name = 'H2';
tags = ['h2'];
command = HeadingCommand;
execute(editor: HTMLElement) {
this.edit(editor, 'H2');
}
}
export abstract class H3Tool extends Tool {
name = 'H3';
tags = ['h3'];
command = HeadingCommand;
execute(editor: HTMLElement) {
this.edit(editor, 'H3');
}
}
export abstract class FontSizeDownTool extends Tool {
name = 'Font Size down';
tags = ['small'];
command = 'decreaseFontSize';
}
export abstract class FontSizeUpTool extends Tool {
name = 'Font Size up';
tags = ['big'];
command = 'increaseFontSize';
}
export abstract class SubscriptTool extends Tool {
name = 'Subscript';
tags = ['sub'];
command = 'subscript';
}
export abstract class SuperscriptTool extends Tool {
name = 'Superscript';
tags = ['sup'];
command = 'superscript';
}
export abstract class LinkTool extends Tool {
name = 'Link';
tags = ['a'];
inputs = ['Path'];
command = 'createLink';
}