npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-simple-markdown-editor

v1.1.0

Published

Simple markdown editor widget you can attach to any TextArea element to provide rich markdown capabilities. Requires few dependencies

Downloads

11

Readme

Simple React Markdown Editor

This makes it easy to add a simple markdown editing widget to any TextArea element. example

Demo

CodePen Demo

Installation

npm install react-simple-markdown-editor

Features

  • Entirely customizable. Modify CSS easily with props, or add custom classes and modify CSS with stylesheets. Define which buttons are visible.
  • The only package dependencies are react and lodash, minimizing risk.

Usage

In your code:

ES6:

import {SimpleMarkdownEditor} from 'react-simple-markdown-editor';

Non-ES6:

var SimpleMarkdownEditor = require('react-simple-markdown-editor');

In your React render() function:

<SimpleMarkdownEditor textAreaID={"myTextAreaElement"} />

Rendering Markdown

Use another library like react-remarkable in combination with this. Then set the source of the remarkable component to the value of your TextArea element.

API

Props:

SimpleMarkdownEditor.propTypes = {
    // Required props
    textAreaID: PropTypes.string.isRequired,

    // Optional props
    styles: PropTypes.object,
    containerClass: PropTypes.string,
    buttonClass: PropTypes.string,
    enabledButtons: PropTypes.object,
    buttonHtmlText: PropTypes.object,
    additionalProps: PropTypes.object
};

textAreaID (String, Required): The ID of the TextArea element you want the editor attached to. When you press buttons in this widget, the text in this TextArea will be modified.

styles: (Object, optional): Used to overwrite inline CSS without using your own stylesheets.

Existing properties:

container: {
            
},
button: {
    fontFamily: 'Georgia, serif',
    backgroundColor: '#333536',
    color: 'white',
    marginRight: '5px',
    float: 'left',
    width: '25px',
    borderRadius: '4px',
    textAlign: 'center',
    cursor: 'pointer'
}

For instance, if you want to add a border to each button: <SimpleMarkdownEditor styles={{button: {border: '1px solid green'}}} />

containerClass and buttonClass (String, optional): Provide classes to the container and button elements, so you can overwrite them using your own CSS stylesheets. An alternative to setting the styles prop.

enabledButtons: (Object, optional): Hide any buttons you don't want to show. All of them default to showing. Buttons:

{
    bold: true,
    italic: true,
    strike: true,
    code: true,
    quote: true,
    h1: true,
    h2: true,
    h3: true,
    bullet: true,
    link: true,
    image: true
}

For instance, if you want to hide the link button: <SimpleMarkdownEditor enabledButtons={{link: false}} />

buttonHtmlText: (Object, optional): Change the display text of any buttons, including any HTML markup. Defaults:

{
    bold: 'B',
    italic: '<i>I</i>',
    strike: '<s>S</s>',
    code: '&lt; &gt;',
    quote: '&ldquo; &rdquo;',
    h1: 'H1',
    h2: 'H2',
    h3: 'H3',
    bullet: '&#8226;',
    link: '#',
    image: '[i]'
}

For instance, if you want to change code to be a square quote to be 2 right arrows: <SimpleMarkdownEditor buttonHtmlText={{code: '&#9633;', quote: '&#8649;'}} />

additionalProps: (Object, optional): Add arbitrary props to any button. For instance: <SimpleMarkdownEditor additionalProps={{bold: {title: "bold"}}} />

License

MIT, use for free. If you like this, give it a star.