laravel-admin rich text editor - Baidu Configuration Editor

Step One: Download Baidu editor to local: http://ueditor.baidu.com/website/

Step two: Download the file into the file public / vendor (can rename name)

 

The third step: New File ueditor.php in app \ Admin \ Extensions file

namespace  App\Admin\Extensions;
use Encore\Admin\Form\Field;
class Ueditor extends Field
{
    protected static $css = [
    ];
    public static $isJs=false;
    protected static $js = [
 / * Ueditor1433 folder for the second step in a custom folder * /
        '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}');
             
ROT;
        return parent::render();
    }

}

Step Four: New Ueditor.blade.php file resource \ views \ admin \ in

<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>

Step Five: Modify the app \ Admin \ bootstrap.php add the following,

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

Step Six: Use

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

 

Guess you like

Origin www.cnblogs.com/fogwang/p/11781191.html
Recommended