1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 CKEDITOR.plugins.add( 'htmldataprocessor', 7 { 8 requires : [ 'htmlwriter' ], 9 10 init : function( editor, pluginPath ) 11 { 12 editor.dataProcessor = new CKEDITOR.htmlDataProcessor(); 13 } 14 }); 15 16 CKEDITOR.htmlDataProcessor = function() 17 { 18 this.writer = new CKEDITOR.htmlWriter(); 19 }; 20 21 CKEDITOR.htmlDataProcessor.prototype = 22 { 23 toHtml : function( data ) 24 { 25 // The source data is already HTML, so just return it as is. 26 return data; 27 }, 28 29 toDataFormat : function( element ) 30 { 31 var writer = this.writer, 32 fragment = CKEDITOR.htmlParser.fragment.fromHtml( element.getHtml() ); 33 34 writer.reset(); 35 36 fragment.writeHtml( writer ); 37 38 return writer.getHtml( true ); 39 } 40 }; 41