scrumpy/prosemirror-to-html

此包已被废弃,不再维护。作者建议使用 ueberdosis/prosemirror-to-html 包。

接收HTML并输出与ProseMirror兼容的JSON。

2.7.0 2021-08-18 08:05 UTC

This package is auto-updated.

Last update: 2022-01-27 21:41:04 UTC


README

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

ProseMirror到HTML

接收ProseMirror JSON并输出HTML。

Latest Version on Packagist Integrate Total Downloads Sponsor

安装

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>

支持的节点

支持的标记

自定义节点

将自定义节点定义为PHP类

<?php

class CustomNode extends \ProseMirrorToHtml\Nodes\Node
{
    protected $nodeType = 'custom';
    protected $tagName = 'marquee';
}

并注册它们

$renderer->addNode(CustomNode::class);

或覆盖已启用的节点

$renderer->withNodes([
    CustomNode::class,
]);

或覆盖已启用的标记

$renderer->withMarks([
    Bold::class,
]);

或仅替换一个标记或节点

$renderer->replaceNode(
    CodeBlock::class, CustomCodeBlock::class
);

$renderer->replaceMark(
    Bold::class, CustomBold::class
);

贡献

欢迎拉取请求。

致谢

相关包

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。