PHP code example of simialbi / yii2-summernote

1. Go to this page and download the library: Download simialbi/yii2-summernote library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

simialbi / yii2-summernote example snippets



use marqu3s\summernote\Summernote;

/** @var $form \yii\widgets\ActiveForm */
/** @var $model \yii\base\Model */

echo $form->field($model, 'content')->widget(Summernote::class, [
    'clientOptions' => [
        // ...
    ]
]);


use marqu3s\summernote\Summernote;

echo Summernote::widget([
    'name' => 'editor_id',
    'clientOptions' => [
        // ...
    ]
]);

'assetManager' => [
    'bundles' => [
        'marqu3s\summernote\SummernoteAsset'   => [
            'css' => [
                'summernote.css'
            ],
            'js' => [
                'summernote.js'
            ], 
            'depends' => [
                'yii\bootstrap\BootstrapPluginAsset',
            ]
        ]
    ]
]

'assetManager' => [
    'bundles' => [
        'marqu3s\summernote\SummernoteAsset'   => [
            'css' => [
                'summernote-bs5.css'
            ],
            'js' => [
                'summernote-bs5.js'
            ], 
            'depends' => [
                'yii\bootstrap\BootstrapPluginAsset',
            ]
        ]
    ]
]


use marqu3s\summernote\Summernote;

/** @var $model \yii\base\Model */

echo 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' => [
        ...
    ]
]);


public function actions()
{
   return [
      'sign-aws-request' => [
          'class' => 'marqu3s\summernote\actions\SignAwsRequestAction',
          'clientPrivateKey' => 'AWS-KEY',
          'clientPrivateSecret' => 'AWS-SECRET',
          'expectedBucketName' => 'BUCKET-NAME',
          'expectedHostName' => 'BUCKET-NAME',
          'expectedMaxSize' => 'MAX-FILE-SIZE'
      ]
   ];
}