自定義配置UEditor 工具欄上的按鈕列表

修改配置項的方法: 1. 方法一:修改 ueditor.config.js 裏面的 toolbars 2. 方法二:實例化編輯器的時候傳入 toolbars 參數html

方法一:在ueditor.config.js中web

        //工具欄上的全部的功能按鈕和下拉框,能夠在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:裏的值修改爲你想要的就能夠了.app

默認沒修改:                                                                                                               , toolbars: [[            'fullscreen', 'source', 'undo', 'redo', 'bold']]時頁面效果webapp

方法二:實例化編輯器的時候傳入 toolbars 參數編輯器

var ue = UE.getEditor('editor',
  {
    toolbars: [[
               'fullscreen', 'source','|', 'undo', 'redo', 'bold'
           ]],
   });
//對編輯器的操做最好在編輯器ready以後再作
ue.ready(function() {
    //設置編輯器的內容
    ue.setContent('hello--editor');
    //獲取html內容,返回: <p>hello</p>
    var html = ue.getContent();
    //獲取純文本內容,返回: hello
    var txt = ue.getContentTxt();
    console.log(txt);
});
相關文章
相關標籤/搜索