-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
underlineui.js
61 lines (50 loc) · 1.31 KB
/
underlineui.js
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
/**
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
/**
* @module basic-styles/underline/underlineui
*/
import { Plugin } from 'ckeditor5/src/core';
import { ButtonView } from 'ckeditor5/src/ui';
import underlineIcon from '../../theme/icons/underline.svg';
const UNDERLINE = 'underline';
/**
* The underline UI feature. It introduces the Underline button.
*
* @extends module:core/plugin~Plugin
*/
export default class UnderlineUI extends Plugin {
/**
* @inheritDoc
*/
static get pluginName() {
return 'UnderlineUI';
}
/**
* @inheritDoc
*/
init() {
const editor = this.editor;
const t = editor.t;
// Add bold button to feature components.
editor.ui.componentFactory.add( UNDERLINE, locale => {
const command = editor.commands.get( UNDERLINE );
const view = new ButtonView( locale );
view.set( {
label: t( 'Underline' ),
icon: underlineIcon,
keystroke: 'CTRL+U',
tooltip: true,
isToggleable: true
} );
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
// Execute command.
this.listenTo( view, 'execute', () => {
editor.execute( UNDERLINE );
editor.editing.view.focus();
} );
return view;
} );
}
}