Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何添加自定义按钮以将文本添加到tinymce编辑器_Tinymce - Fatal编程技术网

如何添加自定义按钮以将文本添加到tinymce编辑器

如何添加自定义按钮以将文本添加到tinymce编辑器,tinymce,Tinymce,我想要一个tinymce工具栏中的按钮。点击该按钮,“HELLO”应该出现在光标所在的编辑器中 版本:3.3.7 但我无法添加该按钮 我尝试过添加这样的按钮 setup: function (ed) { ed.addButton('example', { title : 'example.desc', image : '../jscripts/tiny_mce/plugins/example/img/example.gif', onc

我想要一个tinymce工具栏中的按钮。点击该按钮,“HELLO”应该出现在光标所在的编辑器中

版本:3.3.7

但我无法添加该按钮

我尝试过添加这样的按钮

setup: function (ed) {
    ed.addButton('example', {
         title : 'example.desc',
         image : '../jscripts/tiny_mce/plugins/example/img/example.gif',
         onclick : function() {
            ed.windowManager.alert('Hello world!! Selection: ' + ed.selection.getContent({format : 'text'}));
         }
      });
    }
试着遵循这一点

希望能有帮助

注意:我使用的是3.4.8版本

代码镜像:

<script type="text/javascript">
tinyMCE.init({
    // General options
    mode : "textareas",
    theme : "advanced",
    plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",

    // Theme options
    theme_advanced_buttons1 : "save,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,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage,example",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,
    width: "100%",
    height: "400",
    setup: function (ed) {
    ed.addButton('example', {
         title : 'example.desc',
         image : './/',
         onclick : function() {
            tinyMCE.execCommand('mceInsertContent',false, 'Hello!!'); 
         }
      });
    }
});
</script>

<form method="post" action="dump.php">
    <textarea name="content"></textarea>
</form>

tinyMCE.init({
//一般选择
模式:“文本区域”,
主题:“高级”,
插件:“自动链接、列表、拼写检查器、分页符、样式、图层、表格、保存、advhr、advimage、advlink、情感、iSpell、inlinepopups、insertdatetime、预览、媒体、搜索替换、打印、上下文菜单、粘贴、方向性、全屏、不可编辑、visualchars、非中断、xhtmlxtras、模板、imagemanager、文件管理器”,
//主题选项
主题_高级_按钮1:“保存、新建文档、|、粗体、斜体、下划线、删除线、|、左对齐、居中对齐、右对齐、满对齐、|、样式选择、格式选择、字体选择、字体大小选择”,
主题高级按钮2:“剪切、复制、粘贴、粘贴文本、粘贴文字、搜索、替换、布利斯特、numlist、outdent、indent、blockquote、|、撤消、重做、链接、取消链接、锚定、图像、清理、帮助、代码、插入日期、插入时间、预览、前景色、后景色”,
主题|高级|按钮3:“表格控件,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,情感,易趣,媒体,advhr,|,打印,|,ltr,rtl,|,全屏”,
theme_advanced_按钮4:“插入层、向前移动、向后移动、绝对、|、styleprops、拼写检查器、|、引用、缩写、首字母缩写、del、ins、attribs、|、visualchars、非中断、模板、块引号、页面中断、|、插入文件、插入图像、示例”,
主题\高级\工具栏\位置:“顶部”,
主题\高级\工具栏\对齐:“左”,
主题\高级\状态栏\位置:“底部”,
主题\u高级\u大小调整:正确,
宽度:“100%”,
高度:“400”,
设置:功能(ed){
ed.addButton('示例'{
标题:“example.desc”,
图像:'./',
onclick:function(){
execCommand('mceInsertContent',false,'Hello!!');
}
});
}
});

初始化时,不要忘记将按钮添加到
工具栏
选项


如何获取选择器?