You can use my theme-component as an example:
https://github.com/MonDiscourse/md-composer-extras
You have two options, add an icon to the toolbar or on the gear menu
Toolbar:
api.onToolbarCreate(toolbar => {
toolbar.addButton({
id: "align_justify_button",
group: "extras",
icon: "align-justify",
perform: e => e.applySurround('[wrap="justify"]\n', '\n[/wrap]', 'align_justify_text')
});
});
Gear menu
api.addToolbarPopupMenuOptionsCallback(() => {
return {
action: "floatleft",
icon: "indent",
label: "float_left_button"
};
});
You can have some extra options with a plugin, but the component should be enough : GitHub - MonDiscourse/discourse-formatting-toolbar: Add formatting options on your post (center, align to right, justify a text, etc.) · GitHub
