setono/editorjs-php

PHP library for handling data from the EditorJS

Fund package maintenance!
Setono

v1.2.0 2024-02-29 08:43 UTC

README

Latest Version Software License Build Status Code Coverage Mutation testing

Installation

composer require setono/editorjs-php

Usage

Here is a full example going from json to html output.

<?php
use Setono\EditorJS\Parser\Parser;
use Setono\EditorJS\Renderer\Renderer;

$json = '...'; // this is the actual json you receive from the EditorJS instance

$parser = new Parser();
$parserResult = $parser->parse($json);

$renderer = new Renderer();
$renderer->add(new DelimiterBlockRenderer());
$renderer->add(new HeaderBlockRenderer());
$renderer->add(new ImageBlockRenderer());
$renderer->add(new ListBlockRenderer());
$renderer->add(new ParagraphBlockRenderer());
$renderer->add(new RawBlockRenderer());

$html = $renderer->render($parserResult);

EditorJS plugins supported

A PR adding support for any of the above plugins would be awesome! Thank you 🎉