+++ /dev/null
-/*\r
- * FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
- * Copyright (C) 2003-2009 Frederico Caldeira Knabben\r
- *\r
- * == BEGIN LICENSE ==\r
- *\r
- * Licensed under the terms of any of the following licenses at your\r
- * choice:\r
- *\r
- * - GNU General Public License Version 2 or later (the "GPL")\r
- * http://www.gnu.org/licenses/gpl.html\r
- *\r
- * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
- * http://www.gnu.org/licenses/lgpl.html\r
- *\r
- * - Mozilla Public License Version 1.1 or later (the "MPL")\r
- * http://www.mozilla.org/MPL/MPL-1.1.html\r
- *\r
- * == END LICENSE ==\r
- *\r
- * This is a sample implementation for a custom Data Processor for basic BBCode.\r
- */\r
-\r
-FCK.DataProcessor =\r
-{\r
- /*\r
- * Returns a string representing the HTML format of "data". The returned\r
- * value will be loaded in the editor.\r
- * The HTML must be from <html> to </html>, eventually including\r
- * the DOCTYPE.\r
- * @param {String} data The data to be converted in the\r
- * DataProcessor specific format.\r
- */\r
- ConvertToHtml : function( data )\r
- {\r
- // Convert < and > to their HTML entities.\r
- data = data.replace( /</g, '<' ) ;\r
- data = data.replace( />/g, '>' ) ;\r
-\r
- // Convert line breaks to <br>.\r
- data = data.replace( /(?:\r\n|\n|\r)/g, '<br>' ) ;\r
-\r
- // [url]\r
- data = data.replace( /\[url\](.+?)\[\/url]/gi, '<a href="$1">$1</a>' ) ;\r
- data = data.replace( /\[url\=([^\]]+)](.+?)\[\/url]/gi, '<a href="$1">$2</a>' ) ;\r
-\r
- // [b]\r
- data = data.replace( /\[b\](.+?)\[\/b]/gi, '<b>$1</b>' ) ;\r
-\r
- // [i]\r
- data = data.replace( /\[i\](.+?)\[\/i]/gi, '<i>$1</i>' ) ;\r
-\r
- // [u]\r
- data = data.replace( /\[u\](.+?)\[\/u]/gi, '<u>$1</u>' ) ;\r
-\r
- return '<html><head><title></title></head><body>' + data + '</body></html>' ;\r
- },\r
-\r
- /*\r
- * Converts a DOM (sub-)tree to a string in the data format.\r
- * @param {Object} rootNode The node that contains the DOM tree to be\r
- * converted to the data format.\r
- * @param {Boolean} excludeRoot Indicates that the root node must not\r
- * be included in the conversion, only its children.\r
- * @param {Boolean} format Indicates that the data must be formatted\r
- * for human reading. Not all Data Processors may provide it.\r
- */\r
- ConvertToDataFormat : function( rootNode, excludeRoot, ignoreIfEmptyParagraph, format )\r
- {\r
- var data = rootNode.innerHTML ;\r
-\r
- // Convert <br> to line breaks.\r
- data = data.replace( /<br(?=[ \/>]).*?>/gi, '\r\n') ;\r
-\r
- // [url]\r
- data = data.replace( /<a .*?href=(["'])(.+?)\1.*?>(.+?)<\/a>/gi, '[url=$2]$3[/url]') ;\r
-\r
- // [b]\r
- data = data.replace( /<(?:b|strong)>/gi, '[b]') ;\r
- data = data.replace( /<\/(?:b|strong)>/gi, '[/b]') ;\r
-\r
- // [i]\r
- data = data.replace( /<(?:i|em)>/gi, '[i]') ;\r
- data = data.replace( /<\/(?:i|em)>/gi, '[/i]') ;\r
-\r
- // [u]\r
- data = data.replace( /<u>/gi, '[u]') ;\r
- data = data.replace( /<\/u>/gi, '[/u]') ;\r
-\r
- // Remove remaining tags.\r
- data = data.replace( /<[^>]+>/g, '') ;\r
-\r
- return data ;\r
- },\r
-\r
- /*\r
- * Makes any necessary changes to a piece of HTML for insertion in the\r
- * editor selection position.\r
- * @param {String} html The HTML to be fixed.\r
- */\r
- FixHtml : function( html )\r
- {\r
- return html ;\r
- }\r
-} ;\r
-\r
-// This Data Processor doesn't support <p>, so let's use <br>.\r
-FCKConfig.EnterMode = 'br' ;\r
-\r
-// To avoid pasting invalid markup (which is discarded in any case), let's\r
-// force pasting to plain text.\r
-FCKConfig.ForcePasteAsPlainText = true ;\r
-\r
-// Rename the "Source" buttom to "BBCode".\r
-FCKToolbarItems.RegisterItem( 'Source', new FCKToolbarButton( 'Source', 'BBCode', null, FCK_TOOLBARITEM_ICONTEXT, true, true, 1 ) ) ;\r
-\r
-// Let's enforce the toolbar to the limits of this Data Processor. A custom\r
-// toolbar set may be defined in the configuration file with more or less entries.\r
-FCKConfig.ToolbarSets["Default"] = [\r
- ['Source'],\r
- ['Bold','Italic','Underline','-','Link'],\r
- ['About']\r
-] ;\r