D
D
Dmitry Sidorenko2015-08-22 21:17:07
Yii
Dmitry Sidorenko, 2015-08-22 21:17:07

How to add plugin in ckeditor from 2amigos in Yii2?

There is a plugin from 2amigos
https://github.com/2amigos/yii2-ckeditor-widget
Excellent use of
echo $form->field($model, $k)->textarea($model['fldArr'][$k][ 'options'])->widget(CKEditor::className(), [
'options' => [
'rows' => 3,
], ...
I want to inject plugin into it ckeditor.com/addon/fontawesome
Failed = )
Tried many options, does not work.
Please write at least approximate instructions 1,2,3
Thank you in advance!
-----------------------
PS
I did the following
1) I downloaded the plugin from the site - ckeditor.com/addon/fontawesome
2) Uploaded it to \vendor\2amigos\yii2-ckeditor-widget\src\assets\ckeditor\plugins
3) In the form template I wrote
echo $form->field($model, $k)->textarea($model[ 'fldArr'][$k]['options'])->widget(CKEditor::className(), [
'options' => [
'rows' => 3,
],
'clientOptions' => [
'config. extraPlugins' => 'fontawesome',
'config.contentsCss' => 'path/to/your/font-awesome.css',
'config.allowedContent' => true,
'resize_enabled' => true,
'allowedContent' => true,
'contentsCss' => '/_protected/vendor/2amigos/yii2-ckeditor-widget/src/assets/ckeditor/plugins/fontawesome/font-awesome/css/font-awesome.min.css',
'removeEmpty' => [
'span' => false ,
],
...
'presets' => 'full',
4) In C:\OpenServer\domains\jullycms\_protected\vendor\2amigos\yii2-ckeditor-widget\src\presets\full.php added
['name' => 'insert', 'items' => [ 'FontAwesome', 'Source' ]
Result - everything is broken))

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Bulatov, 2017-07-05
@sidorenkoda

If anyone is interested, you can solve it in an ABSOLUTELY simpler way))))
Everything is like on the official website for CKEditor.
Drop your plugin into the vendor/ckeditor/ckeditor/plugins folder.
And then include the main plugin file where you need it, like this:
And in the display itself, like this:

<?= $form->field($model, 'content')->widget(CKEditor::className(), [
            'preset' => 'custom',
            'options' => ['rows' => 15],
            'clientOptions' => [
                'extraPlugins' => 'pbckcode',
                'toolbarGroups' => [
                    ['name' => 'undo'],
                    ['name' => 'basicstyles', 'groups' => ['basicstyles', 'cleanup']],
                    ['name' => 'colors'],
                    ['name' => 'links', 'groups' => ['links', 'insert']],
                    ['name' => 'others', 'groups' => ['others', 'about']],

                    //['name' => 'youtube'], // <--- OUR NEW PLUGIN YAY!
                    ['name' => 'pbckcode']
                ]
            ],
    ]) ?>

And then you refresh the page with this editor - there will be an error (in the console). In the console, look at the folder where CKEditor is cached (will be shown when hovering over a file that the system cannot find). Find it in the @webroot directory and delete this ill-fated folder completely. And then refresh the page with the editor Ctrl + F5 and watch your plugin added.
We rejoice)))
By the way, this is exactly how this "2amigos" gives instructions on github, but I forgot that everything there is cached.

M
madphoenix, 2016-04-26
@madphoenix

Everything is solved quite simply without unnecessary gestures:
In the form view, specify:

<?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');");

Copy the folder with the plugin, for example, to @app/web/js
That is, you should get something like this - web/js/widgetbootstrap/plugin.js

V
Vlad Pasechnik, 2015-08-27
@jumper423

1) Asset
Don't do this
Everything is only through composer. It is forbidden to change something in the vendor folder according to the unspoken rule.

M
Mister8891, 2015-10-29
@Mister8891

So has anyone solved this problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question