2

I am using jQuery's jHTMLArea and its working great however when a user copies content from a webpage and pastes it into the editor, once saved it also copies all the html formatting.

Is there a way to strip any pasted content of all HTML tags?

The users will not have the knowledge to use the source code view.

Cheers

puks1978
  • 3,667
  • 11
  • 44
  • 103

1 Answers1

0

I tried to solve this same problem before and ran into a few roadblocks. The issue is that the os copies the content's format along with the text to your clipboard, so if you try pasting html back into ANY textarea (or html-formattable area) youll get your content back formatted.

Luckily Jquery gives you some control over the document's clipboard, so ideally the trick would be to intercept paste, paste the content into a hidden textfield (which wont grab formatting) and then copy the contents back into the jhtmlArea. I tried doing this a couple weeks ago with little success, but Im gonna take another look at it now and see if I can come up with something.

Catch paste input Might point you in the right direction

Good luck

Community
  • 1
  • 1
alex-e-leon
  • 332
  • 3
  • 12
  • I know this is forever old but did you guys ever figure out a way to do this? I tried doing what you mentioned in the answer but it doesn't quite work. – Jake Zeitz Jan 14 '16 at 19:34
  • 1
    @JakeZeitz I never ended up getting this working but you might want to look at https://github.com/zeroclipboard/jquery.zeroclipboard or any other plugins that hook into clipboard events. – alex-e-leon Jan 16 '16 at 01:04