@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
|
-
"use strict";const se="app.grapesjs.com",re="app-stage.grapesjs.com",ue="app2.grapesjs.com",he="app-stage2.grapesjs.com",Y=[se,ue,re,he,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ge="license:check:start",be="license:check:end",me=()=>typeof window<"u",de=({isDev:e,isStage:n,isPlatform:t})=>`${e?"":`https://${n?re:se}`}/${t?"platform-api":"api"}`,ye=()=>{const e=me()&&window.location.hostname;return!!e&&(Y.includes(e)||Y.some(n=>e.endsWith(n)))};async function ve({path:e,baseApiUrl:n,method:t="GET",headers:l={},params:o,body:u}){const p=`${n||de({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 G=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(G||{});const ee={[G.free]:0,[G.startup]:10,[G.business]:20,[G.enterprise]:30};function fe(e){const n=e;return n.init=t=>l=>e(l,t),n}const Te=e=>fe(e);async function we({editor:e,plan:n,pluginName:t,licenseKey:l,onLicenseCheckResponse:o,cleanup:u}){let r="",p=!1;const h=ye(),c=s=>{console.warn("Cleanup plugin:",t,"Reason:",s),u()},b=(s={})=>{var k;const{error:P,sdkLicense:V}=s,T=(k=s.plan)==null?void 0:k.category;if(!(V||s.license)||P)c(P||"Invalid license");else if(T){const O=ee[n],$=ee[T];O>$&&c({pluginRequiredPlan:n,licensePlan:T})}};e.on(ge,s=>{r=s==null?void 0:s.baseApiUrl,p=!0}),e.on(be,s=>{o==null||o(s),b(s)}),setTimeout(async()=>{if(!p){if(h)return;if(l){const s=await Se({licenseKey:l,pluginName:t,baseApiUrl:r});o==null||o(s),s&&b(s)}else c("The `licenseKey` option not provided")}},2e3)}async function Se(e){const{licenseKey:n,pluginName:t,baseApiUrl:l}=e;try{return(await ve({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 B=(e,n)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,n))},xe="lightGalleryComponent",Ie=G.startup;var E=(e=>(e.image="image",e.video="video",e.external="external",e))(E||{});const I="lightGallery",te=`${I}-item`,U="data-lightgallery",ae=`${U}-item`,j="toggle",A={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>'},W={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})},Z=(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)})},Ae=(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)},Pe={[j]:{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}},ke={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}]}}},Ee={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}]}}},f="sourceType",K="data-iframe",q={name:"href",type:"file",label:"Image Source"},H={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},J={name:"data-poster",label:"Video Poster",type:"file"},le={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},ce={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Ge={[j]:{type:"button",label:"Toggle Gallery",command:(e,n)=>{var o,u;const t=n.target,l=(o=t==null?void 0:t.closestType(I))==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)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[q],video:[H,J],external:[le]},options:[{id:"image",label:q.label||"",icon:A.image},{id:"video",label:H.label||"",icon:A.video},{id:"external",label:le.label||"",icon:A.external}]},subHtml:ce},ne="lgThumbnail",Ve="lgVideo",oe="lgAutoplay",ie="lgZoom",L="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Oe=function(e,n={}){const{Blocks:t,Components:l}=e,o="LightGallery",u="LightGallery Item",r={toolbarIconOpen:A.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[ne,Ve,oe,ie],cdnScript:[`${L}/lightgallery.min.js`,`${L}/plugins/thumbnail/lg-thumbnail.min.js`,`${L}/plugins/video/lg-video.min.js`,`${L}/plugins/autoplay/lg-autoplay.min.js`,`${L}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${L}/css/lightgallery-bundle.min.css`,...n},{block:p,toolbarIconOpen:h,defaultSrc:c}=r,b=function(a){const i=this,g=window,{plugins:d,cdnScript:w,cdnStyle:C,inline:R,lgLicenseKey:pe,...y}=a||{},S=m=>isNaN(m)?void 0:parseInt(m,10),Q=()=>{var D;const m={...y,licenseKey:pe,speed:S(y.speed),startAnimationDuration:S(y.startAnimationDuration),thumbMargin:S(y.thumbMargin),thumbWidth:S(y.thumbWidth),slideShowInterval:S(y.slideShowInterval),scale:S(y.scale),enableZoomAfter:S(y.enableZoomAfter),plugins:(d||[]).map(N=>g[N])};R&&(m.container=i,m.closable=!1);const z=(D=g.lightGallery)==null?void 0:D.call(g,i,m);R&&z.openGallery()};if(g.lightGallery)Q();else{const{head:m}=document,z=Array.isArray(w)?[...w]:[w],D=Array.isArray(C)?[...C]:[C],N=x=>{if(x.length){const v=document.createElement("link");v.href=x.shift(),v.rel="stylesheet",m.appendChild(v),N(x)}},X=x=>{if(x.length){const v=document.createElement("script");v.src=x.shift(),v.onerror=v.onload=X.bind(null,x),m.appendChild(v)}else Q()};N(D),X(z)}},s=a=>{const i=a.getTrait(j);if(!h||!i)return;const{toolbar:g}=a,d={id:j,label:h,command:()=>setTimeout(()=>i.runCommand(),100)};!g.find(C=>C.id===d.id)&&(g==null||g.unshift(d))};let P=[];const V=r.plugins||[],T=_(Pe),M=V.includes(ne)?_(ke):W,k=V.includes(oe)?_(Le):W,O=V.includes(ie)?_(Ee):W;l.addType(I,{block:p&&{label:o,media:A.gallery,category:"Extra",select:!0,...r.block},isComponent:a=>B(a,U),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:A.gallery,draggable:(a,i)=>!i.is(I),attributes:{[U]:!0},components:{type:te},script:b,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...T.propKeys,...M.propKeys,...k.propKeys,...O.propKeys],...T.props,...M.props,...k.props,...O.props,traits:[...T.traits,...M.traits,...k.traits,...O.traits]},init(){Z(this,["thumbnail"]),Z(this,["autoplay"]),Z(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();P=i.getSpots(),setTimeout(()=>i.removeSpots()),g.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();P.forEach(i=>this.em.Canvas.addSpot(i.attributes)),P=[],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 $=_(Ge);l.addType(te,{isComponent:a=>B(a,ae)||a.tagName==="A"&&B(a.parentElement,U),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:u,icon:A.galleryItem,attributes:{[ae]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...$.props,traits:[...$.traits]},init(){const a=[f].map(i=>`change:${i}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Ae(this,f,this.triggerGalleryUpdate)},initToolbar(){s(this)},initScriptUpdate(){const a=[ce.name].map(i=>`change:attributes:${i}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var i;(i=this.closestType(I))==null||i.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:i}=this,{init:g}=a;if(i[f]||g){F(this,f);const d=this.getTrait(f).getValue();if(d===E.image){this.removeAttributes([H.name,J.name,K]);const w=this.getTrait(q.name);w.setValue(w.getValue()||c)}else d===E.video?this.removeAttributes([K]):d===E.external&&this.addAttributes({[K]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[K]?this.set(f,E.external):(a[H.name]||a[J.name])&&this.set(f,E.video)}}}),we({editor:e,plan:Ie,licenseKey:r.licenseKey,pluginName:xe,cleanup:()=>{t.remove(I),l.removeType(I)}})},Ce=Te(Oe);module.exports=Ce;
|
|
1
|
+
"use strict";const re="app.grapesjs.com",ce="app-stage.grapesjs.com",ge="app2.grapesjs.com",he="app-stage2.grapesjs.com",ee=[re,ge,ce,he,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],be="license:check:end",de=()=>typeof window<"u",ye=({isDev:e,isStage:l,isPlatform:t})=>`${e?"":`https://${l?ce:re}`}/${t?"platform-api":"api"}`,me=()=>{const e=de()&&window.location.hostname;return!!e&&(ee.includes(e)||ee.some(l=>e.endsWith(l)))};async function ve({path:e,baseApiUrl:l,method:t="GET",headers:o={},params:i,body:g}){const n=`${l||ye({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 E=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(E||{}),Z=(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))(Z||{});const te={[E.free]:0,[E.startup]:10,[E.business]:20,[E.enterprise]:30};function fe(e){const l=e;return l.init=t=>o=>e(o,t),l}const Te=e=>fe(e);async function we({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 G;const{error:I,sdkLicense:O}=r,T=(G=r.plan)==null?void 0:G.category;if(!(O||r.license)||I)u(I||"Invalid license");else if(T){const M=te[l],_=te[T];M>_&&u({pluginRequiredPlan:l,licensePlan:T})}};e.Commands.has(Z.settings)&&(n=e.runCommand(Z.settings),c=(n==null?void 0:n.baseUrl)||"");const b=r=>{i==null||i(r),r&&p(r)};if(!n){e.onReady(async()=>{if(!me())if(o){const r=await Pe({licenseKey:o,pluginName:t,baseApiUrl:c});b(r)}else u("The `licenseKey` option not provided")});return}if(n.licensePlan||n.licenseError){const r=xe(n);b(r);return}e.on(be,r=>b(r))}const xe=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function Pe(e){const{licenseKey:l,pluginName:t,baseApiUrl:o}=e;try{return(await ve({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 z=(e,l)=>{var t;return!!((t=e==null?void 0:e.hasAttribute)!=null&&t.call(e,l))},Ae="lightGalleryComponent",Le=E.startup;var S=(e=>(e.image="image",e.video="video",e.external="external",e))(S||{});const A="lightGallery",ae=`${A}-item`,j="data-lightgallery",oe=`${j}-item`,N="toggle",L={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>'},F={propKeys:[],props:{},traits:[]},V=(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})},W=(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)})},Ie=(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)},Ge={[N]:{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}},ke={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"}]}}},Se={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}]}}},Ee={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}]}}},f="sourceType",U="data-iframe",J={name:"href",type:"file",label:"Image Source"},K={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},C={name:"data-poster",label:"Video Poster",type:"file"},le={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},pe={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},Oe={[N]:{type:"button",label:"Toggle Gallery",command:(e,l)=>{var i,g;const t=l.target,o=(i=t==null?void 0:t.closestType(A))==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)}}},[f]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[J],video:[K,C],external:[le]},options:[{id:"image",label:J.label||"",icon:L.image},{id:"video",label:K.label||"",icon:L.video},{id:"external",label:le.label||"",icon:L.external}]},subHtml:pe},se="lgThumbnail",Me="lgVideo",ie="lgAutoplay",ne="lgZoom",k="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",De=function(e,l={}){const{Blocks:t,Components:o}=e,i="LightGallery",g="LightGallery Item",c={toolbarIconOpen:L.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[se,Me,ie,ne],cdnScript:[`${k}/lightgallery.min.js`,`${k}/plugins/thumbnail/lg-thumbnail.min.js`,`${k}/plugins/video/lg-video.min.js`,`${k}/plugins/autoplay/lg-autoplay.min.js`,`${k}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${k}/css/lightgallery-bundle.min.css`,...l},{block:n,toolbarIconOpen:u,defaultSrc:p}=c,b=function(a){const s=this,h=window,{plugins:y,cdnScript:w,cdnStyle:D,inline:Q,lgLicenseKey:ue,...m}=a||{},x=d=>isNaN(d)?void 0:parseInt(d,10),X=()=>{var B;const d={...m,licenseKey:ue,speed:x(m.speed),startAnimationDuration:x(m.startAnimationDuration),thumbMargin:x(m.thumbMargin),thumbWidth:x(m.thumbWidth),slideShowInterval:x(m.slideShowInterval),scale:x(m.scale),enableZoomAfter:x(m.enableZoomAfter),plugins:(y||[]).map($=>h[$])};Q&&(d.container=s,d.closable=!1);const H=(B=h.lightGallery)==null?void 0:B.call(h,s,d);Q&&H.openGallery()};if(h.lightGallery)X();else{const{head:d}=document,H=Array.isArray(w)?[...w]:[w],B=Array.isArray(D)?[...D]:[D],$=P=>{if(P.length){const v=document.createElement("link");v.href=P.shift(),v.rel="stylesheet",d.appendChild(v),$(P)}},Y=P=>{if(P.length){const v=document.createElement("script");v.src=P.shift(),v.onerror=v.onload=Y.bind(null,P),d.appendChild(v)}else X()};$(B),Y(H)}},r=a=>{const s=a.getTrait(N);if(!u||!s)return;const{toolbar:h}=a,y={id:N,label:u,command:()=>setTimeout(()=>s.runCommand(),100)};!h.find(D=>D.id===y.id)&&(h==null||h.unshift(y))};let I=[];const O=c.plugins||[],T=V(Ge),R=O.includes(se)?V(ke):F,G=O.includes(ie)?V(Se):F,M=O.includes(ne)?V(Ee):F;o.addType(A,{block:n&&{label:i,media:L.gallery,category:"Extra",select:!0,...c.block},isComponent:a=>z(a,j),extendFn:["init","initToolbar"],model:{defaults:{name:i,icon:L.gallery,draggable:(a,s)=>!s.is(A),attributes:{[j]:!0},components:{type:ae},script:b,selector:"",exThumbImage:"",cdnScript:c.cdnScript,cdnStyle:c.cdnStyle,plugins:c.plugins,lgLicenseKey:c.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...T.propKeys,...R.propKeys,...G.propKeys,...M.propKeys],...T.props,...R.props,...G.props,...M.props,traits:[...T.traits,...R.traits,...G.traits,...M.traits]},init(){W(this,["thumbnail"]),W(this,["autoplay"]),W(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();I=s.getSpots(),setTimeout(()=>s.removeSpots()),h.__lgOpened=!0},onLgClose(){const a=this.getLightGallery();I.forEach(s=>this.em.Canvas.addSpot(s.attributes)),I=[],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 _=V(Oe);o.addType(ae,{isComponent:a=>z(a,oe)||a.tagName==="A"&&z(a.parentElement,j),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:g,icon:L.galleryItem,attributes:{[oe]:!0,href:p},components:{type:"image",attributes:{alt:"Image",src:p}},..._.props,traits:[..._.traits]},init(){const a=[f].map(s=>`change:${s}`).join(" ");this.initSourceType(),this.on(a,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),Ie(this,f,this.triggerGalleryUpdate)},initToolbar(){r(this)},initScriptUpdate(){const a=[pe.name].map(s=>`change:attributes:${s}`).join(" ");this.on(a,this.triggerGalleryUpdate)},triggerGalleryUpdate(...a){var s;(s=this.closestType(A))==null||s.__scriptPropsChange(...a)},updateTraits(a={}){const{changed:s}=this,{init:h}=a;if(s[f]||h){q(this,f);const y=this.getTrait(f).getValue();if(y===S.image){this.removeAttributes([K.name,C.name,U]);const w=this.getTrait(J.name);w.setValue(w.getValue()||p)}else y===S.video?this.removeAttributes([U]):y===S.external&&this.addAttributes({[U]:!0})}},initSourceType(){const a=this.getAttributes({noClass:!0,noStyle:!0});a[U]?this.set(f,S.external):(a[K.name]||a[C.name])&&this.set(f,S.video)}}}),we({editor:e,plan:Le,licenseKey:c.licenseKey,pluginName:Ae,cleanup:()=>{t.remove(A),o.removeType(A)}})},Ve=Te(De);module.exports=Ve;
|