diff --git a/src/imagestyle/imagestylecommand.js b/src/imagestyle/imagestylecommand.js index 3a9dd3d7..24461890 100644 --- a/src/imagestyle/imagestylecommand.js +++ b/src/imagestyle/imagestylecommand.js @@ -79,7 +79,13 @@ export default class ImageStyleCommand extends Command { doc.enqueueChanges( () => { const batch = options.batch || doc.batch(); - batch.setAttribute( imageElement, 'imageStyle', this.style.name ); + // Default style means that there is no `imageStyle` attribute in the model. + // https://github.com/ckeditor/ckeditor5-image/issues/147 + if ( this.style.isDefault ) { + batch.removeAttribute( imageElement, 'imageStyle' ); + } else { + batch.setAttribute( imageElement, 'imageStyle', this.style.name ); + } } ); } } diff --git a/tests/imagestyle/imagestylecommand.js b/tests/imagestyle/imagestylecommand.js index e3a795b4..c890575f 100644 --- a/tests/imagestyle/imagestylecommand.js +++ b/tests/imagestyle/imagestylecommand.js @@ -105,4 +105,21 @@ describe( 'ImageStyleCommand', () => { expect( defaultStyleCommand.isEnabled ).to.be.false; expect( otherStyleCommand.isEnabled ).to.be.false; } ); + + it( 'default style should be active after executing it after another style', () => { + setData( document, '[]' ); + + expect( defaultStyleCommand.value ).to.be.true; + expect( otherStyleCommand.value ).to.be.false; + + otherStyleCommand.execute(); + + expect( getData( document ) ).to.equal( '[]' ); + + defaultStyleCommand.execute(); + + expect( getData( document ) ).to.equal( '[]' ); + expect( defaultStyleCommand.value ).to.be.true; + expect( otherStyleCommand.value ).to.be.false; + } ); } );