@grapesjs/studio-sdk-plugins 1.0.18 → 1.0.19-rc.1
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 +2 -2
- package/dist/accordionComponent/index.es.js +12 -12
- package/dist/accordionComponent/index.umd.js +2 -2
- package/dist/accordionComponent/shared.d.ts +3 -0
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +25 -25
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasEmptyState/shared.d.ts +3 -0
- package/dist/canvasFullSize/index.cjs.js +2 -2
- package/dist/canvasFullSize/index.es.js +26 -26
- package/dist/canvasFullSize/index.umd.js +2 -2
- package/dist/canvasFullSize/shared.d.ts +3 -0
- package/dist/canvasGridMode/commands/moveCommand.d.ts +2 -0
- package/dist/canvasGridMode/commands/resizeCommand.d.ts +6 -0
- package/dist/canvasGridMode/commands/updateCommand.d.ts +2 -0
- package/dist/canvasGridMode/index.cjs.d.ts +3 -0
- package/dist/canvasGridMode/index.cjs.js +26 -0
- package/dist/canvasGridMode/index.d.ts +3 -0
- package/dist/canvasGridMode/index.es.d.ts +3 -0
- package/dist/canvasGridMode/index.es.js +673 -0
- package/dist/canvasGridMode/index.umd.js +26 -0
- package/dist/canvasGridMode/shared.d.ts +3 -0
- package/dist/canvasGridMode/styleManager.d.ts +3 -0
- package/dist/canvasGridMode/types.d.ts +16 -0
- package/dist/canvasGridMode/typesSchema.d.ts +36 -0
- package/dist/canvasGridMode/utils.d.ts +150 -0
- package/dist/flexComponent/index.cjs.js +6 -6
- package/dist/flexComponent/index.es.js +40 -40
- package/dist/flexComponent/index.umd.js +6 -6
- package/dist/flexComponent/shared.d.ts +3 -0
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +28 -28
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/fsLightboxComponent/shared.d.ts +3 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +118 -98
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/googleFontsAssetProvider/utils.d.ts +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +160 -160
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/iconifyComponent/shared.d.ts +3 -0
- package/dist/index.cjs.d.ts +2 -0
- package/dist/index.cjs.js +87 -51
- package/dist/index.d.ts +2 -0
- package/dist/index.es.d.ts +2 -0
- package/dist/index.es.js +5629 -4929
- package/dist/index.umd.js +79 -43
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +81 -81
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/shared.d.ts +3 -0
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +45 -45
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/lightGalleryComponent/shared.d.ts +3 -0
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +63 -62
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/listPagesComponent/shared.d.ts +3 -0
- package/dist/presetPrintable/index.cjs.d.ts +3 -0
- package/dist/presetPrintable/index.cjs.js +12 -0
- package/dist/presetPrintable/index.d.ts +3 -0
- package/dist/presetPrintable/index.es.d.ts +3 -0
- package/dist/presetPrintable/index.es.js +215 -0
- package/dist/presetPrintable/index.umd.js +12 -0
- package/dist/presetPrintable/types.d.ts +17 -0
- package/dist/presetPrintable/typesSchema.d.ts +13 -0
- package/dist/presetPrintable/utils.d.ts +5 -0
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +437 -436
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/prosemirror/shared.d.ts +3 -0
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +37 -37
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/rteTinyMce/shared.d.ts +3 -0
- package/dist/swiperComponent/index.cjs.js +1 -1
- package/dist/swiperComponent/index.es.js +4 -4
- package/dist/swiperComponent/index.umd.js +3 -3
- package/dist/swiperComponent/shared.d.ts +3 -0
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +95 -94
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/tableComponent/shared.d.ts +3 -0
- package/dist/types.d.ts +2 -1
- package/dist/utils.d.ts +1 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +29 -28
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/dist/youtubeAssetProvider/shared.d.ts +3 -0
- package/package.json +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
(function(D,I){typeof exports=="object"&&typeof module<"u"?module.exports=I():typeof define=="function"&&define.amd?define(I):(D=typeof globalThis<"u"?globalThis:D||self,D.StudioSdkPlugins_canvasGridMode=I())})(this,function(){"use strict";const D="app.grapesjs.com",I="app-stage.grapesjs.com",U=[D,I,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],st="license:check:start",at="license:check:end",it=()=>typeof window<"u",lt=({isDev:t,isStage:e})=>`${t?"":`https://${e?I:D}`}/api`,ct=()=>{const t=it()&&window.location.hostname;return!!t&&(U.includes(t)||U.some(e=>t.endsWith(e)))};function Y(t){return typeof t=="function"}async function pt({path:t,baseApiUrl:e,method:r="GET",headers:o={},params:n,body:i}){const l=`${e||lt({isDev:!1,isStage:!1})}${t}`,c={method:r,headers:{"Content-Type":"application/json",...o}};i&&(c.body=JSON.stringify(i));const p=n?new URLSearchParams(n).toString():"",a=p?`?${p}`:"",d=await fetch(`${l}${a}`,c);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}var _=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(_||{});const H={[_.free]:0,[_.startup]:10,[_.business]:20,[_.enterprise]:30};function dt(t){const e=t;return e.init=r=>o=>t(o,r),e}const ut=t=>dt(t);async function gt({editor:t,plan:e,pluginName:r,licenseKey:o,cleanup:n}){let i="",s=!1;const l=ct(),c=a=>{console.warn("Cleanup plugin:",r,"Reason:",a),n()},p=(a={})=>{var S;const{error:d,sdkLicense:u}=a,g=(S=a.plan)==null?void 0:S.category;if(!(u||a.license)||d)c(d||"Invalid license");else if(g){const f=H[e],b=H[g];f>b&&c({pluginRequiredPlan:e,licensePlan:g})}};t.on(st,a=>{i=a==null?void 0:a.baseApiUrl,s=!0}),t.on(at,a=>{p(a)}),setTimeout(async()=>{if(!s){if(l)return;if(o){const a=await mt({licenseKey:o,pluginName:r,baseApiUrl:i});a&&p(a)}else c("The `licenseKey` option not provided")}},2e3)}async function mt(t){const{licenseKey:e,pluginName:r,baseApiUrl:o}=t;try{return(await pt({baseApiUrl:o,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:r}})).result||{}}catch(n){return console.error("Error during SDK license check:",n),!1}}const F="canvasGridMode",ft=_.startup,z="component-grid-mode",N="grid-mode",W="gjs-drag-grid-spot",X=`${W}__grid-item`,q=`${W}__grid-target`,K=`${W}__snapped`,yt=`${W}__container`,ht=()=>{const t="data-gjs-drag-grid-style",e=document,r="var(--gs-theme-cl-cmp-bg1, var(--gjs-color-highlight))",o="var(--gs-theme-cl-cmp-bg2, var(--gjs-color-blue))",n=e.querySelector(`style[${t}]`)||e.createElement("style");n.setAttribute(t,"true"),n.innerHTML=`
|
|
2
|
+
.${X} {
|
|
3
|
+
outline: 2px solid ${o};
|
|
4
|
+
background: ${r};
|
|
5
|
+
outline-offset: -2px;
|
|
6
|
+
border-radius: 3px;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
opacity: 0.1;
|
|
10
|
+
}
|
|
11
|
+
.${K} {
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: 100%;
|
|
14
|
+
outline: 2px solid ${o};
|
|
15
|
+
outline-offset: -2px;
|
|
16
|
+
position: absolute;
|
|
17
|
+
}
|
|
18
|
+
.${q} {
|
|
19
|
+
position: absolute;
|
|
20
|
+
z-index: -1;
|
|
21
|
+
background: ${r};
|
|
22
|
+
outline: 1px solid ${o};
|
|
23
|
+
outline-offset: -1px;
|
|
24
|
+
opacity: 0.35;
|
|
25
|
+
}
|
|
26
|
+
`,e.head.appendChild(n)};function J(t){const{editor:e,type:r}=t,o=$t(e,t.component),n=k(e,o.component);if(!vt(e,o,n,r))return{target:o,container:n,startScroll:B(e).scroll,shadowContainerEl:document.createElement("div"),shadowSnappedEl:document.createElement("div"),shadowTargetEl:document.createElement("div"),spot:e.Canvas.addSpot({type:N,component:n.component})}}function Q(t){const{editor:e,shadowTargetEl:r,shadowSnappedEl:o,shadowContainerEl:n,spotEl:i,target:s,container:l}=t,{Canvas:c}=e,p=e.config.stylePrefix;i==null||i.appendChild(n),n==null||n.appendChild(r),n==null||n.appendChild(o),wt(n,l),St(r,s,l),bt(o,s),Ct(n,l.el),s.el.style.opacity="0";const a=c.getSpots().filter(d=>d.type!==N);e.em.stopDefault({preserveSelected:!0}),c.removeSpots(a),c.startAutoscroll(),c.getBody().classList.add(`${p}is__grabbing`)}function Z(t){const{editor:e,shadowSnappedEl:r,shadowContainerEl:o,target:n,cancelled:i}=t,{Canvas:s}=e,l=e.config.stylePrefix,{component:c}=n;if(!i){const p=window.getComputedStyle(r);c.addStyle({"grid-area":p.gridArea,width:"",height:""})}n.el.style.opacity="",o.contains(r)&&(o==null||o.removeChild(r)),e.getModel().runDefault({preserveSelected:1}),s.stopAutoscroll(),s.getBody().classList.remove(`${l}is__grabbing`),s.removeSpots({type:N}),e.select(c)}function wt(t,{rows:e,columns:r}){const o=[];for(let n=0;n<r.length;n++){o[n]=[];for(let i=0;i<e.length;i++){const s=document.createElement("div");s.className=X,s.style.gridArea=`${i+1} / ${n+1}`,o[n][i]=s,t.appendChild(s)}}return o}function St(t,e,r){return t.className=q,t.style.top=`${e.offset.top-r.offset.top}px`,t.style.left=`${e.offset.left-r.offset.left}px`,t.style.width=`${e.offset.width+e.margin.left+e.margin.right}px`,t.style.height=`${e.offset.height+e.margin.top+e.margin.bottom}px`,t}function bt(t,e){const r=et(e.el,e.computedStyles);return t.className=K,t.style.gridArea=`${r.row.start} / ${r.column.start} / ${r.row.end} / ${r.column.end}`,t}function Ct(t,e){const r=window.getComputedStyle(e);t.className=yt,t.style.position="relative",t.style.display=r.display,t.style.gap=r.gap,t.style.padding=r.padding,t.style.border=r.border,t.style.gridTemplateColumns=r.gridTemplateColumns,t.style.gridTemplateRows=r.gridTemplateRows}function V(t,e){if(e){if(Array.isArray(e))return[...e].pop()}else return[...t.getSelectedAll()].pop();return e}function $t(t,e){const r=V(t,e),o=r.getEl(),n=window.getComputedStyle(o);return{component:r,el:o,offset:t.Canvas.offset(o),margin:{top:parseFloat(n.marginTop),right:parseFloat(n.marginRight),bottom:parseFloat(n.marginBottom),left:parseFloat(n.marginLeft)},computedStyles:n}}function k(t,e){const r=e.parent(),o=r.getEl(),n=window.getComputedStyle(o);return{component:r,el:o,offset:t.Canvas.offset(o),computedStyles:n,padding:{top:parseFloat(n.paddingTop),right:parseFloat(n.paddingRight),bottom:parseFloat(n.paddingBottom),left:parseFloat(n.paddingLeft)},columns:n.gridTemplateColumns.split(" ").map(s=>parseFloat(s)),rows:n.gridTemplateRows.split(" ").map(s=>parseFloat(s)),gap:{column:parseInt(n.columnGap),row:parseInt(n.rowGap)}}}function T(t,e,r,o,n=1){let i=0;for(let s=e;s<=t.length;s++){if(i+(t[s-1]+o)*n>r)return s;i+=o+t[s-1]}return t.length+1}function B(t){const{scrollY:e,scrollX:r}=t.Canvas.getWindow();return{scroll:{top:e,left:r}}}function vt(t,e,r,o){const n=i=>t.em.logWarning(i);return o==="draggable"&&e.component.get(o)===!1?(n(`[${F}] The element is not ${o}`),!0):r.computedStyles.display!=="grid"?(n(`[${F}] The container does not have style display:grid`),!0):!1}function O(t,e,r={}){const o=V(t,e),n=o==null?void 0:o.parent(),i=n==null?void 0:n.getEl();if(!n||!i)return!1;const{enableGrid:s}=r,l=window.getComputedStyle(i).display==="grid";return Y(s)?s({component:o,parent:n,isParentGrid:l}):l}const tt=t=>t.split(" ").map(e=>parseFloat(e));function et(t,e){const r=t.ownerDocument.defaultView,o=e||r.getComputedStyle(t),n=o.gridArea.split("/").some(w=>isNaN(parseInt(w.trim()))),i={isComputed:n,raw:o.gridArea};if(!n)return{...i,row:{start:parseInt(o.gridRowStart),end:parseInt(o.gridRowEnd)},column:{start:parseInt(o.gridColumnStart),end:parseInt(o.gridColumnEnd)}};const s=t.parentElement,l=r.getComputedStyle(s),c=parseFloat(l.columnGap)||0,p=parseFloat(l.rowGap)||0,a=tt(l.gridTemplateColumns),d=tt(l.gridTemplateRows),u=parseFloat(l.paddingLeft)||0,g=parseFloat(l.paddingTop)||0,h=s.getBoundingClientRect(),S=t.getBoundingClientRect(),f=(w,C,R,G,A)=>{let x=1,E=G+A;for(let P=0;P<C.length;P++){const M=C[P],L=E+M;if(w>=E&&w<L)return x;E=L+R,x++}return-1},b=f(S.left,a,c,h.left,u),v=f(S.right-1,a,c,h.left,u)+1,m=f(S.top,d,p,h.top,g),y=f(S.bottom-1,d,p,h.top,g)+1;return{...i,row:{start:m,end:y},column:{start:b,end:v}}}function Et(t){t.Commands.add(z,{stop(){},run(e,r,o={}){const n=J({editor:e,component:o.target,type:"draggable"});if(!n){this.stopCommand();return}const{spot:i,target:s,shadowContainerEl:l,shadowSnappedEl:c,shadowTargetEl:p,startScroll:a}=n;let{container:d}=n,u;new e.Utils.Dragger({doc:s.el.ownerDocument,onStart:()=>{u=setTimeout(()=>{Q({editor:e,shadowTargetEl:p,shadowSnappedEl:c,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:s,container:d}),d=k(e,s.component)},10)},onEnd:(h,S,{cancelled:f})=>{clearTimeout(u),Z({editor:e,shadowSnappedEl:c,shadowContainerEl:l,target:s,cancelled:f}),this.stopCommand(),e.em.set("_cmpDrag",1)},setPosition:({x:h,y:S})=>{const{scroll:f}=B(e),{columns:b,rows:v,gap:m,offset:y,padding:w}=d,{offset:C,margin:R}=s,G=C.top-y.top-w.top-R.top+S-a.top+f.top,A=C.left-y.left-w.left-R.left+h-a.left+f.left,x=Math.min(T(b,1,A,m.column,.5),b.length),E=Math.min(T(v,1,G,m.row,.5),v.length),P=Math.min(T(b,x,C.width,m.column)+1,b.length+1),M=Math.min(T(v,E,C.height,m.row)+1,v.length+1);c.style.gridArea=`${E} / ${x} / ${M} / ${P}`,p.style.top=`${G+w.top}px`,p.style.left=`${A+w.left}px`}}).start(o.event)}})}function xt(t,e){const r=J({editor:t,component:e.target,type:"resizable"});if(!r)return;const{onMove:o,onEnd:n}=e.options||{},{spot:i,target:s,shadowContainerEl:l,shadowSnappedEl:c,shadowTargetEl:p}=r;let{container:a}=r,d="",u;return{onStart:g=>{d=g.target.dataset.gjsHandler||"",u=setTimeout(()=>{Q({editor:t,shadowTargetEl:p,shadowSnappedEl:c,shadowContainerEl:l,spotEl:i.attributes.spotEl,target:s,container:a}),a=k(t,s.component)},10),t.trigger("component:resize",{...s,type:"start"})},onEnd:(g,h)=>{const{startDim:S,rectDim:f}=h.resizer,b=JSON.stringify(S)===JSON.stringify(f);clearTimeout(u),Z({editor:t,shadowSnappedEl:c,shadowContainerEl:l,target:s,cancelled:b}),n==null||n(g,h)},onMove:g=>{var rt;const h=g;if(((rt=h.target)==null?void 0:rt.nodeName)==="I")return;const{scroll:S}=B(t),f=et(c);let b=0,v=0,m=0,y=0;const w=s.margin.left,C=s.margin.top,R=s.margin.bottom,G=s.margin.right,{width:A,top:x,left:E,height:P}=s.offset,M=h.clientX,L=h.clientY,$={t:x-C,l:E-w,h:P+C+R,w:A+w+G};d.startsWith("t")?($.t=L-C,$.h=x+P+C+R-L):d.startsWith("b")&&($.h=L-x+C+R),d.endsWith("l")?($.l=M-w,$.w=E+A+w+G-M):d.endsWith("r")&&($.w=M-E+w+G),d.endsWith("l")&&(m=S.left,f.column.start=T(a.columns,1,$.l-a.offset.left-m-a.padding.left,a.gap.column,.5)),d.startsWith("t")&&(b=S.top,f.row.start=T(a.rows,1,$.t-a.offset.top+b-a.padding.top,a.gap.row,.5)),d.endsWith("r")&&(y=S.left,f.column.end=Math.max(T(a.columns,f.column.start,$.w-y,a.gap.column,.5),f.column.start+1)),d.startsWith("b")&&(v=S.top,f.row.end=Math.max(T(a.rows,f.row.start,$.h+v,a.gap.row,.5),f.row.start+1)),c.style.gridArea=`${f.row.start} / ${f.column.start} / ${f.row.end} / ${f.column.end}`,p.style.width=`${$.w+y+m}px`,p.style.height=`${$.h+v-b}px`,p.style.left=`${$.l-a.offset.left-m}px`,p.style.top=`${$.t-a.offset.top+b}px`,o==null||o(g)}}}const nt=["px","%","em","rem","vw","vh"],Tt=(t,e)=>{const r=t.Styles.getSectors().find(o=>!!o.getProperty(e));return{sector:r,property:r?r.getProperty(e):void 0}},Rt=(t,e)=>Tt(t,e),Gt=(t,{x:e,y:r,mergable:o}={})=>{const n={property:`${t}-x`,type:"integer",units:nt,...e},i={property:`${t}-y`,type:"integer",units:nt,...r};return{property:t,type:"composite",properties:[n,i],...o&&{fromStyle(s,{name:l,separator:c,property:p}){const[a,d]=p.getProperties(),[u,g]=(s[l]||"").split(c);return{[a.getId()]:s[a.getName()]||u||"",[d.getId()]:s[d.getName()]||g||u||""}},toStyle(s,{name:l,property:c}){const[p,a]=c.getProperties(),d=s[p.getId()],u=s[a.getId()];return{[l]:d===u?d:`${d} ${u}`}}}}},j={display:["grid"]};function Pt(t=""){const e=/^repeat\(\s*(\d+)\s*,\s*(.+)\s*\)$/i,r=/^minmax\(\s*(.+?)\s*,\s*(.+?)\s*\)$/i,o=t.match(e);if(!o)return null;const n=parseInt(o[1],10),i=o[2];let s=i,l=i;const c=i.match(r);return c&&(s=c[1],l=c[2]),{total:n,min:s===l?"":s,max:l}}function At(t={}){let e="",r="",o="",n="";const i=S=>S.split("/").map(f=>f.trim()).filter(Boolean),s=t["grid-area"]||"",l=t["grid-column"]||"",c=t["grid-row"]||"",p=i(s),a=i(l),d=i(c),u=p.length,g=a.length,h=d.length;return u===4?(o=p[0],e=p[1],n=p[2],r=p[3]):u===3?(o=p[0],e=p[1],n=p[2]):u===2?(o=p[0],e=p[1]):u===1&&(o=p[0]),g===2?(e=a[0],r=a[1]):g===1&&(e=a[0]),h===2?(o=d[0],n=d[1]):h===1&&(o=d[0]),{columnStart:e,columnEnd:r,rowStart:o,rowEnd:n}}function ot(t){const{property:e,label:r}=t,o="1",n="1fr";return{property:e,label:r,type:"composite",requires:j,generic:!0,properties:[{name:" ",property:`${e}-repeat`,type:"number",full:!0,min:1,default:"1"},{label:"Min size",property:`${e}-min`,type:"number",min:0,units:["px","%"],default:"0"},{label:"Max size",property:`${e}-max`,type:"number",min:1,units:["fr","px","%"],default:"1"}],fromStyle(i,s){const{name:l,property:c}=s,[p,a,d]=c.getProperties(),u=i[l],g=Pt(u),h=(g==null?void 0:g.max)??n;return{[p.id]:(g==null?void 0:g.total)??o,[a.id]:(g==null?void 0:g.min)??"",[d.id]:h===n?"":h}},toStyle(i,{name:s,property:l}){const[c,p,a]=l.getProperties(),d=i[c.id],u=i[p.id],g=i[a.id]||n,h=u&&g?`minmax(${u}, ${g})`:g;return{[s]:`repeat(${d||o}, ${h})`}}}}function Mt(t,e){if(!e.styleableGrid)return;const{property:r,...o}=Rt(t,"display");if(!r)return;const n=r.getOption("grid"),i=o.sector;n||r.addOption({id:"grid",label:"Grid"}),i.addProperty(ot({label:"Columns",property:"grid-template-columns"}),{}),i.addProperty(ot({label:"Rows",property:"grid-template-rows"}),{}),i.addProperty({id:"grid-gap",requires:j,...Gt("gap",{x:{id:"grid-row-gap",label:"Row",property:"row-gap",min:0,default:"0"},y:{id:"grid-column-gap",label:"Column",property:"column-gap",min:0,default:"0"},mergable:!0})},{}),i.addProperty({type:"composite",property:"grid-area",label:"Grid area",requiresParent:j,generic:!0,properties:[{label:"Row start",property:"grid-row-start",type:"integer",default:"auto"},{label:"Row end",property:"grid-row-end",type:"integer",default:"auto"},{label:"Column start",property:"grid-column-start",type:"integer",default:"auto"},{label:"Column end",property:"grid-column-end",type:"integer",default:"auto"}],fromStyle(s){const l=At(s);return{"grid-column-start":s["grid-column-start"]||l.columnStart,"grid-column-end":s["grid-column-end"]||l.columnEnd,"grid-row-start":s["grid-row-start"]||l.rowStart,"grid-row-end":s["grid-row-end"]||l.rowEnd}},toStyle(s,{name:l}){const c=s["grid-row-start"]||"auto",p=s["grid-row-end"]||"auto",a=s["grid-column-start"]||"auto",d=s["grid-column-end"]||"auto";return{[l]:`${c} / ${a} / ${p} / ${d}`}}},{})}return ut(function(t,e={}){const r={itemResizable:!0,...e},{Canvas:o,Commands:n,Components:i}=t,{itemResizable:s}=r,l=o.events,c=n.events,p=i.events,a=`${c.runBeforeCommand}tlb-move`,d=`${c.runBeforeCommand}resize`;let u;Et(t);const g=({options:m})=>{O(t,m.target,r)&&(t.runCommand(z,{...m}),m.abort=!0)},h=({options:m})=>{O(t,m.target,r)&&Object.assign(m.options,xt(t,m))},S=()=>{const m=o.getSpots({type:N}).pop();if(!m)return;let y=m.attributes.spotEl;y||(y=document.createElement("div"),y.className=W,m.set({spotEl:y})),Object.entries(m.getStyle()).forEach(([w,C])=>y.style.setProperty(w,C)),u==null||u.appendChild(y)},f=({spot:m})=>{const y=m.attributes.spotEl;m.type!==N||!y||u==null||u.removeChild(y)};if(s){const m=y=>{const w=Y(s)?s({component:y}):s;return typeof w=="boolean"?w:{tl:!1,tc:!1,tr:!1,cl:!1,cr:!1,bl:!1,bc:!1,br:!1,...w}};t.on(p.resizeInit,y=>{const{component:w}=y;if(O(t,w,r)){const C=m(w);y.resizable=C}})}const b=[[a,g],[d,h],[l.spot,S],[l.spotRemove,f]];b.forEach(([m,y])=>{t.on(m,y)}),t.onReady(()=>{u=o.getSpotsEl(),ht(),Mt(t,r)});const v=()=>{delete t.Commands.commands[z],b.forEach(([m,y])=>{t.off(m,y)})};gt({editor:t,licenseKey:r.licenseKey,plan:ft,pluginName:F,cleanup:v})})});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CanvasSpotProps, ResizerOptions } from 'grapesjs';
|
|
2
|
+
import { CanvasGridModeOptions as CanvasGridModeOptionsSchema } from './typesSchema';
|
|
3
|
+
import { Component } from '../types';
|
|
4
|
+
export interface CanvasGridModeOptions extends Omit<CanvasGridModeOptionsSchema, 'enableGrid' | 'itemResizable'> {
|
|
5
|
+
enableGrid?: (props: {
|
|
6
|
+
component: Component;
|
|
7
|
+
parent: Component;
|
|
8
|
+
isParentGrid?: boolean;
|
|
9
|
+
}) => boolean;
|
|
10
|
+
itemResizable?: boolean | ((props: {
|
|
11
|
+
component: Component;
|
|
12
|
+
}) => boolean | ResizerOptions);
|
|
13
|
+
}
|
|
14
|
+
export interface SpotGridDragProps extends CanvasSpotProps {
|
|
15
|
+
spotEl?: HTMLElement;
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SDKPluginOptions } from '../utils';
|
|
2
|
+
export interface CanvasGridModeOptions extends SDKPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Provide a custom logic to enable the grid mode.
|
|
5
|
+
* @examples
|
|
6
|
+
* enableGrid: ({ component, isParentGrid }) => {
|
|
7
|
+
* if (isParentGrid && component.is('image')) {
|
|
8
|
+
* return true; // enable grid mode only for images
|
|
9
|
+
* }
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
enableGrid?: '__fn__';
|
|
13
|
+
/**
|
|
14
|
+
* Make grid items resizable when selected. Could also be a function for custom logic.
|
|
15
|
+
* @default true
|
|
16
|
+
* @examples
|
|
17
|
+
* itemResizable: ({ component }) => {
|
|
18
|
+
* if (component.is('text')) {
|
|
19
|
+
* // Make the text component resizable only on the right and left sides.
|
|
20
|
+
* return { cr: true, cl: true };
|
|
21
|
+
* } else if (component.is('image')) {
|
|
22
|
+
* // Disable resizing for images
|
|
23
|
+
* return false;
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* // Enable resizing for all other components
|
|
27
|
+
* return true;
|
|
28
|
+
* }
|
|
29
|
+
*/
|
|
30
|
+
itemResizable?: object;
|
|
31
|
+
/**
|
|
32
|
+
* Allow to edit grid properties in Style Manager.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
styleableGrid?: boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Component, Editor } from '../types';
|
|
2
|
+
import { CanvasGridModeOptions, SpotGridDragProps } from './types';
|
|
3
|
+
export declare const COMMAND_DRAG_GRID = "component-grid-mode";
|
|
4
|
+
export declare const SPOT_TYPE_GRID = "grid-mode";
|
|
5
|
+
export declare const clsSpotGridDrag = "gjs-drag-grid-spot";
|
|
6
|
+
export declare const clsSpotGridDragCell = "gjs-drag-grid-spot__grid-item";
|
|
7
|
+
export declare const clsSpotGridDragTarget = "gjs-drag-grid-spot__grid-target";
|
|
8
|
+
export declare const clsSpotGridDragSnapped = "gjs-drag-grid-spot__snapped";
|
|
9
|
+
export declare const clsSpotGridDragContainer = "gjs-drag-grid-spot__container";
|
|
10
|
+
export declare const createDefaultSpotStyleEl: () => void;
|
|
11
|
+
export declare function onGridDragInit(props: {
|
|
12
|
+
editor: Editor;
|
|
13
|
+
component: Component | Component[];
|
|
14
|
+
type: string;
|
|
15
|
+
}): {
|
|
16
|
+
target: {
|
|
17
|
+
component: Component;
|
|
18
|
+
el: HTMLElement;
|
|
19
|
+
offset: {
|
|
20
|
+
top: number;
|
|
21
|
+
left: number;
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
margin: {
|
|
26
|
+
top: number;
|
|
27
|
+
right: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
};
|
|
31
|
+
computedStyles: CSSStyleDeclaration;
|
|
32
|
+
};
|
|
33
|
+
container: {
|
|
34
|
+
component: Component;
|
|
35
|
+
el: HTMLElement;
|
|
36
|
+
offset: {
|
|
37
|
+
top: number;
|
|
38
|
+
left: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
computedStyles: CSSStyleDeclaration;
|
|
43
|
+
padding: {
|
|
44
|
+
top: number;
|
|
45
|
+
right: number;
|
|
46
|
+
bottom: number;
|
|
47
|
+
left: number;
|
|
48
|
+
};
|
|
49
|
+
columns: number[];
|
|
50
|
+
rows: number[];
|
|
51
|
+
gap: {
|
|
52
|
+
column: number;
|
|
53
|
+
row: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
startScroll: {
|
|
57
|
+
top: number;
|
|
58
|
+
left: number;
|
|
59
|
+
};
|
|
60
|
+
shadowContainerEl: HTMLDivElement;
|
|
61
|
+
shadowSnappedEl: HTMLDivElement;
|
|
62
|
+
shadowTargetEl: HTMLDivElement;
|
|
63
|
+
spot: import('grapesjs').CanvasSpot<SpotGridDragProps>;
|
|
64
|
+
} | undefined;
|
|
65
|
+
export declare function onGridDragStart(props: {
|
|
66
|
+
editor: Editor;
|
|
67
|
+
shadowTargetEl: HTMLElement;
|
|
68
|
+
shadowSnappedEl: HTMLElement;
|
|
69
|
+
shadowContainerEl: HTMLElement;
|
|
70
|
+
spotEl: HTMLElement | undefined;
|
|
71
|
+
target: ReturnType<typeof getTarget>;
|
|
72
|
+
container: ReturnType<typeof getContainer>;
|
|
73
|
+
}): void;
|
|
74
|
+
export declare function onGridDragEnd(props: {
|
|
75
|
+
editor: Editor;
|
|
76
|
+
shadowSnappedEl: HTMLElement;
|
|
77
|
+
shadowContainerEl: HTMLElement;
|
|
78
|
+
target: ReturnType<typeof getTarget>;
|
|
79
|
+
cancelled?: boolean;
|
|
80
|
+
}): void;
|
|
81
|
+
export declare function setShadowCells(containerEl: HTMLElement, { rows, columns }: {
|
|
82
|
+
rows: number[];
|
|
83
|
+
columns: number[];
|
|
84
|
+
}): HTMLElement[][];
|
|
85
|
+
export declare function setShadowTargetStyle(el: HTMLElement, target: ReturnType<typeof getTarget>, container: ReturnType<typeof getContainer>): HTMLElement;
|
|
86
|
+
export declare function setShadowSnappedStyle(el: HTMLElement, target: ReturnType<typeof getTarget>): HTMLElement;
|
|
87
|
+
export declare function setShadowContainerStyle(el: HTMLElement, containerEl: HTMLElement): void;
|
|
88
|
+
export declare function findTarget(editor: Editor, target?: Component | Component[]): Component;
|
|
89
|
+
export declare function getTarget(editor: Editor, target?: Component | Component[]): {
|
|
90
|
+
component: Component;
|
|
91
|
+
el: HTMLElement;
|
|
92
|
+
offset: {
|
|
93
|
+
top: number;
|
|
94
|
+
left: number;
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
};
|
|
98
|
+
margin: {
|
|
99
|
+
top: number;
|
|
100
|
+
right: number;
|
|
101
|
+
bottom: number;
|
|
102
|
+
left: number;
|
|
103
|
+
};
|
|
104
|
+
computedStyles: CSSStyleDeclaration;
|
|
105
|
+
};
|
|
106
|
+
export declare function getContainer(editor: Editor, target: Component): {
|
|
107
|
+
component: Component;
|
|
108
|
+
el: HTMLElement;
|
|
109
|
+
offset: {
|
|
110
|
+
top: number;
|
|
111
|
+
left: number;
|
|
112
|
+
width: number;
|
|
113
|
+
height: number;
|
|
114
|
+
};
|
|
115
|
+
computedStyles: CSSStyleDeclaration;
|
|
116
|
+
padding: {
|
|
117
|
+
top: number;
|
|
118
|
+
right: number;
|
|
119
|
+
bottom: number;
|
|
120
|
+
left: number;
|
|
121
|
+
};
|
|
122
|
+
columns: number[];
|
|
123
|
+
rows: number[];
|
|
124
|
+
gap: {
|
|
125
|
+
column: number;
|
|
126
|
+
row: number;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
export declare function getGridPosition(items: number[], start: number, minSize: number, gap: number, fraction?: number): number;
|
|
130
|
+
export declare function getWindowScroll(editor: Editor): {
|
|
131
|
+
scroll: {
|
|
132
|
+
top: number;
|
|
133
|
+
left: number;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export declare function shouldTerminate(editor: Editor, target: ReturnType<typeof getTarget>, container: ReturnType<typeof getContainer>, prop: string): boolean;
|
|
137
|
+
export declare function isGrid(editor: Editor, target?: Component | Component[], pluginOptions?: CanvasGridModeOptions): boolean;
|
|
138
|
+
export declare function findComponentInGrid(editor: Editor, target: Component, opts?: CanvasGridModeOptions): Component | undefined;
|
|
139
|
+
export declare function getGridItemArea(gridItemEl: HTMLElement, style?: CSSStyleDeclaration): {
|
|
140
|
+
row: {
|
|
141
|
+
start: number;
|
|
142
|
+
end: number;
|
|
143
|
+
};
|
|
144
|
+
column: {
|
|
145
|
+
start: number;
|
|
146
|
+
end: number;
|
|
147
|
+
};
|
|
148
|
+
isComputed: boolean;
|
|
149
|
+
raw: string;
|
|
150
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";const de="app.grapesjs.com",ue="app-stage.grapesjs.com",ie=[de,ue,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?ue:de}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(ie.includes(n)||ie.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const g=i?new URLSearchParams(i).toString():"",p=g?`?${g}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),he=(n=>(n.web="web",n.email="email",n))(he||{});const ae={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},g=(p={})=>{var S;const{error:u,sdkLicense:f}=p,v=(S=p.plan)==null?void 0:S.category;if(!(f||p.license)||u)c(u||"Invalid license");else if(v){const I=ae[e],R=ae[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{g(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&g(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const ge=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ne))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),fe="gjs-plg-",ne="data-type-role",
|
|
1
|
+
"use strict";const de="app.grapesjs.com",ue="app-stage.grapesjs.com",ie=[de,ue,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Se="license:check:start",be="license:check:end",Ce=()=>typeof window<"u",Pe=({isDev:n,isStage:e})=>`${n?"":`https://${e?ue:de}`}/api`,ze=()=>{const n=Ce()&&window.location.hostname;return!!n&&(ie.includes(n)||ie.some(e=>n.endsWith(e)))};function xe(n){return typeof n=="function"}async function we({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:i,body:a}){const l=`${e||Pe({isDev:!1,isStage:!1})}${n}`,c={method:t,headers:{"Content-Type":"application/json",...s}};a&&(c.body=JSON.stringify(a));const g=i?new URLSearchParams(i).toString():"",p=g?`?${g}`:"",u=await fetch(`${l}${p}`,c);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var $=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))($||{}),he=(n=>(n.web="web",n.email="email",n))(he||{});const ae={[$.free]:0,[$.startup]:10,[$.business]:20,[$.enterprise]:30};function ve(n){const e=n;return e.init=t=>s=>n(s,t),e}const Ie=n=>ve(n);async function Re({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:i}){let a="",o=!1;const l=ze(),c=p=>{console.warn("Cleanup plugin:",t,"Reason:",p),i()},g=(p={})=>{var S;const{error:u,sdkLicense:f}=p,v=(S=p.plan)==null?void 0:S.category;if(!(f||p.license)||u)c(u||"Invalid license");else if(v){const I=ae[e],R=ae[v];I>R&&c({pluginRequiredPlan:e,licensePlan:v})}};n.on(Se,p=>{a=p==null?void 0:p.baseApiUrl,o=!0}),n.on(be,p=>{g(p)}),setTimeout(async()=>{if(!o){if(l)return;if(s){const p=await Ee({licenseKey:s,pluginName:t,baseApiUrl:a});p&&g(p)}else c("The `licenseKey` option not provided")}},2e3)}async function Ee(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await we({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const ge=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,ne))===n},Ge=(...n)=>e=>n.some(t=>e.is(t)),Te=(...n)=>(e,t)=>n.some(s=>t.is(s)),fe="gjs-plg-",ne="data-type-role",N=class N{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):se(e.componentColumn,N.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.addStyle({[N.CSS_FLEX_BASIS]:i},{partial:a})}}};N.CSS_FLEX_BASIS="flex-basis";let K=N;const j=class j{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):se(e.componentRow,j.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:i,partial:a}=e;s.addStyle({[j.CSS_GAP]:i},{partial:a})}}};j.CSS_GAP="gap";let J=j;const Y=class Y{constructor(e){this.config=e}getParentSize(e){var a;if((a=this.config)!=null&&a.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();return i?s?i.clientHeight:i.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=se(e.componentRow,Y.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Y.CSS_FLEX_DIRECTION="flex-direction";let q=Y;const _=class _{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(_.MJML_COLUMN_TYPE)){const a=t.getAttributes().width;if(a&&(a.includes("%")||!isNaN(parseFloat(a))))return parseFloat(a);const o=t.parent();return 100/(o?o.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:i,partial:a}=e;s.is(_.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(i)}%`},{partial:a})}}};_.MJML_COLUMN_TYPE="mj-column";let Z=_;const U=class U{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(U.MJML_SECTION_TYPE)){const i=t.getAttributes();if(i&&i.padding)return parseInt(i.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};U.MJML_SECTION_TYPE="mj-section";let Q=U;class Le{constructor(e){this.config=e}getParentSize(e){var o;if((o=this.config)!=null&&o.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,i=t.getEl();if(!i)return 0;let a=i;if(i.tagName!=="TABLE"){const l=i.querySelectorAll("table");l.length&&(a=l[0])}return s?a.clientHeight:a.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class A{constructor(){this.handlerCache=new Map}static getInstance(){return A.instance||(A.instance=new A),A.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(H(e)?this.handlerCache.set(t,{sizeHandler:new Z(e),gapHandler:new Q(e),parentSizeHandler:new Le(e)}):this.handlerCache.set(t,{sizeHandler:new K(e),gapHandler:new J(e),parentSizeHandler:new q(e)})),this.handlerCache.get(t)}}function G(n){return A.getInstance().getHandlers(n)}const oe=n=>{n.style.display="none"},re=n=>{n.style.display="block"},V=n=>+parseFloat(`${n}`).toFixed(2),H=n=>n.projectType===he.email,k=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},$e=n=>n?["top","bottom"]:["left","right"],Ae=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},He=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},Ve=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},Me=(n,e,t,s)=>{const a=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return a>=0&&a<s?a:-1},O=n=>n==="top"||n==="bottom",Ne=(n,e)=>!!(Ae(n)&&(e==="left"||e==="top")||He(n)&&(e==="right"||e==="bottom")),je=n=>{const e=n.parent();return e?e.components().models.length>1:!1},ce=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,se=(n,e,t=!1)=>{const s=!t,i=n.getEl();if(!i)return s?0:"";const o=window.getComputedStyle(i)[e]||"";if(s){let l;return typeof o=="string"?(l=parseFloat(o.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(o)||0,l}return o},le=(n,e,t)=>{const s=ee({componentRow:n,isVertical:e},t),i=n.components().models;return s*(i.length-1)},F=(n,e)=>G(e).parentSizeHandler.isLayoutVertical({componentRow:n}),B=(n,e)=>G(e).sizeHandler.getSize(n),ee=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=G(e);if(!t.isGapSupported())return 0;const i=t.getGap(n),a=s.getParentSize(n);return i/100*a},te=(n,e)=>G(e).parentSizeHandler.getParentSize(n),M=(n,e)=>{G(e).sizeHandler.setSize(n)},me=(n,e)=>{const t=B(n,e);M({...n,sizeValue:`${t}%`,partial:!1},e)},ye=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=G(e);t.isGapSupported()&&t.setGap(n)},_e=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,i={componentRow:n,isVertical:F(n,e)};s.map(a=>me({...i,componentColumn:a},e)),ye({...i,gapValue:String(t),partial:!1},e)};function Fe(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:i,blocks:a}=e;if(a===!1||H(e))return;const o=u=>({type:i,components:u.map(f=>({type:s,style:{"flex-basis":`${f}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
2
2
|
${u.map(f=>`<div style="flex-basis: ${f}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
3
|
-
</div>`,c=(u,f)=>({id:`flex-row-${f.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(f),content:o(f)}),g=[c("1 Column",[100]),c("2 Columns 50/50",[50,50]),c("2 Columns 25/75",[25,75]),c("2 Columns 75/25",[75,25]),c("3 Columns",[33.33,33.33,33.33]),c("3 Columns 50/25/25",[50,25,25]),c("3 Columns 25/50/25",[25,50,25]),c("3 Columns 25/25/50",[25,25,50]),c("4 Columns",[25,25,25,25]),c("5 Columns",[20,20,20,20,20])],p=xe(a)?a({blocks:g}):g;return p.forEach(u=>t.add(u.id,u)),()=>{p.forEach(u=>t.remove(u.id))}}const Be=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=e,o=`${fe}${i}`,c=!!i&&!!t.getType(i)&&!a;if(!(!i||c||
|
|
3
|
+
</div>`,c=(u,f)=>({id:`flex-row-${f.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(f),content:o(f)}),g=[c("1 Column",[100]),c("2 Columns 50/50",[50,50]),c("2 Columns 25/75",[25,75]),c("2 Columns 75/25",[75,25]),c("3 Columns",[33.33,33.33,33.33]),c("3 Columns 50/25/25",[50,25,25]),c("3 Columns 25/50/25",[25,50,25]),c("3 Columns 25/25/50",[25,25,50]),c("4 Columns",[25,25,25,25]),c("5 Columns",[20,20,20,20,20])],p=xe(a)?a({blocks:g}):g;return p.forEach(u=>t.add(u.id,u)),()=>{p.forEach(u=>t.remove(u.id))}}const Be=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeColumn:a}=e,o=`${fe}${i}`,c=!!i&&!!t.getType(i)&&!a;if(!(!i||c||H(e)))return t.addType(i,{isComponent:ge(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:Te(s),attributes:{[ne]:i},styles:`
|
|
4
4
|
.${o} {
|
|
5
5
|
flex-grow: 1;
|
|
6
6
|
}
|
|
7
|
-
`}}}),()=>{t.removeType(i)}},De=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeRow:a}=e,o=`${fe}${s}`,c=!!s&&!!t.getType(s)&&!a;if(!(!s||c||
|
|
7
|
+
`}}}),()=>{t.removeType(i)}},De=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:i,extendTypeRow:a}=e,o=`${fe}${s}`,c=!!s&&!!t.getType(s)&&!a;if(!(!s||c||H(e)))return t.addType(s,{isComponent:ge(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:{[ne]:s},droppable:Ge(i),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.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
|
-
`}}}),()=>{t.removeType(s)}};class
|
|
13
|
+
`}}}),()=>{t.removeType(s)}},ke="flexComponent",Oe=$.startup;class Xe{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const s=e.get("type"),i=t.get("type");return this.typeRelationships.has(s)?this.typeRelationships.get(s).has(i):!1}}class Ye{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,s){const{opts:i}=this,a=this.getState(e);a.direction=t,a.startX=s.clientX,a.startY=s.clientY,a.resizing=!0,a.lastSnappedPercent=void 0;const o=e.parent();if(!o||!this.registry.isValidRelationship(o,e))return;a.snapEnabled=o.get("snap")??i.snapEnabled,a.snapDivisions=o.get("snap-divisions")??i.snapDivisions??12;const l=o.components().models,c=l.findIndex(f=>f.cid===e.cid),g=F(o,i),p=Me(c,t,g,l.length);p!==-1&&(a.adjacentIdx=p);const u={componentColumn:e,componentRow:o,isVertical:g};if(a.startPercent=B(u,i),typeof a.adjacentIdx<"u"){const f=l[a.adjacentIdx];a.neighborStartPercent=B({...u,componentColumn:f},i)}}updateResizeByDelta(e,t,s){const i=this.getState(e),a=e.parent();!i.resizing||!a||(i.snapEnabled?this.updateSnapResize(e,t,s):this.updateContinuesResize(e,t,s))}finishResize(e){const t=e.parent(),s=t==null?void 0:t.components().models,i={componentRow:t,isVertical:!!t&&F(t,this.opts)};s==null||s.forEach(a=>me({...i,componentColumn:a},this.opts)),this.clearState(e)}updateContinuesResize(e,t,s){const i=this.getState(e),a=e.parent(),{opts:o}=this;if(!a)return;const l=o.minItemPercent??0,c=O(t),g=te({componentRow:a,isVertical:c},o),p=le(a,c,this.opts),f=100-p/g*100,v=s/(g-p)*f,{startPercent:P=0,neighborStartPercent:S=0}=i,I={componentRow:a,isVertical:c,componentColumn:e,partial:!0},R=ce(t,s)?P+Math.abs(v):P-Math.abs(v);if(typeof i.adjacentIdx<"u"){const z=a.components().models[i.adjacentIdx],x=P+S,b=x-l,r=Math.min(b,Math.max(l,R)),d=x-r;M({...I,sizeValue:`${V(r)}%`},o),M({...I,componentColumn:z,sizeValue:`${V(d)}%`},o)}else{const z=Math.max(l,Math.min(f,R));M({...I,sizeValue:`${V(z)}%`},o)}}updateSnapResize(e,t,s){const i=this.getState(e),a=e.parent(),o=O(t),l=te({componentRow:a,isVertical:o},this.opts),c=le(a,o,this.opts),g=l-c,p=s/g*100,u=ce(t,s),{startPercent:f=0,snapDivisions:v=12}=i,P=u?f+Math.abs(p):f-Math.abs(p),S=100/v,I=Math.floor(P/S)*S,R=Math.ceil(P/S)*S,z=Math.abs(R-P),x=Math.abs(P-I),b=S*.2,C=z<x?R:I;if(C>0&&C<100&&(z<b||x<b)&&i.lastSnappedPercent!==C){i.lastSnappedPercent=C;let m=Math.abs(C-f)/100*g;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(m=-m),this.updateContinuesResize(e,t,m)}else z>=b&&x>=b&&(i.lastSnappedPercent=void 0)}}class Ue{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s}updateGapByDelta(e,t,s,i){if(!this.registry.isGapAdjustableParent(e))return;const{opts:a}=this,o=Math.max(0,s+t),l=te({componentRow:e,isVertical:i},a),c=o/l*100,g=e.components().models,p=g.length-1,u={componentRow:e,isVertical:i},f=g.reduce((b,C)=>b+B({...u,componentColumn:C},a),0),P=100-c*p,S=a.minItemPercent||5;if(P<S*g.length)return;const R=100-p*c,z=f-R,x={componentRow:e,isVertical:i,partial:!0};g.map(b=>{const C=B({...u,componentColumn:b},a),r=C-C/f*z;M({...x,componentColumn:b,sizeValue:`${V(r)}%`},a)}),ye({...x,gapValue:`${V(c)}%`},a)}finishGapAdjust(e){_e(e,this.opts)}}class We{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeHandler=new Ye(e,t,s),this.gapHandler=new Ue(e,t,s)}startResize(e,t,s){this.resizeHandler.startResize(e,t,s)}updateResizeByDelta(e,t,s){this.resizeHandler.updateResizeByDelta(e,t,s)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,s,i){this.gapHandler.updateGapByDelta(e,t,s,i)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const X="gs-flex-spots",pe=`${X}__handle-size`,Ke=`${X}__handle-gap`;function Je(n,e){const{Canvas:t}=n,s="flex-resize-spot";let i,a,o,l,c=null,g=null;const p=new Xe,u=new We(n,p,e),f=()=>{var r;i=document.createElement("div"),i.className=X,i.style.display="none",a=document.createElement("div"),a.className=`${X}__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=O(y);m.className=`${pe} ${pe}-${y} gjs-resizer-h gjs-cv-unscale`,m.style.cssText=`
|
|
14
14
|
pointer-events: all;
|
|
15
15
|
position: absolute;
|
|
16
16
|
z-index: 1;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
${y==="right"?"right: 0px;":""}
|
|
21
21
|
${y==="top"?"top: 0px;":""}
|
|
22
22
|
${y==="bottom"?"bottom: 0px;":""}
|
|
23
|
-
`,m.addEventListener("pointerdown",v(y)),a.appendChild(m)}),!e.disableGapHandler&&!
|
|
23
|
+
`,m.addEventListener("pointerdown",v(y)),a.appendChild(m)}),!e.disableGapHandler&&!H(e)&&(l=document.createElement("div"),l.className=Ke,l.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
|
-
`,l.addEventListener("pointerdown",P()),a.appendChild(l)),i.append(a),(r=t.getSpotsEl())==null||r.appendChild(i)},v=r=>d=>{if(!c)return;k(n,!0),d.stopPropagation(),d.preventDefault(),u.startResize(c,r,d);const m=d.clientX,y=d.clientY;d.target.setPointerCapture(d.pointerId);const h=T=>{const E=n.Canvas.getZoomMultiplier(),L=(T.clientX-m)*E,D=(T.clientY-y)*E,W=O(r)?D:L;u.updateResizeByDelta(c,r,W)},w=()=>{k(n,!1),u.finishResize(c),d.target.releasePointerCapture(d.pointerId),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w)};document.addEventListener("pointermove",h),document.addEventListener("pointerup",w)},P=()=>r=>{if(!g)return;const d=g;k(n,!0),r.stopPropagation(),r.preventDefault();const m=F(d,e),y=ee({componentRow:d,isVertical:m},e),h=r.clientX,w=r.clientY;r.target.setPointerCapture(r.pointerId);const T=L=>{const D=n.Canvas.getZoomMultiplier(),W=m?(L.clientY-w)*D:(L.clientX-h)*D;u.updateGapByDelta(d,W,y,m)},E=()=>{k(n,!1),u.finishGapAdjust(d),r.target.releasePointerCapture(r.pointerId),document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",E)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",E)},S=r=>{const d=r.component;if(!d||!i||(c=d,g=d.parent(),!g))return;const m=g;re(i);const y=r.getStyle();a&&Object.assign(a.style,y);const h=F(m,e),w=$e(h);if(Object.values(o).forEach(oe),w.forEach(E=>{if(
|
|
33
|
+
`,l.addEventListener("pointerdown",P()),a.appendChild(l)),i.append(a),(r=t.getSpotsEl())==null||r.appendChild(i)},v=r=>d=>{if(!c)return;k(n,!0),d.stopPropagation(),d.preventDefault(),u.startResize(c,r,d);const m=d.clientX,y=d.clientY;d.target.setPointerCapture(d.pointerId);const h=T=>{const E=n.Canvas.getZoomMultiplier(),L=(T.clientX-m)*E,D=(T.clientY-y)*E,W=O(r)?D:L;u.updateResizeByDelta(c,r,W)},w=()=>{k(n,!1),u.finishResize(c),d.target.releasePointerCapture(d.pointerId),document.removeEventListener("pointermove",h),document.removeEventListener("pointerup",w)};document.addEventListener("pointermove",h),document.addEventListener("pointerup",w)},P=()=>r=>{if(!g)return;const d=g;k(n,!0),r.stopPropagation(),r.preventDefault();const m=F(d,e),y=ee({componentRow:d,isVertical:m},e),h=r.clientX,w=r.clientY;r.target.setPointerCapture(r.pointerId);const T=L=>{const D=n.Canvas.getZoomMultiplier(),W=m?(L.clientY-w)*D:(L.clientX-h)*D;u.updateGapByDelta(d,W,y,m)},E=()=>{k(n,!1),u.finishGapAdjust(d),r.target.releasePointerCapture(r.pointerId),document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",E)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",E)},S=r=>{const d=r.component;if(!d||!i||(c=d,g=d.parent(),!g))return;const m=g;re(i);const y=r.getStyle();a&&Object.assign(a.style,y);const h=F(m,e),w=$e(h);if(Object.values(o).forEach(oe),w.forEach(E=>{if(Ne(d,E))return;const L=o[E];re(L)}),G(e).gapHandler.isGapSupported()&&l&&je(d)){const E=ee({componentRow:m,isVertical:h},e);I(E,h,Ve(d))}},I=(r,d,m=!1)=>{const y=e.gapHandleSize,h=l.style;if(d){h.height=`${y}px`;const w=l.offsetHeight;m?(h.top=`-${(r+w)/2}px`,h.bottom=""):(h.bottom=`-${(r+w)/2}px`,h.top=""),h.width="50%",h.left="50%",h.transform="translateX(-50%)",h.cursor="row-resize"}else{h.width=`${y}px`;const w=l.offsetWidth;m?(h.left=`-${(r+w)/2}px`,h.right=""):(h.right=`-${(r+w)/2}px`,h.left=""),h.height="50%",h.top="50%",h.transform="translateY(-50%)",h.cursor="col-resize"}},R=()=>{i&&(oe(i),c=null,g=null)},z=()=>{t.removeSpots({type:s});const r=n.getSelected(),d=r==null?void 0:r.parent();r&&d&&p.isValidRelationship(d,r)?t.addSpot({type:s,component:r}):R()},x=()=>{const r=t.getSpots().filter(d=>d.type===s)[0];r&&S(r)},b=(r,d)=>{p.registerTypeRelationship(r,d)};n.onReady(()=>{f(),H(e)?b("mj-section","mj-column"):b(e.typeRow,e.typeColumn)});const C="component:toggled";return n.on(t.events.spot,x),n.on(C,z),()=>{n.off(t.events.spot,x),n.off(C,z)}}const qe=function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},s=[De(n,t),Be(n,t)],i=Je(n,t),a=Fe(n,t);Re({editor:n,licenseKey:t.licenseKey,plan:Oe,pluginName:ke,cleanup:()=>{s.forEach(o=>o==null?void 0:o()),i(),a==null||a()}})},Ze=Ie(qe);module.exports=Ze;
|
|
@@ -103,13 +103,13 @@ async function Ee(n) {
|
|
|
103
103
|
const ge = (n) => (e) => {
|
|
104
104
|
var t;
|
|
105
105
|
return ((t = e.getAttribute) == null ? void 0 : t.call(e, ne)) === n;
|
|
106
|
-
}, Ge = (...n) => (e) => n.some((t) => e.is(t)), Te = (...n) => (e, t) => n.some((s) => t.is(s)), fe = "gjs-plg-", ne = "data-type-role",
|
|
106
|
+
}, Ge = (...n) => (e) => n.some((t) => e.is(t)), Te = (...n) => (e, t) => n.some((s) => t.is(s)), fe = "gjs-plg-", ne = "data-type-role", N = class N {
|
|
107
107
|
constructor(e) {
|
|
108
108
|
this.config = e;
|
|
109
109
|
}
|
|
110
110
|
getSize(e) {
|
|
111
111
|
var t;
|
|
112
|
-
return (t = this.config) != null && t.getSize ? this.config.getSize(e) : se(e.componentColumn,
|
|
112
|
+
return (t = this.config) != null && t.getSize ? this.config.getSize(e) : se(e.componentColumn, N.CSS_FLEX_BASIS);
|
|
113
113
|
}
|
|
114
114
|
setSize(e) {
|
|
115
115
|
var t;
|
|
@@ -117,13 +117,13 @@ const ge = (n) => (e) => {
|
|
|
117
117
|
this.config.setSize(e);
|
|
118
118
|
else {
|
|
119
119
|
const { componentColumn: s, sizeValue: i, partial: a } = e;
|
|
120
|
-
s.addStyle({ [
|
|
120
|
+
s.addStyle({ [N.CSS_FLEX_BASIS]: i }, { partial: a });
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
|
-
|
|
125
|
-
let K =
|
|
126
|
-
const
|
|
124
|
+
N.CSS_FLEX_BASIS = "flex-basis";
|
|
125
|
+
let K = N;
|
|
126
|
+
const j = class j {
|
|
127
127
|
constructor(e) {
|
|
128
128
|
this.config = e;
|
|
129
129
|
}
|
|
@@ -132,7 +132,7 @@ const N = class N {
|
|
|
132
132
|
}
|
|
133
133
|
getGap(e) {
|
|
134
134
|
var t;
|
|
135
|
-
return (t = this.config) != null && t.getGap ? this.config.getGap(e) : se(e.componentRow,
|
|
135
|
+
return (t = this.config) != null && t.getGap ? this.config.getGap(e) : se(e.componentRow, j.CSS_GAP);
|
|
136
136
|
}
|
|
137
137
|
setGap(e) {
|
|
138
138
|
var t;
|
|
@@ -140,12 +140,12 @@ const N = class N {
|
|
|
140
140
|
this.config.setGap(e);
|
|
141
141
|
else {
|
|
142
142
|
const { componentRow: s, gapValue: i, partial: a } = e;
|
|
143
|
-
s.addStyle({ [
|
|
143
|
+
s.addStyle({ [j.CSS_GAP]: i }, { partial: a });
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
|
-
|
|
148
|
-
let J =
|
|
147
|
+
j.CSS_GAP = "gap";
|
|
148
|
+
let J = j;
|
|
149
149
|
const Y = class Y {
|
|
150
150
|
constructor(e) {
|
|
151
151
|
this.config = e;
|
|
@@ -240,16 +240,16 @@ class Le {
|
|
|
240
240
|
return (t = this.config) != null && t.isParentVertical ? this.config.isParentVertical(e) : !1;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
class
|
|
243
|
+
class A {
|
|
244
244
|
constructor() {
|
|
245
245
|
this.handlerCache = /* @__PURE__ */ new Map();
|
|
246
246
|
}
|
|
247
247
|
static getInstance() {
|
|
248
|
-
return
|
|
248
|
+
return A.instance || (A.instance = new A()), A.instance;
|
|
249
249
|
}
|
|
250
250
|
getHandlers(e) {
|
|
251
251
|
const t = `${e.projectType}-${e.disableGapHandler ? "nogap" : "gap"}`;
|
|
252
|
-
return this.handlerCache.has(t) || (
|
|
252
|
+
return this.handlerCache.has(t) || (H(e) ? this.handlerCache.set(t, {
|
|
253
253
|
sizeHandler: new Z(e),
|
|
254
254
|
gapHandler: new Q(e),
|
|
255
255
|
parentSizeHandler: new Le(e)
|
|
@@ -261,19 +261,19 @@ class H {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
function G(n) {
|
|
264
|
-
return
|
|
264
|
+
return A.getInstance().getHandlers(n);
|
|
265
265
|
}
|
|
266
266
|
const oe = (n) => {
|
|
267
267
|
n.style.display = "none";
|
|
268
268
|
}, re = (n) => {
|
|
269
269
|
n.style.display = "block";
|
|
270
|
-
}, V = (n) => +parseFloat(`${n}`).toFixed(2),
|
|
270
|
+
}, V = (n) => +parseFloat(`${n}`).toFixed(2), H = (n) => n.projectType === he.email, k = (n, e) => {
|
|
271
271
|
const t = n.Canvas.getFramesEl();
|
|
272
272
|
t && (t.style.pointerEvents = e ? "none" : "");
|
|
273
|
-
}, $e = (n) => n ? ["top", "bottom"] : ["left", "right"],
|
|
273
|
+
}, $e = (n) => n ? ["top", "bottom"] : ["left", "right"], Ae = (n) => {
|
|
274
274
|
const e = n.parent();
|
|
275
275
|
return e ? e.components().models.indexOf(n) === 0 : !1;
|
|
276
|
-
},
|
|
276
|
+
}, He = (n) => {
|
|
277
277
|
const e = n.parent();
|
|
278
278
|
if (!e) return !1;
|
|
279
279
|
const t = e.components().models;
|
|
@@ -286,7 +286,7 @@ const oe = (n) => {
|
|
|
286
286
|
}, Me = (n, e, t, s) => {
|
|
287
287
|
const a = n + (t ? e === "top" ? -1 : e === "bottom" ? 1 : 0 : e === "left" ? -1 : e === "right" ? 1 : 0);
|
|
288
288
|
return a >= 0 && a < s ? a : -1;
|
|
289
|
-
}, O = (n) => n === "top" || n === "bottom",
|
|
289
|
+
}, O = (n) => n === "top" || n === "bottom", Ne = (n, e) => !!(Ae(n) && (e === "left" || e === "top") || He(n) && (e === "right" || e === "bottom")), je = (n) => {
|
|
290
290
|
const e = n.parent();
|
|
291
291
|
return e ? e.components().models.length > 1 : !1;
|
|
292
292
|
}, ce = (n, e) => n === "right" || n === "bottom" ? e > 0 : e < 0, se = (n, e, t = !1) => {
|
|
@@ -325,7 +325,7 @@ const oe = (n) => {
|
|
|
325
325
|
};
|
|
326
326
|
function Fe(n, e) {
|
|
327
327
|
const { Blocks: t } = n, { typeColumn: s, typeRow: i, blocks: a } = e;
|
|
328
|
-
if (a === !1 ||
|
|
328
|
+
if (a === !1 || H(e)) return;
|
|
329
329
|
const o = (u) => ({
|
|
330
330
|
type: i,
|
|
331
331
|
components: u.map((f) => ({
|
|
@@ -361,7 +361,7 @@ function Fe(n, e) {
|
|
|
361
361
|
}
|
|
362
362
|
const Be = (n, e) => {
|
|
363
363
|
const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeColumn: a } = e, o = `${fe}${i}`, c = !!i && !!t.getType(i) && !a;
|
|
364
|
-
if (!(!i || c ||
|
|
364
|
+
if (!(!i || c || H(e)))
|
|
365
365
|
return t.addType(i, {
|
|
366
366
|
isComponent: ge(i),
|
|
367
367
|
model: {
|
|
@@ -385,7 +385,7 @@ const Be = (n, e) => {
|
|
|
385
385
|
};
|
|
386
386
|
}, De = (n, e) => {
|
|
387
387
|
const { Components: t } = n, { typeRow: s, typeColumn: i, extendTypeRow: a } = e, o = `${fe}${s}`, c = !!s && !!t.getType(s) && !a;
|
|
388
|
-
if (!(!s || c ||
|
|
388
|
+
if (!(!s || c || H(e)))
|
|
389
389
|
return t.addType(s, {
|
|
390
390
|
isComponent: ge(s),
|
|
391
391
|
model: {
|
|
@@ -453,8 +453,8 @@ const Be = (n, e) => {
|
|
|
453
453
|
}), () => {
|
|
454
454
|
t.removeType(s);
|
|
455
455
|
};
|
|
456
|
-
};
|
|
457
|
-
class
|
|
456
|
+
}, ke = "flexComponent", Oe = $.startup;
|
|
457
|
+
class Xe {
|
|
458
458
|
constructor() {
|
|
459
459
|
this.resizableChildTypes = /* @__PURE__ */ new Set(), this.gapAdjustableParentTypes = /* @__PURE__ */ new Set(), this.typeRelationships = /* @__PURE__ */ new Map();
|
|
460
460
|
}
|
|
@@ -478,7 +478,7 @@ class ke {
|
|
|
478
478
|
return this.typeRelationships.has(s) ? this.typeRelationships.get(s).has(i) : !1;
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
class
|
|
481
|
+
class Ye {
|
|
482
482
|
constructor(e, t, s) {
|
|
483
483
|
this.editor = e, this.registry = t, this.opts = s, this.resizeState = /* @__PURE__ */ new WeakMap();
|
|
484
484
|
}
|
|
@@ -534,7 +534,7 @@ class Oe {
|
|
|
534
534
|
} else z >= b && x >= b && (i.lastSnappedPercent = void 0);
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
class
|
|
537
|
+
class Ue {
|
|
538
538
|
constructor(e, t, s) {
|
|
539
539
|
this.editor = e, this.registry = t, this.opts = s;
|
|
540
540
|
}
|
|
@@ -556,9 +556,9 @@ class Xe {
|
|
|
556
556
|
_e(e, this.opts);
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
-
class
|
|
559
|
+
class We {
|
|
560
560
|
constructor(e, t, s) {
|
|
561
|
-
this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new
|
|
561
|
+
this.editor = e, this.registry = t, this.opts = s, this.resizeHandler = new Ye(e, t, s), this.gapHandler = new Ue(e, t, s);
|
|
562
562
|
}
|
|
563
563
|
startResize(e, t, s) {
|
|
564
564
|
this.resizeHandler.startResize(e, t, s);
|
|
@@ -583,11 +583,11 @@ class Ye {
|
|
|
583
583
|
return this.registry.isGapAdjustableParent(e);
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
const X = "gs-flex-spots", pe = `${X}__handle-size`,
|
|
587
|
-
function
|
|
586
|
+
const X = "gs-flex-spots", pe = `${X}__handle-size`, Ke = `${X}__handle-gap`;
|
|
587
|
+
function Je(n, e) {
|
|
588
588
|
const { Canvas: t } = n, s = "flex-resize-spot";
|
|
589
589
|
let i, a, o, l, c = null, g = null;
|
|
590
|
-
const p = new
|
|
590
|
+
const p = new Xe(), u = new We(n, p, e), f = () => {
|
|
591
591
|
var r;
|
|
592
592
|
i = document.createElement("div"), i.className = X, i.style.display = "none", a = document.createElement("div"), a.className = `${X}__handles`, a.style.position = "absolute", a.style.pointerEvents = "none", a.style.zIndex = "21", o = {
|
|
593
593
|
left: document.createElement("div"),
|
|
@@ -607,7 +607,7 @@ function We(n, e) {
|
|
|
607
607
|
${y === "top" ? "top: 0px;" : ""}
|
|
608
608
|
${y === "bottom" ? "bottom: 0px;" : ""}
|
|
609
609
|
`, m.addEventListener("pointerdown", v(y)), a.appendChild(m);
|
|
610
|
-
}), !e.disableGapHandler && !
|
|
610
|
+
}), !e.disableGapHandler && !H(e) && (l = document.createElement("div"), l.className = Ke, l.style.cssText = `
|
|
611
611
|
position: absolute;
|
|
612
612
|
background-color: var(--gs-theme-cl-cmp-bg1, #3b97e3);
|
|
613
613
|
border-width: 2px;
|
|
@@ -652,10 +652,10 @@ function We(n, e) {
|
|
|
652
652
|
a && Object.assign(a.style, y);
|
|
653
653
|
const h = F(m, e), w = $e(h);
|
|
654
654
|
if (Object.values(o).forEach(oe), w.forEach((E) => {
|
|
655
|
-
if (
|
|
655
|
+
if (Ne(d, E)) return;
|
|
656
656
|
const L = o[E];
|
|
657
657
|
re(L);
|
|
658
|
-
}), G(e).gapHandler.isGapSupported() && l &&
|
|
658
|
+
}), G(e).gapHandler.isGapSupported() && l && je(d)) {
|
|
659
659
|
const E = ee({ componentRow: m, isVertical: h }, e);
|
|
660
660
|
I(E, h, Ve(d));
|
|
661
661
|
}
|
|
@@ -683,14 +683,14 @@ function We(n, e) {
|
|
|
683
683
|
p.registerTypeRelationship(r, d);
|
|
684
684
|
};
|
|
685
685
|
n.onReady(() => {
|
|
686
|
-
f(),
|
|
686
|
+
f(), H(e) ? b("mj-section", "mj-column") : b(e.typeRow, e.typeColumn);
|
|
687
687
|
});
|
|
688
688
|
const C = "component:toggled";
|
|
689
689
|
return n.on(t.events.spot, x), n.on(C, z), () => {
|
|
690
690
|
n.off(t.events.spot, x), n.off(C, z);
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
|
-
const
|
|
693
|
+
const qe = function(n, e = {}) {
|
|
694
694
|
const t = {
|
|
695
695
|
typeRow: "flex-row",
|
|
696
696
|
typeColumn: "flex-column",
|
|
@@ -698,17 +698,17 @@ const Ke = "flexComponent", Je = function(n, e = {}) {
|
|
|
698
698
|
snapDivisions: 12,
|
|
699
699
|
minItemPercent: 5,
|
|
700
700
|
...e
|
|
701
|
-
}, s = [De(n, t), Be(n, t)], i =
|
|
701
|
+
}, s = [De(n, t), Be(n, t)], i = Je(n, t), a = Fe(n, t);
|
|
702
702
|
Re({
|
|
703
703
|
editor: n,
|
|
704
704
|
licenseKey: t.licenseKey,
|
|
705
|
-
plan:
|
|
706
|
-
pluginName:
|
|
705
|
+
plan: Oe,
|
|
706
|
+
pluginName: ke,
|
|
707
707
|
cleanup: () => {
|
|
708
708
|
s.forEach((o) => o == null ? void 0 : o()), i(), a == null || a();
|
|
709
709
|
}
|
|
710
710
|
});
|
|
711
|
-
},
|
|
711
|
+
}, Ze = Ie(qe);
|
|
712
712
|
export {
|
|
713
|
-
|
|
713
|
+
Ze as default
|
|
714
714
|
};
|