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

@eritaakash/react-markdown-editor

v4.4.4

Published

React Component to render markdown preview directly into text area.

Downloads

18

Readme

React Markdown Editor

React Component to render markdown preview directly into text field.

npm i @eritaakash/react-markdown-editor

Features

It's currently very basic, and all it does is:

  • Provide a live preview within the text field. The user won't have to switch between "editor" and "preview" section.
  • Format Bold, Italic and Underline texts as of now.
  • Provide option for customizable styling of the text editor container.
  • Provide option to customize the css of the preview container and markdown textarea.

Usage

  1. In a page file,
import MarkdownEditor from "@eritaakash/react-markdown-editor";
import { useState } from 'react';

export default function Home() {
  /* text is the state that will be used to store the markdown text of the editor */
  const [text, setText] = useState('');

  return (
    <MarkdownEditor 
        text={text} 
        setText={setText} 
    />
  );
};
  1. It results in:

React Markdown Editor Preview

Customization

You can customie the styling of the component through the linked css file, using the .r-md_customStyle selector. The default style is:

.r-md_customStyle {
    height: 30rem;
    width: 30rem;
    padding: 10px;
}

It is only useful to change dimension-related properties such as width, height, padding. For a deeper styling, markdown-editor class should be used in your globals.css file.

Custom caret-color

/* global css file (Next.js) */
/* Or, linked css file (React) */

textarea.markdown-editor {
    caret-color: red;
}

result:

React Markdown Editor textarea styling example

Do not change text or background color through textarea, as its kept transparent.

Text or Background Color

use div.markdown-editor to change the color of background or text

/* global css file (Next.js) */
/* Or, linked css file (React) */

div.markdown-editor {
    color: crimson;
    background-color: black;
}

result:

React Markdown Editor text and background color styling example

Font Size & Adding Custom Font

apply the font to both div and textarea.

/* global css file (Next.js) */
/* Or, linked css file (React) */

textarea.markdown-editor {
    caret-color: grey;

    /* Custom font size */
    font-size: 20px;

    /* Add font family */
    font-family: Poppins, sans-serif;
}

div.markdown-editor {
    color: white;
    background-color: black;

    /* Custom font size */
    font-size: 20px;

    /* Add font family */
    font-family: Poppins, sans-serif;
}

result:

React Markdown Editor custom text font example

⚠ Using a font other than monospace leads to a slight misposition of caret in some cases, like:

an issue with React Markdown Editor

I will try to figure out how would I solve this issue.

Todo

  • Add support for various other markdown formatting methods such as List Item, Link & Image.

Contributing

Reporting of issues and pull requests for bug fixes or new suggestions are welcomed.