浏览代码

Extract Indent plugin stub.

Maciej Gołaszewski 6 年之前
父节点
当前提交
cdec694a4e

+ 9 - 0
packages/ckeditor5-indent/src/indentblock.js

@@ -8,6 +8,8 @@
  */
 
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import Indent from '@ckeditor/ckeditor5-core/src/indent';
+
 import IndentBlockCommand from './indentblockcommand';
 
 /**
@@ -38,6 +40,13 @@ export default class IndentBlock extends Plugin {
 	/**
 	 * @inheritDoc
 	 */
+	static get requires() {
+		return [ Indent ];
+	}
+
+	/**
+	 * @inheritDoc
+	 */
 	init() {
 		const editor = this.editor;
 		const schema = editor.model.schema;

+ 2 - 48
packages/ckeditor5-indent/tests/manual/indent-block-classes.js

@@ -6,56 +6,10 @@
 /* globals console, window, document */
 
 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 IndentBlock from '../../src/indentblock';
-
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
+import Indent from '@ckeditor/ckeditor5-core/src/indent';
 
-class Indent extends Plugin {
-	init() {
-		const editor = this.editor;
-		const t = editor.t;
-
-		editor.commands.add( 'indent', new MultiCommand( editor ) );
-		editor.commands.add( 'outdent', new MultiCommand( editor ) );
-
-		this._createButton( 'indent', t( '>' ) );
-		this._createButton( 'outdent', t( '<' ) );
-
-		// TODO: temporary - tests only
-		this._createButton( 'indentList', t( '> List' ) );
-		this._createButton( 'outdentList', t( '< List' ) );
-
-		// TODO: temporary - tests only
-		this._createButton( 'indentBlock', t( '> Block' ) );
-		this._createButton( 'outdentBlock', t( '< Block' ) );
-	}
-
-	_createButton( commandName, label ) {
-		const editor = this.editor;
-
-		editor.ui.componentFactory.add( commandName, locale => {
-			const command = editor.commands.get( commandName );
-			const view = new ButtonView( locale );
-
-			view.set( {
-				label,
-				withText: true,
-				tooltip: true
-			} );
-
-			view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
-
-			// Execute command.
-			this.listenTo( view, 'execute', () => editor.execute( commandName ) );
-
-			return view;
-		} );
-	}
-}
+import IndentBlock from '../../src/indentblock';
 
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {

+ 1 - 47
packages/ckeditor5-indent/tests/manual/indent-block.js

@@ -7,59 +7,13 @@
 
 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 IndentBlock from '../../src/indentblock';
 
 import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
 
-class Indent extends Plugin {
-	init() {
-		const editor = this.editor;
-		const t = editor.t;
-
-		editor.commands.add( 'indent', new MultiCommand( editor ) );
-		editor.commands.add( 'outdent', new MultiCommand( editor ) );
-
-		this._createButton( 'indent', t( '>' ) );
-		this._createButton( 'outdent', t( '<' ) );
-
-		// TODO: temporary - tests only
-		this._createButton( 'indentList', t( '> List' ) );
-		this._createButton( 'outdentList', t( '< List' ) );
-
-		// TODO: temporary - tests only
-		this._createButton( 'indentBlock', t( '> Block' ) );
-		this._createButton( 'outdentBlock', t( '< Block' ) );
-	}
-
-	_createButton( commandName, label ) {
-		const editor = this.editor;
-
-		editor.ui.componentFactory.add( commandName, locale => {
-			const command = editor.commands.get( commandName );
-			const view = new ButtonView( locale );
-
-			view.set( {
-				label,
-				withText: true,
-				tooltip: true
-			} );
-
-			view.bind( 'isOn', 'isEnabled' ).to( command, 'value', 'isEnabled' );
-
-			// Execute command.
-			this.listenTo( view, 'execute', () => editor.execute( commandName ) );
-
-			return view;
-		} );
-	}
-}
-
 ClassicEditor
 	.create( document.querySelector( '#editor' ), {
-		plugins: [ ArticlePluginSet, Indent, IndentBlock ],
+		plugins: [ ArticlePluginSet, IndentBlock ],
 		toolbar: [
 			'heading',
 			'|',