2amigos / yii2-ckeditor-widget

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

Support additional javascript on initialisation #52

Closed akger1379 closed 8 years ago

akger1379 commented 8 years ago

Hi and thx for the module.

However I wanted to change CKEDITOR.timestamp to remove all those query strings from CKEditors css file loading. I ended up copy and paste the whole registerPlugin function inside my child class of CKEditor to insert the javascript at the right place. I think it would be better to give others the possibility to add more javascript while the plugin is registered. Please have a look at my additions. You now could extend CKEditior and just adjust call of parent::registerPlugin()

tonydspaniard commented 8 years ago

I'll have a look! Thanks!

tonydspaniard commented 8 years ago

@akger1379 sorry for the delay. I think that your option could be done this way:

class MyCKEditor extend CKEditor {
   public $preJs; 
   public $posJs;

  // ...
   protected function registerPlugin() {
       $js[] = $this->preJs; 
       // ... other stuff setting $js 
       $js[] = $this->posJs;
       $view->registerJs(implode("\n", array_filter($js)));
    }
}

I haven't yet received requests that justify the addition of this feature nor I think is too hard to implement if someone needs it. Not sure about its inclusion but if we do, then it has to be a different approach so is not simply added to a protected method just in case someone wishes to customize it.

Thank you very much for your input.

akger1379 commented 8 years ago

@tonydspaniard thank you for your comment.

For me it is not a good OOP design implementation to copy and paste the whole registerPlugin() function into a child class. There is too much stuff inside which I need to track and change if you update registerPlugin() for yourself. So I may end up implementing my own CKEditor widget.

Anyway thanks for your time!