Add float and columns, move strikethrough.

This commit is contained in:
T. H. Wright 2019-11-13 10:34:59 -05:00
parent 51ba2452c1
commit 95dbbc6962
4 changed files with 63 additions and 26 deletions

View File

@ -4,6 +4,6 @@
"license_url": null, "license_url": null,
"about_url": "https://www.mon-discourse.fr/themes/md-composer-extras/", "about_url": "https://www.mon-discourse.fr/themes/md-composer-extras/",
"authors": "Steven", "authors": "Steven",
"theme_version": "1.2", "theme_version": "1.3",
"learn_more": "https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966" "learn_more": "https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966"
} }

View File

@ -9,3 +9,18 @@
[data-wrap="justify"] { [data-wrap="justify"] {
text-align: justify; text-align: justify;
} }
[data-wrap="columns"] {
width: 50%;
float: left;
}
[data-wrap="floatl"] {
float: left;
margin-right: 10px;
}
[data-wrap="floatr"] {
float: right;
margin-left: 10px;
}

View File

@ -1,7 +1,5 @@
<script type="text/discourse-plugin" version="0.8"> <script type="text/discourse-plugin" version="0.8">
const { iconNode } = require("discourse-common/lib/icon-library"); const { iconNode } = require("discourse-common/lib/icon-library");
// TOOLBAR // TOOLBAR
api.onToolbarCreate(toolbar => { api.onToolbarCreate(toolbar => {
toolbar.addButton({ toolbar.addButton({
@ -11,6 +9,14 @@ api.onToolbarCreate(toolbar => {
perform: e => e.applySurround('[u]', '[/u]', 'underline_text') 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_prompt')
});
});
api.onToolbarCreate(toolbar => { api.onToolbarCreate(toolbar => {
toolbar.addButton({ toolbar.addButton({
id: "align_center_button", id: "align_center_button",
@ -35,25 +41,22 @@ api.onToolbarCreate(toolbar => {
perform: e => e.applySurround('[wrap="justify"]\n', '\n[/wrap]', 'align_justify_text') perform: e => e.applySurround('[wrap="justify"]\n', '\n[/wrap]', 'align_justify_text')
}); });
}); });
api.onToolbarCreate(toolbar => {
toolbar.addButton({
// EXTRAS id: "columns_button",
api.addToolbarPopupMenuOptionsCallback(() => { group: "extras",
return { icon: "columns",
action: "strikethrough", perform: e => e.applySurround('[wrap="columns"]\n', '\n[/wrap]', 'columns_text')
icon: "strikethrough", });
label: "strikethrough_button"
};
}); });
api.modifyClass("controller:composer", { api.onToolbarCreate(toolbar => {
actions: { toolbar.addButton({
strikethrough() { id: "float_left_button",
this.get("toolbarEvent").applySurround("<s>", "</s>", "strikethrough_prompt"); group: "extras",
}, icon: "indent",
} perform: e => e.applySurround('[wrap="floatl"]\n', '\n[/wrap]', 'float_left_text')
});
}); });
// TEXTS // TEXTS
let translations = I18n.translations[I18n.currentLocale()].js; let translations = I18n.translations[I18n.currentLocale()].js;
if (!translations) { if (!translations) {
@ -69,16 +72,19 @@ translations.composer.underline_text =
translations.composer.align_center_button_title = settings.align_center_button; translations.composer.align_center_button_title = settings.align_center_button;
translations.composer.align_center_text = translations.composer.align_center_text =
settings.align_center_text; settings.align_center_text;
translations.composer.align_right_button_title = settings.align_right_button; translations.composer.align_right_button_title = settings.align_right_button;
translations.composer.align_right_text = translations.composer.align_right_text =
settings.align_right_text; settings.align_right_text;
translations.composer.align_justify_button_title = settings.align_justify_button; translations.composer.align_justify_button_title = settings.align_justify_button;
translations.composer.align_justify_text = translations.composer.align_justify_text =
settings.align_justify_text; settings.align_justify_text;
translations.strikethrough_button = settings.strikethrough_button; translations.strikethrough_button = settings.strikethrough_button;
translations.composer.strikethrough_prompt = translations.composer.strikethrough_prompt =
settings.strikethrough_prompt; settings.strikethrough_prompt;
</script> translations.composer.columns_button_title = settings.columns_button;
translations.composer.columns_text =
settings.columns_text;
translations.composer.float_left_button_title = settings.float_left_button;
translations.composer.float_left_text =
settings.float_left_text;
</script>

View File

@ -38,10 +38,26 @@ strikethrough_prompt:
default: "Text" default: "Text"
description: description:
en: Enter the placeholder text that appears in the composer after the user clicks the button. en: Enter the placeholder text that appears in the composer after the user clicks the button.
float_left_button:
default: "Float left"
description:
en: Enter the text for the title of the button in the composer.
float_left_text:
default: "Text"
description:
en: Enter the placeholder text that appears in the composer after the user clicks the button.
columns_button:
default: "Columns"
description:
en: Enter the text for the title of the button in the composer.
columns_text:
default: "Use the closing tag to mark where the column ends."
description:
en: Enter the placeholder text that appears in the composer after the user clicks the button.
Svg_icons: Svg_icons:
type: 'list' type: 'list'
list_type: 'compact' list_type: 'compact'
default: 'fa-align-center|fa-align-right|fa-align-justify|fa-strikethrough|fa-underline' default: 'fa-align-center|fa-align-right|fa-align-justify|fa-strikethrough|fa-underline|fa-indent|fa-columns'
description: description:
en: "Include FontAwesome 5 icon classes for each icon used in the list." en: "Include FontAwesome 5 icon classes for each icon used in the list."