prosemirror-to-html-node-js

1.0.1 • Public • Published

ProseMirror to HTML (JS)

Original from https://github.com/enVolt/prosemirror-to-html

(This package is based on prosemirror-to-html, which was originally written for PHP.)

Takes ProseMirror JSON and outputs HTML.

Installation

npm install prosemirror-to-html-node-js --save

Usage

const Renderer = require("prosemirror-to-html-node-js").Renderer;

const renderer = new Renderer();

console.log(renderer.render({
  "type": "doc",
  "content": [
    {
      "type": "paragraph",
      "content": [
        {
          "type": "text",
          "text": "Example Paragraph"
        }
      ]
    }
  ]
}));  // `<p>Example Text</p>`

Supported Nodes

  • Blockquote
  • BulletList
  • CodeBlock
  • Heading
  • ListItem
  • OrderedList
  • Paragraph

Supported Marks

  • Bold
  • Code
  • Italic
  • Link

Custom Nodes

Define your node as a class -

const Node = require("prosemirror-to-html").Node;

class CustomNode extends Node {
    matching () {
        return this.node.type === "custom_node";
    }

    tag () {
        return "cnode";
    }
}

Feed it to renderer instance -

renderer.addNode(CustomNode);

Package Sidebar

Install

npm i prosemirror-to-html-node-js

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

25.4 kB

Total Files

33

Last publish

Collaborators

  • lyrictape