Giter VIP home page Giter VIP logo

yii2-summernote's Introduction

Yii2 Summernote widget. Summernote 0.8.0

Yii2 Summernote widget. Super simple WYSIWYG editor on Bootstrap

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require marqu3s/yii2-summernote "dev-master"

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: [email protected]

Updates by

João Marques, e-mail: [email protected]

yii2-summernote's People

Contributors

marqu3s avatar zelenin avatar renanvalente avatar siamskoi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.