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

Commit 5f5b4a9

Browse files
authored
Merge pull request #49 from ckeditor/t/ckeditor5/488
Other: Align feature class naming to a new scheme.
2 parents e471861 + 3c60e91 commit 5f5b4a9

File tree

7 files changed

+50
-50
lines changed

7 files changed

+50
-50
lines changed

docs/features/autoformat.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ClassicEditor
6868

6969
## Creating custom autoformatters
7070

71-
The {@link module:autoformat/autoformat~Autoformat} feature bases on {@link module:autoformat/blockautoformatengine~BlockAutoformatEngine} and {@link module:autoformat/inlineautoformatengine~InlineAutoformatEngine} tools to create the autoformatters mentioned above.
71+
The {@link module:autoformat/autoformat~Autoformat} feature bases on {@link module:autoformat/blockautoformatediting~BlockAutoformatEditing} and {@link module:autoformat/inlineautoformatediting~InlineAutoformatEditing} tools to create the autoformatters mentioned above.
7272

7373
You can use these tools to create your own autoformatters. Check the [`Autoformat` feature's code](https://github.com/ckeditor/ckeditor5-autoformat/blob/master/src/autoformat.js) as an example.
7474

src/autoformat.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* @module autoformat/autoformat
88
*/
99

10-
import BlockAutoformatEngine from './blockautoformatengine';
11-
import InlineAutoformatEngine from './inlineautoformatengine';
10+
import BlockAutoformatEditing from './blockautoformatediting';
11+
import InlineAutoformatEditing from './inlineautoformatediting';
1212
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
1313

1414
/**
@@ -49,12 +49,12 @@ export default class Autoformat extends Plugin {
4949

5050
if ( commands.get( 'bulletedList' ) ) {
5151
// eslint-disable-next-line no-new
52-
new BlockAutoformatEngine( this.editor, /^[*-]\s$/, 'bulletedList' );
52+
new BlockAutoformatEditing( this.editor, /^[*-]\s$/, 'bulletedList' );
5353
}
5454

5555
if ( commands.get( 'numberedList' ) ) {
5656
// eslint-disable-next-line no-new
57-
new BlockAutoformatEngine( this.editor, /^\d+[.|)]\s$/, 'numberedList' );
57+
new BlockAutoformatEditing( this.editor, /^\d+[.|)]\s$/, 'numberedList' );
5858
}
5959
}
6060

@@ -76,8 +76,8 @@ export default class Autoformat extends Plugin {
7676

7777
if ( commands.get( 'bold' ) ) {
7878
/* eslint-disable no-new */
79-
new InlineAutoformatEngine( this.editor, /(\*\*)([^*]+)(\*\*)$/g, 'bold' );
80-
new InlineAutoformatEngine( this.editor, /(__)([^_]+)(__)$/g, 'bold' );
79+
new InlineAutoformatEditing( this.editor, /(\*\*)([^*]+)(\*\*)$/g, 'bold' );
80+
new InlineAutoformatEditing( this.editor, /(__)([^_]+)(__)$/g, 'bold' );
8181
/* eslint-enable no-new */
8282
}
8383

@@ -86,14 +86,14 @@ export default class Autoformat extends Plugin {
8686
// text before the pattern (e.g. `(?:^|[^\*])`).
8787

8888
/* eslint-disable no-new */
89-
new InlineAutoformatEngine( this.editor, /(?:^|[^*])(\*)([^*_]+)(\*)$/g, 'italic' );
90-
new InlineAutoformatEngine( this.editor, /(?:^|[^_])(_)([^_]+)(_)$/g, 'italic' );
89+
new InlineAutoformatEditing( this.editor, /(?:^|[^*])(\*)([^*_]+)(\*)$/g, 'italic' );
90+
new InlineAutoformatEditing( this.editor, /(?:^|[^_])(_)([^_]+)(_)$/g, 'italic' );
9191
/* eslint-enable no-new */
9292
}
9393

9494
if ( commands.get( 'code' ) ) {
9595
/* eslint-disable no-new */
96-
new InlineAutoformatEngine( this.editor, /(`)([^`]+)(`)$/g, 'code' );
96+
new InlineAutoformatEditing( this.editor, /(`)([^`]+)(`)$/g, 'code' );
9797
/* eslint-enable no-new */
9898
}
9999
}
@@ -117,7 +117,7 @@ export default class Autoformat extends Plugin {
117117
const pattern = new RegExp( `^(#{${ level }})\\s$` );
118118

119119
// eslint-disable-next-line no-new
120-
new BlockAutoformatEngine( this.editor, pattern, () => {
120+
new BlockAutoformatEditing( this.editor, pattern, () => {
121121
this.editor.execute( commandName );
122122
} );
123123
} );
@@ -134,7 +134,7 @@ export default class Autoformat extends Plugin {
134134
_addBlockQuoteAutoformats() {
135135
if ( this.editor.commands.get( 'blockQuote' ) ) {
136136
// eslint-disable-next-line no-new
137-
new BlockAutoformatEngine( this.editor, /^>\s$/, 'blockQuote' );
137+
new BlockAutoformatEditing( this.editor, /^>\s$/, 'blockQuote' );
138138
}
139139
}
140140
}

src/blockautoformatengine.js renamed to src/blockautoformatediting.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/**
7-
* @module autoformat/blockautoformatengine
7+
* @module autoformat/blockautoformatediting
88
*/
99

1010
import Range from '@ckeditor/ckeditor5-engine/src/model/range';
@@ -20,7 +20,7 @@ import Range from '@ckeditor/ckeditor5-engine/src/model/range';
2020
* the {@link module:autoformat/autoformat~Autoformat} feature which enables a set of default autoformatters
2121
* (lists, headings, bold and italic).
2222
*/
23-
export default class BlockAutoformatEngine {
23+
export default class BlockAutoformatEditing {
2424
/**
2525
* Creates a listener triggered on `change` event in the document.
2626
* Calls the callback when inserted text matches the regular expression or the command name
@@ -30,11 +30,11 @@ export default class BlockAutoformatEngine {
3030
*
3131
* To convert a paragraph to heading 1 when `- ` is typed, using just the commmand name:
3232
*
33-
* new BlockAutoformatEngine( editor, /^\- $/, 'heading1' );
33+
* new BlockAutoformatEditing( editor, /^\- $/, 'heading1' );
3434
*
3535
* To convert a paragraph to heading 1 when `- ` is typed, using just the callback:
3636
*
37-
* new BlockAutoformatEngine( editor, /^\- $/, ( context ) => {
37+
* new BlockAutoformatEditing( editor, /^\- $/, ( context ) => {
3838
* const { match } = context;
3939
* const headingLevel = match[ 1 ].length;
4040
*

src/inlineautoformatengine.js renamed to src/inlineautoformatediting.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
/**
7-
* @module autoformat/inlineautoformatengine
7+
* @module autoformat/inlineautoformatediting
88
*/
99

1010
import LiveRange from '@ckeditor/ckeditor5-engine/src/model/liverange';
@@ -20,7 +20,7 @@ import LiveRange from '@ckeditor/ckeditor5-engine/src/model/liverange';
2020
* the {@link module:autoformat/autoformat~Autoformat} feature which enables a set of default autoformatters
2121
* (lists, headings, bold and italic).
2222
*/
23-
export default class InlineAutoformatEngine {
23+
export default class InlineAutoformatEditing {
2424
/**
2525
* Enables autoformatting mechanism for a given {@link module:core/editor/editor~Editor}.
2626
*
@@ -38,7 +38,7 @@ export default class InlineAutoformatEngine {
3838
* // - The first to match the starting `**` delimiter.
3939
* // - The second to match the text to format.
4040
* // - The third to match the ending `**` delimiter.
41-
* new InlineAutoformatEngine( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' );
41+
* new InlineAutoformatEditing( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' );
4242
*
4343
* When a function is provided instead of the regular expression, it will be executed with the text to match as a parameter.
4444
* The function should return proper "ranges" to delete and format.
@@ -57,10 +57,10 @@ export default class InlineAutoformatEngine {
5757
* formatting.
5858
*
5959
* // Use attribute name:
60-
* new InlineAutoformatEngine( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' );
60+
* new InlineAutoformatEditing( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' );
6161
*
6262
* // Use formatting callback:
63-
* new InlineAutoformatEngine( editor, /(\*\*)([^\*]+?)(\*\*)$/g, ( writer, validRanges ) => {
63+
* new InlineAutoformatEditing( editor, /(\*\*)([^\*]+?)(\*\*)$/g, ( writer, validRanges ) => {
6464
* for ( let range of validRanges ) {
6565
* writer.setAttribute( command, true, range );
6666
* }

tests/autoformat.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import Autoformat from '../src/autoformat';
77

88
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
9-
import ListEngine from '@ckeditor/ckeditor5-list/src/listengine';
10-
import HeadingEngine from '@ckeditor/ckeditor5-heading/src/headingengine';
11-
import BoldEngine from '@ckeditor/ckeditor5-basic-styles/src/boldengine';
12-
import CodeEngine from '@ckeditor/ckeditor5-basic-styles/src/codeengine';
13-
import ItalicEngine from '@ckeditor/ckeditor5-basic-styles/src/italicengine';
14-
import BlockQuoteEngine from '@ckeditor/ckeditor5-block-quote/src/blockquoteengine';
9+
import ListEditing from '@ckeditor/ckeditor5-list/src/listediting';
10+
import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting';
11+
import BoldEditing from '@ckeditor/ckeditor5-basic-styles/src/bold/boldediting';
12+
import CodeEditing from '@ckeditor/ckeditor5-basic-styles/src/code/codeediting';
13+
import ItalicEditing from '@ckeditor/ckeditor5-basic-styles/src/italic/italicediting';
14+
import BlockQuoteEditing from '@ckeditor/ckeditor5-block-quote/src/blockquoteediting';
1515
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
1616

1717
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
@@ -33,12 +33,12 @@ describe( 'Autoformat', () => {
3333
Enter,
3434
Paragraph,
3535
Autoformat,
36-
ListEngine,
37-
HeadingEngine,
38-
BoldEngine,
39-
ItalicEngine,
40-
CodeEngine,
41-
BlockQuoteEngine
36+
ListEditing,
37+
HeadingEditing,
38+
BoldEditing,
39+
ItalicEditing,
40+
CodeEditing,
41+
BlockQuoteEditing
4242
]
4343
} )
4444
.then( newEditor => {
@@ -378,7 +378,7 @@ describe( 'Autoformat', () => {
378378
it( 'should use only configured headings', () => {
379379
return VirtualTestEditor
380380
.create( {
381-
plugins: [ Enter, Paragraph, Autoformat, ListEngine, HeadingEngine ],
381+
plugins: [ Enter, Paragraph, Autoformat, ListEditing, HeadingEditing ],
382382
heading: {
383383
options: [
384384
{ model: 'paragraph' },

tests/blockautoformatengine.js renamed to tests/blockautoformatediting.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* For licensing, see LICENSE.md.
44
*/
55

6-
import BlockAutoformatEngine from '../src/blockautoformatengine';
6+
import BlockAutoformatEditing from '../src/blockautoformatediting';
77
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
88
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
99
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
@@ -13,7 +13,7 @@ import Command from '@ckeditor/ckeditor5-core/src/command';
1313

1414
testUtils.createSinonSandbox();
1515

16-
describe( 'BlockAutoformatEngine', () => {
16+
describe( 'BlockAutoformatEditing', () => {
1717
let editor, model, doc;
1818

1919
beforeEach( () => {
@@ -32,7 +32,7 @@ describe( 'BlockAutoformatEngine', () => {
3232
it( 'should run a command when the pattern is matched', () => {
3333
const spy = testUtils.sinon.spy();
3434
editor.commands.add( 'testCommand', new TestCommand( editor, spy ) );
35-
new BlockAutoformatEngine( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new
35+
new BlockAutoformatEditing( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new
3636

3737
setData( model, '<paragraph>*[]</paragraph>' );
3838
model.change( writer => {
@@ -45,7 +45,7 @@ describe( 'BlockAutoformatEngine', () => {
4545
it( 'should remove found pattern', () => {
4646
const spy = testUtils.sinon.spy();
4747
editor.commands.add( 'testCommand', new TestCommand( editor, spy ) );
48-
new BlockAutoformatEngine( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new
48+
new BlockAutoformatEditing( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new
4949

5050
setData( model, '<paragraph>*[]</paragraph>' );
5151
model.change( writer => {
@@ -60,7 +60,7 @@ describe( 'BlockAutoformatEngine', () => {
6060
describe( 'Callback', () => {
6161
it( 'should run callback when the pattern is matched', () => {
6262
const spy = testUtils.sinon.spy();
63-
new BlockAutoformatEngine( editor, /^[*]\s$/, spy ); // eslint-disable-line no-new
63+
new BlockAutoformatEditing( editor, /^[*]\s$/, spy ); // eslint-disable-line no-new
6464

6565
setData( model, '<paragraph>*[]</paragraph>' );
6666
model.change( writer => {
@@ -72,7 +72,7 @@ describe( 'BlockAutoformatEngine', () => {
7272

7373
it( 'should ignore other delta operations', () => {
7474
const spy = testUtils.sinon.spy();
75-
new BlockAutoformatEngine( editor, /^[*]\s/, spy ); // eslint-disable-line no-new
75+
new BlockAutoformatEditing( editor, /^[*]\s/, spy ); // eslint-disable-line no-new
7676

7777
setData( model, '<paragraph>*[]</paragraph>' );
7878
model.change( writer => {
@@ -84,7 +84,7 @@ describe( 'BlockAutoformatEngine', () => {
8484

8585
it( 'should stop if there is no text to run matching on', () => {
8686
const spy = testUtils.sinon.spy();
87-
new BlockAutoformatEngine( editor, /^[*]\s/, spy ); // eslint-disable-line no-new
87+
new BlockAutoformatEditing( editor, /^[*]\s/, spy ); // eslint-disable-line no-new
8888

8989
setData( model, '<paragraph>[]</paragraph>' );
9090
model.change( writer => {

tests/inlineautoformatengine.js renamed to tests/inlineautoformatediting.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* For licensing, see LICENSE.md.
44
*/
55

6-
import InlineAutoformatEngine from '../src/inlineautoformatengine';
6+
import InlineAutoformatEditing from '../src/inlineautoformatediting';
77
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
88
import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
99
import Enter from '@ckeditor/ckeditor5-enter/src/enter';
@@ -12,7 +12,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
1212

1313
testUtils.createSinonSandbox();
1414

15-
describe( 'InlineAutoformatEngine', () => {
15+
describe( 'InlineAutoformatEditing', () => {
1616
let editor, model, doc;
1717

1818
beforeEach( () => {
@@ -31,7 +31,7 @@ describe( 'InlineAutoformatEngine', () => {
3131

3232
describe( 'attribute', () => {
3333
it( 'should stop early if there are less than 3 capture groups', () => {
34-
new InlineAutoformatEngine( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new
34+
new InlineAutoformatEditing( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new
3535

3636
setData( model, '<paragraph>*foobar[]</paragraph>' );
3737
model.change( writer => {
@@ -42,7 +42,7 @@ describe( 'InlineAutoformatEngine', () => {
4242
} );
4343

4444
it( 'should apply an attribute when the pattern is matched', () => {
45-
new InlineAutoformatEngine( editor, /(\*)(.+?)(\*)/g, 'testAttribute' ); // eslint-disable-line no-new
45+
new InlineAutoformatEditing( editor, /(\*)(.+?)(\*)/g, 'testAttribute' ); // eslint-disable-line no-new
4646

4747
setData( model, '<paragraph>*foobar[]</paragraph>' );
4848
model.change( writer => {
@@ -53,7 +53,7 @@ describe( 'InlineAutoformatEngine', () => {
5353
} );
5454

5555
it( 'should stop early if selection is not collapsed', () => {
56-
new InlineAutoformatEngine( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new
56+
new InlineAutoformatEditing( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new
5757

5858
setData( model, '<paragraph>*foob[ar]</paragraph>' );
5959
model.change( writer => {
@@ -72,7 +72,7 @@ describe( 'InlineAutoformatEngine', () => {
7272
remove: []
7373
} );
7474

75-
new InlineAutoformatEngine( editor, testStub, formatSpy ); // eslint-disable-line no-new
75+
new InlineAutoformatEditing( editor, testStub, formatSpy ); // eslint-disable-line no-new
7676

7777
setData( model, '<paragraph>*[]</paragraph>' );
7878
model.change( writer => {
@@ -89,7 +89,7 @@ describe( 'InlineAutoformatEngine', () => {
8989
remove: [ [] ]
9090
} );
9191

92-
new InlineAutoformatEngine( editor, testStub, formatSpy ); // eslint-disable-line no-new
92+
new InlineAutoformatEditing( editor, testStub, formatSpy ); // eslint-disable-line no-new
9393

9494
setData( model, '<paragraph>*[]</paragraph>' );
9595
model.change( writer => {
@@ -106,7 +106,7 @@ describe( 'InlineAutoformatEngine', () => {
106106
remove: [ [] ]
107107
} );
108108

109-
new InlineAutoformatEngine( editor, testStub, formatSpy ); // eslint-disable-line no-new
109+
new InlineAutoformatEditing( editor, testStub, formatSpy ); // eslint-disable-line no-new
110110

111111
setData( model, '<paragraph>[]</paragraph>' );
112112
model.change( writer => {
@@ -123,7 +123,7 @@ describe( 'InlineAutoformatEngine', () => {
123123
.callThrough()
124124
.callsFake( ranges => ranges.map( saveDetachSpy ) );
125125

126-
new InlineAutoformatEngine( editor, /(\*)(.+?)(\*)/g, callback ); // eslint-disable-line no-new
126+
new InlineAutoformatEditing( editor, /(\*)(.+?)(\*)/g, callback ); // eslint-disable-line no-new
127127

128128
setData( model, '<paragraph>*foobar[]</paragraph>' );
129129

0 commit comments

Comments
 (0)