PHPackages                             wolfguard/yii2-tinymce-codemirror - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. wolfguard/yii2-tinymce-codemirror

ActiveYii2-extension

wolfguard/yii2-tinymce-codemirror
=================================

Yii2 extension to use TinyMce with Compressor, CodeMirror and FileManager

v0.1.1(10y ago)12251BSD-3-ClauseJavaScript

Since Mar 15Pushed 10y ago2 watchersCompare

[ Source](https://github.com/wolfguarder/yii2-tinymce-codemirror)[ Packagist](https://packagist.org/packages/wolfguard/yii2-tinymce-codemirror)[ RSS](/packages/wolfguard-yii2-tinymce-codemirror/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

TinyMCE integration for Yii2
============================

[](#tinymce-integration-for-yii2)

Yii2 extension to simplify TinyMCE WYSIWYG editor usage in your application.

Provides:

- widget;
- compressor action;
- integration with file managers like elFinder;
- integration with spelling services like Yandex.
- TinyMCE gone to npm package to always have the latest version;
- Added integration with great [elFinder extension](https://github.com/MihailDev/yii2-elfinder);
- (TODO) Icon to insert many images at once;
- Few bugs resolved. It's all working now.

Fork of [another extension](https://github.com/NecroMan/yii2-tinymce) with some additional features:

- CodeMirror plugin integration for source code mode.

CodeMirror plugin was taken from Christiaan Baartse [repository](https://github.com/christiaan/tinymce-codemirror)

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](https://getcomposer.org/).

Either run

`php composer.phar require --prefer-dist wolfguard/yii2-tinymce-codemirror "*"`

or add

`"wolfguard/yii2-tinymce-codemirror": "*"`

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

### Widget basic usage

[](#widget-basic-usage)

```
$form->field($model, 'content')->widget(\wolfguard\tinymce\TinyMce::className())
```

### Scripts compressor

[](#scripts-compressor)

This can be used to optimize widget loading time.

At fist setup controller map:

```
'controllerMap' => [
    'tinyMce' => [
        'class' => 'wolfguard\tinymce\TinyMceController',
    ]
],
```

Next add route to configured action to widget options:

```
$form->field($model, 'content')->widget(\wolfguard\tinymce\TinyMce::className(), [
    'compressorRoute' => 'tinyMce/tinyMceCompressor'
])
```

### ElFinder file manager

[](#elfinder-file-manager)

Install [mihaildev/yii2-elfinder](https://github.com/MihailDev/yii2-elfinder) extension. You can just include

```
"mihaildev/yii2-elfinder": "*"
```

to the require section of your `composer.json` file.

Configure elFinder (more info [here](https://github.com/MihailDev/yii2-elfinder)).:

```
'controllerMap' => [
    'elfinder' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['@'],
        'disabledCommands' => ['netmount'],
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'files/global',
                'name' => 'Global'
            ],
        ],
        'watermark' => [
                'source'         => __DIR__.'/logo.png',
                 'marginRight'    => 5,
                 'marginBottom'   => 5,
                 'quality'        => 95,
                 'transparency'   => 70,
                 'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP,
                 'targetMinPixel' => 200
        ]
    ]
],
```

Then select file manager provider in the widget:

```
$form->field($model, 'content')->widget(\wolfguard\tinymce\TinyMce::className(), [
    'fileManager' => [
        'class' => \wolfguard\tinymce\fm\MihaildevElFinder::className()
    ],
])
```

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:

```
'controllerMap' => [
    'elf1' => [
        'class' => 'mihaildev\elfinder\Controller',
        'access' => ['@'],
        'roots' => [
            [
                'baseUrl'=>'@web',
                'basePath'=>'@webroot',
                'path' => 'files/global',
                'name' => 'Global'
            ],
        ],
        'watermark' => [
                'source'         => __DIR__.'/logo.png',
                 'marginRight'    => 5,
                 'marginBottom'   => 5,
                 'quality'        => 95,
                 'transparency'   => 70,
                 'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP,
                 'targetMinPixel' => 200
        ]
    ],
    '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']
            ]
        ]
    ]
],
```

and then point to required controller in the widget:

```
$form->field($model, 'content2')->widget(\wolfguard\tinymce\TinyMce::className(), [
    'fileManager' => [
        'class' => \wolfguard\tinymce\fm\MihaildevElFinder::className(),
        'controller' => 'elf2'
    ]
])
```

### Any file manager

[](#any-file-manager)

You can write your own file manager provider. Just inherit it from `\wolfguard\tinymce\fm\FileManager` class and realize `getFileBrowserCallback` and `registerAsset` functions.

### Spellchecker

[](#spellchecker)

TinyMce has bundled plugin for spellchecking but it requires backed to work.

You can use Yandex spellchecker service.

```
$form->field($model, 'content')->widget(\wolfguard\tinymce\TinyMce::className(), [
    'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell'
])
```

More info about it here:

Or you can build own spellcheking service using code provided by moxicode:

### Combined features

[](#combined-features)

```
