One possible option is to use a theme component.
This goes in header.html
<script type="text/discourse-plugin" version="0.8">
var disclaimer = settings.Disclaimer_text,
disclaimer_selector = 'div[data-theme="disclaimer"]';
$.fn.disclaimer = function() {
if (!this.length) {
return;
} else {
this.each(function() {
$(this).html(disclaimer);
});
return this;
}
};
api.decorateCooked($elem => $elem.children(disclaimer_selector).disclaimer());
// create composer button
let currentLocale = I18n.currentLocale();
I18n.translations[currentLocale].js.disclaimer_button = "Add disclaimer";
I18n.translations[currentLocale].js.composer.disclaimer_prompt = ""; // leave empty
api.onToolbarCreate(function(toolbar) {
toolbar.addButton({
trimLeading: true,
id: "disclaimer-button",
group: "insertions",
icon: "exclamation-circle", // change icon
title: "disclaimer_button",
perform: function(e) {
return e.applySurround(
'<div data-theme="disclaimer">',
"</div>",
"disclaimer_prompt"
);
}
});
});
</script>
and this goes into your component’s settings.yml
file
Disclaimer_text:
default: "Lorem ipsum dolor sit amet, ei purto complectitur has, per at quas senserit. Et malis libris eos, vix id pericula dissentiet, aliquid apeirian pro eu. Sed ex viderer inciderint, vitae officiis dissentiet eos no. Omnes percipit singulis in has, ne nam nibh tation inciderint. Quas nulla ei sit, ex eam rebum voluptaria. Id eam altera similique. Ex justo assentior persequeris mea, ei hinc paulo ubique mei. <br><br>Cu nam epicurei torquatos, et accusam accommodare vim. Vis sint saperet officiis et. Ad consequat posidonium mea, et duo paulo quidam maluisset, vel an electram expetendis. An vis repudiare tincidunt, mentitum convenire eloquentiam ut vis, summo partiendo pro ad."
description:
en: Enter desired disclaimer text. Use <br> for linebreaks.
You would then have a button in the composer that looks like so:
and clicking the button would add
<div data-theme="disclaimer"></div>
which get’s converted to whatever you set in the component’s settings
and the end result looks like this
and you can use
[data-theme="disclaimer"] {
}
in CSS to style it however you like.