xinha_editors = null; xinha_init = null; xinha_config = null; xinha_plugins = null; // This contains the names of textareas we will make into Xinha editors xinha_init = xinha_init ? xinha_init : function() { /** STEP 1 *************************************************************** * First, specify the textareas that shall be turned into Xinhas. * For each one add the respective id to the xinha_editors array. * I you want add more than on textarea, keep in mind that these * values are comma seperated BUT there is no comma after the last value. * If you are going to use this configuration on several pages with different * textarea ids, you can add them all. The ones that are not found on the * current page will just be skipped. ************************************************************************/ xinha_editors = xinha_editors ? xinha_editors : [ 'myTextArea', 'anotherOne' ]; /** STEP 2 *************************************************************** * Now, what are the plugins you will be using in the editors on this * page. List all the plugins you will need, even if not all the editors * will use all the plugins. * * The list of plugins below is a good starting point, but if you prefer * a simpler editor to start with then you can use the following * * xinha_plugins = xinha_plugins ? xinha_plugins : [ ]; * * which will load no extra plugins at all. ************************************************************************/ xinha_plugins = xinha_plugins ? xinha_plugins : [ 'OpenSaveAs', 'CharacterMap', 'ContextMenu', //'SmartReplace', //'Stylist', 'InsertAnchor', 'ExtendedFileManager', 'Linker', //'SuperClean', 'TableOperations', 'SaveSubmit', 'InsertCode', 'InsertTitle', //'InsertSnippet2', //'PreserveScripts', // => only for PHP, otherwise scripts are converted to tags... //'PersistentStorage', //'PSServer', ]; // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :) if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return; /** STEP 3 *************************************************************** * We create a default configuration to be used by all the editors. * If you wish to configure some of the editors differently this will be * done in step 5. * * If you want to modify the default config you might do something like this. * * xinha_config = new Xinha.Config(); * xinha_config.width = '640px'; * xinha_config.height = '420px'; * * * For a list of the available configuration options, see: * http://trac.xinha.org/wiki/Documentation/ConfigVariablesList * *************************************************************************/ xinha_config = xinha_config ? xinha_config() : new Xinha.Config(); xinha_config.bodyContentEditable = null; xinha_config.fullScreen = null; xinha_config.fullPage = null; xinha_config.stripScripts = null; xinha_config.inward_regex_replacements = []; xinha_config.outward_regex_replacements = []; xinha_config.absolute = null; xinha_config.dropbox_images = null; xinha_config.domain_specific_replacements = null; xinha_config.domain_specific_events = null; xinha_config.bodyContentEditable = false; //do not need editblocks!! xinha_config.fullScreen = true; xinha_config.fullPage = true; xinha_config.stripScripts = false; xinha_config.defaults = {}; xinha_config.dada_url = {}; /***************************************************************** * Editor configurations (see also editor_xinha.php) *****************************************************************/ xinha_config.editor_config = { 'xinha_editor' : 'xinha_editor', 'edit_enable_script' : 'edit_enable_script', 'edit_enable_object' : 'edit_enable_object', 'freezescript' : 'freezescript', 'unique_id' : '662f121d252fb', 'exclude_dirs' : '/(^|\/)([._]|htmlarea|tinymce|xinah|xinha|cgi-bin|common|ssi_menus.*?|plugins|drupal.*?|wp.*?)/', }; /***************************************************************** * Do some pre processing (see Xinha.prototype.inwardHtml) * Examples: * x(?!y) Matches 'x' only if 'x' is not followed by 'y'. This is called a negated lookahead. * xinha_config.inward_regex_replacements[i++] = { * 'pattern': /(]*((type=[\"\']?text\/)|(language=[\"\']?)))(javascript)/gi, * 'replace': function(match, match1, match2){ } * }; *****************************************************************/ var i=0; xinha_config.inward_regex_replacements = []; xinha_config.inward_regex_replacements[i++] = { //add type="text/javascript" if not there 'not_mode' : 'textmode', 'pattern': /(]*?((type=[\"\']?text\/)|(language=[\"\']?))javascript[\"\']?)/gi, 'replace': '$1 type="text/javascript" language="javascript"' }; xinha_config.inward_regex_replacements[i++] = { //first type= 'not_mode' : 'textmode', 'pattern': /(]*?)\s+(type=[^> ]+)/gi, 'replace': '$1 $3 $2', }; xinha_config.inward_regex_replacements[i++] = { //last edit_enable_script 'not_mode' : 'textmode', 'pattern': /(]*?)(\stitle=[\"\']?edit_enable_script[\"\']?)([^>]*?)>/gi, 'replace': '$1 $3 $2>', }; xinha_config.inward_regex_replacements[i++] = { //freeze scripts, keep this order, very important!! type must become first!! 'not_mode' : 'textmode', 'pattern': /(]*?(type=[\"\']?text\/|language=[\"\']?))(javascript)(?![^>]+?title=[\"\']?edit_enable_script[\"\']?)/gi, 'replace': '$1freezescript', }; xinha_config.inward_regex_replacements[i++] = { //first language=, then type= 'not_mode' : 'textmode', 'pattern': /(]*?)\s+(language=[^> ]+)/gi, 'replace': '$1 $3 $2', }; xinha_config.inward_regex_replacements[i++] = { //for firefox, remove white spaces between div and p elements 'not_mode' : 'textmode', 'pattern': /\s+((])/gi, 'replace': '$1', }; xinha_config.inward_regex_replacements[i++] = { //for Chrome, remove multiple white spaces just after a
'not_mode' : 'textmode', 'pattern': /(]*?>)\s+( )+/gi, 'replace': '$1 ', }; xinha_config.inward_regex_replacements[i++] = { //remove classnames from bookmarks, replace with "anchor" 'not_mode' : 'textmode', 'pattern': /(]*)class="[^"]*(anchor|bookmark)[^"]*"([^>]*>)/gi, 'replace': '$1class="anchor"$3' }; /***************************************************************** Do some post processing for mainly script tags (see Xinha.prototype.outwardHtml) *****************************************************************/ var i=0; xinha_config.outward_regex_replacements = []; xinha_config.outward_regex_replacements[i++] = { //remove temporary classnames 'not_mode' : 'textmode', 'pattern': /(\s|"|'|=)(edit_resize_allowed|edit_drag_allowed)(\s|"|')/gi, 'replace': '$1$3' }; xinha_config.outward_regex_replacements[i++] = { //remove empty class attribute 'not_mode' : 'textmode', 'pattern': /\s*class="\s+"\s*/gi, 'replace': ' ' }; xinha_config.outward_regex_replacements[i++] = { //remove external inserted (no)scripts 'not_mode' : 'textmode', 'pattern': /(<(no)?script(?![^>]+class=[\"\']?xinha_editor[\"\']?)[^>]*?>[\s\S]*?<\/(no)?script>)/gi, 'replace': '' }; xinha_config.outward_regex_replacements[i++] = { //undo freeze 'not_mode' : 'textmode', 'pattern': /(]*?((type=[\"\']text\/)|(language=[\"\'])))(freezescript)/gi, 'replace': '$1javascript' }; xinha_config.outward_regex_replacements[i++] = { //first language=, then type= 'not_mode' : 'textmode', 'pattern': /(]*?)\s+(type=[^> ]+)/gi, 'replace': '$1 $3 $2' }; xinha_config.outward_regex_replacements[i++] = { //first language=, then type= 'not_mode' : 'textmode', 'pattern': /(]*?)\s+(language=[^> ]+)/gi, 'replace': '$1 $3 $2' }; xinha_config.outward_regex_replacements[i++] = { //cleanup 'not_mode' : 'textmode', 'pattern': /\s*(