ueditor怎么控制工具栏按钮是否显示

u011114717 2015-06-05 05:58:10
我想要在编辑器刚开始加载的时候显示一部分常用的按钮,然后如果需要全部,有个按钮可以控制


求大神们帮忙解决一下

就剩40分了 解决完立马结贴给分
...全文
1936 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
happydevelopers 2017-03-14
  • 打赏
  • 举报
回复
//初始化设置默认的editor(可以自行设置需要的工具栏) var ue = UE.getEditor('editor'); //再在按钮单击事件里面,销毁编辑器ue ue.destroy(); //再重新创建编辑器即可 ue = UE.getEditor('editor',{toolbars: [[ 'fullscreen', 'source', '|', 'undo', 'redo', '|' ]]});
落叶3213 2016-06-27
  • 打赏
  • 举报
回复
更正: 引入ueditor的网页里,第18行应为

if(stateText==0||stateText==""){
落叶3213 2016-06-27
  • 打赏
  • 举报
回复
具体效果看下图
简易工具栏

复杂工具栏
落叶3213 2016-06-27
  • 打赏
  • 举报
回复
ueditor 1.4.3 一、t加入一个按钮 ueditor.all.js中 1. var btnCmds= 中加 'toggletool' 2. 找到 “fullscreen这里单独处理一下,放到首行去” 下一行修改成
if (toolbarItem == 'fullscreen'||toolbarItem == 'toggletool') {
目的是把这个按钮也跟全屏按钮一样放到首行 themes/default/ueditor.css 中 1. 加css(跟全屏按钮一样浮动到右边)
.edui-default .edui-toolbar .edui-for-toggletool {
    float: right;
}
2. 定义按钮背景图片
.edui-default  .edui-for-toggletool .edui-icon {
    background-position: -400px -40px;
}
二 、在引用ueditor的网页代码里

var stateText=0;
var countnum=0;
    //实例化编辑器
    var ue = UE.getEditor('editor',{toolbars:[[
            'toggletool','fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist','|',
            'simpleupload', 'insertimage','|', 'selectall', 'cleardoc'
        ]],initialFrameWidth:1024,initialFrameHeight:500});
  baidu.editor.commands['toggletool']={
	execCommand:function () {
		var fullscreenstate=this.ui.isFullScreen();
		if(fullscreenstate==true){
			this.ui.setFullScreen(false);//取消全屏模式
		}
		countnum++;
		//this.setContent(" <a href='http://www.lzzx.cn' target='_blank'>连云港市厉庄高级中学</a>  "+"第"+countnum+"次:原stateText值:"+stateText+"<br>", true);
		this.destroy();
		if(stateText<0||stateText==""){
			//alert("简易");
			ue = UE.getEditor('editor',{toolbars:[[
            'toggletool','fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
            'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
            'directionalityltr', 'directionalityrtl', 'indent', '|',
            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
            'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode', 'webapp', 'pagebreak', 'template', 'background', '|',
            'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
            'print', 'preview', 'searchreplace', 'help', 'drafts'
        ]],initialFrameWidth:1024,initialFrameHeight:500});
			stateText=1;
		}else if(stateText>0){
			//alert("复杂");
			ue = UE.getEditor('editor',{toolbars:[[
            'toggletool','fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist','|',
            'simpleupload', 'insertimage','|', 'selectall', 'cleardoc'
        ]],initialFrameWidth:1024,initialFrameHeight:500});
			stateText=0;
		}
		return true;
	}
  }
一枝梨花 2016-01-07
  • 打赏
  • 举报
回复
//本来是这样的:UE.getEditor('editor'); 传入参数后就是下面那样子了,toolbars里的就是工具的图标 UE.getEditor('editor', { toolbars: [ ['fullscreen', 'source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'backcolor', 'fontsize', 'fontfamily', 'justifyleft', 'justifyright', 'justifycenter', 'justifyjustify', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', 'link', 'unlink', 'emotion', 'help'] ] }); }) 在toolbars里面自定义即可,就是你运行的那个html页面里面引用对象时做修改,我是最近才做这个功能的 看我的: //var ue = UE.getEditor('editor');//这个就是加载默认内容,下面的就是重新定义 var ue = UE.getEditor('editor',{toolbars: [[ 'fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'forecolor', 'backcolor', '|', 'insertorderedlist', 'insertunorderedlist', 'cleardoc', '|', 'paragraph', 'fontfamily', 'fontsize', '|', 'indent', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'link', '|', 'simpleupload', 'emotion', 'insertvideo', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts' ]]});
u011114717 2015-06-05
  • 打赏
  • 举报
回复
自己给自己顶一下
Ueditor HTML编辑器是百度开源的HTML编辑器, 本模块帮助在Django应用中集成百度Ueditor HTML编辑器。 安装包中已经集成Ueditor v1.2.2 使用Django-Ueditor非常简单,方法如下: 1、安装方法 **方法一:下载安装包,在命令行运行: python setup.py install **方法二:使用pip工具在命令行运行(推荐): pip install DjangoUeditor 2、在INSTALL_APPS里面增加DjangoUeditor app,如下: INSTALLED_APPS = ( #........ 'DjangoUeditor', ) 3、在urls.py中增加: url(r'^ueditor/',include('DjangoUeditor.urls' )), 4、在models中这样定义: from DjangoUeditor.models import UEditorField class Blog(models.Model): Name=models.CharField(,max_length=100,blank=True) Content=UEditorField('内容 ',height=100,width=500,default='test',imagePath="uploadimg/",imageManagerPath="imglib",toolbars='mini',options={"elementPathEnabled":True},filePath='upload',blank=True) 说明: UEditorField继承自models.TextField,因此你可以直接将model里面定义的models.TextField直接改成UEditorField即可。 UEditorField提供了额外的参数: toolbars:配置你想显示工具栏,取值为mini,normal,full,代表小,一般,全部。如果默认的工具栏不符合您的要求,您可以在settings里面配置自己的显示按钮。参见后面介绍。 imagePath:图片上传的路径,如"images/",实现上传到"{{MEDIA_ROOT}}/images"文件夹 filePath:附件上传的路径,如"files/",实现上传到"{{MEDIA_ROOT}}/files"文件夹 imageManagerPath:图片管理器显示的路径,如"imglib/",实现上传到"{{MEDIA_ROOT}}/imglib",如果不指定则默认=imagepath。 options:其他UEditor参数,字典类型。参见Ueditor的文档ueditor_config.js里面的说明。 css:编辑器textarea的CSS样式 width,height:编辑器的宽度和高度,以像素为单位。 5、在表单中使用非常简单,与常规的form字段没什么差别,如下: class TestUeditorModelForm(forms.ModelForm): class Meta: model=Blog *********************************** 如果不是用ModelForm,可以有两种方法使用: 1: 使用forms.UEditorField from DjangoUeditor.forms import UEditorField class TestUEditorForm(forms.Form): Description=UEditorField("描述",initial="abc",width=600,height=800) 2: widgets.UEditorWidget from DjangoUeditor.widgets import UEditorWidget class TestUEditorForm(forms.Form): Content=forms.CharField(label="内容",widget=UEditorWidget(width=800,height=500, imagePath='aa', filePath='bb',toolbars={})) widgets.UEditorWidget和forms.UEditorField的输入参数与上述models.UEditorField一样。 6、Settings配置 在Django的Settings可以配置以下参数: UEDITOR_SETTINGS={ "toolbars":{ #定义多个工具栏显示按钮,允行定义多个 "name1":[[ 'source', '|','bold', 'italic', 'underline']], "name2",[] }, "images_upload":{ "allow_type":"jpg,png", #定义允许的上传的图片类型 "max_size":"2222kb" #定义允许上传的图片大小,0代表不限制 }, "files_upload":{ "allow_type":"zip,rar", #定义允许的上传的文件类型 "max_size":"2222kb" #定义允许上传的文件大小,0代表不限制 },, "image_manager":{ "location":"" #图片管理器的位置,如果没有指定,默认跟图片路径上传一样 }, } 7、其他事项: **本程序基于百度ueditor 1.2.2,安装包里面已经包括了,不需要再额外安装。 **目前暂时不支持ueditor的插件 **Django默认开启了CSRF中间件,因此如果你的表单没有加入{% csrf_token %},那么当您上传文件和图片时会失败

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧