Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underline Functionality Addition #58

Closed
JohnWeidmann opened this issue Jun 21, 2024 · 1 comment
Closed

Underline Functionality Addition #58

JohnWeidmann opened this issue Jun 21, 2024 · 1 comment

Comments

@JohnWeidmann
Copy link

Would is be possible to request underline button for this text editor?

Thanks

@tonysm
Copy link
Owner

tonysm commented Aug 2, 2024

@JohnWeidmann Yep. You can register a new text attribute in Trix.

  1. Here's how text attributes are defined in Trix itself: https://github.com/basecamp/trix/blob/main/src/trix/config/text_attributes.js#L30-L33
  2. You'd have to add your custom text attribute after Trix boots (like this and this)
  3. Then, you'd have to either add your own toolbar or hook into the Trix initialization process (like this) and insert your new button into the text attributes (like this). I'd recommend using the <u> tag for that (mdn docs), but you need to style as underline via CSS to ensure all browsers render it the same way.

I'll cover this as a blog post soon, it's a nice example. Thanks!

@tonysm tonysm closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants