ueberdosis/prosemirror-to-html

This package is abandoned and no longer maintained. No replacement package was suggested.

Takes HTML and outputs ProseMirror compatible JSON.

Fund package maintenance!
ueberdosis/

Installs: 1 383 916

Dependents: 3

Suggesters: 0

Security: 0

Stars: 77

Watchers: 2

Forks: 18

2.7.0 2021-08-18 08:05 UTC

This package is auto-updated.

Last update: 2022-02-27 21:54:06 UTC


README

🚨 We’ve done a rewrite that you probably want to check out: ueberdosis/tiptap-php

ProseMirror to HTML

Takes ProseMirror JSON and outputs HTML.

Latest Version on Packagist Integrate Total Downloads Sponsor

Installation

composer require ueberdosis/prosemirror-to-html

Usage

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

Output

<p>Example Text</p>

Supported nodes

Supported marks

Custom nodes

Define your custom nodes as PHP classes:

<?php

class CustomNode extends \ProseMirrorToHtml\Nodes\Node
{
    protected $nodeType = '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,
]);

Or replace just one mark or node:

$renderer->replaceNode(
    CodeBlock::class, CustomCodeBlock::class
);

$renderer->replaceMark(
    Bold::class, CustomBold::class
);

Contributing

Pull Requests are welcome.

Credits

Related packages

License

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