gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 17:36:02 52 4
gpt4 key购买 nike

我想要 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'}));
}
});
}

最佳答案

尝试关注此 fiddle

希望能帮助到你!!

注意:我使用的是 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 - 如何添加自定义按钮以将文本添加到 tinymce 编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18274819/

52 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com