laravel-admin 富文本編輯器-百度編輯器的配置


第一步:下載百度編輯器到本地:http://ueditor.baidu.com/website/

第二步:將下載文件放到文件public/vendor下(可以重命名名)

 

第三步:在app\Admin\Extensions 文件下新建文件ueditor.php

namespace  App\Admin\Extensions;
use Encore\Admin\Form\Field;
class Ueditor extends Field
{
    protected static $css = [
    ];
    public static $isJs=false;
    protected static $js = [
 /*ueditor1433文件夾為第二步中自定義的文件夾*/
        'vendor/ueditor1433/ueditor.config.js',
        'vendor/ueditor1433/ueditor.all.js',
    ];
    protected $view = 'admin.Ueditor';
    public function render()
    {
        $this->script = <<<EOT
        UE.delEditor('{$this->id}');
             var  ue = UE.getEditor('{$this->id}');
             
EOT;
        return parent::render();
    }

}

第四步:在resource\views\admin\ 中新建Ueditor.blade.php文件

<div class="form-group {!! !$errors->has($errorKey) ?: 'has-error' !!}">
    <label for="{{$id}}" class="col-sm-2 control-label">{{$label}}</label>
<div class="col-sm-8">
    @include('admin::form.error')
    <textarea class="{{ $class }}" id="{{$name}}" name="{{$name}}"
              placeholder="{{ $placeholder }}" {!! $attributes !!} >
       {{ old($column, $value) }}
    </textarea>
    @include('admin::form.help-block')
</div>
</div>

第五步:修改 app\Admin\bootstrap.php 加入以下內容、

use Encore\Admin\Form;
use App\Admin\Extensions\Ueditor;
Encore\Admin\Form::forget(['map', 'editor']);
Form::extend('ueditor', Ueditor::class);

第六步:使用方法

$form = new Form(new News);
$form->ueditor('content', __('內容'));

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM