-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathinline-tool-bold.ts
More file actions
58 lines (52 loc) · 1.09 KB
/
inline-tool-bold.ts
File metadata and controls
58 lines (52 loc) · 1.09 KB
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
import type { InlineTool, SanitizerConfig } from '../../../types';
import { IconBold } from '@codexteam/icons';
import type { MenuConfig } from '../../../types/tools';
/**
* Bold Tool
*
* Inline Toolbar Tool
*
* Makes selected text bold
*/
export default class BoldInlineTool implements InlineTool {
/**
* Specifies Tool as Inline Toolbar Tool
*/
public static isInline = true;
/**
* Title for hover-tooltip
*/
public static title = 'Bold';
/**
* Sanitizer Rule
* Leave <b> tags
*/
public static get sanitize(): SanitizerConfig {
return {
b: {},
};
}
/**
* Native Document's command that uses for Bold
*/
private readonly commandName: string = 'bold';
/**
* Create button for Inline Toolbar
*/
public render(): MenuConfig {
return {
icon: IconBold,
name: 'bold',
onActivate: () => {
document.execCommand(this.commandName);
},
isActive: () => document.queryCommandState(this.commandName),
};
}
/**
* Set a shortcut
*/
public get shortcut(): string {
return 'CMD+B';
}
}