Skip to content

Trix sanitizer stripping out custom <u> tags on editor form render #864

@spovich

Description

@spovich

Hi, I've implemented action-text in our Rails 6 app to get some user-provided text that we put in generated PDFs (prawn). Everything is great except that Trix doesn't support the underline tag.

I've updated ActionText Trix.config.textAttributes to include u as a valid tagName and I've created a custom toolbar that adds a button for underline. The <u> tags are properly getting stored in the database when the form is saved.

I then added Rails::Html::SafeListSanitizer.allowed_tags << "u" to get the rendered show view to stop stripping the <u> tags.

So, everything is great except when re-rendering the editor form, the <u> tags are stripped.

In reading discussions and looking at the code, defining u as a tagName in Trix.config.textAttributes should mean that Trix.HTMLSanitizer includes that tag in the list of allowed attributes, but that isn't happening.

Any ideas on this last step to make a custom textAttribute tag work correctly for a full life-cycle?

Details
  • Trix version: Rails 6.0.3
  • Browser name and version Chrome latest
  • Operating system: Mac OS X

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions