Skip to content

devscast/editorjs-backend

Repository files navigation

EditorJS Backend

PHP Version Require Latest Stable Version Total Downloads License

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();

About

PHP backend for Editor.js

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published