提交代码
This commit is contained in:
43
app/Admin/Extensions/WangEditor.php
Normal file
43
app/Admin/Extensions/WangEditor.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Extensions;
|
||||
|
||||
use Encore\Admin\Form\Field;
|
||||
|
||||
class WangEditor extends Field
|
||||
{
|
||||
protected $view = 'admin.wang-editor';
|
||||
|
||||
protected static $css = [
|
||||
'/vendor/wangEditor-3.1.1/release/wangEditor.min.css',
|
||||
];
|
||||
|
||||
protected static $js = [
|
||||
'/vendor/wangEditor-3.1.1/release/wangEditor.min.js',
|
||||
];
|
||||
|
||||
public function render()
|
||||
{
|
||||
$_token = csrf_token();
|
||||
$name = $this->formatName($this->column);
|
||||
|
||||
$this->script = <<<EOT
|
||||
|
||||
var E = window.wangEditor
|
||||
var editor = new E('#{$this->id}');
|
||||
editor.customConfig.zIndex = 0
|
||||
editor.customConfig.uploadImgServer = '/admin/uploads/editor'
|
||||
editor.customConfig.uploadImgMaxSize = 2 * 1024 * 1024
|
||||
editor.customConfig.uploadFileName = 'image[]'
|
||||
editor.customConfig.uploadImgParams = {
|
||||
_token: '{$_token}'
|
||||
}
|
||||
editor.customConfig.onchange = function (html) {
|
||||
$('input[name=\'$name\']').val(html);
|
||||
}
|
||||
editor.create()
|
||||
|
||||
EOT;
|
||||
return parent::render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user