diff options
| author | Daniel Sutcliffe <dansut@users.sourceforge.net> | 2010-02-02 17:54:17 +0000 |
|---|---|---|
| committer | Daniel Sutcliffe <dansut@users.sourceforge.net> | 2010-02-02 17:54:17 +0000 |
| commit | b1de4b213ba60402d6d13a2a6892d5a422c4f8e4 (patch) | |
| tree | e4adb31477ee586349cd935365a84aaee50c5899 /_source/plugins/fakeobjects/plugin.js | |
| parent | 8630f2bc4d63b3320f5469d9532a1cba1dddb7a3 (diff) | |
| download | ckeditor-b1de4b213ba60402d6d13a2a6892d5a422c4f8e4.tar.gz ckeditor-b1de4b213ba60402d6d13a2a6892d5a422c4f8e4.tar.bz2 ckeditor-b1de4b213ba60402d6d13a2a6892d5a422c4f8e4.zip | |
Update CKEditor to 3.1 and make work as a bw package
Diffstat (limited to '_source/plugins/fakeobjects/plugin.js')
| -rw-r--r-- | _source/plugins/fakeobjects/plugin.js | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/_source/plugins/fakeobjects/plugin.js b/_source/plugins/fakeobjects/plugin.js index 8d761ab..c53085a 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-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -11,25 +11,25 @@ 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._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._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 ) { // Get the width from the style. - var match = /(?:^|\s)width\s*:\s*(\d+)/.exec( style ), + var match = /(?:^|\s)width\s*:\s*(\d+)/i.exec( style ), width = match && match[1]; // Get the height from the style. - match = /(?:^|\s)height\s*:\s*(\d+)/.exec( style ); + match = /(?:^|\s)height\s*:\s*(\d+)/i.exec( style ); var height = match && match[1]; if ( width ) @@ -63,15 +63,19 @@ 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 attributes = { 'class' : className, src : CKEDITOR.getUrl( 'images/spacer.gif' ), _cke_realelement : encodeURIComponent( realElement.getOuterHtml() ), + _cke_real_node_type : realElement.type, alt : lang[ realElementType ] || lang.unknown }; + if ( realElementType ) attributes._cke_real_element_type = realElementType; + if ( isResizable ) attributes._cke_resizable = isResizable; @@ -80,18 +84,19 @@ CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable ) { - var writer = new CKEDITOR.htmlParser.basicWriter(); + var lang = this.lang.fakeobjects, + 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 ), + _cke_real_node_type : realElement.type, alt : lang[ realElementType ] || lang.unknown }; @@ -106,6 +111,10 @@ CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, class CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement ) { - var html = decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) ); - return CKEDITOR.dom.element.createFromHtml( html, this.document ); + if ( fakeElement.getAttribute( '_cke_real_node_type' ) != CKEDITOR.NODE_ELEMENT ) + return null; + + return CKEDITOR.dom.element.createFromHtml( + decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) ), + this.document ); }; |
