Ben Borgers

All posts

Disabling file uploads with the Trix editor

Basecamp's Trix text editor lets people upload their own files into the text they're writing, but maybe you don't want to deal with file uploads at the moment.

To disable file uploads, first remove the "file" button (it looks like a paperclip) using CSS:

trix-toolbar [data-trix-button-group="file-tools"] {
  display: none;

This removes the button, but it doesn't stop people from dragging files in. For that, add this javascript that ignores file uploads whenever one is attempted:

document.addEventListener("trix-file-accept", event => {