Opened 17 years ago
Closed 11 years ago
#856 closed New Feature (fixed)
Provision for a custom onPaste code cleanup function
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | |
Keywords: | SF | Cc: | Frederico Caldeira Knabben, Alfonso Martínez de Lizarrondo |
Description
Can you please add a custom code cleanup function (callback) that would be executed onPaste being fired into the main editor text area.
Reason: Many implementations of FCKEditor in an application would require end-users to create their own web pages (CMS). Consequently, if a end-user pastes in HTML from a 3rd party web site, the code would need to be cleaned in some way before being saved in a content repository (on the server) - for example to remove javascript onclick handlers or form elements. While this is is easy to do on the server side, the saved html would not be what the end-user had pasted into the editor, and thus confuse the end user.
It would be better if the cleanup could be done on the client side using the onPaste event before being displayed in the editor, so the user knows exactly what he/she is getting.
However, each implementing application's requirements for the cleaning algorithm would be different.
Thus, the requirements are:
- Provide a custom cleanup function callback that is
executed onPaste. The function can be an empty stub, that returns the raw html if not modified by the implementer. (maybe with a commented out regex example inside)
- Provide a config setting for turning this feature on
and off
- Obviously this would only work for browsers that
support access to the clipboard (Gecko browsers (firefox) currently do not - but would be there for when it does!)
Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1403554&group_id=75348&atid=543656
Change History (3)
comment:1 Changed 17 years ago by
Cc: | Frederico Caldeira Knabben Alfonso Martínez de Lizarrondo added |
---|---|
Reporter: | changed from Martin Kou to moonpool99@… |
comment:2 Changed 16 years ago by
Keywords: | Confirmed added |
---|
function myOnPaste(fck){ var data = fck.GetClipboardHTML(); fck.InsertHtml(data.length +'"'+ data +'"'); return false; } FCK.Events.AttachEvent( 'OnPaste', myOnPaste ) ;
This code works only in IE, in FF inserts 0"" because of:
FCK.GetClipboardHTML = function() { return '' ; }
comment:3 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | confirmed → closed |
Consequently, if a end-user pastes in HTML from a 3rd party web site, the code would need to be cleaned in some way before being saved in a content repository (on the server)
This can currently be achieved from CKEditor 4.1 with usage of ACF and inserHTml or setData functions.
I understood the request... just a way to use the FCKeditor Word Cleanup feature and interface, but calling a custom cleaning code.
Moved from SF. Original poster: fredck
You define a function and make it listen to OnPaste. Inside that function you read the clipboard (you can even use FCK.GetClipboardHTML), clean up however you like, put it inside the editor with FCK.InsertHtml and then return false so the event doesn't follow its normal processing.
There's no need at all to touch FCK internals as you can see.
Moved from SF. Original poster: alfonsoml
There is an OnPaste event, but nothing coded for the user to easily define a custom cleanup algorithm withou hacking the fck internals.
I am suggesting attaching a stub call from the onPaste event which the user can easily populate with some regexes to clean the pasted HTML with..
Moved from SF. Original poster: moonpool99
doesn't the OnPaste event work like that?
Moved from SF. Original poster: alfonsoml