Disabling file uploads with the Trix editor
May 3, 2020
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 => {
event.preventDefault()
})
Subscribe to my newsletter!
A weekly round-up of new blog posts and updates to projects Iâm working on.