X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ffakeobjects%2Fplugin.js;h=234e3a8c756818d4d310c5cae7f2937db741e809;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=58c5bcd43aab18b912bdf7d815fce4f8c2f3d47b;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git diff --git a/_source/plugins/fakeobjects/plugin.js b/_source/plugins/fakeobjects/plugin.js index 58c5bcd..234e3a8 100644 --- a/_source/plugins/fakeobjects/plugin.js +++ b/_source/plugins/fakeobjects/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -11,15 +11,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { $ : function( element ) { - var realHtml = element.attributes._cke_realelement, + var attributes = element.attributes, + realHtml = attributes && attributes[ 'data-cke-realelement' ], realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ), realElement = realFragment && realFragment.children[ 0 ]; - if ( realElement ) + // If we have width/height in the element, we must move it into + // the real element. + if ( realElement && element.attributes[ 'data-cke-resizable' ] ) { - // If we have width/height in the element, we must move it into - // the real element. - var style = element.attributes.style; if ( style ) @@ -62,50 +62,65 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable ) { - var lang = this.lang.fakeobjects; + var lang = this.lang.fakeobjects, + label = lang[ realElementType ] || lang.unknown; + var attributes = { 'class' : className, src : CKEDITOR.getUrl( 'images/spacer.gif' ), - _cke_realelement : encodeURIComponent( realElement.getOuterHtml() ), - alt : lang[ realElementType ] || lang.unknown + 'data-cke-realelement' : encodeURIComponent( realElement.getOuterHtml() ), + 'data-cke-real-node-type' : realElement.type, + alt : label, + title : label, + align : realElement.getAttribute( 'align' ) || '' }; + if ( realElementType ) - attributes._cke_real_element_type = realElementType; + attributes[ 'data-cke-real-element-type' ] = realElementType; + if ( isResizable ) - attributes._cke_resizable = isResizable; + attributes[ 'data-cke-resizable' ] = isResizable; return this.document.createElement( 'img', { attributes : attributes } ); }; CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable ) { - var writer = new CKEDITOR.htmlParser.basicWriter(); + var lang = this.lang.fakeobjects, + label = lang[ realElementType ] || lang.unknown, + html; + var writer = new CKEDITOR.htmlParser.basicWriter(); realElement.writeHtml( writer ); - - var html = writer.getHtml(); - var lang = this.lang.fakeobjects; + html = writer.getHtml(); var attributes = { 'class' : className, src : CKEDITOR.getUrl( 'images/spacer.gif' ), - _cke_realelement : encodeURIComponent( html ), - alt : lang[ realElementType ] || lang.unknown + 'data-cke-realelement' : encodeURIComponent( html ), + 'data-cke-real-node-type' : realElement.type, + alt : label, + title : label, + align : realElement.attributes.align || '' }; if ( realElementType ) - attributes._cke_real_element_type = realElementType; + attributes[ 'data-cke-real-element-type' ] = realElementType; if ( isResizable ) - attributes._cke_resizable = isResizable; + attributes[ 'data-cke-resizable' ] = isResizable; return new CKEDITOR.htmlParser.element( 'img', attributes ); }; CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement ) { - var html = decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) ); - return CKEDITOR.dom.element.createFromHtml( html, this.document ); + if ( fakeElement.data( 'cke-real-node-type' ) != CKEDITOR.NODE_ELEMENT ) + return null; + + return CKEDITOR.dom.element.createFromHtml( + decodeURIComponent( fakeElement.data( 'cke-realelement' ) ), + this.document ); };