Skip to content

NickGoodwind/yii2-imperavi-widget

 
 

Repository files navigation

Imperavi Redactor Widget for Yii 2 - Mod by NickGoodwind

Imperavi Redactor Widget is a wrapper for Imperavi Redactor 10.2.5, a high quality WYSIWYG editor.

Note that Imperavi Redactor itself is a proprietary commercial copyrighted software but since Yii community bought OEM license you can use it for free within Yii.

Install

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require --prefer-dist vova07/yii2-imperavi-widget "*"

or add

"vova07/yii2-imperavi-widget": "*"

to the require section of your composer.json file.

Basic usage

For basic usage follow the intructions provided by vova07

CodeMirror usage

Simply add the following lines to your Redactor configuration

use vova07\imperavi\Widget;

echo $form->field($model, 'content')->widget(Widget::className(), [
    'settings' => [
        ...
        'codemirror' => true,
        'soure' => [
            'codemirror' => [
                'lineNubers' => true,
                'mode' => 'htmlmixed',
                'theme' => 'ayu-mirage',
                'indentWithTabs' => true,
                # Add all other codemirror options here.
            ]
        ],
        ...
    ],
]);

For all CodeMirror options review the manual

Custom modes, themes or assets

To use custom CodeMirror assets (modes, themes, plugins) other than the ones predefined here you need to add those assets to the codemirror assets folder src/assets/codemirror If you need to add a mode added to the modes folder; same with the themes. Just make sure to maintain the folder order. You can get all assets from CodeMirror.

After including the assets you need to update the CodemirrorAsset.php file:

class CodemirrorAsset extends AssetBundle
{
    public $sourcePath = '@vova07/imperavi/assets';
    
    public $js = [
        'codemirror/codemirror.js',
        # Add your modes and plugins here
    ];

    public $css = [
        'codemirror/codemirror.css',
        # Add your themes and styles here
    ];

    public $depends = [
        'app\modules\admin\assets\AdminAppAsset'
    ];
}

Further Information

Please, check the Imperavi Redactor v10 documentation for further information about its configuration options.

Contributing

Please see CONTRIBUTING for vova07 previous contributtor details. All changes staged in this fork have been done by NickgGoodwind

Credits

License

The BSD License (BSD). Please see License File for more information.

Upgrade guide

Please check the UPGRADE GUIDE for details.

About

Imperavi Redactor widget for Yii 2 - CodeMirror integration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 88.3%
  • CSS 4.7%
  • PHP 3.5%
  • Less 3.5%