如何在TinyMCE Simple主题中将工具栏移动到顶部?感谢
答案 0 :(得分:24)
注意:以下说明适用于TinyMCE 3.x. TinyMCE 4.x现已上市,您可能应该使用它。有关详细信息,请参阅http://www.tinymce.com/wiki.php/Configuration。
在TinyMCE中使用theme : advanced
时,工具栏只能移到顶部。没有theme_simple_toolbar_location
,只有theme_advanced_toolbar_location
。请参阅此处的文档http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_toolbar_location。
您可以做的是将编辑器作为theme : advanced
提供,然后使用theme_advanced_buttons_1_n
属性自定义按钮。它在此处记录http://www.tinymce.com/wiki.php/Configuration3x:theme_advanced_buttons_1_n。
示例中的代码未经过测试,但应该可以使用。它将显示一个编辑器,顶部有Bold,Italic和Underline按钮。
tinyMCE.init({
mode : "textareas",
theme : "advanced",
theme_advanced_toolbar_location : "top",
theme_advanced_buttons1 : "bold,italic,underline",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : ""
});
所以答案是:使用theme : simple
时无法移动按钮。
答案 1 :(得分:2)
为此,您必须编辑在themes / simple文件夹中的editor_template.js。
以下是带有更改的代码,将工具栏置于顶部。
(function() {
var a = tinymce.DOM;
tinymce.ThemeManager.requireLangPack("simple");
tinymce.create("tinymce.themes.SimpleTheme", {
init: function(c, d) {
var e = this,
b = ["Bold", "Italic", "Underline", "Strikethrough", "InsertUnorderedList", "InsertOrderedList"],
f = c.settings;
e.editor = c;
c.contentCSS.push(d + "/skins/" + f.skin + "/content.css");
c.onInit.add(function() {
c.onNodeChange.add(function(h, g) {
tinymce.each(b, function(i) {
g.get(i.toLowerCase()).setActive(h.queryCommandState(i))
})
})
});
a.loadCSS((f.editor_css ? c.documentBaseURI.toAbsolute(f.editor_css) : "") || d + "/skins/" + f.skin + "/ui.css")
},
renderUI: function(h) {
var e = this,
i = h.targetNode,
b, c, d = e.editor,
f = d.controlManager,
g, tbody;
i = a.insertAfter(a.create("span", {
id: d.id + "_container",
"class": "mceEditor " + d.settings.skin + "SimpleSkin"
}), i);
i = g = a.add(i, "table", {
cellPadding: 0,
cellSpacing: 0,
"class": "mceLayout"
});
tbody = c = a.add(i, "tbody");
i = b = a.add(a.add(i, "td"), "div", {
"class": "mceIframeContainer"
});
i = a.add(a.add(c, "tr", {
"class": "last"
}), "td", {
"class": "mceToolbar mceLast",
align: "center"
});
c = e.toolbar = f.createToolbar("tools1");
c.add(f.createButton("bold", {
title: "simple.bold_desc",
cmd: "Bold"
}));
c.add(f.createButton("italic", {
title: "simple.italic_desc",
cmd: "Italic"
}));
c.add(f.createButton("underline", {
title: "simple.underline_desc",
cmd: "Underline"
}));
c.add(f.createButton("strikethrough", {
title: "simple.striketrough_desc",
cmd: "Strikethrough"
}));
c.add(f.createSeparator());
c.add(f.createButton("undo", {
title: "simple.undo_desc",
cmd: "Undo"
}));
c.add(f.createButton("redo", {
title: "simple.redo_desc",
cmd: "Redo"
}));
c.add(f.createSeparator());
c.add(f.createButton("cleanup", {
title: "simple.cleanup_desc",
cmd: "mceCleanup"
}));
c.add(f.createSeparator());
c.add(f.createButton("insertunorderedlist", {
title: "simple.bullist_desc",
cmd: "InsertUnorderedList"
}));
c.add(f.createButton("insertorderedlist", {
title: "simple.numlist_desc",
cmd: "InsertOrderedList"
}));
c.renderTo(i);
i = c = a.add(i, "tbody");
i = a.add(c, "tr");
return {
iframeContainer: b,
editorContainer: d.id + "_container",
sizeContainer: g,
deltaHeight: -20
}
},
getInfo: function() {
return {
longname: "Simple theme",
author: "Moxiecode Systems AB",
authorurl: "http://tinymce.moxiecode.com",
version: tinymce.majorVersion + "." + tinymce.minorVersion
}
}
});
tinymce.ThemeManager.add("simple", tinymce.themes.SimpleTheme)
})();
答案 2 :(得分:-3)
tinyMCE.init({
mode : "textareas",
theme : "simple"
theme_simple_toolbar_location : "top"
});
重要的一位是“toolbar_location”参数。