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 strikethroughIcon from '../../theme/icons/strikethrough.svg';
|
14 |
|
15 | const STRIKETHROUGH = 'strikethrough';
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export default class StrikethroughUI extends Plugin {
|
23 | |
24 |
|
25 |
|
26 | static get pluginName() {
|
27 | return 'StrikethroughUI';
|
28 | }
|
29 |
|
30 | |
31 |
|
32 |
|
33 | init() {
|
34 | const editor = this.editor;
|
35 | const t = editor.t;
|
36 |
|
37 |
|
38 | editor.ui.componentFactory.add( STRIKETHROUGH, locale => {
|
39 | const command = editor.commands.get( STRIKETHROUGH );
|
40 | const view = new ButtonView( locale );
|
41 |
|
42 | view.set( {
|
43 | label: t( 'Strikethrough' ),
|
44 | icon: strikethroughIcon,
|
45 | keystroke: 'CTRL+SHIFT+X',
|
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( STRIKETHROUGH );
|
55 | editor.editing.view.focus();
|
56 | } );
|
57 |
|
58 | return view;
|
59 | } );
|
60 | }
|
61 | }
|