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.