import Component from 'flarum/Component';
import icon from 'flarum/helpers/icon';
import apply from '../util/apply';

const modifierKey = navigator.userAgent.match(/Macintosh/) ? '⌘' : 'ctrl';

export default class MarkdownButton extends Component {
  config(isInitialized) {
    if (isInitialized) return;

    this.$().tooltip();
  }

  view() {
    return <button className="Button Button--icon Button--link" title={this.title()} data-hotkey={this.props.hotkey}
                   onclick={this.click.bind(this)} onkeydown={this.keydown.bind(this)}>
      {icon(this.icon())}
    </button>;
  }

  keydown(event) {
    if (event.key === ' ' || event.key === 'Enter') {
      event.preventDefault();
      this.click();
    }
  }

  click() {
    return apply(this.element, this.styles());
  }

  title() {
    let tooltip = this.props.title;

    if (this.props.hotkey) tooltip += ` <${modifierKey}-${this.props.hotkey}>`;

    return tooltip;
  }

  icon() {
    return this.props.icon;
  }

  styles() {
    return this.props.style;
  }
}

@@ -563,22 +563,26 @@
 on(this.
+props.
 icon
-()
 )%7D%0A    %3C
@@ -778,24 +778,27 @@
 t, this.
+props.
 style
-s()
 );%0A  %7D%0A%0A
@@ -927,16 +927,16 @@
 ey%7D%3E%60;%0A%0A
+
     retu
@@ -954,98 +954,7 @@
 %0A  %7D
-%0A%0A  icon() %7B%0A    return this.props.icon;%0A  %7D%0A%0A  styles() %7B%0A    return this.props.style;%0A  %7D
 %0A%7D%0A

Simplify some code in MarkdownButton component