Sfoglia il codice sorgente

Stub IndentBlockCommand.

Maciej Gołaszewski 6 anni fa
parent
commit
0308d31764

+ 62 - 0
packages/ckeditor5-indent/src/indentblockcommand.js

@@ -0,0 +1,62 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module indent-block/indentblockcommand
+ */
+
+import Command from '@ckeditor/ckeditor5-core/src/command';
+import first from '@ckeditor/ckeditor5-utils/src/first';
+
+/**
+ * The block indentation feature.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class IndentBlockCommand extends Command {
+	/**
+	 * @inheritDoc
+	 */
+	refresh() {
+		this.isEnabled = this._checkEnabled();
+	}
+
+	/**
+	 * Indents or outdents (depends on the {@link #constructor}'s `indentDirection` parameter) selected list items.
+	 *
+	 * @fires execute
+	 */
+	execute() {
+		const model = this.editor.model;
+		const doc = model.document;
+
+		const itemsToChange = Array.from( doc.selection.getSelectedBlocks() );
+
+		model.change( () => {
+			for ( const item of itemsToChange ) {
+				// eslint-disable-next-line no-undef
+				console.log( 'indent block', item );
+			}
+		} );
+	}
+
+	/**
+	 * Checks whether the command can be enabled in the current context.
+	 *
+	 * @private
+	 * @returns {Boolean} Whether the command should be enabled.
+	 */
+	_checkEnabled() {
+		// Check whether any of position's ancestor is a list item.
+		const block = first( this.editor.model.document.selection.getSelectedBlocks() );
+
+		// If selection is not in a list item, the command is disabled.
+		if ( !block || !this.editor.model.schema.checkAttribute( block, 'indent' ) ) {
+			return false;
+		}
+
+		return true;
+	}
+}

+ 4 - 50
packages/ckeditor5-indent/tests/manual/indent-block.js

@@ -10,58 +10,12 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'
 import MultiCommand from '@ckeditor/ckeditor5-core/src/multicommand';
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
-import Command from '@ckeditor/ckeditor5-core/src/command';
-import first from '@ckeditor/ckeditor5-utils/src/first';
-
-import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 import IndentBlock from '../../src/indentblock';
 
-class IndentBlockCommand extends Command {
-	/**
-	 * @inheritDoc
-	 */
-	refresh() {
-		this.isEnabled = this._checkEnabled();
-	}
-
-	/**
-	 * Indents or outdents (depends on the {@link #constructor}'s `indentDirection` parameter) selected list items.
-	 *
-	 * @fires execute
-	 */
-	execute() {
-		const model = this.editor.model;
-		const doc = model.document;
-
-		const itemsToChange = Array.from( doc.selection.getSelectedBlocks() );
-
-		model.change( () => {
-			for ( const item of itemsToChange ) {
-				console.log( 'indent block', item );
-			}
-		} );
-	}
-
-	/**
-	 * Checks whether the command can be enabled in the current context.
-	 *
-	 * @private
-	 * @returns {Boolean} Whether the command should be enabled.
-	 */
-	_checkEnabled() {
-		// Check whether any of position's ancestor is a list item.
-		const block = first( this.editor.model.document.selection.getSelectedBlocks() );
-
-		// If selection is not in a list item, the command is disabled.
-		if ( !block || !this.editor.model.schema.checkAttribute( block, 'indent' ) ) {
-			return false;
-		}
-
-		return true;
-	}
-}
+import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import IndentBlockCommand from '../../src/indentblockcommand';
 
-class IndentOutdent extends Plugin {
+class IndentUI extends Plugin {
 	init() {
 		const editor = this.editor;
 		const t = editor.t;
@@ -120,7 +74,7 @@ class IndentOutdent extends Plugin {
 }
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
-		plugins: [ ArticlePluginSet, IndentOutdent, IndentBlock ],
+		plugins: [ ArticlePluginSet, IndentUI, IndentBlock ],
 		toolbar: [
 			'heading',
 			// '|',