Git Product home page Git Product logo

wangeditor's Introduction

wangEditor extension for laravel-admin

这是一个laravel-admin扩展,用来将wangEditor集成进laravel-admin的表单中

laravel-admin extension
1.x 1.x
2.x 2.x

截图

wx20180904-103609

安装

// laravel-admin 1.x
composer require "laravel-admin-ext/wang-editor:1.*"

// laravel-admin 2.x
composer require laravel-admin-ext/wang-editor

然后

php artisan vendor:publish --tag=laravel-admin-wangEditor

配置

config/admin.php文件的extensions,加上属于这个扩展的一些配置

    'extensions' => [

        'wang-editor' => [
        
            // 如果要关掉这个扩展,设置为false
            'enable' => true,
            
            // 编辑器的配置
            'config' => [
                
            ]
        ]
    ]

编辑器的配置可以到wangEditor文档找到,比如配置上传图片的地址上传图片

    'config' => [
        // `/upload`接口用来上传文件,上传逻辑要自己实现,可参考下面的`上传图片`
        'uploadImgServer' => '/upload'
    ]

使用

在form表单中使用它:

$form->editor('content');

上传图片

图片上传默认使用base64格式化后与文本内容一起存入数据库,如果要上传图片到本地接口,那么下面是这个接口对应的action代码示例:

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

public function upload(Request $request)
{
    $urls = [];

    foreach ($request->file() as $file) {
        $urls[] = Storage::url($file->store('images'));
    }

    return [
        "errno" => 0,
        "data"  => $urls,
    ];
}

Note: 配置路由指向这个action,存储的disk配置在config/filesystem.php中,这个需参考laravel官方文档。

支持

如果觉得这个项目帮你节约了时间,不妨支持一下;)

-1

License

Licensed under The MIT License (MIT).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.