// Do not allow file attachments in rich text content addEventListener("trix-file-accept", function(event) { event.preventDefault(); }); Trix.config.textAttributes.underline = { style: { "textDecoration": "underline" }, inheritable: true, parser: function (element) { var style = window.getComputedStyle(element); return style.textDecoration === "underline"; } } document.addEventListener('trix-initialize', function (e) { const trix = e.target; const toolBar = trix.toolbarElement; // // Creation of the button const button = document.createElement("button"); button.setAttribute("type", "button"); button.setAttribute("class", "trix-button trix-button--icon trix-button--icon-underline"); button.setAttribute("data-trix-attribute", "underline"); button.setAttribute("title", "underline"); button.setAttribute("tabindex", "-1"); button.innerText = "U"; // Attachment of the button to the toolBar toolBar.querySelector('.trix-button-group--text-tools').appendChild(button); });