Skip to content

A platform for community discussion. Free, open, simple.

UX: Show fewer toolbar icons in mobile composer (#14621)

Penar Musaraj7a4a1744a20e
diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index a1754cb56d7..a7a879d5b49 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -64,7 +64,7 @@ let _createCallbacks = [];
class Toolbar {
constructor(opts) {
- const { siteSettings } = opts;
+ const { site, siteSettings } = opts;
this.shortcuts = {};
this.context = null;
@@ -129,29 +129,31 @@ class Toolbar {
action: (...args) => this.context.send("formatCode", args),
});
- this.addButton({
- id: "bullet",
- group: "extras",
- icon: "list-ul",
- shortcut: "Shift+8",
- title: "composer.ulist_title",
- preventFocus: true,
- perform: (e) => e.applyList("* ", "list_item"),
- });
+ if (!site.mobileView) {
+ this.addButton({
+ id: "bullet",
+ group: "extras",
+ icon: "list-ul",
+ shortcut: "Shift+8",
+ title: "composer.ulist_title",
+ preventFocus: true,
+ perform: (e) => e.applyList("* ", "list_item"),
+ });
- this.addButton({
- id: "list",
- group: "extras",
- icon: "list-ol",
- shortcut: "Shift+7",
- title: "composer.olist_title",
- preventFocus: true,
- perform: (e) =>
- e.applyList(
- (i) => (!i ? "1. " : `${parseInt(i, 10) + 1}. `),
- "list_item"
- ),
- });
+ this.addButton({
+ id: "list",
+ group: "extras",
+ icon: "list-ol",
+ shortcut: "Shift+7",
+ title: "composer.olist_title",
+ preventFocus: true,
+ perform: (e) =>
+ e.applyList(
+ (i) => (!i ? "1. " : `${parseInt(i, 10) + 1}. `),
+ "list_item"
+ ),
+ });
+ }
if (siteSettings.support_mixed_text_direction) {
this.addButton({
diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js
index 56110de30bf..5fcbe09befd 100644
--- a/app/assets/javascripts/discourse/app/controllers/composer.js
+++ b/app/assets/javascripts/discourse/app/controllers/composer.js
@@ -318,6 +318,28 @@ export default Controller.extend({
})
);
+ if (this.site.mobileView) {
+ options.push(
+ this._setupPopupMenuOption(() => {
+ return {
+ action: "applyUnorderedList",
+ icon: "list-ul",
+ label: "composer.ulist_title",
+ };
+ })
+ );
+
+ options.push(
+ this._setupPopupMenuOption(() => {
+ return {
+ action: "applyOrderedList",
+ icon: "list-ol",
+ label: "composer.olist_title",
+ };
+ })
+ );
+ }
+
options.push(
this._setupPopupMenuOption(() => {
return {
@@ -679,6 +701,17 @@ export default Controller.extend({
});
});
},
+
+ applyUnorderedList() {
+ this.toolbarEvent.applyList("* ", "list_item");
+ },
+
+ applyOrderedList() {
+ this.toolbarEvent.applyList(
+ (i) => (!i ? "1. " : `${parseInt(i, 10) + 1}. `),
+ "list_item"
+ );
+ },
},
disableSubmit: or("model.loading", "isUploading", "isProcessingUpload"),
diff --git a/app/assets/stylesheets/common/d-editor.scss b/app/assets/stylesheets/common/d-editor.scss
index d014a7aeaa3..80878e04af9 100644
--- a/app/assets/stylesheets/common/d-editor.scss
+++ b/app/assets/stylesheets/common/d-editor.scss
@@ -230,6 +230,9 @@
display: inline-block;
border-left: 1px solid var(--primary-low-mid);
margin: 0 0.25em;
+ .mobile-view & {
+ display: none;
+ }
}
.btn:focus {