Answer the question
In order to leave comments, you need to log in
How to add custom plugin for yii2 tinymce?
I installed this widget in yii2, but I don’t understand how to write my plugin and add it, I just need a button that, when pressed, adds static text.
Answer the question
In order to leave comments, you need to log in
1. Take a ready-made plugin for Yii2 and install it into the system, because doing something from scratch is a bicycle invention
2. Inherit the installed plugin at the class level (roughly speaking, this will be your modification)
3. In your plugin modification, set for JS -plugin to the setup property (during initialization):
setup: function (editor) {
editor.addButton('mybutton', {
text: 'My button',
icon: <url-to-icon>,
onclick: function () {
editor.insertContent(' <b>It\'s my content!</b> ');
}
});
},
use dosamigos\tinymce\TinyMce;
<?= $form->field($model, 'text')->widget(TinyMce::className(), [
'options' => ['rows' => 6],
'language' => 'es',
'clientOptions' => [
'plugins' => [
"advlist autolink lists link charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste"
],
'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
'setup' => // тут JS код указанный в пункте 3
]
]);?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question