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

inline-markdown-editor

v0.5.0

Published

An inline wysiwyg markdown document editor based on replacing string subsections. WYSIWYG possible via woofmark.

Downloads

32

Readme

inline-markdown-editor

Build Status Code Climate

An inline wysiwyg markdown document editor based on replacing string subsections. WYSIWYG possible via the woofmark-based PublicLab.Editor.

Basics

inline-markdown-editor splits up a Markdown-containing string by double newlines into sections, and parses each into HTML, which it displays.

It then adds an "edit button" beneath each section, which expands a nice form for editing that section either as Markdown or in rich text with a WYSIWYG editor.

Upon submitting the form, an asynchronous AJAX post request is made to the specified server with parameters before and after, containing the original subsection markdown and its replacement. The form listens for a true or false response and updates the section's displayed HTML accordingly.

For a demo, see:

https://publiclab.github.io/inline-markdown-editor/examples/

https://publiclab.github.io/inline-markdown-editor/examples/wysiwyg

Usage

For an easy start, you can begin using inline-markdown-editor by pointing it at a markdown-containing element by its selector, and specifying a URL to send changes to.

inlineMarkdownEditor({
  replaceUrl: '/wiki/replace/',
  selector: '.markdown'
});

You can also specify filters to run on the raw original markdown before display, and afterwards upon the displayed DOM element, as well as override several other defaults:

inlineMarkdownEditor({
  replaceUrl: '/wiki/replace/' + wiki_id,
  selector: '.markdown',
  preProcessor: function preProcessMarkdown(markdown) {
    // do things to markdown here before it's used to construct the form
    return markdown
  },
  postProcessor: function postProcessContent(element) {
    // do things to element here after the section has been converted to HTML and displayed
  },
  defaultMarkdown: function(markdown) {}, // a markdown parser
  buildSectionForm: function() {}, // return a string containing the form element
  onComplete: function(response, markdown, html, el, uniqueId, form, o) {}, // run on completing AJAX post
  isEditable: function(markdown) {}, // returns boolean; whether a given subsection should get an inline form; default skips HTML and horizontal rules
  extraButtons: { 'fa-icon-name': function(element) {} }, // object with keys of icon names for additional buttons with associated actions for each; returns jQuery element upon construction
  submitSectionForm: function(event, before, after, options) {}, // optional, to override the form submission handling for each subsection; before/after represent the text diff
  editorOptions: {} // any options to pass to the built-in PublicLab.Editor instance
});

Contributing

To install this library for development, you'll need NodeJS. You can get the detailed instruction on installing node and npm in its official documentation.

After installing node and npm run npm install from the root directory.

inline-markdown-editor uses grunt - the JavaScript task runner - for compilation of the modules. To install grunt run npm install -g grunt-cli. You may have to use sudo for root privileges.

Make changes to the files in the /src/ directory, then run grunt build to compile into /dist/inlineMarkdownEditor.js. This will use grunt-browserify to concatenate and include any node modules named in require() statements. You'll then be able to try it out in /examples/index.html. Run grunt and leave it running to build as you go.

Tests

Tests are set up with Jasmine, and can be run with npm test.

Goals

  • configurable editors
    • plan for swappable editors; will need to specify both constructor and onEditorSubmit in processSection
  • better modularization of processSection.js
  • more tests

Tests we want

  • defaultMarkdown
  • preProcessor
  • postProcessor
  • insertForm: look for the form, the button