https://github.com/coderius/yii2-pell-widget
Pell.JS smallest WYSIWYG text editor YIIi2 widget. Text editor for web - only 3.54kB size.
https://github.com/coderius/yii2-pell-widget
Last synced: 14 days ago
JSON representation
Pell.JS smallest WYSIWYG text editor YIIi2 widget. Text editor for web - only 3.54kB size.
- Host: GitHub
- URL: https://github.com/coderius/yii2-pell-widget
- Owner: coderius
- License: mit
- Created: 2019-11-04T19:45:23.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-18T15:47:03.000Z (over 5 years ago)
- Last Synced: 2025-03-25T08:51:20.123Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 262 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
Pell content WYSIWYG editor Widget for Yii2
===========================================[](https://github.com/coderius/yii2-pell-widget/releases)
[](LICENSE.md)
[](https://scrutinizer-ci.com/g/coderius/yii2-pell-widget/?branch=master)
[](https://scrutinizer-ci.com/g/coderius/yii2-pell-widget/?branch=master)
[](https://scrutinizer-ci.com/code-intelligence)
[](https://scrutinizer-ci.com/g/coderius/yii2-pell-widget/build-status/master)
[](https://travis-ci.org/coderius/yii2-pell-widget)Renders a [Pell WYSIWYG text editor plugin](https://github.com/jaredreich/pell) widget.

## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
composer require coderius/yii2-pell-widget:"~1.0"
```
or add```json
"coderius/yii2-pell-widget" : "~1.0"
```to the require section of your application's `composer.json` file.
## Usage
For example to use the pell editor with a [[\yii\base\Model|model]]:
```php
echo Pell::widget([
'model' => $model,
'attribute' => 'text',
]);
```
Inside form without model:```php
$value = 'textarea some content';echo \coderius\pell\Pell::widget([
'name' => 'textarea-name',
'value' => $value,
'clientOptions' =>[]
]);
```The following example will used not as an element of form:
```php
echo Pell::widget([
'asFormPart' => false,
'value' => $value,
'clientOptions' =>[
'onChange' => new JsExpression(
"html => {
console.log(html);
},"
)
]
]);
```
You can also use this widget in an [[\yii\widgets\ActiveForm|ActiveForm]] using the [[\yii\widgets\ActiveField::widget()|widget()]] method, for example like this:```php
use coderius\pell\Pell;
= $form->field($model, 'text')->widget(Pell::className(), []);?>
```### About ClientOptions
Please, remember that if you are required to add javascript to the configuration of the js plugin and is required to be
plain JS, make use of `JsExpression`. That class was made by Yii for that specific purpose. For example:
```php
// Having the following scenario
function jsFunctionToBeCalled() {
// ...
}= $form->field($model, 'content')->widget(Pell::className(), [
'clientOptions' => [
'defaultParagraphSeparato' => 'div',// ...
'actions' => [
'bold',
'italic',
'underline',
'strikethrough',
'heading1',
'heading2',
'paragraph',
'quote',
'olist',
'ulist',
'code',
'line',
'link',
'image',
[
'name' => 'backColor',
'icon' => 'A',
'title' => 'Highlight Color',
// this will render the function name without quotes on the configuration options of the plugin
'result' => new JsExpression('jsFunctionToBeCalled')
],
],
// ...
]
]
]); ?>
```## Examples widget usage
Please see [Examples usage in yii2 view files](https://github.com/coderius/yii2-pell-widget/blob/master/examples/some-yii2-view.php) for more examples.## Testing
``` bash
$ phpunit
```## Further Information
Please, check the [Pell plugin github](https://github.com/jaredreich/pell) documentation for further
information about its configuration options.## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Credits
- [Sergio Coderius](https://github.com/coderius)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
Web development has never been so fun!
[coderius.biz.ua](https://coderius.biz.ua)