Paste option editor

8 posts, 0 answers
  1. I. Breukink
    I. Breukink avatar
    24 posts
    Member since:
    Dec 2008

    Posted 27 Nov 2014 Link to this post

    I want to strip all formatting from a paste of a word document in the editor. I use the sample http://dojo.telerik.com/obaPu , with paste-function overide:

    paste: function(e) {
        e.value((e.html).text());
     }


    If I look a the editor in this example, it has still the formatted text. Even if i replace 
    e.value((e.html).text()); by
    e.value("test");
    still the pasted text has not been changed. What am i doing wrong?

    Thanks
  2. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 27 Nov 2014 Link to this post

    Hello Ivor,

    To update the pasted text, update the e.html field:

    paste: function(e) {
        e.html = $(e.html).text();
    }

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. I. Breukink
    I. Breukink avatar
    24 posts
    Member since:
    Dec 2008

    Posted 27 Nov 2014 Link to this post

    Thanks Alex,

    It is working now in that example.
    I now have transformed it to my situation and it is not working. This is a different error and reported in a previous thread but apparently still not fixed. You can see the example in http://dojo.telerik.com/obaPu/4 . The paste of a word-text creates another contenteditable line and paste the text outside the editor.

    Thanks
  5. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 28 Nov 2014 Link to this post

    Hello Ivor,

    Can you please provide the document that you are pasting from, and the exact steps you take, so that we can reproduce the issue?

    I noticed that the approach for removing tags through jQuery breaks the pasting of text (since the $() function will treat "asdf" as a selector, and try to match elements rather than creating a fragment). This can be mitigated by removing tags via a regex, like shown in this updated sample.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. I. Breukink
    I. Breukink avatar
    24 posts
    Member since:
    Dec 2008

    Posted 28 Nov 2014 Link to this post

    Thanks Alex,

    This works perfectly.
    I only have one question left. How can I only preserve the line-breaks in this conversion (like pasting the text in html-mode). Now a complete text with linebreaks comes out as a single line. 

    Thanks
  7. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 28 Nov 2014 Link to this post

    Hello Ivor,

    You may need to use a more complex regex (or replace function). Here's the updated sample.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. I. Breukink
    I. Breukink avatar
    24 posts
    Member since:
    Dec 2008

    Posted 28 Nov 2014 Link to this post

    Hi Alex,

    I thought it was working, but on testing on my own application it was still going wrong. It took me a while, but now i found a reproducable situation. It appears that there is a difference between Firefox and IE11. I have enclosed screenshots of the before and after paste on Firefox 33.1 and IE 11.0.9600. Also the worddocument is enclosed.
    The test-url is http://dojo.telerik.com/uVed/2

    You can see in firefox that the pasted text is completely different and more important it is pasted outside the editor, so it can not be accessed anymore.
    Can you reproduce this also and if so, how can i fix this?

    Thanks
  9. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 28 Nov 2014 Link to this post

    Hello Ivor,

    We are able to reproduce the issue, and it is caused by the specific Word document. It has been logged for fixing.

    Regards,
    Alex Gyoshev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready