PHP code example of megasteve19 / editorjs

1. Go to this page and download the library: Download megasteve19/editorjs 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/ */

    

megasteve19 / editorjs example snippets


use Megasteve19\EditorJS\EditorJS;

$editorJS = new EditorJS( $json, $config );

$editorJS = new EditorJS($json, $config);

// Create a new block
$newBlockData = new \Megasteve19\EditorJS\Blocks\Block([
    'type' => 'header',
    'data' => [
        'text' => 'Hello World',
        'level' => 1
    ]
]);

// Push the new block to the collection
$editorJS->collection->insert($newBlock);


echo $editorJS->collection->find($id)->find('text');

// Find a block
$block = $editorJS->collection->find($id);

// Update block
$block->insert('alt', 'alt text');
$block->update('file.url', 'http://example.com/image.jpg');

// Update collection
$editorJS->collection->update($block);


<img src=" <?= $this->find('file.url') 

editorjs-templates/
├─ image.php
├─ header.php
├─ paragraph.php