@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33
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 +161 -156
- package/dist/accordionComponent/index.umd.js +9 -9
- package/dist/aiChat/chatManager.d.ts +15 -0
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
- package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
- package/dist/aiChat/components/AiChatError.d.ts +2 -1
- package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
- package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
- package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
- package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
- package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
- package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
- package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
- package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
- package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
- package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
- package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
- package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
- package/dist/aiChat/components/index.d.ts +24 -25
- package/dist/aiChat/components/utils.d.ts +12 -4
- package/dist/aiChat/index.cjs.d.ts +5 -0
- package/dist/aiChat/index.cjs.js +453 -0
- package/dist/aiChat/index.d.ts +4 -3
- package/dist/aiChat/index.es.d.ts +5 -0
- package/dist/aiChat/index.es.js +30930 -0
- package/dist/aiChat/index.js +453 -0
- package/dist/aiChat/index.umd.js +453 -0
- package/dist/aiChat/locales/en.d.ts +64 -0
- package/dist/aiChat/server/index.cjs.d.ts +4 -0
- package/dist/aiChat/server/index.cjs.js +309 -0
- package/dist/aiChat/server/index.d.ts +0 -50
- package/dist/aiChat/server/index.es.d.ts +4 -0
- package/dist/aiChat/server/index.es.js +876 -0
- package/dist/aiChat/server/index.js +309 -0
- package/dist/aiChat/server/index.umd.js +309 -0
- package/dist/aiChat/server/stream.d.ts +0 -6
- package/dist/aiChat/server/tools.d.ts +157 -51
- package/dist/aiChat/server/types.d.ts +108 -64
- package/dist/aiChat/types.d.ts +148 -108
- package/dist/aiChat/typesSchema.d.ts +238 -25
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +174 -169
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +161 -156
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +113 -108
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +137 -132
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +4 -4
- package/dist/canvasGridMode/index.es.js +168 -163
- package/dist/canvasGridMode/index.umd.js +8 -8
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +132 -127
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +5 -5
- package/dist/dataSourceEjs/index.es.js +151 -146
- package/dist/dataSourceEjs/index.umd.js +5 -5
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +91 -86
- package/dist/dataSourceHandlebars/index.umd.js +5 -5
- package/dist/dialogComponent/index.cjs.js +16 -16
- package/dist/dialogComponent/index.es.js +117 -112
- package/dist/dialogComponent/index.umd.js +16 -16
- package/dist/flexComponent/index.cjs.js +11 -11
- package/dist/flexComponent/index.es.js +416 -411
- package/dist/flexComponent/index.umd.js +11 -11
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +152 -147
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +127 -122
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +170 -165
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +27 -22
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -151
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +197 -192
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +86 -81
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +121 -116
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +180 -175
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +128 -123
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +127 -122
- 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 +160 -155
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +25 -25
- package/dist/shapeDividerComponent/index.es.js +127 -122
- package/dist/shapeDividerComponent/index.umd.js +25 -25
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +197 -192
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +227 -222
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +124 -119
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +5 -2
- package/dist/aiChat/components/AiChatInput.d.ts +0 -17
- package/dist/aiChat/server/stream-utils.d.ts +0 -16
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
${
|
|
3
|
-
</div>`,
|
|
1
|
+
(function(R,A){typeof exports=="object"&&typeof module<"u"?module.exports=A():typeof define=="function"&&define.amd?define(A):(R=typeof globalThis<"u"?globalThis:R||self,R.StudioSdkPlugins_flexComponent=A())})(this,function(){"use strict";const R="app.grapesjs.com",A="app-stage.grapesjs.com",at=[R,"app2.grapesjs.com",A,"app-stage2.grapesjs.com","localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],St="license:check:start",yt="license:check:end",bt=()=>typeof window<"u",Pt=({isDev:n,isStage:t,isPlatform:e})=>`${n?"":`https://${t?A:R}`}/${e?"platform-api":"api"}`,zt=()=>{const n=bt()&&window.location.hostname;return!!n&&(at.includes(n)||at.some(t=>n.endsWith(t)))};function Ct(n){return typeof n=="function"}async function xt({path:n,baseApiUrl:t,method:e="GET",headers:s={},params:i,body:a}){const c=`${t||Pt({isDev:!1,isStage:!1})}${n}`,p={method:e,headers:{"Content-Type":"application/json",...s}};a&&(p.body=JSON.stringify(a));const u=i?new URLSearchParams(i).toString():"",f=u?`?${u}`:"",r=await fetch(`${c}${f}`,p);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),ot=(n=>(n.web="web",n.email="email",n.document="document",n.react="react",n))(ot||{});const rt={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function wt(n){const t=n;return t.init=e=>s=>n(s,e),t}const It=n=>wt(n);async function vt({editor:n,plan:t,pluginName:e,licenseKey:s,onLicenseCheckResponse:i,cleanup:a}){let o="",c=!1;const p=zt(),u=r=>{console.warn("Cleanup plugin:",e,"Reason:",r),a()},f=(r={})=>{var x;const{error:g,sdkLicense:E}=r,S=(x=r.plan)==null?void 0:x.category;if(!(E||r.license)||g)u(g||"Invalid license");else if(S){const v=rt[t],b=rt[S];v>b&&u({pluginRequiredPlan:t,licensePlan:S})}};n.on(St,r=>{o=r==null?void 0:r.baseApiUrl,c=!0}),n.on(yt,r=>{i==null||i(r),f(r)}),setTimeout(async()=>{if(!c){if(p)return;if(s){const r=await Gt({licenseKey:s,pluginName:e,baseApiUrl:o});i==null||i(r),r&&f(r)}else u("The `licenseKey` option not provided")}},2e3)}async function Gt(n){const{licenseKey:t,pluginName:e,baseApiUrl:s}=n;try{return(await xt({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const lt=n=>t=>{var e;return((e=t.getAttribute)==null?void 0:e.call(t,K))===n},Et=(...n)=>t=>n.some(e=>t.is(e)),Tt=(...n)=>(t,e)=>n.some(s=>e.is(s)),ct="gjs-plg-",K="data-type-role",B=class B{constructor(t){this.config=t}getSize(t){var e;return(e=this.config)!=null&&e.getSize?this.config.getSize(t):et(t.componentColumn,B.CSS_FLEX_BASIS)}setSize(t){var e;if((e=this.config)!=null&&e.setSize)this.config.setSize(t);else{const{componentColumn:s,sizeValue:i,partial:a}=t;s.addStyle({[B.CSS_FLEX_BASIS]:i},{partial:a})}}};B.CSS_FLEX_BASIS="flex-basis";let J=B;const F=class F{constructor(t){this.config=t}isGapSupported(){return!0}getGap(t){var e;return(e=this.config)!=null&&e.getGap?this.config.getGap(t):et(t.componentRow,F.CSS_GAP)}setGap(t){var e;if((e=this.config)!=null&&e.setGap)this.config.setGap(t);else{const{componentRow:s,gapValue:i,partial:a}=t;s.addStyle({[F.CSS_GAP]:i},{partial:a})}}};F.CSS_GAP="gap";let q=F;const U=class U{constructor(t){this.config=t}getParentSize(t){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(t);const{componentRow:e,isVertical:s}=t,i=e.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(t){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(t);const e=et(t.componentRow,U.CSS_FLEX_DIRECTION,!0);return e==="column"||e==="column-reverse"}};U.CSS_FLEX_DIRECTION="flex-direction";let Z=U;const O=class O{constructor(t){this.config=t}getSize(t){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(t);const e=t.componentColumn;if(e.is(O.MJML_COLUMN_TYPE)){const a=e.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=e.parent();return 100/(o?o.components().length:1)}return 0}setSize(t){var e;if((e=this.config)!=null&&e.setSize)this.config.setSize(t);else{const{componentColumn:s,sizeValue:i,partial:a}=t;s.is(O.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};O.MJML_COLUMN_TYPE="mj-column";let Q=O;const k=class k{constructor(t){this.config=t}isGapSupported(){return!1}getGap(t){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(t);const{componentRow:e}=t;if(e.is(k.MJML_SECTION_TYPE)){const i=e.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(t){var e,s;(s=(e=this.config)==null?void 0:e.setGap)==null||s.call(e,t)}};k.MJML_SECTION_TYPE="mj-section";let tt=k;class Rt{constructor(t){this.config=t}getParentSize(t){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(t);const{componentRow:e,isVertical:s}=t,i=e.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const c=i.querySelectorAll("table");c.length&&(a=c[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(t){var e;return(e=this.config)!=null&&e.isParentVertical?this.config.isParentVertical(t):!1}}class M{constructor(){this.handlerCache=new Map}static getInstance(){return M.instance||(M.instance=new M),M.instance}getHandlers(t){const e=`${t.projectType}-${t.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(e)||(H(t)?this.handlerCache.set(e,{sizeHandler:new Q(t),gapHandler:new tt(t),parentSizeHandler:new Rt(t)}):this.handlerCache.set(e,{sizeHandler:new J(t),gapHandler:new q(t),parentSizeHandler:new Z(t)})),this.handlerCache.get(e)}}function T(n){return M.getInstance().getHandlers(n)}const pt=n=>{n.style.display="none"},dt=n=>{n.style.display="block"},V=n=>+parseFloat(`${n}`).toFixed(2),H=n=>n.projectType===ot.email,At=n=>n?["top","bottom"]:["left","right"],$t=n=>{const t=n.parent();return t?t.components().models.indexOf(n)===0:!1},Mt=n=>{const t=n.parent();if(!t)return!1;const e=t.components().models;return e.indexOf(n)===e.length-1},Ht=n=>{const t=n.parent();if(!t)return!1;const e=t.components().models;return e.length>1&&n.index()===e.length-1},Lt=(n,t,e,s)=>{const a=n+(e?t==="top"?-1:t==="bottom"?1:0:t==="left"?-1:t==="right"?1:0);return a>=0&&a<s?a:-1},X=n=>n==="top"||n==="bottom",Nt=(n,t)=>!!($t(n)&&(t==="left"||t==="top")||Mt(n)&&(t==="right"||t==="bottom")),Vt=n=>{const t=n.parent();return t?t.components().models.length>1:!1},ut=(n,t)=>n==="right"||n==="bottom"?t>0:t<0,et=(n,t,e=!1)=>{const s=!e,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[t]||"";if(s){let c;return typeof o=="string"?(c=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(c)&&(c=0)):c=Number(o)||0,c}return o},ht=(n,t,e)=>{const s=nt({componentRow:n,isVertical:t},e),i=n.components().models;return s*(i.length-1)},j=(n,t)=>T(t).parentSizeHandler.isLayoutVertical({componentRow:n}),_=(n,t)=>T(t).sizeHandler.getSize(n),nt=(n,t)=>{if(t!=null&&t.disableGapHandler)return 0;const{gapHandler:e,parentSizeHandler:s}=T(t);if(!e.isGapSupported())return 0;const i=e.getGap(n),a=s.getParentSize(n);return i/100*a},st=(n,t)=>T(t).parentSizeHandler.getParentSize(n),D=(n,t)=>{T(t).sizeHandler.setSize(n)},gt=(n,t)=>{const e=_(n,t);D({...n,sizeValue:`${e}%`,partial:!1},t)},ft=(n,t)=>{if(t!=null&&t.disableGapHandler)return;const{gapHandler:e}=T(t);e.isGapSupported()&&e.setGap(n)},jt=(n,t)=>{const e=n.getStyle().gap;if(!e)return;const s=n.components().models,i={componentRow:n,isVertical:j(n,t)};s.map(a=>gt({...i,componentColumn:a},t)),ft({...i,gapValue:String(e),partial:!1},t)};function _t(n,t){const{Blocks:e}=n,{typeColumn:s,typeRow:i,blocks:a}=t;if(a===!1||H(t))return;const o=r=>({type:i,components:r.map(g=>({type:s,style:{"flex-basis":`${g}%`}}))}),c=r=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
2
|
+
${r.map(g=>`<div style="flex-basis: ${g}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
3
|
+
</div>`,p=(r,g)=>({id:`flex-row-${g.join("-")}`,label:r,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:c(g),content:o(g)}),u=[p("1 Column",[100]),p("2 Columns 50/50",[50,50]),p("2 Columns 25/75",[25,75]),p("2 Columns 75/25",[75,25]),p("3 Columns",[33.33,33.33,33.33]),p("3 Columns 50/25/25",[50,25,25]),p("3 Columns 25/50/25",[25,50,25]),p("3 Columns 25/25/50",[25,25,50]),p("4 Columns",[25,25,25,25]),p("5 Columns",[20,20,20,20,20])],f=Ct(a)?a({blocks:u}):u;return f.forEach(r=>e.add(r.id,r)),()=>{f.forEach(r=>e.remove(r.id))}}const Dt=(n,t)=>{const{Components:e}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=t,o=`${ct}${i}`,p=!!i&&!!e.getType(i)&&!a;if(!(!i||p||H(t)))return e.addType(i,{isComponent:lt(i),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Tt(s),attributes:{[K]:i},styles:`
|
|
4
4
|
.${o} {
|
|
5
5
|
flex-grow: 1;
|
|
6
6
|
}
|
|
7
|
-
`}}}),()=>{
|
|
7
|
+
`}}}),()=>{e.removeType(i)}},Bt=(n,t)=>{const{Components:e}=n,{typeRow:s,typeColumn:i,extendTypeRow:a}=t,o=`${ct}${s}`,p=!!s&&!!e.getType(s)&&!a;if(!(!s||p||H(t)))return e.addType(s,{isComponent:lt(s),model:{defaults:{name:"Row",classes:o,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[K]:s},droppable:Et(i),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:t.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:t.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
|
|
8
8
|
.${o} {
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: stretch;
|
|
11
11
|
flex-wrap: nowrap;
|
|
12
12
|
}
|
|
13
|
-
`}}}),()=>{
|
|
13
|
+
`}}}),()=>{e.removeType(s)}},Ft="flexComponent",Ot=$.startup;class Xt{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(t){this.resizableChildTypes.add(t)}registerGapAdjustableParent(t){this.gapAdjustableParentTypes.add(t)}registerTypeRelationship(t,e){this.typeRelationships.has(t)||this.typeRelationships.set(t,new Set),this.typeRelationships.get(t).add(e),this.registerResizableChild(e),this.registerGapAdjustableParent(t)}isResizableChild(t){return this.resizableChildTypes.has(t.get("type"))}isGapAdjustableParent(t){return this.gapAdjustableParentTypes.has(t.get("type"))}isValidRelationship(t,e){const s=t.get("type"),i=e.get("type");return this.typeRelationships.has(s)?this.typeRelationships.get(s).has(i):!1}}class Yt{constructor(t,e,s){this.editor=t,this.registry=e,this.opts=s,this.resizeState=new WeakMap}getState(t){return this.resizeState.has(t)||this.resizeState.set(t,{}),this.resizeState.get(t)}clearState(t){return this.resizeState.delete(t)}startResize(t,e,s){const{opts:i}=this,a=this.getState(t);a.direction=e,a.startX=s.clientX,a.startY=s.clientY,a.resizing=!0,a.lastSnappedPercent=void 0;const o=t.parent();if(!o||!this.registry.isValidRelationship(o,t))return;a.snapEnabled=o.get("snap")??i.snapEnabled,a.snapDivisions=o.get("snap-divisions")??i.snapDivisions??12;const c=o.components().models,p=c.findIndex(g=>g.cid===t.cid),u=j(o,i),f=Lt(p,e,u,c.length);f!==-1&&(a.adjacentIdx=f);const r={componentColumn:t,componentRow:o,isVertical:u};if(a.startPercent=_(r,i),typeof a.adjacentIdx<"u"){const g=c[a.adjacentIdx];a.neighborStartPercent=_({...r,componentColumn:g},i)}}updateResizeByDelta(t,e,s){const i=this.getState(t),a=t.parent();!i.resizing||!a||(i.snapEnabled?this.updateSnapResize(t,e,s):this.updateContinuesResize(t,e,s))}finishResize(t){const e=t.parent(),s=e==null?void 0:e.components().models,i={componentRow:e,isVertical:!!e&&j(e,this.opts)};s==null||s.forEach(a=>gt({...i,componentColumn:a},this.opts)),this.clearState(t)}updateContinuesResize(t,e,s){const i=this.getState(t),a=t.parent(),{opts:o}=this;if(!a)return;const c=o.minItemPercent??0,p=X(e),u=st({componentRow:a,isVertical:p},o),f=ht(a,p,this.opts),g=100-f/u*100,E=s/(u-f)*g,{startPercent:S=0,neighborStartPercent:C=0}=i,x={componentRow:a,isVertical:p,componentColumn:t,partial:!0},v=ut(e,s)?S+Math.abs(E):S-Math.abs(E);if(typeof i.adjacentIdx<"u"){const b=a.components().models[i.adjacentIdx],w=S+C,P=w-c,l=Math.min(P,Math.max(c,v)),d=w-l;D({...x,sizeValue:`${V(l)}%`},o),D({...x,componentColumn:b,sizeValue:`${V(d)}%`},o)}else{const b=Math.max(c,Math.min(g,v));D({...x,sizeValue:`${V(b)}%`},o)}}updateSnapResize(t,e,s){const i=this.getState(t),a=t.parent(),o=X(e),c=st({componentRow:a,isVertical:o},this.opts),p=ht(a,o,this.opts),u=c-p,f=s/u*100,r=ut(e,s),{startPercent:g=0,snapDivisions:E=12}=i,S=r?g+Math.abs(f):g-Math.abs(f),C=100/E,x=Math.floor(S/C)*C,v=Math.ceil(S/C)*C,b=Math.abs(v-S),w=Math.abs(S-x),P=C*.2,z=b<w?v:x;if(z>0&&z<100&&(b<P||w<P)&&i.lastSnappedPercent!==z){i.lastSnappedPercent=z;let m=Math.abs(z-g)/100*u;(r&&(e==="left"||e==="top")||!r&&(e==="right"||e==="bottom"))&&(m=-m),this.updateContinuesResize(t,e,m)}else b>=P&&w>=P&&(i.lastSnappedPercent=void 0)}}class Ut{constructor(t,e,s){this.editor=t,this.registry=e,this.opts=s}updateGapByDelta(t,e,s,i){if(!this.registry.isGapAdjustableParent(t))return;const{opts:a}=this,o=Math.max(0,s+e),c=st({componentRow:t,isVertical:i},a),p=o/c*100,u=t.components().models,f=u.length-1,r={componentRow:t,isVertical:i},g=u.reduce((P,z)=>P+_({...r,componentColumn:z},a),0),S=100-p*f,C=a.minItemPercent||5;if(S<C*u.length)return;const v=100-f*p,b=g-v,w={componentRow:t,isVertical:i,partial:!0};u.map(P=>{const z=_({...r,componentColumn:P},a),l=z-z/g*b;D({...w,componentColumn:P,sizeValue:`${V(l)}%`},a)}),ft({...w,gapValue:`${V(p)}%`},a)}finishGapAdjust(t){jt(t,this.opts)}}class kt{constructor(t,e,s){this.editor=t,this.registry=e,this.opts=s,this.resizeHandler=new Yt(t,e,s),this.gapHandler=new Ut(t,e,s)}startResize(t,e,s){this.resizeHandler.startResize(t,e,s)}updateResizeByDelta(t,e,s){this.resizeHandler.updateResizeByDelta(t,e,s)}finishResize(t){this.resizeHandler.finishResize(t)}updateGapByDelta(t,e,s,i){this.gapHandler.updateGapByDelta(t,e,s,i)}finishGapAdjust(t){this.gapHandler.finishGapAdjust(t)}canResize(t){const e=t.parent();return e?this.registry.isValidRelationship(e,t):!1}canAdjustGap(t){return this.registry.isGapAdjustableParent(t)}}const Y="gs-flex-spots",mt=`${Y}__handle-size`,Wt=`${Y}__handle-gap`;function Kt(n,t){const{Canvas:e}=n,s="flex-resize-spot";let i,a,o,c,p=null,u=null;const f=new Xt,r=new kt(n,f,t),g=()=>{var l;i=document.createElement("div"),i.className=Y,i.style.display="none",a=document.createElement("div"),a.className=`${Y}__handles`,a.style.position="absolute",a.style.pointerEvents="none",a.style.zIndex="21",o={left:document.createElement("div"),right:document.createElement("div"),top:document.createElement("div"),bottom:document.createElement("div")},Object.entries(o).forEach(([d,m])=>{const y=d,h=X(y);m.className=`${mt} ${mt}-${y} gjs-resizer-h gjs-cv-unscale`,m.style.cssText=`
|
|
14
14
|
pointer-events: all;
|
|
15
15
|
position: absolute;
|
|
16
16
|
z-index: 1;
|
|
17
17
|
cursor: ${h?"ns-resize":"ew-resize"};
|
|
18
18
|
${h?"left: 50%;":"top: 50%;"}
|
|
19
|
-
${
|
|
20
|
-
${
|
|
21
|
-
${
|
|
22
|
-
${
|
|
23
|
-
`,m.addEventListener("pointerdown",
|
|
19
|
+
${y==="left"?"left: 0px;":""}
|
|
20
|
+
${y==="right"?"right: 0px;":""}
|
|
21
|
+
${y==="top"?"top: 0px;":""}
|
|
22
|
+
${y==="bottom"?"bottom: 0px;":""}
|
|
23
|
+
`,m.addEventListener("pointerdown",E(y)),a.appendChild(m)}),!t.disableGapHandler&&!H(t)&&(c=document.createElement("div"),c.className=Wt,c.style.cssText=`
|
|
24
24
|
position: absolute;
|
|
25
25
|
background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
|
|
26
26
|
border-width: 2px;
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
pointer-events: all;
|
|
31
31
|
max-width: 3rem;
|
|
32
32
|
max-height: 3rem;
|
|
33
|
-
`,
|
|
33
|
+
`,c.addEventListener("pointerdown",S()),a.appendChild(c)),i.append(a),(l=e.getSpotsEl())==null||l.appendChild(i)},E=l=>d=>{if(!p)return;d.stopPropagation(),d.preventDefault(),r.startResize(p,l,d);const m=d.clientX,y=d.clientY;d.target.setPointerCapture(d.pointerId);const h=L=>{const G=n.Canvas.getZoomMultiplier(),N=(L.clientX-m)*G,W=(L.clientY-y)*G,it=X(l)?W:N;r.updateResizeByDelta(p,l,it)},I=()=>{r.finishResize(p),d.target.releasePointerCapture(d.pointerId),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",I)};document.addEventListener("pointermove",h),document.addEventListener("pointerup",I)},S=()=>l=>{if(!u)return;const d=u;l.stopPropagation(),l.preventDefault();const m=j(d,t),y=nt({componentRow:d,isVertical:m},t),h=l.clientX,I=l.clientY;l.target.setPointerCapture(l.pointerId);const L=N=>{const W=n.Canvas.getZoomMultiplier(),it=m?(N.clientY-I)*W:(N.clientX-h)*W;r.updateGapByDelta(d,it,y,m)},G=()=>{r.finishGapAdjust(d),l.target.releasePointerCapture(l.pointerId),document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",G)};document.addEventListener("pointermove",L),document.addEventListener("pointerup",G)},C=l=>{const d=l.component;if(!d||!i||(p=d,u=d.parent(),!u))return;const m=u;dt(i);const y=l.getStyle();a&&Object.assign(a.style,y);const h=j(m,t),I=At(h);if(Object.values(o).forEach(pt),I.forEach(G=>{if(Nt(d,G))return;const N=o[G];dt(N)}),T(t).gapHandler.isGapSupported()&&c&&Vt(d)){const G=nt({componentRow:m,isVertical:h},t);x(G,h,Ht(d))}},x=(l,d,m=!1)=>{const y=t.gapHandleSize,h=c.style;if(d){h.height=`${y}px`;const I=c.offsetHeight;m?(h.top=`-${(l+I)/2}px`,h.bottom=""):(h.bottom=`-${(l+I)/2}px`,h.top=""),h.width="50%",h.left="50%",h.transform="translateX(-50%)",h.cursor="row-resize"}else{h.width=`${y}px`;const I=c.offsetWidth;m?(h.left=`-${(l+I)/2}px`,h.right=""):(h.right=`-${(l+I)/2}px`,h.left=""),h.height="50%",h.top="50%",h.transform="translateY(-50%)",h.cursor="col-resize"}},v=()=>{i&&(pt(i),p=null,u=null)},b=()=>{e.removeSpots({type:s});const l=n.getSelected(),d=l==null?void 0:l.parent();l&&d&&f.isValidRelationship(d,l)?e.addSpot({type:s,component:l}):v()},w=()=>{const l=e.getSpots().filter(d=>d.type===s)[0];l&&C(l)},P=(l,d)=>{f.registerTypeRelationship(l,d)};n.onReady(()=>{g(),H(t)?P("mj-section","mj-column"):P(t.typeRow,t.typeColumn)});const z="component:toggled";return n.on(e.events.spot,w),n.on(z,b),()=>{n.off(e.events.spot,w),n.off(z,b)}}return It(function(n,t={}){const e={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...t},s=[Bt(n,e),Dt(n,e)],i=Kt(n,e),a=_t(n,e);vt({editor:n,licenseKey:e.licenseKey,plan:Ot,pluginName:Ft,cleanup:()=>{s.forEach(o=>o==null?void 0:o()),i(),a==null||a()}})})});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
.${
|
|
1
|
+
"use strict";const k="app.grapesjs.com",U="app-stage.grapesjs.com",B="app2.grapesjs.com",C="app-stage2.grapesjs.com",D=[k,B,U,C,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],W="license:check:start",F="license:check:end",G=()=>typeof window<"u",K=({isDev:s,isStage:c,isPlatform:r})=>`${s?"":`https://${c?U:k}`}/${r?"platform-api":"api"}`,Z=()=>{const s=G()&&window.location.hostname;return!!s&&(D.includes(s)||D.some(c=>s.endsWith(c)))};async function q({path:s,baseApiUrl:c,method:r="GET",headers:l={},params:a,body:m}){const f=`${c||K({isDev:!1,isStage:!1})}${s}`,b={method:r,headers:{"Content-Type":"application/json",...l}};m&&(b.body=JSON.stringify(m));const d=a?new URLSearchParams(a).toString():"",v=d?`?${d}`:"",n=await fetch(`${f}${v}`,b);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);return n.json()}var w=(s=>(s.free="free",s.startup="startup",s.business="business",s.enterprise="enterprise",s))(w||{});const H={[w.free]:0,[w.startup]:10,[w.business]:20,[w.enterprise]:30};function z(s){const c=s;return c.init=r=>l=>s(l,r),c}const J=s=>z(s);async function R({editor:s,plan:c,pluginName:r,licenseKey:l,onLicenseCheckResponse:a,cleanup:m}){let h="",f=!1;const b=Z(),d=n=>{console.warn("Cleanup plugin:",r,"Reason:",n),m()},v=(n={})=>{var A;const{error:p,sdkLicense:E}=n,y=(A=n.plan)==null?void 0:A.category;if(!(E||n.license)||p)d(p||"Invalid license");else if(y){const j=H[c],t=H[y];j>t&&d({pluginRequiredPlan:c,licensePlan:y})}};s.on(W,n=>{h=n==null?void 0:n.baseApiUrl,f=!0}),s.on(F,n=>{a==null||a(n),v(n)}),setTimeout(async()=>{if(!f){if(b)return;if(l){const n=await X({licenseKey:l,pluginName:r,baseApiUrl:h});a==null||a(n),n&&v(n)}else d("The `licenseKey` option not provided")}},2e3)}async function X(s){const{licenseKey:c,pluginName:r,baseApiUrl:l}=s;try{return(await q({baseApiUrl:l,path:`/sdk/${c||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(a){return console.error("Error during SDK license check:",a),!1}}const Y="gjs-plg-",Q="fsLightboxComponent",tt=w.startup,$="data-fslightbox",N="data-type",et="fslightbox-open",L="fslightbox",x={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>',imageLightbox:'<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>',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>'},st=function(s,c={}){const{Blocks:r,Components:l}=s,a="Lightbox",m=`${Y}${L}`,h={toolbarIconOpen:x.eye,block:{},defaultSrc:"https://placehold.co/300/777/white.png?text=Image",cdnScript:"https://cdn.jsdelivr.net/npm/fslightbox@3.4.2/index.js",...c},{block:f,toolbarIconOpen:b,defaultSrc:d}=h,v=function(t){const e=this,i="data-fslightbox",o=window,g=()=>{var M;const u=o.refreshFsLightbox;u==null||u();const O=e.getAttribute(i);if((M=o.fsLightboxInstances)==null||M[O],!o._isEditor)return;Array.from(document.querySelectorAll(`[${i}]`)).forEach(T=>{const S=T.onclick;T.onclick=function(I){I.preventDefault();const P=T;!P.__skipLb&&(S==null||S(I)),P.__skipLb=!0}})};if(o.refreshFsLightbox)g();else{const u=document.createElement("script");u.src=t.cdnScript,u.onload=g,document.head.appendChild(u)}},n=t=>({id:`${L}-open-lb`,label:b,command:()=>{const e=t.getView();e==null||e.toggleLightbox()}}),p="source-type",E={type:"radio",name:p,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:x.image},{id:"video",label:"Video",icon:x.video},{id:"el",label:"Custom Element",icon:x.external}],labelToTitle:!0},y={id:"href-image",name:"href",type:"file",label:"Source Image"},V={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},A={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},j={image:[y],video:[V],el:[A]};l.addType(L,{block:f&&{label:a,media:x.imageLightbox,category:"Extra",select:!0,...h.block},isComponent:t=>{var e;return(e=t.hasAttribute)==null?void 0:e.call(t,$)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:a,icon:x.imageLightbox,classes:m,draggable:(t,e)=>!e.is(L),attributes:{[$]:"lightbox",[N]:"image",href:d},components:{type:"image",src:d},script:v,cdnScript:h.cdnScript,"script-props":["attributes","cdnScript"],[p]:"image",traits:[E,{name:$,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(t,e){var o;const i=(o=e.target)==null?void 0:o.getView();i==null||i.toggleLightbox()}}],styles:`
|
|
2
|
+
.${m} {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
padding: 10px;
|
|
5
5
|
}
|
|
6
|
-
`},init(){const
|
|
6
|
+
`},init(){const t=[p].map(e=>`change:${e}`).join(" ");this.on(t,this.updateTraits),this.on(`change:${p}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(t,e,i){if(i.adjust)return;const g=this.get(p)==="video"?"video":"image";this.addAttributes({[N]:g,href:""})},adjustSourceType(){const t=this.get(p),e=this.getAttributes().href||"",i={adjust:!0};if(t==="video"){const o=e.includes("youtube.com")?"youtube":"video";this.addAttributes({[N]:o},i)}else t!=="el"&&e.startsWith("#")?this.set(p,"el",i):t==="image"&&this.addAttributes({[N]:"image"},i)},updateTraits(t={}){const{changed:e}=this,{init:i}=t;if(e[E.name]||i){this.removeTrait([y.name,V.name,A.name]);const o=this.get(p)||"image",g=this.getTraitIndex(p)+1;this.addTrait(j[o],{at:g})}},initToolbar(){if(!b)return;const{toolbar:t}=this,e=n(this);!t.find(o=>o.id===e.id)&&(t==null||t.unshift(e))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var T;const{em:t,el:e,model:i}=this,{Canvas:o}=t,g=i.getAttributes()[$],{defaultView:u,documentElement:O}=e.ownerDocument,_=(T=u.fsLightboxInstances)==null?void 0:T[g];if(O.classList.contains(et))_.close();else{e.__skipLb=!1;let S;_.props.onOpen=()=>{S=o.getSpots(),setTimeout(()=>o.removeSpots())},_.props.onClose=()=>{S.forEach(I=>o.addSpot(I.attributes))},e.click()}}}}),R({editor:s,plan:tt,licenseKey:h.licenseKey,pluginName:Q,cleanup:()=>{r.remove(L),l.removeType(L)}})},nt=J(st);module.exports=nt;
|