1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import { Plugin } from 'ckeditor5/src/core';
|
11 | import { ButtonView } from 'ckeditor5/src/ui';
|
12 |
|
13 | import underlineIcon from '../../theme/icons/underline.svg';
|
14 |
|
15 | const UNDERLINE = 'underline';
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export default class UnderlineUI extends Plugin {
|
23 | |
24 |
|
25 |
|
26 | static get pluginName() {
|
27 | return 'UnderlineUI';
|
28 | }
|
29 |
|
30 | |
31 |
|
32 |
|
33 | init() {
|
34 | const editor = this.editor;
|
35 | const t = editor.t;
|
36 |
|
37 |
|
38 | editor.ui.componentFactory.add( UNDERLINE, locale => {
|
39 | const command = editor.commands.get( UNDERLINE );
|
40 | const view = new ButtonView( locale );
|
41 |
|
42 | view.set( {
|
43 | label: t( 'Underline' ),
|
44 | icon: underlineIcon,
|
45 | keystroke: 'CTRL+U',
|
46 | tooltip: true,
|
47 | isToggleable: true
|
48 | } );
|
49 |
|
50 | view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
|
51 |
|
52 |
|
53 | this.listenTo( view, 'execute', () => {
|
54 | editor.execute( UNDERLINE );
|
55 | editor.editing.view.focus();
|
56 | } );
|
57 |
|
58 | return view;
|
59 | } );
|
60 | }
|
61 | }
|