Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 51a4b61

Browse files
authored
Merge pull request #65 from ckeditor/t/ckeditor5/488
Other: Align feature class naming to a new scheme.
2 parents 5cccbe8 + 2c43e03 commit 51a4b61

30 files changed

+798
-641
lines changed

src/bold.js

+6-38
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
*/
99

1010
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11-
import BoldEngine from './boldengine';
12-
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
13-
import boldIcon from '../theme/icons/bold.svg';
11+
import BoldEditing from './bold/boldediting';
12+
import BoldUI from './bold/boldui';
1413

1514
/**
16-
* The bold feature. It introduces the Bold button and the <kbd>Ctrl+B</kbd> keystroke.
15+
* The bold feature.
1716
*
18-
* It uses the {@link module:basic-styles/boldengine~BoldEngine bold engine feature}.
17+
* It loads the {@link module:basic-styles/bold/boldediting~BoldEditing bold editing feature}
18+
* and {@link module:basic-styles/bold/boldui~BoldUI bold UI feature}.
1919
*
2020
* @extends module:core/plugin~Plugin
2121
*/
@@ -24,7 +24,7 @@ export default class Bold extends Plugin {
2424
* @inheritDoc
2525
*/
2626
static get requires() {
27-
return [ BoldEngine ];
27+
return [ BoldEditing, BoldUI ];
2828
}
2929

3030
/**
@@ -33,36 +33,4 @@ export default class Bold extends Plugin {
3333
static get pluginName() {
3434
return 'Bold';
3535
}
36-
37-
/**
38-
* @inheritDoc
39-
*/
40-
init() {
41-
const editor = this.editor;
42-
const t = editor.t;
43-
const command = editor.commands.get( 'bold' );
44-
const keystroke = 'CTRL+B';
45-
46-
// Add bold button to feature components.
47-
editor.ui.componentFactory.add( 'bold', locale => {
48-
const view = new ButtonView( locale );
49-
50-
view.set( {
51-
label: t( 'Bold' ),
52-
icon: boldIcon,
53-
keystroke,
54-
tooltip: true
55-
} );
56-
57-
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
58-
59-
// Execute command.
60-
this.listenTo( view, 'execute', () => editor.execute( 'bold' ) );
61-
62-
return view;
63-
} );
64-
65-
// Set the Ctrl+B keystroke.
66-
editor.keystrokes.set( keystroke, 'bold' );
67-
}
6836
}

src/boldengine.js renamed to src/bold/boldediting.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,28 @@
44
*/
55

66
/**
7-
* @module basic-styles/boldengine
7+
* @module basic-styles/bold/boldediting
88
*/
99

1010
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11-
import AttributeCommand from './attributecommand';
11+
import AttributeCommand from '../attributecommand';
1212

1313
const BOLD = 'bold';
1414

1515
/**
16-
* The bold engine feature.
16+
* The bold editing feature.
1717
*
1818
* It registers the `bold` command and introduces the `bold` attribute in the model which renders to the view
1919
* as a `<strong>` element.
2020
*
2121
* @extends module:core/plugin~Plugin
2222
*/
23-
export default class BoldEngine extends Plugin {
23+
export default class BoldEditing extends Plugin {
2424
/**
2525
* @inheritDoc
2626
*/
2727
init() {
2828
const editor = this.editor;
29-
3029
// Allow bold attribute on text nodes.
3130
editor.model.schema.extend( '$text', { allowAttributes: BOLD } );
3231

@@ -47,5 +46,8 @@ export default class BoldEngine extends Plugin {
4746

4847
// Create bold command.
4948
editor.commands.add( BOLD, new AttributeCommand( editor, BOLD ) );
49+
50+
// Set the Ctrl+B keystroke.
51+
editor.keystrokes.set( 'CTRL+B', BOLD );
5052
}
5153
}

src/bold/boldui.js

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
3+
* For licensing, see LICENSE.md.
4+
*/
5+
6+
/**
7+
* @module basic-styles/bold/boldui
8+
*/
9+
10+
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11+
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
12+
13+
import boldIcon from '../../theme/icons/bold.svg';
14+
15+
const BOLD = 'bold';
16+
17+
/**
18+
* The bold UI feature. It introduces the Bold button.
19+
*
20+
* @extends module:core/plugin~Plugin
21+
*/
22+
export default class BoldUI extends Plugin {
23+
/**
24+
* @inheritDoc
25+
*/
26+
init() {
27+
const editor = this.editor;
28+
const t = editor.t;
29+
30+
// Add bold button to feature components.
31+
editor.ui.componentFactory.add( BOLD, locale => {
32+
const command = editor.commands.get( BOLD );
33+
const view = new ButtonView( locale );
34+
35+
view.set( {
36+
label: t( 'Bold' ),
37+
icon: boldIcon,
38+
keystroke: 'CTRL+B',
39+
tooltip: true
40+
} );
41+
42+
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
43+
44+
// Execute command.
45+
this.listenTo( view, 'execute', () => editor.execute( BOLD ) );
46+
47+
return view;
48+
} );
49+
}
50+
}

src/code.js

+6-33
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
*/
99

1010
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11-
import CodeEngine from './codeengine';
12-
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
13-
import codeIcon from '../theme/icons/code.svg';
11+
import CodeEditing from './code/codeediting';
12+
import CodeUI from './code/codeui';
1413

1514
import '../theme/code.css';
1615

1716
/**
18-
* The code feature. It introduces the Code button.
17+
* The code feature.
1918
*
20-
* It uses the {@link module:basic-styles/codeengine~CodeEngine code engine feature}.
19+
* It loads the {@link module:basic-styles/code/codeediting~CodeEditing code editing feature}
20+
* and {@link module:basic-styles/code/codeui~CodeUI code UI feature}.
2121
*
2222
* @extends module:core/plugin~Plugin
2323
*/
@@ -26,7 +26,7 @@ export default class Code extends Plugin {
2626
* @inheritDoc
2727
*/
2828
static get requires() {
29-
return [ CodeEngine ];
29+
return [ CodeEditing, CodeUI ];
3030
}
3131

3232
/**
@@ -35,31 +35,4 @@ export default class Code extends Plugin {
3535
static get pluginName() {
3636
return 'Code';
3737
}
38-
39-
/**
40-
* @inheritDoc
41-
*/
42-
init() {
43-
const editor = this.editor;
44-
const t = editor.t;
45-
const command = editor.commands.get( 'code' );
46-
47-
// Add code button to feature components.
48-
editor.ui.componentFactory.add( 'code', locale => {
49-
const view = new ButtonView( locale );
50-
51-
view.set( {
52-
label: t( 'Code' ),
53-
icon: codeIcon,
54-
tooltip: true
55-
} );
56-
57-
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
58-
59-
// Execute command.
60-
this.listenTo( view, 'execute', () => editor.execute( 'code' ) );
61-
62-
return view;
63-
} );
64-
}
6538
}

src/codeengine.js renamed to src/code/codeediting.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
*/
55

66
/**
7-
* @module basic-styles/codeengine
7+
* @module basic-styles/code/codeediting
88
*/
99

1010
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11-
import AttributeCommand from './attributecommand';
11+
import AttributeCommand from '../attributecommand';
1212

1313
const CODE = 'code';
1414

1515
/**
16-
* The code engine feature.
16+
* The code editing feature.
1717
*
1818
* It registers the `code` command and introduces the `code` attribute in the model which renders to the view
1919
* as a `<code>` element.
2020
*
2121
* @extends module:core/plugin~Plugin
2222
*/
23-
export default class CodeEngine extends Plugin {
23+
export default class CodeEditing extends Plugin {
2424
/**
2525
* @inheritDoc
2626
*/

src/code/codeui.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
3+
* For licensing, see LICENSE.md.
4+
*/
5+
6+
/**
7+
* @module basic-styles/code/codeui
8+
*/
9+
10+
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11+
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
12+
13+
import codeIcon from '../../theme/icons/code.svg';
14+
15+
import '../../theme/code.css';
16+
17+
const CODE = 'code';
18+
19+
/**
20+
* The code UI feature. It introduces the Code button.
21+
*
22+
* @extends module:core/plugin~Plugin
23+
*/
24+
export default class CodeUI extends Plugin {
25+
/**
26+
* @inheritDoc
27+
*/
28+
init() {
29+
const editor = this.editor;
30+
const t = editor.t;
31+
32+
// Add code button to feature components.
33+
editor.ui.componentFactory.add( CODE, locale => {
34+
const command = editor.commands.get( CODE );
35+
const view = new ButtonView( locale );
36+
37+
view.set( {
38+
label: t( 'Code' ),
39+
icon: codeIcon,
40+
tooltip: true
41+
} );
42+
43+
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
44+
45+
// Execute command.
46+
this.listenTo( view, 'execute', () => editor.execute( CODE ) );
47+
48+
return view;
49+
} );
50+
}
51+
}

src/italic.js

+6-38
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
*/
99

1010
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
11-
import ItalicEngine from './italicengine';
12-
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
13-
import italicIcon from '../theme/icons/italic.svg';
11+
import ItalicEditing from './italic/italicediting';
12+
import ItalicUI from './italic/italicui';
1413

1514
/**
16-
* The italic feature. It introduces the Italic button and the <kbd>Ctrl+I</kbd> keystroke.
15+
* The italic feature.
1716
*
18-
* It uses the {@link module:basic-styles/italicengine~ItalicEngine italic engine feature}.
17+
* It loads the {@link module:basic-styles/italic/italicediting~ItalicEditing} and
18+
* {@link module:basic-styles/italic/italicui~ItalicUI} plugins.
1919
*
2020
* @extends module:core/plugin~Plugin
2121
*/
@@ -24,7 +24,7 @@ export default class Italic extends Plugin {
2424
* @inheritDoc
2525
*/
2626
static get requires() {
27-
return [ ItalicEngine ];
27+
return [ ItalicEditing, ItalicUI ];
2828
}
2929

3030
/**
@@ -33,36 +33,4 @@ export default class Italic extends Plugin {
3333
static get pluginName() {
3434
return 'Italic';
3535
}
36-
37-
/**
38-
* @inheritDoc
39-
*/
40-
init() {
41-
const editor = this.editor;
42-
const t = editor.t;
43-
const command = editor.commands.get( 'italic' );
44-
const keystroke = 'CTRL+I';
45-
46-
// Add bold button to feature components.
47-
editor.ui.componentFactory.add( 'italic', locale => {
48-
const view = new ButtonView( locale );
49-
50-
view.set( {
51-
label: t( 'Italic' ),
52-
icon: italicIcon,
53-
keystroke,
54-
tooltip: true
55-
} );
56-
57-
view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
58-
59-
// Execute command.
60-
this.listenTo( view, 'execute', () => editor.execute( 'italic' ) );
61-
62-
return view;
63-
} );
64-
65-
// Set the Ctrl+I keystroke.
66-
editor.keystrokes.set( keystroke, 'italic' );
67-
}
6836
}

0 commit comments

Comments
 (0)