I'm using Trumbowyg which is a javascript text editor. My problem is, when I paste text from another site into the editor, it adopts the style of the text from that site. How can I prevent this?
My editor is rendered in my Django template like this:
{{ post.content }}
Is there a template tag I can use to remove HTML? Because the external styling is inline styles, eg <span style='font-family: Arial;font-size:30px'
etc..?
To remove styles from a formatted paste (styles pasted from clipboard) in Trumbowyg , set the removeformatPasted
option to true
:
$('.trumbowyg').trumbowyg({
removeformatPasted: true
});
But also keep in mind:
In order to use this option, you need to define a font size in your CSS or use a reset like normalize.
Remove format pasted is not active by default (set to false
).
You want to remove HTML tags? If yes just use:
{{ post.content|striptags }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.