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
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
0
Hello Ivor,
To update the pasted text, update the e.html field:
paste: function(e) {
e.html = $(e.html).text();
}
Regards,
Alex Gyoshev
Telerik
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
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
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
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
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
Hello Ivor,
You may need to use a more complex regex (or replace function). Here's the updated sample.
Regards,
Alex Gyoshev
Telerik
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
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
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
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!