博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自定义配置UEditor 工具栏上的按钮列表
阅读量:4610 次
发布时间:2019-06-09

本文共 2133 字,大约阅读时间需要 7 分钟。

修改配置项的方法: 1. 方法一:修改 ueditor.config.js 里面的 toolbars 2. 方法二:实例化编辑器的时候传入 toolbars 参数

方法一:在ueditor.config.js中

//工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义        , toolbars: [[            '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', 'drafts', 'help'            // 'fullscreen', 'source', 'undo', 'redo', 'bold'        ]]

toolbars:里的值修改成你想要的就可以了.

默认没修改:                                                                                                               , toolbars: [[            'fullscreen', 'source', 'undo', 'redo', 'bold']]时页面效果

方法二:实例化编辑器的时候传入 toolbars 参数

var ue = UE.getEditor('editor',  {    toolbars: [[               'fullscreen', 'source','|', 'undo', 'redo', 'bold'           ]],   });//对编辑器的操作最好在编辑器ready之后再做ue.ready(function() {    //设置编辑器的内容    ue.setContent('hello--editor');    //获取html内容,返回: 

hello

var html = ue.getContent(); //获取纯文本内容,返回: hello var txt = ue.getContentTxt(); console.log(txt);});

 

转载于:https://www.cnblogs.com/yingzi1028/p/5611381.html

你可能感兴趣的文章