Ticket #202 (new enhancement)
Improve direct pasting rich text (from Word)
Reported by: | nathany | Owned by: | jf.hovinne |
---|---|---|---|
Priority: | major | Milestone: | 1.x |
Component: | editor | Version: | trunk |
Keywords: | Cc: |
Description
I've found that people forget to use "Paste from Word" type features, so it would be better to improve handling of pasting directly. I did some simple tests with 0.50 rc1 in Safari 4 and Word 2008 Mac and but noticed a few issues.
- If I'm inside a "p" while pasting, I get paragraphs nested inside that paragraph, instead of new paragraphs falling bellow.
- If I make some big colorful text in Word, it appears that way in the editor even though viewing HTML looks to have it correct (my "strong" carried over but the other junk did not).
- It would be nice to do some cleanup, such as removing blank "p" lines between the pasted paragraphs or collapsing trailing/initial spaces. Maybe a good candidate for a plugin.
Change History
comment:2 Changed 2 years ago by nathany
I heard that CKeditor 3.1+ does paste detection now, but I haven't tried it or investigated the (massive amounts of) code yet.
comment:3 Changed 2 years ago by mr_lundis
Here are some relevant resources for anyone who's interested.
Relevant CKeditor tickets:
http://dev.fckeditor.net/ticket/4379
Corresponding TinyMCE plugin:
http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste
http://github.com/tinymce/tinymce/blob/master/jscripts/tiny_mce/plugins/paste/editor_plugin_src.js
comment:5 Changed 2 years ago by mr_lundis
It's rather easy to capture the plain text value of whats pasted into the editor trough the paste event, however you can not access the html version through the paste event in any browser as far as I'm aware, which sucks!
So my idea for now is to force plain text pases into WYMeditor, and to improve the paste from word dialog to allow for richer formating.
Another possible route would be to store the current content on paste (an array of the current elements in the editor?) and using that information do an aggressive cleanup targeting only the newly pasted content. We could also insert a temporary element around the current selection as another way of targeting the pasted content. Either way, for this to work we'd need to find some creative way of detecting when the content has been pasted. Polling?
comment:6 Changed 21 months ago by padelt
It seems that CKEditor in fact solve exactly this problem. It is open source. Is there an open technical problem or could their solution be transplanted to WYMeditor? Would a bounty help? For my users (of django cms) the current state of pasting semi-formatted elements into WYMeditor is not bearable.
This issue have been discussed heavily in the forums. The detection of pastes is what's making this hard, at least if you want to clean just the pasted content. If I remember correctly detecting pastes is possible in IE, but doesn't work in Mozilla-based browsers as accessing the clipboard is considered a security risk. I don't know how things work in Safari and other webkit-based browsers. Ideally you want the same behavior in all browsers, and there's been other thing higher up on the to-do list, thus we've never gotten around to implementing any paste cleanups.
There is one other possibility though - to just "clean" all content a little bit harder (i.e. removing everything that's not pure text/content.) Do a quick search and I think you'll find some reg-ex's that'll do the job...
If you feel up for the task of implementing this functionality - go ahead! Help is always welcome!