PHP code example of nhujanen / editorphp

1. Go to this page and download the library: Download nhujanen/editorphp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nhujanen / editorphp example snippets




$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,
            ],
        ],
    ],
]);



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' => [],
        ],
    ],
]);