Skip to content
A rich-text editor using Prosemirror with React
JavaScript Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Wax Editor

MIT license

This application is being developed by the Coko Foundation, for the University of California Press as part of the Editoria application.

Wax Editor is build against Prosemirror libraries. Check Prosemirror website and GitHub repo for more information.

Get up and running

Run a local version of the editor


  2. yarn with node >= 11 (11.14.0 is tested on)

  3. yarn editoria Will bring up a demo of the Editoria Ediitor

Scripts: yarn , yarn clean, yarn reset


Wax depends on the following libraries.

  • React for the view(ui)

  • Styled-components for theming and styling.

  • as service containers

Assemble your own Editor

Currently Wax is under heavy development. Master holds a as possible as stable version of the editor. For latest versions see here. Documentation follows, but it is rather limited for now. It lists all the basic parts , and includes a brief explanation on how to configure Wax for your own project. More detailed examples will follow.

Check editoria editor, editoria's package.json and editoria's configuration file for a full example on how to mount Wax and all available packages(services).

Editor Properties

All available editor properties

autoFocus; // sets cursor in the begging of the document
onChange; // when the editor's surface is updated (perform an action ex. save)
value; // the actual HTML content of the editor
fileUpload; // used for uploading images (should return a promise with the actual file path)
placeholder; // a placeholder used for empty documents
config; // adds on the editor anything from new services, tools, Pmpplugins etc. Check [editoria config](
readonly; // editor in in read-only mode
onBlur; // on focus lost
layout; // used to create your own Layout using React components
debug; // dev-tools (

Current Tools and Toolgroups:

  1. Base Tool group: undo, redo, save

  2. Inline Annotations Tool group: strong, italic, link, strikethrough, underline, subscript, superscript, small caps

  3. Lists Tool group: numbered list, bullet list

  4. Image Tool group: image

  5. Table Tool group: create table, edit table dropdown that includes: insert/delete row, insert/delete column ,merge cells, split cell, delete table, Toggle header column, Toggle header row

  6. Display Tool group: Title, Author, Subtitle, Epigraph Prose, Epigraph Poetry, Heading 1, Heading 2, Heading 3

  7. Text Tool group: Paragraph, Paragraph Continued, Extract Prose, Extract Poetry, Source Note, Block Quote

  8. Notes Tool group: notes (currently under development)


The role of wax-core is

  • Mount a prosemirror instance

  • Initiate default services

    1. LayoutService

    2. SchemaService

    3. MenuService

    4. RulesService

    5. ShortCutsService

A big part of wax-core is the application layer, which is responsible for the application’s lifecycle by registering and booting services, merging configs, using the schema and gathering all prosemirror plugins.

Also holds some default prosemirror plugins that are necessary like the dropCursor, gapCursor, history and some optional as the placeholder.


Holds all the nodes and marks currently supported by Wax. You can either have a node/mark in “Wax node/mark structure” or a default prosemirror node/mark. For more information on how a Wax node/mark is different check the SchemaService


React components to support various features of the editor from buttons to overlays to comment discussions etc. Right now is really basic as the focus is not yet on UI.


Holds the different themes of the editor. Check the options in the [CokoTheme](


Holds different layouts of the editor. Through the layout service you can configure the areas of different components. As an example check [EditoriaLayout](


Various helpers methods needed throughout Wax to support the funcionality needed.


Editors are private pakages inside the monorepo, for development/demo purposes.


Service providers are the central place of Wax bootstrapping. Your own services, as well as all of Wax's core services are bootstrapped via application provider and are initiated before everything else.

But, what do we mean by "bootstrapped"? In general, we mean registering things, including registering service container bindings and event listeners. Service providers are the central place to configure your application.

If you open editoria's config file, you will see the config file where you can configure the extra services (apart from those Wax will load on init) of your editor. These are all of the service provider classes that will be loaded for your application.

In the following overview we will see how to write our own service providers and register them within the Editor.

Writing Service Providers

All service providers extend the Service class. Most service providers contain a register and a boot method. Within the register method, you should only bind things into the service container.

The Register Method

Let’s take a look at a simple service like the StrongService. Within any of your service provider methods, you always have access to the config and schema properties and also you have access to the service container using

import { toggleMark } from "prosemirror-commands";
import Service from "wax-prosemirror-core/src/services/Service";
import { strongMark } from "wax-prosemirror-schema";
import Strong from "./Strong";

class StrongService extends Service {
  boot() {
    const shortCuts = this.container.get("ShortCuts");
    shortCuts.addShortCut({ "Mod-b": toggleMark(this.schema.marks.strong) });

  register() {
    const createMark = this.container.get("CreateMark");
        strong: strongMark
      { toWaxSchema: true }

export default StrongService;

This service provider defines a register method, it registers a class and in this case is the strong tool. For more information on how to use service container check documentation.

A slightly more complicated example could be the ShortCutsService register method.

register() {
    const PmPlugins =;
      .toDynamicValue(() => {
        const { schema: { schema } } =;

        return new ShortCuts(PmPlugins, schema);

In the above example we bind ShortCuts to a factory method which injects PmPlugins and schema into ShortCuts class.

The Boot Method

So, what if we need to register a view component within our service provider? This should be done within the boot method. This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered.

A good example could be the MenuSerivce

boot() {
    const { menus } = this.container.get("MenuCollection");
    const layout = this.container.get("Layout");
    menus.forEach(menu => {
      layout.addComponent(menu.config.templateArea, menu.render());

In Menu’s boot method we get Layout and we add components to the already defined areas from our Layout.

Extra functionalities include

  1. Registering Services from within a Service.
class InlineAnnotationsService extends Service {
  dependencies = [
    new CodeService(),
    new StrongService(),
    new EmphasisService(),
    new SubscriptService(),
    new SuperscriptService(),
    new StrikeThroughService(),
    new UnderlineService(),
    new SmallCapsService()
  1. Within any of your service provider methods, you always have access to the app, config properties .
  2. Dependant functionality between services. An example of the dependency between two services are linkService and OverLayService where OverLayService registers a function that adds a component to the overlay area and LinkService calls OverLay and adds it’s component. ShortCut Service could be another example where each of the services like Strong, paragraph etc can call it to add a shortcut.

Core Services


Schema service enable us to add marks and nodes into prosemirror. We have two functions for that scope CreateNode and CreateMark. In prosemirror all attributes are in the node so you might have on the same node a class , href, user attribute etc. This attributes might be used from different services.

So for example on the pararaph node Service A adds the class attribute while Service B adds the user attribute. If you only use Service A the user attribute still exists in the schema for that node. So if we want to add the user attribute only through service B , we have “toWaxSchema” option .

Service A register method.

    paragraph: {
      group: "block",
      content: "inline*",
      attrs: {
        class: { default: "paragraph" }
      parseDOM: {
        tag: "p.paragraph",
        getAttrs(hook, next) {
          Object.assign(hook, {
            class: hook.dom.getAttribute("class")
      toDOM(hook, next) {
        const attrs = { class: hook.node.attrs.class };

        hook.value = ["p", attrs, 0];
  { toWaxSchema: true }

Service B register method.

    paragraph: {
      group: "block",
      content: "inline*",
      attrs: {
        user: { default: [] }
      parseDOM: {
        tag: "p.paragraph",
        getAttrs(hook, next) {
          Object.assign(hook, {
            user: parseUser(hook.dom.dataset.user)
      toDOM(hook, next) {
        Object.assign(hook.value[1], {
          "data-user": JSON.stringify(hook.node.attrs.user)
  { toWaxSchema: true }

If the above 2 services are registed SchemaService will merge those 2 nodes into a single prosemirror one having both attributes.


This service enables us to set a layout for the editor. Internally Wax calls the setLayout method to apply a layout. How can you write your own layout. Check Editoria's [layout](

A layout is a react component which has a prop the mounted prosemirror instance in order to place within the layout. You can also have your own “Areas”. For example in EditoriaLayout we have the following

const LeftSideBar = componentPlugin("leftSideBar");
const RightSideBar = componentPlugin("rightSideBar");
const TopBar = componentPlugin("topBar");
const BottomBar = componentPlugin("bottomBar");
const WaxOverlays = componentPlugin("waxOverlays");

const EditoriaLayout = ({ editor }) => {
  return (
    <ThemeProvider theme={cokoTheme}>
            <TopBar />
              <LeftSideBar />
          <WaxSurfaceScroll className="wax-surface-scroll">
            <WaxOverlays />
          <RightSideBar />
        <BottomBar />
        <InfoArea />

<LeftSideBar /> is placed accordingly to our design in the left of the editor as ui element. So we define a “leftSideBar” area. Area is like a “tag” for the editor so it knows where to place certain components. So by defining the leftSideBar Area we can use that area in our services to add components into it.

An example of using areas in editoria config.

MenuService: [
      templateArea: "topBar",
      toolGroups: ["Base", "Annotations", "Lists", "Images", "Tables"]
      templateArea: "leftSideBar",
      toolGroups: ["Display"]

Lastly Layout has a core method which is called ComponentPlugin. Is used in order to render the components to the area and to provide the view state of the editor in order to get updates.

ShortCuts Service

Another Core Service of Wax for registering shortcuts within a service. Check as an example , how it is used on Strong Service.

Rules Service

Core Service of Wax for registering prosemirror rules. Check editoria config or it can be used from within any service similar to Short Cuts as an addRule method is available.

Menu Service

Is used for adding menus to the editor.

Other Stuff

  1. How to create overlays. Check as an example the link overlay, which uses Wax's default overlay.
  2. How to create toolgroups Check as an example Inline Annotations here for the services and here for creating your toolgroup
  3. How to create modals inside the editor (under development)
  4. Adding prosemirror plugins. You can do it either from the config or from inside any service with PmPlugins.add("shortcuts", shortCuts) or you can have access to the plugin by [pmplugins.get("imagePlaceHolder")] (

Latest versions

  • wax-prosemirror-components@0.0.4
  • wax-prosemirror-core@0.0.4
  • wax-prosemirror-layouts@0.0.4
  • wax-prosemirror-plugins@0.0.4
  • wax-prosemirror-schema@0.0.4
  • wax-prosemirror-services@0.0.4
  • wax-prosemirror-themes@0.0.4
  • wax-prosemirror-utilities@0.0.4
You can’t perform that action at this time.