From 3c60e9172a6195ef879ba5f2da877a5601d99dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Go=C5=82aszewski?= Date: Fri, 9 Feb 2018 14:20:50 +0100 Subject: [PATCH] Align feature class naming to a new scheme. --- docs/features/autoformat.md | 2 +- src/autoformat.js | 22 ++++++++-------- ...matengine.js => blockautoformatediting.js} | 8 +++--- ...atengine.js => inlineautoformatediting.js} | 10 +++---- tests/autoformat.js | 26 +++++++++---------- ...matengine.js => blockautoformatediting.js} | 14 +++++----- ...atengine.js => inlineautoformatediting.js} | 18 ++++++------- 7 files changed, 50 insertions(+), 50 deletions(-) rename src/{blockautoformatengine.js => blockautoformatediting.js} (93%) rename src/{inlineautoformatengine.js => inlineautoformatediting.js} (95%) rename tests/{blockautoformatengine.js => blockautoformatediting.js} (84%) rename tests/{inlineautoformatengine.js => inlineautoformatediting.js} (83%) diff --git a/docs/features/autoformat.md b/docs/features/autoformat.md index 9f08201..5dc46da 100644 --- a/docs/features/autoformat.md +++ b/docs/features/autoformat.md @@ -68,7 +68,7 @@ ClassicEditor ## Creating custom autoformatters -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. +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. 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. diff --git a/src/autoformat.js b/src/autoformat.js index c842c16..3500f3f 100644 --- a/src/autoformat.js +++ b/src/autoformat.js @@ -7,8 +7,8 @@ * @module autoformat/autoformat */ -import BlockAutoformatEngine from './blockautoformatengine'; -import InlineAutoformatEngine from './inlineautoformatengine'; +import BlockAutoformatEditing from './blockautoformatediting'; +import InlineAutoformatEditing from './inlineautoformatediting'; import Plugin from '@ckeditor/ckeditor5-core/src/plugin'; /** @@ -49,12 +49,12 @@ export default class Autoformat extends Plugin { if ( commands.get( 'bulletedList' ) ) { // eslint-disable-next-line no-new - new BlockAutoformatEngine( this.editor, /^[*-]\s$/, 'bulletedList' ); + new BlockAutoformatEditing( this.editor, /^[*-]\s$/, 'bulletedList' ); } if ( commands.get( 'numberedList' ) ) { // eslint-disable-next-line no-new - new BlockAutoformatEngine( this.editor, /^\d+[.|)]\s$/, 'numberedList' ); + new BlockAutoformatEditing( this.editor, /^\d+[.|)]\s$/, 'numberedList' ); } } @@ -76,8 +76,8 @@ export default class Autoformat extends Plugin { if ( commands.get( 'bold' ) ) { /* eslint-disable no-new */ - new InlineAutoformatEngine( this.editor, /(\*\*)([^*]+)(\*\*)$/g, 'bold' ); - new InlineAutoformatEngine( this.editor, /(__)([^_]+)(__)$/g, 'bold' ); + new InlineAutoformatEditing( this.editor, /(\*\*)([^*]+)(\*\*)$/g, 'bold' ); + new InlineAutoformatEditing( this.editor, /(__)([^_]+)(__)$/g, 'bold' ); /* eslint-enable no-new */ } @@ -86,14 +86,14 @@ export default class Autoformat extends Plugin { // text before the pattern (e.g. `(?:^|[^\*])`). /* eslint-disable no-new */ - new InlineAutoformatEngine( this.editor, /(?:^|[^*])(\*)([^*_]+)(\*)$/g, 'italic' ); - new InlineAutoformatEngine( this.editor, /(?:^|[^_])(_)([^_]+)(_)$/g, 'italic' ); + new InlineAutoformatEditing( this.editor, /(?:^|[^*])(\*)([^*_]+)(\*)$/g, 'italic' ); + new InlineAutoformatEditing( this.editor, /(?:^|[^_])(_)([^_]+)(_)$/g, 'italic' ); /* eslint-enable no-new */ } if ( commands.get( 'code' ) ) { /* eslint-disable no-new */ - new InlineAutoformatEngine( this.editor, /(`)([^`]+)(`)$/g, 'code' ); + new InlineAutoformatEditing( this.editor, /(`)([^`]+)(`)$/g, 'code' ); /* eslint-enable no-new */ } } @@ -117,7 +117,7 @@ export default class Autoformat extends Plugin { const pattern = new RegExp( `^(#{${ level }})\\s$` ); // eslint-disable-next-line no-new - new BlockAutoformatEngine( this.editor, pattern, () => { + new BlockAutoformatEditing( this.editor, pattern, () => { this.editor.execute( commandName ); } ); } ); @@ -134,7 +134,7 @@ export default class Autoformat extends Plugin { _addBlockQuoteAutoformats() { if ( this.editor.commands.get( 'blockQuote' ) ) { // eslint-disable-next-line no-new - new BlockAutoformatEngine( this.editor, /^>\s$/, 'blockQuote' ); + new BlockAutoformatEditing( this.editor, /^>\s$/, 'blockQuote' ); } } } diff --git a/src/blockautoformatengine.js b/src/blockautoformatediting.js similarity index 93% rename from src/blockautoformatengine.js rename to src/blockautoformatediting.js index 217fef1..fdee5e5 100644 --- a/src/blockautoformatengine.js +++ b/src/blockautoformatediting.js @@ -4,7 +4,7 @@ */ /** - * @module autoformat/blockautoformatengine + * @module autoformat/blockautoformatediting */ import Range from '@ckeditor/ckeditor5-engine/src/model/range'; @@ -20,7 +20,7 @@ import Range from '@ckeditor/ckeditor5-engine/src/model/range'; * the {@link module:autoformat/autoformat~Autoformat} feature which enables a set of default autoformatters * (lists, headings, bold and italic). */ -export default class BlockAutoformatEngine { +export default class BlockAutoformatEditing { /** * Creates a listener triggered on `change` event in the document. * Calls the callback when inserted text matches the regular expression or the command name @@ -30,11 +30,11 @@ export default class BlockAutoformatEngine { * * To convert a paragraph to heading 1 when `- ` is typed, using just the commmand name: * - * new BlockAutoformatEngine( editor, /^\- $/, 'heading1' ); + * new BlockAutoformatEditing( editor, /^\- $/, 'heading1' ); * * To convert a paragraph to heading 1 when `- ` is typed, using just the callback: * - * new BlockAutoformatEngine( editor, /^\- $/, ( context ) => { + * new BlockAutoformatEditing( editor, /^\- $/, ( context ) => { * const { match } = context; * const headingLevel = match[ 1 ].length; * diff --git a/src/inlineautoformatengine.js b/src/inlineautoformatediting.js similarity index 95% rename from src/inlineautoformatengine.js rename to src/inlineautoformatediting.js index 62919a3..b8e4942 100644 --- a/src/inlineautoformatengine.js +++ b/src/inlineautoformatediting.js @@ -4,7 +4,7 @@ */ /** - * @module autoformat/inlineautoformatengine + * @module autoformat/inlineautoformatediting */ import LiveRange from '@ckeditor/ckeditor5-engine/src/model/liverange'; @@ -20,7 +20,7 @@ import LiveRange from '@ckeditor/ckeditor5-engine/src/model/liverange'; * the {@link module:autoformat/autoformat~Autoformat} feature which enables a set of default autoformatters * (lists, headings, bold and italic). */ -export default class InlineAutoformatEngine { +export default class InlineAutoformatEditing { /** * Enables autoformatting mechanism for a given {@link module:core/editor/editor~Editor}. * @@ -38,7 +38,7 @@ export default class InlineAutoformatEngine { * // - The first to match the starting `**` delimiter. * // - The second to match the text to format. * // - The third to match the ending `**` delimiter. - * new InlineAutoformatEngine( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' ); + * new InlineAutoformatEditing( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' ); * * When a function is provided instead of the regular expression, it will be executed with the text to match as a parameter. * The function should return proper "ranges" to delete and format. @@ -57,10 +57,10 @@ export default class InlineAutoformatEngine { * formatting. * * // Use attribute name: - * new InlineAutoformatEngine( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' ); + * new InlineAutoformatEditing( editor, /(\*\*)([^\*]+?)(\*\*)$/g, 'bold' ); * * // Use formatting callback: - * new InlineAutoformatEngine( editor, /(\*\*)([^\*]+?)(\*\*)$/g, ( writer, validRanges ) => { + * new InlineAutoformatEditing( editor, /(\*\*)([^\*]+?)(\*\*)$/g, ( writer, validRanges ) => { * for ( let range of validRanges ) { * writer.setAttribute( command, true, range ); * } diff --git a/tests/autoformat.js b/tests/autoformat.js index 64d5fdb..0335e89 100644 --- a/tests/autoformat.js +++ b/tests/autoformat.js @@ -6,12 +6,12 @@ import Autoformat from '../src/autoformat'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; -import ListEngine from '@ckeditor/ckeditor5-list/src/listengine'; -import HeadingEngine from '@ckeditor/ckeditor5-heading/src/headingengine'; -import BoldEngine from '@ckeditor/ckeditor5-basic-styles/src/boldengine'; -import CodeEngine from '@ckeditor/ckeditor5-basic-styles/src/codeengine'; -import ItalicEngine from '@ckeditor/ckeditor5-basic-styles/src/italicengine'; -import BlockQuoteEngine from '@ckeditor/ckeditor5-block-quote/src/blockquoteengine'; +import ListEditing from '@ckeditor/ckeditor5-list/src/listediting'; +import HeadingEditing from '@ckeditor/ckeditor5-heading/src/headingediting'; +import BoldEditing from '@ckeditor/ckeditor5-basic-styles/src/bold/boldediting'; +import CodeEditing from '@ckeditor/ckeditor5-basic-styles/src/code/codeediting'; +import ItalicEditing from '@ckeditor/ckeditor5-basic-styles/src/italic/italicediting'; +import BlockQuoteEditing from '@ckeditor/ckeditor5-block-quote/src/blockquoteediting'; import Enter from '@ckeditor/ckeditor5-enter/src/enter'; import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; @@ -33,12 +33,12 @@ describe( 'Autoformat', () => { Enter, Paragraph, Autoformat, - ListEngine, - HeadingEngine, - BoldEngine, - ItalicEngine, - CodeEngine, - BlockQuoteEngine + ListEditing, + HeadingEditing, + BoldEditing, + ItalicEditing, + CodeEditing, + BlockQuoteEditing ] } ) .then( newEditor => { @@ -378,7 +378,7 @@ describe( 'Autoformat', () => { it( 'should use only configured headings', () => { return VirtualTestEditor .create( { - plugins: [ Enter, Paragraph, Autoformat, ListEngine, HeadingEngine ], + plugins: [ Enter, Paragraph, Autoformat, ListEditing, HeadingEditing ], heading: { options: [ { model: 'paragraph' }, diff --git a/tests/blockautoformatengine.js b/tests/blockautoformatediting.js similarity index 84% rename from tests/blockautoformatengine.js rename to tests/blockautoformatediting.js index 2dd3d50..2b743d2 100644 --- a/tests/blockautoformatengine.js +++ b/tests/blockautoformatediting.js @@ -3,7 +3,7 @@ * For licensing, see LICENSE.md. */ -import BlockAutoformatEngine from '../src/blockautoformatengine'; +import BlockAutoformatEditing from '../src/blockautoformatediting'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; import Enter from '@ckeditor/ckeditor5-enter/src/enter'; @@ -13,7 +13,7 @@ import Command from '@ckeditor/ckeditor5-core/src/command'; testUtils.createSinonSandbox(); -describe( 'BlockAutoformatEngine', () => { +describe( 'BlockAutoformatEditing', () => { let editor, model, doc; beforeEach( () => { @@ -32,7 +32,7 @@ describe( 'BlockAutoformatEngine', () => { it( 'should run a command when the pattern is matched', () => { const spy = testUtils.sinon.spy(); editor.commands.add( 'testCommand', new TestCommand( editor, spy ) ); - new BlockAutoformatEngine( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new + new BlockAutoformatEditing( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new setData( model, '*[]' ); model.change( writer => { @@ -45,7 +45,7 @@ describe( 'BlockAutoformatEngine', () => { it( 'should remove found pattern', () => { const spy = testUtils.sinon.spy(); editor.commands.add( 'testCommand', new TestCommand( editor, spy ) ); - new BlockAutoformatEngine( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new + new BlockAutoformatEditing( editor, /^[*]\s$/, 'testCommand' ); // eslint-disable-line no-new setData( model, '*[]' ); model.change( writer => { @@ -60,7 +60,7 @@ describe( 'BlockAutoformatEngine', () => { describe( 'Callback', () => { it( 'should run callback when the pattern is matched', () => { const spy = testUtils.sinon.spy(); - new BlockAutoformatEngine( editor, /^[*]\s$/, spy ); // eslint-disable-line no-new + new BlockAutoformatEditing( editor, /^[*]\s$/, spy ); // eslint-disable-line no-new setData( model, '*[]' ); model.change( writer => { @@ -72,7 +72,7 @@ describe( 'BlockAutoformatEngine', () => { it( 'should ignore other delta operations', () => { const spy = testUtils.sinon.spy(); - new BlockAutoformatEngine( editor, /^[*]\s/, spy ); // eslint-disable-line no-new + new BlockAutoformatEditing( editor, /^[*]\s/, spy ); // eslint-disable-line no-new setData( model, '*[]' ); model.change( writer => { @@ -84,7 +84,7 @@ describe( 'BlockAutoformatEngine', () => { it( 'should stop if there is no text to run matching on', () => { const spy = testUtils.sinon.spy(); - new BlockAutoformatEngine( editor, /^[*]\s/, spy ); // eslint-disable-line no-new + new BlockAutoformatEditing( editor, /^[*]\s/, spy ); // eslint-disable-line no-new setData( model, '[]' ); model.change( writer => { diff --git a/tests/inlineautoformatengine.js b/tests/inlineautoformatediting.js similarity index 83% rename from tests/inlineautoformatengine.js rename to tests/inlineautoformatediting.js index acca3fb..aabada9 100644 --- a/tests/inlineautoformatengine.js +++ b/tests/inlineautoformatediting.js @@ -3,7 +3,7 @@ * For licensing, see LICENSE.md. */ -import InlineAutoformatEngine from '../src/inlineautoformatengine'; +import InlineAutoformatEditing from '../src/inlineautoformatediting'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph'; import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor'; import Enter from '@ckeditor/ckeditor5-enter/src/enter'; @@ -12,7 +12,7 @@ import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; testUtils.createSinonSandbox(); -describe( 'InlineAutoformatEngine', () => { +describe( 'InlineAutoformatEditing', () => { let editor, model, doc; beforeEach( () => { @@ -31,7 +31,7 @@ describe( 'InlineAutoformatEngine', () => { describe( 'attribute', () => { it( 'should stop early if there are less than 3 capture groups', () => { - new InlineAutoformatEngine( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new setData( model, '*foobar[]' ); model.change( writer => { @@ -42,7 +42,7 @@ describe( 'InlineAutoformatEngine', () => { } ); it( 'should apply an attribute when the pattern is matched', () => { - new InlineAutoformatEngine( editor, /(\*)(.+?)(\*)/g, 'testAttribute' ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, /(\*)(.+?)(\*)/g, 'testAttribute' ); // eslint-disable-line no-new setData( model, '*foobar[]' ); model.change( writer => { @@ -53,7 +53,7 @@ describe( 'InlineAutoformatEngine', () => { } ); it( 'should stop early if selection is not collapsed', () => { - new InlineAutoformatEngine( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, /(\*)(.+?)\*/g, 'testAttribute' ); // eslint-disable-line no-new setData( model, '*foob[ar]' ); model.change( writer => { @@ -72,7 +72,7 @@ describe( 'InlineAutoformatEngine', () => { remove: [] } ); - new InlineAutoformatEngine( editor, testStub, formatSpy ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, testStub, formatSpy ); // eslint-disable-line no-new setData( model, '*[]' ); model.change( writer => { @@ -89,7 +89,7 @@ describe( 'InlineAutoformatEngine', () => { remove: [ [] ] } ); - new InlineAutoformatEngine( editor, testStub, formatSpy ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, testStub, formatSpy ); // eslint-disable-line no-new setData( model, '*[]' ); model.change( writer => { @@ -106,7 +106,7 @@ describe( 'InlineAutoformatEngine', () => { remove: [ [] ] } ); - new InlineAutoformatEngine( editor, testStub, formatSpy ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, testStub, formatSpy ); // eslint-disable-line no-new setData( model, '[]' ); model.change( writer => { @@ -123,7 +123,7 @@ describe( 'InlineAutoformatEngine', () => { .callThrough() .callsFake( ranges => ranges.map( saveDetachSpy ) ); - new InlineAutoformatEngine( editor, /(\*)(.+?)(\*)/g, callback ); // eslint-disable-line no-new + new InlineAutoformatEditing( editor, /(\*)(.+?)(\*)/g, callback ); // eslint-disable-line no-new setData( model, '*foobar[]' );