-
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathedjsHTML.node.js
More file actions
1 lines (1 loc) · 2.54 KB
/
edjsHTML.node.js
File metadata and controls
1 lines (1 loc) · 2.54 KB
1
"use strict";var t=function(){return t=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},t.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var e={code:function(t){var e=t.data;return"<pre><code>".concat(e.code,"</code></pre>")},embed:function(t){var e=t.data,r=e.service;return"vimeo"===r?'<iframe src="'.concat(e.embed,'" height="').concat(e.height,'" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>'):"youtube"===r?'<iframe width="'.concat(e.width,'" height="').concat(e.height,'" src="').concat(e.embed,'" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'):(console.error("[editorjs-html]: Only Youtube & Vimeo embeds are available by default. Write your own embed parser for other options."),"")},header:function(t){var e=t.data;return"<h".concat(e.level,">").concat(e.text,"</h").concat(e.level,">")},image:function(t){var e,r=t.data,o=r.caption?r.caption:"Image",n=(null===(e=null==r?void 0:r.file)||void 0===e?void 0:e.url)||(null==r?void 0:r.url);return'<img src="'.concat(n,'" alt="').concat(o,'" />')},list:function(t){var e=t.data,r="unordered"===e.style?"ul":"ol",o=function(t,e){var r=t.map((function(t){var r;if(!t.content&&!t.items)return"<li>".concat(t,"</li>");var n="";return(null===(r=t.items)||void 0===r?void 0:r.length)&&(n=o(t.items,e)),t.content?"<li>".concat(t.content).concat(n,"</li>"):void 0}));return"<".concat(e,">").concat(r.join(""),"</").concat(e,">")};return o(e.items,r)},paragraph:function(t){var e=t.data,r=e.alignment||e.align;return r?'<p style="text-align:'.concat(r,'"> ').concat(e.text," </p>"):"<p>".concat(e.text,"</p>")},quote:function(t){var e=t.data;return"<blockquote>".concat(e.text,"</blockquote> - ").concat(e.caption)},delimiter:function(t){return t.data,"<br/>"}};module.exports=function(r,o){void 0===r&&(r={}),void 0===o&&(o={strict:!1});var n=t(t({},e),r);return{parse:function(t){return function(t,e,r){return t.blocks.reduce((function(t,o){if(o.type in e)return t+e[o.type](o);var n="[editorjs-html]: Parser function for ".concat(o.type," does not exist");if(r.strict)throw new Error(n);return console.error(n),t}),"")}(t,n,o)},parseBlock:function(t){return function(t,e,r){if(t.type in e)return e[t.type](t);var o="[editorjs-html]: Parser function for ".concat(t.type," does not exist");if(r.strict)throw new Error(o);console.error(o)}(t,n,o)}}};