@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
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.
- package/dist/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(P,k){typeof exports=="object"&&typeof module<"u"?module.exports=k():typeof define=="function"&&define.amd?define(k):(P=typeof globalThis<"u"?globalThis:P||self,P.StudioSdkPlugins_lightGalleryComponent=k())})(this,function(){"use strict";const P="app.grapesjs.com",k="app-stage.grapesjs.com",X=[P,"app2.grapesjs.com",k,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],pe="license:check:start",ue="license:check:end",he=()=>typeof window<"u",ge=({isDev:e,isStage:n,isPlatform:t})=>`${e?"":`https://${n?k:P}`}/${t?"platform-api":"api"}`,be=()=>{const e=he()&&window.location.hostname;return!!e&&(X.includes(e)||X.some(n=>e.endsWith(n)))};async function de({path:e,baseApiUrl:n,method:t="GET",headers:l={},params:o,body:u}){const p=`${n||ge({isDev:!1,isStage:!1})}${e}`,h={method:t,headers:{"Content-Type":"application/json",...l}};u&&(h.body=JSON.stringify(u));const c=o?new URLSearchParams(o).toString():"",b=c?`?${c}`:"",s=await fetch(`${p}${b}`,h);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var L=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(L||{});const Y={[L.free]:0,[L.startup]:10,[L.business]:20,[L.enterprise]:30};function me(e){const n=e;return n.init=t=>l=>e(l,t),n}const ye=e=>me(e);async function fe({editor:e,plan:n,pluginName:t,licenseKey:l,onLicenseCheckResponse:o,cleanup:u}){let r="",p=!1;const h=be(),c=s=>{console.warn("Cleanup plugin:",t,"Reason:",s),u()},b=(s={})=>{var V;const{error:O,sdkLicense:C}=s,S=(V=s.plan)==null?void 0:V.category;if(!(C||s.license)||O)c(O||"Invalid license");else if(S){const M=Y[n],H=Y[S];M>H&&c({pluginRequiredPlan:n,licensePlan:S})}};e.on(pe,s=>{r=s==null?void 0:s.baseApiUrl,p=!0}),e.on(ue,s=>{o==null||o(s),b(s)}),setTimeout(async()=>{if(!p){if(h)return;if(l){const s=await ve({licenseKey:l,pluginName:t,baseApiUrl:r});o==null||o(s),s&&b(s)}else c("The `licenseKey` option not provided")}},2e3)}async function ve(e){const{licenseKey:n,pluginName:t,baseApiUrl:l}=e;try{return(await de({baseApiUrl:l,path:`/sdk/${n||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const W=(e,n)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,n))},Te="lightGalleryComponent",we=L.startup;var E=(e=>(e.image="image",e.video="video",e.external="external",e))(E||{});const T="lightGallery",ee=`${T}-item`,$="data-lightgallery",te=`${$}-item`,N="toggle",w={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Z={propKeys:[],props:{},traits:[]},_=(e,n={})=>{var o;const t={},l=[];for(const u in e){const{value:r,...p}=e[u];l.push({id:u,name:u,changeProp:!0,category:n.category,...p}),t[u]=r;const{subTraits:h={}}=p;for(const c in p.subTraits)(o=h[c])==null||o.forEach(b=>{const s=b.id||b.name;t[s]=b.value})}return{propKeys:Object.keys(t),props:t,traits:l}},F=(e,n)=>{const t=e.getTrait(n),l=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);e.removeTrait(r);const p=o[t.getValue()],h=e.getTraitIndex(n)+1;p&&e.addTrait(p.map(c=>({category:l,...c})),{at:h})},q=(e,n)=>{n.forEach(t=>{const l=e.getTrait(t);if(!l||!l.get("subTraits"))return;const o=l.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(o,()=>F(e,t)),F(e,t)})},Se=(e,n,t)=>{const o=e.getTrait(n).get("subTraits")||{},r=(Object.values(o).flat()||[]).map(h=>{const c=h.name||h.id;return h.changeProp?`change:${c}`:`change:attributes:${c}`}),p=Array.from(new Set(r));p.length&&e.on(p.join(" "),t)},xe={[N]:{type:"button",label:"Toggle Gallery",command:(e,n)=>{var t,l;return(l=(t=n.target)==null?void 0:t.getView())==null?void 0:l.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Ae={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Ie={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Pe={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},m="sourceType",j="data-iframe",R={name:"href",type:"file",label:"Image Source"},K={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},J={name:"data-poster",label:"Video Poster",type:"file"},ae={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},le={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},ke={[N]:{type:"button",label:"Toggle Gallery",command:(e,n)=>{var o,u;const t=n.target,l=(o=t==null?void 0:t.closestType(T))==null?void 0:o.getView();if(l&&t){const r=((u=l.getLightGallery())==null?void 0:u.items)||[],p=Array.from(r).indexOf(t.getEl());p>=0&&l.toggleGallery(p)}}},[m]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[R],video:[K,J],external:[ae]},options:[{id:"image",label:R.label||"",icon:w.image},{id:"video",label:K.label||"",icon:w.video},{id:"external",label:ae.label||"",icon:w.external}]},subHtml:le},ne="lgThumbnail",Le="lgVideo",oe="lgAutoplay",ie="lgZoom",G="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2";return ye(function(e,n={}){const{Blocks:t,Components:l}=e,o="LightGallery",u="LightGallery Item",r={toolbarIconOpen:w.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ne,Le,oe,ie],cdnScript:[`${G}/lightgallery.min.js`,`${G}/plugins/thumbnail/lg-thumbnail.min.js`,`${G}/plugins/video/lg-video.min.js`,`${G}/plugins/autoplay/lg-autoplay.min.js`,`${G}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${G}/css/lightgallery-bundle.min.css`,...n},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,b=function(a){const i=this,g=window,{plugins:y,cdnScript:x,cdnStyle:D,inline:se,lgLicenseKey:Ee,...f}=a||{},A=d=>isNaN(d)?void 0:parseInt(d,10),re=()=>{var z;const d={...f,licenseKey:Ee,speed:A(f.speed),startAnimationDuration:A(f.startAnimationDuration),thumbMargin:A(f.thumbMargin),thumbWidth:A(f.thumbWidth),slideShowInterval:A(f.slideShowInterval),scale:A(f.scale),enableZoomAfter:A(f.enableZoomAfter),plugins:(y||[]).map(B=>g[B])};se&&(d.container=i,d.closable=!1);const Q=(z=g.lightGallery)==null?void 0:z.call(g,i,d);se&&Q.openGallery()};if(g.lightGallery)re();else{const{head:d}=document,Q=Array.isArray(x)?[...x]:[x],z=Array.isArray(D)?[...D]:[D],B=I=>{if(I.length){const v=document.createElement("link");v.href=I.shift(),v.rel="stylesheet",d.appendChild(v),B(I)}},ce=I=>{if(I.length){const v=document.createElement("script");v.src=I.shift(),v.onerror=v.onload=ce.bind(null,I),d.appendChild(v)}else re()};B(z),ce(Q)}},s=a=>{const i=a.getTrait(N);if(!h||!i)return;const{toolbar:g}=a,y={id:N,label:h,command:()=>setTimeout(()=>i.runCommand(),100)};!g.find(D=>D.id===y.id)&&(g==null||g.unshift(y))};let O=[];const C=r.plugins||[],S=_(xe),U=C.includes(ne)?_(Ae):Z,V=C.includes(oe)?_(Ie):Z,M=C.includes(ie)?_(Pe):Z;l.addType(T,{block:p&&{label:o,media:w.gallery,category:"Extra",select:!0,...r.block},isComponent:a=>W(a,$),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:w.gallery,draggable:(a,i)=>!i.is(T),attributes:{[$]:!0},components:{type:ee},script:b,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...S.propKeys,...U.propKeys,...V.propKeys,...M.propKeys],...S.props,...U.props,...V.props,...M.props,traits:[...S.traits,...U.traits,...V.traits,...M.traits]},init(){q(this,["thumbnail"]),q(this,["autoplay"]),q(this,["zoom"])},initToolbar(){s(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,l.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var i;const a=this.getLightGallery();return((i=a==null?void 0:a.settings)==null?void 0:i.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:i}=a,g=this.getLightGallery();O=i.getSpots(),setTimeout(()=>i.removeSpots()),g.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();O.forEach(i=>this.em.Canvas.addSpot(i.attributes)),O=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const i=this.getLightGallery();if(i.__lgOpened)return i.closeGallery(!0);i.lgOpened=!1,i.openGallery(a)}}});const H=_(ke);l.addType(ee,{isComponent:a=>W(a,te)||a.tagName==="A"&&W(a.parentElement,$),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:w.galleryItem,attributes:{[te]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...H.props,traits:[...H.traits]},init(){const a=[m].map(i=>`change:${i}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Se(this,m,this.triggerGalleryUpdate)},initToolbar(){s(this)},initScriptUpdate(){const a=[le.name].map(i=>`change:attributes:${i}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var i;(i=this.closestType(T))==null||i.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:i}=this,{init:g}=a;if(i[m]||g){F(this,m);const y=this.getTrait(m).getValue();if(y===E.image){this.removeAttributes([K.name,J.name,j]);const x=this.getTrait(R.name);x.setValue(x.getValue()||c)}else y===E.video?this.removeAttributes([j]):y===E.external&&this.addAttributes({[j]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[j]?this.set(m,E.external):(a[K.name]||a[J.name])&&this.set(m,E.video)}}}),fe({editor:e,plan:we,licenseKey:r.licenseKey,pluginName:Te,cleanup:()=>{t.remove(T),l.removeType(T)}})})});
|
|
1
|
+
(function(L,G){typeof exports=="object"&&typeof module<"u"?module.exports=G():typeof define=="function"&&define.amd?define(G):(L=typeof globalThis<"u"?globalThis:L||self,L.StudioSdkPlugins_lightGalleryComponent=G())})(this,function(){"use strict";const L="app.grapesjs.com",G="app-stage.grapesjs.com",Y=[L,"app2.grapesjs.com",G,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ue="license:check:end",ge=()=>typeof window<"u",he=({isDev:e,isStage:l,isPlatform:t})=>`${e?"":`https://${l?G:L}`}/${t?"platform-api":"api"}`,be=()=>{const e=ge()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(l=>e.endsWith(l)))};async function de({path:e,baseApiUrl:l,method:t="GET",headers:o={},params:i,body:g}){const n=`${l||he({isDev:!1,isStage:!1})}${e}`,u={method:t,headers:{"Content-Type":"application/json",...o}};g&&(u.body=JSON.stringify(g));const p=i?new URLSearchParams(i).toString():"",b=p?`?${p}`:"",r=await fetch(`${n}${b}`,u);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var k=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(k||{}),F=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",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.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",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 ee={[k.free]:0,[k.startup]:10,[k.business]:20,[k.enterprise]:30};function ye(e){const l=e;return l.init=t=>o=>e(o,t),l}const me=e=>ye(e);async function fe({editor:e,plan:l,pluginName:t,licenseKey:o,onLicenseCheckResponse:i,cleanup:g}){let c="",n;const u=r=>{console.warn("Cleanup plugin:",t,"Reason:",r),g()},p=(r={})=>{var M;const{error:O,sdkLicense:V}=r,x=(M=r.plan)==null?void 0:M.category;if(!(V||r.license)||O)u(O||"Invalid license");else if(x){const R=ee[l],K=ee[x];R>K&&u({pluginRequiredPlan:l,licensePlan:x})}};e.Commands.has(F.settings)&&(n=e.runCommand(F.settings),c=(n==null?void 0:n.baseUrl)||"");const b=r=>{i==null||i(r),r&&p(r)};if(!n){e.onReady(async()=>{if(!be())if(o){const r=await Te({licenseKey:o,pluginName:t,baseApiUrl:c});b(r)}else u("The `licenseKey` option not provided")});return}if(n.licensePlan||n.licenseError){const r=ve(n);b(r);return}e.on(ue,r=>b(r))}const ve=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Te(e){const{licenseKey:l,pluginName:t,baseApiUrl:o}=e;try{return(await de({baseApiUrl:o,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const W=(e,l)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,l))},we="lightGalleryComponent",xe=k.startup;var S=(e=>(e.image="image",e.video="video",e.external="external",e))(S||{});const T="lightGallery",te=`${T}-item`,B="data-lightgallery",ae=`${B}-item`,$="toggle",w={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Z={propKeys:[],props:{},traits:[]},D=(e,l={})=>{var i;const t={},o=[];for(const g in e){const{value:c,...n}=e[g];o.push({id:g,name:g,changeProp:!0,category:l.category,...n}),t[g]=c;const{subTraits:u={}}=n;for(const p in n.subTraits)(i=u[p])==null||i.forEach(b=>{const r=b.id||b.name;t[r]=b.value})}return{propKeys:Object.keys(t),props:t,traits:o}},q=(e,l)=>{const t=e.getTrait(l),o=t.get("category"),i=t.get("subTraits")||{},c=(Object.values(i).flat()||[]).map(p=>p.id||p.name);e.removeTrait(c);const n=i[t.getValue()],u=e.getTraitIndex(l)+1;n&&e.addTrait(n.map(p=>({category:o,...p})),{at:u})},C=(e,l)=>{l.forEach(t=>{const o=e.getTrait(t);if(!o||!o.get("subTraits"))return;const i=o.changeProp?`change:${t}`:`change:attributes:${t}`;e.on(i,()=>q(e,t)),q(e,t)})},Pe=(e,l,t)=>{const i=e.getTrait(l).get("subTraits")||{},c=(Object.values(i).flat()||[]).map(u=>{const p=u.name||u.id;return u.changeProp?`change:${p}`:`change:attributes:${p}`}),n=Array.from(new Set(c));n.length&&e.on(n.join(" "),t)},Ae={[$]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var t,o;return(o=(t=l.target)==null?void 0:t.getView())==null?void 0:o.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:e})=>!!e.getTrait("closable").getValue(),value:!0}},Ie={thumbnail:{category:{id:"thumbnail-options",label:"Thumbnail Options"},type:"checkbox",label:"Thumbnails",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"enableThumbDrag",label:"Thumbnail drag",tip:"Enable thumbnail drag on desktop",changeProp:!0,value:!0},{type:"checkbox",name:"enableThumbSwipe",label:"Thumbnail swipe",tip:"Enable thumbnail swipe on mobile devices",changeProp:!0,value:!0},{type:"select",name:"alignThumbnails",tip:"Position of thumbnails when the width of all thumbnails combined is less than the gallery's width",label:"Align Thumbnails",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"select",name:"currentPagerPosition",label:"Select thumbnail position",value:"middle",changeProp:!0,options:[{id:"left",label:"Left"},{id:"middle",label:"Middle"},{id:"right",label:"Right"}]},{type:"number",name:"thumbMargin",label:"Thumb margin",tip:"Spacing between each thumbnails",changeProp:!0,min:0,value:"5"},{type:"number",name:"thumbWidth",label:"Thumb width",tip:"Width of each thumbnails",changeProp:!0,min:0,value:"100"}]}}},Le={autoplay:{category:{id:"autoplay-options",label:"Autoplay options"},type:"checkbox",label:"Autoplay",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"autoplayControls",label:"Autoplay controls",tip:"Show/hide autoplay controls",changeProp:!0,value:!0},{type:"checkbox",name:"progressBar",label:"Progress bar",tip:"Show autoplay progress bar",changeProp:!0,value:!0},{type:"checkbox",name:"forceSlideShowAutoplay",label:"Force autoplay",tip:"If false, autoplay will be stopped after first user action",changeProp:!0,value:!1},{type:"checkbox",name:"slideShowAutoplay",label:"Start autoplay",tip:"Enable autoplay on start",changeProp:!0,value:!1},{type:"number",name:"slideShowInterval",label:"Interval",tip:"The time (in ms) between each auto transition",changeProp:!0,min:0,step:50,value:5e3}]}}},Ge={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},y="sourceType",N="data-iframe",J={name:"href",type:"file",label:"Image Source"},j={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Q={name:"data-poster",label:"Video Poster",type:"file"},oe={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},le={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},ke={[$]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var i,g;const t=l.target,o=(i=t==null?void 0:t.closestType(T))==null?void 0:i.getView();if(o&&t){const c=((g=o.getLightGallery())==null?void 0:g.items)||[],n=Array.from(c).indexOf(t.getEl());n>=0&&o.toggleGallery(n)}}},[y]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[J],video:[j,Q],external:[oe]},options:[{id:"image",label:J.label||"",icon:w.image},{id:"video",label:j.label||"",icon:w.video},{id:"external",label:oe.label||"",icon:w.external}]},subHtml:le},se="lgThumbnail",Se="lgVideo",ie="lgAutoplay",ne="lgZoom",E="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2";return me(function(e,l={}){const{Blocks:t,Components:o}=e,i="LightGallery",g="LightGallery Item",c={toolbarIconOpen:w.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[se,Se,ie,ne],cdnScript:[`${E}/lightgallery.min.js`,`${E}/plugins/thumbnail/lg-thumbnail.min.js`,`${E}/plugins/video/lg-video.min.js`,`${E}/plugins/autoplay/lg-autoplay.min.js`,`${E}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${E}/css/lightgallery-bundle.min.css`,...l},{block:n,toolbarIconOpen:u,defaultSrc:p}=c,b=function(a){const s=this,h=window,{plugins:m,cdnScript:P,cdnStyle:_,inline:re,lgLicenseKey:Ee,...f}=a||{},A=d=>isNaN(d)?void 0:parseInt(d,10),ce=()=>{var H;const d={...f,licenseKey:Ee,speed:A(f.speed),startAnimationDuration:A(f.startAnimationDuration),thumbMargin:A(f.thumbMargin),thumbWidth:A(f.thumbWidth),slideShowInterval:A(f.slideShowInterval),scale:A(f.scale),enableZoomAfter:A(f.enableZoomAfter),plugins:(m||[]).map(z=>h[z])};re&&(d.container=s,d.closable=!1);const X=(H=h.lightGallery)==null?void 0:H.call(h,s,d);re&&X.openGallery()};if(h.lightGallery)ce();else{const{head:d}=document,X=Array.isArray(P)?[...P]:[P],H=Array.isArray(_)?[..._]:[_],z=I=>{if(I.length){const v=document.createElement("link");v.href=I.shift(),v.rel="stylesheet",d.appendChild(v),z(I)}},pe=I=>{if(I.length){const v=document.createElement("script");v.src=I.shift(),v.onerror=v.onload=pe.bind(null,I),d.appendChild(v)}else ce()};z(H),pe(X)}},r=a=>{const s=a.getTrait($);if(!u||!s)return;const{toolbar:h}=a,m={id:$,label:u,command:()=>setTimeout(()=>s.runCommand(),100)};!h.find(_=>_.id===m.id)&&(h==null||h.unshift(m))};let O=[];const V=c.plugins||[],x=D(Ae),U=V.includes(se)?D(Ie):Z,M=V.includes(ie)?D(Le):Z,R=V.includes(ne)?D(Ge):Z;o.addType(T,{block:n&&{label:i,media:w.gallery,category:"Extra",select:!0,...c.block},isComponent:a=>W(a,B),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:w.gallery,draggable:(a,s)=>!s.is(T),attributes:{[B]:!0},components:{type:te},script:b,selector:"",exThumbImage:"",cdnScript:c.cdnScript,cdnStyle:c.cdnStyle,plugins:c.plugins,lgLicenseKey:c.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...x.propKeys,...U.propKeys,...M.propKeys,...R.propKeys],...x.props,...U.props,...M.props,...R.props,traits:[...x.traits,...U.traits,...M.traits,...R.traits]},init(){C(this,["thumbnail"]),C(this,["autoplay"]),C(this,["zoom"])},initToolbar(){r(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,o.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const a=this.getLightGallery();a==null||a.destroy()},disableLgInCanvas(){const a=this.getLightGallery();a.lgOpened=!0},isInlineGallery(){var s;const a=this.getLightGallery();return((s=a==null?void 0:a.settings)==null?void 0:s.container)===this.el},onLgInit(a){this.el.__lg=a.detail.instance,!this.isInlineGallery()&&this.disableLgInCanvas()},onLgOpen(){const{em:a}=this,{Canvas:s}=a,h=this.getLightGallery();O=s.getSpots(),setTimeout(()=>s.removeSpots()),h.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();O.forEach(s=>this.em.Canvas.addSpot(s.attributes)),O=[],a.__lgOpened=!1,setTimeout(()=>this.disableLgInCanvas())},toggleGallery(a){const s=this.getLightGallery();if(s.__lgOpened)return s.closeGallery(!0);s.lgOpened=!1,s.openGallery(a)}}});const K=D(ke);o.addType(te,{isComponent:a=>W(a,ae)||a.tagName==="A"&&W(a.parentElement,B),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:g,icon:w.galleryItem,attributes:{[ae]:!0,href:p},components:{type:"image",attributes:{alt:"Image",src:p}},...K.props,traits:[...K.traits]},init(){const a=[y].map(s=>`change:${s}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Pe(this,y,this.triggerGalleryUpdate)},initToolbar(){r(this)},initScriptUpdate(){const a=[le.name].map(s=>`change:attributes:${s}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var s;(s=this.closestType(T))==null||s.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:s}=this,{init:h}=a;if(s[y]||h){q(this,y);const m=this.getTrait(y).getValue();if(m===S.image){this.removeAttributes([j.name,Q.name,N]);const P=this.getTrait(J.name);P.setValue(P.getValue()||p)}else m===S.video?this.removeAttributes([N]):m===S.external&&this.addAttributes({[N]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[N]?this.set(y,S.external):(a[j.name]||a[Q.name])&&this.set(y,S.video)}}}),fe({editor:e,plan:xe,licenseKey:c.licenseKey,pluginName:we,cleanup:()=>{t.remove(T),o.removeType(T)}})})});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const w="app.grapesjs.com",D="app-stage.grapesjs.com",G="app2.grapesjs.com",k="app-stage2.grapesjs.com",P=[w,G,D,k,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],I="license:check:end",L=()=>typeof window<"u",x=({isDev:e,isStage:o,isPlatform:a})=>`${e?"":`https://${o?D:w}`}/${a?"platform-api":"api"}`,E=()=>{const e=L()&&window.location.hostname;return!!e&&(P.includes(e)||P.some(o=>e.endsWith(o)))};async function M({path:e,baseApiUrl:o,method:a="GET",headers:r={},params:i,body:g}){const n=`${o||x({isDev:!1,isStage:!1})}${e}`,c={method:a,headers:{"Content-Type":"application/json",...r}};g&&(c.body=JSON.stringify(g));const d=i?new URLSearchParams(i).toString():"",u=d?`?${d}`:"",s=await fetch(`${n}${u}`,c);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),T=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",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.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",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))(T||{});const A={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function N(e){const o=e;return o.init=a=>r=>e(r,a),o}const O=e=>N(e);async function B({editor:e,plan:o,pluginName:a,licenseKey:r,onLicenseCheckResponse:i,cleanup:g}){let p="",n;const c=s=>{console.warn("Cleanup plugin:",a,"Reason:",s),g()},d=(s={})=>{var y;const{error:f,sdkLicense:t}=s,l=(y=s.plan)==null?void 0:y.category;if(!(t||s.license)||f)c(f||"Invalid license");else if(l){const v=A[o],R=A[l];v>R&&c({pluginRequiredPlan:o,licensePlan:l})}};e.Commands.has(T.settings)&&(n=e.runCommand(T.settings),p=(n==null?void 0:n.baseUrl)||"");const u=s=>{i==null||i(s),s&&d(s)};if(!n){e.onReady(async()=>{if(!E())if(r){const s=await $({licenseKey:r,pluginName:a,baseApiUrl:p});u(s)}else c("The `licenseKey` option not provided")});return}if(n.licensePlan||n.licenseError){const s=U(n);u(s);return}e.on(I,s=>u(s))}const U=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function $(e){const{licenseKey:o,pluginName:a,baseApiUrl:r}=e;try{return(await M({baseApiUrl:r,path:`/sdk/${o||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const j="linkImageComponent",_=b.startup,F=function(e,o={}){const{Components:a,Blocks:r}=e,i="link-image",g="Link Image",p="link-image",{model:n,view:c}=e.Components.getType("image"),d=a.getType("link").model.getDefaults().traits,u=n.getDefaults().traits,s=d.filter(t=>t!=="title"),f=u.filter(t=>t.name!=="customAttributes").map(t=>typeof t=="string"?{name:t}:t).map(t=>({...t,getValue({component:l}){var h;return(h=l.components().at(0).getTrait(t.name))==null?void 0:h.getValue()},setValue({component:l,value:h,options:y}){var v;(v=l.components().at(0).getTrait(t.name))==null||v.setValue(h,y)}}));a.addType(i,{isComponent:t=>{var l;return t.tagName==="A"&&((l=t.children)==null?void 0:l.length)===1&&t.children[0].tagName==="IMG"},block:{label:g,media:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M2 6.3A2.3 2.3 0 0 1 4.3 4h15.4A2.3 2.3 0 0 1 22 6.3v7a4.7 4.7 0 0 0-2.8-.8h-3.4a4.8 4.8 0 0 0-4 7.5H4.3A2.3 2.3 0 0 1 2 17.7zm21 11a3.8 3.8 0 0 0-3.8-3.8.8.8 0 0 0 0 1.5h.2a2.3 2.3 0 0 1-.1 4.5H19a.8.8 0 0 0 .2 1.5h.2a3.8 3.8 0 0 0 3.5-3.8m-6.5-3a.8.8 0 0 0-.8-.7h-.1a3.8 3.8 0 0 0 .2 7.5.8.8 0 0 0 0-1.5h-.2a2.3 2.3 0 0 1 .2-4.5.8.8 0 0 0 .7-.7m3.5 3a.8.8 0 0 0-.8-.8h-3.6a.8.8 0 0 0 .2 1.5h3.6a.8.8 0 0 0 .6-.8"/></svg>'},extend:"link",extendFn:["init"],model:{defaults:{name:g,classes:p,resizable:{ratioDefault:!0},traits:[...f,...s],droppable:!1,stylable:["width","min-width","max-width","height","min-height","max-height","padding","margin","position","border-radius","border-width","border-style","border-color","opacity","box-shadow","filter","transform"],components:{type:"image"},styles:`
|
|
2
2
|
.${p} {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
overflow: hidden;
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
width: 100%;
|
|
10
10
|
height: 100%;
|
|
11
11
|
}
|
|
12
|
-
`},init(){const
|
|
12
|
+
`},init(){const t=this.components().at(0);t==null||t.set({layerable:!1,locked:!0})}},view:{onActive(t){c.prototype.onActive.call(this,t)}}}),B({editor:e,licenseKey:o.licenseKey,plan:_,pluginName:j,cleanup:()=>{a.removeType(i),r.remove(i)}})},W=O(F);module.exports=W;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
v,
|
|
1
|
+
const w = "app.grapesjs.com", D = "app-stage.grapesjs.com", G = "app2.grapesjs.com", k = "app-stage2.grapesjs.com", P = [
|
|
2
|
+
w,
|
|
3
|
+
G,
|
|
5
4
|
D,
|
|
5
|
+
k,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,130 +11,143 @@ const A = "app.grapesjs.com", v = "app-stage.grapesjs.com", N = "app2.grapesjs.c
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
14
|
+
], I = "license:check:end", L = () => typeof window < "u", x = ({
|
|
15
15
|
isDev: e,
|
|
16
|
-
isStage:
|
|
17
|
-
isPlatform:
|
|
18
|
-
}) => `${e ? "" : `https://${
|
|
19
|
-
const e =
|
|
20
|
-
return !!e && (
|
|
16
|
+
isStage: o,
|
|
17
|
+
isPlatform: a
|
|
18
|
+
}) => `${e ? "" : `https://${o ? D : w}`}/${a ? "platform-api" : "api"}`, E = () => {
|
|
19
|
+
const e = L() && window.location.hostname;
|
|
20
|
+
return !!e && (P.includes(e) || P.some((o) => e.endsWith(o)));
|
|
21
21
|
};
|
|
22
|
-
async function
|
|
22
|
+
async function M({
|
|
23
23
|
path: e,
|
|
24
|
-
baseApiUrl:
|
|
25
|
-
method:
|
|
26
|
-
headers:
|
|
27
|
-
params:
|
|
28
|
-
body:
|
|
24
|
+
baseApiUrl: o,
|
|
25
|
+
method: a = "GET",
|
|
26
|
+
headers: r = {},
|
|
27
|
+
params: i,
|
|
28
|
+
body: g
|
|
29
29
|
}) {
|
|
30
|
-
const
|
|
31
|
-
method:
|
|
30
|
+
const n = `${o || x({ isDev: !1, isStage: !1 })}${e}`, c = {
|
|
31
|
+
method: a,
|
|
32
32
|
headers: {
|
|
33
33
|
"Content-Type": "application/json",
|
|
34
|
-
...
|
|
34
|
+
...r
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
throw new Error(`HTTP error! status: ${
|
|
41
|
-
return
|
|
37
|
+
g && (c.body = JSON.stringify(g));
|
|
38
|
+
const d = i ? new URLSearchParams(i).toString() : "", u = d ? `?${d}` : "", s = await fetch(`${n}${u}`, c);
|
|
39
|
+
if (!s.ok)
|
|
40
|
+
throw new Error(`HTTP error! status: ${s.status}`);
|
|
41
|
+
return s.json();
|
|
42
42
|
}
|
|
43
|
-
var
|
|
44
|
-
const
|
|
45
|
-
[
|
|
46
|
-
[
|
|
47
|
-
[
|
|
48
|
-
[
|
|
43
|
+
var b = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(b || {}), T = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", 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.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", 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.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", 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))(T || {});
|
|
44
|
+
const A = {
|
|
45
|
+
[b.free]: 0,
|
|
46
|
+
[b.startup]: 10,
|
|
47
|
+
[b.business]: 20,
|
|
48
|
+
[b.enterprise]: 30
|
|
49
49
|
};
|
|
50
|
-
function
|
|
51
|
-
const
|
|
52
|
-
return
|
|
50
|
+
function N(e) {
|
|
51
|
+
const o = e;
|
|
52
|
+
return o.init = (a) => (r) => e(r, a), o;
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
async function
|
|
54
|
+
const O = (e) => /* @__PURE__ */ N(e);
|
|
55
|
+
async function B({
|
|
56
56
|
editor: e,
|
|
57
|
-
plan:
|
|
58
|
-
pluginName:
|
|
59
|
-
licenseKey:
|
|
60
|
-
onLicenseCheckResponse:
|
|
61
|
-
cleanup:
|
|
57
|
+
plan: o,
|
|
58
|
+
pluginName: a,
|
|
59
|
+
licenseKey: r,
|
|
60
|
+
onLicenseCheckResponse: i,
|
|
61
|
+
cleanup: g
|
|
62
62
|
}) {
|
|
63
|
-
let p = "",
|
|
64
|
-
const
|
|
65
|
-
console.warn("Cleanup plugin:",
|
|
66
|
-
}, d = (
|
|
67
|
-
var
|
|
68
|
-
const { error: f, sdkLicense: t } =
|
|
69
|
-
if (!(t ||
|
|
70
|
-
|
|
71
|
-
else if (
|
|
72
|
-
const
|
|
73
|
-
|
|
63
|
+
let p = "", n;
|
|
64
|
+
const c = (s) => {
|
|
65
|
+
console.warn("Cleanup plugin:", a, "Reason:", s), g();
|
|
66
|
+
}, d = (s = {}) => {
|
|
67
|
+
var y;
|
|
68
|
+
const { error: f, sdkLicense: t } = s, l = (y = s.plan) == null ? void 0 : y.category;
|
|
69
|
+
if (!(t || s.license) || f)
|
|
70
|
+
c(f || "Invalid license");
|
|
71
|
+
else if (l) {
|
|
72
|
+
const v = A[o], R = A[l];
|
|
73
|
+
v > R && c({ pluginRequiredPlan: o, licensePlan: l });
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
e.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
76
|
+
e.Commands.has(T.settings) && (n = e.runCommand(T.settings), p = (n == null ? void 0 : n.baseUrl) || "");
|
|
77
|
+
const u = (s) => {
|
|
78
|
+
i == null || i(s), s && d(s);
|
|
79
|
+
};
|
|
80
|
+
if (!n) {
|
|
81
|
+
e.onReady(async () => {
|
|
82
|
+
if (!E())
|
|
83
|
+
if (r) {
|
|
84
|
+
const s = await $({ licenseKey: r, pluginName: a, baseApiUrl: p });
|
|
85
|
+
u(s);
|
|
86
|
+
} else
|
|
87
|
+
c("The `licenseKey` option not provided");
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (n.licensePlan || n.licenseError) {
|
|
92
|
+
const s = U(n);
|
|
93
|
+
u(s);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
e.on(I, (s) => u(s));
|
|
90
97
|
}
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
const U = (e) => ({
|
|
99
|
+
sdkLicense: e.license,
|
|
100
|
+
license: e.license,
|
|
101
|
+
error: e.licenseError,
|
|
102
|
+
plan: e.licensePlan
|
|
103
|
+
});
|
|
104
|
+
async function $(e) {
|
|
105
|
+
const { licenseKey: o, pluginName: a, baseApiUrl: r } = e;
|
|
93
106
|
try {
|
|
94
|
-
return (await
|
|
95
|
-
baseApiUrl:
|
|
96
|
-
path: `/sdk/${
|
|
107
|
+
return (await M({
|
|
108
|
+
baseApiUrl: r,
|
|
109
|
+
path: `/sdk/${o || "na"}`,
|
|
97
110
|
method: "POST",
|
|
98
111
|
params: {
|
|
99
112
|
d: window.location.hostname,
|
|
100
|
-
pn:
|
|
113
|
+
pn: a
|
|
101
114
|
}
|
|
102
115
|
})).result || {};
|
|
103
|
-
} catch (
|
|
104
|
-
return console.error("Error during SDK license check:",
|
|
116
|
+
} catch (i) {
|
|
117
|
+
return console.error("Error during SDK license check:", i), !1;
|
|
105
118
|
}
|
|
106
119
|
}
|
|
107
|
-
const j = "linkImageComponent",
|
|
108
|
-
const { Components:
|
|
120
|
+
const j = "linkImageComponent", _ = b.startup, F = function(e, o = {}) {
|
|
121
|
+
const { Components: a, Blocks: r } = e, i = "link-image", g = "Link Image", p = "link-image", { model: n, view: c } = e.Components.getType("image"), d = a.getType("link").model.getDefaults().traits, u = n.getDefaults().traits, s = d.filter((t) => t !== "title"), f = u.filter((t) => t.name !== "customAttributes").map((t) => typeof t == "string" ? { name: t } : t).map(
|
|
109
122
|
(t) => ({
|
|
110
123
|
...t,
|
|
111
|
-
getValue({ component:
|
|
124
|
+
getValue({ component: l }) {
|
|
112
125
|
var h;
|
|
113
|
-
return (h =
|
|
126
|
+
return (h = l.components().at(0).getTrait(t.name)) == null ? void 0 : h.getValue();
|
|
114
127
|
},
|
|
115
|
-
setValue({ component:
|
|
116
|
-
var
|
|
117
|
-
(
|
|
128
|
+
setValue({ component: l, value: h, options: y }) {
|
|
129
|
+
var v;
|
|
130
|
+
(v = l.components().at(0).getTrait(t.name)) == null || v.setValue(h, y);
|
|
118
131
|
}
|
|
119
132
|
})
|
|
120
133
|
);
|
|
121
|
-
|
|
134
|
+
a.addType(i, {
|
|
122
135
|
isComponent: (t) => {
|
|
123
|
-
var
|
|
124
|
-
return t.tagName === "A" && ((
|
|
136
|
+
var l;
|
|
137
|
+
return t.tagName === "A" && ((l = t.children) == null ? void 0 : l.length) === 1 && t.children[0].tagName === "IMG";
|
|
125
138
|
},
|
|
126
139
|
block: {
|
|
127
|
-
label:
|
|
140
|
+
label: g,
|
|
128
141
|
media: '<svg viewBox="0 0 24 24"><path fill="currentColor" d="M2 6.3A2.3 2.3 0 0 1 4.3 4h15.4A2.3 2.3 0 0 1 22 6.3v7a4.7 4.7 0 0 0-2.8-.8h-3.4a4.8 4.8 0 0 0-4 7.5H4.3A2.3 2.3 0 0 1 2 17.7zm21 11a3.8 3.8 0 0 0-3.8-3.8.8.8 0 0 0 0 1.5h.2a2.3 2.3 0 0 1-.1 4.5H19a.8.8 0 0 0 .2 1.5h.2a3.8 3.8 0 0 0 3.5-3.8m-6.5-3a.8.8 0 0 0-.8-.7h-.1a3.8 3.8 0 0 0 .2 7.5.8.8 0 0 0 0-1.5h-.2a2.3 2.3 0 0 1 .2-4.5.8.8 0 0 0 .7-.7m3.5 3a.8.8 0 0 0-.8-.8h-3.6a.8.8 0 0 0 .2 1.5h3.6a.8.8 0 0 0 .6-.8"/></svg>'
|
|
129
142
|
},
|
|
130
143
|
extend: "link",
|
|
131
144
|
extendFn: ["init"],
|
|
132
145
|
model: {
|
|
133
146
|
defaults: {
|
|
134
|
-
name:
|
|
147
|
+
name: g,
|
|
135
148
|
classes: p,
|
|
136
149
|
resizable: { ratioDefault: !0 },
|
|
137
|
-
traits: [...f, ...
|
|
150
|
+
traits: [...f, ...s],
|
|
138
151
|
droppable: !1,
|
|
139
152
|
stylable: [
|
|
140
153
|
"width",
|
|
@@ -176,19 +189,19 @@ const j = "linkImageComponent", C = g.startup, L = function(e, a = {}) {
|
|
|
176
189
|
},
|
|
177
190
|
view: {
|
|
178
191
|
onActive(t) {
|
|
179
|
-
|
|
192
|
+
c.prototype.onActive.call(this, t);
|
|
180
193
|
}
|
|
181
194
|
}
|
|
182
|
-
}),
|
|
195
|
+
}), B({
|
|
183
196
|
editor: e,
|
|
184
|
-
licenseKey:
|
|
185
|
-
plan:
|
|
197
|
+
licenseKey: o.licenseKey,
|
|
198
|
+
plan: _,
|
|
186
199
|
pluginName: j,
|
|
187
200
|
cleanup: () => {
|
|
188
|
-
|
|
201
|
+
a.removeType(i), r.remove(i);
|
|
189
202
|
}
|
|
190
203
|
});
|
|
191
|
-
},
|
|
204
|
+
}, W = O(F);
|
|
192
205
|
export {
|
|
193
|
-
|
|
206
|
+
W as default
|
|
194
207
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(d,f){typeof exports=="object"&&typeof module<"u"?module.exports=f():typeof define=="function"&&define.amd?define(f):(d=typeof globalThis<"u"?globalThis:d||self,d.StudioSdkPlugins_linkImageComponent=f())})(this,function(){"use strict";const d="app.grapesjs.com",f="app-stage.grapesjs.com",w=[d,"app2.grapesjs.com",f,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],R="license:check:end",I=()=>typeof window<"u",k=({isDev:e,isStage:s,isPlatform:n})=>`${e?"":`https://${s?f:d}`}/${n?"platform-api":"api"}`,G=()=>{const e=I()&&window.location.hostname;return!!e&&(w.includes(e)||w.some(s=>e.endsWith(s)))};async function x({path:e,baseApiUrl:s,method:n="GET",headers:r={},params:i,body:g}){const a=`${s||k({isDev:!1,isStage:!1})}${e}`,c={method:n,headers:{"Content-Type":"application/json",...r}};g&&(c.body=JSON.stringify(g));const b=i?new URLSearchParams(i).toString():"",u=b?`?${b}`:"",o=await fetch(`${a}${u}`,c);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var h=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(h||{}),P=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",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.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",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))(P||{});const D={[h.free]:0,[h.startup]:10,[h.business]:20,[h.enterprise]:30};function L(e){const s=e;return s.init=n=>r=>e(r,n),s}const E=e=>L(e);async function M({editor:e,plan:s,pluginName:n,licenseKey:r,onLicenseCheckResponse:i,cleanup:g}){let p="",a;const c=o=>{console.warn("Cleanup plugin:",n,"Reason:",o),g()},b=(o={})=>{var T;const{error:v,sdkLicense:t}=o,l=(T=o.plan)==null?void 0:T.category;if(!(t||o.license)||v)c(v||"Invalid license");else if(l){const A=D[s],$=D[l];A>$&&c({pluginRequiredPlan:s,licensePlan:l})}};e.Commands.has(P.settings)&&(a=e.runCommand(P.settings),p=(a==null?void 0:a.baseUrl)||"");const u=o=>{i==null||i(o),o&&b(o)};if(!a){e.onReady(async()=>{if(!G())if(r){const o=await N({licenseKey:r,pluginName:n,baseApiUrl:p});u(o)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const o=O(a);u(o);return}e.on(R,o=>u(o))}const O=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function N(e){const{licenseKey:s,pluginName:n,baseApiUrl:r}=e;try{return(await x({baseApiUrl:r,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const B="linkImageComponent",U=h.startup;return E(function(e,s={}){const{Components:n,Blocks:r}=e,i="link-image",g="Link Image",p="link-image",{model:a,view:c}=e.Components.getType("image"),b=n.getType("link").model.getDefaults().traits,u=a.getDefaults().traits,o=b.filter(t=>t!=="title"),v=u.filter(t=>t.name!=="customAttributes").map(t=>typeof t=="string"?{name:t}:t).map(t=>({...t,getValue({component:l}){var y;return(y=l.components().at(0).getTrait(t.name))==null?void 0:y.getValue()},setValue({component:l,value:y,options:T}){var A;(A=l.components().at(0).getTrait(t.name))==null||A.setValue(y,T)}}));n.addType(i,{isComponent:t=>{var l;return t.tagName==="A"&&((l=t.children)==null?void 0:l.length)===1&&t.children[0].tagName==="IMG"},block:{label:g,media:'<svg viewBox="0 0 24 24"><path fill="currentColor" d="M2 6.3A2.3 2.3 0 0 1 4.3 4h15.4A2.3 2.3 0 0 1 22 6.3v7a4.7 4.7 0 0 0-2.8-.8h-3.4a4.8 4.8 0 0 0-4 7.5H4.3A2.3 2.3 0 0 1 2 17.7zm21 11a3.8 3.8 0 0 0-3.8-3.8.8.8 0 0 0 0 1.5h.2a2.3 2.3 0 0 1-.1 4.5H19a.8.8 0 0 0 .2 1.5h.2a3.8 3.8 0 0 0 3.5-3.8m-6.5-3a.8.8 0 0 0-.8-.7h-.1a3.8 3.8 0 0 0 .2 7.5.8.8 0 0 0 0-1.5h-.2a2.3 2.3 0 0 1 .2-4.5.8.8 0 0 0 .7-.7m3.5 3a.8.8 0 0 0-.8-.8h-3.6a.8.8 0 0 0 .2 1.5h3.6a.8.8 0 0 0 .6-.8"/></svg>'},extend:"link",extendFn:["init"],model:{defaults:{name:g,classes:p,resizable:{ratioDefault:!0},traits:[...v,...o],droppable:!1,stylable:["width","min-width","max-width","height","min-height","max-height","padding","margin","position","border-radius","border-width","border-style","border-color","opacity","box-shadow","filter","transform"],components:{type:"image"},styles:`
|
|
2
2
|
.${p} {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
overflow: hidden;
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
width: 100%;
|
|
10
10
|
height: 100%;
|
|
11
11
|
}
|
|
12
|
-
`},init(){const t=this.components().at(0);t==null||t.set({layerable:!1,locked:!0})}},view:{onActive(t){
|
|
12
|
+
`},init(){const t=this.components().at(0);t==null||t.set({layerable:!1,locked:!0})}},view:{onActive(t){c.prototype.onActive.call(this,t)}}}),M({editor:e,licenseKey:s.licenseKey,plan:U,pluginName:B,cleanup:()=>{n.removeType(i),r.remove(i)}})})});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
.${
|
|
1
|
+
"use strict";const B="app.grapesjs.com",O="app-stage.grapesjs.com",$="app2.grapesjs.com",N="app-stage2.grapesjs.com",G=[B,$,O,N,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],_="license:check:end",U=()=>typeof window<"u",F=({isDev:e,isStage:s,isPlatform:a})=>`${e?"":`https://${s?O:B}`}/${a?"platform-api":"api"}`,j=()=>{const e=U()&&window.location.hostname;return!!e&&(G.includes(e)||G.some(s=>e.endsWith(s)))};async function W({path:e,baseApiUrl:s,method:a="GET",headers:t={},params:n,body:r}){const i=`${s||F({isDev:!1,isStage:!1})}${e}`,l={method:a,headers:{"Content-Type":"application/json",...t}};r&&(l.body=JSON.stringify(r));const p=n?new URLSearchParams(n).toString():"",c=p?`?${p}`:"",o=await fetch(`${i}${c}`,l);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);return o.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),E=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",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.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",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.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",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))(E||{});const V={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function K(e){const s=e;return s.init=a=>t=>e(t,a),s}const m=e=>K(e);async function q({editor:e,plan:s,pluginName:a,licenseKey:t,onLicenseCheckResponse:n,cleanup:r}){let g="",i;const l=o=>{console.warn("Cleanup plugin:",a,"Reason:",o),r()},p=(o={})=>{var h;const{error:P,sdkLicense:L}=o,u=(h=o.plan)==null?void 0:h.category;if(!(L||o.license)||P)l(P||"Invalid license");else if(u){const T=V[s],I=V[u];T>I&&l({pluginRequiredPlan:s,licensePlan:u})}};e.Commands.has(E.settings)&&(i=e.runCommand(E.settings),g=(i==null?void 0:i.baseUrl)||"");const c=o=>{n==null||n(o),o&&p(o)};if(!i){e.onReady(async()=>{if(!j())if(t){const o=await Y({licenseKey:t,pluginName:a,baseApiUrl:g});c(o)}else l("The `licenseKey` option not provided")});return}if(i.licensePlan||i.licenseError){const o=X(i);c(o);return}e.on(_,o=>c(o))}const X=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Y(e){const{licenseKey:s,pluginName:a,baseApiUrl:t}=e;try{return(await W({baseApiUrl:t,path:`/sdk/${s||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const x="gjs-plg-",Z="listPagesComponent",J=b.startup;function z(e,s,a){let t,n,r,g,i;const l=s;function p(){const o=Date.now()-g;o<l&&o>=0?t=setTimeout(p,l-o):(t=null,i=e.apply(r,n),r=n=null)}const c=function(){return r=this,n=arguments,g=Date.now(),t||(t=setTimeout(p,l)),i};return c.clear=function(){t&&(clearTimeout(t),t=null)},c.flush=function(){t&&(i=e.apply(r,n),r=n=null,clearTimeout(t),t=null)},c}const k="page://",d="list-pages",f="list-pages-item",y="list-pages-link",Q=e=>e.components().reduce((s,a)=>{var g;const t=a.findFirstType(y),n=(g=t==null?void 0:t.attributes.attributes)==null?void 0:g.href,r=n!=null&&n.startsWith(k)?n.replace(k,""):"";if(r&&t){const i=s[r];i?i.push(t):s[r]=[t]}return s},{}),A="data-type-role",S="page_root",C=e=>s=>s.is(e),ee=e=>(s,a)=>a.is(e),M=e=>s=>{var a;return((a=s.getAttribute)==null?void 0:a.call(s,A))===e},te=function(e,s={}){const{Blocks:a,Components:t,Pages:n}=e,{licenseKey:r,block:g={}}=s,i="List Pages",l="List Pages Item",p="Link",c=`${x}${d}`,o=`${x}${y}`,P='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',L='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';t.addType(d,{block:g&&{label:i,media:P,category:"Extra",select:!0,...s.block},isComponent:M(d),model:{defaults:{tagName:"ul",name:i,[S]:"",classes:c,attributes:{[A]:d,role:"navigation"},droppable:C(f),styles:`
|
|
2
|
+
.${c} {
|
|
3
3
|
list-style: none;
|
|
4
4
|
margin: 0;
|
|
5
5
|
padding: 0;
|
|
6
6
|
}
|
|
7
|
-
`},init(){this.syncPageItems=
|
|
8
|
-
.${
|
|
7
|
+
`},init(){this.syncPageItems=z(this.syncPageItems.bind(this),0),this.listenTo(this.em,n.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(e.Components.getSymbolInfo(this).isInstance)return;const u=this.em.Pages.getAll(),H=this.components(),h=Q(this);u.forEach((T,I)=>{const D=T.id,R=T.getName(),v=h[D];v?v==null||v.forEach(w=>{w.getInnerHTML()!==R&&w.components(R)}):H.add({type:f,components:[{type:y,attributes:{href:`page://${D}`},components:{type:"textnode",content:R}}]},{at:I})})}}}),t.addType(f,{isComponent:M(f),model:{defaults:{name:l,tagName:"li",icon:L,attributes:{[A]:f},components:{type:y},draggable:ee(d)}}}),t.addType(y,{extend:"link",isComponent:M(y),model:{defaults:{removable:!1,copyable:!1,delegate:{move:u=>u.closestType(f)},name:p,classes:o,attributes:{[A]:y},components:{type:"textnode",content:"Item"},styles:`
|
|
8
|
+
.${o} {
|
|
9
9
|
text-decoration: none;
|
|
10
10
|
}
|
|
11
|
-
`}}}),
|
|
11
|
+
`}}}),q({editor:e,licenseKey:r,plan:J,pluginName:Z,cleanup:()=>{a.remove(d),t.removeType(d)}})},se=m(te);module.exports=se;
|