- {$lang_insert_link_target}:
-
+ {$lang_insert_link_target}
+
{$lang_insert_link_target_same}
{$lang_insert_link_target_blank}
-
+
-
+
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js
index 4e92fdce57..9fbf19f152 100644
--- a/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-includes/js/tinymce/tiny_mce.js
@@ -1,19 +1,13 @@
-/**
- * $RCSfile: tiny_mce_src.js,v $
- * $Revision: 1.281 $
- * $Date: 2005/12/02 08:12:07 $
- *
- * @author Moxiecode
- * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
- */
-function TinyMCE() {
+/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
+
+function TinyMCE_Engine() {
this.majorVersion = "2";
- this.minorVersion = "0";
- this.releaseDate = "2005-12-01";
+ this.minorVersion = "0.5.1";
+ this.releaseDate = "2006-03-22";
this.instances = new Array();
- this.stickyClassesLookup = new Array();
+ this.switchClassCache = new Array();
this.windowArgs = new Array();
this.loadedFiles = new Array();
this.configs = new Array();
@@ -32,6 +26,12 @@ function TinyMCE() {
this.isNS7 = ua.indexOf('Netscape/7') != -1;
this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
this.dialogCounter = 0;
+ this.plugins = new Array();
+ this.themes = new Array();
+ this.menus = new Array();
+ this.loadedPlugins = new Array();
+ this.buttonMap = new Array();
+ this.isLoaded = false;
// Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those
if (this.isOpera) {
@@ -44,342 +44,3376 @@ function TinyMCE() {
this.idCounter = 0;
};
-TinyMCE.prototype.defParam = function(key, def_val) {
- this.settings[key] = tinyMCE.getParam(key, def_val);
-};
+TinyMCE_Engine.prototype = {
+ init : function(settings) {
+ var theme;
-TinyMCE.prototype.init = function(settings) {
- var theme;
+ this.settings = settings;
- this.settings = settings;
+ // Check if valid browser has execcommand support
+ if (typeof(document.execCommand) == 'undefined')
+ return;
- // Check if valid browser has execcommand support
- if (typeof(document.execCommand) == 'undefined')
- return;
+ // Get script base path
+ if (!tinyMCE.baseURL) {
+ var elements = document.getElementsByTagName('script');
- // Get script base path
- if (!tinyMCE.baseURL) {
- var elements = document.getElementsByTagName('script');
+ for (var i=0; i');
- this.defParam("font_size_classes", '');
- this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large');
- this.defParam("event_elements", 'a,img');
- this.defParam("convert_urls", true);
- this.defParam("table_inline_editing", false);
- this.defParam("object_resizing", true);
+ // Set default values on settings
+ this._def("mode", "none");
+ this._def("theme", "advanced");
+ this._def("plugins", "", true);
+ this._def("language", "en");
+ this._def("docs_language", this.settings['language']);
+ this._def("elements", "");
+ this._def("textarea_trigger", "mce_editable");
+ this._def("editor_selector", "");
+ this._def("editor_deselector", "mceNoEditor");
+ this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]");
+ this._def("extended_valid_elements", "");
+ this._def("invalid_elements", "");
+ this._def("encoding", "");
+ this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL"));
+ this._def("save_callback", "");
+ this._def("debug", false);
+ this._def("force_br_newlines", false);
+ this._def("force_p_newlines", true);
+ this._def("add_form_submit_trigger", true);
+ this._def("relative_urls", true);
+ this._def("remove_script_host", true);
+ this._def("focus_alert", true);
+ this._def("document_base_url", this.documentURL);
+ this._def("visual", true);
+ this._def("visual_table_class", "mceVisualAid");
+ this._def("setupcontent_callback", "");
+ this._def("fix_content_duplication", true);
+ this._def("custom_undo_redo", true);
+ this._def("custom_undo_redo_levels", -1);
+ this._def("custom_undo_redo_keyboard_shortcuts", true);
+ this._def("custom_undo_redo_restore_selection", true);
+ this._def("verify_html", true);
+ this._def("apply_source_formatting", false);
+ this._def("directionality", "ltr");
+ this._def("cleanup_on_startup", false);
+ this._def("inline_styles", false);
+ this._def("convert_newlines_to_brs", false);
+ this._def("auto_reset_designmode", true);
+ this._def("entities", "160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true);
+ this._def("entity_encoding", "named");
+ this._def("cleanup_callback", "");
+ this._def("add_unload_trigger", true);
+ this._def("ask", false);
+ this._def("nowrap", false);
+ this._def("auto_resize", false);
+ this._def("auto_focus", false);
+ this._def("cleanup", true);
+ this._def("remove_linebreaks", true);
+ this._def("button_tile_map", false);
+ this._def("submit_patch", true);
+ this._def("browsers", "msie,safari,gecko,opera", true);
+ this._def("dialog_type", "window");
+ this._def("accessibility_warnings", true);
+ this._def("accessibility_focus", true);
+ this._def("merge_styles_invalid_parents", "");
+ this._def("force_hex_style_colors", true);
+ this._def("trim_span_elements", true);
+ this._def("convert_fonts_to_spans", false);
+ this._def("doctype", '');
+ this._def("font_size_classes", '');
+ this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true);
+ this._def("event_elements", 'a,img', true);
+ this._def("convert_urls", true);
+ this._def("table_inline_editing", false);
+ this._def("object_resizing", true);
+ this._def("custom_shortcuts", true);
+ this._def("convert_on_click", false);
+ this._def("content_css", '');
+ this._def("fix_list_elements", false);
+ this._def("fix_table_elements", false);
- // Browser check IE
- if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
- return;
+ // Browser check IE
+ if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
+ return;
- // Browser check Gecko
- if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
- return;
+ // Browser check Gecko
+ if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
+ return;
- // Browser check Safari
- if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
- return;
+ // Browser check Safari
+ if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
+ return;
- // Browser check Opera
- if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
- return;
+ // Browser check Opera
+ if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
+ return;
- // If not super absolute make it so
- var baseHREF = tinyMCE.settings['document_base_url'];
- var h = document.location.href;
- var p = h.indexOf('://');
- if (p > 0 && document.location.protocol != "file:") {
- p = h.indexOf('/', p + 3);
- h = h.substring(0, p);
+ // If not super absolute make it so
+ var baseHREF = tinyMCE.settings['document_base_url'];
+ var h = document.location.href;
+ var p = h.indexOf('://');
+ if (p > 0 && document.location.protocol != "file:") {
+ p = h.indexOf('/', p + 3);
+ h = h.substring(0, p);
- if (baseHREF.indexOf('://') == -1)
- baseHREF = h + baseHREF;
+ if (baseHREF.indexOf('://') == -1)
+ baseHREF = h + baseHREF;
- tinyMCE.settings['document_base_url'] = baseHREF;
- tinyMCE.settings['document_base_prefix'] = h;
- }
+ tinyMCE.settings['document_base_url'] = baseHREF;
+ tinyMCE.settings['document_base_prefix'] = h;
+ }
- // Trim away query part
- if (baseHREF.indexOf('?') != -1)
- baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
+ // Trim away query part
+ if (baseHREF.indexOf('?') != -1)
+ baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
- this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
+ this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
- theme = this.settings['theme'];
- this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i");
- this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
- this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
- this.uniqueTag = 'TMP
';
+ theme = this.settings['theme'];
+ this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i");
+ this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
+ this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
+ this.uniqueTag = 'TMP
';
+ this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup');
- // Theme url
- this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
+ // Theme url
+ this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
- if (!tinyMCE.isMSIE)
- this.settings['force_br_newlines'] = false;
+ if (!tinyMCE.isMSIE)
+ this.settings['force_br_newlines'] = false;
- if (tinyMCE.getParam("content_css", false)) {
- var cssPath = tinyMCE.getParam("content_css", "");
+ if (tinyMCE.getParam("popups_css", false)) {
+ var cssPath = tinyMCE.getParam("popups_css", "");
- // Is relative
- if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
- this.settings['content_css'] = this.documentBasePath + "/" + cssPath;
- else
- this.settings['content_css'] = cssPath;
- } else
- this.settings['content_css'] = '';
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['popups_css'] = cssPath;
+ } else
+ this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
- if (tinyMCE.getParam("popups_css", false)) {
- var cssPath = tinyMCE.getParam("popups_css", "");
+ if (tinyMCE.getParam("editor_css", false)) {
+ var cssPath = tinyMCE.getParam("editor_css", "");
- // Is relative
- if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
- this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
- else
- this.settings['popups_css'] = cssPath;
- } else
- this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['editor_css'] = cssPath;
+ } else
+ this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
- if (tinyMCE.getParam("editor_css", false)) {
- var cssPath = tinyMCE.getParam("editor_css", "");
+ if (tinyMCE.settings['debug']) {
+ var msg = "Debug: \n";
- // Is relative
- if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
- this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
- else
- this.settings['editor_css'] = cssPath;
- } else
- this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
+ msg += "baseURL: " + this.baseURL + "\n";
+ msg += "documentBasePath: " + this.documentBasePath + "\n";
+ msg += "content_css: " + this.settings['content_css'] + "\n";
+ msg += "popups_css: " + this.settings['popups_css'] + "\n";
+ msg += "editor_css: " + this.settings['editor_css'] + "\n";
- if (tinyMCE.settings['debug']) {
- var msg = "Debug: \n";
+ alert(msg);
+ }
- msg += "baseURL: " + this.baseURL + "\n";
- msg += "documentBasePath: " + this.documentBasePath + "\n";
- msg += "content_css: " + this.settings['content_css'] + "\n";
- msg += "popups_css: " + this.settings['popups_css'] + "\n";
- msg += "editor_css: " + this.settings['editor_css'] + "\n";
+ // Only do this once
+ if (this.configs.length == 0) {
+ // Is Safari enabled
+ if (this.isSafari && this.getParam('safari_warning', false))
+ alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
- alert(msg);
- }
+ if (typeof(TinyMCECompressed) == "undefined") {
+ tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
- // Init HTML cleanup
- this._initCleanup();
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (document.body)
+ tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
+ else
+ tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad);
+ }
- // Only do this once
- if (this.configs.length == 0) {
- // Is Safari enabled
- if (this.isSafari && this.getParam('safari_warning', true))
- alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
+ tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad);
+ tinyMCE._addUnloadEvents();
+ }
+ }
- tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad);
+ this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');
+ this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js');
+ this.loadCSS(this.settings['editor_css']);
+ // Add plugins
+ var p = tinyMCE.getParam('plugins', '', true, ',');
+ if (p.length > 0) {
+ for (var i=0; i');
+
+ this.loadedFiles[this.loadedFiles.length] = url;
+ },
+
+ loadCSS : function(url) {
+ var ar = url.replace(/\s+/, '').split(',');
+ var lflen = 0, csslen = 0;
+ var skip = false;
+ var x = 0, i = 0;
+
+ for (x = 0,csslen = ar.length; x 0) {
+ /* Make sure it doesn't exist. */
+ for (i=0, lflen=this.loadedFiles.length; i ');
+ this.loadedFiles[this.loadedFiles.length] = ar[x];
+ }
+ }
+ }
+ },
+
+ importCSS : function(doc, css) {
+ var css_ary = css.replace(/\s+/, '').split(',');
+ var csslen, elm, headArr, x, css_file;
+
+ for (x = 0, csslen = css_ary.length; x 0) {
+ // Is relative, make absolute
+ if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/')
+ css_file = this.documentBasePath + "/" + css_file;
+
+ if (typeof(doc.createStyleSheet) == "undefined") {
+ elm = doc.createElement("link");
+
+ elm.rel = "stylesheet";
+ elm.href = css_file;
+
+ if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
+ headArr[0].appendChild(elm);
+ } else
+ doc.createStyleSheet(css_file);
+ }
+ }
+ },
+
+ confirmAdd : function(e, settings) {
+ var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
+ var elementId = elm.name ? elm.name : elm.id;
+
+ tinyMCE.settings = settings;
+
+ if (tinyMCE.settings['convert_on_click'] || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])))
+ tinyMCE.addMCEControl(elm, elementId);
+
+ elm.setAttribute('mce_noask', 'true');
+ },
+
+ updateContent : function(form_element_name) {
+ // Find MCE instance linked to given form element and copy it's value
+ var formElement = document.getElementById(form_element_name);
+ for (var n in tinyMCE.instances) {
+ var inst = tinyMCE.instances[n];
+ if (!tinyMCE.isInstance(inst))
+ continue;
+
+ inst.switchSettings();
+
+ if (inst.formElement == formElement) {
+ var doc = inst.getDoc();
+
+ tinyMCE._setHTML(doc, inst.formElement.value);
+
+ if (!tinyMCE.isMSIE)
+ doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
+ }
+ }
+ },
+
+ addMCEControl : function(replace_element, form_element_name, target_document) {
+ var id = "mce_editor_" + tinyMCE.idCounter++;
+ var inst = new TinyMCE_Control(tinyMCE.settings);
+
+ inst.editorId = id;
+ this.instances[id] = inst;
+
+ inst._onAdd(replace_element, form_element_name, target_document);
+ },
+
+ removeMCEControl : function(editor_id) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+
+ if (inst) {
+ inst.switchSettings();
+
+ editor_id = inst.editorId;
+ var html = tinyMCE.getContent(editor_id);
+
+ // Remove editor instance from instances array
+ var tmpInstances = new Array();
+ for (var instanceName in tinyMCE.instances) {
+ var instance = tinyMCE.instances[instanceName];
+ if (!tinyMCE.isInstance(instance))
+ continue;
+
+ if (instanceName != editor_id)
+ tmpInstances[instanceName] = instance;
+ }
+ tinyMCE.instances = tmpInstances;
+
+ tinyMCE.selectedElement = null;
+ tinyMCE.selectedInstance = null;
+
+ // Remove element
+ var replaceElement = document.getElementById(editor_id + "_parent");
+ var oldTargetElement = inst.oldTargetElement;
+ var targetName = oldTargetElement.nodeName.toLowerCase();
+
+ if (targetName == "textarea" || targetName == "input") {
+ // Just show the old text area
+ replaceElement.parentNode.removeChild(replaceElement);
+ oldTargetElement.style.display = "inline";
+ oldTargetElement.value = html;
+ } else {
+ oldTargetElement.innerHTML = html;
+ oldTargetElement.style.display = 'block';
+
+ replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
+ replaceElement.parentNode.removeChild(replaceElement);
+ }
+ }
+ },
+
+ triggerSave : function(skip_cleanup, skip_callback) {
+ var inst, n;
+
+ // Default to false
+ if (typeof(skip_cleanup) == "undefined")
+ skip_cleanup = false;
+
+ // Default to false
+ if (typeof(skip_callback) == "undefined")
+ skip_callback = false;
+
+ // Cleanup and set all form fields
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
+
+ if (!tinyMCE.isInstance(inst))
+ continue;
+
+ inst.triggerSave(skip_cleanup, skip_callback);
+ }
+ },
+
+ resetForm : function(form_index) {
+ var i, inst, n, formObj = document.forms[form_index];
+
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
+
+ if (!tinyMCE.isInstance(inst))
+ continue;
+
+ inst.switchSettings();
+
+ for (i=0; i');
-
- this.loadedFiles[this.loadedFiles.length] = url;
-};
-
-TinyMCE.prototype.loadCSS = function(url) {
- for (var i=0; i ');
+ case "mceAddControl":
+ case "mceAddEditor":
+ tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
+ return;
- this.loadedFiles[this.loadedFiles.length] = url;
-};
+ case "mceAddFrameControl":
+ tinyMCE.addMCEControl(tinyMCE._getElementById(value['element'], value['document']), value['element'], value['document']);
+ return;
-TinyMCE.prototype.importCSS = function(doc, css_file) {
- if (css_file == '')
- return;
+ case "mceRemoveControl":
+ case "mceRemoveEditor":
+ tinyMCE.removeMCEControl(value);
+ return;
- if (typeof(doc.createStyleSheet) == "undefined") {
- var elm = doc.createElement("link");
+ case "mceResetDesignMode":
+ // Resets the designmode state of the editors in Gecko
+ if (!tinyMCE.isMSIE) {
+ for (var n in tinyMCE.instances) {
+ if (!tinyMCE.isInstance(tinyMCE.instances[n]))
+ continue;
- elm.rel = "stylesheet";
- elm.href = css_file;
+ try {
+ tinyMCE.instances[n].getDoc().designMode = "on";
+ } catch (e) {
+ // Ignore any errors
+ }
+ }
+ }
- if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
- headArr[0].appendChild(elm);
- } else
- var styleSheet = doc.createStyleSheet(css_file);
-};
+ return;
+ }
-TinyMCE.prototype.confirmAdd = function(e, settings) {
- var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
- var elementId = elm.name ? elm.name : elm.id;
+ if (this.selectedInstance) {
+ this.selectedInstance.execCommand(command, user_interface, value);
+ } else if (tinyMCE.settings['focus_alert'])
+ alert(tinyMCELang['lang_focus_alert']);
+ },
- tinyMCE.settings = settings;
+ _createIFrame : function(replace_element, doc, win) {
+ var iframe, id = replace_element.getAttribute("id");
+ var aw, ah;
- if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm']))
- tinyMCE.addMCEControl(elm, elementId);
+ if (typeof(doc) == "undefined")
+ doc = document;
- elm.setAttribute('mce_noask', 'true');
-};
+ if (typeof(win) == "undefined")
+ win = window;
-TinyMCE.prototype.updateContent = function(form_element_name) {
- // Find MCE instance linked to given form element and copy it's value
- var formElement = document.getElementById(form_element_name);
- for (var n in tinyMCE.instances) {
- var inst = tinyMCE.instances[n];
- if (!tinyMCE.isInstance(inst))
- continue;
+ iframe = doc.createElement("iframe");
+
+ aw = "" + tinyMCE.settings['area_width'];
+ ah = "" + tinyMCE.settings['area_height'];
+
+ if (aw.indexOf('%') == -1) {
+ aw = parseInt(aw);
+ aw = aw < 0 ? 300 : aw;
+ aw = aw + "px";
+ }
+
+ if (ah.indexOf('%') == -1) {
+ ah = parseInt(ah);
+ ah = ah < 0 ? 240 : ah;
+ ah = ah + "px";
+ }
+
+ iframe.setAttribute("id", id);
+ iframe.setAttribute("className", "mceEditorIframe");
+ iframe.setAttribute("border", "0");
+ iframe.setAttribute("frameBorder", "0");
+ iframe.setAttribute("marginWidth", "0");
+ iframe.setAttribute("marginHeight", "0");
+ iframe.setAttribute("leftMargin", "0");
+ iframe.setAttribute("topMargin", "0");
+ iframe.setAttribute("width", aw);
+ iframe.setAttribute("height", ah);
+ iframe.setAttribute("allowtransparency", "true");
+
+ if (tinyMCE.settings["auto_resize"])
+ iframe.setAttribute("scrolling", "no");
+
+ // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ iframe.setAttribute("src", this.settings['default_document']);
+
+ iframe.style.width = aw;
+ iframe.style.height = ah;
+
+ // MSIE 5.0 issue
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ replace_element.outerHTML = iframe.outerHTML;
+ else
+ replace_element.parentNode.replaceChild(iframe, replace_element);
+
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return win.frames[id];
+ else
+ return iframe;
+ },
+
+ setupContent : function(editor_id) {
+ var inst = tinyMCE.instances[editor_id];
+ var doc = inst.getDoc();
+ var head = doc.getElementsByTagName('head').item(0);
+ var content = inst.startContent;
inst.switchSettings();
- if (inst.formElement == formElement) {
+ // Not loaded correctly hit it again, Mozilla bug #997860
+ if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
+ // This part will remove the designMode status
+ // Failes first time in Firefox 1.5b2 on Mac
+ try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
+ window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);
+ return;
+ }
+
+ if (!head) {
+ window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);
+ return;
+ }
+
+ // Import theme specific content CSS the user specific
+ tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings['theme'] + "/css/editor_content.css");
+ tinyMCE.importCSS(inst.getDoc(), inst.settings['content_css']);
+ tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst);
+
+ // Setup keyboard shortcuts
+ if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) {
+ inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo');
+ inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
+ }
+
+ // Add default shortcuts for gecko
+ if (tinyMCE.isGecko) {
+ inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
+ inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic');
+ inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline');
+ }
+
+ // Setup span styles
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
+
+ if (tinyMCE.settings['nowrap'])
+ doc.body.style.whiteSpace = "nowrap";
+
+ doc.body.dir = this.settings['directionality'];
+ doc.editorId = editor_id;
+
+ // Add on document element in Mozilla
+ if (!tinyMCE.isMSIE)
+ doc.documentElement.editorId = editor_id;
+
+ inst.setBaseHREF(tinyMCE.settings['base_href']);
+
+ // Replace new line characters to BRs
+ if (tinyMCE.settings['convert_newlines_to_brs']) {
+ content = tinyMCE.regexpReplace(content, "\r\n", " ", "gi");
+ content = tinyMCE.regexpReplace(content, "\r", " ", "gi");
+ content = tinyMCE.regexpReplace(content, "\n", " ", "gi");
+ }
+
+ // Open closed anchors
+ // content = content.replace(new RegExp(' ', 'gi'), ' ');
+
+ // Call custom cleanup code
+ content = tinyMCE.storeAwayURLs(content);
+ content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
+
+ if (tinyMCE.isMSIE) {
+ // Ugly!!!
+ window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
+
+ if (tinyMCE.settings["force_br_newlines"])
+ doc.styleSheets[0].addRule("p", "margin: 0;");
+
+ var body = inst.getBody();
+ body.editorId = editor_id;
+ }
+
+ content = tinyMCE.cleanupHTMLCode(content);
+
+ // Fix for bug #958637
+ if (!tinyMCE.isMSIE) {
+ var contentElement = inst.getDoc().createElement("body");
var doc = inst.getDoc();
- tinyMCE._setHTML(doc, inst.formElement.value);
+ contentElement.innerHTML = content;
- if (!tinyMCE.isMSIE)
- doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
+ // Remove weridness!
+ if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt'])
+ content = content.replace(new RegExp('<>', 'g'), "");
+
+ if (tinyMCE.settings['cleanup_on_startup'])
+ tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
+ else {
+ // Convert all strong/em to b/i
+ content = tinyMCE.regexpReplace(content, "", "", "gi");
+ content = tinyMCE.regexpReplace(content, "", "", "gi");
+ content = tinyMCE.regexpReplace(content, " ", " ", "gi");
+ tinyMCE.setInnerHTML(inst.getBody(), content);
+ }
+
+ tinyMCE.convertAllRelativeURLs(inst.getBody());
+ } else {
+ if (tinyMCE.settings['cleanup_on_startup']) {
+ tinyMCE._setHTML(inst.getDoc(), content);
+
+ // Produces permission denied error in MSIE 5.5
+ eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}');
+ } else
+ tinyMCE._setHTML(inst.getDoc(), content);
+ }
+
+ // Fix for bug #957681
+ //inst.getDoc().designMode = inst.getDoc().designMode;
+
+ // Setup element references
+ var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');
+ inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
+
+ tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
+ tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
+
+ // Re-add design mode on mozilla
+ if (!tinyMCE.isMSIE)
+ tinyMCE.addEventHandlers(inst);
+
+ // Add blur handler
+ if (tinyMCE.isMSIE) {
+ tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
+
+ // Workaround for drag drop/copy paste base href bug
+ if (!tinyMCE.isOpera) {
+ tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove);
+ tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch);
+ }
+ }
+
+ // Trigger node change, this call locks buttons for tables and so forth
+ tinyMCE.selectedInstance = inst;
+ tinyMCE.selectedElement = inst.contentWindow.document.body;
+
+ // Call custom DOM cleanup
+ tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
+ tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
+ tinyMCE._setEventsEnabled(inst.getBody(), false);
+ tinyMCE.cleanupAnchors(inst.getDoc());
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(inst.getDoc());
+
+ inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
+ inst.undoRedo.add({ content : inst.startContent });
+
+ tinyMCE.selectedInstance = inst;
+ tinyMCE.triggerNodeChange(false, true);
+ },
+
+ storeAwayURLs : function(s) {
+ // Remove all mce_src, mce_href and replace them with new ones
+ // s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
+ // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
+
+ if (!s.match(/(mce_src|mce_href)/gi, s)) {
+ s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"');
+ s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"');
+ }
+
+ return s;
+ },
+
+ removeTinyMCEFormElements : function(form_obj) {
+ // Check if form is valid
+ if (typeof(form_obj) == "undefined" || form_obj == null)
+ return;
+
+ // If not a form, find the form
+ if (form_obj.nodeName != "FORM") {
+ if (form_obj.form)
+ form_obj = form_obj.form;
+ else
+ form_obj = tinyMCE.getParentElement(form_obj, "form");
+ }
+
+ // Still nothing
+ if (form_obj == null)
+ return;
+
+ // Disable all UI form elements that TinyMCE created
+ for (var i=0; i ");
+ rng.collapse(false);
+ rng.select();
+
+ tinyMCE.execCommand("mceAddUndoLevel");
+ tinyMCE.triggerNodeChange(false);
+ return false;
+ }
+ }
+
+ // Backspace or delete
+ if (e.keyCode == 8 || e.keyCode == 46) {
+ tinyMCE.selectedElement = e.target;
+ tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
+ tinyMCE.triggerNodeChange(false);
+ }
+
+ return false;
+ break;
+
+ case "keyup":
+ case "keydown":
+ tinyMCE.hideMenus();
+ tinyMCE.hasMouseMoved = false;
+
+ if (inst && inst.handleShortcut(e))
+ return false;
+
+ if (e.target.editorId)
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ else
+ return;
+
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.switchSettings();
+
+ var inst = tinyMCE.selectedInstance;
+
+ // Handle backspace
+ if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
+ // Insert P element instead of BR
+ if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
+ // Cancel event
+ tinyMCE.execCommand("mceAddUndoLevel");
+ e.preventDefault();
+ return false;
+ }
+ }
+
+ tinyMCE.selectedElement = null;
+ tinyMCE.selectedNode = null;
+ var elm = tinyMCE.selectedInstance.getFocusElement();
+ tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
+ tinyMCE.selectedElement = elm;
+
+ // Update visualaids on tabs
+ if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
+ tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);
+
+ // Fix empty elements on return/enter, check where enter occured
+ if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
+ tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
+
+ // Fix empty elements on return/enter
+ if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
+ var elm = tinyMCE.enterKeyElement;
+ if (elm) {
+ var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
+ var dre = new RegExp('^H[1-6]$','g'); // Add double on these
+
+ if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
+ if (dre.test(elm.nodeName))
+ elm.innerHTML = " ";
+ else
+ elm.innerHTML = " ";
+ }
+ }
+ }
+
+ // Check if it's a position key
+ var keys = tinyMCE.posKeyCodes;
+ var posKey = false;
+ for (var i=0; i';
+ h += ' ';
+ h += '';
+ } else {
+ // Normal button
+ h += '';
+ h += ' ';
+ h += ' ';
+ }
+
+ return h;
+ },
+
+ addButtonMap : function(m) {
+ var i, a = m.replace(/\s+/, '').split(',');
+
+ for (i=0; i 0);
+
+ if (tinyMCE.settings['custom_undo_redo']) {
+ undoIndex = inst.undoRedo.undoIndex;
+ undoLevels = inst.undoRedo.undoLevels.length;
+ }
+
+ tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
+ }
+
+ if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
+ this.selectedInstance.contentWindow.focus();
+ },
+
+ _customCleanup : function(inst, type, content) {
+ var pl, po, i;
+
+ // Call custom cleanup
+ var customCleanup = tinyMCE.settings['cleanup_callback'];
+ if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
+ content = eval(customCleanup + "(type, content, inst);");
+
+ // Trigger plugin cleanups
+ pl = inst.plugins;
+ for (i=0; i 0) {
+ for (i=ar.length-1; i>=0; i--) {
+ s = ar[i].substring(2, ar[i].length-1);
+
+ if (s.indexOf('lang_') == 0 && tinyMCELang[s])
+ h = tinyMCE.replaceVar(h, s, tinyMCELang[s]);
+ else if (as && as[s])
+ h = tinyMCE.replaceVar(h, s, as[s]);
+ else if (tinyMCE.settings[s])
+ h = tinyMCE.replaceVar(h, s, tinyMCE.settings[s]);
+ }
+ }
+
+ h = tinyMCE.replaceVar(h, "themeurl", tinyMCE.themeURL);
+
+ return h;
+ },
+
+ replaceVar : function(h, r, v) {
+ return h.replace(new RegExp('{\\\$' + r + '}', 'g'), v);
+ },
+
+ openWindow : function(template, args) {
+ var html, width, height, x, y, resizable, scrollbars, url;
+
+ args['mce_template_file'] = template['file'];
+ args['mce_width'] = template['width'];
+ args['mce_height'] = template['height'];
+ tinyMCE.windowArgs = args;
+
+ html = template['html'];
+ if (!(width = parseInt(template['width'])))
+ width = 320;
+
+ if (!(height = parseInt(template['height'])))
+ height = 200;
+
+ // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
+ if (tinyMCE.isMSIE)
+ height += 40;
+ else
+ height += 20;
+
+ x = parseInt(screen.width / 2.0) - (width / 2.0);
+ y = parseInt(screen.height / 2.0) - (height / 2.0);
+
+ resizable = (args && args['resizable']) ? args['resizable'] : "no";
+ scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
+
+ if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
+ url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
+ else
+ url = template['file'];
+
+ // Replace all args as variables in URL
+ for (var name in args) {
+ if (typeof(args[name]) == 'function')
+ continue;
+
+ url = tinyMCE.replaceVar(url, name, escape(args[name]));
+ }
+
+ if (html) {
+ html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']);
+ html = tinyMCE.applyTemplate(html, args);
+
+ var win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable);
+ if (win == null) {
+ alert(tinyMCELang['lang_popup_blocked']);
+ return;
+ }
+
+ win.document.write(html);
+ win.document.close();
+ win.resizeTo(width, height);
+ win.focus();
+ } else {
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
+ height += 10;
+
+ var features = "resizable:" + resizable
+ + ";scroll:"
+ + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:"
+ + width + "px;dialogHeight:" + height + "px;";
+
+ window.showModalDialog(url, window, features);
+ } else {
+ var modal = (resizable == "yes") ? "no" : "yes";
+
+ if (tinyMCE.isGecko && tinyMCE.isMac)
+ modal = "no";
+
+ if (template['close_previous'] != "no")
+ try {tinyMCE.lastWindow.close();} catch (ex) {}
+
+ var win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable);
+ if (win == null) {
+ alert(tinyMCELang['lang_popup_blocked']);
+ return;
+ }
+
+ if (template['close_previous'] != "no")
+ tinyMCE.lastWindow = win;
+
+ eval('try { win.resizeTo(width, height); } catch(e) { }');
+
+ // Make it bigger if statusbar is forced
+ if (tinyMCE.isGecko) {
+ if (win.document.defaultView.statusbar.visible)
+ win.resizeBy(0, tinyMCE.isMac ? 10 : 24);
+ }
+
+ win.focus();
+ }
+ }
+ },
+
+ closeWindow : function(win) {
+ win.close();
+ },
+
+ getVisualAidClass : function(class_name, state) {
+ var aidClass = tinyMCE.settings['visual_table_class'];
+
+ if (typeof(state) == "undefined")
+ state = tinyMCE.settings['visual'];
+
+ // Split
+ var classNames = new Array();
+ var ar = class_name.split(' ');
+ for (var i=0; i 0)
+ className += " ";
+
+ className += classNames[i];
+ }
+
+ return className;
+ },
+
+ handleVisualAid : function(el, deep, state, inst) {
+ if (!el)
+ return;
+
+ var tableElement = null;
+
+ switch (el.nodeName) {
+ case "TABLE":
+ var oldW = el.style.width;
+ var oldH = el.style.height;
+ var bo = tinyMCE.getAttrib(el, "border");
+
+ bo = bo == "" || bo == "0" ? true : false;
+
+ tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
+
+ el.style.width = oldW;
+ el.style.height = oldH;
+
+ for (var y=0; y ', 'gi'), ' ');
+
+ html_content = tinyMCE.cleanupHTMLCode(html_content);
+
+ // Try innerHTML if it fails use pasteHTML in MSIE
+ try {
+ tinyMCE.setInnerHTML(doc.body, html_content);
+ } catch (e) {
+ if (this.isMSIE)
+ doc.body.createTextRange().pasteHTML(html_content);
+ }
+
+ // Content duplication bug fix
+ if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
+ // Remove P elements in P elements
+ var paras = doc.getElementsByTagName("P");
+ for (var i=0; i<\/o:p>", " ");
+ html = tinyMCE.regexpReplace(html, " <\/o:p>", "");
+ html = tinyMCE.regexpReplace(html, "", "");
+ html = tinyMCE.regexpReplace(html, "<\/p>", "");
+ html = tinyMCE.regexpReplace(html, "
<\/p>\r\n
<\/p>", "");
+ html = tinyMCE.regexpReplace(html, "
<\/p>", " ");
+ html = tinyMCE.regexpReplace(html, "
\s*(
\s*)?", "
");
+ html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "
");
+ }*/
+
+ // Always set the htmlText output
+ tinyMCE.setInnerHTML(doc.body, html);
+ }
+
+ tinyMCE.cleanupAnchors(doc);
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(doc);
+ },
+
+ getEditorId : function(form_element) {
+ var inst = this.getInstanceById(form_element);
+ if (!inst)
+ return null;
+
+ return inst.editorId;
+ },
+
+ getInstanceById : function(editor_id) {
+ var inst = this.instances[editor_id];
+ if (!inst) {
+ for (var n in tinyMCE.instances) {
+ var instance = tinyMCE.instances[n];
+ if (!tinyMCE.isInstance(instance))
+ continue;
+
+ if (instance.formTargetElementId == editor_id) {
+ inst = instance;
+ break;
+ }
+ }
+ }
+
+ return inst;
+ },
+
+ queryInstanceCommandValue : function(editor_id, command) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+ if (inst)
+ return inst.queryCommandValue(command);
+
+ return false;
+ },
+
+ queryInstanceCommandState : function(editor_id, command) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+ if (inst)
+ return inst.queryCommandState(command);
+
+ return null;
+ },
+
+ setWindowArg : function(n, v) {
+ this.windowArgs[n] = v;
+ },
+
+ getWindowArg : function(n, d) {
+ return (typeof(this.windowArgs[n]) == "undefined") ? d : this.windowArgs[n];
+ },
+
+ getCSSClasses : function(editor_id, doc) {
+ var output = new Array();
+
+ // Is cached, use that
+ if (typeof(tinyMCE.cssClasses) != "undefined")
+ return tinyMCE.cssClasses;
+
+ if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {
+ var instance;
+
+ for (var instanceName in tinyMCE.instances) {
+ instance = tinyMCE.instances[instanceName];
+ if (!tinyMCE.isInstance(instance))
+ continue;
+
+ break;
+ }
+
+ doc = instance.getDoc();
+ }
+
+ if (typeof(doc) == "undefined") {
+ var instance = tinyMCE.getInstanceById(editor_id);
+ doc = instance.getDoc();
+ }
+
+ if (doc) {
+ var styles = tinyMCE.isMSIE ? doc.styleSheets : doc.styleSheets;
+
+ if (styles && styles.length > 0) {
+ for (var x=0; x 0)
+ tinyMCE.cssClasses = output;
+
+ return output;
+ },
+
+ regexpReplace : function(in_str, reg_exp, replace_str, opts) {
+ if (in_str == null)
+ return in_str;
+
+ if (typeof(opts) == "undefined")
+ opts = 'g';
+
+ var re = new RegExp(reg_exp, opts);
+ return in_str.replace(re, replace_str);
+ },
+
+ trim : function(s) {
+ return s.replace(/^\s*|\s*$/g, "");
+ },
+
+ cleanupEventStr : function(s) {
+ s = "" + s;
+ s = s.replace('function anonymous()\n{\n', '');
+ s = s.replace('\n}', '');
+ s = s.replace(/^return true;/gi, ''); // Remove event blocker
+
+ return s;
+ },
+
+ getControlHTML : function(c) {
+ var i, l, n, o, v;
+
+ l = tinyMCE.plugins;
+ for (n in l) {
+ o = l[n];
+
+ if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
+ return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
+ }
+
+ o = tinyMCE.themes[tinyMCE.settings['theme']];
+ if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
+ return v;
+
+ return '';
+ },
+
+ evalFunc : function(f, idx, a) {
+ var s = '(', i;
+
+ for (i=idx; i 0)
+ return true;
+
+ if (ins != null) {
+ for (i=0, l = ins.plugins; i 0)
+ return true;
+ }
+ }
+
+ l = tinyMCE.themes;
+ for (on in l) {
+ o = l[on];
+
+ if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ return true;
+ }
+
+ return false;
+ },
+
+ xmlEncode : function(s) {
+ s = "" + s;
+ s = s.replace(/&/g, '&');
+ s = s.replace(new RegExp('"', 'g'), '"');
+ s = s.replace(/\'/g, '''); // ' is not working in MSIE
+ s = s.replace(//g, '>');
+
+ return s;
+ },
+
+ extend : function(p, np) {
+ var o = {};
+
+ o.parent = p;
+
+ for (n in p)
+ o[n] = p[n];
+
+ for (n in np)
+ o[n] = np[n];
+
+ return o;
+ },
+
+ hideMenus : function() {
+ var e = tinyMCE.lastSelectedMenuBtn;
+
+ if (tinyMCE.lastMenu) {
+ tinyMCE.lastMenu.hide();
+ tinyMCE.lastMenu = null;
+ }
+
+ if (e) {
+ tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass);
+ tinyMCE.lastSelectedMenuBtn = null;
}
}
};
-TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) {
- var id = "mce_editor_" + tinyMCE.idCounter++;
- var inst = new TinyMCEControl(tinyMCE.settings);
+// Global instances
+var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors
+var tinyMCE = new TinyMCE_Engine();
+var tinyMCELang = {};
- inst.editorId = id;
- this.instances[id] = inst;
+/* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */
- inst.onAdd(replace_element, form_element_name, target_document);
+function TinyMCE_Control(settings) {
+ var t, i, to, fu, p, x, fn, fu, pn, s = settings;
+
+ this.undoRedoLevel = true;
+ this.isTinyMCE_Control = true;
+
+ // Default settings
+ this.settings = s;
+ this.settings['theme'] = tinyMCE.getParam("theme", "default");
+ this.settings['width'] = tinyMCE.getParam("width", -1);
+ this.settings['height'] = tinyMCE.getParam("height", -1);
+ this.selection = new TinyMCE_Selection(this);
+ this.undoRedo = new TinyMCE_UndoRedo(this);
+ this.cleanup = new TinyMCE_Cleanup();
+ this.shortcuts = new Array();
+ this.hasMouseMoved = false;
+
+ this.cleanup.init({
+ valid_elements : s.valid_elements,
+ extended_valid_elements : s.extended_valid_elements,
+ entities : s.entities,
+ entity_encoding : s.entity_encoding,
+ debug : s.cleanup_debug,
+ url_converter : 'TinyMCE_Cleanup.prototype._urlConverter',
+ indent : s.apply_source_formatting,
+ invalid_elements : s.invalid_elements,
+ verify_html : s.verify_html,
+ fix_content_duplication : s.fix_content_duplication
+ });
+
+ // Wrap old theme
+ t = this.settings['theme'];
+ if (!tinyMCE.hasTheme(t)) {
+ fn = tinyMCE.callbacks;
+ to = {};
+
+ for (i=0; i 0) {
+ for (i=0; i 1 && tinyMCE.currentConfig != this.settings['index']) {
+ tinyMCE.settings = this.settings;
+ tinyMCE.currentConfig = this.settings['index'];
+ }
+ },
+
+ getBody : function() {
+ return this.getDoc().body;
+ },
+
+ getDoc : function() {
+ return this.contentWindow.document;
+ },
+
+ getWin : function() {
+ return this.contentWindow;
+ },
+
+ addShortcut : function(m, k, d, cmd, ui, va) {
+ var n = typeof(k) == "number", ie = tinyMCE.isMSIE, c, sc, i;
+ var scl = this.shortcuts;
+
+ if (!tinyMCE.getParam('custom_shortcuts'))
+ return false;
+
+ m = m.toLowerCase();
+ k = ie && !n ? k.toUpperCase() : k;
+ c = n ? null : k.charCodeAt(0);
+ d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d;
+
+ sc = {
+ alt : m.indexOf('alt') != -1,
+ ctrl : m.indexOf('ctrl') != -1,
+ shift : m.indexOf('shift') != -1,
+ charCode : c,
+ keyCode : n ? k : (ie ? c : null),
+ desc : d,
+ cmd : cmd,
+ ui : ui,
+ val : va
+ };
+
+ for (i=0; i 0)
+ rng.pasteHTML('' + rng.htmlText + "
");
+
+ tinyMCE.triggerNodeChange();
+ return;
+ }
+ }
+ }
+
+ switch (command) {
+ case "mceRepaint":
+ this.repaint();
+ return true;
+
+ case "InsertUnorderedList":
+ case "InsertOrderedList":
+ var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
+
+ if (tinyMCE.isSafari)
+ this.execCommand("mceInsertContent", false, "<" + tag + "> <" + tag + ">");
+ else
+ this.getDoc().execCommand(command, user_interface, value);
+
+ tinyMCE.triggerNodeChange();
+ break;
+
+ case "Strikethrough":
+ if (tinyMCE.isSafari)
+ this.execCommand("mceInsertContent", false, "" + this.selection.getSelectedHTML() + " ");
+ else
+ this.getDoc().execCommand(command, user_interface, value);
+
+ tinyMCE.triggerNodeChange();
+ break;
+
+ case "mceSelectNode":
+ this.selection.selectNode(value);
+ tinyMCE.triggerNodeChange();
+ tinyMCE.selectedNode = value;
+ break;
+
+ case "FormatBlock":
+ if (value == null || value == "") {
+ var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");
+
+ if (elm)
+ this.execCommand("mceRemoveNode", false, elm);
+ } else {
+ if (value == '' && tinyMCE.isGecko)
+ value = 'div';
+
+ this.getDoc().execCommand("FormatBlock", false, value);
+ }
+
+ tinyMCE.triggerNodeChange();
+
+ break;
+
+ case "mceRemoveNode":
+ if (!value)
+ value = tinyMCE.getParentElement(this.getFocusElement());
+
+ if (tinyMCE.isMSIE) {
+ value.outerHTML = value.innerHTML;
+ } else {
+ var rng = value.ownerDocument.createRange();
+ rng.setStartBefore(value);
+ rng.setEndAfter(value);
+ rng.deleteContents();
+ rng.insertNode(rng.createContextualFragment(value.innerHTML));
+ }
+
+ tinyMCE.triggerNodeChange();
+
+ break;
+
+ case "mceSelectNodeDepth":
+ var parentNode = this.getFocusElement();
+ for (var i=0; parentNode; i++) {
+ if (parentNode.nodeName.toLowerCase() == "body")
+ break;
+
+ if (parentNode.nodeName.toLowerCase() == "#text") {
+ i--;
+ parentNode = parentNode.parentNode;
+ continue;
+ }
+
+ if (i == value) {
+ this.selection.selectNode(parentNode, false);
+ tinyMCE.triggerNodeChange();
+ tinyMCE.selectedNode = parentNode;
+ return;
+ }
+
+ parentNode = parentNode.parentNode;
+ }
+
+ break;
+
+ case "SetStyleInfo":
+ var rng = this.getRng();
+ var sel = this.getSel();
+ var scmd = value['command'];
+ var sname = value['name'];
+ var svalue = value['value'] == null ? '' : value['value'];
+ //var svalue = value['value'] == null ? '' : value['value'];
+ var wrapper = value['wrapper'] ? value['wrapper'] : "span";
+ var parentElm = null;
+ var invalidRe = new RegExp("^BODY|HTML$", "g");
+ var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;
+
+ // Whole element selected check
+ if (tinyMCE.isMSIE) {
+ // Control range
+ if (rng.item)
+ parentElm = rng.item(0);
+ else {
+ var pelm = rng.parentElement();
+ var prng = doc.selection.createRange();
+ prng.moveToElementText(pelm);
+
+ if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
+ if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
+ parentElm = pelm;
+ }
+ }
+ } else {
+ var felm = this.getFocusElement();
+ if (sel.isCollapsed || (new RegExp('td|tr|tbody|table', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode))
+ parentElm = felm;
+ }
+
+ // Whole element selected
+ if (parentElm && !invalidRe.test(parentElm.nodeName)) {
+ if (scmd == "setstyle")
+ tinyMCE.setStyleAttrib(parentElm, sname, svalue);
+
+ if (scmd == "setattrib")
+ tinyMCE.setAttrib(parentElm, sname, svalue);
+
+ if (scmd == "removeformat") {
+ parentElm.style.cssText = '';
+ tinyMCE.setAttrib(parentElm, 'class', '');
+ }
+
+ // Remove style/attribs from all children
+ var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);
+ for (var z=0; z
=0; i--) {
+ var elm = nodes[i];
+ var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
+
+ elm.removeAttribute("mce_new");
+
+ // Is only child a element
+ if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
+ //tinyMCE.debug("merge1" + isNew);
+ this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
+ continue;
+ }
+
+ // Is I the only child
+ if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
+ //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
+ if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
+ this._mergeElements(scmd, elm.parentNode, elm, false);
+ }
+ }
+
+ // Remove empty wrappers
+ var nodes = doc.getElementsByTagName(wrapper);
+ for (var i=nodes.length-1; i>=0; i--) {
+ var elm = nodes[i];
+ var isEmpty = true;
+
+ // Check if it has any attribs
+ var tmp = doc.createElement("body");
+ tmp.appendChild(elm.cloneNode(false));
+
+ // Is empty span, remove it
+ tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
+ //tinyMCE.debug(tmp.innerHTML);
+ if (new RegExp('', 'gi').test(tmp.innerHTML)) {
+ for (var x=0; x 0) {
+ value = tinyMCE.replaceVar(value, "selection", selectedText);
+ tinyMCE.execCommand('mceInsertContent', false, value);
+ }
+
+ tinyMCE.triggerNodeChange();
+ break;
+
+ case "mceSetAttribute":
+ if (typeof(value) == 'object') {
+ var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];
+ var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
+
+ if (targetNode) {
+ targetNode.setAttribute(value['name'], value['value']);
+ tinyMCE.triggerNodeChange();
+ }
+ }
+ break;
+
+ case "mceSetCSSClass":
+ this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value});
+ break;
+
+ case "mceInsertRawHTML":
+ var key = 'tiny_mce_marker';
+
+ this.execCommand('mceBeginUndoLevel');
+
+ // Insert marker key
+ this.execCommand('mceInsertContent', false, key);
+
+ // Store away scroll pos
+ var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
+ var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
+
+ // Find marker and replace with RAW HTML
+ var html = this.getBody().innerHTML;
+ if ((pos = html.indexOf(key)) != -1)
+ tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
+
+ // Restore scoll pos
+ this.contentWindow.scrollTo(scrollX, scrollY);
+
+ this.execCommand('mceEndUndoLevel');
+
+ break;
+
+ case "mceInsertContent":
+ // Force empty string
+ if (!value)
+ value = '';
+
+ var insertHTMLFailed = false;
+ this.getWin().focus();
+
+ if (tinyMCE.isGecko || tinyMCE.isOpera) {
+ try {
+ // Is plain text or HTML, &, etc will be encoded wrong in FF
+ if (value.indexOf('<') == -1 && !value.match(/(&| |<|>)/g)) {
+ var r = this.getRng();
+ var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value));
+ var s = this.getSel();
+ var r2 = r.cloneRange();
+
+ // Insert text at cursor position
+ s.removeAllRanges();
+ r.deleteContents();
+ r.insertNode(n);
+
+ // Move the cursor to the end of text
+ r2.selectNode(n);
+ r2.collapse(false);
+ s.removeAllRanges();
+ s.addRange(r2);
+ } else {
+ value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value);
+ this.getDoc().execCommand('inserthtml', false, value);
+ tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
+ }
+ } catch (ex) {
+ insertHTMLFailed = true;
+ }
+
+ if (!insertHTMLFailed) {
+ tinyMCE.triggerNodeChange();
+ return;
+ }
+ }
+
+ // Ugly hack in Opera due to non working "inserthtml"
+ if (tinyMCE.isOpera && insertHTMLFailed) {
+ this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);
+ var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);
+ ar[0].outerHTML = value;
+ return;
+ }
+
+ if (!tinyMCE.isMSIE) {
+ var isHTML = value.indexOf('<') != -1;
+ var sel = this.getSel();
+ var rng = this.getRng();
+
+ if (isHTML) {
+ if (tinyMCE.isSafari) {
+ var tmpRng = this.getDoc().createRange();
+
+ tmpRng.setStart(this.getBody(), 0);
+ tmpRng.setEnd(this.getBody(), 0);
+
+ value = tmpRng.createContextualFragment(value);
+ } else
+ value = rng.createContextualFragment(value);
+ } else {
+ // Setup text node
+ var el = document.createElement("div");
+ el.innerHTML = value;
+ value = el.firstChild.nodeValue;
+ value = doc.createTextNode(value);
+ }
+
+ // Insert plain text in Safari
+ if (tinyMCE.isSafari && !isHTML) {
+ this.execCommand('InsertText', false, value.nodeValue);
+ tinyMCE.triggerNodeChange();
+ return true;
+ } else if (tinyMCE.isSafari && isHTML) {
+ rng.deleteContents();
+ rng.insertNode(value);
+ tinyMCE.triggerNodeChange();
+ return true;
+ }
+
+ rng.deleteContents();
+
+ // If target node is text do special treatment, (Mozilla 1.3 fix)
+ if (rng.startContainer.nodeType == 3) {
+ var node = rng.startContainer.splitText(rng.startOffset);
+ node.parentNode.insertBefore(value, node);
+ } else
+ rng.insertNode(value);
+
+ if (!isHTML) {
+ // Removes weird selection trails
+ sel.selectAllChildren(doc.body);
+ sel.removeAllRanges();
+
+ // Move cursor to end of content
+ var rng = doc.createRange();
+
+ rng.selectNode(value);
+ rng.collapse(false);
+
+ sel.addRange(rng);
+ } else
+ rng.collapse(false);
+
+ tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
+ } else {
+ var rng = doc.selection.createRange();
+ var c = value.indexOf('";
-
- default: // Unknown
- return "[UNKNOWN NODETYPE " + node.nodeType + "]";
+ var fColor = s[i].style.color;
+ if (fColor != null && fColor != "") {
+ tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor));
+ s[i].style.color = '';
+ }
}
};
-TinyMCE.prototype.convertStringToXML = function(html_data) {
- var output = "";
+TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) {
+ var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
- for (var i=0; i 127)
- output += '' + chr + ";";
- else
- output += String.fromCharCode(chr);
+ var fsClasses = tinyMCE.getParam('font_size_classes');
+ if (fsClasses != '')
+ fsClasses = fsClasses.replace(/\s+/, '').split(',');
+ else
+ fsClasses = null;
- continue;
- }
+ var s = doc.getElementsByTagName("span");
+ for (var i=0; i 0 && fSize < 8) {
+ if (fsClasses != null)
+ tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]);
+ else
+ s[i].style.fontSize = sizes[fSize-1];
}
- // Force check
- if ((pos = attribName.indexOf(':')) != -1) {
- attribForce = attribName.substring(pos+1);
- attribName = attribName.substring(0, pos);
- }
-
- // Force check
- if ((pos = attribName.indexOf('<')) != -1) {
- attribMustBe = attribName.substring(pos+1).split('?');
- attribName = attribName.substring(0, pos);
- }
-
- attribs[x] = new Array(attribName, attribDefault, attribForce, attribMustBe);
+ s[i].removeAttribute('size');
}
- validElements[i] = attribs;
+ if (fFace != "") {
+ s[i].style.fontFamily = fFace;
+ s[i].removeAttribute('face');
+ }
+
+ if (fColor != "") {
+ s[i].style.color = fColor;
+ s[i].removeAttribute('color');
+ }
}
-
- var invalidElements = tinyMCE.settings['invalid_elements'].split(',');
- for (var i=0; i/gi, '>');
-
- return html;
- }
-
- if (on_save && tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertFontsToSpans(doc);
-
- // Call custom cleanup code
- tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);
-
- // Move bgcolor to style
- var n = doc.getElementsByTagName("font");
- for (var i=0; i=0; x--)
+ tinyMCE.insertAfter(cn[x], an[i]);
}
}
-
- // Set these for performance
- tinyMCE.cleanup_validElements = tinyMCE.settings['cleanup_validElements'];
- tinyMCE.cleanup_invalidElements = tinyMCE.settings['cleanup_invalidElements'];
- tinyMCE.cleanup_verify_html = tinyMCE.settings['verify_html'];
- tinyMCE.cleanup_force_br_newlines = tinyMCE.settings['force_br_newlines'];
- tinyMCE.cleanup_urlconverter_callback = tinyMCE.settings['urlconverter_callback'];
- tinyMCE.cleanup_verify_css_classes = tinyMCE.settings['verify_css_classes'];
- tinyMCE.cleanup_visual_table_class = tinyMCE.settings['visual_table_class'];
- tinyMCE.cleanup_apply_source_formatting = tinyMCE.settings['apply_source_formatting'];
- tinyMCE.cleanup_inline_styles = tinyMCE.settings['inline_styles'];
- tinyMCE.cleanup_visual_aid = visual;
- tinyMCE.cleanup_on_save = on_save;
- tinyMCE.cleanup_idCount = 0;
- tinyMCE.cleanup_elementLookupTable = new Array();
-
- var startTime = new Date().getTime();
-
- // Cleanup madness that breaks the editor in MSIE
- if (tinyMCE.isMSIE) {
- // Remove null ids from HR elements, results in runtime error
- var nodes = element.getElementsByTagName("hr");
- for (var i=0; i[ \n\r]*[ \n\r]*', ' ', 'gi'));
- tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '', '', 'gi'));
- }
-
- var html = this.cleanupNode(element);
-
- if (tinyMCE.settings['debug'])
- tinyMCE.debug("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms.");
-
- // Remove pesky HR paragraphs and other crap
- html = tinyMCE.regexpReplace(html, '
', ' ');
- html = tinyMCE.regexpReplace(html, '
', ' ');
- html = tinyMCE.regexpReplace(html, '\\s* \\s* ', ' ');
- html = tinyMCE.regexpReplace(html, '\\s* \\s*
', '
');
- html = tinyMCE.regexpReplace(html, '\\s* \\s* \\s* \\s*
', '
');
- html = tinyMCE.regexpReplace(html, '\\s* \\s* \\s*
', '
');
- html = tinyMCE.regexpReplace(html, '\\s* \\s* \\s*
', '
');
-
- // Remove empty anchors
- html = html.replace(new RegExp('(.*?) ', 'gi'), '$1');
-
- // Remove some mozilla crap
- if (!tinyMCE.isMSIE)
- html = html.replace(new RegExp(' ', 'g'), "");
-
- if (tinyMCE.settings['remove_linebreaks'])
- html = html.replace(new RegExp('\r|\n', 'g'), ' ');
-
- if (tinyMCE.getParam('apply_source_formatting')) {
- html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n");
- html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n$1$2>\n");
- html = html.replace(new RegExp(' ', 'g'), " \n");
- }
-
- if (tinyMCE.settings['force_br_newlines']) {
- var re = new RegExp('
', 'g');
- html = html.replace(re, " ");
- }
-
- if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) {
- // Remove weridness!
- var re = new RegExp('<>', 'g');
- html = html.replace(re, "");
- }
-
- // Call custom cleanup code
- html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html);
-
- // Emtpy node, return empty
- var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase();
- if (chk == " " || chk == " " || chk == "
" || chk == "
" || chk == "
")
- html = "";
-
- if (tinyMCE.settings["preformatted"])
- return "" + html + " ";
-
- return html;
};
-TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) {
- tinyMCE.execCommand('mceBeginUndoLevel');
+TinyMCE_Engine.prototype.getContent = function(editor_id) {
+ var h;
- if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") {
- var doc = this.selectedInstance.getDoc();
- var linkElement = tinyMCE.getParentElement(this.selectedElement, "a");
- var newLink = false;
+ if (typeof(editor_id) != "undefined")
+ tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);
- if (!linkElement) {
- linkElement = doc.createElement("a");
- newLink = true;
- }
+ if (tinyMCE.selectedInstance) {
+ h = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);
- var mhref = href;
- var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
- mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+ // When editing always use fonts internaly
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(this.selectedInstance.getDoc());
- tinyMCE.setAttrib(linkElement, 'href', thref);
- tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
- tinyMCE.setAttrib(linkElement, 'target', target);
- tinyMCE.setAttrib(linkElement, 'title', title);
- tinyMCE.setAttrib(linkElement, 'onclick', onclick);
- tinyMCE.setAttrib(linkElement, 'class', style_class);
-
- if (newLink) {
- linkElement.appendChild(this.selectedElement.cloneNode(true));
- this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement);
- }
-
- return;
- }
-
- if (!this.linkElement && this.selectedInstance) {
- if (tinyMCE.isSafari) {
- tinyMCE.execCommand("mceInsertContent", false, '' + this.selectedInstance.getSelectedHTML() + ' ');
- } else
- this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
-
- tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
-
- var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
-
- for (var i=0; i ';
-
- tinyMCE.execCommand("mceInsertContent", false, html);
- } else {
- if (!this.imgElement && this.selectedInstance) {
- if (tinyMCE.isSafari)
- tinyMCE.execCommand("mceInsertContent", false, ' ');
- else
- this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
-
- tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
- }
- }
-
- if (this.imgElement) {
- var needsRepaint = false;
- var msrc = src;
-
- src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
-
- if (tinyMCE.getParam('convert_urls'))
- msrc = src;
-
- if (onmouseover && onmouseover != "")
- onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
-
- if (onmouseout && onmouseout != "")
- onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
-
- // Use alt as title if it's undefined
- if (typeof(title) == "undefined")
- title = alt;
-
- if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align"))
- needsRepaint = true;
-
- tinyMCE.setAttrib(this.imgElement, 'src', src);
- tinyMCE.setAttrib(this.imgElement, 'mce_src', msrc);
- tinyMCE.setAttrib(this.imgElement, 'alt', alt);
- tinyMCE.setAttrib(this.imgElement, 'title', title);
- tinyMCE.setAttrib(this.imgElement, 'align', align);
- tinyMCE.setAttrib(this.imgElement, 'border', border, true);
- tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true);
- tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true);
- tinyMCE.setAttrib(this.imgElement, 'width', width, true);
- tinyMCE.setAttrib(this.imgElement, 'height', height, true);
- tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover);
- tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout);
-
- // Fix for bug #989846 - Image resize bug
- if (width && width != "")
- this.imgElement.style.pixelWidth = width;
-
- if (height && height != "")
- this.imgElement.style.pixelHeight = height;
-
- if (needsRepaint)
- tinyMCE.selectedInstance.repaint();
- }
-
- tinyMCE.execCommand('mceEndUndoLevel');
-};
-
-TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) {
- var elements = this.getElementsByAttributeValue(node, element_name, attrib, value);
- if (elements.length == 0)
- return null;
-
- return elements[0];
-};
-
-TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) {
- var elements = new Array();
-
- if (node && node.nodeName.toLowerCase() == element_name) {
- if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1)
- elements[elements.length] = node;
- }
-
- if (node && node.hasChildNodes()) {
- for (var x=0, n=node.childNodes.length; x]*>/gi, '');
+ h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), '');
+ h = h.replace(/
<\/p>/g, ' ');
+ h = h.replace(/( | )<\/p>
( | )<\/p>/g, '
');
+ h = h.replace(/\s* \s*<\/td>/g, ' ');
+ h = h.replace(/\s* \s*<\/p>/g, '
');
+ h = h.replace(/\s*( | )\s* \s*( | )\s*<\/p>/g, '
');
+ h = h.replace(/\s*( | )\s* \s*<\/p>/g, '
');
+ h = h.replace(/\s* \s* \s*<\/p>/g, '
');
+ h = h.replace(/(.*?)<\/a>/g, '$1');
+ h = h.replace(/]*)>\s*<\/p>/g, '
');
+
+ // Clean body
+ if (/^\s*( | <\/p>|
<\/p>|
<\/p>)\s*$/.test(h))
+ h = '';
+
+ // If preformatted
+ if (s.preformatted) {
+ h = h.replace(/^
/, '');
+ h = h.replace(/<\/pre>$/, '');
+ h = '' + h + ' ';
+ }
+
+ // Gecko specific processing
+ if (tinyMCE.isGecko) {
+ h = h.replace(/ /g, '');
+ h = h.replace(/]*)>\s* \s*<\/td>/g, ' ');
+ }
+
+ if (s.force_br_newlines)
+ h = h.replace(/( | )<\/p>/g, ' ');
+
+ // Call custom cleanup code
+ h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h);
+
+ // Remove internal classes
+ if (on_save) {
+ h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), '');
+ h = h.replace(new RegExp(' ?class=""', 'g'), '');
+ }
+
+ if (s.remove_linebreaks && !c.settings.indent)
+ h = h.replace(/\n|\r/g, ' ');
+
+ if (d)
+ t4 = new Date().getTime();
+
+ if (on_save && c.settings.indent)
+ h = c.formatHTML(h);
+
+ // If encoding (not recommended option)
+ if (on_submit && (s.encoding == "xml" || s.encoding == "html"))
+ h = c.xmlEncode(h);
+
+ if (d)
+ t5 = new Date().getTime();
+
+ if (c.settings.debug)
+ tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + ".");
+
+ return h;
+};
+
+function TinyMCE_Cleanup() {
+ this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ this.rules = tinyMCE.clearArray(new Array());
+
+ // Default config
+ this.settings = {
+ indent_elements : 'head,table,tbody,thead,tfoot,form,tr,ul,ol,blockquote,object',
+ newline_before_elements : 'h1,h2,h3,h4,h5,h6,pre,address,div,ul,ol,li,meta,option,area,title,link,base,script,td',
+ newline_after_elements : 'br,hr,p,pre,address,div,ul,ol,meta,option,area,link,base,script',
+ newline_before_after_elements : 'html,head,body,table,thead,tbody,tfoot,tr,form,ul,ol,blockquote,p,object,param,hr,div',
+ indent_char : '\t',
+ indent_levels : 1,
+ entity_encoding : 'raw',
+ valid_elements : '*[*]',
+ entities : '',
+ url_converter : '',
+ invalid_elements : '',
+ verify_html : false
+ };
+
+ this.vElements = tinyMCE.clearArray(new Array());
+ this.vElementsRe = '';
+ this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON)$/;
+ this.codeElementsRe = /^(SCRIPT|STYLE)$/;
+ this.serializationId = 0;
+ this.mceAttribs = {
+ href : 'mce_href',
+ src : 'mce_src',
+ type : 'mce_type'
+ };
+}
+
+TinyMCE_Cleanup.prototype = {
+ init : function(s) {
+ var n, a, i, ir, or, st;
+
+ for (n in s)
+ this.settings[n] = s[n];
+
+ // Setup code formating
+ s = this.settings;
+
+ // Setup regexps
+ this.inRe = this._arrayToRe(s.indent_elements.split(','), '', '^<(', ')[^>]*');
+ this.ouRe = this._arrayToRe(s.indent_elements.split(','), '', '^<\\/(', ')[^>]*');
+ this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>');
+ this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>');
+ this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>');
+
+ if (s.invalid_elements != '')
+ this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$');
+ else
+ this.iveRe = null;
+
+ // Setup separator
+ st = '';
+ for (i=0; i 1) {
+ r.vAttribsRe = '^(';
+ a = this.split(/\|/, p[1]);
+
+ for (i=0; i 0) {
+ if (av[0].charAt(0) == ':') {
+ if (!r.forceAttribs)
+ r.forceAttribs = tinyMCE.clearArray(new Array());
+
+ r.forceAttribs[t.toLowerCase()] = av[0].substring(1);
+ } else if (av[0].charAt(0) == '=') {
+ if (!r.defaultAttribs)
+ r.defaultAttribs = tinyMCE.clearArray(new Array());
+
+ dv = av[0].substring(1);
+
+ r.defaultAttribs[t.toLowerCase()] = dv == "" ? "mce_empty" : dv;
+ } else if (av[0].charAt(0) == '<') {
+ if (!r.validAttribValues)
+ r.validAttribValues = tinyMCE.clearArray(new Array());
+
+ r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), '');
+ }
+ }
+
+ r.vAttribsRe += '' + t.toLowerCase() + (i != a.length - 1 ? '|' : '');
+
+ a[i] = t.toLowerCase();
+ }
+
+ r.vAttribsRe += ')$';
+ r.vAttribsRe = this._wildcardToRe(r.vAttribsRe);
+ r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe);
+ r.vAttribsRe = new RegExp(r.vAttribsRe);
+ r.vAttribs = a.reverse();
+
+ //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC);
+ } else {
+ r.vAttribsRe = '';
+ r.vAttribs = tinyMCE.clearArray(new Array());
+ r.vAttribsReIsWild = false;
+ }
+
+ or[r.tag] = r;
+ }
+ }
+
+ return or;
+ },
+
+ serializeNodeAsXML : function(n) {
+ var s, b;
+
+ if (!this.xmlDoc) {
+ if (this.isMSIE) {
+ try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
+
+ if (!this.xmlDoc)
+ try {this.xmlDoc = new ActiveXObject('Microsoft.XmlDom');} catch (e) {}
+ } else
+ this.xmlDoc = document.implementation.createDocument('', '', null);
+
+ if (!this.xmlDoc)
+ alert("Error XML Parser could not be found.");
+ }
+
+ if (this.xmlDoc.firstChild)
+ this.xmlDoc.removeChild(this.xmlDoc.firstChild);
+
+ b = this.xmlDoc.createElement("html");
+ b = this.xmlDoc.appendChild(b);
+
+ this._convertToXML(n, b);
+
+ if (this.isMSIE)
+ return this.xmlDoc.xml;
+ else
+ return new XMLSerializer().serializeToString(this.xmlDoc);
+ },
+
+ _convertToXML : function(n, xn) {
+ var xd, el, i, l, cn, at, no, hc = false;
+
+ if (this._isDuplicate(n))
+ return;
+
+ xd = this.xmlDoc;
+
+ switch (n.nodeType) {
+ case 1: // Element
+ hc = n.hasChildNodes();
+
+ el = xd.createElement(n.nodeName.toLowerCase());
+
+ at = n.attributes;
+ for (i=at.length-1; i>-1; i--) {
+ no = at[i];
+
+ if (no.specified && no.nodeValue)
+ el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue);
+ }
+
+ if (!hc && !this.closeElementsRe.test(n.nodeName))
+ el.appendChild(xd.createTextNode(""));
+
+ xn = xn.appendChild(el);
+ break;
+
+ case 3: // Text
+ xn.appendChild(xd.createTextNode(n.nodeValue));
+ return;
+
+ case 8: // Comment
+ xn.appendChild(xd.createComment(n.nodeValue));
+ return;
+ }
+
+ if (hc) {
+ cn = n.childNodes;
+
+ for (i=0, l=cn.length; i
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && n.nodeName.indexOf('/') != -1)
+ break;
+
+ if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName))) {
+ va = true;
+
+ r = this.rules[n.nodeName];
+ if (!r) {
+ at = this.rules;
+ for (no in at) {
+ if (at[no] && at[no].validRe.test(n.nodeName)) {
+ r = at[no];
+ break;
+ }
+ }
+ }
+
+ en = r.isWild ? n.nodeName.toLowerCase() : r.oTagName;
+ f = r.fill;
+
+ if (r.removeEmpty && !hc)
+ return "";
+
+ h += '<' + en;
+
+ if (r.vAttribsReIsWild) {
+ // Serialize wildcard attributes
+ at = n.attributes;
+ for (i=at.length-1; i>-1; i--) {
+ no = at[i];
+ if (no.specified && r.vAttribsRe.test(no.nodeName))
+ h += this._serializeAttribute(n, r, no.nodeName);
+ }
+ } else {
+ // Serialize specific attributes
+ for (i=r.vAttribs.length-1; i>-1; i--)
+ h += this._serializeAttribute(n, r, r.vAttribs[i]);
+ }
+
+ // Serialize mce_ atts
+ if (!this.settings.on_save) {
+ at = this.mceAttribs;
+
+ for (no in at) {
+ if (at[no])
+ h += this._serializeAttribute(n, r, at[no]);
+ }
+ }
+
+ // Close these
+ if (this.closeElementsRe.test(n.nodeName))
+ return h + ' />';
+
+ h += '>';
+
+ if (this.isMSIE && this.codeElementsRe.test(n.nodeName))
+ h += n.innerHTML;
+ }
+ break;
+
+ case 3: // Text
+ if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
+ return this.isMSIE ? '' : n.nodeValue;
+
+ return this.xmlEncode(n.nodeValue);
+
+ case 8: // Comment
+ return "";
+ }
+
+ if (hc) {
+ cn = n.childNodes;
+
+ for (i=0, l=cn.length; i';
+
+ return h;
+ },
+
+ _serializeAttribute : function(n, r, an) {
+ var av = '', t, os = this.settings.on_save;
+
+ if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0))
+ return '';
+
+ if (os && this.mceAttribs[an])
+ av = this._getAttrib(n, this.mceAttribs[an]);
+
+ if (av.length == 0)
+ av = this._getAttrib(n, an);
+
+ if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) {
+ av = t;
+
+ if (av == "mce_empty")
+ return " " + an + '=""';
+ }
+
+ if (r.forceAttribs && (t = r.forceAttribs[an]))
+ av = t;
+
+ if (os && av.length != 0 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an))
+ av = eval(this.settings.url_converter + '(this, n, av)');
+
+ if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
+ return "";
+
+ if (av.length != 0 && av == "{$uid}")
+ av = "uid_" + (this.idCount++);
+
+ if (av.length != 0)
+ return " " + an + "=" + '"' + this.xmlEncode(av) + '"';
+
+ return "";
+ },
+
+ formatHTML : function(h) {
+ var s = this.settings, p = '', i = 0, li = 0, o = '', l;
+
+ h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :)
+ h = '\n' + h;
+ h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting
+ h = h.replace(this.nlBeforeRe, '\n<$1$2>');
+ h = h.replace(this.nlAfterRe, '<$1$2>\n');
+ h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n');
+ h += '\n';
+
+ //tinyMCE.debug(h);
+
+ while ((i = h.indexOf('\n', i + 1)) != -1) {
+ if ((l = h.substring(li + 1, i)).length != 0) {
+ if (this.ouRe.test(l) && p.length >= s.indent_levels)
+ p = p.substring(s.indent_levels);
+
+ o += p + l + '\n';
+
+ if (this.inRe.test(l))
+ p += this.inStr;
+ }
+
+ li = i;
+ }
+
+ //tinyMCE.debug(h);
+
+ return o;
+ },
+
+ xmlEncode : function(s) {
+ var i, l, e, o = '', c;
+
+ this._setupEntities(); // Will intialize lookup table
+
+ switch (this.settings.entity_encoding) {
+ case "raw":
+ return tinyMCE.xmlEncode(s);
+
+ case "named":
+ for (i=0, l=s.length; i 127 || c == 60 || c == 62 || c == 38 || c == 39 || c == 34)
+ o += '' + c + ";";
+ else
+ o += String.fromCharCode(c);
+ }
+
+ return o;
+ }
+
+ return s;
+ },
+
+ split : function(re, s) {
+ var c = s.split(re);
+ var i, l, o = new Array();
+
+ for (i=0, l=c.length; i gets converted to .
+ h = h.replace(/\s\/>/g, '>');
+
+ // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones
+ h = h.replace(/]*)>\u00A0?<\/p>/gi, '
'); // Keep empty paragraphs
+ h = h.replace(/]*)> <\/p>/gi, '
'); // Keep empty paragraphs
+
+ // Remove first comment
+ e.innerHTML = tinyMCE.uniqueTag + h;
+ e.firstChild.removeNode(true);
+
+ // Remove weird auto generated empty paragraphs unless it's supposed to be there
+ nl = e.getElementsByTagName("p");
+ for (i=nl.length-1; i>=0; i--) {
+ n = nl[i];
+
+ if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep)
+ n.parentNode.removeChild(n);
+ }
+ } else {
+ h = this.fixGeckoBaseHREFBug(1, e, h);
+ e.innerHTML = h;
+ this.fixGeckoBaseHREFBug(2, e, h);
+ }
+};
+
+TinyMCE_Engine.prototype.getOuterHTML = function(e) {
+ if (tinyMCE.isMSIE)
+ return e.outerHTML;
+
+ var d = e.ownerDocument.createElement("body");
+ d.appendChild(e);
+ return d.innerHTML;
+};
+
+TinyMCE_Engine.prototype.setOuterHTML = function(e, h) {
+ if (tinyMCE.isMSIE) {
+ e.outerHTML = h;
+ return;
+ }
+
+ var d = e.ownerDocument.createElement("body");
+ d.innerHTML = h;
+ e.parentNode.replaceChild(d.firstChild, e);
+};
+
+TinyMCE_Engine.prototype._getElementById = function(id, d) {
+ var e, i, j, f;
+
+ if (typeof(d) == "undefined")
+ d = document;
+
+ e = d.getElementById(id);
+ if (!e) {
+ f = d.forms;
+
+ for (i=0; i 0);
-
- if (tinyMCE.settings['custom_undo_redo']) {
- undoIndex = inst.undoIndex;
- undoLevels = inst.undoLevels.length;
- }
-
- tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
- }
- }
-
- if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
- this.selectedInstance.contentWindow.focus();
-};
-
-TinyMCE.prototype._customCleanup = function(inst, type, content) {
- // Call custom cleanup
- var customCleanup = tinyMCE.settings['cleanup_callback'];
- if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
- content = eval(customCleanup + "(type, content, inst);");
-
- // Trigger plugin cleanups
- var plugins = tinyMCE.getParam('plugins', '', true, ',');
- for (var i=0; i 0)
- className += " ";
-
- className += classNames[i];
- }
-
- return className;
-};
-
-TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) {
- if (!el)
- return;
-
- var tableElement = null;
-
- switch (el.nodeName) {
- case "TABLE":
- var oldW = el.style.width;
- var oldH = el.style.height;
- var bo = tinyMCE.getAttrib(el, "border");
-
- bo = bo == "" || bo == "0" ? true : false;
-
- tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
-
- el.style.width = oldW;
- el.style.height = oldH;
-
- for (var y=0; y 0) {
- tinyMCE.setAttrib(s[i], 'size', fSize);
- s[i].style.fontSize = '';
- }
-
- var fFace = s[i].style.fontFamily;
- if (fFace != null && fFace != "") {
- tinyMCE.setAttrib(s[i], 'face', fFace);
- s[i].style.fontFamily = '';
- }
-
- var fColor = s[i].style.color;
- if (fColor != null && fColor != "") {
- tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor));
- s[i].style.color = '';
- }
- }
-};
-
-TinyMCE.prototype.convertFontsToSpans = function(doc) {
- var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
-
- var h = doc.body.innerHTML;
- h = h.replace(/ 0 && fSize < 8) {
- if (fsClasses != null)
- tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]);
- else
- s[i].style.fontSize = sizes[fSize-1];
- }
-
- s[i].removeAttribute('size');
- }
-
- if (fFace != "") {
- s[i].style.fontFamily = fFace;
- s[i].removeAttribute('face');
- }
-
- if (fColor != "") {
- s[i].style.color = fColor;
- s[i].removeAttribute('color');
- }
- }
-};
-
-/*
-TinyMCE.prototype.applyClassesToFonts = function(doc, size) {
- var f = doc.getElementsByTagName("font");
- for (var i=0; i=0; x--)
- tinyMCE.insertAfter(cn[x], an[i]);
- }
- }
-};
-
-TinyMCE.prototype._setHTML = function(doc, html_content) {
- // Force closed anchors open
- //html_content = html_content.replace(new RegExp(' ', 'gi'), ' ');
-
- html_content = tinyMCE.cleanupHTMLCode(html_content);
-
- // Try innerHTML if it fails use pasteHTML in MSIE
- try {
- tinyMCE.setInnerHTML(doc.body, html_content);
- } catch (e) {
- if (this.isMSIE)
- doc.body.createTextRange().pasteHTML(html_content);
- }
-
- // Content duplication bug fix
- if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
- // Remove P elements in P elements
- var paras = doc.getElementsByTagName("P");
- for (var i=0; i<\/o:p>", " ");
- html = tinyMCE.regexpReplace(html, " <\/o:p>", "");
- html = tinyMCE.regexpReplace(html, "", "");
- html = tinyMCE.regexpReplace(html, "<\/p>", "");
- html = tinyMCE.regexpReplace(html, "
<\/p>\r\n
<\/p>", "");
- html = tinyMCE.regexpReplace(html, "
<\/p>", " ");
- html = tinyMCE.regexpReplace(html, "
\s*(
\s*)?", "
");
- html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "
");
- }
-
- // Always set the htmlText output
- tinyMCE.setInnerHTML(doc.body, html);
- }
-
- tinyMCE.cleanupAnchors(doc);
-
- if (tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertSpansToFonts(doc);
-};
-
-TinyMCE.prototype.getImageSrc = function(str) {
- var pos = -1;
-
- if (!str)
- return "";
-
- if ((pos = str.indexOf('this.src=')) != -1) {
- var src = str.substring(pos + 10);
-
- src = src.substring(0, src.indexOf('\''));
-
- return src;
- }
-
- return "";
-};
-
-TinyMCE.prototype._getElementById = function(element_id) {
- var elm = document.getElementById(element_id);
- if (!elm) {
- // Check for element in forms
- for (var j=0; j 0) {
- for (var x=0; x 0)
- tinyMCE.cssClasses = output;
-
- return output;
-};
-
-TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) {
- if (in_str == null)
- return in_str;
-
- if (typeof(opts) == "undefined")
- opts = 'g';
-
- var re = new RegExp(reg_exp, opts);
- return in_str.replace(re, replace_str);
-};
-
-TinyMCE.prototype.trim = function(str) {
- return str.replace(/^\s*|\s*$/g, "");
-};
-
-TinyMCE.prototype.cleanupEventStr = function(str) {
- str = "" + str;
- str = str.replace('function anonymous()\n{\n', '');
- str = str.replace('\n}', '');
- str = str.replace(/^return true;/gi, ''); // Remove event blocker
-
- return str;
-};
-
-TinyMCE.prototype.getAbsPosition = function(node) {
- var pos = new Object();
-
- pos.absLeft = pos.absTop = 0;
-
- var parentNode = node;
- while (parentNode) {
- pos.absLeft += parentNode.offsetLeft;
- pos.absTop += parentNode.offsetTop;
-
- parentNode = parentNode.offsetParent;
- }
-
- return pos;
-};
-
-TinyMCE.prototype.getControlHTML = function(control_name) {
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- var templateFunction;
-
- // Is it defined in any plugins
- for (var i=themePlugins.length; i>=0; i--) {
- templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML";
- if (eval("typeof(" + templateFunction + ")") != 'undefined') {
- var html = eval(templateFunction + "('" + control_name + "');");
- if (html != "")
- return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]);
- }
- }
-
- return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');");
-};
-
-TinyMCE.prototype._themeExecCommand = function(editor_id, element, command, user_interface, value) {
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- var templateFunction;
-
- // Is it defined in any plugins
- for (var i=themePlugins.length; i>=0; i--) {
- templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand";
- if (eval("typeof(" + templateFunction + ")") != 'undefined') {
- if (eval(templateFunction + "(editor_id, element, command, user_interface, value);"))
- return true;
- }
- }
-
- // Theme funtion
- templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand";
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- return eval(templateFunction + "(editor_id, element, command, user_interface, value);");
-
- // Pass to normal
- return false;
-};
-
-TinyMCE.prototype._getThemeFunction = function(suffix, skip_plugins) {
- if (skip_plugins)
- return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
-
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- var templateFunction;
-
- // Is it defined in any plugins
- for (var i=themePlugins.length; i>=0; i--) {
- templateFunction = 'TinyMCE_' + themePlugins[i] + suffix;
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- return templateFunction;
- }
-
- return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
-};
-
-
-TinyMCE.prototype.isFunc = function(func_name) {
- if (func_name == null || func_name == "")
- return false;
-
- return eval("typeof(" + func_name + ")") != "undefined";
-};
-
-TinyMCE.prototype.exec = function(func_name, args) {
- var str = func_name + '(';
-
- // Add all arguments
- for (var i=3; i 1 && tinyMCE.currentConfig != this.settings['index']) {
- tinyMCE.settings = this.settings;
- tinyMCE.currentConfig = this.settings['index'];
- }
-};
-
-TinyMCEControl.prototype.convertAllRelativeURLs = function() {
- var body = this.getBody();
-
+TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
// Convert all image URL:s to absolute URL
var elms = body.getElementsByTagName("img");
for (var i=0; i bookmark.index)
+ rng.addElement(nl[bookmark.index]);
+ } else {
+ rng = inst.getSel().createRange();
+ rng.moveToElementText(inst.getBody());
+ rng.collapse(true);
+ rng.moveStart('character', bookmark.start);
+ rng.moveEnd('character', bookmark.length);
+ }
+
+ rng.select();
+
+ win.scrollTo(bookmark.scrollX, bookmark.scrollY);
+ return true;
+ }
+
+ if (tinyMCE.isGecko && bookmark.rng) {
+ sel.removeAllRanges();
+ sel.addRange(bookmark.rng);
+ win.scrollTo(bookmark.scrollX, bookmark.scrollY);
+ return true;
+ }
+
+ if (tinyMCE.isGecko) {
+ // try {
+ rng = doc.createRange();
+
+ nl = doc.getElementsByTagName(bookmark.startTag);
+ if (nl.length > bookmark.start)
+ rng.setStart(nl[bookmark.start].childNodes[bookmark.startIndex], bookmark.startOffset);
+
+ nl = doc.getElementsByTagName(bookmark.endTag);
+ if (nl.length > bookmark.end)
+ rng.setEnd(nl[bookmark.end].childNodes[bookmark.endIndex], bookmark.endOffset);
+
+ sel.removeAllRanges();
+ sel.addRange(rng);
+ /* } catch {
+ // Ignore
+ }*/
+
+ win.scrollTo(bookmark.scrollX, bookmark.scrollY);
+ return true;
+ }
+
+ return false;
+ },
+
+ selectNode : function(node, collapse, select_text_node, to_start) {
+ var inst = this.instance, sel, rng, nodes;
+
+ if (!node)
+ return;
+
+ if (typeof(collapse) == "undefined")
+ collapse = true;
+
+ if (typeof(select_text_node) == "undefined")
+ select_text_node = false;
+
+ if (typeof(to_start) == "undefined")
+ to_start = true;
+
+ if (tinyMCE.isMSIE) {
+ rng = inst.getBody().createTextRange();
+
+ try {
+ rng.moveToElementText(node);
+
+ if (collapse)
+ rng.collapse(to_start);
+
+ rng.select();
+ } catch (e) {
+ // Throws illigal agrument in MSIE some times
+ }
+ } else {
+ sel = this.getSel();
+
+ if (!sel)
+ return;
+
+ if (tinyMCE.isSafari) {
+ sel.setBaseAndExtent(node, 0, node, node.innerText.length);
+
+ if (collapse) {
+ if (to_start)
+ sel.collapseToStart();
+ else
+ sel.collapseToEnd();
+ }
+
+ this.scrollToNode(node);
+
+ return;
+ }
+
+ rng = inst.getDoc().createRange();
+
+ if (select_text_node) {
+ // Find first textnode in tree
+ nodes = tinyMCE.getNodeTree(node, new Array(), 3);
+ if (nodes.length > 0)
+ rng.selectNodeContents(nodes[0]);
+ else
+ rng.selectNodeContents(node);
+ } else
+ rng.selectNode(node);
if (collapse) {
- if (to_start)
- sel.realSelection.collapseToStart();
- else
- sel.realSelection.collapseToEnd();
+ // Special treatment of textnode collapse
+ if (!to_start && node.nodeType == 3) {
+ rng.setStart(node, node.nodeValue.length);
+ rng.setEnd(node, node.nodeValue.length);
+ } else
+ rng.collapse(to_start);
}
- this.scrollToNode(node);
-
- return;
+ sel.removeAllRanges();
+ sel.addRange(rng);
}
- var rng = this.getDoc().createRange();
+ this.scrollToNode(node);
- if (select_text_node) {
- // Find first textnode in tree
- var nodes = tinyMCE.getNodeTree(node, new Array(), 3);
- if (nodes.length > 0)
- rng.selectNodeContents(nodes[0]);
- else
- rng.selectNodeContents(node);
- } else
- rng.selectNode(node);
+ // Set selected element
+ tinyMCE.selectedElement = null;
+ if (node.nodeType == 1)
+ tinyMCE.selectedElement = node;
+ },
- if (collapse) {
- // Special treatment of textnode collapse
- if (!to_start && node.nodeType == 3) {
- rng.setStart(node, node.nodeValue.length);
- rng.setEnd(node, node.nodeValue.length);
- } else
- rng.collapse(to_start);
- }
+ scrollToNode : function(node) {
+ var inst = this.instance;
+ var pos, doc, scrollX, scrollY, height;
- sel.removeAllRanges();
- sel.addRange(rng);
- }
+ // Scroll to node position
+ pos = tinyMCE.getAbsPosition(node);
+ doc = inst.getDoc();
+ scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
+ scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
+ height = tinyMCE.isMSIE ? document.getElementById(inst.editorId).style.pixelHeight : inst.targetElement.clientHeight;
- this.scrollToNode(node);
+ // Only scroll if out of visible area
+ if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
+ inst.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
+ },
- // Set selected element
- tinyMCE.selectedElement = null;
- if (node.nodeType == 1)
- tinyMCE.selectedElement = node;
-};
+ getSel : function() {
+ var inst = this.instance;
-TinyMCEControl.prototype.scrollToNode = function(node) {
- // Scroll to node position
- var pos = tinyMCE.getAbsPosition(node);
- var doc = this.getDoc();
- var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
- var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
- var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : this.targetElement.clientHeight;
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return inst.getDoc().selection;
- // Only scroll if out of visible area
- if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
- this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
-};
+ return inst.contentWindow.getSelection();
+ },
-TinyMCEControl.prototype.getBody = function() {
- return this.getDoc().body;
-};
+ getRng : function() {
+ var inst = this.instance;
+ var sel = this.getSel();
-TinyMCEControl.prototype.getDoc = function() {
- return this.contentWindow.document;
-};
+ if (sel == null)
+ return null;
-TinyMCEControl.prototype.getWin = function() {
- return this.contentWindow;
-};
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return sel.createRange();
-TinyMCEControl.prototype.getSel = function() {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return this.getDoc().selection;
+ if (tinyMCE.isSafari && !sel.getRangeAt)
+ return '' + window.getSelection();
- var sel = this.contentWindow.getSelection();
+ return sel.getRangeAt(0);
+ },
- // Fake getRangeAt
- if (tinyMCE.isSafari && !sel.getRangeAt) {
- var newSel = new Object();
- var doc = this.getDoc();
+ getFocusElement : function() {
+ var inst = this.instance;
- function getRangeAt(idx) {
- var rng = new Object();
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ var doc = inst.getDoc();
+ var rng = doc.selection.createRange();
- rng.startContainer = this.focusNode;
- rng.endContainer = this.anchorNode;
- rng.commonAncestorContainer = this.focusNode;
- rng.createContextualFragment = function (html) {
- // Seems to be a tag
- if (html.charAt(0) == '<') {
- var elm = doc.createElement("div");
+ // if (rng.collapse)
+ // rng.collapse(true);
- elm.innerHTML = html;
-
- return elm.firstChild;
- }
-
- return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!");
- };
-
- rng.deleteContents = function () {
- doc.execCommand("Delete", false, "");
- };
-
- return rng;
- }
-
- // Patch selection
-
- newSel.focusNode = sel.baseNode;
- newSel.focusOffset = sel.baseOffset;
- newSel.anchorNode = sel.extentNode;
- newSel.anchorOffset = sel.extentOffset;
- newSel.getRangeAt = getRangeAt;
- newSel.text = "" + sel;
- newSel.realSelection = sel;
-
- newSel.toString = function () {return this.text;};
-
- return newSel;
- }
-
- return sel;
-};
-
-TinyMCEControl.prototype.getRng = function() {
- var sel = this.getSel();
- if (sel == null)
- return null;
-
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return sel.createRange();
-
- if (tinyMCE.isSafari) {
- var rng = this.getDoc().createRange();
- var sel = this.getSel().realSelection;
-
- rng.setStart(sel.baseNode, sel.baseOffset);
- rng.setEnd(sel.extentNode, sel.extentOffset);
-
- return rng;
- }
-
- return this.getSel().getRangeAt(0);
-};
-
-TinyMCEControl.prototype._insertPara = function(e) {
- function isEmpty(para) {
- function isEmptyHTML(html) {
- return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
- }
-
- // Check for images
- if (para.getElementsByTagName("img").length > 0)
- return false;
-
- // Check for tables
- if (para.getElementsByTagName("table").length > 0)
- return false;
-
- // Check for HRs
- if (para.getElementsByTagName("hr").length > 0)
- return false;
-
- // Check all textnodes
- var nodes = tinyMCE.getNodeTree(para, new Array(), 3);
- for (var i=0; i " + blockName + "><" + blockName + "> " + blockName + ">";
- paraAfter = body.childNodes[1];
+ if (inst.isHidden())
+ return inst.getBody();
+
+ var sel = this.getSel();
+ var rng = this.getRng();
+
+ if (!sel || !rng)
+ return null;
+
+ var elm = rng.commonAncestorContainer;
+ //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
+
+ // Handle selection a image or other control like element such as anchors
+ if (!rng.collapsed) {
+ // Is selection small
+ if (rng.startContainer == rng.endContainer) {
+ if (rng.startOffset - rng.endOffset < 2) {
+ if (rng.startContainer.hasChildNodes())
+ elm = rng.startContainer.childNodes[rng.startOffset];
+ }
+ }
+ }
+
+ // Get the element parent of the node
+ elm = tinyMCE.getParentElement(elm);
+
+ //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
+ // elm = tinyMCE.selectedElement;
}
- this.selectNode(paraAfter, true, true);
-
- return true;
+ return elm;
}
-
- // Place first part within new paragraph
- if (startChop.nodeName == blockName)
- rngBefore.setStart(startChop, 0);
- else
- rngBefore.setStartBefore(startChop);
-
- rngBefore.setEnd(startNode, startOffset);
- paraBefore.appendChild(rngBefore.cloneContents());
-
- // Place secound part within new paragraph
- rngAfter.setEndAfter(endChop);
- rngAfter.setStart(endNode, endOffset);
- var contents = rngAfter.cloneContents();
-
- if (contents.firstChild && contents.firstChild.nodeName == blockName) {
-/* var nodes = contents.firstChild.childNodes;
- for (var i=0; i customUndoLevels) {
+ for (var i=0; i 0) {
+ this.undoIndex--;
+ tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
+ inst.repaint();
+ if (inst.settings.custom_undo_redo_restore_selection)
+ inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
+ }
+
+ // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
+ },
+
+ redo : function() {
+ var inst = this.instance;
+
+ tinyMCE.execCommand("mceEndTyping");
+
+ if (this.undoIndex < (this.undoLevels.length-1)) {
+ this.undoIndex++;
+ tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
+ inst.repaint();
+// if (this.undoIndex > 0)
+// inst.selection.moveToBookmark(this.undoLevels[this.undoIndex-1].bookmark);
+ if (inst.settings.custom_undo_redo_restore_selection)
+ inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
+ // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
+ }
+
+ tinyMCE.triggerNodeChange();
+ }
+};
+
+/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
+
+var TinyMCE_ForceParagraphs = {
+ _insertPara : function(inst, e) {
+ function isEmpty(para) {
+ function isEmptyHTML(html) {
+ return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
+ }
+
+ // Check for images
+ if (para.getElementsByTagName("img").length > 0)
+ return false;
+
+ // Check for tables
+ if (para.getElementsByTagName("table").length > 0)
+ return false;
+
+ // Check for HRs
+ if (para.getElementsByTagName("hr").length > 0)
+ return false;
+
+ // Check all textnodes
+ var nodes = tinyMCE.getNodeTree(para, new Array(), 3);
+ for (var i=0; i 0)
- rng.pasteHTML('' + rng.htmlText + "
");
-
- tinyMCE.triggerNodeChange();
- return;
- }
- }
- }
-
- switch (command) {
- case "mceRepaint":
- this.repaint();
- return true;
-
- case "mceStoreSelection":
- this.selectionBookmark = this.getBookmark();
- return true;
-
- case "mceRestoreSelection":
- this.moveToBookmark(this.selectionBookmark);
- return true;
-
- case "InsertUnorderedList":
- case "InsertOrderedList":
- var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
-
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<" + tag + "> <" + tag + ">");
- else
- this.getDoc().execCommand(command, user_interface, value);
-
- tinyMCE.triggerNodeChange();
- break;
-
- case "Strikethrough":
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "" + this.getSelectedHTML() + " ");
- else
- this.getDoc().execCommand(command, user_interface, value);
-
- tinyMCE.triggerNodeChange();
- break;
-
- case "mceSelectNode":
- this.selectNode(value);
- tinyMCE.triggerNodeChange();
- tinyMCE.selectedNode = value;
- break;
-
- case "FormatBlock":
- if (value == null || value == "") {
- var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");
-
- if (elm)
- this.execCommand("mceRemoveNode", false, elm);
- } else
- this.getDoc().execCommand("FormatBlock", false, value);
-
- tinyMCE.triggerNodeChange();
-
- break;
-
- case "mceRemoveNode":
- if (!value)
- value = tinyMCE.getParentElement(this.getFocusElement());
-
- if (tinyMCE.isMSIE) {
- value.outerHTML = value.innerHTML;
- } else {
- var rng = value.ownerDocument.createRange();
- rng.setStartBefore(value);
- rng.setEndAfter(value);
+ // Delete old contents
rng.deleteContents();
- rng.insertNode(rng.createContextualFragment(value.innerHTML));
+ rngAfter.deleteContents();
+ rngBefore.deleteContents();
+
+ // Insert new paragraphs
+ paraAfter.normalize();
+ rngBefore.insertNode(paraAfter);
+ paraBefore.normalize();
+ rngBefore.insertNode(paraBefore);
+
+ // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
+ } else {
+ body.innerHTML = "<" + blockName + "> " + blockName + "><" + blockName + "> " + blockName + ">";
+ paraAfter = body.childNodes[1];
}
- tinyMCE.triggerNodeChange();
+ inst.selection.selectNode(paraAfter, true, true);
- break;
+ return true;
+ }
- case "mceSelectNodeDepth":
- var parentNode = this.getFocusElement();
- for (var i=0; parentNode; i++) {
- if (parentNode.nodeName.toLowerCase() == "body")
+ // Place first part within new paragraph
+ if (startChop.nodeName == blockName)
+ rngBefore.setStart(startChop, 0);
+ else
+ rngBefore.setStartBefore(startChop);
+
+ rngBefore.setEnd(startNode, startOffset);
+ paraBefore.appendChild(rngBefore.cloneContents());
+
+ // Place secound part within new paragraph
+ rngAfter.setEndAfter(endChop);
+ rngAfter.setStart(endNode, endOffset);
+ var contents = rngAfter.cloneContents();
+
+ if (contents.firstChild && contents.firstChild.nodeName == blockName) {
+ /* var nodes = contents.firstChild.childNodes;
+ for (var i=0; i
';
+
+ h += '';
+
+ for (i=0; i';
break;
- if (parentNode.nodeName.toLowerCase() == "#text") {
- i--;
- parentNode = parentNode.parentNode;
- continue;
- }
+ case 'title':
+ h += ' ' + t + ' ';
+ break;
- if (i == value) {
- this.selectNode(parentNode, false);
- tinyMCE.triggerNodeChange();
- tinyMCE.selectedNode = parentNode;
- return;
- }
+ case 'disabled':
+ h += '' + t + ' ';
+ break;
- parentNode = parentNode.parentNode;
+ default:
+ h += '' + t + ' ';
}
- break;
+ h += ' ';
+ }
- case "SetStyleInfo":
- var rng = this.getRng();
- var sel = this.getSel();
- var scmd = value['command'];
- var sname = value['name'];
- var svalue = value['value'] == null ? '' : value['value'];
- //var svalue = value['value'] == null ? '' : value['value'];
- var wrapper = value['wrapper'] ? value['wrapper'] : "span";
- var parentElm = null;
- var invalidRe = new RegExp("^BODY|HTML$", "g");
- var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;
+ h += '
';
- // Whole element selected check
- if (tinyMCE.isMSIE) {
- // Control range
- if (rng.item)
- parentElm = rng.item(0);
- else {
- var pelm = rng.parentElement();
- var prng = doc.selection.createRange();
- prng.moveToElementText(pelm);
+ e.innerHTML = h;
- if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
- if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
- parentElm = pelm;
- }
- }
- } else {
- var felm = this.getFocusElement();
- if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode))
- parentElm = felm;
- }
+ this.needsUpdate = false;
+ this.updateBlocker();
+ },
- // Whole element selected
- if (parentElm && !invalidRe.test(parentElm.nodeName)) {
- if (scmd == "setstyle")
- tinyMCE.setStyleAttrib(parentElm, sname, svalue);
-
- if (scmd == "setattrib")
- tinyMCE.setAttrib(parentElm, sname, svalue);
-
- if (scmd == "removeformat") {
- parentElm.style.cssText = '';
- tinyMCE.setAttrib(parentElm, 'class', '');
- }
-
- // Remove style/attribs from all children
- var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);
- for (var z=0; z=0; i--) {
- var elm = nodes[i];
- var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
-
- elm.removeAttribute("mce_new");
-
- // Is only child a element
- if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
- //tinyMCE.debug("merge1" + isNew);
- this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
- continue;
- }
-
- // Is I the only child
- if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
- //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
- if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
- this._mergeElements(scmd, elm.parentNode, elm, false);
- }
- }
-
- // Remove empty wrappers
- var nodes = doc.getElementsByTagName(wrapper);
- for (var i=nodes.length-1; i>=0; i--) {
- var elm = nodes[i];
- var isEmpty = true;
-
- // Check if it has any attribs
- var tmp = doc.createElement("body");
- tmp.appendChild(elm.cloneNode(false));
-
- // Is empty span, remove it
- tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
- //tinyMCE.debug(tmp.innerHTML);
- if (new RegExp('', 'gi').test(tmp.innerHTML)) {
- for (var x=0; x 0) {
- value = tinyMCE.replaceVar(value, "selection", selectedText);
- tinyMCE.execCommand('mceInsertContent', false, value);
- }
-
- tinyMCE.triggerNodeChange();
- break;
-
- case "mceSetAttribute":
- if (typeof(value) == 'object') {
- var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];
- var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
-
- if (targetNode) {
- targetNode.setAttribute(value['name'], value['value']);
- tinyMCE.triggerNodeChange();
- }
- }
- break;
-
- case "mceSetCSSClass":
- this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value});
- break;
-
- case "mceInsertRawHTML":
- var key = 'tiny_mce_marker';
-
- this.execCommand('mceBeginUndoLevel');
-
- // Insert marker key
- this.execCommand('mceInsertContent', false, key);
-
- // Store away scroll pos
- var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
- var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
-
- // Find marker and replace with RAW HTML
- var html = this.getBody().innerHTML;
- if ((pos = html.indexOf(key)) != -1)
- tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
-
- // Restore scoll pos
- this.contentWindow.scrollTo(scrollX, scrollY);
-
- this.execCommand('mceEndUndoLevel');
-
- break;
-
- case "mceInsertContent":
- var insertHTMLFailed = false;
- this.getWin().focus();
-/* WP
- if (tinyMCE.isGecko || tinyMCE.isOpera) {
- try {
- // Is plain text or HTML
- if (value.indexOf('<') == -1) {
- var r = this.getRng();
- var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value));
- var s = this.getSel();
- var r2 = r.cloneRange();
-
- // Insert text at cursor position
- s.removeAllRanges();
- r.deleteContents();
- r.insertNode(n);
-
- // Move the cursor to the end of text
- r2.selectNode(n);
- r2.collapse(false);
- s.removeAllRanges();
- s.addRange(r2);
- } else {
- value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value);
- this.getDoc().execCommand('inserthtml', false, value);
- tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
- }
- } catch (ex) {
- insertHTMLFailed = true;
- }
-
- if (!insertHTMLFailed) {
- tinyMCE.triggerNodeChange();
- return;
- }
- }
-*/
- // Ugly hack in Opera due to non working "inserthtml"
- if (tinyMCE.isOpera && insertHTMLFailed) {
- this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);
- var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);
- ar[0].outerHTML = value;
- return;
- }
-
- if (!tinyMCE.isMSIE) {
- var isHTML = value.indexOf('<') != -1;
- var sel = this.getSel();
- var rng = this.getRng();
-
- if (isHTML) {
- if (tinyMCE.isSafari) {
- var tmpRng = this.getDoc().createRange();
-
- tmpRng.setStart(this.getBody(), 0);
- tmpRng.setEnd(this.getBody(), 0);
-
- value = tmpRng.createContextualFragment(value);
- } else
- value = rng.createContextualFragment(value);
- } else {
- // Setup text node
- var el = document.createElement("div");
- el.innerHTML = value;
- value = el.firstChild.nodeValue;
- value = doc.createTextNode(value);
- }
-
- // Insert plain text in Safari
- if (tinyMCE.isSafari && !isHTML) {
- this.execCommand('InsertText', false, value.nodeValue);
- tinyMCE.triggerNodeChange();
- return true;
- } else if (tinyMCE.isSafari && isHTML) {
- rng.deleteContents();
- rng.insertNode(value);
- tinyMCE.triggerNodeChange();
- return true;
- }
-
- rng.deleteContents();
-
- // If target node is text do special treatment, (Mozilla 1.3 fix)
- if (rng.startContainer.nodeType == 3) {
- var node = rng.startContainer.splitText(rng.startOffset);
- node.parentNode.insertBefore(value, node);
- } else
- rng.insertNode(value);
-
- if (!isHTML) {
- // Removes weird selection trails
- sel.selectAllChildren(doc.body);
- sel.removeAllRanges();
-
- // Move cursor to end of content
- var rng = doc.createRange();
-
- rng.selectNode(value);
- rng.collapse(false);
-
- sel.addRange(rng);
- } else
- rng.collapse(false);
- } else {
- var rng = doc.selection.createRange();
- var c = value.indexOf('