Trix - amssdias/multitenant-blog-platform GitHub Wiki
This blog project uses Trix Editor to provide rich-text editing capabilities for blog posts. Trix is a lightweight, WYSIWYG editor built by Basecamp that outputs clean HTML, making it ideal for storing and rendering user-generated content in blogs.
- Lightweight and easy to integrate
- Outputs clean HTML
- Built-in support for formatting (bold, italic, links, lists, etc.)
- Secure by default (no inline JS)
Trix is added to the frontend via a package manager or CDN:
<link rel="stylesheet" href="https://unpkg.com/trix/dist/trix.css">
<script src="https://unpkg.com/trix/dist/trix.js"></script>To use the Trix editor on a blog post form:
<form method="post" action="/posts">
<input id="post_content" type="hidden" name="post[content]">
<trix-editor input="post_content"></trix-editor>
</form>- The
post[content]field receives the Trix HTML output. - This content is stored as-is in the database (usually as HTML-safe text).
Each tenant uses the same Trix configuration. However, we can:
- Override Trix CSS per-tenant for branding
- Add tenant-specific extensions (e.g. custom embeds or toolbars)
- Toolbar: Custom tools or buttons can be added by modifying the Trix toolbar.
-
Events: Trix emits events like
trix-change,trix-attachment-addfor advanced use. -
Sanitization: Consider using HTML sanitizers server-side (e.g.
sanitize-html,Loofah, etc.) to ensure saved content is safe.
- Trix Docs: https://trix-editor.org/
- GitHub: https://github.com/basecamp/trix