Przeglądaj źródła

Fixed model to view converter for image styles.

Szymon Kupś 9 lat temu
rodzic
commit
3d139524b2

+ 6 - 6
packages/ckeditor5-image/src/imagestyle/converters.js

@@ -30,20 +30,20 @@ export function modelToViewSetStyle( styles ) {
 		const oldStyle = getStyleByValue( data.attributeOldValue, styles );
 		const viewElement = conversionApi.mapper.toViewElement( data.item );
 
-		if ( eventType == 'addAttribute' || eventType == 'changeAttribute' ) {
-			if ( !newStyle ) {
+		if ( eventType == 'changeAttribute' || eventType == 'removeAttribute' ) {
+			if ( !oldStyle ) {
 				return;
 			}
 
-			viewElement.addClass( newStyle.className );
+			viewElement.removeClass( oldStyle.className );
 		}
 
-		if ( eventType == 'changeAttribute' || eventType == 'removeAttribute' ) {
-			if ( !oldStyle ) {
+		if ( eventType == 'addAttribute' || eventType == 'changeAttribute' ) {
+			if ( !newStyle ) {
 				return;
 			}
 
-			viewElement.removeClass( data.attributeOldValue );
+			viewElement.addClass( newStyle.className );
 		}
 
 		consumable.consume( data.item, consumableType );