PHP library for handling data from the EditorJS

v0.2.2 2022-06-30 11:13 UTC


Latest Version Software License Build Status Code Coverage Mutation testing


composer require setono/editorjs-php


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

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

$hydrator = new CompositeHydrator();
$hydrator->add(new BlockHydrator());
$hydrator->add(new EmbedBlockHydrator());
$hydrator->add(new HeaderBlockHydrator());
$hydrator->add(new ImageBlockHydrator());
$hydrator->add(new ListBlockHydrator());
$hydrator->add(new ParagraphBlockHydrator());
$hydrator->add(new RawBlockHydrator());

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

$blockRenderer = new CompositeBlockRenderer();
$blockRenderer->add(new DelimiterBlockRenderer());
$blockRenderer->add(new HeaderBlockRenderer());
$blockRenderer->add(new ImageBlockRenderer());
$blockRenderer->add(new ListBlockRenderer());
$blockRenderer->add(new ParagraphBlockRenderer());
$blockRenderer->add(new RawBlockRenderer());

$renderer = new Renderer($blockRenderer);
$html = $renderer->render($parserResult);

EditorJS plugins supported

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