We need your support to maintain this package. 💖 https://github.com/sponsors/ueberdosis
Takes ProseMirror JSON and outputs HTML.
composer require ueberdosis/prosemirror-to-html
(new \ProseMirrorToHtml\Renderer)->render([
'type' => 'doc',
'content' => [
[
'type' => 'paragraph',
'content' => [
[
'type' => 'text',
'text' => 'Example Paragraph',
],
],
],
],
])
<p>Example Text</p>
- Blockquote
- BulletList
- CodeBlock
- HardBreak
- Heading
- Image
- ListItem
- OrderedList
- Paragraph
- Table
- TableCell
- TableHeader
- TableRow
Define your custom nodes as PHP classes:
<?php
class CustomNode extends \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,
]);
Or replace just one mark or node:
$renderer->replaceNode(
CodeBlock::class, CustomCodeBlock::class
);
$renderer->replaceMark(
Bold::class, CustomBold::class
);
Pull Requests are welcome.
- tiptap by @ueberdosis
- prosemirror-to-html-js by @enVolt
The MIT License (MIT). Please see License File for more information.