alexantr/yii2-tinymce

TinyMCE widget for Yii 2

Installs: 644

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 1

Type:yii2-extension

0.1.1 2018-08-08 06:07 UTC

This package is not auto-updated.

Last update: 2020-09-27 12:48:04 UTC


README

This extension renders a TinyMCE widget for Yii framework 2.0.

Latest Stable Version Total Downloads License

Installation

Install extension through composer:

composer require alexantr/yii2-tinymce

Usage

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

<?= alexantr\tinymce\TinyMCE::widget(['name' => 'attributeName']) ?>

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

<?= alexantr\tinymce\TinyMCE::widget([
    'name' => 'attributeName',
    'clientOptions' => [
        'plugins' => ['advlist', 'anchor', 'charmap', 'image', 'hr', 'imagetools', 'link', 'lists', 'media', 'paste', 'table'],
        'height' => 500,
        'convert_urls' => false,
        'invalid_elements' => 'acronym,font,center,nobr,strike,noembed,script,noscript',
    ],
]) ?>

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

<?= $form->field($model, 'attributeName')->widget(alexantr\tinymce\TinyMCE::className()) ?>

Using global configuration (presets)

To avoid repeating identical configuration in every widget you can set global configuration in @app/config/tinymce.php. Options from widget's clientOptions will be merged with this configuration.

You can change default path with presetPath attribute:

<?= alexantr\tinymce\TinyMCE::widget([
    'name' => 'attributeName',
    'presetPath' => '@backend/config/my-tinymce-config.php',
]) ?>