Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-to-html-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-to-html-js

Takes ProseMirror JSON and outputs HTML

  • 1.0.1
  • npm
  • Socket score

Version published
Weekly downloads
294
decreased by-36.23%
Maintainers
1
Weekly downloads
 
Created
Source

ProseMirror to HTML (JS)

(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-js --save

Usage

const Renderer = require("prosemirror-to-html").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);

Keywords

FAQs

Package last updated on 31 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc