Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

editor js to html

convertDataToHtml(blocks) {
      var convertedHtml = "";
      blocks.map(block => {
        
        switch (block.type) {
          case "header":
            convertedHtml += `<h${block.data.level}>${block.data.text}</h${block.data.level}>`;
            break;
          case "embded":
            convertedHtml += `<div><iframe width="560" height="315" src="${block.data.embed}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></div>`;
            break;
          case "paragraph":
            convertedHtml += `<p>${block.data.text}</p>`;
            break;
          case "delimiter":
            convertedHtml += "<hr />";
            break;
          case "image":
            convertedHtml += `<img class="img-fluid" src="${block.data.file.url}" title="${block.data.caption}" /><br /><em>${block.data.caption}</em>`;
            break;
          case "list":
            convertedHtml += "<ul>";
            block.data.items.forEach(function(li) {
              convertedHtml += `<li>${li}</li>`;
            });
            convertedHtml += "</ul>";
            break;
          default:
            console.log("Unknown block type", block.type);
            break;
        }
      });
      return convertedHtml;
    }
Comment

js html editor

codepen.io
jsfiddle.net
replit.com
Comment

PREVIOUS NEXT
Code Example
Javascript :: hammer js cdn 
Javascript :: cookie in javascript 
Javascript :: window widht jquery 
Javascript :: replace each string by another string javascript 
Javascript :: js retour à la ligne 
Javascript :: Print array of objects js 
Javascript :: join in mongodb 
Javascript :: queryselectorall in javascript to get data attribute value 
Javascript :: js how to sort strings in array 
Javascript :: jquery id value input 
Javascript :: reg ex with filter in js 
Javascript :: string interpolation in javascript 
Javascript :: toastr.success 
Javascript :: jquery use variable in string "without" concatenate 
Javascript :: async useeffect 
Javascript :: get minutes and seconds of long seconds 
Javascript :: yaml to json javascript 
Javascript :: Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it. 
Javascript :: mocha config 
Javascript :: use svg image in next js 
Javascript :: react does not send the cookie automatically 
Javascript :: install three js fiber 
Javascript :: compare mongoose id 
Javascript :: next day date javascript 
Javascript :: import card content material ui 
Javascript :: Lodash.chunk chunk 
Javascript :: set lodash 
Javascript :: nodejs update in mysql 
Javascript :: nextjs api 
Javascript :: delete element html javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =