szdma / yii2-ueditor-widget
描述
1.21
2017-01-15 06:29 UTC
This package is not auto-updated.
Last update: 2020-10-03 13:53:43 UTC
README
安装
运行以下命令之一
$ php composer.phar require kucha/ueditor "*"
或者
"kucha/ueditor": "*"
将以下内容添加到您的 composer.json 文件的 require 部分中。
应用
控制器
public function actions()
{
return [
'upload' => [
'class' => 'kucha\ueditor\UEditorAction',
]
];
}
视图
echo \kucha\ueditor\UEditor::widget(['name' => 'xxxx']);
或者:
echo $form->field($model,'colum')->widget('kucha\ueditor\UEditor',[]);
说明
ueditor 只支持两种语言,en-us 和 zh-cn,默认跟随系统语言 Yii::$app->language。可以通过以下两种方式设置:1.修改系统语言,在 main.php (高级版) 或 web.php (基础版) 添加 'language' => 'zh-CN',。2.在实例化时配置语言选项,见下文配置。
配置相关
编辑器相关配置,请在 view 中配置,参数为 clientOptions,例如定制菜单,编辑器大小等,具体参数请参考 UEditor 官网文档。
简单实例
use \kucha\ueditor\UEditor;
echo UEditor::widget([
'clientOptions' => [
//编辑区域大小
'initialFrameHeight' => '200',
//设置语言
'lang' =>'en', //中文为 zh-cn
//定制菜单
'toolbars' => [
[
'fullscreen', 'source', 'undo', 'redo', '|',
'fontsize',
'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat',
'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|',
'forecolor', 'backcolor', '|',
'lineheight', '|',
'indent', '|'
],
]
]);
文件上传相关配置,请在 controller 中配置,参数为 config,例如文件上传路径等;更多参数请参考 config.php(与 UEditor 提供的 config.json 相同)。
简单实例
public function actions()
{
return [
'upload' => [
'class' => 'kucha\ueditor\UEditorAction',
'config' => [
"imageUrlPrefix" => "http://www.baidu.com",//图片访问路径前缀
"imagePathFormat" => "/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}" //上传保存路径
"imageRoot" => Yii::getAlias("@webroot"),
],
]
];
}