# Markdown headings and the composer

**URL:** <https://meta.discourse.org/t/markdown-headings-and-the-composer/88526>\
**Category:** Feature\
**Created:** [May 27, 2018, 1:22am UTC](https://meta.discourse.org/t/markdown-headings-and-the-composer/88526 "2018-05-27T01:22:36Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Johani](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/johani/32/176920_2.png) [@Johani](https://meta.discourse.org/u/Johani)\
**Post date:** [May 28, 2018, 2:37am UTC](https://meta.discourse.org/t/markdown-headings-and-the-composer/88526/7 "2018-05-28T02:37:22Z")

</div>

In the context of a theme, creating a separate popup menu for headings probably involves more work, but you can add heading buttons to the current options menu.

 ![headingButtons](https://global.discourse-cdn.com/meta/original/3X/8/9/89350564a59ff0e27bf4250173122fc4631f3e94.gif)

Try something like this (quickly put together)

```plaintext
<script type="text/discourse-plugin" version="0.8.18">
$(document).ready(function() {
  // edit the text of the buttons here
  I18n.translations.en.js.composer.headingOne = I18n.translations.en.js.headingOne =
    "Header 1";
  I18n.translations.en.js.composer.headingTwo = I18n.translations.en.js.headingTwo =
    "Header 2";
  I18n.translations.en.js.composer.headingThree = I18n.translations.en.js.headingThree =
    "Header 3";
  I18n.translations.en.js.composer.headingFour = I18n.translations.en.js.headingFour =
    "Header 4";
});

// no need to edit anything here
api.addToolbarPopupMenuOptionsCallback(() => {
  return {
    action: "headingOne",
    icon: "header",
    label: "headingOne"
  };
});
api.addToolbarPopupMenuOptionsCallback(() => {
  return {
    action: "headingTwo",
    icon: "header",
    label: "headingTwo"
  };
});
api.addToolbarPopupMenuOptionsCallback(() => {
  return {
    action: "headingThree",
    icon: "header",
    label: "headingThree"
  };
});
api.addToolbarPopupMenuOptionsCallback(() => {
  return {
    action: "headingFour",
    icon: "header",
    label: "headingFour"
  };
});

// no need to edit anything here
api.modifyClass("controller:composer", {
  actions: {
    headingOne() {
      this.get("toolbarEvent").applySurround("# ", " ", "headingOne");
    },
    headingTwo() {
      this.get("toolbarEvent").applySurround("## ", " ", "headingTwo");
    },
    headingThree() {
      this.get("toolbarEvent").applySurround("### ", " ", "headingThree");
    },
    headingFour() {
      this.get("toolbarEvent").applySurround("#### ", " ", "headingFour");
    }
  }
});
</script>

```

And use a little bit of CSS to change a few things:

```plaintext
.options .select-kit-collection {
    display: flex;
    flex-direction: column;
}

[data-value*="heading"] {
    order: -1;
}

#reply-control .fa-gear:before {
    content:"\f142";
}

```

And you’d be pretty close to what you wanted

---

_[View the full topic](https://meta.discourse.org/t/markdown-headings-and-the-composer/88526)._
