prosemirror-to-html

1.0.1-c • Public • Published

ProseToHTML

A library for converting ProseMirror Editor content to plain HTML.

Installation

npm i prosemirror-to-html

Usage

const ProseToHTML = require("ProseToHTML");
 
// Pass in the JSON data received from the ProseMirror Editor
await ProseToHTML.toHTML(proseEditorData));

A ProseToHTML instance can take in following properties:

  • types: List of type handlers
  • marks: List of mark handlers
  • verbose: Boolean, debug output (true or false)

and has access to the following functions:

- toHTML(object):

 toHTML(proseEditorOutput)
 returns: html (string)

- initProseMark(string, function):

initProseMark("italic", (value) => {
    return `<i>${value}</i>`;
})

- initProseEntity(string, function):

initProseEntity("paragraph", async function (config, proseToHTML) {
    return "<p>" + await proseModule.renderEntityChildren(config) + "</p>";
})

It is important to note that initProseEntity() or initProseMark() overwrite default values, thus easy to adapt!

Test

To test it, just run the test script.

License

MIT.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1-c
    33
    • latest

Version History

Package Sidebar

Install

npm i prosemirror-to-html

Weekly Downloads

20

Version

1.0.1-c

License

MIT

Unpacked Size

9.63 kB

Total Files

32

Last publish

Collaborators

  • blade67