2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
8 var htmlFilterRules =
\r
12 $ : function( element )
\r
14 var attributes = element.attributes,
\r
15 realHtml = attributes && attributes._cke_realelement,
\r
16 realFragment = realHtml && new CKEDITOR.htmlParser.fragment.fromHtml( decodeURIComponent( realHtml ) ),
\r
17 realElement = realFragment && realFragment.children[ 0 ];
\r
19 // If we have width/height in the element, we must move it into
\r
20 // the real element.
\r
21 if ( realElement && element.attributes._cke_resizable )
\r
23 var style = element.attributes.style;
\r
27 // Get the width from the style.
\r
28 var match = /(?:^|\s)width\s*:\s*(\d+)/i.exec( style ),
\r
29 width = match && match[1];
\r
31 // Get the height from the style.
\r
32 match = /(?:^|\s)height\s*:\s*(\d+)/i.exec( style );
\r
33 var height = match && match[1];
\r
36 realElement.attributes.width = width;
\r
39 realElement.attributes.height = height;
\r
48 CKEDITOR.plugins.add( 'fakeobjects',
\r
50 requires : [ 'htmlwriter' ],
\r
52 afterInit : function( editor )
\r
54 var dataProcessor = editor.dataProcessor,
\r
55 htmlFilter = dataProcessor && dataProcessor.htmlFilter;
\r
58 htmlFilter.addRules( htmlFilterRules );
\r
63 CKEDITOR.editor.prototype.createFakeElement = function( realElement, className, realElementType, isResizable )
\r
65 var lang = this.lang.fakeobjects;
\r
69 'class' : className,
\r
70 src : CKEDITOR.getUrl( 'images/spacer.gif' ),
\r
71 _cke_realelement : encodeURIComponent( realElement.getOuterHtml() ),
\r
72 _cke_real_node_type : realElement.type,
\r
73 alt : lang[ realElementType ] || lang.unknown,
\r
74 align : realElement.getAttribute( 'align' ) || ''
\r
77 if ( realElementType )
\r
78 attributes._cke_real_element_type = realElementType;
\r
81 attributes._cke_resizable = isResizable;
\r
83 return this.document.createElement( 'img', { attributes : attributes } );
\r
86 CKEDITOR.editor.prototype.createFakeParserElement = function( realElement, className, realElementType, isResizable )
\r
88 var lang = this.lang.fakeobjects,
\r
91 var writer = new CKEDITOR.htmlParser.basicWriter();
\r
92 realElement.writeHtml( writer );
\r
93 html = writer.getHtml();
\r
97 'class' : className,
\r
98 src : CKEDITOR.getUrl( 'images/spacer.gif' ),
\r
99 _cke_realelement : encodeURIComponent( html ),
\r
100 _cke_real_node_type : realElement.type,
\r
101 alt : lang[ realElementType ] || lang.unknown,
\r
102 align : realElement.attributes.align || ''
\r
105 if ( realElementType )
\r
106 attributes._cke_real_element_type = realElementType;
\r
109 attributes._cke_resizable = isResizable;
\r
111 return new CKEDITOR.htmlParser.element( 'img', attributes );
\r
114 CKEDITOR.editor.prototype.restoreRealElement = function( fakeElement )
\r
116 if ( fakeElement.getAttribute( '_cke_real_node_type' ) != CKEDITOR.NODE_ELEMENT )
\r
119 return CKEDITOR.dom.element.createFromHtml(
\r
120 decodeURIComponent( fakeElement.getAttribute( '_cke_realelement' ) ),
\r