editorjs.io parser - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of editorjs.io parser.php

  1. <?php
  2.  
  3. $json = '{
  4.   "time": 1563816717958,
  5.   "blocks": [{
  6.       "type": "header",
  7.       "data": {
  8.         "text": "Editor.js",
  9.         "level": 2
  10.       }
  11.     },
  12.     {
  13.       "type": "paragraph",
  14.       "data": {
  15.         "text": "Hey. Meet the new Editor. On this page you can see it in action — try to edit this text."
  16.       }
  17.     },
  18.     {
  19.       "type": "header",
  20.       "data": {
  21.         "text": "Key features",
  22.         "level": 3
  23.       }
  24.     },
  25.     {
  26.       "type": "list",
  27.       "data": {
  28.         "style": "unordered",
  29.         "items": [
  30.           "It is a block-styled editor",
  31.           "It returns clean data output in JSON",
  32.           "Designed to be extendable and pluggable with a simple API"
  33.         ]
  34.       }
  35.     },
  36.     {
  37.       "type": "header",
  38.       "data": {
  39.         "text": "What does it mean «block-styled editor»",
  40.         "level": 3
  41.       }
  42.     },
  43.     {
  44.       "type": "paragraph",
  45.       "data": {
  46.         "text": "Workspace in classic editors is made of a single contenteditable element, used to create different HTML markups. Editor.js <mark class=\"cdx-marker\">workspace consists of separate Blocks: paragraphs, headings, images, lists, quotes, etc</mark>. Each of them is an independent contenteditable element (or more complex structure) provided by Plugin and united by Editor\'s Core."
  47.       }
  48.     },
  49.     {
  50.       "type": "paragraph",
  51.       "data": {
  52.         "text": "There are dozens of <a href=\"https://github.com/editor-js\">ready-to-use Blocks</a> and the <a href=\"https://editorjs.io/creating-a-block-tool\">simple API</a> for creation any Block you need. For example, you can implement Blocks for Tweets, Instagram posts, surveys and polls, CTA-buttons and even games."
  53.       }
  54.     },
  55.     {
  56.       "type": "header",
  57.       "data": {
  58.         "text": "What does it mean clean data output",
  59.         "level": 3
  60.       }
  61.     },
  62.     {
  63.       "type": "paragraph",
  64.       "data": {
  65.         "text": "Classic WYSIWYG-editors produce raw HTML-markup with both content data and content appearance. On the contrary, Editor.js outputs JSON object with data of each Block. You can see an example below"
  66.       }
  67.     },
  68.     {
  69.       "type": "paragraph",
  70.       "data": {
  71.         "text": "Given data can be used as you want: render with HTML for <code class=\"inline-code\">Web clients</code>, render natively for <code class=\"inline-code\">mobile apps</code>, create markup for <code class=\"inline-code\">Facebook Instant Articles</code> or <code class=\"inline-code\">Google AMP</code>, generate an <code class=\"inline-code\">audio version</code> and so on."
  72.       }
  73.     },
  74.     {
  75.       "type": "paragraph",
  76.       "data": {
  77.         "text": "Clean data is useful to sanitize, validate and process on the backend."
  78.       }
  79.     },
  80.     {
  81.       "type": "delimiter",
  82.       "data": {}
  83.     },
  84.     {
  85.       "type": "paragraph",
  86.       "data": {
  87.         "text": "We have been working on this project more than three years. Several large media projects help us to test and debug the Editor, to make it\'s core more stable. At the same time we significantly improved the API. Now, it can be used to create any plugin for any task. Hope you enjoy. ????"
  88.       }
  89.     },
  90.     {
  91.       "type": "image",
  92.       "data": {
  93.         "file": {
  94.           "url": "https://i.vgy.me/XatLT1.png"
  95.         },
  96.         "caption": "Image caption",
  97.         "withBorder": true,
  98.         "stretched": false,
  99.         "withBackground": false
  100.       }
  101.     }
  102.   ],
  103.   "version": "2.15.0"
  104. }';
  105.  
  106. print_r("<pre>");
  107. print_r($json);
  108. print_r("<pre>");
  109.  
File Description
  • editorjs.io parser
  • PHP Code
  • 11 Feb-2020
  • 3.43 Kb
You can Share it: