3 lines
5.5 KiB
JavaScript
3 lines
5.5 KiB
JavaScript
|
|
/*! grapesjs-custom-code - 1.0.2 */
|
||
|
|
!function(e,t){'object'==typeof exports&&'object'==typeof module?module.exports=t():'function'==typeof define&&define.amd?define([],t):'object'==typeof exports?exports["grapesjs-custom-code"]=t():e["grapesjs-custom-code"]=t()}('undefined'!=typeof globalThis?globalThis:'undefined'!=typeof window?window:this,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})}},t={};e.r(t),e.d(t,{default:()=>d});var o='custom-code-plugin__code',n='custom-code',i='custom-code:open-modal',r=void 0&&(void 0).__assign||function(){return r=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};var s=void 0&&(void 0).__assign||function(){return s=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};var a=void 0&&(void 0).__assign||function(){return a=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},a.apply(this,arguments)};var c=void 0&&(void 0).__assign||function(){return c=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},c.apply(this,arguments)};const d=function(e,t){void 0===t&&(t={});var d=c({blockCustomCode:{},propsCustomCode:{},toolbarBtnCustomCode:{},placeholderScript:"<div style=\"pointer-events: none; padding: 10px;\">\n <svg viewBox=\"0 0 24 24\" style=\"height: 30px; vertical-align: middle;\">\n <path d=\"M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2 1 21z\"></path>\n </svg>\n Custom code with <i><script></i> can't be rendered on the canvas\n </div>",modalTitle:'Insert your code',codeViewOptions:{},buttonLabel:'Save',commandCustomCode:{}},t);!function(e,t){void 0===t&&(t={});var r,s=e.Components,c=t.toolbarBtnCustomCode;s.addType('script',{view:{onRender:function(){var e=this.model,t=this.el;e.closestType(n)&&(t.innerHTML='')}}}),s.addType(n,{model:{defaults:a({name:'Custom Code',editable:!0,components:{tagName:'span',components:{type:'textnode',content:'Insert here your custom code'}}},t.propsCustomCode),init:function(){this.on("change:".concat(o),this.onCustomCodeChange);var e=this.get(o);!this.components().length&&this.components(e);var t=this.get('toolbar'),n='custom-code';c&&!t.filter((function(e){return e.id===n})).length&&t.unshift(a({id:n,command:i,label:"<svg viewBox=\"0 0 24 24\">\n <path d=\"M14.6 16.6l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4m-5.2 0L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4z\"></path>\n </svg>"},c))},onCustomCodeChange:function(){this.components(this.get(o))}},view:{events:{dblclick:'onActive'},init:function(){this.listenTo(this.model.components(),'add remove reset',this.onComponentsChange),this.onComponentsChange()},onComponentsChange:function(){var e=this;r&&clearInterval(r),r=setTimeout((function(){var n=e,i=n.model,r=n.el,s=!0;(i.get(o)||'').indexOf('<script')>=0&&t.placeholderScript&&(r.innerHTML=t.placeholderScript,s=!1),i.set({droppable:s})}),0)},onActive:function(){var e=this.model;this.em.get('Commands').run(i,{target:e})}}})}(e,d),function(e,t){var o=(void 0===t?{}:t).blockCustomCode,i=e.Blocks;o&&i.add(n,r({label:'Custom Code',media:"\n <svg viewBox=\"0 0 24 24\">\n <path d=\"M14.6 16.6l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4m-5.2 0L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4z\"></path>\n </svg>\n ",category:'Extra',activate:!0,select:!0,content:{type:n}},o))}(e,d),function(e,t){void 0===t&&(t={});var n=t.modalTitle,r=t.codeViewOptions,a=t.commandCustomCode,c=function(e,t){t insta
|
||
|
|
//# sourceMappingURL=index.js.map
|