Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripping styles from TinyMCE copy+paste?

is there a way to strip specific tags from coming into tiny MCE through a copy+paste from an external source (e.g. Word)? I'd like to prevent font-family and image tags from being copy+pasted over, but have no problem with font-size etc.

Thank you!

like image 260
Walker Avatar asked Oct 24 '11 16:10

Walker


Video Answer


3 Answers

You can't really stop someone from pasting something, so I believe your best bet would be to filter out the unwanted tags by calling a function on form submit, or onchange of the tiny MCE textarea. Then you could use some regular expression replacement to get rid of the unwanted tags.

EDIT: Actually there is a simple way. check the TinyMCE documentation.

like image 138
Brian Glaz Avatar answered Oct 05 '22 23:10

Brian Glaz


Here is the link to a similar SO question with a detailed description of howto strip out unwanted tags: TinyMCE Paste As Plain Text

like image 20
Thariama Avatar answered Oct 05 '22 23:10

Thariama


I don't know how useful this will be, but you might want to take a look at this jQuery plugin which allows you to filter tags and attributed from the text your are pasting.

FilteredPaste.js - A jQuery Plugin To Filter & Clean Pasted Input

like image 40
Hirvesh Avatar answered Oct 05 '22 23:10

Hirvesh