Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I paste an image from the clipboard to Kendo UI Editor? [closed]

Tags:

kendo-ui

I am using the Kendo UI Editor widget. I want to paste the content of the print screen. How can I do that?

Regards,

Naidu

like image 797
Jonathan Avatar asked Dec 04 '12 07:12

Jonathan


1 Answers

Here is a related question. Seems to work in latest Chrome and Firefox. And can be plugged in the Kendo Editor via some code:

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);
      }
  }
});

And here is a live demo: http://jsbin.com/utapal/1/edit

like image 71
Atanas Korchev Avatar answered Sep 22 '22 05:09

Atanas Korchev