0
をツールバーに新しいボタンを追加します。yii2 summernoteウィジェット私はラッパーを使用してYII2中でsummernoteウィジェットに新しいカスタムボタンを追加しようとしています
use marqu3s\summernote\Summernote;
これはsummernoteサンプル次のビューで私のコードです:
:http://summernote.org/deep-dive/
$form->field($model, 'text_body')->widget(Summernote::className(), [
'clientOptions' => [
'id' => 'ysk-summernote',
'toolbar' => [
['mybutton', ['hello']],
['undo', ['undo']],
['redo', ['redo']],
['insert', ['link', 'hr']],
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['view', ['codeview']],
['help', ['help']],
],
'height' => 400,
'buttons' => ['hello' => 'HelloButton'],
]
]
);
?>
私はまた、次のJSを追加しています3210
<?php
$script = <<< JS
var HelloButton = function (context) {
var ui = $.summernote.ui;
// create button
var button = ui.button({
contents: '<i class="fa fa-child"/> Hello',
tooltip: 'hello',
click: function() {
// invoke insertText method with 'hello' on editor module.
context.invoke('editor.insertText', 'hello');
}
});
return button.render(); // return button as jquery object
}
JS;
$this->registerJs($script);
?>
ビューエディタでレンダリングが、ボタンが表示されない:
私はかかわらず、div要素を見ることができるツールバーをチェックした場合:
<div class="note-btn-group btn-group note-mybutton"></div>
を、私は時間のために試みたが、運、
http://summernote.org/deep-dive/#using-button-with-optionsで説明したように任意のアイデアが