setono/editorjs-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

setono/editorjs-bundle

最新稳定版本:v1.3.0

Composer 安装命令:

composer require setono/editorjs-bundle

包简介

Symfony bundle that integrates the editorjs-php library

README 文档

README

Latest Version Software License Build Status Code Coverage Mutation testing

This bundle integrates the editorjs-php library into Symfony.

Instead of using the default block renderers in the library, this bundle creates a TwigBlockRenderer which renders all blocks as twig templates. This makes it very easy for you to override the rendered HTML for each block.

Install

composer require setono/editorjs-bundle

Usage

<?php

use Setono\EditorJS\Parser\ParserInterface;
use Setono\EditorJS\Renderer\RendererInterface;

final class YourService
{
    public function __construct(
        private readonly ParserInterface $parser,
        private readonly RendererInterface $renderer
    ) {
    }

    public function __invoke(string $json): string
    {
        return $this->renderer->render($this->parser->parse($json));
    }
}

Override rendered HTML

Each block has a corresponding Twig template inside the block directory. The template for the ListBlock looks like this for example:

{# @var block \Setono\EditorJS\Block\ListBlock #}
<{{ block.tag }}>
{% for item in block.items %}
    <li>{{ item|raw }}</li>
{% endfor %}
</{{ block.tag }}>

Just as other Twig templates you can easily override these templates.

统计信息

  • 总下载量: 42.39k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-08-11