2017 © Pedro Peláez
 

yii2-extension yii2-tinymce-widget

TinyMCE widget for Yii2.

image

dominus77/yii2-tinymce-widget

TinyMCE widget for Yii2.

  • Friday, July 27, 2018
  • by dominus77
  • Repository
  • 1 Watchers
  • 1 Stars
  • 332 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 22 Versions
  • 14 % Grown

The README.md

TinyMCE 4 widget for Yii2

Latest Stable Version License Total Downloads, (*1)

Renders a TinyMCE WYSIWYG text editor widget with the support ElFinder Extension for Yii 2, (*2)

Supplements

A plugin TinyMCE-FontAwesome-Plugin that lets you insert FontAwesome icons via TinyMCE., (*3)

A plugin Typografy that lets implement JavaScript typographer in TinyMCE., (*4)

Installation

The preferred way to install this extension is through composer., (*5)

Either run, (*6)

composer require dominus77/yii2-tinymce-widget

or add, (*7)

"dominus77/yii2-tinymce-widget": "^2.1"

to the require section of your composer.json file., (*8)

Usage

Once the extension is installed, simply use it in your code by :, (*9)

= $form->field($model, 'text')->widget(\dominus77\tinymce\TinyMce::class, [    
    'options' => [
        'rows' => 6,
        'placeholder' => true,
    ], 
    'language' => 'ru',
    'clientOptions' => [
        'menubar' => true,
        'statusbar' => true,        
        'theme' => 'modern',
        'skin' => 'lightgray-gradient', //charcoal, tundora, lightgray-gradient, lightgray
        'plugins' => [
            'typograf advlist autolink lists link image charmap print preview hr anchor pagebreak placeholder',
            'searchreplace wordcount visualblocks visualchars code fullscreen',
            'insertdatetime media nonbreaking save table contextmenu directionality',
            'emoticons template paste textcolor colorpicker textpattern imagetools codesample toc noneditable',
        ],
        'contextmenu' => 'typograf | link image inserttable | cell row column deletetable',
        'noneditable_noneditable_class' => 'fa',
        'extended_valid_elements' => 'span[class|style]',
        'toolbar1' => 'undo redo | insert | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
        'toolbar2' => 'print preview media | forecolor backcolor emoticons | codesample | typograf',
        'image_advtab' => true,
        'templates' => [
            [
                'title' => 'Test template 1',
                'content' => 'Test 1',
            ],
            [
                'title' => 'Test template 2',
                'content' => 'Test 2',
            ]
        ],
        'content_css' => [
            '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
            '//www.tinymce.com/css/codepen.min.css',            
        ]
    ]
]) ?>

Plugin Typograf

Helps to automatically fill in inextricable spaces, correct minor typos, bring quotation marks to the correct form, replace hyphens with dashes in the right places, and much more., (*10)

= $form->field($model, 'text')->widget(\dominus77\tinymce\TinyMce::class, [
    //...
    'clientOptions' => [
        // on plugin
        'plugins' => [
            'typograf',
            //...
        ],
        // adding a button to a toolbar
        'toolbar1' => 'typograf',
        // adding a item to a context menu
        'contextmenu' => 'typograf | link image inserttable | cell row column deletetable',
        // advanced plugin settings        
        'typograf' => [
            'locale' => ['ru', 'en-US'],
            // HTML entities
            'htmlEntity' => [
                //'type' => 'name',
                //'onlyInvisible' => true
            ],
            // Enabling Rules
            'enableRule' => [
                //'ru/money/ruble',
                //'ru/money/*',
                //'ru/symbols/NN',
                //'ru/optalign/*'
            ],
            // Disabling Rules
            'disableRule' => [
                //'ru/money/ruble',
                //'ru/money/*',
                //'ru/symbols/NN'
            ],
            // Change settings for rules
            // Rule name, setting name, value
            'setSetting' => [
                // Continuous space before the last word in a sentence, not more than 5 characters
                ['common/nbsp/beforeShortLastWord', 'lengthLastWord', 5],
                // Nested quotes are also "Christmas trees" for Russian typography
                ['common/punctuation/quote', 'ru', ['left' => '«', 'right' => '»', 'removeDuplicateQuotes' => true]],
                // Non-breaking space after a short word, no more than 3 characters
                ['common/nbsp/afterShortWord', 'lengthShortWord', 5]
            ],
            // Add a simple rule
            // Typographic Smiley
            'addRule' => [
                [
                    'name' => 'common/other/typographicSmiley',
                    'handler' => new yii\web\JsExpression("
                        function (text) {                                            
                            return text.replace(/:-\)/g, ':—)');
                        }
                    ")
                ]
            ],
            // Turn off typography in sections of text
            'addSafeTag' => [
                // Disable typography inside the  tag
                ['', ''],
                // Disable typing inside control structures of some template engine.
                ['\\{\\{', '\\}\\}'], // {{...}}
                ['\\[\\[', '\\]\\]'], // [[...]]
                // Disable typography inside PHP code
                ['']
            ]
        ],
        //...
    ]
]) ?>

See more information on JavaScript typographer, (*11)

Plugin fontawesome

The plugin is supported by FontAwesome version 4.7. In this version of the widget, due to possible conflicts with the new version, the dependency was removed. But the support of the plug-in itself remained. To turn it on, you need to install FontAwesome version 4.7, (*12)

composer require fortawesome/font-awesome "^4.7"

or add, (*13)

"fortawesome/font-awesome": "^4.7"

The connection might look like this:, (*14)

use dominus77\tinymce\assets\FontAwesomeAsset;

$fontAwesome = FontAwesomeAsset::register($this);

````

```php
//...
'clientOptions' => [
    //...
    'plugins' => [            
        "fontawesome", // add plugin
        // other plugins
    ],        
    'toolbar' => "fontawesome", // add button
    //...
    'content_css' => [
        // other css
        $fontAwesome->baseUrl . '/' . $fontAwesome->css[0], // Adding icons to the content area
    ]
]

ElFinder file manager

Install mihaildev/yii2-elfinder extension., (*15)

Either run, (*16)

composer require --prefer-dist mihaildev/yii2-elfinder "^1.3"

or add, (*17)

"mihaildev/yii2-elfinder": "^1.3"

Configure elFinder (more info here), (*18)

'controllerMap' => [
    'elfinder' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['@'], //Global file manager access @ - for authorized , ? - for guests , to open to all ['@', '?']
        'disabledCommands' => ['netmount'], //disabling unnecessary commands https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'files/global',
                'name' => 'Global'
            ],
            [
                'class' => 'mihaildev\elfinder\volume\UserPath',
                'path'  => 'files/user_{id}',
                'name'  => 'My Documents'
            ],
            [
                'path' => 'files/some',
                'name' => ['category' => 'my','message' => 'Some Name'] //перевод Yii::t($category, $message)
            ],
            [
                'path'   => 'files/some',
                'name'   => ['category' => 'my','message' => 'Some Name'], // Yii::t($category, $message)
                'access' => ['read' => '*', 'write' => 'UserFilesAccess']  // * - for all, otherwise the access check in this example can be seen by all users with rights only UserFilesAccess
            ]
        ],
        'watermark' => [
             'source'         => __DIR__.'/logo.png', // Path to Water mark image
             'marginRight'    => 5,          // Margin right pixel
             'marginBottom'   => 5,          // Margin bottom pixel
             'quality'        => 95,         // JPEG image save quality
             'transparency'   => 70,         // Water mark image transparency ( other than PNG )
             'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
             'targetMinPixel' => 200         // Target image minimum pixel size
        ]
    ]
]

Then select file manager provider in the widget:, (*19)

$form->field($model, 'text')->widget(\dominus77\tinymce\TinyMce::class, [    
    'clientOptions' => [
        //...
        /** @see https://www.tinymce.com/docs/configure/file-image-upload/#file_picker_types */
        //'file_picker_types' => 'file image media',        
    ],
    'fileManager' => [
        'class' => \dominus77\tinymce\components\MihaildevElFinder::class,
    ],    
    //...
])

You can customize some window (width and height) and manager (language, filter, path and multiple) properties. If you want to use different access, watermark and roots setting just prepare controllers:, (*20)

'controllerMap' => [
    'elf1' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['@'],
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'files/global',
                'name' => 'Global'
            ],
        ],
        'watermark' => [
            'source'         => __DIR__.'/logo.png', // Path to Water mark image
            'marginRight'    => 5,          // Margin right pixel
            'marginBottom'   => 5,          // Margin bottom pixel
            'quality'        => 95,         // JPEG image save quality
            'transparency'   => 70,         // Water mark image transparency ( other than PNG )
            'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
            'targetMinPixel' => 200         // Target image minimum pixel size            
        ],
    ],
    'elf2' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['*'],
        'roots' => [
            [                
                'path' => 'files/some1',
                'name' => ['category' => 'my','message' => 'Some Name']
            ],
            [                
                'path' => 'files/some2',
                'name' => ['category' => 'my','message' => 'Some Name'],
                'access' => ['read' => '*', 'write' => 'UserFilesAccess']
            ],
        ],
    ],
]

Connection in the module:, (*21)

namespace modules\example;

class Module extends \yii\base\Module
{
    //...
    public function init()
    {
        parent::init();
        $this->controllerMap = [
            'elfinder' => [
                'class' => 'mihaildev\elfinder\Controller',
                'access' => ['@'],
                'disabledCommands' => ['netmount'],
                'roots' => [
                    [
                        'baseUrl'=>'@web',
                        'basePath'=>'@webroot',
                        'path' => 'files/global',
                        'name' => 'Global'
                    ],
                ],
                'watermark' => [
                    'source'         => __DIR__.'/logo.png', // Path to Water mark image
                    'marginRight'    => 5,          // Margin right pixel
                    'marginBottom'   => 5,          // Margin bottom pixel
                    'quality'        => 95,         // JPEG image save quality
                    'transparency'   => 70,         // Water mark image transparency ( other than PNG )
                    'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
                    'targetMinPixel' => 200         // Target image minimum pixel size            
                ],
            ]
        ];
    }
    //...
}

in module view:, (*22)

$form->field($model, 'text')->widget(\dominus77\tinymce\TinyMce::class, [    
    'clientOptions' => [
        //...
        /** @see https://www.tinymce.com/docs/configure/file-image-upload/#file_picker_types */
        //'file_picker_types' => 'file image media',
    ],
    'fileManager' => [
        'class' => \dominus77\tinymce\components\MihaildevElFinder::class,
        'controller' => 'elfinder',        
        'title' => 'My File Manager',
        'width' => 900,
        'height' => 600,
        'resizable' => 'yes',
    ],    
    //...
]);

Further Information

Please, check the TinyMCE site and ElFinder Extension documentation for further information about its configuration options., (*23)

License

The MIT License (MIT). Please see License File for more information., (*24)

The Versions

27/07 2018

dev-master

9999999-dev

TinyMCE widget for Yii2.

  Sources   Download

MIT BSD-3-Clause BSD-3

The Requires

 

by Alexey Shevchenko
by Alexey Schevchenko

extension yii2 widget tinymce dominus77

06/06 2018

v2.0.2

2.0.2.0

TinyMCE widget for Yii2.

  Sources   Download

MIT

The Requires

 

by Alexey Schevchenko

extension yii2 widget tinymce dominus77

02/05 2018

v2.0.1

2.0.1.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Schevchenko

extension yii2 widget tinymce dominus77

16/01 2018

v2.0.0

2.0.0.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Schevchenko

extension yii2 widget tinymce dominus77

04/10 2017

v1.3.0

1.3.0.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

04/10 2017

v1.2.8

1.2.8.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

03/10 2017

v1.2.7

1.2.7.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

30/09 2017

v1.2.6

1.2.6.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

30/09 2017

v1.2.5

1.2.5.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

29/09 2017

v1.2.4

1.2.4.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

17/09 2017

v1.2.3

1.2.3.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

07/06 2017

v1.2.2

1.2.2.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

16/05 2017

v1.2.1

1.2.1.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

17/03 2017

v1.2.0

1.2.0.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

17/03 2017

v1.1.4

1.1.4.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

16/03 2017

v1.1.3

1.1.3.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

16/03 2017

v1.1.2

1.1.2.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

25/02 2017

v1.1.1

1.1.1.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

25/02 2017

v1.1.0

1.1.0.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

25/02 2017

v1.0.2

1.0.2.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

24/02 2017

v1.0.1

1.0.1.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77

24/02 2017

v1.0.0

1.0.0.0

TinyMCE widget for Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

by Alexey Shevchenko

extension yii2 widget tinymce dominus77