<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="tinyMCE.ascx.cs" Inherits="Mvcb2b.admin.tinyMCE" %>
<script type="text/javascript" src="<%=Webd%>editors/tiny_mce3.5/tiny_mce.js"></script>
<script type="text/javascript" src="Comja/up.js"></script>
<script type="text/javascript">
var  tistu=true;
var isie2 = (navigator.appName == "Microsoft Internet Explorer");
var isie11= navigator.userAgent.indexOf('Trident/') != -1 && (navigator.userAgent.indexOf('rv:') != -1 || navigator.appName.indexOf('Netscape') != -1);
var isEdge = navigator.userAgent.indexOf('Edge/') != -1;
if (isie2 || isie11 ||  isEdge)
   tistu=false;
    var editorpath = "<%=Webd%>editors/";
	tinyMCE.init({
	    mode: "exact", theme:"advanced", language:"zh", elements:"<%=txtContent.ClientID %>",		
		//工具栏
		//相应 内联弹出式窗口,全屏,上下文菜单,图片,清理,表情,表格
	  plugins: "fullscreen,emotions,table,preview,pagebreak,advimage,paste,media,visualchars,xhtmlxtras",
	  //  plugins: "autolink,lists,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,advlist,autosave,visualblocks",
		theme_advanced_buttons1: "fullscreen,code,newdocument,|,cut,copy,paste,|,undo,redo,|,bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,|,forecolor,backcolor",
		//theme_advanced_buttons2: "link,unlink,sub,sup,removeformatcleanup,charmap,emotions,table,image,|,formatselect,fontselect,fontsizeselect,pagebreak,preview,pastetext,pasteword,selectall",
		theme_advanced_buttons2: "link,unlink,sub,sup,removeformatcleanup,charmap,emotions,media,table,image,|,formatselect,fontselect,fontsizeselect,pagebreak,preview,pasteword,selectall,mybutton",
		theme_advanced_buttons3: "",

		button_tile_map :false,
		theme_advanced_toolbar_location:"top",//编辑器在顶部
		theme_advanced_toolbar_align: "left", //工具栏按钮靠左
		theme_advanced_statusbar_location : "bottom",//状态栏显示底部	
		plugin_insertdate_dateFormat : "%Y-%m-%d",
        plugin_insertdate_timeFormat : "%H:%M:%S",
        extended_valid_elements: "hr[class|width|size|noshade],font[face|size|color|style],div[class|align|style],span[class|align|style],script[charset|defer|language|src|type],code,iframe[src|width|height|frameborder|name|style],img[class|align|src|width|height|alt|name|style],script[type|src],video[src|width|height|controls]",
        theme_advanced_resizing: true, //可以动态调整编辑器大小
        <%if (Upfile!=null){ %>
		 setup: function (editor) {
						editor.addButton('mybutton', {
							title: '上传图片',
							icon: true,
							image : editorpath+'tiny_mce3.5/image.gif',//注意图片的路径 url是当前js的路径
							onclick: function () {
								tinymceEditor = editor;
								//开始上传对话框	
								var upfile= "<%=Upfile%>";
								upfilebox(upfile);		
							}
						});
		   },
        <%} %>
        // Style formats
        style_formats: [
			{ title: 'Bold text', inline: 'b' },
			{ title: 'Red text', inline: 'span', styles: { color: '#ff0000'} },
			{ title: 'Red header', block: 'h1', styles: { color: '#ff0000'} },
			{ title: 'Example 1', inline: 'span', classes: 'example1' },
			{ title: 'Example 2', inline: 'span', classes: 'example2' },
			{ title: 'Table styles' },
			{ title: 'Table row 1', selector: 'tr', classes: 'tablerow1' }
		],
        paste_auto_cleanup_on_paste:tistu,
        /*
        paste_remove_styles: true,  
paste_remove_styles_if_webkit: true,   
paste_strip_class_attributes: true,  
*/
      //  skin: "o2k7",
		auto_cleanup_word:true,		
		//file_browser_callback : "fileBrowserCallBack",
		//file_browser_callback : "myCustomFileBrowser",
		theme_advanced_resize_horizontal: true, //水平调整编辑器
		theme_advanced_resizing: true, //调整开关	
		nonbreaking_force_tab : true,
		apply_source_formatting : true,
		relative_urls: false
		});	
	
	    //功能：获取TinyMce编辑器的内容
        //返回：内容字符串；如果失败，返回空字符串
        function GetTinyMceContent(editorId)
        {
        // return tinyMCE.getInstanceById(editorId).getBody().innerHTML;
		return tinyMCE.get(editorId).getContent();	 
		 
        }        
        //功能：设置TinyMce编辑器的内容
        //参数：editorId——编辑器的id
        function SetTinyMceContent(editorId,content)
        {
            tinyMCE.getInstanceById(editorId).getBody().innerHTML = content;
        }
        function GetContent() {
           return  GetTinyMceContent('<%=txtContent.ClientID %>');
        }
        function SetContent(content) {
           SetTinyMceContent('<%=txtContent.ClientID %>', content);
        }
        //插入内容
        function InsertContent(content) {
            // tinyMCE.execCommand('mceInsertContent',false, content);
            tinyMCE.execCommand('mceInsertRawHTML', false, content);

        }
        function InsertImage() {
            // tinyMCE.execCommand('mceInsertContent',false, content);
            tinyMCE.execCommand('mceImage', false, null);
        }   
</script>
<asp:TextBox runat="Server" ID="txtContent"  Width="100%"  TextMode="MultiLine" />