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