This package allows you to easily parse Editor.js JSON output to HTML using PHP. This package is currently able to parse the blocks from these plugins:
- Paragraph
- Header
- Image
- Quote
- List
- Nested List
- Code
- Embed (Currently, the following embed blocks are supported)
- Youtube
- Twitter/X
- Codepen
- Github (gist)
PHP >=7.4
composer require muhammadsiyab/editorjs-parser-php
require "vendor/autoload.php";
use MuhammadSiyab\EditorjsParserPhp\Parser;
# The json output generated by Editor.js
$content = '{"time": 1711232666978,"blocks": [{...}]}' ;
$parser = new Parser();
$parsed = $parser->parse($content);
echo $parsed; // outputs the generated HTML
# Only parses the `headings` and `paragraphs`
$parsed = $parser
->only('header', 'paragraph') // can be parsed using the array syntax ['header', 'paragraph']
->parse($content);
# Parses all the blocks except `list` and `code`
$parsed = $parser
->except('list', 'code') // can be parsed using the array syntax ['list', 'code']
->parse($content);
This Package is open-sourced software licensed under the MIT license