2012-12-04 181 views

回答

4

Here是一个相关的问题。似乎可以在最新的Chrome和Firefox中使用。并且可以在剑道编辑器通过一些代码插:

var editor = $("#editor").data("kendoEditor"); 

$(editor.document).on("paste", function(e) { 
    var clipboard = e.originalEvent.clipboardData; 

    if (clipboard && clipboard.items) { 
     var screenshot = clipboard.items[0]; 

     if (screenshot.kind == "file") { 
      var blob = screenshot.getAsFile(); 

      var reader = new FileReader(); 

      reader.onload = function(event){ 
      var html = kendo.format('<img src="{0}"/>', event.target.result); 

      editor.paste(html); 
      }; 

      reader.readAsDataURL(blob); 
     } 
    } 
}); 

这里是一个现场演示:http://jsbin.com/utapal/1/edit

+0

谢谢。还有一个问题,我如何将粘贴的值保存到数据库中。我的意思是我需要将它们转换为流并保存到数据库中 – Jonathan

+0

您需要提取图像的“src”属性的值。它包含base64格式的图像数据。有关数据URI的更多信息可以在这里找到:http://en.wikipedia.org/wiki/Data_URI_scheme –

+0

我怎么能在ie和safari中做到这一点 - 谢谢 – Jonathan