This is a migrated thread and some comments may be shown as answers.

Update Editor content on paste

5 Answers 546 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 16 May 2012, 04:19 PM
Hello,

I have an Editor where I have setup with the "paste" event.  I am having no problem with the event firing it is that I can't get it to replace the content correctly.  Here is a working example of the problem http://jsfiddle.net/WgvNr/3/.  To test paste in some Microsoft Word content with some formatting.  The paste event will strip the Word formatting.  This works also, but it leaves the original content and the edited content. How can I just have the edited content show in the editor?
$("#txtActions").kendoEditor({
    tools: [
     "bold",
     "italic",
     "underline",
     "insertUnorderedList",
     "insertOrderedList",
 ],
    paste: function (e) {
        var editor = $("#txtActions").data("kendoEditor");
        editor.value(CleanWordHTML(e.html));
        //console.log(editor);
    }
});
 

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 May 2012, 12:28 PM
Hi Michael,

You can use setTimeout to set the new Editor value.

Greetings,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michael
Top achievements
Rank 1
answered on 17 May 2012, 02:25 PM
Could you elaborate a bit?  I added the setTimeout and it still does the same thing.

$("#txtActions").kendoEditor({
    tools: [
     "bold",
     "italic",
     "underline",
     "insertUnorderedList",
     "insertOrderedList",
 ],
    paste: function (e) {
        var editor = $("#txtActions").data("kendoEditor");
        setTimeout(editor.value(CleanWordHTML(e.html)),100);
        //console.log(editor);
    }
});
0
Dimo
Telerik team
answered on 19 May 2012, 09:15 AM
Hello Michael,

The setTimeout method accepts either a function reference (recommended), or a string as first argument. The current implementation is producing a Javascript error.

https://developer.mozilla.org/en/DOM/window.setTimeout

Regards,
Dimo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Klas
Top achievements
Rank 1
answered on 23 Aug 2012, 09:15 AM
I am actually surprised that this functionality isn't built in. Hopefully you can add it to Q3.
0
Alex
Top achievements
Rank 1
answered on 19 Mar 2013, 05:21 AM
I believe all you need in that case is to write event handler in this way
paste: function (e) {
    e.html = CleanWordHTML(e.html);
}
editor then will use modified html content to paste it into right position

PS. I wish documentation on editor events will be better - right now you need to learn javascript source codes to understand how things are working there...
Tags
Editor
Asked by
Michael
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Michael
Top achievements
Rank 1
Klas
Top achievements
Rank 1
Alex
Top achievements
Rank 1
Share this question
or