Hi,
Is it possible to clean the HTML code that is pasted using the normal paste (not the Paste From Word function)? I don't want to allow certain tags to be used on my site so I won't users to be able to paste them. (The only tags I allow are strong,em,a,img,h1,h2...)
When pasting from Word I can 'hack' the FCK.CleanAndPaste function in fckeditorcode_ie_2.js to strip all unwanted tags (and clean others). But is there a way to do so for the normal paste?
In a perfect world it seems rather nice to specify somewhere which tags you allow to be pasted in say fckconfig.js
Thanks for any advice!
Fri, 02/18/2005 - 03:00
#1
RE: How to clean HTML on normal paste?
I think you can do it on the next way:
File fckeditorcode_ie_2.js line 56. Modify
"if (FCKConfig.ForcePasteAsPlainText) FCK.Events.AttachEvent("OnPaste",FCK.Paste);"
to
"FCK.Events.AttachEvent("OnPaste",FCK.Paste);"
So, you force to use on every OnPaste event the FCK.Paste function.
On line 17 modify the FCK.Paste function. You have to modify the last "else return true;" to "else {FCK.CleanAndPaste(sHTML); return true;}".
In this way you force every paste event to go throught the CleanAndPaste function (if ForcePasteAsPlainText is set to paste). After that, you can modify the CleanAndPaste function as you wish.
Don't forget to make the same changes in the fckeditorcode_gecko_2.js file to get it working in other browser too.
Best regards,
Jos Benigno
RE: How to clean HTML on normal paste?
I did also on "fckconfig.js" set FCKConfig.ForcePasteAsPlainText = true ;
but if I paste html text on editor it mantain font, h1, h2, h3 and all other format tags.
Thanks