Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


CLEditor or alternative, "paste as text" by default ?

edited January 2011 in Questions
This discussion is related to the CLEditor jQuery WYSIWYG addon.
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.





Comments

  • @glow

    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
  • thank you for the answer @codegrunt but actually this just removes the "paste" button. If one paste a text using ctrl+v, it will keep the source's style.

    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)
  • The second part of my answer covered that. Essentially, your only simple option is likely going to be to disable the HTML editor.

    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
Sign In or Register to comment.