加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
customplugin.js 3.46 KB
一键复制 编辑 原始数据 按行查看 历史
Karson 提交于 2021-09-10 09:59 . 更新License和依赖
define(['nkeditor-core'], function (Nkeditor) {
Nkeditor.plugin('multiimage', function (K) {
var self = this, name = 'multiimage', lang = self.lang(name + '.'),
allowImages = K.undef(self.allowImages, false);
var click = function () {
var html = [
'<div class="ke-dialog-content-inner">',
'<div class="ke-dialog-row ke-clearfix">',
'<div class=""><div class="ke-inline-block ke-upload-button">' +
'<form class="ke-upload-area ke-form nice-validator n-default" method="post" enctype="multipart/form-data" style="width: 266px;margin:50px auto;">' +
'<span class="ke-button-common"><input type="button" class="ke-button-common ke-button" value="批量上传图片" style="width:128px;"></span><input type="file" class="ke-upload-file" name="imgFiles" multiple style="width:128px;left:0;right:inherit" tabindex="-1">' +
'<span class="ke-button-common" style="margin-left:10px;"><input type="button" class="ke-button-common ke-button ke-select-image" style="width:128px;" value="从图片空间选择"></span>' +
'</form>' +
'</div></span></div>',
'</div>',
'</div>'
].join('');
var dialog = self.createDialog({
name: name,
width: Math.min(document.body.clientWidth, 450),
height: 260,
title: self.lang(name),
body: html,
noBtn: {
name: self.lang('no'),
click: function (e) {
self.hideDialog().focus();
}
}
}),
div = dialog.div;
$("input[name=imgFiles]", div).change(function () {
dialog.showLoading();
var files = $(this).prop('files');
$.each(files, function (i, file) {
self.beforeUpload.call(self, function (data) {
self.exec('insertimage', Fast.api.cdnurl(data.data.url));
}, file);
});
setTimeout(function () {
self.hideDialog().focus();
}, 0);
});
$(".ke-select-image", div).click(function () {
self.loadPlugin('filemanager', function () {
self.plugin.filemanagerDialog({
dirName: 'image',
multiple: true,
clickFn: function (urls) {
$.each(urls, function(i, url){
self.exec('insertimage', Fast.api.cdnurl(url));
});
}
});
});
self.hideDialog().focus();
// parent.Fast.api.open("general/attachment/select?element_id=&multiple=true&mimetype=*", __('Choose'), {
// callback: function (data) {
// var urlArr = data.url.split(/\,/);
// $.each(urlArr, function () {
// var url = Fast.api.cdnurl(this);
// self.exec('insertimage', url);
// });
// }
// });
});
};
self.clickToolbar(name, click);
});
return Nkeditor;
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化