ueberdosis/prosemirror-php

该包已被废弃且不再维护。未建议替代包。

在 PHP 中处理 ProseMirror JSON。

资助包维护!
ueberdosis/

0.3.0 2020-12-09 10:38 UTC

This package is auto-updated.

Last update: 2022-02-27 21:49:02 UTC


README

🚨 我们已经重写了,你可能想看看: ueberdosis/tiptap-php

ProseMirror PHP

此包允许你在 PHP 中处理 ProseMirror JSON。将其转换为 HTML,或将 HTML 转换为与 ProseMirror 兼容的 JSON。

Latest Version on Packagist Integrate Total Downloads Sponsor

安装

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)。更多信息请参阅 许可证文件