devscast / editorjs
PHP backend for Editor.js
dev-main
2025-04-18 11:57 UTC
Requires
- php: >=8.3
- swaggest/json-schema: ^0.12.43
- symfony/html-sanitizer: ^7.2
- webmozart/assert: ^1.11
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- rector/rector: ^2.0
- symfony/var-dumper: ^7.2
- symplify/easy-coding-standard: ^12.5
This package is auto-updated.
Last update: 2025-04-18 11:57:14 UTC
README
EditorJS Backend is a library for parsing, validating, and sanitizing JSON data generated by the Editor.js rich text editor. It provides a robust and extensible way to handle Editor.js blocks in PHP applications.
Installation
composer require devscast/editorjs
Basic Usage
Parsing and Sanitizing Editor.js Data The Editor class is the main entry point for processing Editor.js JSON data. It parses the JSON into blocks, validates the structure, and sanitizes the resulting HTML output.
<?php use Devscast\EditorJs\Editor; $data = <<<JSON { "time": 1635603431943, "blocks": [ { "id": "1", "type": "header", "data": { "text": "Hello, Editor.js!", "level": 2 } }, { "id": "2", "type": "paragraph", "data": { "text": "This is a paragraph block." } } ], "version": "2.31.0" } JSON; $editor = new Editor($data); // Get sanitized HTML output echo $editor->getHtml();