Skip to content

rtfb/pagedown-editor

Repository files navigation

Node package for PageDown Editor

The original PageDown repo only packages server-side code in its Node module. This package also packages the editor, intended to be used along with Browserify.

Installation

$ npm install -g browserify
$ npm install pagedown-editor

Usage

In some file, say, sample.js, create an entry point to the editor:

var editor = require("pagedown-editor");

function getPagedownEditor() {
    return editor.getPagedownEditor();
}

global.window.getPagedownEditor = getPagedownEditor;

Then, during build time, browserify that file and copy the buttons and the stylesheet:

$ browserify sample.js -o bundle.js
$ cp node_modules/pagedown-editor/wmd-buttons.png static/
$ cp node_modules/pagedown-editor/pagedown.css static/

Finally, use the bundle like this in your html:

<!-- among headers, instead of Markdown.*.js, include your bundle: -->
<link rel="stylesheet" href="/static/pagedown.css">
<script type="text/javascript" src="/static/bundle.js"></script>

<!-- ...
    Then at the end of body, invoke the editor with this one-liner: -->
<script type="text/javascript">
(function () {
     getPagedownEditor().run();
     })();
</script>

For your convenience there's a sample.html with all of the above in one place. After installation it will work out of the box from within your node_modules directory, just direct your browser to file:///<path to>/node_modules/pagedown-editor/sample.html.

License

MIT license, see LICENSE.txt.

About

This is a Node package for PageDown editor, intended to be used with Browserify.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages