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

Feature: Changed `ImageStyleCommand#defaultStyle` from private to public readonly property.

Szymon Cofalik 6 лет назад
Родитель
Сommit
8f319cc43b

+ 5 - 5
packages/ckeditor5-image/src/imagestyle/imagestylecommand.js

@@ -26,12 +26,12 @@ export default class ImageStyleCommand extends Command {
 		super( editor );
 		super( editor );
 
 
 		/**
 		/**
-		 * The cached name of the default style if it is present. If there is no default style, it defaults to `false`.
+		 * The name of the default style, if it is present. If there is no default style, it defaults to `false`.
 		 *
 		 *
+		 * @readonly
 		 * @type {Boolean|String}
 		 * @type {Boolean|String}
-		 * @private
 		 */
 		 */
-		this._defaultStyle = false;
+		this.defaultStyle = false;
 
 
 		/**
 		/**
 		 * A style handled by this command.
 		 * A style handled by this command.
@@ -43,7 +43,7 @@ export default class ImageStyleCommand extends Command {
 			styles[ style.name ] = style;
 			styles[ style.name ] = style;
 
 
 			if ( style.isDefault ) {
 			if ( style.isDefault ) {
-				this._defaultStyle = style.name;
+				this.defaultStyle = style.name;
 			}
 			}
 
 
 			return styles;
 			return styles;
@@ -64,7 +64,7 @@ export default class ImageStyleCommand extends Command {
 			const attributeValue = element.getAttribute( 'imageStyle' );
 			const attributeValue = element.getAttribute( 'imageStyle' );
 			this.value = this.styles[ attributeValue ] ? attributeValue : false;
 			this.value = this.styles[ attributeValue ] ? attributeValue : false;
 		} else {
 		} else {
-			this.value = this._defaultStyle;
+			this.value = this.defaultStyle;
 		}
 		}
 	}
 	}
 
 

+ 4 - 0
packages/ckeditor5-image/tests/imagestyle/imagestylecommand.js

@@ -30,6 +30,10 @@ describe( 'ImageStyleCommand', () => {
 			} );
 			} );
 	} );
 	} );
 
 
+	it( 'should have defaultStyle property correctly set', () => {
+		expect( command.defaultStyle ).to.equal( 'defaultStyle' );
+	} );
+
 	it( 'command value should be false if no image is selected', () => {
 	it( 'command value should be false if no image is selected', () => {
 		setData( model, '[]<image></image>' );
 		setData( model, '[]<image></image>' );