|
|
@ -1,8 +1,8 @@
|
|
|
|
// Generated by CoffeeScript 1.9.0
|
|
|
|
// Generated by CoffeeScript 1.9.0
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
paste.js is an interface to read data ( text / image ) from clipboard in different browsers. It also contains several hacks.
|
|
|
|
paste.js is an interface to read data ( text / image ) from clipboard in different browsers. It also contains several hacks.
|
|
|
|
https://github.com/layerssss/paste.js
|
|
|
|
https://github.com/layerssss/paste.js
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
(function() {
|
|
|
@ -279,7 +279,7 @@ https://github.com/layerssss/paste.js
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//firefox问题处理,因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
|
|
|
|
//firefox问题处理,因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
|
|
|
|
if ($(img).attr('src').startsWith('data:image/')) {
|
|
|
|
if ($(img).attr('src').startsWith('data:image/')) {
|
|
|
|
_results.push($(img).remove());
|
|
|
|
_results.push($(img).remove());
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _results;
|
|
|
|
return _results;
|
|
|
@ -307,23 +307,23 @@ function enablePasteImg(_editor) {
|
|
|
|
$(nodeBody).pastableContenteditable();
|
|
|
|
$(nodeBody).pastableContenteditable();
|
|
|
|
|
|
|
|
|
|
|
|
dataURItoBlob = function(dataURI) {
|
|
|
|
dataURItoBlob = function(dataURI) {
|
|
|
|
// convert base64/URLEncoded data component to raw binary data held in a string
|
|
|
|
// convert base64/URLEncoded data component to raw binary data held in a string
|
|
|
|
var byteString;
|
|
|
|
var byteString;
|
|
|
|
if (dataURI.split(',')[0].indexOf('base64') >= 0)
|
|
|
|
if (dataURI.split(',')[0].indexOf('base64') >= 0)
|
|
|
|
byteString = atob(dataURI.split(',')[1]);
|
|
|
|
byteString = atob(dataURI.split(',')[1]);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
byteString = unescape(dataURI.split(',')[1]);
|
|
|
|
byteString = unescape(dataURI.split(',')[1]);
|
|
|
|
|
|
|
|
|
|
|
|
// separate out the mime component
|
|
|
|
// separate out the mime component
|
|
|
|
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
|
|
|
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
|
|
|
|
|
|
|
|
|
|
|
// write the bytes of the string to a typed array
|
|
|
|
// write the bytes of the string to a typed array
|
|
|
|
var ia = new Uint8Array(byteString.length);
|
|
|
|
var ia = new Uint8Array(byteString.length);
|
|
|
|
for (var i = 0; i < byteString.length; i++) {
|
|
|
|
for (var i = 0; i < byteString.length; i++) {
|
|
|
|
ia[i] = byteString.charCodeAt(i);
|
|
|
|
ia[i] = byteString.charCodeAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new Blob([ia], {type:mimeString});
|
|
|
|
return new Blob([ia], {type:mimeString});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$(nodeBody).on('pasteImage', function(ev, data) {
|
|
|
|
$(nodeBody).on('pasteImage', function(ev, data) {
|
|
|
@ -337,18 +337,104 @@ function enablePasteImg(_editor) {
|
|
|
|
data.append("imgFile",blob, "imageFilename.png");
|
|
|
|
data.append("imgFile",blob, "imageFilename.png");
|
|
|
|
console.log(data);
|
|
|
|
console.log(data);
|
|
|
|
$.ajax({
|
|
|
|
$.ajax({
|
|
|
|
url: '/kindeditor/upload?dir=image',
|
|
|
|
url: '/kindeditor/upload?dir=image',
|
|
|
|
contentType: false,
|
|
|
|
contentType: false,
|
|
|
|
type: 'POST',
|
|
|
|
type: 'POST',
|
|
|
|
data: data,
|
|
|
|
data: data,
|
|
|
|
processData: false,
|
|
|
|
processData: false,
|
|
|
|
success: function(data) {
|
|
|
|
success: function(data) {
|
|
|
|
console.log(data);
|
|
|
|
console.log(data);
|
|
|
|
editor.exec('insertimage', JSON.parse(data).url);
|
|
|
|
editor.exec('insertimage', JSON.parse(data).url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//复制粘贴时把远程图片上传到服务器
|
|
|
|
|
|
|
|
function df(myself) {
|
|
|
|
|
|
|
|
// var img = $("#ke_paste").find("img");
|
|
|
|
|
|
|
|
var currele = document.activeElement;
|
|
|
|
|
|
|
|
var img = $(currele).contents().find("img");
|
|
|
|
|
|
|
|
var piccount = 0;
|
|
|
|
|
|
|
|
var sstr = "";
|
|
|
|
|
|
|
|
$(img).each(function (i) {
|
|
|
|
|
|
|
|
var that = $(this);
|
|
|
|
|
|
|
|
if(that.attr("src")) {
|
|
|
|
|
|
|
|
if (that.attr("src").indexOf("http://") >= 0 || that.attr("src").indexOf("https://") >= 0) {
|
|
|
|
|
|
|
|
piccount++;
|
|
|
|
|
|
|
|
if (i == $(img).length - 1)
|
|
|
|
|
|
|
|
sstr += that.attr("src");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
sstr += that.attr("src") + "|";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
uploadpic(sstr,myself);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function keShadow(myself)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var keShadowContainer = document.getElementById("ke_shadow");
|
|
|
|
|
|
|
|
if (keShadowContainer == null) {
|
|
|
|
|
|
|
|
keShadowContainer = document.createElement("div");
|
|
|
|
|
|
|
|
keShadowContainer.id = "ke_shadow";
|
|
|
|
|
|
|
|
keShadowContainer.innerHTML = "<div class='ui-widget-overlay' z-index: 1001;'></div>";
|
|
|
|
|
|
|
|
$("#ajax-modal").after(keShadowContainer);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var tWidth = document.body.scrollWidth;
|
|
|
|
|
|
|
|
var tHeight = document.body.scrollHeight;
|
|
|
|
|
|
|
|
$(".ui-widget-overlay").css("width", tWidth);
|
|
|
|
|
|
|
|
$(".ui-widget-overlay").css("height", tHeight);
|
|
|
|
|
|
|
|
$("#ke_shadow").show();
|
|
|
|
|
|
|
|
myself.readonly();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function uploadpic(piclist,myself) {
|
|
|
|
|
|
|
|
if (piclist.length == 0) return false;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
|
|
url: "/kindeditor/uploadpic",
|
|
|
|
|
|
|
|
data:{"pic":piclist},
|
|
|
|
|
|
|
|
type: "GET",
|
|
|
|
|
|
|
|
beforeSend: function () {
|
|
|
|
|
|
|
|
// $("#ajax-indicator span").text("图片上传中请稍等...");
|
|
|
|
|
|
|
|
keShadow(myself);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
success: function (msg) {
|
|
|
|
|
|
|
|
if (msg !== "") {
|
|
|
|
|
|
|
|
var str = new Array();
|
|
|
|
|
|
|
|
str = msg.split('|');
|
|
|
|
|
|
|
|
var currele = document.activeElement;
|
|
|
|
|
|
|
|
var img = $(currele).contents().find("img");
|
|
|
|
|
|
|
|
var tIndex = 0;
|
|
|
|
|
|
|
|
$(img).each(function (i) {
|
|
|
|
|
|
|
|
var that = $(this);
|
|
|
|
|
|
|
|
if(that.attr("src")){
|
|
|
|
|
|
|
|
if (that.attr("src").indexOf("http://") >= 0 || that.attr("src").indexOf("https://") >= 0) {
|
|
|
|
|
|
|
|
that.attr("src", str[tIndex]);
|
|
|
|
|
|
|
|
that.attr("data-ke-src", str[tIndex]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//非视频
|
|
|
|
|
|
|
|
if(!(that.parent().attr("class") && that.parent().attr("class") == "mediaIcobox" )) {
|
|
|
|
|
|
|
|
that.parent().attr("href", str[tIndex]);
|
|
|
|
|
|
|
|
that.parent().attr("data-ke-src", str[tIndex]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tIndex = tIndex + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// $("#ajax-indicator span").text("载入中...");
|
|
|
|
|
|
|
|
$("#ke_shadow").hide();
|
|
|
|
|
|
|
|
myself.readonly(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).fail(function(xhr, status){
|
|
|
|
|
|
|
|
// $("#ajax-indicator span").text("载入中...");
|
|
|
|
|
|
|
|
$("#ke_shadow").hide();
|
|
|
|
|
|
|
|
myself.readonly(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|