myzero1/yii2-ckeditor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

myzero1/yii2-ckeditor

最新稳定版本:4.11.2

Composer 安装命令:

composer require myzero1/yii2-ckeditor

包简介

CKEditor widget for Yii 2

README 文档

README

This extension renders a CKEditor widget for Yii framework 2.0.

License

Installation

Install extension through composer:

Either run

php composer.phar require "myzero1/yii2-ckeditor" "*"

or add

"myzero1/yii2-ckeditor" : "*"

to the require section of your application's composer.json file.

Config the action for upload

Add the section of your application's main.json file, as flowing:


return [
    ......
    'controllerNamespace' => 'backend\controllers',
    'controllerMap' => [
        'ckeditor' => [
            'class' => 'myzero1\ckeditor\CKditorController',
            'config' => [
                'imageFieldName' => 'upload',
                'imageMaxSize' => 1024*1024*2, // 2M = 1024*1024*2
                'imageAllowFiles' => ['.jpg', '.jpeg', '.png', '.gif'],
                'imagePathFormat' => '/upload/image/{yyyy}{mm}{dd}/{time}{rand:8}',
            ],
        ]
    ],
    'bootstrap' => ['log'],
    ......

Usage

The following code in a view file would render a CKEditor widget:

<?= myzero1\ckeditor\CKEditor::widget(['name' => 'attributeName']) ?>

Configuring the CKEditor options should be done using the clientOptions attribute:

<?= myzero1\ckeditor\CKEditor::widget([
    'name' => 'attributeName',
    'clientOptions' => [
        'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,preview,image2',
        // 'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,preview,easyimage',
        'removePlugins' => 'resize,image',
        'autoGrow_maxHeight' => 900,
        'stylesSet' => [
            ['name' => 'Subscript', 'element' => 'sub'],
            ['name' => 'Superscript', 'element' => 'sup'],
        ],
    ],
]) ?>

If you want to use the CKEditor widget in an ActiveForm, it can be done like this:

<?= $form->field($model, 'attributeName')->widget(myzero1\ckeditor\CKEditor::className()) ?>

If you want to use the CKEditor widget in an ActiveForm,and to configuring the CKEditor options, it can be done like this:

<?= $form->field($model, 'attributeName')->widget(myzero1\ckeditor\CKEditor::className(), [
        'clientOptions' => [
            'selectMultiple' => true,
            'filebrowserImageUploadUrl' => '/ckeditor/upload-image',
            'imageUploadUrl' => '/ckeditor/upload-image',
            'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,preview,image2',
            // 'extraPlugins' => 'autogrow,colorbutton,colordialog,iframe,justify,showblocks,image2,preview,easyimage',
            'removePlugins' => 'resize,image',
            'autoGrow_maxHeight' => 900,
            'stylesSet' => [
                ['name' => 'Subscript', 'element' => 'sub'],
                ['name' => 'Superscript', 'element' => 'sup'],
            ],
        ],
    ]) ?>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-03