未验证 提交 3452116e 编写于 作者: C catouse

* fix paste-image in kindeditor not work sometimes in windows.

上级 af53a1e1
......@@ -107,6 +107,24 @@ KindEditor.plugin('pasteimage', function(K) {
};
var pasteUrl = options.postUrl;
var findBase64OnPaste = function() {
setTimeout(function() {
var html = K(doc.body).html();
if(html.search(/<img src="data:.+;base64,/) > -1) {
pasteBegin();
$.post(pasteUrl, {editor: html}, function(data) {
if(data.indexOf('<img') === 0) data = '<p>' + data + '</p>';
self.undo();
self._redoStack.pop();
edit.html(data);
pasteEnd();
}).error(function()
{
pasteEnd(true);
});
}
}, 80);
};
$(doc.body).on('paste.ke' + uuid, function(ev) {
if (K.WEBKIT) {
/* Paste in chrome.*/
......@@ -126,7 +144,7 @@ KindEditor.plugin('pasteimage', function(K) {
}
}
var file = clipboardItem && clipboardItem.getAsFile();
if (!file) return;
if (!file) return findBase64OnPaste();
original.preventDefault();
pasteBegin();
......@@ -157,22 +175,7 @@ KindEditor.plugin('pasteimage', function(K) {
reader.readAsDataURL(file);
} else {
/* Paste in firefox and other browsers. */
setTimeout(function() {
var html = K(doc.body).html();
if(html.search(/<img src="data:.+;base64,/) > -1) {
pasteBegin();
$.post(pasteUrl, {editor: html}, function(data) {
if(data.indexOf('<img') === 0) data = '<p>' + data + '</p>';
self.undo();
self._redoStack.pop();
edit.html(data);
pasteEnd();
}).error(function()
{
pasteEnd(true);
});
}
}, 80);
findBase64OnPaste();
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册