124 lines
3.6 KiB
HTML
124 lines
3.6 KiB
HTML
<script type="text/discourse-plugin" version="0.8">
|
|
const { iconNode } = require("discourse-common/lib/icon-library");
|
|
// TOOLBAR
|
|
api.onToolbarCreate(toolbar => {
|
|
toolbar.addButton({
|
|
id: "underline_button",
|
|
group: "fontStyles",
|
|
icon: "underline",
|
|
perform: e => e.applySurround('[u]', '[/u]', 'underline_text')
|
|
});
|
|
});
|
|
api.onToolbarCreate(toolbar => {
|
|
toolbar.addButton({
|
|
id: "strikethrough_button",
|
|
group: "fontStyles",
|
|
icon: "strikethrough",
|
|
perform: e => e.applySurround('<s>', '</s>', 'strikethrough_text')
|
|
});
|
|
});
|
|
api.onToolbarCreate(toolbar => {
|
|
toolbar.addButton({
|
|
id: "superscript_button",
|
|
group: "fontStyles",
|
|
icon: "superscript",
|
|
perform: e => e.applySurround('<sup>', '</sup>', 'superscript_text')
|
|
});
|
|
});
|
|
api.onToolbarCreate(toolbar => {
|
|
toolbar.addButton({
|
|
id: "subscript_button",
|
|
group: "fontStyles",
|
|
icon: "subscript",
|
|
perform: e => e.applySurround('<sub>', '</sub>', 'subscript_text')
|
|
});
|
|
});
|
|
api.onToolbarCreate(toolbar => {
|
|
toolbar.addButton({
|
|
id: "align_center_button",
|
|
group: "extras",
|
|
icon: "align-center",
|
|
perform: e => e.applySurround('[wrap="center"]\n', '\n[/wrap]', 'align_center_text')
|
|
});
|
|
});
|
|
api.onToolbarCreate(toolbar => {
|
|
toolbar.addButton({
|
|
id: "align_right_button",
|
|
group: "extras",
|
|
icon: "align-right",
|
|
perform: e => e.applySurround('[wrap="right"]\n', '\n[/wrap]', 'align_right_text')
|
|
});
|
|
});
|
|
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')
|
|
});
|
|
});
|
|
|
|
// EXTRAS
|
|
api.addComposerToolbarPopupMenuOption({
|
|
action: (toolbarEvent) => {
|
|
toolbarEvent.applySurround('[wrap="floatl"]\n', '\n[/wrap]', "float_left_text");
|
|
},
|
|
icon: 'indent',
|
|
label: 'float_left_button',
|
|
});
|
|
|
|
api.addComposerToolbarPopupMenuOption({
|
|
action: (toolbarEvent) => {
|
|
toolbarEvent.applySurround('[wrap="columns"]\n', '\n[/wrap]', "columns_text");
|
|
},
|
|
icon: 'columns',
|
|
label: 'columns_button',
|
|
});
|
|
|
|
// TEXTS
|
|
let translations = I18n.translations[I18n.currentLocale()].js;
|
|
if (!translations) {
|
|
translations = {};
|
|
}
|
|
if (!translations.composer) {
|
|
translations.composer = {};
|
|
}
|
|
|
|
translations.composer.underline_button_title = settings.underline_button;
|
|
translations.composer.underline_text =
|
|
settings.underline_text;
|
|
|
|
translations.composer.align_center_button_title = settings.align_center_button;
|
|
translations.composer.align_center_text =
|
|
settings.align_center_text;
|
|
|
|
translations.composer.align_right_button_title = settings.align_right_button;
|
|
translations.composer.align_right_text =
|
|
settings.align_right_text;
|
|
|
|
translations.composer.align_justify_button_title = settings.align_justify_button;
|
|
translations.composer.align_justify_text =
|
|
settings.align_justify_text;
|
|
|
|
translations.composer.strikethrough_button_title = settings.strikethrough_button;
|
|
translations.composer.strikethrough_text =
|
|
settings.strikethrough_text;
|
|
|
|
translations.composer.superscript_button_title = settings.superscript_button;
|
|
translations.composer.superscript_text =
|
|
settings.superscript_text;
|
|
|
|
translations.composer.subscript_button_title = settings.subscript_button;
|
|
translations.composer.subscript_text =
|
|
settings.subscript_text;
|
|
|
|
translations.columns_button = settings.columns_button;
|
|
translations.composer.columns_text =
|
|
settings.columns_text;
|
|
|
|
translations.float_left_button = settings.float_left_button;
|
|
translations.composer.float_left_text =
|
|
settings.float_left_text;
|
|
|
|
</script>
|