百度编辑器 Laravel Ueditor

码农软件 · 软件分类 · 可视化HTML编辑器 · 2019-04-06 18:59:06

软件介绍

百度编辑器 For Laravel 5

支持自定义路由, 默认前后台独立控制器,支持重写方法方便自己的业务逻辑处理,支持扩展图片助手(推荐使用Intervention\Image第三方包)

官网

NinJa911工作室.

疑问讨论

请在issue里new一个.

授权

此Laravel 扩展包基于MIT协议开源MIT license.

安装

1.Composer 安装

composer require "zhangmazi/laravel-ueditor:^1.0"

2.编辑config/app.php文件,在节点[providers]中加入

Zhangmazi\Ueditor\UeditorServiceProivder::class

3.在命令行工具执行

php artisan vendor:publish --provider="Zhangmazi\Ueditor\UeditorServiceProivder"

相关资源配置会成功发布到:config/zhangmazi/(配置); public/assets/(静态资源); resources/views/vendor/zhangmazi/(视图,包含demo所需).

配置

1.配置config/zhangmazi/filesystem.php

请根据注释填写,特别要注意root和url_root,这个2个很关键,因为直接导致你是否能上传成功和是否能正常开放预览附件; root的物理路径一定有0755或者0777(当需要建立子目录时)权限.

2.配置config/zhangmazi/ueditor.php

请根据注释填写,节点[routes]支持多组应用场景,其配置其实就Laravel的Route原生配置方法; 其中带有"group_"前缀的都不填,将不使用路由组模式; 如果"via_integrate"为true,将将适用内置命名空间,同时不要修改"uese".

3.配置config/zhangmazi/ext2mime.php

这个增加上传安全性的, 如果您觉得多了和少了, 请自行根据格式进行修改.

使用

Demo使用

开发此包时, 为了增加体验感, 特为大家准备了demo.

访问 http://localhost/zhangmazi/ueditor/demo/index, 其中localhost跟更改为你自己的绑定的域名.

为了安全性, 在[.env]文件中APP_DEBUG=true才能使用demo,否则无法访问以上demo相关路由地址.

如何使用

1.在您的视图中, 在body闭包前(即</body>),加入以下代码

@include("zhangmazi::ueditor")

2.在您的视图中, 需要占位编辑器的dom节点内,加入以下代码

<script id="ueditor_filed" name="article_content" type="text/plain"></script>

其中id="ueditor_filed"这里是需要给百度编辑器创建的时候用到的名字, 如果同一个页面有多个,这个id请用不同的名字替换.

3.在您的视图中, 在body闭包前(即</body>),加入以下代码

<script>
    var ueditor_full = UE.getEditor('ueditor_filed', {
    'serverUrl' : '{{ route("zhangmazi_front_ueditor_service", ['_token' => csrf_token()]) }}'
});
</script>

如果需要更多参考以及调用样板,比如如何自定义编辑工具栏、同一个页面多个编辑器,请查看阅读文件 vendor/zhangmazi/ueditor/src/views/ueditorDemoIndex.blade.php

自定义扩展

以下说明需要一定PHP知识和Laravel5框架了解背景

1.扩展继承内置控制器

新建一个控制器,并继承内置控制器"Zhangmazi\Ueditor\UeditorFrontController".

<?php
/**
 * 自定义的编辑器控制器.
 * 可以观看 Zhangmazi\Ueditor\UeditorUploaderAbstract 类的方法,根据自身业务选择性重写覆盖
 *
 * @author ninja911<ninja911@qq.com>
 * @date   2016-08-20 22:22
 */
namespace App\Http\Controllers;

use Zhangmazi\Ueditor\UeditorFrontController;

class CustomUeditorController extends UeditorFrontController
{
    /**
     * 记录上传日志(这些方法都可以重写覆盖)
     * @return mixed
     */
    protected function insertRecord()
    {

    }

    /**
     * 验证是否合法(这些方法都可以重写覆盖)
     * @return bool|mixed
     */
    protected function checkGuard()
    {
        //Auth....
        return true;
    }

    /**
     * 获取相对于public_path()根目录的相对目录
     * @return bool|mixed
     */
    protected function getRelativeDir()
    {
        return 'uploads/ueditor';
    }
}

?>

把相关路由配置一下,不用内置的

3.查看路由清单,看是否生效,命令行里执行

php artisan route:list

本文地址:https://codercto.com/soft/d/3008.html

The Intersectional Internet

The Intersectional Internet

Safiya Umoja Noble、Brendesha M. Tynes / Peter Lang Publishing / 2016

From race, sex, class, and culture, the multidisciplinary field of Internet studies needs theoretical and methodological approaches that allow us to question the organization of social relations that ......一起来看看 《The Intersectional Internet》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具