ueberdosis / prosemirror-php
该包已被废弃且不再维护。未建议替代包。
在 PHP 中处理 ProseMirror JSON。
资助包维护!
ueberdosis/
0.3.0
2020-12-09 10:38 UTC
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
🚨 我们已经重写了,你可能想看看: ueberdosis/tiptap-php
ProseMirror PHP
此包允许你在 PHP 中处理 ProseMirror JSON。将其转换为 HTML,或将 HTML 转换为与 ProseMirror 兼容的 JSON。
安装
composer require ueberdosis/prosemirror-php
使用
将 HTML 转换为 ProseMirror JSON
(new \ProseMirror\ProseMirror)->html('<p>Example Text</p>')->toJson();
或
\ProseMirror\ProseMirror::htmlToJson('<p>Example Text</p>');
输出
{ "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "Example Text" } ] } ] }
将 ProseMirror JSON 转换为 HTML
(new \ProseMirror\ProseMirror)->json([ 'type' => 'doc', 'content' => [ [ 'type' => 'paragraph', 'content' => [ [ 'type' => 'text', 'text' => 'Example Text', ], ], ], ], ])->toHtml();
或
\ProseMirror\ProseMirror::jsonToHtml([ 'type' => 'doc', 'content' => [ [ 'type' => 'paragraph', 'content' => [ [ 'type' => 'text', 'text' => 'Example Text', ], ], ], ], ]);
输出
<p>Example Text</p>
贡献
欢迎 Pull Requests。
鸣谢
相关包
许可证
MIT 许可证 (MIT)。更多信息请参阅 许可证文件。