ueberdosis / prosemirror-php
Work with ProseMirror JSON in PHP.
Fund package maintenance!
ueberdosis/
Requires
- php: ^7.1.3|^8.0
- ueberdosis/html-to-prosemirror: ^1.3
- ueberdosis/prosemirror-to-html: ^2.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.17
- phpunit/phpunit: ^7.0|^8.0|^9.0
README
🚨 We’ve done a rewrite that you probably want to check out: ueberdosis/tiptap-php
ProseMirror PHP
This package enables you to work with ProseMirror JSON in PHP. Convert it to HTML, or convert HTML to ProseMirror compatible JSON.
Installation
composer require ueberdosis/prosemirror-php
Usage
Convert HTML to ProseMirror JSON:
(new \ProseMirror\ProseMirror)->html('<p>Example Text</p>')->toJson();
or
\ProseMirror\ProseMirror::htmlToJson('<p>Example Text</p>');
Output:
{ "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Example Text" } ] } ] }
Convert ProseMirror JSON to HTML:
(new \ProseMirror\ProseMirror)->json([ 'type' => 'doc', 'content' => [ [ 'type' => 'paragraph', 'content' => [ [ 'type' => 'text', 'text' => 'Example Text', ], ], ], ], ])->toHtml();
or
\ProseMirror\ProseMirror::jsonToHtml([ 'type' => 'doc', 'content' => [ [ 'type' => 'paragraph', 'content' => [ [ 'type' => 'text', 'text' => 'Example Text', ], ], ], ], ]);
Output:
<p>Example Text</p>
Contributing
Pull Requests are welcome.
Credits
Related Packages
License
The MIT License (MIT). Please see License File for more information.