marqu3s/yii2-summernote
最新稳定版本:v1.0.4
Composer 安装命令:
composer require marqu3s/yii2-summernote
包简介
Yii2 Summernote widget. Super simple WYSIWYG editor on Bootstrap
README 文档
README
Yii2 Summernote widget. Super simple WYSIWYG editor on Bootstrap
Installation
Composer
The preferred way to install this extension is through Composer.
Either run
composer require marqu3s/yii2-summernote
or add
"marqu3s/yii2-summernote": "dev-master"
to the require section of your composer.json
Usage
<?= $form->field($model, 'content')->widget(Summernote::className(), [ 'clientOptions' => [ ... ] ]); ?>
or
<?= Summernote::widget([ 'name' => 'editor_id', 'clientOptions' => [ ... ] ]); ?>
Uploading directly to Amazon S3
To upload images inserted into the editor to S3, you have to configure a few options.
<?= Summernote::widget([ 'uploadToS3' => true, 'signEndpoint' => '/<controller>/sign-aws-request?v4=true', 'bucket' => 'S3-BUCKET-NAME', //'folder' => '', 'folder' => new \yii\web\JsExpression("function() { return $('#aFormFieldId').val() + '/'; }"), 'filenamePrefix' => "'{$model->id}-'", 'maxFileSize' => 1024000, 'expiration' => gmdate('Y-m-d\TH:i:s.000\Z', strtotime('+5 minutes')), 'clientOptions' => [ ... ] ]); ?>
Then, in your controller, configure an action as the signEndpoint to sign the POST request that will upload the image.
public function actions() { return [ 'sign-aws-request' => [ 'class' => 'common\actions\SignAwsRequestAction', 'clientPrivateKey' => 'AWS-KEY', 'clientPrivateSecret' => 'AWS-SECRET', 'expectedBucketName' => 'BUCKET-NAME', 'expectedHostName' => 'BUCKET-NAME', 'expectedMaxSize' => 'MAX-FILE-SIZE' ] ]; }
See clientOptions
Original Author
Aleksandr Zelenin, e-mail: aleksandr@zelenin.me
Updates by
João Marques, e-mail: joao@jjmf.com
统计信息
- 总下载量: 87.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 1
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-02-15