📄 tiny_mce_src.js
字号:
if (tinyMCE.isRealIE && window.event.type == "readystatechange" && document.readyState != "complete") return true; if (tinyMCE.isLoaded) return true; tinyMCE.isLoaded = true; // IE produces JS error if TinyMCE is placed in a frame // It seems to have something to do with the selection not beeing // correctly initialized in IE so this hack solves the problem if (tinyMCE.isRealIE && document.body && window.location.href != window.top.location.href) { r = document.body.createTextRange(); r.collapse(true); r.select(); } tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad'); for (c=0; c<tinyMCE.configs.length; c++) { tinyMCE.settings = tinyMCE.configs[c]; selector = tinyMCE.getParam("editor_selector"); deselector = tinyMCE.getParam("editor_deselector"); elementRefAr = []; // Add submit triggers if (document.forms && tinyMCE.settings.add_form_submit_trigger && !tinyMCE.submitTriggers) { for (i=0; i<document.forms.length; i++) { form = document.forms[i]; tinyMCE.addEvent(form, "submit", TinyMCE_Engine.prototype.handleEvent); tinyMCE.addEvent(form, "reset", TinyMCE_Engine.prototype.handleEvent); tinyMCE.submitTriggers = true; // Do it only once // Patch the form.submit function if (tinyMCE.settings.submit_patch) { try { form.mceOldSubmit = form.submit; form.submit = TinyMCE_Engine.prototype.submitPatch; } catch (e) { // Do nothing } } } } // Add editor instances based on mode mode = tinyMCE.settings.mode; switch (mode) { case "exact": elements = tinyMCE.getParam('elements', '', true, ','); for (i=0; i<elements.length; i++) { element = tinyMCE._getElementById(elements[i]); trigger = element ? element.getAttribute(tinyMCE.settings.textarea_trigger) : ""; if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class"))) continue; if (trigger == "false") continue; if ((tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) && element) { elementRefAr[elementRefAr.length] = element; continue; } if (element) tinyMCE.addMCEControl(element, elements[i]); } break; case "specific_textareas": case "textareas": elements = document.getElementsByTagName("textarea"); for (i=0; i<elements.length; i++) { elm = elements.item(i); trigger = elm.getAttribute(tinyMCE.settings.textarea_trigger); if (selector !== '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class"))) continue; if (selector !== '') trigger = selector !== '' ? "true" : ""; if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class"))) continue; if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false")) elementRefAr[elementRefAr.length] = elm; } break; } for (i=0; i<elementRefAr.length; i++) { element = elementRefAr[i]; elementId = element.name ? element.name : element.id; if (tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) { // Focus breaks in Mozilla if (tinyMCE.isGecko) { settings = tinyMCE.settings; tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); if (element.nodeName != "TEXTAREA" && element.nodeName != "INPUT") tinyMCE.addEvent(element, "click", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); // tinyMCE.addEvent(element, "mouseover", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); } else { settings = tinyMCE.settings; tinyMCE.addEvent(element, "focus", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); tinyMCE.addEvent(element, "click", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); // tinyMCE.addEvent(element, "mouseenter", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); } } else tinyMCE.addMCEControl(element, elementId); } // Handle auto focus if (tinyMCE.settings.auto_focus) { window.setTimeout(function () { var inst = tinyMCE.getInstanceById(tinyMCE.settings.auto_focus); inst.selection.selectNode(inst.getBody(), true, true); inst.contentWindow.focus(); }, 100); } tinyMCE.dispatchCallback(null, 'oninit', 'onInit'); } }, isInstance : function(o) { return o != null && typeof(o) == "object" && o.isTinyMCE_Control; }, getParam : function(name, default_value, strip_whitespace, split_chr) { var i, outArray, value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; // Fix bool values if (value == "true" || value == "false") return (value == "true"); if (strip_whitespace) value = tinyMCE.regexpReplace(value, "[ \t\r\n]", ""); if (typeof(split_chr) != "undefined" && split_chr != null) { value = value.split(split_chr); outArray = []; for (i=0; i<value.length; i++) { if (value[i] && value[i] !== '') outArray[outArray.length] = value[i]; } value = outArray; } return value; }, getLang : function(name, default_value, parse_entities, va) { var v = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name], n; if (parse_entities) v = tinyMCE.entityDecode(v); if (va) { for (n in va) v = this.replaceVar(v, n, va[n]); } return v; }, entityDecode : function(s) { var e = document.createElement("div"); e.innerHTML = s; return !e.firstChild ? s : e.firstChild.nodeValue; }, addToLang : function(prefix, ar) { var k; for (k in ar) { if (typeof(ar[k]) == 'function') continue; tinyMCELang[(k.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix !== '' ? (prefix + "_") : '') + k] = ar[k]; } this.loadNextScript(); }, triggerNodeChange : function(focus, setup_content) { var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st; if (tinyMCE.selectedInstance) { inst = tinyMCE.selectedInstance; elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();/* if (elm == inst.lastTriggerEl) return; inst.lastTriggerEl = elm;*/ editorId = inst.editorId; st = inst.selection.getSelectedText(); if (tinyMCE.settings.auto_resize) inst.resizeToContent(); if (setup_content && tinyMCE.isGecko && inst.isHidden()) elm = inst.getBody(); inst.switchSettings(); if (tinyMCE.selectedElement) anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 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, customCleanup; // Call custom cleanup customCleanup = tinyMCE.settings.cleanup_callback; if (customCleanup != '') content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst); // Trigger theme cleanup po = tinyMCE.themes[tinyMCE.settings.theme]; if (po && po.cleanup) content = po.cleanup(type, content, inst); // Trigger plugin cleanups pl = inst.plugins; for (i=0; i<pl.length; i++) { po = tinyMCE.plugins[pl[i]]; if (po && po.cleanup) content = po.cleanup(type, content, inst); } return content; }, setContent : function(h) { if (tinyMCE.selectedInstance) { tinyMCE.selectedInstance.execCommand('mceSetContent', false, h); tinyMCE.selectedInstance.repaint(); } }, importThemeLanguagePack : function(name) { if (typeof(name) == "undefined") name = tinyMCE.settings.theme; tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings.language + '.js'); }, importPluginLanguagePack : function(name) { var b = tinyMCE.baseURL + '/plugins/' + name; if (this.plugins[name]) b = this.plugins[name].baseURL; tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings.language + '.js'); }, applyTemplate : function(h, ag) { return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) { if (s.indexOf('lang_') == 0 && tinyMCELang[s]) return tinyMCELang[s]; if (ag && ag[s]) return ag[s]; if (tinyMCE.settings[s]) return tinyMCE.settings[s]; if (m == 'themeurl') return tinyMCE.themeURL; return m; }); }, 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, name, win, modal, features; args = !args ? {} : args; 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.isIE) 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 (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); 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.isRealIE) && resizable != 'yes' && tinyMCE.settings.dialog_type == "modal") { height += 10; features = "resizable:" + resizable + ";scroll:" + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;"; window.showModalDialog(url, window, features); } else { modal = (resizable == "yes") ? "no" : "yes"; if (tinyMCE.isGecko && tinyMCE.isMac) modal = "no"; if (template.close_previous != "no") try {tinyMCE.lastWindow.close();} catch (ex) {} 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; try { win.resizeTo(width, height); } catch(e) { // Ignore
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -