📄 tiny_mce_src.js
字号:
return v;
},
entityDecode : function(s) {
var e = document.createElement("div");
e.innerHTML = s;
return e.innerHTML;
},
addToLang : function(prefix, ar) {
for (var key in ar) {
if (typeof(ar[key]) == 'function')
continue;
tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key];
}
this.loadNextScript();
// for (var key in ar)
// tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|";
},
triggerNodeChange : function(focus, setup_content) {
if (tinyMCE.selectedInstance) {
var inst = tinyMCE.selectedInstance;
var editorId = inst.editorId;
var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
var undoIndex = -1;
var undoLevels = -1;
var anySelection = false;
var selectedText = inst.selection.getSelectedText();
if (setup_content && tinyMCE.isGecko && inst.isHidden())
elm = inst.getBody();
inst.switchSettings();
if (tinyMCE.settings["auto_resize"]) {
var doc = inst.getDoc();
inst.iframeElement.style.width = doc.body.offsetWidth + "px";
inst.iframeElement.style.height = doc.body.offsetHeight + "px";
}
if (tinyMCE.selectedElement)
anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.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;
// 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<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, valid_languages) {
var lang = "en", b = tinyMCE.baseURL + '/plugins/' + name;
valid_languages = valid_languages.split(',');
for (var i=0; i<valid_languages.length; i++) {
if (tinyMCE.settings['language'] == valid_languages[i])
lang = tinyMCE.settings['language'];
}
if (this.plugins[name])
b = this.plugins[name].baseURL;
tinyMCE.loadScript(b + '/langs/' + lang + '.js');
},
applyTemplate : function(h, as) {
var i, s, ar = h.match(new RegExp('\\{\\$[a-z0-9_]+\\}', 'gi'));
if (ar && ar.length > 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<ar.length; i++) {
if (ar[i] == aidClass)
ar[i] = "";
if (ar[i] != "")
classNames[classNames.length] = ar[i];
}
if (state)
classNames[classNames.length] = aidClass;
// Glue
var className = "";
for (var i=0; i<classNames.length; i++) {
if (i > 0)
className += " ";
className += classNames[i];
}
return className;
},
handleVisualAid : function(el, deep, state, inst, skip_dispatch) {
if (!el)
return;
if (!skip_dispatch)
tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst);
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<el.rows.length; y++) {
for (var x=0; x<el.rows[y].cells.length; x++) {
var cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);
tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn);
}
}
break;
case "A":
var anchorName = tinyMCE.getAttrib(el, "name");
if (anchorName != '' && state) {
el.title = anchorName;
el.className = 'mceItemAnchor';
} else if (anchorName != '' && !state)
el.className = '';
break;
}
if (deep && el.hasChildNodes()) {
for (var i=0; i<el.childNodes.length; i++)
tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true);
}
},
/*
applyClassesToFonts : function(doc, size) {
var f = doc.getElementsByTagName("font");
for (var i=0; i<f.length; i++) {
var s = tinyMCE.getAttrib(f[i], "size");
if (s != "")
tinyMCE.setAttrib(f[i], 'class', "mceItemFont" + s);
}
if (typeof(size) != "undefined") {
var css = "";
for (var x=0; x<doc.styleSheets.length; x++) {
for (var i=0; i<doc.styleSheets[x].rules.length; i++) {
if (doc.styleSheets[x].rules[i].selectorText == '#mceSpanFonts .mceItemFont' + size) {
css = doc.styleSheets[x].rules[i].style.cssText;
break;
}
}
if (css != "")
break;
}
if (doc.styleSheets[0].rules[0].selectorText == "FONT")
doc.styleSheets[0].removeRule(0);
doc.styleSheets[0].addRule("FONT", css, 0);
}
},
*/
fixGeckoBaseHREFBug : function(m, e, h) {
var nl, i, a, n, xsrc, xhref, el;
if (tinyMCE.isGecko) {
if (m == 1) {
h = h.replace(/\ssrc=/gi, " mce_tsrc=");
h = h.replace(/\shref=/gi, " mce_thref=");
return h;
} else {
el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
for (a=0; a<el.length; a++) {
n = e.getElementsByTagName(el[a]);
for (i=0; i<n.length; i++) {
xsrc = tinyMCE.getAttrib(n[i], "mce_tsrc");
xhref = tinyMCE.getAttrib(n[i], "mce_thref");
if (xsrc != "") {
try {
n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
} catch (e) {
// Ignore, Firefox cast exception if local file wasn't found
}
n[i].removeAttribute("mce_tsrc");
}
if (xhref != "") {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -