firefox粘贴图片只能一张的bug

tmp
guange 10 years ago
parent bdecea83ca
commit 6472367b68

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150917022239) do ActiveRecord::Schema.define(:version => 20150930011457) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -497,26 +497,23 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id" add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :primary_key => "Num", :force => true do |t| create_table "dts", :force => true do |t|
t.string "Defect", :limit => 50 t.string "IPLineCode"
t.string "Category", :limit => 50
t.string "File"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
t.string "Description" t.string "Description"
t.text "PreConditions", :limit => 2147483647 t.string "Num"
t.text "TraceInfo", :limit => 2147483647 t.string "Variable"
t.text "Code", :limit => 2147483647 t.string "TraceInfo"
t.string "Method"
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
t.integer "id", :null => false
end end
create_table "enabled_modules", :force => true do |t| create_table "enabled_modules", :force => true do |t|
@ -575,6 +572,8 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.integer "viewed" t.integer "viewed"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "secret_key"
t.integer "status"
end end
create_table "forums", :force => true do |t| create_table "forums", :force => true do |t|
@ -783,16 +782,6 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t| create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id" t.integer "journal_id"
t.integer "user_id" t.integer "user_id"
@ -911,6 +900,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.datetime "updated_on", :null => false t.datetime "updated_on", :null => false
t.boolean "locked", :default => false t.boolean "locked", :default => false
t.integer "sticky", :default => 0 t.integer "sticky", :default => 0
t.integer "reply_id"
end end
add_index "messages", ["author_id"], :name => "index_messages_on_author_id" add_index "messages", ["author_id"], :name => "index_messages_on_author_id"
@ -1318,9 +1308,9 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
create_table "student_work_tests", :force => true do |t| create_table "student_work_tests", :force => true do |t|
t.integer "student_work_id" t.integer "student_work_id"
t.integer "status"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "status", :default => 9
t.text "results" t.text "results"
t.text "src" t.text "src"
end end
@ -1376,6 +1366,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.text "description" t.text "description"
t.string "subject"
end end
create_table "taggings", :force => true do |t| create_table "taggings", :force => true do |t|
@ -1567,6 +1558,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.string "identity_url" t.string "identity_url"
t.string "mail_notification", :default => "", :null => false t.string "mail_notification", :default => "", :null => false
t.string "salt", :limit => 64 t.string "salt", :limit => 64
t.integer "gid"
end end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"

@ -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 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 @asset.asset_type = @dir
if @asset.save 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 else
show_error(@asset.errors.full_messages) show_error(@asset.errors.full_messages)
end end

@ -277,7 +277,10 @@ https://github.com/layerssss/paste.js
if (!img["_paste_marked_" + timespan]) { if (!img["_paste_marked_" + timespan]) {
cb(img.src); cb(img.src);
} }
//firefox问题处理因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
if ($(img).attr('src').startsWith('data:image/')) {
_results.push($(img).remove()); _results.push($(img).remove());
};
} }
return _results; return _results;
}; };
@ -290,10 +293,9 @@ https://github.com/layerssss/paste.js
}).call(this); }).call(this);
function enablePasteImg(_editor) { KindEditor.plugin('paste', function(K) {
var editor = _editor, var editor = this,
name = 'paste'; name = 'paste';
//这样貌似多编辑器就不会冲突了
if(editor.edit == undefined || editor.edit.iframe == undefined){ if(editor.edit == undefined || editor.edit.iframe == undefined){
return; return;
} }
@ -329,7 +331,6 @@ function enablePasteImg(_editor) {
console.log("dataURL: " + data.dataURL); console.log("dataURL: " + data.dataURL);
console.log("width: " + data.width); console.log("width: " + data.width);
console.log("height: " + data.height); console.log("height: " + data.height);
console.log(data.blob);
var blob = dataURItoBlob(data.dataURL); var blob = dataURItoBlob(data.dataURL);
if (data.blob !== null) { if (data.blob !== null) {
var data = new FormData(); var data = new FormData();
@ -342,6 +343,7 @@ function enablePasteImg(_editor) {
data: data, data: data,
processData: false, processData: false,
success: function(data) { success: function(data) {
console.log(data);
editor.exec('insertimage', JSON.parse(data).url); editor.exec('insertimage', JSON.parse(data).url);
} }
}); });
@ -349,37 +351,5 @@ function enablePasteImg(_editor) {
}); });
return; 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]) { if (!img["_paste_marked_" + timespan]) {
cb(img.src); cb(img.src);
} }
//firefox问题处理因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
if ($(img).attr('src').startsWith('data:image/')) {
_results.push($(img).remove()); _results.push($(img).remove());
};
} }
return _results; return _results;
}; };
@ -293,7 +296,6 @@ https://github.com/layerssss/paste.js
KindEditor.plugin('paste', function(K) { KindEditor.plugin('paste', function(K) {
var editor = this, var editor = this,
name = 'paste'; name = 'paste';
//这样貌似多编辑器就不会冲突了
if(editor.edit == undefined || editor.edit.iframe == undefined){ if(editor.edit == undefined || editor.edit.iframe == undefined){
return; return;
} }
@ -329,7 +331,6 @@ KindEditor.plugin('paste', function(K) {
console.log("dataURL: " + data.dataURL); console.log("dataURL: " + data.dataURL);
console.log("width: " + data.width); console.log("width: " + data.width);
console.log("height: " + data.height); console.log("height: " + data.height);
console.log(data.blob);
var blob = dataURItoBlob(data.dataURL); var blob = dataURItoBlob(data.dataURL);
if (data.blob !== null) { if (data.blob !== null) {
var data = new FormData(); var data = new FormData();
@ -342,6 +343,7 @@ KindEditor.plugin('paste', function(K) {
data: data, data: data,
processData: false, processData: false,
success: function(data) { success: function(data) {
console.log(data);
editor.exec('insertimage', JSON.parse(data).url); editor.exec('insertimage', JSON.parse(data).url);
} }
}); });
@ -349,37 +351,5 @@ KindEditor.plugin('paste', function(K) {
}); });
return; 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…
Cancel
Save