我正在使用,Tinymce的版本V3或v4,我想做下一步行动:
1-在焦点上显示工具栏.
2- On blur隐藏工具栏.
我正在看这个例子:http://sourceforge.net/p/tinymce/plugins/185/,还不错,但我正在尝试处理事件,但是没有用.
有人知道一个很好的例子吗?
<!-- TinyMCE -->
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
alert("cargado...");
});
tinyMCE.init({
// General options
mode: "textareas",
theme: "advanced",
plugins: "toggletoolbars, pdw, safari,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,wordcount",
toggletoolbars_status: "off",
// Theme options
theme_advanced_buttons1: "pdw_toggle, 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,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: true,
// PDW Toggle Toolbars settings
pdw_toggle_on: 0,
pdw_toggle_toolbars: "2,3,4",
// Example content CSS (should be your site CSS)
content_css: "css/content.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url: "lists/template_list.js",
external_link_list_url: "lists/link_list.js",
external_image_list_url: "lists/image_list.js",
media_external_list_url: "lists/media_list.js",
// Replace values for the template plugin
template_replace_values: {
username: "Some User",
staffid: "991234"
},
setup: function (ed) {
ed.onBlur.add(function (ed, l) {
tinyMCE.getInstanceById(editorID).toolbarElement.style.display = 'none';
});
}
});
</script>
<!-- /TinyMCE -->
解决方法:
非常感谢afzalulh的帮助,现在有效,我已粘贴代码….如果对另一个人有用.
但是..我有这个解决方案的问题,我使用这个编辑器从文本框ASP.net组件中的数据库加载文本,当我加载文本时,文本没有出现,但是当我在焦点上选择一个Tiny编辑器时我在文本里面插入一个空格出现,我没有错误,我不知道是否需要添加另一个配置参数..?
<head runat="server">
<title>Show/Hide ToolBar on Focus/Blur Event - TinyMCE 4.0.16 jQuery package </title>
<!-- Loading the jQuery Library -->
<script type="text/javascript" src="Javascript/tinymce/js/tinymce/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheet.css" />
<!-- Loading jQuery TinyMCE -->
<script type="text/javascript" src="Javascript/tinymce/js/tinymce/jquery.tinymce.min.js"></script>
<!-- Loading TinyMCE -->
<script type="text/javascript" src="Javascript/tinymce/js/tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: ".editorTextarea",
theme: "modern",
plugins: "pagebreak table save charmap media contextmenu paste directionality noneditable visualchars nonbreaking spellchecker template",
toolbar1: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify fontselect fontsizeselect | bullist numlist | undo redo | forecolor backcolor | charmap nonbreaking",
contextmenu: "cut copy paste",
menubar: false,
statusbar: false,
toolbar_item_size: "small",
setup: function (theEditor) {
theEditor.on('focus', function () {
$(this.contentAreaContainer.parentElement).find("div.mce-toolbar-grp").show();
});
theEditor.on('blur', function () {
$(this.contentAreaContainer.parentElement).find("div.mce-toolbar-grp").hide();
});
theEditor.on("init", function () {
$(this.contentAreaContainer.parentElement).find("div.mce-toolbar-grp").hide();
});
}
});
<asp:TextBox ID="Block1_Text2_D" runat="server" Rows="3" TextMode="MultiLine" Width="400px" CssClass="editorTextarea"></asp:TextBox>