Files
old-holivud2/app/assets/javascripts/trix.js

30 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-05-31 22:38:19 +02:00
// Do not allow file attachments in rich text content
addEventListener("trix-file-accept", function(event) {
event.preventDefault();
2020-09-09 05:33:57 +02:00
});
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);
});