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

scribe-editor-asknature

v1.3.5

Published

Scribe [![Build Status](https://travis-ci.org/guardian/scribe.svg?branch=master)](https://travis-ci.org/guardian/scribe) ======

Downloads

20

Readme

Scribe Build Status

A rich text editor framework for the web platform, with patches for browser inconsistencies and sensible defaults.

For an introduction, you may want to read the blog post Inside the Guardian’s CMS: meet Scribe, an extensible rich text editor.

Please note: There is a lot of missing documentation for Scribe and many of its plugins. We plan to improve this, however in the meantime we encourage you to look at the code. Scribe is very small in comparison to other libraries of its kind.

You can join us on IRC at [#scribejs] on freenode, or via the Google Group.

See an example.

Core

At the core of Scribe we have:

Patches

Scribe patches many browser inconsistencies in the native command API.

Modes

Natively, contenteditable will produce DIVs for new lines. This is not a bug. However, this is not ideal because in most cases we require semantic HTML to be produced.

Scribe overrides this behaviour to produce paragraphs (Ps; default) or BRs (with block element mode turned off) for new lines instead.

Installation

bower install scribe

Alternatively, you can access the distribution files through GitHub releases.

Options

Usage Example

Scribe is an AMD module:

require(['scribe', 'scribe-plugin-blockquote-command', 'scribe-plugin-toolbar'],
  function (Scribe, scribePluginBlockquoteCommand, scribePluginToolbar) {
  var scribeElement = document.querySelector('.scribe');
  // Create an instance of Scribe
  var scribe = new Scribe(scribeElement);

  // Use some plugins
  scribe.use(scribePluginBlockquoteCommand());
  var toolbarElement = document.querySelector('.toolbar');
  scribe.use(scribePluginToolbar(toolbarElement));
});

You can see a live example here, or view the code here.

Also be sure to check the examples directory for an AMD syntax example as well as a CommonJS (browserify) example.

Architecture

A plugin is simply a function that receives Scribe as an argument:

function myPlugin(scribe) {}

A consumer can then use your plugin with Scribe.use:

scribe.use(myPlugin);

Plugins may package whatever functionality you desire, and you are free to use native APIs to do so. However, you are required to wrap any DOM manipulation in a transaction, so that we can capture state changes for the history. For example:

function myPlugin(scribe) {
  scribe.transactionManager.run(function () {
    // Do some fancy DOM manipulation
  });
}

Browser Support

Theoretically, Scribe should work in any browser with the Selection API, the Range API, and support for most of the non-standardised list of commands that appears in this MDN article. It has been tested in Firefox >= 31, Chrome >= 35.

See the status of our integration tests for more up-to-date support information.

Commands

Commands are objects that describe formatting operations. For example, the bold command.

Commands tell Scribe:

  • how to format some HTML when executed (similar to document.queryCommand);
  • how to query for whether the given command has been executed on the current selection (similar to document.queryCommandState);
  • how to query for whether the command can be executed on the document in its current state (similar to document.queryCommandEnabled)

To ensure a separation of concerns, commands are split into multiple layers. When a command method is called by Scribe, it will be filtered through these layers sequentially.

Plugins

We have created a collection of plugins for advanced rich text editing purposes, all of which can be seen in use in our example.

FAQ

Is it production ready?

Yes. The Guardian is using Scribe as the basis for their internal CMS’ rich text editor.

It is likely that there will be unknown edge cases, but these will be addressed when they are discovered.

How do I run tests?

See CONTRIBUTING.md for information about running tests.

Why does Scribe have a custom undo manager?

The native API for formatting content in a contenteditable has many browser inconsistencies. Scribe has to manipulate the DOM directly on top of using these commands in order to patch those inconsistencies. What’s more, there is no widely supported command for telling contenteditable to insert Ps or BRs for line breaks. Thus, to add this behaviour Scribe needs to manipulate the DOM once again.

The undo stack breaks whenever DOM manipulation is used instead of the native command API, therefore we have to use our own.

Scribe's undo manager can be turned off by configuration eg:

var scribe = new Scribe(scribeElement, {
  undo: {
    enabled: false
  }
})