2017 © Pedro Peláez
 

yii2-extension yii2-tinymce

TinyMCE widget for Yii 2

image

alexantr/yii2-tinymce

TinyMCE widget for Yii 2

  • Monday, February 19, 2018
  • by alexantr
  • Repository
  • 1 Watchers
  • 2 Stars
  • 77 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 64 % Grown

The README.md

TinyMCE widget for Yii 2

This extension renders a TinyMCE widget for Yii framework 2.0., (*1)

Latest Stable Version Total Downloads License, (*2)

Installation

Install extension through composer:, (*3)

composer require alexantr/yii2-tinymce

Note: By default, the latest TinyMCE 5 will be installed. But you can install 4.x version manually:, (*4)

composer require "tinymce/tinymce:^4.8"

Usage

The following code in a view file would render a TinyMCE widget:, (*5)

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

Configuring the TinyMCE options should be done using the clientOptions attribute:, (*6)

<?= alexantr\tinymce\TinyMCE::widget([
    'name' => 'attributeName',
    'clientOptions' => [
        'plugins' => [
            'anchor', 'charmap', 'code', 'help', 'hr',
            'image', 'link', 'lists', 'media', 'paste',
            'searchreplace', 'table',
        ],
        'height' => 500,
        'convert_urls' => false,
        'element_format' => 'html',
        // ...
    ],
]) ?>

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

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

Using presets

To avoid repeating identical configuration in every widget you can create preset in @app/config/tinymce.php. Options from widget's clientOptions will be merged with this configuration., (*8)

Preset example:, (*9)

<?php
return [
    'plugins' => [
        'anchor', 'charmap', 'code', 'help', 'hr',
        'image', 'link', 'lists', 'media', 'paste',
        'searchreplace', 'table',
    ],
    'height' => 500,
    'convert_urls' => false,
    'element_format' => 'html',
    'image_caption' => true,
    'keep_styles' => false,
    'paste_block_drop' => true,
    'table_default_attributes' => new yii\web\JsExpression('{}'),
    'table_default_styles' => new yii\web\JsExpression('{}'),
    'invalid_elements' => 'acronym,font,center,nobr,strike,noembed,script,noscript',
    'extended_valid_elements' => 'strong/b,em/i,table[style]',
    // elFinder file manager https://github.com/alexantr/yii2-elfinder
    'file_picker_callback' => alexantr\elfinder\TinyMCE::getFilePickerCallback(['elfinder/tinymce']),
];

You can change default path with presetPath attribute:, (*10)

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

The Versions

19/02 2018

dev-master

9999999-dev

TinyMCE widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 widget tinymce editor wysiwyg

19/02 2018

0.1.0

0.1.0.0

TinyMCE widget for Yii 2

  Sources   Download

MIT

The Requires

 

yii2 widget tinymce editor wysiwyg