Ben Borgers / Posts /

Disabling file uploads with the Trix editor

January 24, 2021 by @benborgers

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 => {

A quick favor: was anything I wrote incorrect or misspelled, or do you still have questions? Please use this form to let me know or ask for help!