Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
CLEditor or alternative, "paste as text" by default ?
Is it possible to configure CLEditor to "paste as text" by default. I know there is a button "paste as text" but people don't use it, and i don't want to keep the style of the source text.
Tagged:
0
Comments
You should be able to remove the main "paste" function by editing:
plugins/cleditor/jquery.cleditor.js
Remove "paste" from the controls section:
controls: // controls to add to the toolbar "bold italic underline strikethrough subscript superscript | font size " + "style | color highlight removeformat | bullets numbering | outdent " + "indent | alignleft center alignright justify | undo redo | " + "rule image link unlink | cut copy paste pastetext | print source",
That leaves you with "pastetext" only. Calling whatever method pastetext uses for every key stroke and onchange action is a road that leads to madness (chicken and the egg issues, performance problems, horrible regexps needed, etc.). If that is what you wanted, just disable the module altogether and be done with it.
Cheers
Let say someboby copies a text from a .doc document and copies it (ctrl+v) in CLEditor, the html formating from the original document will be kept (this is what i don't want! just need the plain text)
To do what you want means trying to modify the event handlers for CLEditor to trap all known keypresses that correspond to paste operations as well as probably onchange() and onkeyup() (not sure what OS menu chosen "paste" functions appear to Javascript as). You would also have to make sure that none of CLEditor's built in events conflict. This is not at all straight forward and also is nothing to do with Vanilla (CLEditor is a 3rd party library).
You can try asking your question on the CLEditor forum:
http://groups.google.com/group/cleditor
It is possible someone has come up with a solution but my initial feeling is that this is an unsolvable problem due to all the interactions involved. With the existing editor's "Paste as text" function, it is handled via a separate form element so it is trivial to pass that data to an arbitrary Javascript function *first* before appending it in the editor. The user hitting CTRL V is totally outside of that and handling this will almost for sure require unique changes per browser *and* per OS. That assumes that there even is a way to detect the difference between a copy and paste and the editor itself making changes to a form field.
It may sound like a simple question but there is a lot going on behind the scenes which makes what you ask far from straightforward.
Personally I would like to see all HTML markup removed from the editor and BBCode used instead since it should be much easier to safely sanitize.
Cheers