firefox粘贴图片只能一张的bug
This commit is contained in:
parent
bdecea83ca
commit
6472367b68
3428
db/schema.rb
3428
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,7 @@ class Kindeditor::AssetsController < ApplicationController
|
|||
logger.warn '========= Warning: the owner_id is 0, "delete uploaded files automatically" will not work. =========' if defined?(logger) && @asset.owner_id == 0
|
||||
@asset.asset_type = @dir
|
||||
if @asset.save
|
||||
render :text => ({:error => 0, :url => "http://"+Setting.host_name + "/" + @asset.asset.url,:asset_id => @asset.id}.to_json)
|
||||
render :text => ({:error => 0, :url => @asset.asset.url,:asset_id => @asset.id}.to_json)
|
||||
else
|
||||
show_error(@asset.errors.full_messages)
|
||||
end
|
||||
|
|
|
@ -277,7 +277,10 @@ https://github.com/layerssss/paste.js
|
|||
if (!img["_paste_marked_" + timespan]) {
|
||||
cb(img.src);
|
||||
}
|
||||
_results.push($(img).remove());
|
||||
//firefox问题处理,因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
|
||||
if ($(img).attr('src').startsWith('data:image/')) {
|
||||
_results.push($(img).remove());
|
||||
};
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
@ -290,10 +293,9 @@ https://github.com/layerssss/paste.js
|
|||
|
||||
}).call(this);
|
||||
|
||||
function enablePasteImg(_editor) {
|
||||
var editor = _editor,
|
||||
KindEditor.plugin('paste', function(K) {
|
||||
var editor = this,
|
||||
name = 'paste';
|
||||
//这样貌似多编辑器就不会冲突了
|
||||
if(editor.edit == undefined || editor.edit.iframe == undefined){
|
||||
return;
|
||||
}
|
||||
|
@ -303,7 +305,7 @@ function enablePasteImg(_editor) {
|
|||
var nodeBody = contentWindow.document.getElementsByTagName('body')[0];
|
||||
console.log(nodeBody);
|
||||
$(nodeBody).pastableContenteditable();
|
||||
|
||||
|
||||
dataURItoBlob = function(dataURI) {
|
||||
// convert base64/URLEncoded data component to raw binary data held in a string
|
||||
var byteString;
|
||||
|
@ -329,7 +331,6 @@ function enablePasteImg(_editor) {
|
|||
console.log("dataURL: " + data.dataURL);
|
||||
console.log("width: " + data.width);
|
||||
console.log("height: " + data.height);
|
||||
console.log(data.blob);
|
||||
var blob = dataURItoBlob(data.dataURL);
|
||||
if (data.blob !== null) {
|
||||
var data = new FormData();
|
||||
|
@ -342,6 +343,7 @@ function enablePasteImg(_editor) {
|
|||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
|
@ -349,37 +351,5 @@ function enablePasteImg(_editor) {
|
|||
|
||||
});
|
||||
return;
|
||||
contentWindow.document.getElementsByTagName('body')[0].onpaste = function(event) {
|
||||
// use event.originalEvent.clipboard for newer chrome versions
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
console.log(JSON.stringify(items)); // will give you the mime types
|
||||
// find pasted image among pasted items
|
||||
var blob = null;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf("image") === 0) {
|
||||
blob = items[i].getAsFile();
|
||||
}
|
||||
}
|
||||
// load image if there is a pasted image
|
||||
if (blob !== null) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
console.log(event.target.result); // data url!
|
||||
var data = new FormData();
|
||||
data.append("imgFile", blob, "imageFilename.png");
|
||||
console.log(blob);
|
||||
$.ajax({
|
||||
url: '/kindeditor/upload?dir=image',
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -277,7 +277,10 @@ https://github.com/layerssss/paste.js
|
|||
if (!img["_paste_marked_" + timespan]) {
|
||||
cb(img.src);
|
||||
}
|
||||
_results.push($(img).remove());
|
||||
//firefox问题处理,因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
|
||||
if ($(img).attr('src').startsWith('data:image/')) {
|
||||
_results.push($(img).remove());
|
||||
};
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
@ -293,7 +296,6 @@ https://github.com/layerssss/paste.js
|
|||
KindEditor.plugin('paste', function(K) {
|
||||
var editor = this,
|
||||
name = 'paste';
|
||||
//这样貌似多编辑器就不会冲突了
|
||||
if(editor.edit == undefined || editor.edit.iframe == undefined){
|
||||
return;
|
||||
}
|
||||
|
@ -303,7 +305,7 @@ KindEditor.plugin('paste', function(K) {
|
|||
var nodeBody = contentWindow.document.getElementsByTagName('body')[0];
|
||||
console.log(nodeBody);
|
||||
$(nodeBody).pastableContenteditable();
|
||||
|
||||
|
||||
dataURItoBlob = function(dataURI) {
|
||||
// convert base64/URLEncoded data component to raw binary data held in a string
|
||||
var byteString;
|
||||
|
@ -329,7 +331,6 @@ KindEditor.plugin('paste', function(K) {
|
|||
console.log("dataURL: " + data.dataURL);
|
||||
console.log("width: " + data.width);
|
||||
console.log("height: " + data.height);
|
||||
console.log(data.blob);
|
||||
var blob = dataURItoBlob(data.dataURL);
|
||||
if (data.blob !== null) {
|
||||
var data = new FormData();
|
||||
|
@ -342,6 +343,7 @@ KindEditor.plugin('paste', function(K) {
|
|||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
|
@ -349,37 +351,5 @@ KindEditor.plugin('paste', function(K) {
|
|||
|
||||
});
|
||||
return;
|
||||
contentWindow.document.getElementsByTagName('body')[0].onpaste = function(event) {
|
||||
// use event.originalEvent.clipboard for newer chrome versions
|
||||
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
|
||||
console.log(JSON.stringify(items)); // will give you the mime types
|
||||
// find pasted image among pasted items
|
||||
var blob = null;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf("image") === 0) {
|
||||
blob = items[i].getAsFile();
|
||||
}
|
||||
}
|
||||
// load image if there is a pasted image
|
||||
if (blob !== null) {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
console.log(event.target.result); // data url!
|
||||
var data = new FormData();
|
||||
data.append("imgFile", blob, "imageFilename.png");
|
||||
console.log(blob);
|
||||
$.ajax({
|
||||
url: '/kindeditor/upload?dir=image',
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue