📄 editor_template_src.js
字号:
if (toolbarLocation == "bottom")
{
template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
}
// External toolbar changes
if (toolbarLocation == "external")
{
var bod = document.body;
var elm = document.createElement ("div");
toolbarHTML = tinyMCE.replaceVars(toolbarHTML, tinyMCE.settings);
toolbarHTML = tinyMCE.replaceVars(toolbarHTML, tinyMCELang);
toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
toolbarHTML = tinyMCE.replaceVar(toolbarHTML, "editor_id", editorId);
toolbarHTML = tinyMCE.applyTemplate(toolbarHTML);
elm.className = "mceToolbarExternal";
elm.id = editorId+"_toolbar";
elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
bod.appendChild (elm);
// bod.style.marginTop = elm.offsetHeight + "px";
deltaHeight = 0;
tinyMCE.getInstanceById(editorId).toolbarElement = elm;
//template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];
}
else
{
tinyMCE.getInstanceById(editorId).toolbarElement = null;
}
if (statusbarLocation == "bottom")
{
template['html'] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>';
deltaHeight -= 23;
}
template['html'] += '</tbody></table>';
//"SimpleLayout"
break;
case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
//Render Containers:
for (var i = 0; i < containers.length; i++)
{
if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
{
template['html'] += '<tr><td align="center" class="mceEditor_border">\
<span id="{$editor_id}"></span>\
</td></tr>';
}
else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
{
var pathClass = "mceStatusbar";
if (i == containers.length-1)
{
pathClass = "mceStatusbarBottom";
}
else if (i == 0)
{
pathClass = "mceStatusbar";
}
else
{
deltaHeight-=2;
}
template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
deltaHeight -= 22;
}
else //Render normal Container:
{
var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
var curContainerHTML = "";
var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
for (var j=0; j<curContainer.length; j++)
{
curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
}
if (curContainer.length > 0)
{
curContainerHTML += "<br />";
deltaHeight -= 23;
}
template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
}
}
template['html'] += '</tbody></table>';
//RowLayout
break;
case "BorderLayout" : //will be like java.awt.BorderLayout of SUN Java...
// Not implemented yet...
break;
case "CustomLayout" : //User defined layout callback...
var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined")
{
template = eval(customLayout + "(template);");
}
break;
default:
alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');
//CustomLayout
break;
}
if (resizing)
template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';
template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
template['delta_width'] = 0;
template['delta_height'] = deltaHeight;
return template;
}
/**
* Starts/stops the editor resizing.
*/
function TinyMCE_advanced_setResizing(e, editor_id, state) {
e = typeof(e) == "undefined" ? window.event : e;
var resizer = TinyMCE_advanced_resizer;
var editorContainer = document.getElementById(editor_id + '_parent');
var editorArea = document.getElementById(editor_id + '_parent').firstChild;
var resizeBox = document.getElementById(editor_id + '_resize_box');
var inst = tinyMCE.getInstanceById(editor_id);
if (state) {
// Place box over editor area
var width = editorArea.clientWidth;
var height = editorArea.clientHeight;
resizeBox.style.width = width + "px";
resizeBox.style.height = height + "px";
resizer.iframeWidth = inst.iframeElement.clientWidth;
resizer.iframeHeight = inst.iframeElement.clientHeight;
// Hide editor and show resize box
editorArea.style.display = "none";
resizeBox.style.display = "block";
// Add event handlers, only once
if (!resizer.eventHandlers) {
if (tinyMCE.isMSIE)
tinyMCE.addEvent(document, "mousemove", TinyMCE_advanced_resizeEventHandler);
else
tinyMCE.addEvent(window, "mousemove", TinyMCE_advanced_resizeEventHandler);
tinyMCE.addEvent(document, "mouseup", TinyMCE_advanced_resizeEventHandler);
resizer.eventHandlers = true;
}
resizer.resizing = true;
resizer.downX = e.screenX;
resizer.downY = e.screenY;
resizer.width = parseInt(resizeBox.style.width);
resizer.height = parseInt(resizeBox.style.height);
resizer.editorId = editor_id;
resizer.resizeBox = resizeBox;
resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true);
} else {
resizer.resizing = false;
resizeBox.style.display = "none";
editorArea.style.display = tinyMCE.isMSIE ? "block" : "table";
tinyMCE.execCommand('mceResetDesignMode');
}
}
function TinyMCE_advanced_initInstance(inst) {
if (tinyMCE.getParam("theme_advanced_resizing", false)) {
if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
var w = TinyMCE_advanced_getCookie("TinyMCE_" + inst.editorId + "_width");
var h = TinyMCE_advanced_getCookie("TinyMCE_" + inst.editorId + "_height");
TinyMCE_advanced_resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true));
}
}
}
function TinyMCE_advanced_setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + escape(path) : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
function TinyMCE_advanced_getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0)
return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function TinyMCE_advanced_resizeTo(inst, w, h, set_w) {
var editorContainer = document.getElementById(inst.editorId + '_parent');
var tableElm = editorContainer.firstChild;
var iframe = inst.iframeElement;
if (w == null || w == "null") {
set_w = false;
w = 0;
}
if (h == null || h == "null")
return;
w = parseInt(w);
h = parseInt(h);
if (tinyMCE.isGecko) {
w += 2;
h += 2;
}
var dx = w - tableElm.clientWidth;
var dy = h - tableElm.clientHeight;
w = w < 1 ? 30 : w;
h = h < 1 ? 30 : h;
if (set_w)
tableElm.style.width = w + "px";
tableElm.style.height = h + "px";
iw = iframe.clientWidth + dx;
ih = iframe.clientHeight + dy;
iw = iw < 1 ? 30 : iw;
ih = ih < 1 ? 30 : ih;
if (tinyMCE.isGecko) {
iw -= 2;
ih -= 2;
}
if (set_w)
iframe.style.width = iw + "px";
iframe.style.height = ih + "px";
// Is it to small, make it bigger again
if (set_w) {
var tableBodyElm = tableElm.firstChild;
var minIframeWidth = tableBodyElm.scrollWidth;
if (inst.iframeElement.clientWidth < minIframeWidth) {
dx = minIframeWidth - inst.iframeElement.clientWidth;
inst.iframeElement.style.width = (iw + dx) + "px";
}
}
}
/**
* Handles resizing events.
*/
function TinyMCE_advanced_resizeEventHandler(e) {
var resizer = TinyMCE_advanced_resizer;
// Do nothing
if (!resizer.resizing)
return;
e = typeof(e) == "undefined" ? window.event : e;
var dx = e.screenX - resizer.downX;
var dy = e.screenY - resizer.downY;
var resizeBox = resizer.resizeBox;
var editorId = resizer.editorId;
switch (e.type) {
case "mousemove":
var w, h;
w = resizer.width + dx;
h = resizer.height + dy;
w = w < 1 ? 1 : w;
h = h < 1 ? 1 : h;
if (resizer.horizontal)
resizeBox.style.width = w + "px";
resizeBox.style.height = h + "px";
break;
case "mouseup":
TinyMCE_advanced_setResizing(e, editorId, false);
TinyMCE_advanced_resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal);
// Expire in a month
if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
var expires = new Date();
expires.setTime(expires.getTime() + 3600000 * 24 * 30);
// Set the cookies
TinyMCE_advanced_setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires);
TinyMCE_advanced_setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires);
}
break;
}
}
/**
* Insert link template function.
*/
function TinyMCE_advanced_getInsertLinkTemplate()
{
var template = new Array();
template['file'] = 'link.htm';
template['width'] = 330;
template['height'] = 170 + (tinyMCE.isMSIE ? 25 : 0);
// Language specific width and height addons
template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
return template;
};
/**
* Insert image template function.
*/
function TinyMCE_advanced_getInsertImageTemplate() {
var template = new Array();
template['file'] = 'image.htm?src={$src}';
template['width'] = 340;
template['height'] = 250 + (tinyMCE.isMSIE ? 25 : 0);
// Language specific width and height addons
template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
return template;
};
/**
* Node change handler.
*/
function TinyMCE_advanced_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
function selectByValue(select_elm, value, first_index) {
first_index = typeof(first_index) == "undefined" ? false : true;
if (select_elm) {
for (var i=0; i<select_elm.options.length; i++) {
var ov = "" + select_elm.options[i].value;
if (first_index && ov.toLowerCase().indexOf(value.toLowerCase()) == 0) {
select_elm.selectedIndex = i;
return true;
}
if (ov == value) {
select_elm.selectedIndex = i;
return true;
}
}
}
return false;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -