Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

etrias-nl/prosemirror-to-html

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠ DEPRECATED

No replacement suggested.

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

  • Blockquote
  • BulletList
  • CodeBlock
  • HardBreak
  • Heading
  • Image
  • 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 \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
);

Contributing

Pull Requests are welcome.

Credits

Related packages

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%