0.0.1 • Published 4 years ago

prosemirror-to-html-sync v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

ProseToHTML

A library for converting ProseMirror Editor content to plain HTML.

Installation

npm i prosemirror-to-html-sync

Usage

const ProseToHTML = require("ProseToHTML");

// Pass in the JSON data received from the ProseMirror Editor
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", function (config, proseToHTML) {
    return "<p>" + 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.