What is the best way to add custom tags (like h1–h6) to ActionText?

I tried extending Trix — https://codepen.io/javan/pen/ZmbWGP.

h2 tags are rendered in Trix but are not saved to the database and all changes are lost on refresh.

See also:

I haven’t really dug into it yet (I’m still at work at the moment) But I’d assume you need to override or append to ActionTexts sanitize allowed_tags list.

Hi Brandon! Thank you for the reply!

Rails::Html::Sanitizer.safe_list_sanitizer.new.class.allowed_tags

already includes h2–h6, so appending h2 to this list doesn’t yield any result. It looks like Action Text supports an even narrower subset of tags.

I don’t know about saving in the database but you might find some inspiration to customize Trix here:

It would be great though, if this could be more easily supported out of the box.

it is so awesome, I am using it in production environment.