2amigos / yii2-ckeditor-widget

CKEditor WYSIWYG widget for Yii2.
https://2amigos.us/open-source/ckeditor-widget
Other
172 stars 112 forks source link

How to add new external plugin 'wordcount' #53

Closed GAMITG closed 7 years ago

GAMITG commented 8 years ago

I need to add wordcount plugin in CKeditor. please give me solution for this.

tonydspaniard commented 8 years ago

Download the plugin and add it to a web folder, then register a script AFTER rendering the widget:

$this->registerJs("CKEDITOR.plugins.addExternal(....)"); 

use any of the following options (from documentation)

// Loads a plugin from '/myplugin/samples/plugin.js'.
CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' );

// Loads a plugin from '/myplugin/samples/my_plugin.js'.
CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' );

// Loads a plugin from '/myplugin/samples/my_plugin.js'.
CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/my_plugin.js', '' );
GAMITG commented 8 years ago

Thank you. @tonydspaniard

aenima700 commented 8 years ago

I cannot configure CkEditor with wordcount :( Any help please?

demogorgorn commented 8 years ago

This is the solution I found:

in the forms's view:

<?php echo $form->field($model, 'description')->widget(CKEditor::className(), [
            'options' => ['rows' => 6],
            'preset' => 'full',
            'clientOptions' => [

                'extraPlugins' => 'widgetbootstrap',
            ]
        ]) ?>

<?php 
$this->registerJs("CKEDITOR.plugins.addExternal('widgetbootstrap', '/js/widgetbootstrap/', 'plugin.js');"); 

And the plugin's folder I've copied to @app/web/js

E.g. web/js/widgetbootstrap/plugin.js

tonydspaniard commented 7 years ago

https://github.com/2amigos/yii2-ckeditor-widget/blob/master/README.md#how-to-add-custom-plugins

demogorgorn commented 7 years ago

I'm glad that my solution helped!