thinkPHP和百度ueditor对接经验分享

浏览:3468 发布日期:2016/01/06 分类:用法示例
thinkPHP和百度ueditor对接经验分享
下载百度ueditor文件解压到Public文件下
在需要的界面上引入以下js<script src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <script src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <script src="__PUBLIC__/ueditor/lang/zh-cn/zh-cn.js"></script>
在html代码上这样来写<!-- 加载编辑器的容器 -->
<script id="container" name="content" type="text/plain"></script>
在html页面上js这样来写(根据自己的需要选择自己所要的富文本功能)    <script type="text/javascript">
        $(document).ready(function(){
            
            var ue = UE.getEditor('container',{
                toolbars:[[
                    'undo', 'redo', '|',
                    'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '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', '|',
                    'link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                    'simpleupload', 'insertimage', 'emotion', 'attachment', 'map','pagebreak', '|',
                    'horizontal', 'date', 'time', 'spechars', '|',
                    'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|',
                    'print', 'searchreplace', 'drafts'
                ]],
                initialFrameHeight:250
            });
            
        });

        
    </script>
此处我是使用了上传图片的功能(其他功能处理方式一样),但需要对路径配置好
在ueditor文件夹里/php/路径下有config.json文件,修改里面的imagePathFormat和imageMaxSize属性,此处是配置上传的地址。/* 上传图片配置项 */
    "imageActionName": "uploadimage", /* 执行上传图片的action名称 */
    "imageFieldName": "upfile", /* 提交的图片表单名称 */
    "imageMaxSize": 20480000, /* 上传大小限制,单位B */
    "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
    "imageCompressEnable": true, /* 是否压缩图片,默认是true */
    "imageCompressBorder": 1600, /* 图片压缩最长边限制 */
    "imageInsertAlign": "none", /* 插入的图片浮动方式 */
    "imageUrlPrefix": "", /* 图片访问路径前缀 */
    "imagePathFormat": "/File/Public/Uploads/ueditorimage/{yyyy}{mm}{dd}/{time}{rand:6}",
/* 列出指定目录下的图片 */
    "imageManagerActionName": "listimage", /* 执行图片管理的action名称 */
    "imageManagerListPath": "/File/Public/Uploads/ueditorimage/", /* 指定要列出图片的目录 */
    "imageManagerListSize": 20, /* 每次列出文件数量 */
    "imageManagerUrlPrefix": "", /* 图片访问路径前缀 */
    "imageManagerInsertAlign": "none", /* 插入的图片浮动方式 */
    "imageManagerAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 列出的文件类型 */
如果对上传图片的地方有一个图片列表不需要,可以到相应的模板上去注销相应的代码即可,我注销的是dialogs/image/images/image.html下的 <!--<span class="tab" data-content-id="online"><var id="lang_tab_online"></var></span>
            <span class="tab" data-content-id="search"><var id="lang_tab_search"></var></span>-->
附件是我使用ueditor的版本,建议使用最新或最稳定的版本。

附件 ueditor_release-ueditor1_4_3_1-utf8-php.zip ( 2.78 MB 下载:108 次 )

评论( 相关
后面还有条评论,点击查看>>