183 lines
5.2 KiB
HTML
183 lines
5.2 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_justify_button",
|
|
group: "extras",
|
|
icon: "align-justify",
|
|
perform: e => e.applySurround('[wrap="justify"]\n', '\n[/wrap]', 'align_justify_text')
|
|
});
|
|
});
|
|
|
|
// EXTRAS
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
id: "bleu_color",
|
|
action: "bleucolor",
|
|
icon: "palette",
|
|
label: "bleu_color_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
id: "rose_color",
|
|
action: "rosecolor",
|
|
icon: "palette",
|
|
label: "rose_color_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
id: "jaune_color",
|
|
action: "jaunecolor",
|
|
icon: "palette",
|
|
label: "jaune_color_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
id: "orange_color",
|
|
action: "orangecolor",
|
|
icon: "palette",
|
|
label: "orange_color_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
id: "rouge_color",
|
|
action: "rougecolor",
|
|
icon: "palette",
|
|
label: "rouge_color_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
id: "vert_color",
|
|
action: "vertcolor",
|
|
icon: "palette",
|
|
label: "vert_color_button"
|
|
};
|
|
});
|
|
|
|
api.modifyClass("controller:composer", {
|
|
actions: {
|
|
bleucolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#068EEF]', '[/color]', "bleu_color_text");
|
|
},
|
|
rosecolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#EF06A0]', '[/color]', "rose_color_text");
|
|
},
|
|
jaunecolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#EFC906]', '[/color]', "jaune_color_text");
|
|
},
|
|
orangecolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#EF8806]', '[/color]', "orange_color_text");
|
|
},
|
|
rougecolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#EF0606]', '[/color]', "rouge_color_text");
|
|
},
|
|
vertcolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#2A821C]', '[/color]', "vert_color_text");
|
|
},
|
|
}
|
|
});
|
|
|
|
// 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_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.bleu_color_button = settings.bleu_color_button;
|
|
translations.composer.bleu_color_text =
|
|
settings.bleu_color_text;
|
|
|
|
translations.rose_color_button = settings.rose_color_button;
|
|
translations.composer.rose_color_text =
|
|
settings.rose_color_text;
|
|
|
|
translations.jaune_color_button = settings.jaune_color_button;
|
|
translations.composer.jaune_color_text =
|
|
settings.jaune_color_text;
|
|
|
|
translations.orange_color_button = settings.orange_color_button;
|
|
translations.composer.orange_color_text =
|
|
settings.orange_color_text;
|
|
|
|
translations.rouge_color_button = settings.rouge_color_button;
|
|
translations.composer.rouge_color_text =
|
|
settings.rouge_color_text;
|
|
|
|
translations.vert_color_button = settings.vert_color_button;
|
|
translations.composer.vert_color_text =
|
|
settings.vert_color_text;
|
|
|
|
</script> |