davidwhthomas / prosemirror-to-html

Takes ProseMirror JSON and renders HTML.

Repository from Github https://github.comdavidwhthomas/prosemirror-to-htmlRepository from Github https://github.comdavidwhthomas/prosemirror-to-html

This repository has been migrated to a new organization (Read more: ueberdosis/tiptap#759)

ProseMirror to HTML

Takes ProseMirror JSON and outputs HTML.

Latest Version on Packagist Integrate Total Downloads

Installation

composer require ueberdosis/prosemirror-to-html

Usage

(new \Scrumpy\ProseMirrorToHtml\Renderer)->render([
    'type' => 'doc',
    'content' => [
        [
            'type' => 'paragraph',
            'content' => [
                [
                    'type' => 'text',
                    'text' => 'Example Paragraph',
                ],
            ],
        ],
    ],
])

Output

<p>Example Text</p>

Supported Nodes

  • Blockquote
  • BulletList
  • CodeBlock
  • HardBreak
  • Heading
  • ListItem
  • OrderedList
  • Paragraph
  • Table
  • TableRow
  • TableHeader
  • TableCell

Supported Marks

  • Bold
  • Code
  • Italic
  • Link
  • Strike
  • Subscript
  • Superscript
  • Underline

Custom Nodes

Define your custom nodes as PHP classes:

<?php

class CustomNode extends \Scrumpy\ProseMirrorToHtml\Nodes\Node
{
    protected $markType = 'custom';
    protected $tagName = 'marquee';
}

And register them:

$renderer->addNode(CustomNode::class);

Or overwrite the enabled nodes:

$renderer->withNodes([
    CustomNode::class,
]);

Or overwrite the enabled marks:

$renderer->withMarks([
    Bold::class,
]);

Contributing

Pull Requests are welcome.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Takes ProseMirror JSON and renders HTML.

License:MIT License


Languages

Language:PHP 100.0%