X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fdiv%2Fdialogs%2Fdiv.js;h=37e1e976f4c9116ee07d421b751ccf34bf79d799;hb=2f22c0c38f17e75be5541089076885442aaa2377;hp=c1bfb8ff0c932d04ef66c7115d971792505dd878;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1;p=ckeditor.git diff --git a/_source/plugins/div/dialogs/div.js b/_source/plugins/div/dialogs/div.js index c1bfb8f..37e1e97 100644 --- a/_source/plugins/div/dialogs/div.js +++ b/_source/plugins/div/dialogs/div.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. + * Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -140,8 +140,8 @@ var containedBlocks = [], block; // Get all ranges from the selection. - var selection = editor.document.getSelection(); - var ranges = selection.getRanges(); + var selection = editor.document.getSelection(), + ranges = selection.getRanges(); var bookmarks = selection.createBookmarks(); var i, iterator; @@ -330,7 +330,13 @@ { var styleName; if ( ( styleName = this.getValue() ) ) - styles[ styleName ].applyToObject( element ); + { + var style = styles[ styleName ]; + var customData = element.getCustomData( 'elementStyle' ) || ''; + + style.applyToObject( element ); + element.setCustomData( 'elementStyle', customData + style._.definition.attributes.style ); + } } }, { @@ -386,9 +392,8 @@ commit : function( element ) { // Merge with 'elementStyle', which is of higher priority. - var value = this.getValue(), - merged = [ value, element.getAttribute( 'style' ) ].join( ';' ); - value && element.setAttribute( 'style', merged ); + var merged = this.getValue() + ( element.getCustomData( 'elementStyle' ) || '' ); + element.setAttribute( 'style', merged ); } } ] @@ -432,7 +437,7 @@ ], onLoad : function() { - setupFields.call(this); + setupFields.call( this ); // Preparing for the 'elementStyle' field. var dialog = this, @@ -484,7 +489,6 @@ }, onOk : function() { - editor.fire( 'saveSnapshot' ); if ( command == 'editdiv' ) containers = [ this._element ]; else @@ -499,12 +503,14 @@ // Remove empty 'style' attribute. !containers[ i ].getAttribute( 'style' ) && containers[ i ].removeAttribute( 'style' ); } - editor.fire( 'saveSnapshot' ); this.hide(); }, onHide : function() { + // Remove style only when editing existing DIV. (#6315) + if ( command == 'editdiv' ) + this._element.removeCustomData( 'elementStyle' ); delete this._element; } };