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 🙏

© 2026 – Pkg Stats / Ryan Hefner

markedit

v1.0.1

Published

Markdown widget

Readme

Markedit


Build Status npm version Bower version Code Climate Test Coverage

Markedit is a simple JavaScript only markdown widget.

Markedit

Features

  • Small and simple
  • Not jQuery dependent
  • Easy Image upload
  • Easy to customize
  • Works with any browser above IE9

Getting Started

  • Add Markedit to your project using NPM or bower by running either of the following:
# NPM
npm install markedit

# Bower
bower install markedit

CDN coming soon

  • Include Markedit to your code
var Markedit = require('markedit');

var markedit = new Markedit(options);

Or

<script src="dist/markedit.js"></script>
<script>
    var markedit = new Markedit(options);
</script>

Include the css file:

<link rel="stylesheet" href="dist/markedit.css">

markedit.css references the font files which is available in the dist folder. If you plan to go custom, see Custom Styles

  • Configure Options
var options = {
            container: 'md',
            width: '400px',
            height: '400px',
            resize: 'both'
        };
  • Load
<div class="page_wrap">
    <div id="md"></div>
</div>

Configuration

| Option | Description | Default | | ------------- |---------------| ------ | | height | Widget height | 400px | | width | Widget width | 400px | | imageUrl | Endpoint for handling image upload | null | | marked | Marked's configuration object | null | | markedHandler | Marked's callback | null | | resizeable | Determines if widget should be resizeable or not (both, horizontal, vertical, none) | none |

Markedit uses Marked to parse markdown. options.marked and options.markedHandler are passed as argument to Marked when parsing.

Events

You can also pass in some callbacks to the config to handle the events. Supported events are:

  • onFocus: Called when the editor has focus:
var options = {
    onFocus: function(e) {
      console.log(e);
    }
};
  • onBlur: Called when the editor looses focus:
var options = {
    onBlur: function(e) {
      console.log(e);
    }
};
  • onPreview: Called when the preview button is clicked:
var options = {
    onPreview: function(e) {
      console.log(e);
    }
};
  • onFullscreen: Called when the full screen button is clicked:
var options = {
    onFullscreen: function(e) {
      console.log(e);
    }
};

Image Upload

Markedit supports image upload. To enable this feature, set the imageUrl to the url upload endpoint

var options = {
    imageUrl: 'http://localhost:3000/images/upload'
}

The normal behavior of clicking the image button is to insert markdown image template at the cursor position but with image upload enabled, a file upload dialogue will be opened.

The end point provided should return a response that has an image property:

{
    image: 'http://localhost:3000/uploads/just-uploaded.jpg'
}

An example handler using express and multer:

// Imports
var express = require('express');
var bodyParser = require('body-parser');
var multer = require('multer');
var app = express();
var upload = multer({dest: 'uploads/'});

app.use('/uploads', express.static(path.join(__dirname, 'uploads')));
app.set('port', (process.env.PORT || 3000));

app.post('/api/image', upload.single('image'), function (req, res) {
          console.log(req.file);
          res.json({image: 'http://localhost:1337/'+req.file.path})
      });

app.listen(app.get('port'), function () {
            console.log(`Server started: http://localhost:${port}/`);
        });

Custom Style

You can override the provided style. To do so, you need to understand the DOM hierachy. Below is how the DOM looks under the hood:

  <div class="markedit">
    <div class="markedit__controls">
      <a class="markedit__control bold">
        <i class="icon-bold"></i>
      </a>
      <a class="markedit__control header">
        <i class="icon-header"></i>
      </a>
      <a class="markedit__control italic">
        <i class="icon-italic"></i>
      </a>

     <!-- ... more icons but truncated for brevity -->
    </div>
    <textarea class="markedit__text">

    </textarea>
    <div class="markedit__preview">
      a
    </div>
  </div>

What you can then do is use the classes to target each item and add your custom style::

.markedit__preview{
    background: black;
    color: white;
}

Examples

See the examples folder in this repository for a working demo

Contributing

  1. Fork the repository
  2. Clone to your workspace
  3. Run npm install
  4. Create a feature or bug fix branch
  5. Make changes
  6. Run grunt to:
    • Lint
    • Test
    • Build
  7. Push and send in PR.

Credits

@chrizt_n