定制 paskuale75/yii2-summernote 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

paskuale75/yii2-summernote

Composer 安装命令:

composer require paskuale75/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

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

<?php
use marqu3s\summernote\Summernote;

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

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

or

<?php
use marqu3s\summernote\Summernote;

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

Bootstrap version

By default \marqu3s\summernote\SummernoteAsset loads Bootstrap 4 compatible Version of Summernote. If you need Boostrap 3 compatible version, configure your application like this:

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

If you need Bootstrap 5 compatible one, the configuration would look like this:

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

Uploading directly to Amazon S3

To upload images inserted into the editor to S3, you have to configure a few options.

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

Then, in your controller, configure an action as the signEndpoint to sign the POST request that will upload the image.

<?php
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'
      ]
   ];
}

See clientOptions

Original Author

Aleksandr Zelenin, e-mail: aleksandr@zelenin.me

Updates by

João Marques, e-mail: joao@jjmf.com

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 31
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固