📄 tiny_mce_src.js
字号:
u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u; this.plugins[n] = {baseURL : u}; this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js"); }, hasTheme : function(n) { return typeof(this.themes[n]) != "undefined" && this.themes[n] != null; }, addTheme : function(n, t) { this.themes[n] = t; this.loadNextScript(); }, addMenu : function(n, m) { this.menus[n] = m; }, hasMenu : function(n) { return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; }, loadScript : function(url) { var i; for (i=0; i<this.loadedFiles.length; i++) { if (this.loadedFiles[i] == url) return; } if (tinyMCE.settings.strict_loading_mode) this.pendingFiles[this.pendingFiles.length] = url; else document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>'); this.loadedFiles[this.loadedFiles.length] = url; }, loadNextScript : function() { var d = document, se; if (!tinyMCE.settings.strict_loading_mode) return; if (this.loadingIndex < this.pendingFiles.length) { se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script'); se.setAttribute('language', 'javascript'); se.setAttribute('type', 'text/javascript'); se.setAttribute('src', this.pendingFiles[this.loadingIndex++]); d.getElementsByTagName("head")[0].appendChild(se); } else this.loadingIndex = -1; // Done with loading }, loadCSS : function(url) { var ar = url.replace(/\s+/, '').split(','); var lflen = 0, csslen = 0, skip = false; var x = 0, i = 0, nl, le; for (x = 0,csslen = ar.length; x<csslen; x++) { if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) { /* Make sure it doesn't exist. */ for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) { if (this.loadedFiles[i] == ar[x]) { skip = true; break; } } if (!skip) { if (tinyMCE.settings.strict_loading_mode) { nl = document.getElementsByTagName("head"); le = document.createElement('link'); le.setAttribute('href', ar[x]); le.setAttribute('rel', 'stylesheet'); le.setAttribute('type', 'text/css'); nl[0].appendChild(le); } else document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />'); 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<csslen; x++) { css_file = css_ary[x]; if (css_file != null && css_file != 'null' && css_file.length > 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.isIE ? 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) { var formElement, n, inst, doc; // Find MCE instance linked to given form element and copy it's value formElement = document.getElementById(form_element_name); for (n in tinyMCE.instances) { inst = tinyMCE.instances[n]; if (!tinyMCE.isInstance(inst)) continue; inst.switchSettings(); if (inst.formElement == formElement) { doc = inst.getDoc(); tinyMCE._setHTML(doc, inst.formElement.value); if (!tinyMCE.isIE) 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); }, removeInstance : function(ti) { var t = [], n, i; // Remove from instances for (n in tinyMCE.instances) { i = tinyMCE.instances[n]; if (tinyMCE.isInstance(i) && ti != i) t[n] = i; } tinyMCE.instances = t; // Remove from global undo/redo n = []; t = tinyMCE.undoLevels; for (i=0; i<t.length; i++) { if (t[i] != ti) n.push(t[i]); } tinyMCE.undoLevels = n; tinyMCE.undoIndex = n.length; // Dispatch remove instance call tinyMCE.dispatchCallback(ti, 'remove_instance_callback', 'removeInstance', ti); return ti; }, removeMCEControl : function(editor_id) { var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn, n; if (inst) { inst.switchSettings(); editor_id = inst.editorId; h = tinyMCE.getContent(editor_id); this.removeInstance(inst); tinyMCE.selectedElement = null; tinyMCE.selectedInstance = null; tinyMCE.selectedElement = null; tinyMCE.selectedInstance = null; // Try finding an instance for (n in tinyMCE.instances) { if (!tinyMCE.isInstance(tinyMCE.instances[n])) continue; tinyMCE.selectedInstance = tinyMCE.instances[n]; break; } // Remove element re = document.getElementById(editor_id + "_parent"); ot = inst.oldTargetElement; tn = ot.nodeName.toLowerCase(); if (tn == "textarea" || tn == "input") { re.parentNode.removeChild(re); ot.style.display = "inline"; ot.value = h; } else { ot.innerHTML = h; ot.style.display = 'block'; re.parentNode.insertBefore(ot, re); re.parentNode.removeChild(re); } } }, 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<formObj.elements.length; i++) { if (inst.formTargetElementId == formObj.elements[i].name) inst.getBody().innerHTML = inst.startContent; } } }, execInstanceCommand : function(editor_id, command, user_interface, value, focus) { var inst = tinyMCE.getInstanceById(editor_id), r; if (inst) { r = inst.selection.getRng(); if (typeof(focus) == "undefined") focus = true; // IE bug lost focus on images in absolute divs Bug #1534575 if (focus && (!r || !r.item)) inst.contentWindow.focus(); // Reset design mode if lost inst.autoResetDesignMode(); this.selectedElement = inst.getFocusElement(); inst.select(); tinyMCE.execCommand(command, user_interface, value); // Cancel event so it doesn't call onbeforeonunlaod if (tinyMCE.isIE && window.event != null) tinyMCE.cancelEvent(window.event); } }, execCommand : function(command, user_interface, value) { var inst = tinyMCE.selectedInstance, n, pe, te; // Default input user_interface = user_interface ? user_interface : false; value = value ? value : null; if (inst) inst.switchSettings(); switch (command) { case "Undo": if (this.getParam('custom_undo_redo_global')) { if (this.undoIndex > 0) { tinyMCE.nextUndoRedoAction = 'Undo'; inst = this.undoLevels[--this.undoIndex]; inst.select(); if (!tinyMCE.nextUndoRedoInstanceId) inst.execCommand('Undo'); } } else inst.execCommand('Undo'); return true; case "Redo": if (this.getParam('custom_undo_redo_global')) { if (this.undoIndex <= this.undoLevels.length - 1) { tinyMCE.nextUndoRedoAction = 'Redo'; inst = this.undoLevels[this.undoIndex++]; inst.select(); if (!tinyMCE.nextUndoRedoInstanceId) inst.execCommand('Redo'); } } else inst.execCommand('Redo'); return true; case 'mceFocus': inst = tinyMCE.getInstanceById(value); if (inst) inst.getWin().focus(); return; case "mceAddControl": case "mceAddEditor": tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); return; case "mceAddFrameControl": tinyMCE.addMCEControl(tinyMCE._getElementById(value.element, value.document), value.element, value.document); return; case "mceRemoveControl": case "mceRemoveEditor": tinyMCE.removeMCEControl(value); return; case "mceToggleEditor": inst = tinyMCE.getInstanceById(value); if (inst) { pe = document.getElementById(inst.editorId + '_parent'); te = inst.oldTargetElement; if (typeof(inst.enabled) == 'undefined') inst.enabled = true; inst.enabled = !inst.enabled; if (!inst.enabled) { pe.style.display = 'none'; if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') te.value = inst.getHTML(); else te.innerHTML = inst.getHTML(); te.style.display = inst.oldTargetDisplay; tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); } else { pe.style.display = 'block'; te.style.display = 'none'; if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') inst.setHTML(te.value); else inst.setHTML(te.innerHTML);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -