summernote 插件插入本地视频文件
记录一下
summernote 只支持插入本地图片,修改全局js ,在全局js中调用插入视频方法
注: fastadmin 在清除缓存时会重新更新这个软件,最后复制一份修改后的文件,有好的解决方法请留言,感谢!
修改 public\assets\js\addons.js
$(Config.summernote.classname || '.editor', form).each(function () {
$(this).summernote($.extend(true, {}, {
height: 250,
lang: 'zh-CN',
fontNames: [
'Arial', 'Arial Black', 'Serif', 'Sans', 'Courier',
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande',
"Open Sans", "Hiragino Sans GB", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
],
fontNamesIgnoreCheck: [
"Open Sans", "Microsoft YaHei",
'微软雅黑', '宋体', '黑体', '仿宋', '楷体', '幼圆'
],
toolbar: [
['style', ['style', 'undo', 'redo']],
['font', ['bold', 'underline', 'strikethrough', 'clear']],
['fontname', ['color', 'fontname', 'fontsize']],
['para', ['ul', 'ol', 'paragraph', 'height']],
['table', ['table', 'hr']],
['insert', ['link', 'picture', 'video']],
['view', ['fullscreen', 'codeview', 'help']],
],
buttons: {
image: imageButton,
attachment: attachmentButton,
},
dialogsInBody: true,
followingToolbar: false,
callbacks: {
onChange: function (contents) {
$(this).val(contents);
$(this).trigger('change');
},
onInit: function () {
},
onImageUpload: function (files) {
var that = this;
//依次上传图片
for (var i = 0; i < files.length; i++) {
Upload.api.send(files[i], function (data) {
var url = Fast.api.cdnurl(data.url, true);
$(that).summernote("insertImage", url, 'filename');
});
}
},
onFileUpload: function (files) {
//添加调用插入本地视频方法
var that = this;
for (var i = 0; i < files.length; i++) {
Upload.api.send(files[i], function (data) {
var url = Fast.api.cdnurl(data.url, true);
console.log(url);
$(that).summernote("videoDialog.insertFile", url, 'filename');
});
}
},
}
}, $(this).data("summernote-options") || {}));
});