有没有办法将自定义按钮添加到TinyMCE工具栏上,只有文字(没有图像)? 尝试删除设置图像路径部分,现在它有一个空白按钮。这是我现有的代码:
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "advanced",
theme_advanced_buttons1: "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink",
theme_advanced_buttons2: "mybutton",
theme_advanced_buttons3: "",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
setup: function (ed) {
// Add a custom button
ed.addButton('mybutton', {
title: 'My button',
onclick: function () {
ed.focus();
ed.selection.setContent('SampleText');
}
});
}
});
</script>
如何在没有图像的情况下在按钮上设置文字?
答案 0 :(得分:5)
只需将工具栏“mybutton”放入其中,然后在tinymce.init中添加:
setup: function(editor) {
editor.addButton('mybutton', {
type: 'menubutton',
text: 'My button',
icon: false,
menu: [
{text: 'Menu item 1', onclick: function() {editor.insertContent('Menu item 1');}},
{text: 'Menu item 2', onclick: function() {editor.insertContent('Menu item 2');}}
]
});
}
答案 1 :(得分:3)
尝试设置label
属性。
ed.addButton('mybutton', {
title: 'My button',
onclick: function () {
ed.focus();
ed.selection.setContent('SampleText');
ed.label = 'My Button';
}
});
答案 2 :(得分:3)
我不得不将标签属性移出onclick函数以使其适合我。
ed.addButton('mybutton', {
title: 'My button',
label: 'My Button',
onclick: function () {
ed.selection.setContent('SampleText');
}
});