151 lines
4.1 KiB
HTML
151 lines
4.1 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')
|
|
});
|
|
});
|
|
|
|
// EXTRAS
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "strikethrough",
|
|
icon: "strikethrough",
|
|
label: "strikethrough_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "superscript",
|
|
icon: "superscript",
|
|
label: "superscript_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "subscript",
|
|
icon: "subscript",
|
|
label: "subscript_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "aligncenter",
|
|
icon: "align-center",
|
|
label: "align_center_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "alignright",
|
|
icon: "align-right",
|
|
label: "align_right_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "alignjustify",
|
|
icon: "align-justify",
|
|
label: "align_justify_button"
|
|
};
|
|
});
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "floatleft",
|
|
icon: "indent",
|
|
label: "float_left_button"
|
|
};
|
|
});
|
|
|
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
|
return {
|
|
action: "bbcodecolor",
|
|
icon: "palette",
|
|
label: "bbcode_color_button"
|
|
};
|
|
});
|
|
|
|
api.modifyClass("controller:composer", {
|
|
actions: {
|
|
strikethrough() {
|
|
this.get("toolbarEvent").applySurround("<s>", "</s>", "strikethrough_text");
|
|
},
|
|
superscript() {
|
|
this.get("toolbarEvent").applySurround("<sup>", "</sub>", "superscript_text");
|
|
},
|
|
subscript() {
|
|
this.get("toolbarEvent").applySurround("<sub>", "</sub>", "subscript_text");
|
|
},
|
|
aligncenter() {
|
|
this.get("toolbarEvent").applySurround('[wrap="center"]\n', '\n[/wrap]', "align_center_text");
|
|
},
|
|
alignright() {
|
|
this.get("toolbarEvent").applySurround('[wrap="right"]\n', '\n[/wrap]', "align_right_text");
|
|
},
|
|
alignjustify() {
|
|
this.get("toolbarEvent").applySurround('[wrap="justify"]\n', '\n[/wrap]', "align_justify_text");
|
|
},
|
|
floatleft() {
|
|
this.get("toolbarEvent").applySurround('[wrap="floatl"]\n', '\n[/wrap]', "float_left_text");
|
|
},
|
|
bbcodecolor() {
|
|
this.get("toolbarEvent").applySurround('[color=#222]', '[/color]', "bbcode_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.align_center_button = settings.align_center_button;
|
|
translations.composer.align_center_text =
|
|
settings.align_center_text;
|
|
|
|
translations.align_right_button = settings.align_right_button;
|
|
translations.composer.align_right_text =
|
|
settings.align_right_text;
|
|
|
|
translations.align_justify_button = settings.align_justify_button;
|
|
translations.composer.align_justify_text =
|
|
settings.align_justify_text;
|
|
|
|
translations.strikethrough_button = settings.strikethrough_button;
|
|
translations.composer.strikethrough_text =
|
|
settings.strikethrough_text;
|
|
|
|
translations.superscript_button = settings.superscript_button;
|
|
translations.composer.superscript_text =
|
|
settings.superscript_text;
|
|
|
|
translations.subscript_button = 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;
|
|
|
|
translations.bbcode_color_button = settings.bbcode_color_button;
|
|
translations.composer.bbcode_color_text =
|
|
settings.bbcode_color_text;
|
|
|
|
</script>
|