github.com/basecamp/trix ↗
A rich text editor for everyday writing
Open this visualization on its own page →
Contributors
51
Lines of Code
8,750
From
2014-02-18
To
2023-01-24
About basecamp/trix
Trix is a WYSIWYG rich text editor built by Basecamp for everyday writing tasks like messages, comments, and articles. It handles formatted text, embedded attachments, and outputs clean, consistent HTML suitable for the simple documents most web applications need to manage.
The project takes a distinctive architectural approach by treating the browser's contenteditable API as an input/output device rather than directly manipulating it. When users type or paste content, Trix converts that input into operations on an internal document model, then re-renders the result. This gives developers complete control over editor behavior at every keystroke and eliminates the need to use the error-prone execCommand API, an approach that has since become standard in modern production WYSIWYG editors.
Built with web standards including Custom Elements, Element Internals, Mutation Observer, and Promises, Trix works across all evergreen browsers on desktop and mobile. The editor integrates with HTML forms through Element Internals support, validates content using the Constraint Validation API, and provides extensive programmatic control through methods for text manipulation, attribute formatting, selection management, and undo/redo functionality. Developers can also customize rendering, listen to detailed change events, and extend functionality with custom toolbar actions.