#SNPlus Yii2 Summernote widget. Summernote v0.8.7 [仅适用于SNPlus]
Yii2 Summernote widget. Super simple WYSIWYG editor on Bootstrap
The preferred way to install this extension is through Composer.
Either run
php composer.phar require iqianfang/yii2-summernote
or add
"iqianfang/yii2-summernote": "dev-master"
to the require section of your composer.json
<?= $form->field($model, 'content')->widget(Summernote::className(), [
'clientOptions' => [
...
]
]); ?>
or
<?= Summernote::widget([
'name' => 'editor_id',
'clientOptions' => [
...
]
]); ?>
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() + '/'; }"),
'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
Aleksandr Zelenin, e-mail: [email protected]
João Marques, e-mail: [email protected]