2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * The Data Processor is responsible for transforming the input and output data
\r
22 * in the editor. For more info:
\r
23 * http://dev.fckeditor.net/wiki/Components/DataProcessor
\r
25 * The default implementation offers the base XHTML compatibility features of
\r
26 * FCKeditor. Further Data Processors may be implemented for other purposes.
\r
30 var FCKDataProcessor = function()
\r
33 FCKDataProcessor.prototype =
\r
36 * Returns a string representing the HTML format of "data". The returned
\r
37 * value will be loaded in the editor.
\r
38 * The HTML must be from <html> to </html>, including <head>, <body> and
\r
39 * eventually the DOCTYPE.
\r
40 * Note: HTML comments may already be part of the data because of the
\r
41 * pre-processing made with ProtectedSource.
\r
42 * @param {String} data The data to be converted in the
\r
43 * DataProcessor specific format.
\r
45 ConvertToHtml : function( data )
\r
47 // The default data processor must handle two different cases depending
\r
48 // on the FullPage setting. Custom Data Processors will not be
\r
49 // compatible with FullPage, much probably.
\r
50 if ( FCKConfig.FullPage )
\r
52 // Save the DOCTYPE.
\r
53 FCK.DocTypeDeclaration = data.match( FCKRegexLib.DocTypeTag ) ;
\r
55 // Check if the <body> tag is available.
\r
56 if ( !FCKRegexLib.HasBodyTag.test( data ) )
\r
57 data = '<body>' + data + '</body>' ;
\r
59 // Check if the <html> tag is available.
\r
60 if ( !FCKRegexLib.HtmlOpener.test( data ) )
\r
61 data = '<html dir="' + FCKConfig.ContentLangDirection + '">' + data + '</html>' ;
\r
63 // Check if the <head> tag is available.
\r
64 if ( !FCKRegexLib.HeadOpener.test( data ) )
\r
65 data = data.replace( FCKRegexLib.HtmlOpener, '$&<head><title></title></head>' ) ;
\r
73 '<html dir="' + FCKConfig.ContentLangDirection + '"' ;
\r
75 // On IE, if you are using a DOCTYPE different of HTML 4 (like
\r
76 // XHTML), you must force the vertical scroll to show, otherwise
\r
77 // the horizontal one may appear when the page needs vertical scrolling.
\r
78 // TODO : Check it with IE7 and make it IE6- if it is the case.
\r
79 if ( FCKBrowserInfo.IsIE && FCKConfig.DocType.length > 0 && !FCKRegexLib.Html4DocType.test( FCKConfig.DocType ) )
\r
80 html += ' style="overflow-y: scroll"' ;
\r
82 html += '><head><title></title></head>' +
\r
83 '<body' + FCKConfig.GetBodyAttributes() + '>' +
\r
92 * Converts a DOM (sub-)tree to a string in the data format.
\r
93 * @param {Object} rootNode The node that contains the DOM tree to be
\r
94 * converted to the data format.
\r
95 * @param {Boolean} excludeRoot Indicates that the root node must not
\r
96 * be included in the conversion, only its children.
\r
97 * @param {Boolean} format Indicates that the data must be formatted
\r
98 * for human reading. Not all Data Processors may provide it.
\r
100 ConvertToDataFormat : function( rootNode, excludeRoot, ignoreIfEmptyParagraph, format )
\r
102 var data = FCKXHtml.GetXHTML( rootNode, !excludeRoot, format ) ;
\r
104 if ( ignoreIfEmptyParagraph && FCKRegexLib.EmptyOutParagraph.test( data ) )
\r
111 * Makes any necessary changes to a piece of HTML for insertion in the
\r
112 * editor selection position.
\r
113 * @param {String} html The HTML to be fixed.
\r
115 FixHtml : function( html )
\r