HTML to Prosemirror (JS)
(This package is based on html-to-prosemirror, which was originally written for PHP.)
Takes HTML and outputs ProseMirror JSON.
Installation
npm install html-to-prosemirror-js --save
Usage
const Renderer = Renderer; const renderer = ; console;/* { type: "doc", content: [ { type: "paragraph", content: [ { type: "text", text: "Example Text" } ] } ] }*/
Supported Nodes
- BulletList
- CodeBlock
- CodeBlockWrapper (with
pre
) - HardBreak
- Heading
- Image (different from the scrumpy's implementations)
- ListItem
- OrderedList
- Paragraph
Supported Marks
- Bold
- Code
- Italic
- Link
Custom Nodes
Define your node as a class -
const Node = Node; { return thisDOMNodenodeName === "USER"; // uses `jsdom` library } { return type: "user" attrs: id: thisDOMNode ; }
Feed it to renderer
instance -
renderer;