您的位置:首页 > 编程语言 > PHP开发

YII2下使用百度编辑器扩展yii2-ueditor

2014-12-25 10:20 615 查看
<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: