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

Paste option editor

7 Answers 121 Views
Editor
This is a migrated thread and some comments may be shown as answers.
I. Breukink
Top achievements
Rank 1
I. Breukink asked on 27 Nov 2014, 03:55 PM
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

7 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 27 Nov 2014, 04:07 PM
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!
 
0
I. Breukink
Top achievements
Rank 1
answered on 27 Nov 2014, 04:27 PM
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
0
Alex Gyoshev
Telerik team
answered on 28 Nov 2014, 08:52 AM
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!
 
0
I. Breukink
Top achievements
Rank 1
answered on 28 Nov 2014, 09:11 AM
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
0
Alex Gyoshev
Telerik team
answered on 28 Nov 2014, 09:49 AM
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!
 
0
I. Breukink
Top achievements
Rank 1
answered on 28 Nov 2014, 11:41 AM
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
0
Alex Gyoshev
Telerik team
answered on 28 Nov 2014, 02:12 PM
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!
 
Tags
Editor
Asked by
I. Breukink
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
I. Breukink
Top achievements
Rank 1
Share this question
or