Yii2 extension to simplify TinyMCE WYSIWYG editor usage in your application.
Provides:
Fork of another extension with some additional features:
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist as-milano/yii2-tinymce "*"
or add
"as-milano/yii2-tinymce": "*"
to the require section of your composer.json
file.
$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className())
This can be used to optimize widget loading time.
At fist setup controller map:
'controllerMap' => [
'tinyMce' => [
'class' => 'milano\tinymce\TinyMceController',
]
],
Next add route to configured action to widget options:
$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
'compressorRoute' => 'tinyMce/tinyMceCompressor'
])
Install 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).:
'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(\milano\tinymce\TinyMce::className(), [
'fileManager' => [
'class' => \milano\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(\milano\tinymce\TinyMce::className(), [
'fileManager' => [
'class' => \milano\tinymce\fm\MihaildevElFinder::className(),
'controller' => 'elf2'
]
])
You can write your own file manager provider.
Just inherit it from \milano\tinymce\fm\FileManager
class and realize getFileBrowserCallback
and registerAsset
functions.
TinyMce has bundled plugin for spellchecking but it requires backed to work.
You can use Yandex spellchecker service.
$form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell'
])
More info about it here: http://api.yandex.ru/speller/doc/dg/tasks/how-to-spellcheck-tinymce.xml
Or you can build own spellcheking service using code provided by moxicode: http://www.tinymce.com/download/download.php
<?= $form->field($model, 'content')->widget(\milano\tinymce\TinyMce::className(), [
'compressorRoute' => 'site/tinyMceCompressor',
'fileManager' => [
'class' => \milano\tinymce\fm\MihaildevElFinder::className()
],
'spellcheckerUrl'=>'http://speller.yandex.net/services/tinyspell',
'options' => ['rows' => 6]
]) ?>
No stable releases.
Comments