0
我一直在尝试添加自己的菜单,并且必须做错某些事情。这里是我到目前为止,这是非常简单的从一些示例代码外壳:TinyMCE添加菜单问题(带插件)
tinymce.html - 网页,我承载的textarea和初始化代码:
<!-- /TinyMCE -->
<script type="text/javascript">
tinyMCE.init({
mode: "textareas",
skin: "o2k7",
theme: "advanced",
plugins: "mymenu,fullpage,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
theme_advanced_buttons1: "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
toolbar: "mymenu",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_resizing: false,
extended_valid_elements: "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
});
</script>
<!-- /TinyMCE -->
<body>
<form method="post">
<textarea name="tinyMceEditor" cols="1" rows="1" style="width:100%; height: 100%"></textarea>
</form>
</body>
您可以看到该插件“ mymenu'和工具栏'mymenu'在TinyMCE的初始化中。
对于插件,它位于带有editor_plugin.js约定的/ Plugins/mymenu /目录中。我知道它正在加载它,因为如果我向文件引入错误,我会收到警告。
editor_plugin.js:
(function() {
tinymce.create('tinymce.plugins.mymenu', {
init: function (editor, url) {
editor.addButton('mymenu', {
type: 'menubutton',
text: 'My Menu',
icon: false,
menu: [{
text: 'Data Loop',
onclick: function(){
editor.insertContent('{DataLoop}');
}
}, {
text: 'Collector Loop',
onclick: function(){
editor.insertContent('{CollectorLoop}');
}
}]
});
}
});
// Register plugin
tinymce.PluginManager.add('mymenu', tinymce.plugins.PageBreakPlugin);
})();
它看起来对我来说,我所拥有的一切是正确的。但是 - 没有菜单显示。只需4个工具栏按钮,如init代码中的按钮1-4所示。
编辑:我曾尝试删除所有高级按钮,更改主题,以简单,相当多的其他选择。仍无法得到这个简单的菜单出现:(
我用这个小提琴把它直接进入HTML文件的init部分仍然不显示菜单:( – Andrew
你能不能e TinyMCE你正在做什么的小提琴? –
就是这样......我在CodePen中这样做没问题:http://codepen.io/bdogi/pen/KNRaVm。当我在HTML文件中这样做时,我得到一个空白但大的文本区域。没有菜单。 – Andrew