Browse Source

Made ImageStyleEngine.localizedDefaultStylesTitles a public getter.

Aleksander Nowodzinski 8 years ago
parent
commit
30c8e52be9

+ 2 - 3
packages/ckeditor5-image/src/imagestyle/imagestyleengine.js

@@ -85,7 +85,7 @@ export default class ImageStyleEngine extends Plugin {
 
 		const styles = [];
 		const editor = this.editor;
-		const titles = this._localizedStyleTitles;
+		const titles = this.localizedDefaultStylesTitles;
 		const configuredStyles = editor.config.get( 'image.styles' );
 
 		for ( let style of configuredStyles ) {
@@ -109,10 +109,9 @@ export default class ImageStyleEngine extends Plugin {
 	 * use in the {@link #imageStyles}.
 	 *
 	 * @readonly
-	 * @private
 	 * @type {Object.<String,String>}
 	 */
-	get _localizedStyleTitles() {
+	get localizedDefaultStylesTitles() {
 		const t = this.editor.t;
 
 		return {

+ 29 - 0
packages/ckeditor5-image/tests/imagestyle/imagestyleengine.js

@@ -69,6 +69,8 @@ describe( 'ImageStyleEngine', () => {
 					plugins: [ ImageStyleEngine ]
 				} )
 				.then( newEditor => {
+					editor = newEditor;
+
 					expect( newEditor.config.get( 'image.styles' ) ).to.deep.equal( [ 'imageStyleFull', 'imageStyleSide' ] );
 				} );
 		} );
@@ -286,6 +288,8 @@ describe( 'ImageStyleEngine', () => {
 					plugins: [ ImageStyleEngine ]
 				} )
 				.then( newEditor => {
+					editor = newEditor;
+
 					expect( newEditor.config.get( 'image.styles' ) ).to.deep.equal( [ 'imageStyleFull', 'imageStyleSide' ] );
 				} );
 		} );
@@ -301,6 +305,8 @@ describe( 'ImageStyleEngine', () => {
 					}
 				} )
 				.then( newEditor => {
+					editor = newEditor;
+
 					expect( newEditor.config.get( 'image.styles' ) ).to.deep.equal( [ 'imageStyleSide' ] );
 				} );
 		} );
@@ -316,6 +322,8 @@ describe( 'ImageStyleEngine', () => {
 					}
 				} )
 				.then( newEditor => {
+					editor = newEditor;
+
 					expect( newEditor.config.get( 'image.styles' ) ).to.deep.equal( [ { name: 'imageStyleSide' } ] );
 				} );
 		} );
@@ -434,6 +442,27 @@ describe( 'ImageStyleEngine', () => {
 		} );
 	} );
 
+	describe( 'localizedDefaultStylesTitles()', () => {
+		it( 'should return localized titles of default styles', () => {
+			return VirtualTestEditor
+				.create( {
+					plugins: [ ImageStyleEngine ]
+				} )
+				.then( newEditor => {
+					editor = newEditor;
+					plugin = editor.plugins.get( ImageStyleEngine );
+
+					expect( plugin.localizedDefaultStylesTitles ).to.deep.equal( {
+						'Full size image': 'Full size image',
+						'Side image': 'Side image',
+						'Left aligned image': 'Left aligned image',
+						'Centered image': 'Centered image',
+						'Right aligned image': 'Right aligned image'
+					} );
+				} );
+		} );
+	} );
+
 	describe( 'defaultStyles', () => {
 		it( 'should be defined', () => {
 			expect( ImageStyleEngine.defaultStyles ).to.deep.equal( {