ueditor1_2_6的用法

经常用到编辑器,也经常忘记一些常用编辑器的配置,今天干脆写篇记录下来

编辑器:百度编辑器

版本:1.2.6 utf-8

1,引入js,css,文件

     <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <!-- 语言包文件(建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败) -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>

2,设置容器

     <script id="container" name="content" type="text/plain">
      </script>

3,配置

     看源码如下:

         UE.getEditor = function (id, opt) {
        var editor = instances[id];
        if (!editor) {
            editor = instances[id] = new UE.ui.Editor(opt);
            editor.render(id);
        }
        return editor;
    };

   可知,id为编辑器要渲染的容器id,opt为参数对象,所以配置如下:

       <script type="text/javascript">
    var editor = UE.getEditor('container',{
        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', '|',
                        'insertimage', 'emotion', 'scrawl',
                        ]
                ]//自定义工具
        ,initialFrameHeight:350 //容器高度
        ,elementPathEnabled:false  //是否显示底部的元素层级关系
        ,UEDITOR_HOME_URL:"Public/ueditor/"  //ueditor的路径,这个很关键
        
    })
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值