├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── composer.json └── src ├── CKEditor.php ├── CKEditorAsset.php ├── CKEditorInline.php ├── CKEditorTrait.php ├── CKEditorWidgetAsset.php ├── KCFinderAsset.php ├── assets └── dosamigos-ckeditor.widget.js └── presets ├── basic.php ├── full.php └── standard.php /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/2amigos/yii2-ckeditor-widget). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer). 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ phpunit 29 | ``` 30 | 31 | 32 | **Happy coding**! 33 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The BSD License (BSD) 2 | 3 | Copyright (c) 2013-2015, 2amigOS! Consulting Group LLC. 4 | 5 | > Redistribution and use in source and binary forms, with or without modification, 6 | > are permitted provided that the following conditions are met: 7 | > 8 | > Redistributions of source code must retain the above copyright notice, this 9 | > list of conditions and the following disclaimer. 10 | > 11 | > Redistributions in binary form must reproduce the above copyright notice, this 12 | > list of conditions and the following disclaimer in the documentation and/or 13 | > other materials provided with the distribution. 14 | > 15 | > Neither the name of 2amigOS! Consulting Group, LLC. nor the names of its 16 | > contributors may be used to endorse or promote products derived from 17 | > this software without specific prior written permission. 18 | > 19 | >THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | >ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | >WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | >DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 23 | >ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | >(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | >LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | >ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | >(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | >SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | CKEditor Widget for Yii2 2 | ======================== 3 | 4 | [![Latest Version](https://img.shields.io/github/tag/2amigos/yii2-ckeditor-widget.svg?style=flat-square&label=release)](https://github.com/2amigos/yii2-ckeditor-widget/tags) 5 | [![Software License](https://img.shields.io/badge/license-BSD-brightgreen.svg?style=flat-square)](LICENSE.md) 6 | [![Build Status](https://img.shields.io/travis/2amigos/yii2-ckeditor-widget/master.svg?style=flat-square)](https://travis-ci.org/2amigos/yii2-ckeditor-widget) 7 | [![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/2amigos/yii2-ckeditor-widget.svg?style=flat-square)](https://scrutinizer-ci.com/g/2amigos/yii2-ckeditor-widget/code-structure) 8 | [![Quality Score](https://img.shields.io/scrutinizer/g/2amigos/yii2-ckeditor-widget.svg?style=flat-square)](https://scrutinizer-ci.com/g/2amigos/yii2-ckeditor-widget) 9 | [![Total Downloads](https://img.shields.io/packagist/dt/2amigos/yii2-ckeditor-widget.svg?style=flat-square)](https://packagist.org/packages/2amigos/yii2-ckeditor-widget) 10 | 11 | Renders a [CKEditor WYSIWYG text editor plugin](http://www.ckeditor.com) widget. 12 | 13 | Installation 14 | ------------ 15 | The preferred way to install this extension is through [composer](http://getcomposer.org/download/). 16 | 17 | Either run 18 | 19 | ``` 20 | composer require 2amigos/yii2-ckeditor-widget 21 | ``` 22 | or add 23 | 24 | ```json 25 | "2amigos/yii2-ckeditor-widget" : "~2.1" 26 | ``` 27 | 28 | to the require section of your application's `composer.json` file. 29 | 30 | Skins & Plugins 31 | --------------- 32 | 33 | This widget works with default's `dev-full/stable` branch of CKEditor, with a set of plugins and skins. If you wish to 34 | configure a different skins or plugins that the one proposed, you will have to download them separately and configure 35 | the widget's `clientOptions` attribute accordingly. 36 | 37 | 38 | Usage 39 | ----- 40 | The library comes with two widgets: `CKEditor` and `CKEditorInline`. One is for classic edition and the other for inline 41 | editing respectively. 42 | 43 | Using a model with a basic preset: 44 | 45 | ``` 46 | 47 | use dosamigos\ckeditor\CKEditor; 48 | 49 | 50 | field($model, 'text')->widget(CKEditor::className(), [ 51 | 'options' => ['rows' => 6], 52 | 'preset' => 'basic' 53 | ]) ?> 54 | ``` 55 | Using inline edition with basic preset: 56 | 57 | ``` 58 | 59 | use dosamigos\ckeditor\CKEditorInline; 60 | 61 | 'basic']);?> 62 | This text can be edited now :) 63 | 64 | ``` 65 | 66 | How to add custom plugins 67 | ------------------------- 68 | This is the way to add custom plugins to the editor. Since version 2.0 we are working with the packagist version of the 69 | CKEditor library, therefore we are required to use its configuration API in order to add external plugins. 70 | 71 | Lets add the popular [Code Editor Plugin](http://ckeditor.com/addon/pbckcode) for example. This plugin would allow us to 72 | add a button to our editor's toolbar so we can add code to the content we are editing. 73 | 74 | Assuming you have downloaded the plugin and added to the root directory of your Yii2 site. I have it this way: 75 | 76 |
 77 | + frontend 
 78 | + -- web 
 79 |     + -- pbckcode 
 80 | 
81 | 82 | We can now add it to our CKEditor widget. For this example I am using `CKEditorInline` widget. One thing you notice on 83 | this example is that we do not use the preset attribute; this is highly important as we want to add a customized toolbar to our 84 | widget. No more talking, here is the code: 85 | 86 | ```php 87 | registerJs("CKEDITOR.plugins.addExternal('pbckcode', '/pbckcode/plugin.js', '');"); 93 | 94 | // ... 95 | // Using the plugin 96 | 'custom', 'clientOptions' => [ 97 | 'extraPlugins' => 'pbckcode', 98 | 'toolbarGroups' => [ 99 | ['name' => 'undo'], 100 | ['name' => 'basicstyles', 'groups' => ['basicstyles', 'cleanup']], 101 | ['name' => 'colors'], 102 | ['name' => 'links', 'groups' => ['links', 'insert']], 103 | ['name' => 'others', 'groups' => ['others', 'about']], 104 | 105 | ['name' => 'pbckcode'] // <--- OUR NEW PLUGIN YAY! 106 | ] 107 | ]]) ?> 108 | 109 |

110 | Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et 111 | dolore magna aliqua. 112 |

113 | 114 | ``` 115 | 116 | Browse & Upload 117 | --------------- 118 | To browse and upload files, the [KCFinder](https://kcfinder.sunhater.com/) plugin is used, which is disabled by default. 119 | 120 | To enable it, just use `'kcfinder'=>true`. 121 | 122 | See this simple example code: 123 | 124 | ```php 125 | field($model, 'text')->widget(CKEditor::className(), [ 129 | 'kcfinder' => true, 130 | ]); 131 | ``` 132 | 133 | The upload folder name is `upload` in the root web directory by default. 134 | 135 | You can set options for the `kcfOptions` parameter, and can find all KCFinder's options in this link: [https://kcfinder.sunhater.com/install](https://kcfinder.sunhater.com/install) 136 | 137 | For change upload directory or change some options you can see this advanced example code: 138 | 139 | ```php 140 | field($model, 'text')->widget(CKEditor::className(), [ 144 | 'kcfinder' => true, 145 | 'kcfOptions' => [ 146 | 'uploadURL' => '@web/upload', 147 | 'uploadDir' => '@webroot/upload', 148 | 'access' => [ // @link http://kcfinder.sunhater.com/install#_access 149 | 'files' => [ 150 | 'upload' => true, 151 | 'delete' => true, 152 | 'copy' => true, 153 | 'move' => true, 154 | 'rename' => true, 155 | ], 156 | 'dirs' => [ 157 | 'create' => true, 158 | 'delete' => true, 159 | 'rename' => true, 160 | ], 161 | ], 162 | 'types' => [ // @link http://kcfinder.sunhater.com/install#_types 163 | 'files' => [ 164 | 'type' => '', 165 | ], 166 | ], 167 | ], 168 | ]); 169 | ``` 170 | 171 | About extra assets 172 | ------------------ 173 | You maybe wonder why there is file `dosamigos-ckeditor.widget.js`. The reason is that due to the way Yii2 works with 174 | forms and Cross-Site Request Forgery (csrf). CKEditor does not trigger the on change event nor collects the CSRF token 175 | when using file uploads. 176 | 177 | The asset tackles both issues. 178 | 179 | Testing 180 | ------- 181 | 182 | To test the extension, is better to clone this repository on your computer. After, go to the extensions folder and do 183 | the following (assuming you have `composer` installed on your computer): 184 | 185 | ```bash 186 | $ composer install --no-interaction --prefer-source --dev 187 | ``` 188 | Once all required libraries are installed then do: 189 | 190 | ```bash 191 | $ vendor/bin/phpunit 192 | ``` 193 | 194 | Further Information 195 | ------------------- 196 | Please, check the [CKEditor plugin site](http://www.ckeditor.com) documentation for further information about its configuration options. 197 | 198 | Contributing 199 | ------------ 200 | 201 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 202 | 203 | Credits 204 | ------- 205 | 206 | - [Antonio Ramirez](https://github.com/tonydspaniard) 207 | - [All Contributors](../../contributors) 208 | 209 | License 210 | ------- 211 | 212 | The BSD License (BSD). Please see [License File](LICENSE.md) for more information. 213 | 214 | 215 | > [![2amigOS!](http://www.gravatar.com/avatar/55363394d72945ff7ed312556ec041e0.png)](http://www.2amigos.us) 216 | Web development has never been so fun! 217 | [www.2amigos.us](http://www.2amigos.us) 218 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "2amigos/yii2-ckeditor-widget", 3 | "description": "CKEditor widget for Yii2.", 4 | "type": "yii2-extension", 5 | "keywords": [ 6 | "2amigos", 7 | "yii", 8 | "yii2", 9 | "yii 2", 10 | "extension", 11 | "widget", 12 | "ckeditor" 13 | ], 14 | "homepage": "http://yiiwheels.com/extension/ckeditor-widget", 15 | "license": "BSD-3-Clause", 16 | "minimum-stability": "dev", 17 | "prefer-stable": true, 18 | "authors": [ 19 | { 20 | "name": "2amigOS! Consulting Group", 21 | "email": "hola@2amigos.us", 22 | "homepage": "http://2amigos.us", 23 | "role": "Developer" 24 | } 25 | ], 26 | "support": { 27 | "issues": "https://github.com/2amigos/yii2-ckeditor-widget/issues", 28 | "source": "https://github.com/2amigos/yii2-ckeditor-widget" 29 | }, 30 | "require": { 31 | "yiisoft/yii2": "^2.0", 32 | "ckeditor/ckeditor": "^4.7 || dev-full/4.11.x", 33 | "sunhater/kcfinder": "*" 34 | }, 35 | "require-dev": { 36 | "phpunit/phpunit": "4.*", 37 | "roave/security-advisories": "dev-master" 38 | }, 39 | "autoload": { 40 | "psr-4": { 41 | "dosamigos\\ckeditor\\": "src" 42 | } 43 | }, 44 | "config": { 45 | "fxp-asset": { 46 | "installer-paths": { 47 | "npm-asset-library": "vendor/npm" 48 | } 49 | } 50 | }, 51 | "extra": { 52 | "branch-alias": { 53 | "dev-master": "1.0-dev" 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/CKEditor.php: -------------------------------------------------------------------------------- 1 | 17 | * @link http://www.ramirezcobos.com/ 18 | * @link http://www.2amigos.us/ 19 | * @package dosamigos\ckeditor 20 | */ 21 | class CKEditor extends InputWidget 22 | { 23 | use CKEditorTrait; 24 | 25 | /** 26 | * @inheritdoc 27 | */ 28 | public function init() 29 | { 30 | parent::init(); 31 | $this->initOptions(); 32 | } 33 | 34 | /** 35 | * @inheritdoc 36 | */ 37 | public function run() 38 | { 39 | if ($this->hasModel()) { 40 | echo Html::activeTextarea($this->model, $this->attribute, $this->options); 41 | } else { 42 | echo Html::textarea($this->name, $this->value, $this->options); 43 | } 44 | $this->registerPlugin(); 45 | } 46 | 47 | /** 48 | * Registers CKEditor plugin 49 | * @codeCoverageIgnore 50 | */ 51 | protected function registerPlugin() 52 | { 53 | $js = []; 54 | 55 | $view = $this->getView(); 56 | 57 | CKEditorWidgetAsset::register($view); 58 | 59 | $id = $this->options['id']; 60 | 61 | $options = $this->clientOptions !== false && !empty($this->clientOptions) 62 | ? Json::encode($this->clientOptions) 63 | : '{}'; 64 | 65 | $js[] = "CKEDITOR.replace('$id', $options);"; 66 | $js[] = "dosamigos.ckEditorWidget.registerOnChangeHandler('$id');"; 67 | 68 | if (isset($this->clientOptions['filebrowserUploadUrl']) || isset($this->clientOptions['filebrowserImageUploadUrl'])) { 69 | $js[] = "dosamigos.ckEditorWidget.registerCsrfImageUploadHandler();"; 70 | } 71 | 72 | $view->registerJs(implode("\n", $js)); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/CKEditorAsset.php: -------------------------------------------------------------------------------- 1 | 15 | * @link http://www.ramirezcobos.com/ 16 | * @link http://www.2amigos.us/ 17 | * @package dosamigos\ckeditor 18 | */ 19 | class CKEditorAsset extends AssetBundle 20 | { 21 | public $sourcePath = '@vendor/ckeditor/ckeditor/'; 22 | public $js = [ 23 | 'ckeditor.js', 24 | 'adapters/jquery.js' 25 | ]; 26 | public $depends = [ 27 | 'yii\web\YiiAsset', 28 | 'yii\web\JqueryAsset' 29 | ]; 30 | } 31 | -------------------------------------------------------------------------------- /src/CKEditorInline.php: -------------------------------------------------------------------------------- 1 | 17 | * @link http://www.ramirezcobos.com/ 18 | * @link http://www.2amigos.us/ 19 | * @package dosamigos\ckeditor 20 | */ 21 | class CKEditorInline extends Widget 22 | { 23 | use CKEditorTrait; 24 | 25 | /** 26 | * @var array the HTML attributes for the input tag. 27 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. 28 | */ 29 | public $options = []; 30 | /** 31 | * @var string 32 | */ 33 | public $tag = 'div'; 34 | /** 35 | * @var bool disables creating the inline editor automatically for elements with contenteditable attribute 36 | * set to the true. Defaults to true. 37 | */ 38 | public $disableAutoInline = true; 39 | 40 | /** 41 | * @inheritdoc 42 | */ 43 | public function init() 44 | { 45 | if (!isset($this->options['id'])) { 46 | $this->options['id'] = $this->getId(); 47 | } 48 | $this->options['contenteditable'] = 'true'; 49 | 50 | parent::init(); 51 | 52 | $this->initOptions(); 53 | 54 | echo Html::beginTag($this->tag, $this->options); 55 | } 56 | 57 | /** 58 | * @inheritdoc 59 | */ 60 | public function run() 61 | { 62 | echo Html::endTag($this->tag); 63 | 64 | $this->registerPlugin(); 65 | } 66 | 67 | /** 68 | * Registers CKEditor plugin 69 | * @codeCoverageIgnore 70 | */ 71 | protected function registerPlugin() 72 | { 73 | $js = []; 74 | 75 | $view = $this->getView(); 76 | 77 | CKEditorAsset::register($view); 78 | 79 | $id = $this->options['id']; 80 | 81 | $options = $this->clientOptions !== false && !empty($this->clientOptions) 82 | ? Json::encode($this->clientOptions) 83 | : '{}'; 84 | 85 | if ($this->disableAutoInline) { 86 | $js[] = "CKEDITOR.disableAutoInline = true;"; 87 | } 88 | $js[] = "CKEDITOR.inline('$id', $options);"; 89 | 90 | if (isset($this->clientOptions['filebrowserUploadUrl'])) { 91 | $js[] = "dosamigos.ckEditorWidget.registerCsrfImageUploadHandler();"; 92 | } 93 | 94 | $view->registerJs(implode("\n", $js)); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/CKEditorTrait.php: -------------------------------------------------------------------------------- 1 | 16 | * @link http://www.ramirezcobos.com/ 17 | * @link http://www.2amigos.us/ 18 | * @package dosamigos\ckeditor 19 | */ 20 | trait CKEditorTrait 21 | { 22 | /** 23 | * @var string the toolbar preset. It can be any of the following: 24 | * 25 | * - basic: will load the configuration on presets/basic.php 26 | * - full: will load the configuration on presets/full.php 27 | * - standard: will load the configuration on presets/standard.php 28 | * - custom: configuration will be based on [[clientOptions]]. 29 | * 30 | * Defaults to 'standard'. It is important to note that any configuration item of the loaded presets can be 31 | * overrided by [[clientOptions]] 32 | */ 33 | public $preset = 'standard'; 34 | 35 | /** 36 | * Enable or disable kcfinder 37 | * @link https://kcfinder.sunhater.com 38 | * @var boolean 39 | */ 40 | public $kcfinder = false; 41 | 42 | /** 43 | * KCFinder dynamic settings (using session) 44 | * @link http://kcfinder.sunhater.com/install#dynamic 45 | * @var array 46 | */ 47 | public $kcfOptions = []; 48 | 49 | /** 50 | * KCFinder default dynamic settings 51 | * @link http://kcfinder.sunhater.com/install#dynamic 52 | * @var array 53 | */ 54 | public static $kcfDefaultOptions = [ 55 | 'disabled' => false, 56 | 'uploadURL' => '@web/upload', 57 | 'uploadDir' => '@webroot/upload', 58 | 'denyZipDownload' => true, 59 | 'denyUpdateCheck' => true, 60 | 'denyExtensionRename' => true, 61 | 'theme' => 'default', 62 | 'access' => [ // @link http://kcfinder.sunhater.com/install#_access 63 | 'files' => [ 64 | 'upload' => true, 65 | 'delete' => true, 66 | 'copy' => true, 67 | 'move' => true, 68 | 'rename' => true, 69 | ], 70 | 'dirs' => [ 71 | 'create' => true, 72 | 'delete' => true, 73 | 'rename' => true, 74 | ], 75 | ], 76 | 'types' => [ // @link http://kcfinder.sunhater.com/install#_types 77 | 'files' => [ 78 | 'type' => '', 79 | ], 80 | ], 81 | 'thumbsDir' => '.thumbs', 82 | 'thumbWidth' => 100, 83 | 'thumbHeight' => 100, 84 | ]; 85 | 86 | /** 87 | * @var array the options for the CKEditor 4 JS plugin. 88 | * Please refer to the CKEditor 4 plugin Web page for possible options. 89 | * @see http://docs.ckeditor.com/#!/guide/dev_installation 90 | */ 91 | public $clientOptions = []; 92 | 93 | /** 94 | * Initializes the widget options. 95 | * This method sets the default values for various options. 96 | */ 97 | protected function initOptions() 98 | { 99 | if ($this->kcfinder) { 100 | $this->registerKCFinder(); 101 | } 102 | 103 | $options = []; 104 | switch ($this->preset) { 105 | case 'custom': 106 | $preset = null; 107 | break; 108 | case 'basic': 109 | case 'full': 110 | case 'standard': 111 | $preset = 'presets/' . $this->preset . '.php'; 112 | break; 113 | default: 114 | $preset = 'presets/standard.php'; 115 | } 116 | if ($preset !== null) { 117 | $options = require($preset); 118 | } 119 | $this->clientOptions = ArrayHelper::merge($options, $this->clientOptions); 120 | } 121 | 122 | /** 123 | * Registers KCFinder (@link https://kcfinder.sunhater.com) 124 | * @author Nabi KaramAliZadeh kcfOptions = array_merge(self::$kcfDefaultOptions, $this->kcfOptions); 130 | 131 | $this->kcfOptions['uploadURL'] = Yii::getAlias($this->kcfOptions['uploadURL']); 132 | $this->kcfOptions['uploadDir'] = Yii::getAlias($this->kcfOptions['uploadDir']); 133 | 134 | Yii::$app->session['KCFINDER'] = $this->kcfOptions; 135 | 136 | $register = KCFinderAsset::register($this->view); 137 | $kcfinderUrl = $register->baseUrl; 138 | 139 | $browseOptions = [ 140 | 'filebrowserBrowseUrl' => $kcfinderUrl . '/browse.php?opener=ckeditor&type=files', 141 | 'filebrowserUploadUrl' => $kcfinderUrl . '/upload.php?opener=ckeditor&type=files', 142 | ]; 143 | 144 | $this->clientOptions = ArrayHelper::merge($browseOptions, $this->clientOptions); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/CKEditorWidgetAsset.php: -------------------------------------------------------------------------------- 1 | 15 | * @link http://www.ramirezcobos.com/ 16 | * @link http://www.2amigos.us/ 17 | * @package dosamigos\ckeditor 18 | */ 19 | class CKEditorWidgetAsset extends AssetBundle 20 | { 21 | public $sourcePath = '@vendor/2amigos/yii2-ckeditor-widget/src/assets/'; 22 | 23 | public $depends = [ 24 | 'dosamigos\ckeditor\CKEditorAsset' 25 | ]; 26 | 27 | public $js = [ 28 | 'dosamigos-ckeditor.widget.js' 29 | ]; 30 | } 31 | -------------------------------------------------------------------------------- /src/KCFinderAsset.php: -------------------------------------------------------------------------------- 1 | 4 | * @link http://www.nabi.ir 5 | * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 6 | */ 7 | namespace dosamigos\ckeditor; 8 | 9 | use yii\web\AssetBundle; 10 | 11 | class KCFinderAsset extends AssetBundle 12 | { 13 | public $sourcePath = '@vendor/sunhater/kcfinder'; 14 | } 15 | -------------------------------------------------------------------------------- /src/assets/dosamigos-ckeditor.widget.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @copyright Copyright (c) 2012-2015 2amigOS! Consulting Group LLC 3 | * @link http://2amigos.us 4 | * @license http://www.opensource.org/licenses/bsd-license.php New BSD License 5 | */ 6 | if (typeof dosamigos == "undefined" || !dosamigos) { 7 | var dosamigos = {}; 8 | } 9 | 10 | dosamigos.ckEditorWidget = (function ($) { 11 | 12 | var pub = { 13 | registerOnChangeHandler: function (id) { 14 | CKEDITOR && CKEDITOR.instances[id] && CKEDITOR.instances[id].on('change', function () { 15 | CKEDITOR.instances[id].updateElement(); 16 | $('#' + id).trigger('change'); 17 | return false; 18 | }); 19 | }, 20 | registerCsrfImageUploadHandler: function () { 21 | yii & $(document).off('click', '.cke_dialog_tabs a[id^="cke_Upload_"]').on('click', '.cke_dialog_tabs a[id^="cke_Upload_"]', function () { 22 | var $forms = $('.cke_dialog_ui_input_file iframe').contents().find('form'); 23 | var csrfName = yii.getCsrfParam(); 24 | $forms.each(function () { 25 | if (!$(this).find('input[name=' + csrfName + ']').length) { 26 | var csrfTokenInput = $('').attr({ 27 | 'type': 'hidden', 28 | 'name': csrfName 29 | }).val(yii.getCsrfToken()); 30 | $(this).append(csrfTokenInput); 31 | } 32 | }); 33 | }); 34 | } 35 | }; 36 | return pub; 37 | })(jQuery); 38 | -------------------------------------------------------------------------------- /src/presets/basic.php: -------------------------------------------------------------------------------- 1 | 8 | * @link http://www.ramirezcobos.com/ 9 | * @link http://www.2amigos.us/ 10 | */ 11 | return [ 12 | 'height' => 200, 13 | 'toolbarGroups' => [ 14 | ['name' => 'undo'], 15 | ['name' => 'basicstyles', 'groups' => ['basicstyles', 'cleanup']], 16 | ['name' => 'colors'], 17 | ['name' => 'links', 'groups' => ['links', 'insert']], 18 | ['name' => 'others', 'groups' => ['others', 'about']], 19 | ], 20 | 'removeButtons' => 'Subscript,Superscript,Flash,Table,HorizontalRule,Smiley,SpecialChar,PageBreak,Iframe', 21 | 'removePlugins' => 'elementspath', 22 | 'resize_enabled' => false 23 | ]; 24 | -------------------------------------------------------------------------------- /src/presets/full.php: -------------------------------------------------------------------------------- 1 | 7 | * @link http://www.ramirezcobos.com/ 8 | * @link http://www.2amigos.us/ 9 | */ 10 | return [ 11 | 'height' => 400, 12 | 'toolbarGroups' => [ 13 | ['name' => 'document', 'groups' => ['mode', 'document', 'doctools']], 14 | ['name' => 'clipboard', 'groups' => ['clipboard', 'undo']], 15 | ['name' => 'editing', 'groups' => [ 'find', 'selection', 'spellchecker']], 16 | ['name' => 'forms'], 17 | '/', 18 | ['name' => 'basicstyles', 'groups' => ['basicstyles', 'colors','cleanup']], 19 | ['name' => 'paragraph', 'groups' => [ 'list', 'indent', 'blocks', 'align', 'bidi' ]], 20 | ['name' => 'links'], 21 | ['name' => 'insert'], 22 | '/', 23 | ['name' => 'styles'], 24 | ['name' => 'blocks'], 25 | ['name' => 'colors'], 26 | ['name' => 'tools'], 27 | ['name' => 'others'], 28 | ], 29 | ]; 30 | -------------------------------------------------------------------------------- /src/presets/standard.php: -------------------------------------------------------------------------------- 1 | 7 | * @link http://www.ramirezcobos.com/ 8 | * @link http://www.2amigos.us/ 9 | */ 10 | return [ 11 | 'height' => 300, 12 | 'toolbarGroups' => [ 13 | ['name' => 'clipboard', 'groups' => ['mode', 'undo', 'selection', 'clipboard', 'doctools']], 14 | ['name' => 'editing', 'groups' => ['tools', 'about']], 15 | '/', 16 | ['name' => 'paragraph', 'groups' => ['templates', 'list', 'indent', 'align']], 17 | ['name' => 'insert'], 18 | '/', 19 | ['name' => 'basicstyles', 'groups' => ['basicstyles', 'cleanup']], 20 | ['name' => 'colors'], 21 | ['name' => 'links'], 22 | ['name' => 'others'], 23 | ], 24 | 'removeButtons' => 'Smiley,Iframe' 25 | ]; 26 | --------------------------------------------------------------------------------