I need to paste as plain text to prevent all sorts of unwanted code and am using the config preference to do this which works well, but as much as I want 90% of that code removed I do need to keep links and retyping all these out is a real pain,m is there any way to solve this?
Tue, 08/28/2012 - 12:48
#1
Re: Paste as plain text but keep links
Re: Paste as plain text but keep links
When pasting from word or other sources as people tend to do lots unwanted code is added which is a real pain to deal with.
Pasting as plain text is a good fix but it goes to far, I don't want people to have to go through an article putting back loads of links a text styles like bold and italic.
All that's needed is a config to allow certain tags and paste the rest as text.
Re: Paste as plain text but keep links
Use paste event to alter the pasted text as you need.
Re: Paste as plain text but keep links
Hi,
In CKEditor 4, which is about to be released (for now you can check it on http://nightly-v4.ckeditor.com and https://github.com/ckeditor/ckeditor-dev), we've rewritten (or rather - written) pasted text "htmlification". This is a filter that is applied when using paste as text feature. In v3 we were basing on browsers, by just passing the content through textarea. Now this process is customized, but unfortunately not yet customizable. I know that paste as text is too brutal, so we'll add some config options for that in the near future.
Anyway, for now there's a quick hack. Htmlification is done by filters defined in getTextificationFilter in plugins/clipboard/plugin.js. The simplest patch you can apply to leave links is:
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+
Any word on config options for paste-as-text?
Hey Piotrek, any word on this:
We would love to have the ability to cut and paste within the document (for links, maybe bold, etc., in particular) without allowing ANY pasting of formatting (except links, maybe bold, etc.) from other sites.
Thanks!
Paste event doesn't have html
Event.data only has dataValue, which has already stripped out the html tags.
OBJECT
Since 4.1 there is better
Since 4.1 there is better solution for pasting. We introduced Advanced Content Filter which may be configured manually, but by default it is configured by features loaded in the editor. This is especially well visible when comparing these samples:
The forcePasteAsPlainText option is disabled in basic preset, but as you can see only links, images, lists, bold and italic may be pasted from other sites - everything else will be stripped out.
Compare this to the full preset and you'll see that it accepts a lot more, but still not everything.
And we believe that thanks to Advanced Content Filter forcePasteAsPlainText is not needed any more and therefore will not be automatically set to true in next releases.
Piotrek (Reinmar) Koszuliński
CKEditor JavaScript Developer
--
CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+