yii2 summernote 小部件设置工具栏选项
yii2 summernote widget set toolbar options
我正在通过 marqu3s\summernote\Summernote 扭曲的 Yii2 实现 summernote;
https://github.com/undeman/yii2-summernote
但我无法添加 summernote 文档中显示的工具栏选项:
http://summernote.org/deep-dive/
这就是我尝试使用它的方式,但是每当我添加工具栏选项时,工具栏就会消失。
$tabReport .= $form->field($model, 'ysk')->widget(Summernote::className(), [
'clientOptions' => [
'placeholder' => 'You can write here some important public notes to be display on top of the report...',
'minHeight' => 100,
'toolbar' => [
'style' => ['bold', 'italic', 'underline', 'clear'],
],
],
]
);
有什么线索吗?
看来工具栏选项得直接用js贴出来了
我所做的是在主客户端选项中添加一个 id:
$tabReport .= $form->field($model, 'ysk')->widget(Summernote::className(), [
'clientOptions' => [
'placeholder' => 'You can write here some important public notes to be display on top of the report...',
'minHeight' => 100,
'id' => 'ysk-summernote',
],
]
);
然后在我的 app.js 中通过 js 添加工具栏选项(或者更好地在视图中注册)
$('#book-ysk').summernote({
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']],
]
});
而且工作起来很有魅力
你的数组格式有误:
'toolbar' => [
'style' => ['bold', 'italic', 'underline', 'clear'],
],
将生成 js:
'toolbar': {'style': ['bold', 'italic', 'underline', 'clear']}
要生成所需的 js,请使用与 javascript 中相同的结构,即:
'toolbar' => [
['style': ['bold', 'italic', 'underline', 'clear']]
]
对于你的:
'toolbar' => [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']],
]
我正在通过 marqu3s\summernote\Summernote 扭曲的 Yii2 实现 summernote; https://github.com/undeman/yii2-summernote
但我无法添加 summernote 文档中显示的工具栏选项: http://summernote.org/deep-dive/
这就是我尝试使用它的方式,但是每当我添加工具栏选项时,工具栏就会消失。
$tabReport .= $form->field($model, 'ysk')->widget(Summernote::className(), [
'clientOptions' => [
'placeholder' => 'You can write here some important public notes to be display on top of the report...',
'minHeight' => 100,
'toolbar' => [
'style' => ['bold', 'italic', 'underline', 'clear'],
],
],
]
);
有什么线索吗?
看来工具栏选项得直接用js贴出来了
我所做的是在主客户端选项中添加一个 id:
$tabReport .= $form->field($model, 'ysk')->widget(Summernote::className(), [
'clientOptions' => [
'placeholder' => 'You can write here some important public notes to be display on top of the report...',
'minHeight' => 100,
'id' => 'ysk-summernote',
],
]
);
然后在我的 app.js 中通过 js 添加工具栏选项(或者更好地在视图中注册)
$('#book-ysk').summernote({
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']],
]
});
而且工作起来很有魅力
你的数组格式有误:
'toolbar' => [
'style' => ['bold', 'italic', 'underline', 'clear'],
],
将生成 js:
'toolbar': {'style': ['bold', 'italic', 'underline', 'clear']}
要生成所需的 js,请使用与 javascript 中相同的结构,即:
'toolbar' => [
['style': ['bold', 'italic', 'underline', 'clear']]
]
对于你的
'toolbar' => [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']],
]