All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

How to disable File Upload in the Trix editor?

This content has been automatically translated from Ukrainian.
Trix - Rich Text Editor created by the Basecamp team (developers of Ruby on Rails). A decent editor if you don't need to do any specific things. There is currently no good API for customizing options.
Many discussions on GitHub only mention that customizing Trix needs to be done +/- independently through manipulations in JS and CSS code.
To disable the file upload feature in the editor, it is suggested:
1. Use JS to ignore trix-file-accept
document.addEventListener("trix-file-accept", function(event) {
  event.preventDefault();
});
2. Use CSS to hide the button:
.trix-button-group.trix-button-group--file-tools {
    display: none;
}
Or do everything in JS (ignore trix-file-accept and remove the button)
(function() {
  addEventListener("trix-initialize", function(e) {
    const file_tools = document.querySelector(".trix-button-group--file-tools");
    file_tools.remove();
  })
  addEventListener("trix-file-accept", function(e) {
    e.preventDefault();
  })
})();
Overall, the concept is clear. You have to do everything yourself. Don't forget to encapsulate the code. Because this code will work on all instances of the Trix editor on the page

This post doesn't have any additions from the author yet.

03 May 17:46

What to do if the webcam is not working on macOS?

meme code
meme code@memecode
03 May 18:48

How to get a random logical value true or false in Ruby?

meme code
meme code@memecode
10 May 17:40

How to use hex color codes in CSS with alpha values?

meme code
meme code@memecode
16 May 20:02

What is Origin in Git?

meme code
meme code@memecode
16 May 22:17

How to remove the space between inline and inline-block elements?

meme code
meme code@memecode
17 May 18:52

What is a loop in Javascript? How do for and while loops work in Javascript?

meme code
meme code@memecode
22 May 16:26

What is the difference between <%, <%=, <%# and -%> in ERB templates (Ruby on Rails)?

meme code
meme code@memecode
23 May 06:57

What is debugging?

meme code
meme code@memecode