@grapesjs/studio-sdk-plugins 1.0.26 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- "use strict";const x="app.grapesjs.com",R="app-stage.grapesjs.com",P=[x,R,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],j="license:check:start",H="license:check:end",B=()=>typeof window<"u",C=({isDev:e,isStage:o})=>`${e?"":`https://${o?R:x}`}/api`,F=()=>{const e=B()&&window.location.hostname;return!!e&&(P.includes(e)||P.some(o=>e.endsWith(o)))};async function W({path:e,baseApiUrl:o,method:t="GET",headers:n={},params:l,body:g}){const r=`${o||C({isDev:!1,isStage:!1})}${e}`,s={method:t,headers:{"Content-Type":"application/json",...n}};g&&(s.body=JSON.stringify(g));const c=l?new URLSearchParams(l).toString():"",i=c?`?${c}`:"",d=await fetch(`${r}${i}`,s);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{}),_=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(_||{}),f=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(f||{});const k={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function m(e){const o=e;return o.init=t=>n=>e(n,t),o}const K=e=>m(e);async function S({editor:e,plan:o,pluginName:t,licenseKey:n,cleanup:l}){let g="",u=!1;const r=F(),s=i=>{console.warn("Cleanup plugin:",t,"Reason:",i),l()},c=(i={})=>{var y;const{error:d,sdkLicense:h}=i,a=(y=i.plan)==null?void 0:y.category;if(!(h||i.license)||d)s(d||"Invalid license");else if(a){const b=k[o],v=k[a];b>v&&s({pluginRequiredPlan:o,licensePlan:a})}};e.on(j,i=>{g=i==null?void 0:i.baseApiUrl,u=!0}),e.on(H,i=>{c(i)}),setTimeout(async()=>{if(!u){if(r)return;if(n){const i=await V({licenseKey:n,pluginName:t,baseApiUrl:g});i&&c(i)}else s("The `licenseKey` option not provided")}},2e3)}async function V(e){const{licenseKey:o,pluginName:t,baseApiUrl:n}=e;try{return(await W({baseApiUrl:n,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(l){return console.error("Error during SDK license check:",l),!1}}const Y=(e,o)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,o))},z="iconifyComponent",q=L.startup,J={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},w=`<svg viewBox="0 0 24 24">
1
+ "use strict";const _="app.grapesjs.com",R="app-stage.grapesjs.com",k=[_,R,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],B="license:check:start",H="license:check:end",F=()=>typeof window<"u",C=({isDev:e,isStage:t})=>`${e?"":`https://${t?R:_}`}/api`,W=()=>{const e=F()&&window.location.hostname;return!!e&&(k.includes(e)||k.some(t=>e.endsWith(t)))};async function K({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:u,body:g}){const r=`${t||C({isDev:!1,isStage:!1})}${e}`,n={method:o,headers:{"Content-Type":"application/json",...s}};g&&(n.body=JSON.stringify(g));const c=u?new URLSearchParams(u).toString():"",i=c?`?${c}`:"",p=await fetch(`${r}${i}`,n);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var v=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(v||{}),D=(e=>(e.Info="info",e.Error="error",e.Success="success",e.Warning="warning",e))(D||{}),L=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(L||{});const O={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function S(e){const t=e;return t.init=o=>s=>e(s,o),t}const V=e=>S(e);async function Y({editor:e,plan:t,pluginName:o,licenseKey:s,cleanup:u}){let g="",a=!1;const r=W(),n=i=>{console.warn("Cleanup plugin:",o,"Reason:",i),u()},c=(i={})=>{var y;const{error:p,sdkLicense:h}=i,l=(y=i.plan)==null?void 0:y.category;if(!(h||i.license)||p)n(p||"Invalid license");else if(l){const b=O[t],d=O[l];b>d&&n({pluginRequiredPlan:t,licensePlan:l})}};e.on(B,i=>{g=i==null?void 0:i.baseApiUrl,a=!0}),e.on(H,i=>{c(i)}),setTimeout(async()=>{if(!a){if(r)return;if(s){const i=await z({licenseKey:s,pluginName:o,baseApiUrl:g});i&&c(i)}else n("The `licenseKey` option not provided")}},2e3)}async function z(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await K({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(u){return console.error("Error during SDK license check:",u),!1}}const q=(e,t)=>{var o;return!!((o=e==null?void 0:e.hasAttribute)!=null&&o.call(e,t))},J="iconifyComponent",m=v.startup,X={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},I=`<svg viewBox="0 0 24 24">
2
2
  <path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
3
- </svg>`,$="layout-icon-picker",X="icons-layout-",D="icons-list-layout",M="gs-iconify-picker",A="__iconify_collection",Z="https://api.iconify.design",I=new Map;let T;const Q=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function N({collectionId:e,editor:o}){try{if(I.has(e))return I.get(e);const t=await fetch(Q({collectionId:e}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const n=await t.json();return I.set(e,n),n}catch(t){console.error("Error fetching collection",t),o.runCommand(f.toastAdd,re());return}}async function ee({collectionIds:e,editor:o}){try{if(T)return T;const t=e?`?prefixes=${e.join(",")}`:"",n=await fetch(`${Z}/collections${t}`);if(!n.ok)throw new Error(`Failed to fetch collections: ${n.statusText}`);return T=await n.json(),T}catch(t){console.error("Error fetching collections",t),o.runCommand(f.toastAdd,U());return}}function O(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var o;(o=e.getSelected())==null||o.trigger("active")}}}async function te({collectionIds:e,editor:o,component:t}){const n=await ee({collectionIds:e,editor:o});if(!n)return;const l=({icon:s,collectionId:c,iconId:i})=>{t.components(s),t.set({collectionId:c,iconId:i})},g=Object.entries(n).map(([s,c])=>({id:s,...c})).sort((s,c)=>s.name.localeCompare(c.name)),u=t.get("collectionId")??g[0].id;o.runCommand(f.layoutToggle,{id:$,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[se({collectionsList:g,collectionId:u,editor:o,handleClick:l}),{id:D,type:"column",grow:!0}]}});const r=await N({collectionId:u,editor:o});r&&E({editor:o,collection:r,handleClick:l,collectionId:u})}function oe({editor:e,collection:o}){e.em.set(A,o)}function ne(e){return e.em.get(A)}function E(e){const{editor:o}=e,t={id:X,layout:ie(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:D}};o.runCommand(f.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>o.runCommand(f.layoutAdd,t),10)}function se(e){const{collectionsList:o,collectionId:t,editor:n,handleClick:l}=e,g=o.map(({id:u,name:r,total:s})=>({id:u,label:`${r} (${s})`})).sort((u,r)=>u.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${M}__header`,children:[{type:"selectField",value:t,options:g,emptyState:"Select an icon collection",onChange:async({setState:u,value:r})=>{const s=await N({collectionId:r,editor:n});s&&(u({value:r}),oe({editor:n,collection:s}),E({editor:n,collection:s,handleClick:l,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${A}`]:({setState:u})=>u({value:""})},onInput:({setState:u,value:r,editor:s})=>{const c=ne(s);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([d])=>d.includes(r)));u({value:r}),E({editor:s,collection:c,handleClick:l,collectionId:r,collectionFiltered:{...c,icons:i}})}}]}}function ie({collection:e,collectionFiltered:o,handleClick:t}){const{height:n=24,width:l=24,icons:g,prefix:u}=o||e,r=Object.entries(g).map(([s,{body:c}])=>({name:s,body:c}),{});return{type:"column",className:`${M}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:s})=>[{type:"custom",render:c=>{const{editor:i,addEl:d,removeEl:h}=c,a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.innerHTML=s.body,a.setAttribute("viewBox",`0 0 ${l} ${n}`);const{cssWidth:p,cssHeight:y}=ce(l,n);a.style.cssText=`width: ${p}px; height: ${y}px; cursor: pointer;`,a.addEventListener("mouseover",()=>{a.style.border="2px solid currentColor",a.style.borderRadius="4px",a.style.padding="4px"}),a.addEventListener("mouseout",()=>{a.style.border="none"});const b=()=>{const v=a.cloneNode(!0);v.removeAttribute("style");const G=v.outerHTML;t({icon:G,collectionId:u,iconId:s.name}),i==null||i.runCommand(f.layoutRemove,{id:$})};return a.addEventListener("click",b),d(a),()=>{a.removeEventListener("click",b),h(a)}}}]}}}function ce(e,o){const t=e/o;let n=48,l=48;return t>1?l=48/t:t<1&&(n=48*t),{cssWidth:n,cssHeight:l}}function U(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:_.Error}}function re(){return{...U(),id:"toast-error-getCollection",content:"Error fetching collection"}}const ae=function(e,o={}){var a;const{Components:t,Blocks:n}=e,{collections:l,extendIconComponent:g=!0,licenseKey:u,block:r={}}=o,s="icon",c="iconify",i="Iconify",d="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){te({collectionIds:l,editor:e,component:this.model})}};if(t.addType(c,{block:r&&{label:i,media:w,content:{type:c},category:"Extra",activate:!0,...r},isComponent:p=>Y(p,d),model:{defaults:{name:i,icon:w,droppable:!1,attributes:{[d]:!0},resizable:J,components:w,style:{width:"50px",height:"50px"},traits:[O()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:h}),g){const p=(a=t.getType(s))==null?void 0:a.model,[y,b,...v]=p.getDefaults().traits;t.addType(s,{model:{defaults:{traits:[y,b,O(),...v]}},view:h})}S({editor:e,licenseKey:u,plan:q,pluginName:z,cleanup:()=>{n.remove(c),t.removeType(c)}})},le=K(ae);module.exports=le;
3
+ </svg>`,$="layout-icon-picker",Z="icons-layout-",U="icons-list-layout",M="gs-iconify-picker",P="__iconify_collection",Q="https://api.iconify.design",E=new Map;let T;const ee=({collectionId:e})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;async function N({collectionId:e,editor:t}){try{if(E.has(e))return E.get(e);const o=await fetch(ee({collectionId:e}));if(!o.ok)throw new Error(`Failed to fetch collection: ${o.statusText}`);const s=await o.json();return E.set(e,s),s}catch(o){console.error("Error fetching collection",o),t.runCommand(L.toastAdd,ce());return}}async function te({collectionIds:e,editor:t}){try{if(T)return T;const o=e?`?prefixes=${e.join(",")}`:"",s=await fetch(`${Q}/collections${o}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return T=await s.json(),T}catch(o){console.error("Error fetching collections",o),t.runCommand(L.toastAdd,j());return}}function x(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(e){var t;(t=e.getSelected())==null||t.trigger("active")}}}async function oe({collectionIds:e,editor:t,component:o}){const s=await te({collectionIds:e,editor:t});if(!s)return;const u=({icon:n,collectionId:c,iconId:i})=>{o.components(n),o.set({collectionId:c,iconId:i})},g=Object.entries(s).map(([n,c])=>({id:n,...c})).sort((n,c)=>n.name.localeCompare(c.name)),a=o.get("collectionId")??g[0].id;t.runCommand(L.layoutToggle,{id:$,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[se({collectionsList:g,collectionId:a,editor:t,handleClick:u}),{id:U,type:"column",grow:!0}]}});const r=await N({collectionId:a,editor:t});r&&(G({editor:t,collection:r}),A({editor:t,collection:r,handleClick:u,collectionId:a}))}function G({editor:e,collection:t}){e.em.set(P,t)}function ne(e){return e.em.get(P)}function A(e){const{editor:t}=e;t.runCommand(L.layoutUpdate,{id:Z,layout:ie(e),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:U}})}function se(e){const{collectionsList:t,collectionId:o,editor:s,handleClick:u}=e,g=t.map(({id:a,name:r,total:n})=>({id:a,label:`${r} (${n})`})).sort((a,r)=>a.label.localeCompare(r.label));return{type:"column",style:{gap:10},className:`${M}__header`,children:[{type:"selectField",value:o,options:g,emptyState:"Select an icon collection",onChange:async({setState:a,value:r})=>{const n=await N({collectionId:r,editor:s});n&&(a({value:r}),G({editor:s,collection:n}),A({editor:s,collection:n,handleClick:u,collectionId:r}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${P}`]:({setState:a})=>a({value:""})},onInput:({setState:a,value:r,editor:n})=>{const c=ne(n);if(!c)return;const i=Object.fromEntries(Object.entries(c.icons).filter(([p])=>p.includes(r)));a({value:r}),A({editor:n,collection:c,handleClick:u,collectionId:o,collectionFiltered:{...c,icons:i}})}}]}}function ie({collection:e,collectionFiltered:t,handleClick:o}){const{height:s=24,width:u=24,icons:g,prefix:a}=t||e,r=Object.entries(g).map(([n,c])=>({name:n,...c}),{});return{type:"column",className:`${M}__content`,style:{height:"100%"},children:{type:"virtualList",items:r,itemLayout:({item:n})=>({type:"custom",render:c=>{const{editor:i,addEl:p,removeEl:h}=c,l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.innerHTML=n.body;const f=n.width||u,y=n.height||s;l.setAttribute("viewBox",`0 0 ${f} ${y}`),l.style.cssText="width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";const b=[["click",()=>{const d=l.cloneNode(!0);d.removeAttribute("style");const w=d.outerHTML;o({icon:w,collectionId:a,iconId:n.name}),i==null||i.runCommand(L.layoutRemove,{id:$})}],["pointerover",()=>{l.style.border="2px solid currentColor",l.style.padding="4px"}],["pointerout",()=>{l.style.border="",l.style.padding=""}]];return b.forEach(([d,w])=>l.addEventListener(d,w)),p(l),()=>{b.forEach(([d,w])=>l.removeEventListener(d,w)),h(l)}}})}}}function j(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:D.Error}}function ce(){return{...j(),id:"toast-error-getCollection",content:"Error fetching collection"}}const re=function(e,t={}){var l;const{Components:o,Blocks:s}=e,{collections:u,extendIconComponent:g=!0,licenseKey:a,block:r={}}=t,n="icon",c="iconify",i="Iconify",p="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){oe({collectionIds:u,editor:e,component:this.model})}};if(o.addType(c,{block:r&&{label:i,media:I,content:{type:c},category:"Extra",activate:!0,...r},isComponent:f=>q(f,p),model:{defaults:{name:i,icon:I,droppable:!1,attributes:{[p]:!0},resizable:X,components:I,style:{width:"50px",height:"50px"},traits:[x()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(f=>f.set({layerable:!1,locked:!0}))}},view:h}),g){const f=(l=o.getType(n))==null?void 0:l.model,[y,b,...d]=f.getDefaults().traits;o.addType(n,{model:{defaults:{traits:[y,b,x(),...d]}},view:h})}Y({editor:e,licenseKey:a,plan:m,pluginName:J,cleanup:()=>{s.remove(c),o.removeType(c)}})},ae=V(re);module.exports=ae;
@@ -1,5 +1,5 @@
1
- const x = "app.grapesjs.com", R = "app-stage.grapesjs.com", P = [
2
- x,
1
+ const _ = "app.grapesjs.com", R = "app-stage.grapesjs.com", k = [
2
+ _,
3
3
  R,
4
4
  "localhost",
5
5
  "127.0.0.1",
@@ -9,144 +9,144 @@ const x = "app.grapesjs.com", R = "app-stage.grapesjs.com", P = [
9
9
  // For stackblitz.com demos
10
10
  "-sandpack.codesandbox.io"
11
11
  // For Sandpack demos
12
- ], j = "license:check:start", H = "license:check:end", B = () => typeof window < "u", C = ({ isDev: e, isStage: o }) => `${e ? "" : `https://${o ? R : x}`}/api`, F = () => {
13
- const e = B() && window.location.hostname;
14
- return !!e && (P.includes(e) || P.some((o) => e.endsWith(o)));
12
+ ], B = "license:check:start", H = "license:check:end", F = () => typeof window < "u", C = ({ isDev: e, isStage: t }) => `${e ? "" : `https://${t ? R : _}`}/api`, W = () => {
13
+ const e = F() && window.location.hostname;
14
+ return !!e && (k.includes(e) || k.some((t) => e.endsWith(t)));
15
15
  };
16
- async function W({
16
+ async function K({
17
17
  path: e,
18
- baseApiUrl: o,
19
- method: t = "GET",
20
- headers: n = {},
21
- params: l,
18
+ baseApiUrl: t,
19
+ method: o = "GET",
20
+ headers: s = {},
21
+ params: u,
22
22
  body: g
23
23
  }) {
24
- const r = `${o || C({ isDev: !1, isStage: !1 })}${e}`, s = {
25
- method: t,
24
+ const r = `${t || C({ isDev: !1, isStage: !1 })}${e}`, n = {
25
+ method: o,
26
26
  headers: {
27
27
  "Content-Type": "application/json",
28
- ...n
28
+ ...s
29
29
  }
30
30
  };
31
- g && (s.body = JSON.stringify(g));
32
- const c = l ? new URLSearchParams(l).toString() : "", i = c ? `?${c}` : "", d = await fetch(`${r}${i}`, s);
33
- if (!d.ok)
34
- throw new Error(`HTTP error! status: ${d.status}`);
35
- return d.json();
31
+ g && (n.body = JSON.stringify(g));
32
+ const c = u ? new URLSearchParams(u).toString() : "", i = c ? `?${c}` : "", p = await fetch(`${r}${i}`, n);
33
+ if (!p.ok)
34
+ throw new Error(`HTTP error! status: ${p.status}`);
35
+ return p.json();
36
36
  }
37
- var L = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(L || {}), _ = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(_ || {}), f = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(f || {});
38
- const k = {
39
- [L.free]: 0,
40
- [L.startup]: 10,
41
- [L.business]: 20,
42
- [L.enterprise]: 30
37
+ var v = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(v || {}), D = /* @__PURE__ */ ((e) => (e.Info = "info", e.Error = "error", e.Success = "success", e.Warning = "warning", e))(D || {}), L = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.projectFiles = "studio:projectFiles", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(L || {});
38
+ const O = {
39
+ [v.free]: 0,
40
+ [v.startup]: 10,
41
+ [v.business]: 20,
42
+ [v.enterprise]: 30
43
43
  };
44
- function m(e) {
45
- const o = e;
46
- return o.init = (t) => (n) => e(n, t), o;
44
+ function S(e) {
45
+ const t = e;
46
+ return t.init = (o) => (s) => e(s, o), t;
47
47
  }
48
- const K = (e) => /* @__PURE__ */ m(e);
49
- async function S({
48
+ const V = (e) => /* @__PURE__ */ S(e);
49
+ async function Y({
50
50
  editor: e,
51
- plan: o,
52
- pluginName: t,
53
- licenseKey: n,
54
- cleanup: l
51
+ plan: t,
52
+ pluginName: o,
53
+ licenseKey: s,
54
+ cleanup: u
55
55
  }) {
56
- let g = "", u = !1;
57
- const r = F(), s = (i) => {
58
- console.warn("Cleanup plugin:", t, "Reason:", i), l();
56
+ let g = "", a = !1;
57
+ const r = W(), n = (i) => {
58
+ console.warn("Cleanup plugin:", o, "Reason:", i), u();
59
59
  }, c = (i = {}) => {
60
60
  var y;
61
- const { error: d, sdkLicense: h } = i, a = (y = i.plan) == null ? void 0 : y.category;
62
- if (!(h || i.license) || d)
63
- s(d || "Invalid license");
64
- else if (a) {
65
- const b = k[o], v = k[a];
66
- b > v && s({ pluginRequiredPlan: o, licensePlan: a });
61
+ const { error: p, sdkLicense: h } = i, l = (y = i.plan) == null ? void 0 : y.category;
62
+ if (!(h || i.license) || p)
63
+ n(p || "Invalid license");
64
+ else if (l) {
65
+ const b = O[t], d = O[l];
66
+ b > d && n({ pluginRequiredPlan: t, licensePlan: l });
67
67
  }
68
68
  };
69
- e.on(j, (i) => {
70
- g = i == null ? void 0 : i.baseApiUrl, u = !0;
69
+ e.on(B, (i) => {
70
+ g = i == null ? void 0 : i.baseApiUrl, a = !0;
71
71
  }), e.on(H, (i) => {
72
72
  c(i);
73
73
  }), setTimeout(async () => {
74
- if (!u) {
74
+ if (!a) {
75
75
  if (r) return;
76
- if (n) {
77
- const i = await V({ licenseKey: n, pluginName: t, baseApiUrl: g });
76
+ if (s) {
77
+ const i = await z({ licenseKey: s, pluginName: o, baseApiUrl: g });
78
78
  i && c(i);
79
79
  } else
80
- s("The `licenseKey` option not provided");
80
+ n("The `licenseKey` option not provided");
81
81
  }
82
82
  }, 2e3);
83
83
  }
84
- async function V(e) {
85
- const { licenseKey: o, pluginName: t, baseApiUrl: n } = e;
84
+ async function z(e) {
85
+ const { licenseKey: t, pluginName: o, baseApiUrl: s } = e;
86
86
  try {
87
- return (await W({
88
- baseApiUrl: n,
89
- path: `/sdk/${o || "na"}`,
87
+ return (await K({
88
+ baseApiUrl: s,
89
+ path: `/sdk/${t || "na"}`,
90
90
  method: "POST",
91
91
  params: {
92
92
  d: window.location.hostname,
93
- pn: t
93
+ pn: o
94
94
  }
95
95
  })).result || {};
96
- } catch (l) {
97
- return console.error("Error during SDK license check:", l), !1;
96
+ } catch (u) {
97
+ return console.error("Error during SDK license check:", u), !1;
98
98
  }
99
99
  }
100
- const Y = (e, o) => {
101
- var t;
102
- return !!((t = e == null ? void 0 : e.hasAttribute) != null && t.call(e, o));
103
- }, z = "iconifyComponent", q = L.startup, J = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, w = `<svg viewBox="0 0 24 24">
100
+ const q = (e, t) => {
101
+ var o;
102
+ return !!((o = e == null ? void 0 : e.hasAttribute) != null && o.call(e, t));
103
+ }, J = "iconifyComponent", m = v.startup, X = { ratioDefault: !0, tc: !1, cl: !1, cr: !1, bc: !1 }, I = `<svg viewBox="0 0 24 24">
104
104
  <path d="M19 0H9C7.9 0 7 .9 7 2V18C7 19.1 7.9 20 9 20H19C20.1 20 21 19.1 21 18V2C21 .9 20.1 0 19 0M19 18H9V2H19V18M3 4V22C3 23.1 3.9 24 5 24H17V22H5V4H3M14 5L11 10L14 15L17 10L14 5Z" />
105
- </svg>`, $ = "layout-icon-picker", X = "icons-layout-", D = "icons-list-layout", M = "gs-iconify-picker", A = "__iconify_collection", Z = "https://api.iconify.design", I = /* @__PURE__ */ new Map();
105
+ </svg>`, $ = "layout-icon-picker", Z = "icons-layout-", U = "icons-list-layout", M = "gs-iconify-picker", P = "__iconify_collection", Q = "https://api.iconify.design", E = /* @__PURE__ */ new Map();
106
106
  let T;
107
- const Q = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
108
- async function N({ collectionId: e, editor: o }) {
107
+ const ee = ({ collectionId: e }) => `https://cdn.jsdelivr.net/npm/@iconify-json/${e}@latest/icons.json`;
108
+ async function N({ collectionId: e, editor: t }) {
109
109
  try {
110
- if (I.has(e)) return I.get(e);
111
- const t = await fetch(Q({ collectionId: e }));
112
- if (!t.ok) throw new Error(`Failed to fetch collection: ${t.statusText}`);
113
- const n = await t.json();
114
- return I.set(e, n), n;
115
- } catch (t) {
116
- console.error("Error fetching collection", t), o.runCommand(f.toastAdd, re());
110
+ if (E.has(e)) return E.get(e);
111
+ const o = await fetch(ee({ collectionId: e }));
112
+ if (!o.ok) throw new Error(`Failed to fetch collection: ${o.statusText}`);
113
+ const s = await o.json();
114
+ return E.set(e, s), s;
115
+ } catch (o) {
116
+ console.error("Error fetching collection", o), t.runCommand(L.toastAdd, ce());
117
117
  return;
118
118
  }
119
119
  }
120
- async function ee({ collectionIds: e, editor: o }) {
120
+ async function te({ collectionIds: e, editor: t }) {
121
121
  try {
122
122
  if (T) return T;
123
- const t = e ? `?prefixes=${e.join(",")}` : "", n = await fetch(`${Z}/collections${t}`);
124
- if (!n.ok) throw new Error(`Failed to fetch collections: ${n.statusText}`);
125
- return T = await n.json(), T;
126
- } catch (t) {
127
- console.error("Error fetching collections", t), o.runCommand(f.toastAdd, U());
123
+ const o = e ? `?prefixes=${e.join(",")}` : "", s = await fetch(`${Q}/collections${o}`);
124
+ if (!s.ok) throw new Error(`Failed to fetch collections: ${s.statusText}`);
125
+ return T = await s.json(), T;
126
+ } catch (o) {
127
+ console.error("Error fetching collections", o), t.runCommand(L.toastAdd, j());
128
128
  return;
129
129
  }
130
130
  }
131
- function O() {
131
+ function x() {
132
132
  return {
133
133
  type: "button",
134
134
  label: "Open Icon Picker",
135
135
  name: "onActive",
136
136
  changeProp: !0,
137
137
  command(e) {
138
- var o;
139
- (o = e.getSelected()) == null || o.trigger("active");
138
+ var t;
139
+ (t = e.getSelected()) == null || t.trigger("active");
140
140
  }
141
141
  };
142
142
  }
143
- async function te({ collectionIds: e, editor: o, component: t }) {
144
- const n = await ee({ collectionIds: e, editor: o });
145
- if (!n) return;
146
- const l = ({ icon: s, collectionId: c, iconId: i }) => {
147
- t.components(s), t.set({ collectionId: c, iconId: i });
148
- }, g = Object.entries(n).map(([s, c]) => ({ id: s, ...c })).sort((s, c) => s.name.localeCompare(c.name)), u = t.get("collectionId") ?? g[0].id;
149
- o.runCommand(f.layoutToggle, {
143
+ async function oe({ collectionIds: e, editor: t, component: o }) {
144
+ const s = await te({ collectionIds: e, editor: t });
145
+ if (!s) return;
146
+ const u = ({ icon: n, collectionId: c, iconId: i }) => {
147
+ o.components(n), o.set({ collectionId: c, iconId: i });
148
+ }, g = Object.entries(s).map(([n, c]) => ({ id: n, ...c })).sort((n, c) => n.name.localeCompare(c.name)), a = o.get("collectionId") ?? g[0].id;
149
+ t.runCommand(L.layoutToggle, {
150
150
  id: $,
151
151
  placer: { type: "dialog", size: "l", title: "Select Icon" },
152
152
  header: !1,
@@ -156,40 +156,40 @@ async function te({ collectionIds: e, editor: o, component: t }) {
156
156
  children: [
157
157
  se({
158
158
  collectionsList: g,
159
- collectionId: u,
160
- editor: o,
161
- handleClick: l
159
+ collectionId: a,
160
+ editor: t,
161
+ handleClick: u
162
162
  }),
163
- { id: D, type: "column", grow: !0 }
163
+ { id: U, type: "column", grow: !0 }
164
164
  ]
165
165
  }
166
166
  });
167
- const r = await N({ collectionId: u, editor: o });
168
- r && E({
169
- editor: o,
167
+ const r = await N({ collectionId: a, editor: t });
168
+ r && (G({ editor: t, collection: r }), A({
169
+ editor: t,
170
170
  collection: r,
171
- handleClick: l,
172
- collectionId: u
173
- });
171
+ handleClick: u,
172
+ collectionId: a
173
+ }));
174
174
  }
175
- function oe({ editor: e, collection: o }) {
176
- e.em.set(A, o);
175
+ function G({ editor: e, collection: t }) {
176
+ e.em.set(P, t);
177
177
  }
178
178
  function ne(e) {
179
- return e.em.get(A);
179
+ return e.em.get(P);
180
180
  }
181
- function E(e) {
182
- const { editor: o } = e, t = {
183
- id: X,
181
+ function A(e) {
182
+ const { editor: t } = e;
183
+ t.runCommand(L.layoutUpdate, {
184
+ id: Z,
184
185
  layout: ie(e),
185
186
  header: !1,
186
187
  style: { height: "100%" },
187
- placer: { type: "static", layoutId: D }
188
- };
189
- o.runCommand(f.layoutRemove, { id: t.id, force: !0 }), setTimeout(() => o.runCommand(f.layoutAdd, t), 10);
188
+ placer: { type: "static", layoutId: U }
189
+ });
190
190
  }
191
191
  function se(e) {
192
- const { collectionsList: o, collectionId: t, editor: n, handleClick: l } = e, g = o.map(({ id: u, name: r, total: s }) => ({ id: u, label: `${r} (${s})` })).sort((u, r) => u.label.localeCompare(r.label));
192
+ const { collectionsList: t, collectionId: o, editor: s, handleClick: u } = e, g = t.map(({ id: a, name: r, total: n }) => ({ id: a, label: `${r} (${n})` })).sort((a, r) => a.label.localeCompare(r.label));
193
193
  return {
194
194
  type: "column",
195
195
  style: { gap: 10 },
@@ -197,15 +197,15 @@ function se(e) {
197
197
  children: [
198
198
  {
199
199
  type: "selectField",
200
- value: t,
200
+ value: o,
201
201
  options: g,
202
202
  emptyState: "Select an icon collection",
203
- onChange: async ({ setState: u, value: r }) => {
204
- const s = await N({ collectionId: r, editor: n });
205
- s && (u({ value: r }), oe({ editor: n, collection: s }), E({
206
- editor: n,
207
- collection: s,
208
- handleClick: l,
203
+ onChange: async ({ setState: a, value: r }) => {
204
+ const n = await N({ collectionId: r, editor: s });
205
+ n && (a({ value: r }), G({ editor: s, collection: n }), A({
206
+ editor: s,
207
+ collection: n,
208
+ handleClick: u,
209
209
  collectionId: r
210
210
  }));
211
211
  }
@@ -215,19 +215,19 @@ function se(e) {
215
215
  value: "",
216
216
  placeholder: "Search icons inside collection...",
217
217
  editorEvents: {
218
- [`change:${A}`]: ({ setState: u }) => u({ value: "" })
218
+ [`change:${P}`]: ({ setState: a }) => a({ value: "" })
219
219
  },
220
- onInput: ({ setState: u, value: r, editor: s }) => {
221
- const c = ne(s);
220
+ onInput: ({ setState: a, value: r, editor: n }) => {
221
+ const c = ne(n);
222
222
  if (!c) return;
223
223
  const i = Object.fromEntries(
224
- Object.entries(c.icons).filter(([d]) => d.includes(r))
224
+ Object.entries(c.icons).filter(([p]) => p.includes(r))
225
225
  );
226
- u({ value: r }), E({
227
- editor: s,
226
+ a({ value: r }), A({
227
+ editor: n,
228
228
  collection: c,
229
- handleClick: l,
230
- collectionId: r,
229
+ handleClick: u,
230
+ collectionId: o,
231
231
  collectionFiltered: { ...c, icons: i }
232
232
  });
233
233
  }
@@ -237,10 +237,10 @@ function se(e) {
237
237
  }
238
238
  function ie({
239
239
  collection: e,
240
- collectionFiltered: o,
241
- handleClick: t
240
+ collectionFiltered: t,
241
+ handleClick: o
242
242
  }) {
243
- const { height: n = 24, width: l = 24, icons: g, prefix: u } = o || e, r = Object.entries(g).map(([s, { body: c }]) => ({ name: s, body: c }), {});
243
+ const { height: s = 24, width: u = 24, icons: g, prefix: a } = t || e, r = Object.entries(g).map(([n, c]) => ({ name: n, ...c }), {});
244
244
  return {
245
245
  type: "column",
246
246
  className: `${M}__content`,
@@ -248,113 +248,119 @@ function ie({
248
248
  children: {
249
249
  type: "virtualList",
250
250
  items: r,
251
- itemLayout: ({ item: s }) => [
252
- {
253
- type: "custom",
254
- render: (c) => {
255
- const { editor: i, addEl: d, removeEl: h } = c, a = document.createElementNS("http://www.w3.org/2000/svg", "svg");
256
- a.setAttribute("xmlns", "http://www.w3.org/2000/svg"), a.innerHTML = s.body, a.setAttribute("viewBox", `0 0 ${l} ${n}`);
257
- const { cssWidth: p, cssHeight: y } = ce(l, n);
258
- a.style.cssText = `width: ${p}px; height: ${y}px; cursor: pointer;`, a.addEventListener("mouseover", () => {
259
- a.style.border = "2px solid currentColor", a.style.borderRadius = "4px", a.style.padding = "4px";
260
- }), a.addEventListener("mouseout", () => {
261
- a.style.border = "none";
262
- });
263
- const b = () => {
264
- const v = a.cloneNode(!0);
265
- v.removeAttribute("style");
266
- const G = v.outerHTML;
267
- t({ icon: G, collectionId: u, iconId: s.name }), i == null || i.runCommand(f.layoutRemove, { id: $ });
268
- };
269
- return a.addEventListener("click", b), d(a), () => {
270
- a.removeEventListener("click", b), h(a);
271
- };
272
- }
251
+ itemLayout: ({ item: n }) => ({
252
+ type: "custom",
253
+ render: (c) => {
254
+ const { editor: i, addEl: p, removeEl: h } = c, l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
255
+ l.setAttribute("xmlns", "http://www.w3.org/2000/svg"), l.innerHTML = n.body;
256
+ const f = n.width || u, y = n.height || s;
257
+ l.setAttribute("viewBox", `0 0 ${f} ${y}`), l.style.cssText = "width: 48px; height: 48px; cursor: pointer; border-radius: 4px; transition: padding 0.1s ease-in-out;";
258
+ const b = [
259
+ [
260
+ "click",
261
+ () => {
262
+ const d = l.cloneNode(!0);
263
+ d.removeAttribute("style");
264
+ const w = d.outerHTML;
265
+ o({ icon: w, collectionId: a, iconId: n.name }), i == null || i.runCommand(L.layoutRemove, { id: $ });
266
+ }
267
+ ],
268
+ [
269
+ "pointerover",
270
+ () => {
271
+ l.style.border = "2px solid currentColor", l.style.padding = "4px";
272
+ }
273
+ ],
274
+ [
275
+ "pointerout",
276
+ () => {
277
+ l.style.border = "", l.style.padding = "";
278
+ }
279
+ ]
280
+ ];
281
+ return b.forEach(([d, w]) => l.addEventListener(d, w)), p(l), () => {
282
+ b.forEach(([d, w]) => l.removeEventListener(d, w)), h(l);
283
+ };
273
284
  }
274
- ]
285
+ })
275
286
  }
276
287
  };
277
288
  }
278
- function ce(e, o) {
279
- const t = e / o;
280
- let n = 48, l = 48;
281
- return t > 1 ? l = 48 / t : t < 1 && (n = 48 * t), { cssWidth: n, cssHeight: l };
282
- }
283
- function U() {
289
+ function j() {
284
290
  return {
285
291
  id: "toast-error-getCollections",
286
292
  header: "Error",
287
293
  content: "Error fetching collections",
288
- variant: _.Error
294
+ variant: D.Error
289
295
  };
290
296
  }
291
- function re() {
297
+ function ce() {
292
298
  return {
293
- ...U(),
299
+ ...j(),
294
300
  id: "toast-error-getCollection",
295
301
  content: "Error fetching collection"
296
302
  };
297
303
  }
298
- const ae = function(e, o = {}) {
299
- var a;
300
- const { Components: t, Blocks: n } = e, { collections: l, extendIconComponent: g = !0, licenseKey: u, block: r = {} } = o, s = "icon", c = "iconify", i = "Iconify", d = "data-type-iconify", h = {
304
+ const re = function(e, t = {}) {
305
+ var l;
306
+ const { Components: o, Blocks: s } = e, { collections: u, extendIconComponent: g = !0, licenseKey: a, block: r = {} } = t, n = "icon", c = "iconify", i = "Iconify", p = "data-type-iconify", h = {
301
307
  events: () => ({
302
308
  dblclick: "onActive"
303
309
  }),
304
310
  onActive() {
305
- te({ collectionIds: l, editor: e, component: this.model });
311
+ oe({ collectionIds: u, editor: e, component: this.model });
306
312
  }
307
313
  };
308
- if (t.addType(c, {
314
+ if (o.addType(c, {
309
315
  block: r && {
310
316
  label: i,
311
- media: w,
317
+ media: I,
312
318
  content: { type: c },
313
319
  category: "Extra",
314
320
  activate: !0,
315
321
  ...r
316
322
  },
317
- isComponent: (p) => Y(p, d),
323
+ isComponent: (f) => q(f, p),
318
324
  model: {
319
325
  defaults: {
320
326
  name: i,
321
- icon: w,
327
+ icon: I,
322
328
  droppable: !1,
323
- attributes: { [d]: !0 },
324
- resizable: J,
325
- components: w,
329
+ attributes: { [p]: !0 },
330
+ resizable: X,
331
+ components: I,
326
332
  style: { width: "50px", height: "50px" },
327
- traits: [O()]
333
+ traits: [x()]
328
334
  },
329
335
  init() {
330
336
  this.listenTo(this.components(), "change add", this.disableLayers), this.disableLayers();
331
337
  },
332
338
  disableLayers() {
333
- this.components().forEach((p) => p.set({ layerable: !1, locked: !0 }));
339
+ this.components().forEach((f) => f.set({ layerable: !1, locked: !0 }));
334
340
  }
335
341
  },
336
342
  view: h
337
343
  }), g) {
338
- const p = (a = t.getType(s)) == null ? void 0 : a.model, [y, b, ...v] = p.getDefaults().traits;
339
- t.addType(s, {
344
+ const f = (l = o.getType(n)) == null ? void 0 : l.model, [y, b, ...d] = f.getDefaults().traits;
345
+ o.addType(n, {
340
346
  model: {
341
347
  defaults: {
342
- traits: [y, b, O(), ...v]
348
+ traits: [y, b, x(), ...d]
343
349
  }
344
350
  },
345
351
  view: h
346
352
  });
347
353
  }
348
- S({
354
+ Y({
349
355
  editor: e,
350
- licenseKey: u,
351
- plan: q,
352
- pluginName: z,
356
+ licenseKey: a,
357
+ plan: m,
358
+ pluginName: J,
353
359
  cleanup: () => {
354
- n.remove(c), t.removeType(c);
360
+ s.remove(c), o.removeType(c);
355
361
  }
356
362
  });
357
- }, le = K(ae);
363
+ }, ae = V(re);
358
364
  export {
359
- le as default
365
+ ae as default
360
366
  };