Jon*_*nan 20 javascript jquery wysiwyg summernote
有没有办法完全禁用Summernote中的图像上传,但保持图像网址输入?我发现最接近的是disableDragAndDrop: true选项,但这不会从图像弹出窗口中删除上传按钮
wes*_*sww 47
可能有更好的方法来实现您的目标......但是想到一个非常简单的解决方案就是将其添加到您的样式表中:
.note-group-select-from-files {
display: none;
}
Run Code Online (Sandbox Code Playgroud)
它完美地保留了图像url输入,并完成你要去的东西,除非有人检查元素并发现上传元素仍然存在且显示无:
编辑:我看了一下Summernote源代码,看起来上面的解决方案实际上是一个很好的方法.目前没有api可以禁用文件上传按钮,更不用说在保持img url输入完整的情况下这样做了.当然,您可以随时添加它并打开拉取请求.
var body = '<div class="form-group note-group-select-from-files">' +
'<label>' + lang.image.selectFromFiles + '</label>' +
'<input class="note-image-input form-control" type="file" name="files" accept="image/*" multiple="multiple" />' +
imageLimitation +
'</div>' +
'<div class="form-group" style="overflow:auto;">' +
'<label>' + lang.image.url + '</label>' +
'<input class="note-image-url form-control col-md-12" type="text" />' +
'</div>';
Run Code Online (Sandbox Code Playgroud)
您可以覆盖工具栏并在那里定义自己的按钮组.这是一个示例codesnippet:
$("#summernote").summernote({
height: 300,
toolbar: [
[ 'style', [ 'style' ] ],
[ 'font', [ 'bold', 'italic', 'underline', 'strikethrough', 'superscript', 'subscript', 'clear'] ],
[ 'fontname', [ 'fontname' ] ],
[ 'fontsize', [ 'fontsize' ] ],
[ 'color', [ 'color' ] ],
[ 'para', [ 'ol', 'ul', 'paragraph', 'height' ] ],
[ 'table', [ 'table' ] ],
[ 'insert', [ 'link'] ],
[ 'view', [ 'undo', 'redo', 'fullscreen', 'codeview', 'help' ] ]
]
});
Run Code Online (Sandbox Code Playgroud)
此代码生成工具栏,没有视频和图像插入选项以及所有其他可用选项.您可以在此处查看详细API文档.