lichv / laravel-ueditor
laravel5的UEditor。支持国际化。UEditor是百度提供的富文本Web编辑器。
0.2
2017-02-07 02:14 UTC
Requires
- php: >=5.4.0
- ext-fileinfo: *
- aliyuncs/oss-sdk-php: ^2.0
- illuminate/support: 5.*
This package is not auto-updated.
Last update: 2024-09-28 19:42:22 UTC
README
## 安装
PHP 5.4+ 和 Composer 是必需的。
要获取 Laravel Exceptions 的最新版本,只需将以下行添加到 composer.json 文件的 require 块中
"lichv/laravel-ueditor": "^0.1"
然后运行 composer install 或 composer update 来下载它并更新自动加载器。
安装 Laravel Exceptions 后,您需要注册服务提供者。打开 config/app.php 并将以下内容添加到 providers 键中。
'Lichv\UEditor\UEditorServiceProvider'
然后运行
php artisan vendor:publish
## 配置
如果以上安装没有问题,自定义项目配置文件会在 config/laravel-u-editor.php (会自动生成)
'core' => [
'route' => [
'middleware' => 'auth',
],
],
中间件非常重要,请根据自己的项目设置,例如,如果在后台使用,请设置为后台的 auth middleware。如果是单纯本机测试,请将 // 'middleware' => 'auth', 直接注释掉,如果留 'middleware'=>''空值,会产生bug,原因不详。
所有UEditor的官方资源都会放在 public/laravel-u-editor/ ,可以根据自己的需求进行更改。
使用
在您的块中只需放入
@include('UEditor::head');
它将需要资源。
如果需要,您可以更改 resources\views\vendor\UEditor\head.blade.php 以适应您的定制。
好了,一切都准备好了。现在就可以使用UEditor了。
<!-- 加载编辑器的容器 -->
<script id="container" name="content" type="text/plain">
这里写你的初始化内容
</script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
var ue = UE.getEditor('container');
ue.ready(function() {
ue.execCommand('serverparam', '_token', '{{ csrf_token() }}');//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
});
</script>