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

Other: Removed config.image.defaultToolbar. Closes #60.

Aleksander Nowodzinski 8 лет назад
Родитель
Сommit
3dc16ed928

+ 0 - 11
packages/ckeditor5-image/src/imagestyle.js

@@ -42,17 +42,6 @@ export default class ImageStyle extends Plugin {
 		for ( let style of styles ) {
 		for ( let style of styles ) {
 			this._createButton( style );
 			this._createButton( style );
 		}
 		}
-
-		// Push buttons to default image toolbar if one exists.
-		const defaultImageToolbarConfig = this.editor.config.get( 'image.defaultToolbar' );
-
-		if ( defaultImageToolbarConfig ) {
-			if ( defaultImageToolbarConfig.length ) {
-				defaultImageToolbarConfig.push( '|' );
-			}
-
-			styles.forEach( style => defaultImageToolbarConfig.push( style.name ) );
-		}
 	}
 	}
 
 
 	/**
 	/**

+ 0 - 11
packages/ckeditor5-image/src/imagetextalternative.js

@@ -45,17 +45,6 @@ export default class ImageTextAlternative extends Plugin {
 	init() {
 	init() {
 		this._createButton();
 		this._createButton();
 
 
-		// Push button to default image toolbar if the image toolbar was loaded.
-		const defaultImageToolbarConfig = this.editor.config.get( 'image.defaultToolbar' );
-
-		if ( defaultImageToolbarConfig ) {
-			if ( defaultImageToolbarConfig.length ) {
-				defaultImageToolbarConfig.push( '|' );
-			}
-
-			defaultImageToolbarConfig.push( 'imageTextAlternative' );
-		}
-
 		return this._createBalloonPanel().then( panel => {
 		return this._createBalloonPanel().then( panel => {
 			/**
 			/**
 			 * Balloon panel containing text alternative change form.
 			 * Balloon panel containing text alternative change form.

+ 2 - 6
packages/ckeditor5-image/src/imagetoolbar.js

@@ -17,8 +17,6 @@ import ImageBalloonPanel from './image/ui/imageballoonpanelview';
  * Image toolbar class. Creates image toolbar placed inside balloon panel that is showed when image widget is selected.
  * Image toolbar class. Creates image toolbar placed inside balloon panel that is showed when image widget is selected.
  * Toolbar components are created using editor's {@link module:ui/componentfactory~ComponentFactory ComponentFactory}
  * Toolbar components are created using editor's {@link module:ui/componentfactory~ComponentFactory ComponentFactory}
  * based on {@link module:core/editor/editor~Editor#config configuration} stored under `image.toolbar`.
  * based on {@link module:core/editor/editor~Editor#config configuration} stored under `image.toolbar`.
- * Other plugins can add new components to the default toolbar configuration by pushing them to `image.defaultToolbar`
- * configuration. Default configuration is used when `image.toolbar` config is not present.
  *
  *
  * @extends module:core/plugin~Plugin
  * @extends module:core/plugin~Plugin
  */
  */
@@ -36,8 +34,6 @@ export default class ImageToolbar extends Plugin {
 	constructor( editor ) {
 	constructor( editor ) {
 		super( editor );
 		super( editor );
 
 
-		editor.config.set( 'image.defaultToolbar', [] );
-
 		/**
 		/**
 		 * When set to `true`, toolbar will be repositioned and showed on each render event and focus change.
 		 * When set to `true`, toolbar will be repositioned and showed on each render event and focus change.
 		 * Set to `false` to temporary disable the image toolbar.
 		 * Set to `false` to temporary disable the image toolbar.
@@ -52,10 +48,10 @@ export default class ImageToolbar extends Plugin {
 	 */
 	 */
 	afterInit() {
 	afterInit() {
 		const editor = this.editor;
 		const editor = this.editor;
-		const toolbarConfig = editor.config.get( 'image.toolbar' ) || editor.config.get( 'image.defaultToolbar' );
+		const toolbarConfig = editor.config.get( 'image.toolbar' );
 
 
 		// Don't add the toolbar if there is no configuration.
 		// Don't add the toolbar if there is no configuration.
-		if ( !toolbarConfig.length ) {
+		if ( !toolbarConfig || !toolbarConfig.length ) {
 			return;
 			return;
 		}
 		}
 
 

+ 0 - 42
packages/ckeditor5-image/tests/imagestyle.js

@@ -3,9 +3,7 @@
  * For licensing, see LICENSE.md.
  * For licensing, see LICENSE.md.
  */
  */
 
 
-import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
-import ImageToolbar from '../src/imagetoolbar';
 import ImageStyle from '../src/imagestyle';
 import ImageStyle from '../src/imagestyle';
 import ImageStyleEngine from '../src/imagestyle/imagestyleengine';
 import ImageStyleEngine from '../src/imagestyle/imagestyleengine';
 import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
 import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
@@ -69,46 +67,6 @@ describe( 'ImageStyle', () => {
 		}
 		}
 	} );
 	} );
 
 
-	it( 'should not add buttons to default image toolbar if image toolbar is not present', () => {
-		expect( editor.config.get( 'image.defaultToolbar' ) ).to.be.undefined;
-	} );
-
-	it( 'should add buttons to default image toolbar if toolbar is present', () => {
-		const editorElement = global.document.createElement( 'div' );
-		global.document.body.appendChild( editorElement );
-
-		return ClassicTestEditor.create( editorElement, {
-			plugins: [ ImageStyle, ImageToolbar ]
-		} )
-			.then( newEditor => {
-				expect( newEditor.config.get( 'image.defaultToolbar' ) ).to.eql( [ 'imageStyleFull', 'imageStyleSide' ] );
-
-				newEditor.destroy();
-			} );
-	} );
-
-	it( 'should add separator before the button if toolbar is present and already has items', () => {
-		const editorElement = global.document.createElement( 'div' );
-		global.document.body.appendChild( editorElement );
-
-		const FooPlugin = class extends Plugin {
-			init() {
-				this.editor.ui.componentFactory.add( 'foo', () => new ButtonView() );
-
-				this.editor.config.get( 'image.defaultToolbar' ).push( 'foo' );
-			}
-		};
-
-		return ClassicTestEditor.create( editorElement, {
-			plugins: [ FooPlugin, ImageStyle, ImageToolbar ]
-		} )
-		.then( newEditor => {
-			expect( newEditor.config.get( 'image.defaultToolbar' ) ).to.eql( [ 'foo', '|', 'imageStyleFull', 'imageStyleSide' ] );
-
-			newEditor.destroy();
-		} );
-	} );
-
 	it( 'should not add buttons to image toolbar if configuration is present', () => {
 	it( 'should not add buttons to image toolbar if configuration is present', () => {
 		const editorElement = global.document.createElement( 'div' );
 		const editorElement = global.document.createElement( 'div' );
 		global.document.body.appendChild( editorElement );
 		global.document.body.appendChild( editorElement );

+ 0 - 41
packages/ckeditor5-image/tests/imagetextalternative.js

@@ -3,7 +3,6 @@
  * For licensing, see LICENSE.md.
  * For licensing, see LICENSE.md.
  */
  */
 
 
-import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
 import Image from '../src/image';
 import Image from '../src/image';
 import ImageToolbar from '../src/imagetoolbar';
 import ImageToolbar from '../src/imagetoolbar';
@@ -92,46 +91,6 @@ describe( 'ImageTextAlternative', () => {
 			sinon.assert.calledOnce( spy );
 			sinon.assert.calledOnce( spy );
 			expect( plugin.form.lebeledInput.value ).equals( '' );
 			expect( plugin.form.lebeledInput.value ).equals( '' );
 		} );
 		} );
-
-		it( 'should not add button to default image toolbar if image toolbar is not present', () => {
-			expect( editor.config.get( 'image.defaultToolbar' ) ).to.be.undefined;
-		} );
-
-		it( 'should add button to default image toolbar if toolbar is present', () => {
-			const editorElement = global.document.createElement( 'div' );
-			global.document.body.appendChild( editorElement );
-
-			return ClassicTestEditor.create( editorElement, {
-				plugins: [ ImageTextAlternative, ImageToolbar ]
-			} )
-			.then( newEditor => {
-				expect( newEditor.config.get( 'image.defaultToolbar' ) ).to.eql( [ 'imageTextAlternative' ] );
-
-				newEditor.destroy();
-			} );
-		} );
-
-		it( 'should add separator before the button if toolbar is present and already has items', () => {
-			const editorElement = global.document.createElement( 'div' );
-			global.document.body.appendChild( editorElement );
-
-			const FooPlugin = class extends Plugin {
-				init() {
-					this.editor.ui.componentFactory.add( 'foo', () => new ButtonView() );
-
-					this.editor.config.get( 'image.defaultToolbar' ).push( 'foo' );
-				}
-			};
-
-			return ClassicTestEditor.create( editorElement, {
-				plugins: [ FooPlugin, ImageTextAlternative, ImageToolbar ]
-			} )
-			.then( newEditor => {
-				expect( newEditor.config.get( 'image.defaultToolbar' ) ).to.eql( [ 'foo', '|', 'imageTextAlternative' ] );
-
-				newEditor.destroy();
-			} );
-		} );
 	} );
 	} );
 
 
 	describe( 'balloon panel form', () => {
 	describe( 'balloon panel form', () => {

+ 0 - 43
packages/ckeditor5-image/tests/imagetoolbar.js

@@ -42,20 +42,6 @@ describe( 'ImageToolbar', () => {
 		expect( editor.plugins.get( ImageToolbar ) ).to.be.instanceOf( ImageToolbar );
 		expect( editor.plugins.get( ImageToolbar ) ).to.be.instanceOf( ImageToolbar );
 	} );
 	} );
 
 
-	it( 'should initialize image.defaultToolbar to an empty array', () => {
-		const editorElement = global.document.createElement( 'div' );
-		global.document.body.appendChild( editorElement );
-
-		return ClassicEditor.create( editorElement, {
-			plugins: [ ImageToolbar ],
-		} )
-		.then( editor => {
-			expect( editor.config.get( 'image.defaultToolbar' ) ).to.eql( [] );
-
-			return editor.destroy();
-		} );
-	} );
-
 	it( 'should not initialize if there is no configuration', () => {
 	it( 'should not initialize if there is no configuration', () => {
 		const editorElement = global.document.createElement( 'div' );
 		const editorElement = global.document.createElement( 'div' );
 		global.document.body.appendChild( editorElement );
 		global.document.body.appendChild( editorElement );
@@ -70,25 +56,6 @@ describe( 'ImageToolbar', () => {
 			} );
 			} );
 	} );
 	} );
 
 
-	it( 'should allow other plugins to alter default config', () => {
-		const editorElement = global.document.createElement( 'div' );
-		global.document.body.appendChild( editorElement );
-
-		return ClassicEditor.create( editorElement, {
-			plugins: [ ImageToolbar, FakeButton, AlterDefaultConfig ]
-		} )
-			.then( newEditor => {
-				const panel = newEditor.plugins.get( ImageToolbar )._panel;
-				const toolbar = panel.content.get( 0 );
-				const button = toolbar.items.get( 0 );
-
-				expect( newEditor.config.get( 'image.defaultToolbar' ) ).to.eql( [ 'fake_button' ] );
-				expect( button.label ).to.equal( 'fake button' );
-
-				newEditor.destroy();
-			} );
-	} );
-
 	it( 'should add ImageBalloonPanel to view body', () => {
 	it( 'should add ImageBalloonPanel to view body', () => {
 		expect( panel ).to.be.instanceOf( ImageBalloonPanel );
 		expect( panel ).to.be.instanceOf( ImageBalloonPanel );
 	} );
 	} );
@@ -145,14 +112,4 @@ describe( 'ImageToolbar', () => {
 			} );
 			} );
 		}
 		}
 	}
 	}
-
-	class AlterDefaultConfig extends Plugin {
-		init() {
-			const defaultImageToolbarConfig = this.editor.config.get( 'image.defaultToolbar' );
-
-			if ( defaultImageToolbarConfig ) {
-				defaultImageToolbarConfig.push( 'fake_button' );
-			}
-		}
-	}
 } );
 } );

+ 4 - 1
packages/ckeditor5-image/tests/manual/caption.js

@@ -25,7 +25,10 @@ ClassicEditor.create( document.querySelector( '#editor' ), {
 		Enter, Typing, Paragraph, Heading, Image, ImageToolbar,
 		Enter, Typing, Paragraph, Heading, Image, ImageToolbar,
 		Undo, Clipboard, ImageCaption, ImageStyle, Bold, Italic, Heading, List
 		Undo, Clipboard, ImageCaption, ImageStyle, Bold, Italic, Heading, List
 	],
 	],
-	toolbar: [ 'headings', 'undo', 'redo', 'bold', 'italic', 'bulletedList', 'numberedList' ]
+	toolbar: [ 'headings', 'undo', 'redo', 'bold', 'italic', 'bulletedList', 'numberedList' ],
+	image: {
+		toolbar: [ 'imageStyleFull', 'imageStyleSide', '|' , 'imageTextAlternative' ]
+	}
 } )
 } )
 .then( editor => {
 .then( editor => {
 	window.editor = editor;
 	window.editor = editor;

+ 4 - 1
packages/ckeditor5-image/tests/manual/imagestyle.js

@@ -18,7 +18,10 @@ import ImageToolbar from '../../src/imagetoolbar';
 
 
 ClassicEditor.create( document.querySelector( '#editor' ), {
 ClassicEditor.create( document.querySelector( '#editor' ), {
 	plugins: [ ImageToolbar, EnterPlugin, TypingPlugin, ParagraphPlugin, HeadingPlugin, ImagePlugin, UndoPlugin, ClipboardPlugin, ImageStyle ],
 	plugins: [ ImageToolbar, EnterPlugin, TypingPlugin, ParagraphPlugin, HeadingPlugin, ImagePlugin, UndoPlugin, ClipboardPlugin, ImageStyle ],
-	toolbar: [ 'headings', 'undo', 'redo' ]
+	toolbar: [ 'headings', 'undo', 'redo' ],
+	image: {
+		toolbar: [ 'imageStyleFull', 'imageStyleSide' ]
+	}
 } )
 } )
 .then( editor => {
 .then( editor => {
 	window.editor = editor;
 	window.editor = editor;

+ 4 - 1
packages/ckeditor5-image/tests/manual/textalternative.js

@@ -17,7 +17,10 @@ import ImageToolbar from '../../src/imagetoolbar';
 
 
 ClassicEditor.create( document.querySelector( '#editor' ), {
 ClassicEditor.create( document.querySelector( '#editor' ), {
 	plugins: [ EnterPlugin, TypingPlugin, ParagraphPlugin, HeadingPlugin, ImagePlugin, UndoPlugin, ClipboardPlugin, ImageToolbar ],
 	plugins: [ EnterPlugin, TypingPlugin, ParagraphPlugin, HeadingPlugin, ImagePlugin, UndoPlugin, ClipboardPlugin, ImageToolbar ],
-	toolbar: [ 'headings', 'undo', 'redo' ]
+	toolbar: [ 'headings', 'undo', 'redo' ],
+	image: {
+		toolbar: [ 'imageTextAlternative' ]
+	}
 } )
 } )
 .then( editor => {
 .then( editor => {
 	window.editor = editor;
 	window.editor = editor;