Browse Source

Renamed the package and classes.

Piotrek Koszuliński 9 years ago
parent
commit
734bd7dbce

+ 3 - 3
packages/ckeditor5-heading/package.json

@@ -1,5 +1,5 @@
 {
-  "name": "ckeditor5-headings",
+  "name": "ckeditor5-heading",
   "version": "0.2.0",
   "description": "Headings feature for CKEditor 5.",
   "keywords": [],
@@ -16,9 +16,9 @@
   "author": "CKSource (http://cksource.com/)",
   "license": "See LICENSE.md",
   "homepage": "https://ckeditor5.github.io",
-  "bugs": "https://github.com/ckeditor/ckeditor5-headings/issues",
+  "bugs": "https://github.com/ckeditor/ckeditor5-heading/issues",
   "repository": {
     "type": "git",
-    "url": "https://github.com/ckeditor/ckeditor5-headings.git"
+    "url": "https://github.com/ckeditor/ckeditor5-heading.git"
   }
 }

+ 8 - 8
packages/ckeditor5-heading/src/headings.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md.
  */
 
-import HeadingsEngine from './headingsengine.js';
+import HeadingEngine from './headingengine.js';
 
 import Feature from '../core/feature.js';
 
@@ -14,18 +14,18 @@ import ListDropdownView from '../ui/dropdown/list/listdropdownview.js';
 import Collection from '../utils/collection.js';
 
 /**
- * The headings feature. It introduces the headings drop-down list and the command that allows
+ * The headings feature. It introduces the `'headings'` drop-down list and the `'heading'` command which allow
  * to convert paragraphs into headings.
  *
- * @memberOf headings
+ * @memberOf heading
  * @extends core.Feature
  */
-export default class Headings extends Feature {
+export default class Heading extends Feature {
 	/**
 	 * @inheritDoc
 	 */
 	static get requires() {
-		return [ HeadingsEngine ];
+		return [ HeadingEngine ];
 	}
 
 	/**
@@ -33,7 +33,7 @@ export default class Headings extends Feature {
 	 */
 	init() {
 		const editor = this.editor;
-		const command = editor.commands.get( 'headings' );
+		const command = editor.commands.get( 'heading' );
 		const formats = command.formats;
 		const collection = new Collection();
 
@@ -49,7 +49,7 @@ export default class Headings extends Feature {
 		const dropdownModel = new Model( {
 			isEnabled: true,
 			isOn: false,
-			label: 'Headings',
+			label: 'Heading',
 			withText: true,
 
 			// Create item list model.
@@ -64,7 +64,7 @@ export default class Headings extends Feature {
 
 		// Execute command when an item from the dropdown is selected.
 		this.listenTo( dropdownModel, 'execute', ( evt ) => {
-			editor.execute( 'headings', evt.source.id );
+			editor.execute( 'heading', evt.source.id );
 			editor.editing.view.focus();
 		} );
 

+ 11 - 11
packages/ckeditor5-heading/src/headingscommand.js

@@ -7,17 +7,17 @@ import Command from '../core/command/command.js';
 import RootElement from '../engine/model/rootelement.js';
 
 /**
- * The headings command. It is used by the {@link headings.Headings headings feature}.
+ * The heading command. It is used by the {@link heading.Heading heading feature} to apply headings.
  *
- * @memberOf headings
+ * @memberOf heading
  * @extends core.command.Command
  */
-export default class HeadingsCommand extends Command {
+export default class HeadingCommand extends Command {
 	/**
 	 * Creates an instance of the command.
 	 *
 	 * @param {core.editor.Editor} editor Editor instance.
-	 * @param {Array.<headings.HeadingsFormat>} formats Heading formats to be used by the command instance.
+	 * @param {Array.<heading.HeadingFormat>} formats Heading formats to be used by the command instance.
 	 */
 	constructor( editor, formats ) {
 		super( editor );
@@ -26,7 +26,7 @@ export default class HeadingsCommand extends Command {
 		 * Heading formats used by this command.
 		 *
 		 * @readonly
-		 * @member {headings.HeadingsFormat} headings.HeadingsCommand#formats
+		 * @member {heading.HeadingFormat} heading.HeadingCommand#formats
 		 */
 		this.formats = formats;
 
@@ -35,7 +35,7 @@ export default class HeadingsCommand extends Command {
 		 *
 		 * @readonly
 		 * @observable
-		 * @member {headings.HeadingsFormat} headings.HeadingsCommand#value
+		 * @member {heading.HeadingFormat} heading.HeadingCommand#value
 		 */
 		this.set( 'value', this.defaultFormat );
 
@@ -56,7 +56,7 @@ export default class HeadingsCommand extends Command {
 	/**
 	 * The default format.
 	 *
-	 * @type {headings.HeadingsFormat}
+	 * @type {heading.HeadingFormat}
 	 */
 	get defaultFormat() {
 		// See https://github.com/ckeditor/ckeditor5/issues/98.
@@ -68,8 +68,8 @@ export default class HeadingsCommand extends Command {
 	 *
 	 * @protected
 	 * @param {String} [formatId] The identifier of the heading format that should be applied. It should be one of the
-	 * {@link headings.HeadingsFormat heading formats} provided to the command constructor. If this parameter is not provided,
-	 * the value from {@link headings.HeadingsCommand#defaultFormat defaultFormat} will be used.
+	 * {@link heading.HeadingFormat heading formats} provided to the command constructor. If this parameter is not provided,
+	 * the value from {@link heading.HeadingCommand#defaultFormat defaultFormat} will be used.
 	 */
 	_doExecute( formatId = this.defaultFormat.id ) {
 		// TODO: What should happen if format is not found?
@@ -132,7 +132,7 @@ export default class HeadingsCommand extends Command {
 	 *
 	 * @private
 	 * @param {String} id
-	 * @returns {headings.HeadingsFormat}
+	 * @returns {heading.HeadingFormat}
 	 */
 	_getFormatById( id ) {
 		return this.formats.find( item => item.id === id ) || this.defaultFormat;
@@ -167,7 +167,7 @@ function findTopmostBlock( position, nodeAfter = true ) {
 /**
  * Heading format descriptor.
  *
- * @typedef {Object} headings.HeadingsFormat
+ * @typedef {Object} heading.HeadingFormat
  * @property {String} id Format identifier. It will be used as the element's name in the model.
  * @property {String} viewElement The name of the view element that will be used to represent the model element in the view.
  * @property {String} label The display name of the format.

+ 8 - 8
packages/ckeditor5-heading/src/headingsengine.js

@@ -7,7 +7,7 @@ import Feature from '../core/feature.js';
 import buildModelConverter from '../engine/conversion/buildmodelconverter.js';
 import buildViewConverter from '../engine/conversion/buildviewconverter.js';
 import Paragraph from '../paragraph/paragraph.js';
-import HeadingsCommand from './headingscommand.js';
+import HeadingCommand from './headingcommand.js';
 
 const formats = [
 	{ id: 'paragraph', viewElement: 'p', label: 'Paragraph' },
@@ -17,13 +17,13 @@ const formats = [
 ];
 
 /**
- * The headings feature. It handles switching between block formats &mdash; different headings and paragraph.
- * This class represents the engine part of the headings feature.
+ * The headings engine feature. It handles switching between block formats &ndash; headings and paragraph.
+ * This class represents the engine part of the heading feature. See also {@link heading.Heading}.
  *
- * @memberOf headings
+ * @memberOf heading
  * @extends core.Feature
  */
-export default class HeadingsEngine extends Feature {
+export default class HeadingEngine extends Feature {
 	/**
 	 * @inheritDoc
 	 */
@@ -57,9 +57,9 @@ export default class HeadingsEngine extends Feature {
 			}
 		}
 
-		// Register the headings command.
-		const command = new HeadingsCommand( editor, formats );
-		editor.commands.set( 'headings', command );
+		// Register the heading command.
+		const command = new HeadingCommand( editor, formats );
+		editor.commands.set( 'heading', command );
 
 		// If the enter command is added to the editor, alter its behavior.
 		// Enter at the end of a heading element should create a paragraph.

+ 9 - 9
packages/ckeditor5-heading/tests/headings.js

@@ -6,14 +6,14 @@
 /* globals document */
 
 import ClassicTestEditor from '/tests/core/_utils/classictesteditor.js';
-import Headings from '/ckeditor5/headings/headings.js';
-import HeadingsEngine from '/ckeditor5/headings/headingsengine.js';
+import Heading from '/ckeditor5/heading/heading.js';
+import HeadingEngine from '/ckeditor5/heading/headingengine.js';
 import ListDropdown from '/ckeditor5/ui/dropdown/list/listdropdown.js';
 import testUtils from '/tests/core/_utils/utils.js';
 
 testUtils.createSinonSandbox();
 
-describe( 'Headings', () => {
+describe( 'Heading', () => {
 	let editor, controller;
 
 	beforeEach( () => {
@@ -21,8 +21,8 @@ describe( 'Headings', () => {
 		document.body.appendChild( editorElement );
 
 		return ClassicTestEditor.create( editorElement, {
-			features: [ Headings ],
-			toolbar: [ 'headings' ]
+			features: [ Heading ],
+			toolbar: [ 'heading' ]
 		} )
 		.then( newEditor => {
 			editor = newEditor;
@@ -35,11 +35,11 @@ describe( 'Headings', () => {
 	} );
 
 	it( 'should be loaded', () => {
-		expect( editor.plugins.get( Headings ) ).to.be.instanceOf( Headings );
+		expect( editor.plugins.get( Heading ) ).to.be.instanceOf( Heading );
 	} );
 
 	it( 'should load FormatsEngine', () => {
-		expect( editor.plugins.get( HeadingsEngine ) ).to.be.instanceOf( HeadingsEngine );
+		expect( editor.plugins.get( HeadingEngine ) ).to.be.instanceOf( HeadingEngine );
 	} );
 
 	it( 'should register formats feature component', () => {
@@ -57,7 +57,7 @@ describe( 'Headings', () => {
 		model.fire( 'execute' );
 
 		sinon.assert.calledOnce( executeSpy );
-		sinon.assert.calledWithExactly( executeSpy, 'headings', 'foo' );
+		sinon.assert.calledWithExactly( executeSpy, 'heading', 'foo' );
 	} );
 
 	it( 'should focus view after command execution', () => {
@@ -75,7 +75,7 @@ describe( 'Headings', () => {
 
 		beforeEach( () => {
 			model = controller.model;
-			command = editor.commands.get( 'headings' );
+			command = editor.commands.get( 'heading' );
 		} );
 
 		it( 'isEnabled', () => {

+ 3 - 3
packages/ckeditor5-heading/tests/headingscommand.js

@@ -4,7 +4,7 @@
  */
 
 import ModelTestEditor from '/tests/core/_utils/modeltesteditor.js';
-import HeadingsCommand from '/ckeditor5/headings/headingscommand.js';
+import HeadingCommand from '/ckeditor5/heading/headingcommand.js';
 import Range from '/ckeditor5/engine/model/range.js';
 import { setData, getData } from '/tests/engine/_utils/model.js';
 
@@ -15,7 +15,7 @@ const formats = [
 	{ id: 'heading3', viewElement: 'h4' }
 ];
 
-describe( 'HeadingsCommand', () => {
+describe( 'HeadingCommand', () => {
 	let editor, document, command, root, schema;
 
 	beforeEach( () => {
@@ -23,7 +23,7 @@ describe( 'HeadingsCommand', () => {
 			.then( newEditor => {
 				editor = newEditor;
 				document = editor.document;
-				command = new HeadingsCommand( editor, formats );
+				command = new HeadingCommand( editor, formats );
 				schema = document.schema;
 
 				for ( let format of formats ) {

+ 8 - 8
packages/ckeditor5-heading/tests/headingsengine.js

@@ -3,19 +3,19 @@
  * For licensing, see LICENSE.md.
  */
 
-import HeadingsEngine from '/ckeditor5/headings/headingsengine.js';
+import HeadingEngine from '/ckeditor5/heading/headingengine.js';
 import Paragraph from '/ckeditor5/paragraph/paragraph.js';
 import VirtualTestEditor from '/tests/core/_utils/virtualtesteditor.js';
-import HeadingsCommand from '/ckeditor5/headings/headingscommand.js';
+import HeadingCommand from '/ckeditor5/heading/headingcommand.js';
 import Enter from '/ckeditor5/enter/enter.js';
 import { getData } from '/tests/engine/_utils/model.js';
 
-describe( 'HeadingsEngine', () => {
+describe( 'HeadingEngine', () => {
 	let editor, document;
 
 	beforeEach( () => {
 		return VirtualTestEditor.create( {
-			features: [ Enter, HeadingsEngine ]
+			features: [ Enter, HeadingEngine ]
 		} )
 		.then( newEditor => {
 			editor = newEditor;
@@ -24,7 +24,7 @@ describe( 'HeadingsEngine', () => {
 	} );
 
 	it( 'should be loaded', () => {
-		expect( editor.plugins.get( HeadingsEngine ) ).to.be.instanceOf( HeadingsEngine );
+		expect( editor.plugins.get( HeadingEngine ) ).to.be.instanceOf( HeadingEngine );
 	} );
 
 	it( 'should load paragraph feature', () => {
@@ -47,10 +47,10 @@ describe( 'HeadingsEngine', () => {
 	} );
 
 	it( 'should register format command', () => {
-		expect( editor.commands.has( 'headings' ) ).to.be.true;
-		const command = editor.commands.get( 'headings' );
+		expect( editor.commands.has( 'heading' ) ).to.be.true;
+		const command = editor.commands.get( 'heading' );
 
-		expect( command ).to.be.instanceOf( HeadingsCommand );
+		expect( command ).to.be.instanceOf( HeadingCommand );
 	} );
 
 	it( 'should convert heading1', () => {

packages/ckeditor5-heading/tests/manual/headings.html → packages/ckeditor5-heading/tests/manual/heading.html


+ 2 - 2
packages/ckeditor5-heading/tests/manual/headings.js

@@ -3,12 +3,12 @@
  * For licensing, see LICENSE.md.
  */
 
-/* globals console:false, document, window */
+/* globals console, document, window */
 
 import ClassicEditor from '/ckeditor5/editor-classic/classic.js';
 
 ClassicEditor.create( document.querySelector( '#editor' ), {
-	features: [ 'enter', 'typing', 'undo', 'headings' ],
+	features: [ 'enter', 'typing', 'undo', 'heading' ],
 	toolbar: [ 'headings', 'undo', 'redo' ]
 } )
 .then( editor => {

+ 1 - 1
packages/ckeditor5-heading/tests/manual/headings.md

@@ -1,6 +1,6 @@
 @bender-ui: collapsed
 
-## Headings
+## Heading feature
 
 1. The data should be loaded with three headings and one paragraph.
 2. Put selection inside each block and check if dropdown label is changing properly.