<span style="font-size:18px;color:#ff0000;"><strong>yii2-ueditor的安装</strong></span>
Yii2是使用composer来管理扩展的
Composer地址:
https://packagist.org/packages/wenyuan/yii2-ueditor
Git 地址:
https://github.com/liucunzhou/yii2-ueditor
composer如果是在path中的话可以直接
composer require --prefer-dist wenyuan/yii2-ueditor "*"
如果不想使用composer来管理扩展的话,也可以直接修改vendor/composer/autoload_psr4.php
前提是源码目录vendor/wenyuan/yii2-ueditor/源码
return array(
// 添加下面的代码
'wenyuan\\ueditor\\' => array($vendorDir . '/wenyuan/yii2-ueditor')
);
yii2-ueditor的使用
单个百度编辑器的使用
use wenyuan\ueditor\Ueditor;
echo Ueditor::widget(['id'=>'newstext1']);
多个编辑器的使用
use wenyuan\ueditor\Ueditor;
echo Ueditor::widget(['id'=>'newstext1']);
echo Ueditor::widget(['id'=>'newstext2']);
自定义编辑器功能模块
use wenyuan\ueditor\Ueditor;
echo Ueditor::widget(
[
'id'=>'newstext1',
'options' => [
'toolbars' => [
['fullscreen', 'source', 'undo', 'redo', 'bold'],
],
'autoHeightEnabled' => true,
'autoFloadEnabled' => true
]
]
);
其中id的作用
<script type="text/plain" id="newstext1" name="newstext1"></script>