Skip to content

davidwhthomas/prosemirror-to-html

 
 

Repository files navigation

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%