nhujanen / editorphp
PHP renderer for EditorJS
0.0.4
2019-05-06 19:00 UTC
Requires
- php: ^7.0
- ext-dom: *
- psr/simple-cache: ^1.0
This package is auto-updated.
Last update: 2025-03-07 07:52:01 UTC
README
PHP renderer for EditorJS
Requirements
PHP 7.x
Usage
require_once 'vendor/autoload.php'; $editor = new EditorPHP('test.html', 'editor-me', true); echo $editor->render([ 'time' => 1550476186479, 'version' => '1.8.2', 'blocks' => [ [ 'type' => 'header', 'data' => [ 'text' => 'Testing header', 'level' => 2, ], ], ], ]);
Register custom renderers
require_once 'vendor/autoload.php'; class Fooler extends Block { public function generate(array $data = []): \DOMElement { return $this->document->createElement('strong', 'FOO FAA SNG'); } } $editor = new EditorPHP('test.html', 'editor-me', true); $editor->registerRenderer('foo', Fooler::class); echo $editor->render([ 'time' => 1550476186479, 'version' => '1.8.2', 'blocks' => [ [ 'type' => 'foo', 'data' => [], ], ], ]);
License
MIT