Yii 2 implementation of Quill, modern WYSIWYG editor.
[size="5"]Quill[/size]
You can find Quill at http://quilljs.com
-
Documentation
-
Examples
-
GitHub
[size="5"]yii2-quill[/size]
[size="4"]Installation[/size]
Easiest way to install this extension is through the Composer.
Add in your composer.json:
"bizley/quill": "*"
or run console command:
php composer.phar require bizley/quill "*"
[size="4"]Usage[/size]
Use it as an active field extension
<?= $form->field($model, $attribute)->widget(bizley\quill\Quill::className(), []) ?>
or as a standalone widget
<?= bizley\quill\Quill::widget(['name' => 'editor']) ?>
[size="4"]Parameters[/size]
-
theme string default âbootstrapâ
false or null for Quillâs default theme with quill.base.css,
âsnowâ for Quillâs snow theme with quill.snow.css,
âbootstrapâ for snow theme with editor wrapped in Bootstrapâs panel
You can set theme in configs array instead but this is the only way to set âbootstrapâ theme.
See Quillâs documentation for themes.
-
toolbar string or array default âfullâ
In case of string:
false or null to switch toolbar off,
âfullâ for full Quillâs toolbar as seen here,
âbasicâ for few basic toolbar options,
anything else for single button (see below).
In case of array:
string element for single button (see below),
array element for buttons grouped together - every element of this array should be string (a single button).
-
configs array default []
Array of Quillâs configuration. This is the equivalent of Quillâs configs variable
[size="4"]Toolbar[/size]
Quill allows you to add your own HTML toolbar for the editor. This is very flexible solution but in most cases you just need to get few standard buttons without worrying about the HTML tags and where and how to properly place them.
With yii2-quill it is quite simple - there are predefined buttons you can use:
-
â|â separator,
-
âbâ bold,
-
âiâ italic,
-
âuâ underline,
-
âsâ strikethrough,
-
âfontâ font family,
-
âsizeâ font size,
-
âtextColorâ font colour,
-
âbackColorâ background colour,
-
âolâ ordered list,
-
âulâ bullet list,
-
âalignmentâ text alignment,
-
âlinkâ link,
-
âimageâ image
With toolbar parameter set to âfullâ all these buttons are added. âbasicâ gives you only âbâ, âiâ, âuâ, âsâ, âolâ, âulâ, âalignmentâ, âlinkâ.
In case you want totally different set of buttons you can set them like:
'toolbar' => ['b', 'i', 'u', '|', 'font', '|', 'alignment'],
If you want to group some buttons together use nested arrays:
'toolbar' => [['b', 'i', 'u'], ['font', 'alignment']],
And donât worry about adding modules in configs for âlinkâ and âimageâ options - this is done automatically.
You may wonder what to do in case of adding some button that is not listed here - simply just put the HTML code of the button inside the toolbar array. And there is still this option to create separate toolbar from the scratch - you can add toolbar module with its containerâs ID in the configs array as seen here.
[size="5"]GitHub repo[/size]