Socket
Socket
Sign inDemoInstall

prosemirror-to-html-js

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prosemirror-to-html-js

Takes ProseMirror JSON and outputs HTML


Version published
Weekly downloads
475
increased by2.81%
Maintainers
1
Install size
24.4 kB
Created
Weekly downloads
 

Readme

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

Last updated on 07 Aug 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc