Socket
Socket
Sign inDemoInstall

editorjs-component-selector

Package Overview
Dependencies
3
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.3

images/preview.png

2

dist/main.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["editorjs-component-selector"]=t():e["editorjs-component-selector"]=t()}(global,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);n(1);const r='<img width="20" height="20" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0xMS41IC0xMC4yMzE3NCAyMyAyMC40NjM0OCI+CiAgPHRpdGxlPlJlYWN0IExvZ288L3RpdGxlPgogIDxjaXJjbGUgY3g9IjAiIGN5PSIwIiByPSIyLjA1IiBmaWxsPSIjNjFkYWZiIi8+CiAgPGcgc3Ryb2tlPSIjNjFkYWZiIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIi8+CiAgICA8ZWxsaXBzZSByeD0iMTEiIHJ5PSI0LjIiIHRyYW5zZm9ybT0icm90YXRlKDYwKSIvPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIiB0cmFuc2Zvcm09InJvdGF0ZSgxMjApIi8+CiAgPC9nPgo8L3N2Zz4K">',o={component:null,props:{}};t.default=class{constructor({data:e,config:t,api:n}){this.api=n,this.config=t,this.nodes={container:null,selector:null,selector_wrapper:null,options:[],preview_wrapper:null,preview:null},this._data={...o},this.data=e}static get toolbox(){return{title:"Component selector",icon:r}}makeElement(e,t,n){const r=document.createElement(e);if(r.classList.add(...t),n)for(const e in n)r.setAttribute(e,n[e]);return r}makeClass(e){return`component-selector_tool__${e}`}render(){return this.nodes.container=this.makeElement("div",[this.makeClass("container"),"cdx-block"]),this.nodes.container.appendChild(this.makeSelector()),this.nodes.container}set data(e){this._data=Object.assign({},o,e),setTimeout(()=>{this.validate()&&this.renderPreview()},0)}get data(){return this._data}save(){return this.data}validate(){return!!this.data.component}getComponentByName(e){return this.config.components.find(t=>t.name===e)}changeComponent(e){const t=this.getComponentByName(e.value);this.data={component:t.name,props:t.props||{}}}makeSelector(){this.nodes.selector_wrapper=this.makeElement("div",[this.makeClass("selector_wrapper")]);const e=this.nodes.selector=this.makeElement("select",[this.makeClass("selector")]);this.nodes.selector_wrapper.appendChild(e);for(let t of this.config.components){const n=this.makeElement("option",[this.makeClass("option")],{value:t.name});n.innerText=t.alias||t.name,this.nodes.options.push(n),e.appendChild(n)}return e.addEventListener("change",e=>this.changeComponent(e.target)),this.changeComponent(e),this.nodes.selector_wrapper}makePreviewWrapper(){return this.nodes.preview_wrapper=this.makeElement("div",[this.makeClass("preview_wrapper")]),this.nodes.preview_wrapper}renderPreview(){console.log("renderPreview"),this.nodes.preview||(this.nodes.container.appendChild(this.makePreviewWrapper()),this.nodes.preview=this.makeElement("img",[this.makeClass("preveiw")]),this.nodes.preview_wrapper.appendChild(this.nodes.preview)),this.nodes.preview.src=this.getComponentByName(this.data.component).preview}}},function(e,t,n){var r=n(2);"string"==typeof r&&(r=[[e.i,r,""]]);var o={transform:void 0},i=n(4)(r,o);r.locals&&(e.exports=r.locals),e.exports.__universal__=i.__universal__},function(e,t,n){(e.exports=n(3)(!1)).push([e.i,".component-selector_tool__selector_wrapper select {\n border: 1px solid rgba(201, 201, 204, 0.48);\n -webkit-box-shadow: inset 0 1px 2px 0 rgba(35, 44, 72, 0.06);\n box-shadow: inset 0 1px 2px 0 rgba(35, 44, 72, 0.06);\n border-radius: 3px;\n padding: 14px 12px;\n outline: none;\n width: 100%;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.component-selector_tool__selector_wrapper {\n margin-bottom: 1em;\n}\n.component-selector_tool__preview_wrapper img {\n width: 100%;\n}\n",""])},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",r=e[3];if(!r)return n;if(t&&"function"==typeof btoa){var o=(s=r,a=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),i=r.sources.map((function(e){return"/*# sourceURL=".concat(r.sourceRoot).concat(e," */")}));return[n].concat(i).concat([o]).join("\n")}var s,a,c;return[n].join("\n")}(t,e);return t[2]?"@media ".concat(t[2],"{").concat(n,"}"):n})).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var i=this[o][0];null!=i&&(r[i]=!0)}for(var s=0;s<e.length;s++){var a=e[s];null!=a[0]&&r[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="(".concat(a[2],") and (").concat(n,")")),t.push(a))}},t}},function(e,t,n){var r,o,i,s=n(5),a=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}},c="data-universal",l="ssr",u=[],p={},d=null,f=0,h=[];function m(){}function v(){for(var e,t=[].slice.call(document.getElementsByTagName("style"),0),n=0;n<t.length;n++)(e=t[n]).getAttribute(c)===l&&e.parentNode.removeChild(e)}function g(e,t){for(var n=[],r={},o=0;o<e.length;o++){var i=e[o],s=t.base?i[0]+t.base:i[0],a={css:i[1],media:i[2],sourceMap:i[3]};r[s]?r[s].parts.push(a):n.push(r[s]={id:s,parts:[a]})}return n}function b(e,t){for(var n=0;n<e.length;n++){var r=e[n],o=p[r.id];if(o){o.refs++;for(var i=0;i<o.parts.length;i++)o.parts[i](r.parts[i]);for(;i<r.parts.length;i++)o.parts.push(_(r.parts[i],t))}else{var s=[];for(i=0;i<r.parts.length;i++)s.push(_(r.parts[i],t));p[r.id]={id:r.id,refs:1,parts:s}}}}function y(e,t){var n=o(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=h[h.length-1];if("top"===e.insertAt)r?r.nextSibling?n.insertBefore(t,r.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),h.push(t);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(t)}}function w(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=h.indexOf(e);t>=0&&h.splice(t,1)}function x(e){var t=document.createElement("style");return e.attrs.type="text/css",C(t,e.attrs),y(e,t),t}function C(e,t){Object.keys(t).forEach((function(n){e.setAttribute(n,t[n])}))}function _(e,t){var n,r,o,i;if(t.transform&&e.css){if(!(i=t.transform(e.css)))return function(){};e.css=i}if(t.singleton){var s=f++;n=d||(d=x(t)),r=k.bind(null,n,s,!1),o=k.bind(null,n,s,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",C(t,e.attrs),y(e,t),t}(t),r=S.bind(null,n,t),o=function(){w(n),n.href&&URL.revokeObjectURL(n.href)}):(n=x(t),r=A.bind(null,n),o=function(){w(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else o()}}e.exports=function(e,t){(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{};var h,y,w=g(e,t);return m.__universal__=void 0,"object"==typeof window&&window.document?(r=a((function(){return window&&document&&document.all&&!window.atob})),t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom"),i=n(6),h=function(e){return document.querySelector(e)},y={},o=function(e){if(void 0===y[e]){var t=h.call(this,e);if(t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(e){t=null}y[e]=t}return y[e]},b(w,t),setTimeout(v,16),function(e){for(var n=[],r=0;r<w.length;r++){var o=w[r];(i=p[o.id]).refs--,n.push(i)}e&&b(g(e,t),t);for(r=0;r<n.length;r++){var i;if(0===(i=n[r]).refs){for(var s=0;s<i.parts.length;s++)i.parts[s]();delete p[i.id]}}}):(r=a((function(){return!("object"!=typeof navigator||!navigator.userAgent)&&/MSIE [5-9]\b/i.test(navigator.userAgent)})),t.singleton||(t.singleton=r()),function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.parts.length;o++)i(r.parts[o],t,r.id);return m.__universal__=u,m;function i(e,t,n){var r,o;if(t.transform&&e.css){if(!(o=t.transform(e.css)))return m;e.css=o}if(t.attrs.type="text/css",t.attrs[c]=l,t.singleton){var i=f++;t.attrs["data-singleton"]="singleton",(r=d||(d=a(t,n))).content.splice(i,1,e.css),-1===u.indexOf(r)&&u.push(r)}else(r=a(t,n)).content.push(e.css),e.media&&r.setAttribute("media",e.media),u.push(r);return m}function a(e,t){var n=new s(t);return Object.keys(e.attrs).forEach((function(t){n.setAttribute(t,e.attrs[t])})),n}}(w,t))};var j,I=(j=[],function(e,t){return j[e]=t,j.filter(Boolean).join("\n")});function k(e,t,n,r){var o=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=I(t,o);else{var i=document.createTextNode(o),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(i,s[t]):e.appendChild(i)}}function A(e,t){var n=t.css,r=t.media;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function S(e,t,n){var r=n.css,o=n.sourceMap,s=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||s)&&(r=i(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var a=new Blob([r],{type:"text/css"}),c=e.href;e.href=URL.createObjectURL(a),c&&URL.revokeObjectURL(c)}},function(e,t){function n(e){this.id=e,this.content=[],this.attrs={}}n.prototype.setAttribute=function(e,t){null==t?delete this.attrs[e]:this.attrs[e]=t},n.prototype.toString=function(e){var t=this.content.join(null==e?"\n":e),n="",r=this.attrs;return Object.keys(this.attrs).forEach((function(e){n+=e+'="'+r[e]+'" '})),n.length>0&&(n=" "+n.slice(0,-1)),"<style"+n+">"+t+"</style>"},e.exports=n},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,r=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(e,t){var o,i=t.trim().replace(/^"(.*)"$/,(function(e,t){return t})).replace(/^'(.*)'$/,(function(e,t){return t}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(i)?e:(o=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:r+i.replace(/^\.\//,""),"url("+JSON.stringify(o)+")")}))}}])}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["editorjs-component-selector"]=e():t["editorjs-component-selector"]=e()}(global,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);n(1);const r='<img width="20" height="20" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0xMS41IC0xMC4yMzE3NCAyMyAyMC40NjM0OCI+CiAgPHRpdGxlPlJlYWN0IExvZ288L3RpdGxlPgogIDxjaXJjbGUgY3g9IjAiIGN5PSIwIiByPSIyLjA1IiBmaWxsPSIjNjFkYWZiIi8+CiAgPGcgc3Ryb2tlPSIjNjFkYWZiIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIi8+CiAgICA8ZWxsaXBzZSByeD0iMTEiIHJ5PSI0LjIiIHRyYW5zZm9ybT0icm90YXRlKDYwKSIvPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIiB0cmFuc2Zvcm09InJvdGF0ZSgxMjApIi8+CiAgPC9nPgo8L3N2Zz4K">',o={component:null,props:{}};e.default=class{constructor({data:t,config:e,api:n}){this.api=n,this.config=e,this.nodes={container:null,selector:null,selector_wrapper:null,options:[],preview_wrapper:null,preview:null},this._data=null,this.data=t}static get toolbox(){return{title:"Component selector",icon:r}}makeElement(t,e,n){const r=document.createElement(t);if(r.classList.add(...e),n)for(const t in n)r.setAttribute(t,n[t]);return r}makeClass(t){return`component-selector_tool__${t}`}render(){return this.nodes.container=this.makeElement("div",[this.makeClass("container"),"cdx-block"]),this.nodes.container.appendChild(this.makeSelector()),this.nodes.container}set data(t){this._data=Object.assign({},o,t),setTimeout(()=>{this.validate()&&this.renderPreview()},0)}get data(){return this._data}save(){return this.data}validate(){return!!this.data.component}getComponentByName(t){return this.config.components.find(e=>e.name===t)}changeComponent(t){const e=this.getComponentByName(t.value);this.data={component:e.name,props:e.props||{}}}makeSelector(){this.nodes.selector_wrapper=this.makeElement("div",[this.makeClass("selector_wrapper")]);const t=this.nodes.selector=this.makeElement("select",[this.makeClass("selector")]);this.nodes.selector_wrapper.appendChild(t);for(let e of this.config.components){const n=this.makeElement("option",[this.makeClass("option")],{value:e.name});n.innerText=e.alias||e.name,this.nodes.options.push(n),t.appendChild(n)}return t.value=this.data.component,t.addEventListener("change",t=>this.changeComponent(t.target)),this.changeComponent(t),this.nodes.selector_wrapper}makePreviewWrapper(){return this.nodes.preview_wrapper=this.makeElement("div",[this.makeClass("preview_wrapper")]),this.nodes.preview_wrapper}renderPreview(){this.nodes.preview||(this.nodes.container.appendChild(this.makePreviewWrapper()),this.nodes.preview=this.makeElement("img",[this.makeClass("preveiw")]),this.nodes.preview_wrapper.appendChild(this.nodes.preview)),this.nodes.preview.src=this.getComponentByName(this.data.component).preview}}},function(t,e,n){var r=n(2);"string"==typeof r&&(r=[[t.i,r,""]]);var o={transform:void 0},i=n(4)(r,o);r.locals&&(t.exports=r.locals),t.exports.__universal__=i.__universal__},function(t,e,n){(t.exports=n(3)(!1)).push([t.i,".component-selector_tool__selector_wrapper select {\n border: 1px solid rgba(201, 201, 204, 0.48);\n -webkit-box-shadow: inset 0 1px 2px 0 rgba(35, 44, 72, 0.06);\n box-shadow: inset 0 1px 2px 0 rgba(35, 44, 72, 0.06);\n border-radius: 3px;\n padding: 14px 12px;\n outline: none;\n width: 100%;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n}\n.component-selector_tool__selector_wrapper {\n margin-bottom: 1em;\n}\n.component-selector_tool__preview_wrapper img {\n width: 100%;\n}\n",""])},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var o=(s=r,a=btoa(unescape(encodeURIComponent(JSON.stringify(s)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),i=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot).concat(t," */")}));return[n].concat(i).concat([o]).join("\n")}var s,a,c;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2],"{").concat(n,"}"):n})).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},o=0;o<this.length;o++){var i=this[o][0];null!=i&&(r[i]=!0)}for(var s=0;s<t.length;s++){var a=t[s];null!=a[0]&&r[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="(".concat(a[2],") and (").concat(n,")")),e.push(a))}},e}},function(t,e,n){var r,o,i,s=n(5),a=function(t){var e;return function(){return void 0===e&&(e=t.apply(this,arguments)),e}},c="data-universal",l="ssr",u=[],p={},d=null,f=0,h=[];function m(){}function v(){for(var t,e=[].slice.call(document.getElementsByTagName("style"),0),n=0;n<e.length;n++)(t=e[n]).getAttribute(c)===l&&t.parentNode.removeChild(t)}function g(t,e){for(var n=[],r={},o=0;o<t.length;o++){var i=t[o],s=e.base?i[0]+e.base:i[0],a={css:i[1],media:i[2],sourceMap:i[3]};r[s]?r[s].parts.push(a):n.push(r[s]={id:s,parts:[a]})}return n}function b(t,e){for(var n=0;n<t.length;n++){var r=t[n],o=p[r.id];if(o){o.refs++;for(var i=0;i<o.parts.length;i++)o.parts[i](r.parts[i]);for(;i<r.parts.length;i++)o.parts.push(_(r.parts[i],e))}else{var s=[];for(i=0;i<r.parts.length;i++)s.push(_(r.parts[i],e));p[r.id]={id:r.id,refs:1,parts:s}}}}function y(t,e){var n=o(t.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var r=h[h.length-1];if("top"===t.insertAt)r?r.nextSibling?n.insertBefore(e,r.nextSibling):n.appendChild(e):n.insertBefore(e,n.firstChild),h.push(e);else{if("bottom"!==t.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(e)}}function w(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t);var e=h.indexOf(t);e>=0&&h.splice(e,1)}function x(t){var e=document.createElement("style");return t.attrs.type="text/css",C(e,t.attrs),y(t,e),e}function C(t,e){Object.keys(e).forEach((function(n){t.setAttribute(n,e[n])}))}function _(t,e){var n,r,o,i;if(e.transform&&t.css){if(!(i=e.transform(t.css)))return function(){};t.css=i}if(e.singleton){var s=f++;n=d||(d=x(e)),r=k.bind(null,n,s,!1),o=k.bind(null,n,s,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(t){var e=document.createElement("link");return t.attrs.type="text/css",t.attrs.rel="stylesheet",C(e,t.attrs),y(t,e),e}(e),r=S.bind(null,n,e),o=function(){w(n),n.href&&URL.revokeObjectURL(n.href)}):(n=x(e),r=A.bind(null,n),o=function(){w(n)});return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else o()}}t.exports=function(t,e){(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{};var h,y,w=g(t,e);return m.__universal__=void 0,"object"==typeof window&&window.document?(r=a((function(){return window&&document&&document.all&&!window.atob})),e.singleton||(e.singleton=r()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom"),i=n(6),h=function(t){return document.querySelector(t)},y={},o=function(t){if(void 0===y[t]){var e=h.call(this,t);if(e instanceof window.HTMLIFrameElement)try{e=e.contentDocument.head}catch(t){e=null}y[t]=e}return y[t]},b(w,e),setTimeout(v,16),function(t){for(var n=[],r=0;r<w.length;r++){var o=w[r];(i=p[o.id]).refs--,n.push(i)}t&&b(g(t,e),e);for(r=0;r<n.length;r++){var i;if(0===(i=n[r]).refs){for(var s=0;s<i.parts.length;s++)i.parts[s]();delete p[i.id]}}}):(r=a((function(){return!("object"!=typeof navigator||!navigator.userAgent)&&/MSIE [5-9]\b/i.test(navigator.userAgent)})),e.singleton||(e.singleton=r()),function(t,e){for(var n=0;n<t.length;n++)for(var r=t[n],o=0;o<r.parts.length;o++)i(r.parts[o],e,r.id);return m.__universal__=u,m;function i(t,e,n){var r,o;if(e.transform&&t.css){if(!(o=e.transform(t.css)))return m;t.css=o}if(e.attrs.type="text/css",e.attrs[c]=l,e.singleton){var i=f++;e.attrs["data-singleton"]="singleton",(r=d||(d=a(e,n))).content.splice(i,1,t.css),-1===u.indexOf(r)&&u.push(r)}else(r=a(e,n)).content.push(t.css),t.media&&r.setAttribute("media",t.media),u.push(r);return m}function a(t,e){var n=new s(e);return Object.keys(t.attrs).forEach((function(e){n.setAttribute(e,t.attrs[e])})),n}}(w,e))};var j,I=(j=[],function(t,e){return j[t]=e,j.filter(Boolean).join("\n")});function k(t,e,n,r){var o=n?"":r.css;if(t.styleSheet)t.styleSheet.cssText=I(e,o);else{var i=document.createTextNode(o),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(i,s[e]):t.appendChild(i)}}function A(t,e){var n=e.css,r=e.media;if(r&&t.setAttribute("media",r),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}function S(t,e,n){var r=n.css,o=n.sourceMap,s=void 0===e.convertToAbsoluteUrls&&o;(e.convertToAbsoluteUrls||s)&&(r=i(r)),o&&(r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var a=new Blob([r],{type:"text/css"}),c=t.href;t.href=URL.createObjectURL(a),c&&URL.revokeObjectURL(c)}},function(t,e){function n(t){this.id=t,this.content=[],this.attrs={}}n.prototype.setAttribute=function(t,e){null==e?delete this.attrs[t]:this.attrs[t]=e},n.prototype.toString=function(t){var e=this.content.join(null==t?"\n":t),n="",r=this.attrs;return Object.keys(this.attrs).forEach((function(t){n+=t+'="'+r[t]+'" '})),n.length>0&&(n=" "+n.slice(0,-1)),"<style"+n+">"+e+"</style>"},t.exports=n},function(t,e){t.exports=function(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var n=e.protocol+"//"+e.host,r=n+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var o,i=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(i)?t:(o=0===i.indexOf("//")?i:0===i.indexOf("/")?n+i:r+i.replace(/^\.\//,""),"url("+JSON.stringify(o)+")")}))}}])}));

@@ -34,3 +34,3 @@ import EditorJS from "@editorjs/editorjs";

data: {
component: "OrderForm",
component: "SubscribeForm",
props: {}

@@ -37,0 +37,0 @@ }

{
"name": "editorjs-component-selector",
"version": "0.0.1",
"version": "0.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

# Editor.js plugin for selecting of component (more likely simple selector)
![preview](/images/preview.png)
## Disclaimer
My advice: Do not use this library =)
This lib do not render React components to Editor.js, just render image

@@ -20,3 +23,4 @@ ### Installation

config: {
title: "OrderForm",
name: "OrderForm",
alias: "Форма заявки",
props: {},

@@ -36,6 +40,5 @@ preview: "..."

"component": "OrderForm",
"props": {},
"preview": "..."
"props": {}
}
}
```

@@ -24,3 +24,3 @@ import "./styles.css";

};
this._data = { ...DEFAULT_DATA };
this._data = null;
this.data = data;

@@ -129,2 +129,3 @@ }

}
selector.value = this.data.component
selector.addEventListener("change", event =>

@@ -152,3 +153,2 @@ this.changeComponent(event.target)

renderPreview() {
console.log("renderPreview");
if (!this.nodes.preview) {

@@ -155,0 +155,0 @@ this.nodes.container.appendChild(this.makePreviewWrapper());

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc