8
0
Просмотр исходного кода

Other: Added minor documentation.

Maciej Gołaszewski 8 лет назад
Родитель
Сommit
6cfe0458e8

+ 10 - 2
packages/ckeditor5-table/src/inserttablecommand.js

@@ -10,6 +10,11 @@
 import Command from '@ckeditor/ckeditor5-core/src/command';
 import Position from '@ckeditor/ckeditor5-engine/src/model/position';
 
+/**
+ * The insert table command.
+ *
+ * @extends module:core/command~Command
+ */
 export default class InsertTableCommand extends Command {
 	/**
 	 * @inheritDoc
@@ -42,6 +47,7 @@ export default class InsertTableCommand extends Command {
 		const columns = parseInt( options.columns ) || 2;
 
 		const firstPosition = selection.getFirstPosition();
+
 		// TODO does API has it?
 		const isRoot = firstPosition.parent === firstPosition.root;
 		const insertTablePosition = isRoot ? Position.createAt( firstPosition ) : Position.createAfter( firstPosition.parent );
@@ -51,13 +57,15 @@ export default class InsertTableCommand extends Command {
 
 			writer.insert( table, insertTablePosition );
 
-			for ( let r = 0; r < rows; r++ ) {
+			// Create rows x columns table.
+			for ( let row = 0; row < rows; row++ ) {
 				const row = writer.createElement( 'tableRow' );
 
 				writer.insert( row, table, 'end' );
 
-				for ( let c = 0; c < columns; c++ ) {
+				for ( let column = 0; column < columns; column++ ) {
 					const cell = writer.createElement( 'tableCell' );
+
 					writer.insert( cell, row, 'end' );
 				}
 			}

+ 7 - 2
packages/ckeditor5-table/src/table.js

@@ -12,7 +12,12 @@ import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import TablesEditing from './tableediting';
 import TablesUI from './tableui';
 
-export default class Tables extends Plugin {
+/**
+ * The highlight plugin.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class Table extends Plugin {
 	/**
 	 * @inheritDoc
 	 */
@@ -24,6 +29,6 @@ export default class Tables extends Plugin {
 	 * @inheritDoc
 	 */
 	static get pluginName() {
-		return 'Tables';
+		return 'Table';
 	}
 }

+ 5 - 0
packages/ckeditor5-table/src/tableediting.js

@@ -12,6 +12,11 @@ import { upcastElementToElement } from '@ckeditor/ckeditor5-engine/src/conversio
 import { downcastTableCell, downcastTable, upcastTable } from './converters';
 import InsertTableCommand from './inserttablecommand';
 
+/**
+ * The table editing feature.
+ *
+ * @extends module:core/plugin~Plugin
+ */
 export default class TablesEditing extends Plugin {
 	/**
 	 * @inheritDoc

+ 6 - 1
packages/ckeditor5-table/src/tableui.js

@@ -12,6 +12,11 @@ import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
 
 import icon from '@ckeditor/ckeditor5-core/theme/icons/object-center.svg';
 
+/**
+ * The table UI plugin.
+ *
+ * @extends module:core/plugin~Plugin
+ */
 export default class TableUI extends Plugin {
 	/**
 	 * @inheritDoc
@@ -26,8 +31,8 @@ export default class TableUI extends Plugin {
 			buttonView.bind( 'isEnabled' ).to( command );
 
 			buttonView.set( {
-				label: 'Insert table',
 				icon,
+				label: 'Insert table',
 				tooltip: true
 			} );
 

+ 4 - 25
packages/ckeditor5-table/tests/table.js

@@ -3,37 +3,16 @@
  * For licensing, see LICENSE.md.
  */
 
-/* global document */
-
 import Table from '../src/table';
 import TableEditing from '../src/tableediting';
 import TableUI from '../src/tableui';
 
-import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
-
 describe( 'Table', () => {
-	let editor, element;
-
-	beforeEach( () => {
-		element = document.createElement( 'div' );
-		document.body.appendChild( element );
-
-		return ClassicTestEditor
-			.create( element, {
-				plugins: [ Table ]
-			} )
-			.then( newEditor => {
-				editor = newEditor;
-			} );
-	} );
-
-	afterEach( () => {
-		element.remove();
-
-		return editor.destroy();
-	} );
-
 	it( 'requires TableEditing and TableUI', () => {
 		expect( Table.requires ).to.deep.equal( [ TableEditing, TableUI ] );
 	} );
+
+	it( 'has proper name', () => {
+		expect( Table.pluginName ).to.equal( 'Table' );
+	} );
 } );