RIP21 / react-simplemde-editor

React wrapper for simplemde (easymde) markdown editor
https://react-simplemde-edtior.netlify.com/
MIT License
766 stars 103 forks source link

How to customize the toolbar #99

Closed mattruma closed 5 years ago

mattruma commented 5 years ago

This is more of question than an issue ... how would you customize the toolbar, which would include some of the standard options, and then a custom option or two? Similar to what is found at https://github.com/Ionaru/easy-markdown-editor#toolbar-customization.

Trying to figure out how to grab the EasyMDE instance and pass it in the toolbar configuration.

Any help would be much appreciated!

mattruma commented 5 years ago

Figured it out ...

render() {
    const toolbar = [
      {
        name: "bold",
        action: function customFunction(editor) {
          editor.toggleBold();
        },
        className: "fa fa-bold",
        title: "Bold"
      }
    ];

    return (
      <div className="rich-text-editor">
        <SimpleMDE
          id={this.props.name}
          onChange={this.handleOnChange}
          value={this.state.value}
          options={{
            autofocus: true,
            spellChecker: false,
            toolbar: toolbar
          }}
        />
      </div>
    );
  }
}

Might be a better way, but this is what is working for me.

RIP21 commented 5 years ago

@mattruma yup something like that. Usually, you just go to the easymde docs itself and do what they say, and bingo :P This one is very light and, I must admit, stupid wrapper :D

mattruma commented 5 years ago

Hey @RIP21 ... thanks for your work with this wrapper ... working great for my project!

koreaLtd commented 4 years ago

Another convenient way is to use the showIcons option

options={{
 showIcons: ['strikethrough', 'code', 'table', 'redo', 'heading', 'undo', 'heading-bigger', 'heading-smaller', 'heading-1', 'heading-2', 'heading-3', 'clean-block', 'horizontal-rule']
}}