@grapesjs/studio-sdk-plugins 1.0.10 → 1.0.11

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.
Files changed (41) hide show
  1. package/dist/dialogComponent/index.cjs.js +2 -2
  2. package/dist/dialogComponent/index.es.js +4 -3
  3. package/dist/dialogComponent/index.umd.js +7 -7
  4. package/dist/fsLightboxComponent/index.cjs.js +2 -2
  5. package/dist/fsLightboxComponent/index.es.js +4 -3
  6. package/dist/fsLightboxComponent/index.umd.js +2 -2
  7. package/dist/index.cjs.d.ts +1 -0
  8. package/dist/index.cjs.js +59 -15
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.es.d.ts +1 -0
  11. package/dist/index.es.js +3891 -2910
  12. package/dist/index.umd.js +66 -22
  13. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  14. package/dist/lightGalleryComponent/index.es.js +21 -20
  15. package/dist/lightGalleryComponent/index.umd.js +1 -1
  16. package/dist/listPagesComponent/index.cjs.js +4 -4
  17. package/dist/listPagesComponent/index.es.js +4 -3
  18. package/dist/listPagesComponent/index.umd.js +3 -3
  19. package/dist/prosemirror/index.cjs.js +1 -1
  20. package/dist/prosemirror/index.es.js +4 -2
  21. package/dist/prosemirror/index.umd.js +1 -1
  22. package/dist/swiperComponent/components/Swiper.d.ts +12 -0
  23. package/dist/swiperComponent/components/SwiperNavigation.d.ts +7 -0
  24. package/dist/swiperComponent/components/SwiperPagination.d.ts +3 -0
  25. package/dist/swiperComponent/components/SwiperScrollbar.d.ts +5 -0
  26. package/dist/swiperComponent/components/SwiperSlide.d.ts +5 -0
  27. package/dist/swiperComponent/components/SwiperWrapper.d.ts +5 -0
  28. package/dist/swiperComponent/index.cjs.d.ts +3 -0
  29. package/dist/swiperComponent/index.cjs.js +45 -0
  30. package/dist/swiperComponent/index.d.ts +3 -0
  31. package/dist/swiperComponent/index.es.d.ts +3 -0
  32. package/dist/swiperComponent/index.es.js +1082 -0
  33. package/dist/swiperComponent/index.umd.js +45 -0
  34. package/dist/swiperComponent/types.d.ts +13 -0
  35. package/dist/swiperComponent/typesSchema.d.ts +19 -0
  36. package/dist/swiperComponent/utils.d.ts +23 -0
  37. package/dist/tableComponent/index.cjs.js +1 -1
  38. package/dist/tableComponent/index.es.js +4 -3
  39. package/dist/tableComponent/index.umd.js +1 -1
  40. package/dist/utils.d.ts +36 -1
  41. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ (function(P,E){typeof exports=="object"&&typeof module<"u"?module.exports=E(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],E):(P=typeof globalThis<"u"?globalThis:P||self,P.StudioSdkPlugins_swiperComponent=E())})(this,function(){"use strict";const P="app.grapesjs.com",E="app-stage.grapesjs.com",z=[P,E,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],Q="license:check:start",ee="license:check:end",te=()=>typeof window<"u",ae=({isDev:t,isStage:l})=>`${t?"":`https://${l?E:P}`}/api`,le=()=>{const t=te()&&window.location.hostname;return!!t&&(z.includes(t)||z.some(l=>t.endsWith(l)))},ne=t=>t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(l,a)=>(a?"-":"")+l.toLowerCase()),se=t=>typeof t<"u";var T=(t=>(t.free="free",t.startup="startup",t.business="business",t.enterprise="enterprise",t))(T||{});async function ie({path:t,baseApiUrl:l,method:a="GET",headers:n={},params:i,body:r}){const u=`${l||ae({isDev:!1,isStage:!1})}${t}`,d={method:a,headers:{"Content-Type":"application/json",...n}};r&&(d.body=JSON.stringify(r));const b=i?new URLSearchParams(i).toString():"",e=b?`?${b}`:"",s=await fetch(`${u}${e}`,d);if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return s.json()}const H={[T.free]:0,[T.startup]:10,[T.business]:20,[T.enterprise]:30};function oe(t){const l=t;return l.init=a=>n=>t(n,a),l}const re=t=>oe(t);async function ce({editor:t,plan:l,pluginName:a,licenseKey:n,cleanup:i}){let r="",c=!1;const u=le(),d=e=>{console.warn("Cleanup plugin:",a,"Reason:",e),i()},b=(e={})=>{var $;const{error:s,sdkLicense:m}=e,g=($=e.plan)==null?void 0:$.category;if(!(m||e.license)||s)d(s||"Invalid license");else if(g){const M=H[l],R=H[g];M>R&&d({pluginRequiredPlan:l,licensePlan:g})}};t.on(Q,e=>{r=e==null?void 0:e.baseApiUrl,c=!0}),t.on(ee,e=>{b(e)}),setTimeout(async()=>{if(!c){if(u)return;if(n){const e=await de({licenseKey:n,pluginName:a,baseApiUrl:r});e&&b(e)}else d("The `licenseKey` option not provided")}},2e3)}async function de(t){const{licenseKey:l,pluginName:a,baseApiUrl:n}=t;try{return(await ie({baseApiUrl:n,path:`/sdk/${l||"na"}`,method:"POST",params:{d:window.location.hostname,pn:a}})).result||{}}catch(i){return console.error("Error during SDK license check:",i),!1}}const S=(t,l)=>{var a;return!!((a=t==null?void 0:t.classList)!=null&&a.contains(l))},pe=(t,l={})=>{var r;const a={},n=[],i=[];for(const c in t){const{value:u,...d}=t[c];n.push({id:c,name:c,changeProp:!0,category:l.category,...d}),a[c]=u,!se(u)&&i.push(c);const{subTraits:b={}}=d;for(const e in d.subTraits)(r=b[e])==null||r.forEach(s=>{const m=s.id||s.name;a[m]=s.value})}return{propKeys:Object.keys(a),propsNoValues:i,props:a,traits:n}},ue=(t,l)=>{l.forEach(a=>{if(a.subTraits){const n=`${a.id||a.name}`,i=a.changeProp?`change:${n}`:`change:attributes:${n}`;t.on(i,()=>G(t,n)),G(t,n)}})},G=(t,l)=>{const a=t.getTrait(l),n=a.get("category"),i=a.get("subTraits")||{},c=(Object.values(i).flat()||[]).map(b=>b.id||b.name);t.removeTrait(c);const u=i[a.getValue()],d=t.getTraitIndex(l)+1;u&&t.addTrait(u.map(b=>({category:n,...b})),{at:d})},be=(t,l)=>{l.forEach(a=>{const n=ne(a);n!==a&&t.has(n)&&t.set({[a]:t.get(n),[n]:void 0})})},f="swiper",_=`${f}-slide`,x=`${f}-wrapper`,L=`${f}-nav-prev`,B=`${f}-nav-next`,k=`${f}-pagination`,N=`${f}-scrollbar`,p={slider:`<svg viewBox="0 0 24 24">
2
+ <path d="M22 7.6c0-1-.5-1.6-1.3-1.6H3.4C2.5 6 2 6.7 2 7.6v9.8c0 1 .5 1.6 1.3 1.6h17.4c.8 0 1.3-.6 1.3-1.6V7.6zM21 18H3V7h18v11z" fill-rule="nonzero"/>
3
+ <path d="M4 12.5L6 14v-3zM20 12.5L18 14v-3z"/>
4
+ </svg>`,effect:`<svg viewBox="0 0 24 24">
5
+ <path d="M7.5 5.6 5 7l1.4-2.5L5 2l2.5 1.4L10 2 8.6 4.5 10 7 7.5 5.6m12 9.8L22 14l-1.4 2.5L22 19l-2.5-1.4L17 19l1.4-2.5L17 14l2.5 1.4M22 2l-1.4 2.5L22 7l-2.5-1.4L17 7l1.4-2.5L17 2l2.5 1.4L22 2m-8.7 10.8 2.5-2.5-2.1-2-2.5 2.4 2.1 2m1-5.4 2.4 2.3c.4.4.4 1 0 1.4L5 22.7a1 1 0 0 1-1.4 0l-2.3-2.3a1 1 0 0 1 0-1.4L13 7.3a1 1 0 0 1 1.4 0Z"/>
6
+ </svg>`,autoplay:`<svg viewBox="0 0 24 24">
7
+ <path d="M5 6.3A1 1 0 0 1 5 5a1 1 0 0 1 1.3 0l6.8 5.4.3.3a2 2 0 0 1-2.8 2.8l-.3-.3L5 6.3M12 20a8 8 0 0 0 8-8 8 8 0 0 0-2.3-5.7L19 5a10 10 0 0 1 3 7 10 10 0 0 1-10 10A10 10 0 0 1 2 12h2a8 8 0 0 0 8 8m0-19a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2 2 2 0 0 1 2-2Z"/>
8
+ </svg>`,pagination:`<svg viewBox="0 0 24 24">
9
+ <path d="M16 12a2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2m-6 0a2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2m-6 0a2 2 0 0 1 2-2 2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2Z"/>
10
+ </svg>`,scrollbar:`<svg viewBox="0 0 24 24">
11
+ <path d="M7.2 9.2 5.8 7.8 1.5 12l4.3 4.2 1.4-1.4L4.4 12zm9.6 5.6 1.4 1.4 4.3-4.2-4.3-4.2-1.4 1.4 2.8 2.8z"/>
12
+ <path fill-rule="evenodd" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0m-2 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0" clip-rule="evenodd"/>
13
+ </svg>`,parallax:`<svg viewBox="0 0 24 24">
14
+ <path d="M12.6 23.3h-.2v.5h.2v-.5m.3-.2-.2.1v.5l.2.1v-.6m-.8 0v.6h.2v-.5z"/>
15
+ <path fill="currentColor" d="M18 9.4a2.5 2.5 0 0 1 3 2.3v5.7a3 3 0 0 1-2.2 2.9h-.2L13 21.4a2.5 2.5 0 0 1-3-2.3v-5.7a3 3 0 0 1 2.2-2.9h.2zM14.5 6a2.5 2.5 0 0 1 3 2.3v.4l-5.3 1A4 4 0 0 0 9 13.4v4.8a2.5 2.5 0 0 1-2.5-2.4v-5.7a3 3 0 0 1 2.2-2.9H9zM11 2.6a2.5 2.5 0 0 1 3 2.3v.3l-5.3 1A4 4 0 0 0 5.5 10v4.8A2.5 2.5 0 0 1 3 12.3V6.6a3 3 0 0 1 2.2-2.9h.2z"/>
16
+ </svg>`,responsive:`<svg viewBox="0 0 24 24">
17
+ <path d="M17 21q-.4 0-.7-.3T16 20V10q0-.8-.6-1.4T14 8h-3.5q-.4 0-.7-.3T9.5 7V4q0-.4.3-.7t.7-.3H20q.4 0 .7.3t.3.7v16q0 .4-.3.7t-.7.3zm-6.5 0q-.4 0-.7-.3t-.3-.7v-9q0-.4.3-.7t.7-.3H13q.4 0 .7.3t.3.7v9q0 .4-.3.7t-.7.3zM4 21q-.4 0-.7-.3T3 20v-9q0-.4.3-.7T4 10h2.5q.4 0 .7.3t.3.7v9q0 .4-.3.7t-.7.3z"/>
18
+ </svg>`,extra:`<svg viewBox="0 0 24 24">
19
+ <path fill-rule="evenodd" d="M5.4 3h13.2A2.4 2.4 0 0 1 21 5.4v13.2a2.4 2.4 0 0 1-2.4 2.4H5.4A2.4 2.4 0 0 1 3 18.6V5.4A2.4 2.4 0 0 1 5.4 3M5 12a2 2 0 1 1 4 0 2 2 0 0 1-4 0m5 0a2 2 0 1 1 4 0 2 2 0 0 1-4 0m7-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4" clip-rule="evenodd"/>
20
+ </svg>`,reload:`<svg viewBox="0 0 24 24">
21
+ <path d="M2 12c0 5 4 9 9 9 2.4 0 4.7-1 6.4-2.6l-1.5-1.5A6.7 6.7 0 0 1 11 19a7 7 0 1 1 7-7h-3l4 4h.1l3.9-4h-3a9 9 0 0 0-18 0Z"/>
22
+ </svg>`,prev:'<svg viewBox="0 0 24 24"><path d="M15.4 16.6 10.8 12l4.6-4.6L14 6l-6 6 6 6 1.4-1.4Z"/></svg>',next:'<svg viewBox="0 0 24 24"><path d="m8.6 16.6 4.6-4.6-4.6-4.6L10 6l6 6-6 6-1.4-1.4Z"/></svg>',add:`<svg viewBox="0 0 24 24">
23
+ <path d="M12 20a8 8 0 1 1 0-16 8 8 0 0 1 0 16m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m1 5h-2v4H7v2h4v4h2v-4h4v-2h-4V7Z"/>
24
+ </svg>`},j={id:"swiper-responsive",label:"Responsive",icon:p.responsive},U={id:"swiper-extra",label:"Extra",icon:p.extra},fe={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:p.reload},{id:"p",label:"Previous slide",icon:p.prev},{id:"n",label:"Next slide",icon:p.next},{id:"a",label:"Add new slide",icon:p.add}],setValue:({component:t,value:l})=>{var n;const a=(n=t.getView())==null?void 0:n.getSwiper();switch(l){case"r":t.reloadSlider();break;case"p":a==null||a.slidePrev();break;case"n":a==null||a.slideNext();break;case"a":t.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:t})=>!!t.findFirstType(L),setValue:({component:t,value:l})=>{var a,n;l?t.append([{type:L},{type:B}]):((a=t.findFirstType(L))==null||a.remove(),(n=t.findFirstType(B))==null||n.remove()),t.set({navigation:l})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:p.effect},type:"select",label:"Effect Type",value:"slide",options:[{id:"slide",label:"Slide"},{id:"fade",label:"Fade"},{id:"cube",label:"Cube"},{id:"coverflow",label:"Coverflow"},{id:"flip",label:"Flip"},{id:"cards",label:"Cards"}],subTraits:{slide:[{type:"number",name:"slidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"slidesPerGroup",label:"Slides per group",tip:"Numbers of slides for group sliding",changeProp:!0,min:1,value:1},{type:"number",name:"spaceBetween",label:"Space between",tip:"Distance between slides in px",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetBefore",label:"Slides offset before",tip:"Add additional slide offset in the beginning of the container (in px, before all slides)",changeProp:!0,min:0,value:0},{type:"number",name:"slidesOffsetAfter",label:"Slides offset after",tip:"Add additional slide offset in the end of the container (in px, after all slides)",changeProp:!0,min:0,value:0},{type:"checkbox",name:"centeredSlides",label:"Centered slides",tip:"If enabled, the active slide will be centered",changeProp:!0,value:!1}],fade:[{type:"checkbox",name:"crossFade",tip:"Enables slides cross fade",label:"Cross fade",changeProp:!0,value:!1}],cube:[{type:"checkbox",name:"cubeEffectShadow",label:"Shadow",changeProp:!0,value:!0},{type:"checkbox",name:"cubeEffectSlideShadows",label:"Slide shadows",changeProp:!0,value:!0},{type:"number",name:"cubeEffectShadowOffset",label:"Shadow offset",changeProp:!0,value:20},{type:"number",name:"cubeEffectShadowScale",label:"Shadow scale",changeProp:!0,value:.94}],coverflow:[{type:"number",name:"coverflowEffectDepth",tip:"Depth offset in px (slides translate in Z axis)",label:"Depth",changeProp:!0,min:0,value:100},{type:"number",name:"coverflowEffectModifier",tip:"Effect multiplier",label:"Modifier",changeProp:!0,step:.1,min:0,value:1},{type:"number",name:"coverflowEffectRotate",tip:"Slide rotate in degrees",label:"Rotate",changeProp:!0,min:0,value:50},{type:"number",name:"coverflowEffectScale",tip:"Slide scale effect",label:"Scale",changeProp:!0,min:0,step:.1,value:1},{type:"number",name:"coverflowEffectStretch",tip:"Stretch space between slides (in px)",label:"Stretch",changeProp:!0,min:0,value:0},{type:"checkbox",name:"coverflowEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadow",changeProp:!0,value:!0}],flip:[{type:"checkbox",name:"flipEffectLimitRotation",tip:"Limit edge slides rotation",label:"Limit rotation",changeProp:!0,value:!0},{type:"checkbox",name:"flipEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}],cards:[{type:"number",name:"cardsEffectPerSlideOffset",tip:"Offset distance per slide (in px)",label:"Slide offset",changeProp:!0,min:0,value:8},{type:"number",name:"cardsEffectPerSlideRotate",tip:"Rotate angle per slide (in degrees)",label:"Slide rotate",changeProp:!0,min:0,value:2},{type:"checkbox",name:"cardsEffectRotate",tip:"Enables cards rotation",label:"Rotate",changeProp:!0,value:!0},{type:"checkbox",name:"cardsEffectSlideShadows",tip:"Enables slides shadows",label:"Slide shadows",changeProp:!0,value:!0}]}},autoplay:{category:{id:"swiper-autoplay",label:"Autoplay",icon:p.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:p.pagination},type:"select",label:"Pagination Type",options:[{id:"none",label:"None"},{id:"bullets",label:"Bullets"},{id:"progressbar",label:"Progressbar"},{id:"fraction",label:"Fraction"}],getValue:({component:t})=>t.findFirstType(k)?t.get("pagination")||"bullets":"none",setValue:({component:t,value:l})=>{const a=t.findFirstType(k);a==null||a.remove(),l!=="none"&&t.append({type:k}),t.set({pagination:l})},subTraits:{bullets:[{type:"checkbox",name:"dynamicBullets",label:"Dynamic bullets",changeProp:!0,value:!1},{type:"checkbox",name:"clickableBullets",label:"Clickable bullets",changeProp:!0,value:!0}],progressbar:[{type:"checkbox",name:"progressbarOpposite",label:"Progress opposite",changeProp:!0,value:!1}]}},scrollbar:{category:{id:"swiper-scrollbar",label:"Scrollbar",icon:p.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:t})=>!!t.findFirstType(N),setValue:({component:t,value:l})=>{const a=t.findFirstType(N);a==null||a.remove(),l&&t.append({type:N}),t.set({scrollbar:l})},subTraits:{false:[],true:[{type:"checkbox",name:"scrollbarDraggable",label:"Draggable",changeProp:!0,value:!1},{type:"checkbox",name:"scrollbarHide",label:"Hide",tip:"Hide scrollbar automatically after user interaction",changeProp:!0,value:!0}]}},parallax:{category:{id:"swiper-parallax",label:"Parallax",icon:p.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:j,type:"checkbox",label:"Enable mobile breakpoint",value:!1,subTraits:{true:[{type:"number",name:"mobileBreakpoint",label:"Mobile breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:460},{type:"number",name:"mobileSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"mobileSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},tablet:{category:j,type:"checkbox",label:"Enable tablet breakpoint",value:!1,subTraits:{true:[{type:"number",name:"tabletBreakpoint",label:"Tablet breakpoint",tip:"Slide values below will be applied when the screen width is greater than this value",changeProp:!0,min:1,value:991},{type:"number",name:"tabletSlidesPerView",label:"Slides per view",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSlidesPerGroup",label:"Slides per group",changeProp:!0,min:1,value:1},{type:"number",name:"tabletSpaceBetween",label:"Space between",changeProp:!0,min:0,value:0}]}},allowTouchMove:{category:U,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:U,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},K="Slider",I="swiper",A=`${I}-`,he=(t,l)=>{const{Components:a,Blocks:n}=t,{block:i}=l,r=pe(fe),c="core:preview",u=function(e){const s=this,m=window,g=s.__onLoad,F=s.__activeSlide,$=s.__inPreview,{cdnScript:M,cdnStyle:R,slidesPerView:W}=e||{},o=h=>isNaN(h)?void 0:parseFloat(h),J=()=>{const h={loop:e.loop,speed:e.speed,initialSlide:e.initialSlide,direction:e.vertical?"vertical":"horizontal",effect:e.effect,freeMode:e.freeMode,parallax:e.parallax,autoHeight:e.autoHeight,allowTouchMove:e.allowTouchMove,grabCursor:e.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(W)?W:o(W),slidesPerGroup:o(e.slidesPerGroup),spaceBetween:o(e.spaceBetween),slidesOffsetBefore:o(e.slidesOffsetBefore),slidesOffsetAfter:o(e.slidesOffsetAfter),centeredSlides:e.centeredSlides,fadeEffect:{crossFade:e.crossFade},cubeEffect:{shadow:e.cubeEffectShadow,slideShadows:e.cubeEffectSlideShadows,shadowOffset:o(e.cubeEffectShadowOffset),shadowScale:o(e.cubeEffectShadowScale)},coverflowEffect:{depth:o(e.coverflowEffectDepth),modifier:o(e.coverflowEffectModifier),rotate:o(e.coverflowEffectRotate),scale:o(e.coverflowEffectScale),stretch:o(e.coverflowEffectStretch),slideShadows:e.coverflowEffectSlideShadows},flipEffect:{limitRotation:e.flipEffectLimitRotation,slideShadows:e.flipEffectSlideShadows},cardsEffect:{perSlideOffset:o(e.cardsEffectPerSlideOffset),perSlideRotate:o(e.cardsEffectPerSlideRotate),rotate:e.cardsEffectRotate,slideShadows:e.cardsEffectSlideShadows},navigation:{nextEl:s.querySelector(".swiper-button-next"),prevEl:s.querySelector(".swiper-button-prev")},pagination:{type:e.pagination||"bullets",dynamicBullets:e.dynamicBullets,clickable:e.clickableBullets,progressbarOpposite:e.progressbarOpposite,el:s.querySelector(".swiper-pagination")},scrollbar:{el:s.querySelector(".swiper-scrollbar"),draggable:e.scrollbarDraggable,hide:e.scrollbarHide},autoplay:e.autoplay&&{delay:e.autoplayDelay,disableOnInteraction:e.autoplayDisableOnInteraction,pauseOnMouseEnter:e.autoplayPauseOnMouseEnter,reverseDirection:e.autoplayReverseDirection,stopOnLastSlide:e.autoplayStopOnLastSlide,waitForTransition:e.autoplayWaitForTransition}};if(e.tablet){const{tabletBreakpoint:O,tabletSlidesPerView:v}=e,C=o(O);h.breakpoints[C]={slidesPerView:isNaN(v)?v:o(v),slidesPerGroup:o(e.tabletSlidesPerGroup),spaceBetween:o(e.tabletSpaceBetween)}}if(e.mobile){const{mobileBreakpoint:O,mobileSlidesPerView:v}=e,C=o(O);h.breakpoints[C]={slidesPerView:isNaN(v)?v:o(v),slidesPerGroup:o(e.mobileSlidesPerGroup),spaceBetween:o(e.mobileSpaceBetween)}}g&&!$&&(h.simulateTouch=!1),F&&(h.initialSlide=F);const q=new m.Swiper(s,h);g==null||g(q)};if(m.Swiper)J();else{const{head:h}=document,q=Array.isArray(M)?[...M]:[M],O=Array.isArray(R)?[...R]:[R],v=w=>{if(w.length){const y=document.createElement("link");y.href=w.shift(),y.rel="stylesheet",h.appendChild(y),v(w)}},C=w=>{if(w.length){const y=document.createElement("script");y.src=w.shift(),y.onerror=y.onload=C.bind(null,w),h.appendChild(y)}else J()};v(O),C(q)}},d=(e=0)=>({type:_,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${e}`}}}),b=a.getType("default").model;return a.addType(f,{block:i&&{label:K,media:p.slider,category:"Extra",select:!0,...l.block},isComponent:e=>S(e,I),model:{defaults:()=>({name:K,icon:p.slider,classes:I,draggable:(e,s)=>!s.is(f),components:[{type:x,components:[d(1),d(2),d(3)]},{type:k}],script:u,cdnScript:l.cdnScript,cdnStyle:l.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:e}=this;ue(this,r.traits),be(this,r.propKeys),this.listenTo(e,`run:${c}`,this.onPreviewOn),this.listenTo(e,`stop:${c}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const e=this.findFirstType(x);e==null||e.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var s;const e=((s=this.findFirstType(x))==null?void 0:s.components().length)||0;return{type:_,components:{type:"text",components:{type:"textnode",content:`Slide ${e+1}`}}}},toJSON(...e){const s=b.prototype.toJSON.apply(this,e);return r.propsNoValues.forEach(m=>delete s[m]),delete s["script-props"],s}},view:{init(){const e=a.events.scriptUnmount;e&&this.listenTo(this.model,e,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var e;(e=this.getSwiper())==null||e.destroy()},onRender(){const e=this.el;e.__onLoad=s=>s.on("slideChange",()=>this.__activeSlide=s.activeIndex),e.__activeSlide=this.__activeSlide,e.__inPreview=this.model.__inPreview}}}),()=>{a.removeType(f),n.remove(f)}},ve="Nav Prev",me="Nav Next",V=`${A}button-prev`,D=`${A}button-next`,ge=t=>{const{Components:l}=t,a=n=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:n,fill:"currentColor"}}});return l.addType(L,{isComponent:n=>S(n,V),model:{defaults:{name:ve,classes:V,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,components:a("M0,22L22,0l2.1,2.1L4.2,22l19.9,19.9L22,44L0,22L0,22L0,22z"),styles:`
25
+ .${V} {
26
+ color: inherit;
27
+ }
28
+ .${V}:after {
29
+ content: none;
30
+ }
31
+ `}}}),l.addType(B,{extend:L,isComponent:n=>S(n,D),model:{defaults:{name:me,classes:D,components:a("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
32
+ .${D} {
33
+ color: inherit;
34
+ }
35
+ .${D}:after {
36
+ content: none;
37
+ }
38
+ `}}}),()=>{l.removeType(L),l.removeType(B)}},ye=t=>{const{Components:l}=t,a=`${A}pagination`;return l.addType(k,{isComponent:n=>S(n,a),model:{defaults:{name:"Pagination",classes:a,copyable:!1,highlightable:!1,droppable:!1,draggable:!1,selectable:!1,hoverable:!1,layerable:!1,styles:`
39
+ .${a}-bullet-active {
40
+ background-color: currentColor;
41
+ }
42
+ .${a}-progressbar-fill {
43
+ --swiper-pagination-color: currentColor;
44
+ }
45
+ `}}}),()=>{l.removeType(k)}},Se="Scrollbar",Z=`${A}scrollbar`,we=t=>{const{Components:l}=t;return l.addType(N,{isComponent:a=>S(a,Z),model:{defaults:{name:Se,classes:Z,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{l.removeType(N)}},Pe="Slide",Y=`${A}slide`,Ee=t=>{const{Components:l}=t;return l.addType(_,{isComponent:a=>S(a,Y),model:{defaults:{name:Pe,classes:Y,icon:p.slider,draggable:(a,n)=>n.is(x)}}}),()=>{l.removeType(_)}},Te="Wrapper",X=`${A}wrapper`,xe=t=>{const{Components:l}=t,{events:a}=l;return l.addType(x,{isComponent:n=>S(n,X),model:{defaults:{name:Te,icon:p.slider,classes:X,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:n=>n.is(_)},init(){const n=this.components();this.listenTo(n,"add remove",this.updateSlider)},updateSlider(n){const i=this.closestType(f);if(i){const r=i.getView();i.reloadSlider();const c=a.scriptMount;c&&this.em.once(c,()=>{setTimeout(()=>{var u;return(u=r.getSwiper())==null?void 0:u.slideTo(n.index())},100)})}}}}),()=>{l.removeType(x)}},Le="swiperComponent";return re(function(t,l={}){const a={block:{},cdnScript:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",cdnStyle:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",...l},n=[he(t,a),ge(t),xe(t),Ee(t),ye(t),we(t)];ce({editor:t,plan:T.startup,licenseKey:a.licenseKey,pluginName:Le,cleanup:()=>{n.forEach(i=>i())}})})});
@@ -0,0 +1,13 @@
1
+ import { BlockProperties } from 'grapesjs';
2
+ import { SwiperComponentOptions as SwiperComponentOptionsSchema } from './typesSchema';
3
+ export interface SwiperComponentOptions extends Omit<SwiperComponentOptionsSchema, 'block'> {
4
+ block?: Partial<BlockProperties> | false;
5
+ }
6
+ export interface ComponentWindow extends Window {
7
+ Swiper?: any;
8
+ }
9
+ export interface HTMLElementWithSwiper extends HTMLElement {
10
+ __onLoad?: (swiper: any) => void;
11
+ __activeSlide?: number;
12
+ __inPreview?: boolean;
13
+ }
@@ -0,0 +1,19 @@
1
+ import { SDKPluginOptions } from '../utils';
2
+ export interface SwiperComponentOptions extends SDKPluginOptions {
3
+ /**
4
+ * Additional Block properties of the component. Pass `false` to avoid adding the block.
5
+ * @example
6
+ * { category: 'Extra', label: 'My label' }
7
+ */
8
+ block?: 'Block';
9
+ /**
10
+ * CDN scripts to load dynamically in case the library is not available.
11
+ * @default "https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"
12
+ */
13
+ cdnScript?: string;
14
+ /**
15
+ * CDN styles to load dynamically.
16
+ * @default "https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"
17
+ */
18
+ cdnStyle?: string;
19
+ }
@@ -0,0 +1,23 @@
1
+ import { StudioPluginTraits } from '../utils';
2
+ export declare const TYPE_SWIPER = "swiper";
3
+ export declare const TYPE_SLIDE = "swiper-slide";
4
+ export declare const TYPE_WRAPPER = "swiper-wrapper";
5
+ export declare const TYPE_NAV_PREV = "swiper-nav-prev";
6
+ export declare const TYPE_NAV_NEXT = "swiper-nav-next";
7
+ export declare const TYPE_PAGINATION = "swiper-pagination";
8
+ export declare const TYPE_SCROLLBAR = "swiper-scrollbar";
9
+ export declare const customIcons: {
10
+ slider: string;
11
+ effect: string;
12
+ autoplay: string;
13
+ pagination: string;
14
+ scrollbar: string;
15
+ parallax: string;
16
+ responsive: string;
17
+ extra: string;
18
+ reload: string;
19
+ prev: string;
20
+ next: string;
21
+ add: string;
22
+ };
23
+ export declare const coreTraits: StudioPluginTraits;
@@ -1 +1 @@
1
- "use strict";function re(e,t,o){let l,s,n,r,a;const c=t;function h(){const b=Date.now()-r;b<c&&b>=0?l=setTimeout(h,c-b):(l=null,a=e.apply(n,s),n=s=null)}const d=function(){return n=this,s=arguments,r=Date.now(),l||(l=setTimeout(h,c)),a};return d.clear=function(){l&&(clearTimeout(l),l=null)},d.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},d}const $="app.grapesjs.com",O="app-stage.grapesjs.com",D=[$,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ie="license:check:start",he="license:check:end",de=()=>typeof window<"u",ve=({isDev:e,isStage:t})=>`${e?"":`https://${t?O:$}`}/api`,be=()=>{const e=de()&&window.location.hostname;return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))};function W(e){return typeof e=="function"}var y=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(y||{});async function ue({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:s,body:n}){const a=`${t||ve({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...l}};n&&(c.body=JSON.stringify(n));const h=s?new URLSearchParams(s).toString():"",d=h?`?${h}`:"",b=await fetch(`${a}${d}`,c);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const L={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function ge(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>ge(e);async function fe({editor:e,plan:t,pluginName:o,licenseKey:l,cleanup:s}){let n="",r=!1;const a=be(),c=d=>{console.warn("Cleanup plugin:",o,"Reason:",d),s()},h=(d={})=>{var m;const{error:b,sdkLicense:f}=d,w=(m=d.plan)==null?void 0:m.category;if(!(f||d.license)||b)c(b||"Invalid license");else if(w){const z=L[t],P=L[w];z>P&&c({pluginRequiredPlan:t,licensePlan:w})}};e.on(ie,d=>{n=d==null?void 0:d.baseApiUrl,r=!0}),e.on(he,d=>{h(d)}),setTimeout(async()=>{if(!r){if(a)return;if(l){const d=await me({licenseKey:l,pluginName:o,baseApiUrl:n});d&&h(d)}else c("The `licenseKey` option not provided")}},2e3)}async function me(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await ue({baseApiUrl:l,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}var U=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(U||{}),i=(e=>(e.table="table",e.tableSettings="tableSettings",e.tableDelete="tableDelete",e.tableHead="tableHead",e.tableFoot="tableFoot",e.tableCellItems="tableCellItems",e.tableCellProperties="tableCellProperties",e.tableCellMerge="tableCellMerge",e.tableCellSplit="tableCellSplit",e.tableRowItems="tableRowItems",e.tableRowInsertBefore="tableRowInsertBefore",e.tableRowInsertAfter="tableRowInsertAfter",e.tableRowDelete="tableRowDelete",e.tableRowProperties="tableRowProperties",e.tableRowCut="tableRowCut",e.tableRowCopy="tableRowCopy",e.tableRowPasteBefore="tableRowPasteBefore",e.tableRowPasteAfter="tableRowPasteAfter",e.tableColumn="tableColumn",e.tableColumnItems="tableColumnItems",e.tableColumnInsertBefore="tableColumnInsertBefore",e.tableColumnInsertAfter="tableColumnInsertAfter",e.tableColumnDelete="tableColumnDelete",e.tableColumnCut="tableColumnCut",e.tableColumnCopy="tableColumnCopy",e.tableColumnPasteBefore="tableColumnPasteBefore",e.tableColumnPasteAfter="tableColumnPasteAfter",e))(i||{});const v={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},p="table",G="thead",_="tfoot",x="tbody",g="row",u="cell",k="clipboardTable",we=[p,G,_,x,g,u],A=e=>e.em.get(k)||[],ye=e=>e.every(t=>t.is(u)),M=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:r,y:a,width:c,height:h}=n.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:a,w:c,h},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...t};W(s.openSettings)?s.openSettings({...e,layoutProps:d}):o.runCommand(U.layoutToggle,d)},Ce=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:g,components:Array.from(Array(o).keys()).map(n=>({type:u,components:l?{type:"text",content:W(l)?l({y:s,x:n}):l}:void 0}))}))}),K="Table settings",j=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},He=e=>{var t;(t=j(e))==null||t.remove(e.opts)},Re=e=>{const t=j(e);t&&(e.editor.select(t),M(e,{id:"tableSettings",header:{label:K}}))},q=e=>[{id:i.table,icon:v[i.table],label:"Table",items:[{id:i.tableSettings,label:K,icon:v[i.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:v[i.tableDelete],onClick:()=>He(e)}]}],X=({editor:e})=>{const t=A(e);return t.length&&ye(t)},E=({component:e,editor:t,after:o})=>{if(!e.is(u))return;const l=e.closestType(p),s=e.closestType(g),n=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:u},{at:n}));const r=s==null?void 0:s.components().at(n);r&&t.select(r)},Y=({component:e,opts:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index();o==null||o.findType(g).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},J=({component:e,editor:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index(),s=(o==null?void 0:o.findType(g).map(n=>n.components().at(l)))||[];s.length&&t.em.set(k,s)},Z=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(u)||!X(e))return;const s=A(o),n=t.closestType(p),r=t.index()+(l?1:0);n==null||n.findType(g).forEach((a,c)=>{const h=s[c],d=(h==null?void 0:h.clone())||{type:u};a.append(d,{at:r})})},Ve=e=>{const{component:t}=e;t.is(u)&&(J(e),Y({...e,opts:{temporary:!0}}))},ze=e=>{const t=X(e);return[{id:i.tableColumnItems,icon:v[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:v[i.tableColumnInsertBefore],onClick:()=>E(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:v[i.tableColumnInsertAfter],onClick:()=>E({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:v[i.tableColumnDelete],onClick:()=>Y(e)},{id:i.tableColumnCut,label:"Cut column",icon:v[i.tableColumnCut],onClick:()=>Ve(e)},{id:i.tableColumnCopy,label:"Copy column",icon:v[i.tableColumnCopy],onClick:()=>J(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:v[i.tableColumnPasteBefore],disabled:!t,onClick:()=>Z(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:v[i.tableColumnPasteAfter],disabled:!t,onClick:()=>Z({...e,after:!0})}]}]},Q="Row settings",Pe=e=>e.every(t=>t.is(g)),R=e=>{const{component:t}=e,o=t.is(u),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},N=e=>{const{component:t,editor:o,after:l}=e,s=R(e);if(!s)return;const n=s.index()+(l?1:0),r=s.components().length,a=Array.from(Array(r).keys()).map(()=>({type:u})),c=s.parent();if(c){const h=c.append({type:g,components:a},{at:n})[0];if(t.is(u)&&h){const d=t.index(),b=h.components().at(d);b&&o.select(b)}}},ee=e=>{var t;(t=R(e))==null||t.remove(e.opts)},te=e=>{const t=R(e);t&&e.editor.em.set(k,[t])},F=e=>{var a;const{editor:t,after:o}=e,l=R(e);if(!l||!le(e))return;const n=A(t)[0],r=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:r}))},Ae=e=>{R(e)&&(te(e),ee({...e,opts:{temporary:!0}}))},le=({editor:e})=>{const t=A(e);return t.length&&Pe(t)},Be=e=>{const t=R(e);t&&(e.editor.select(t),M(e,{id:"tableRowSettings",header:{label:Q}}))},oe=e=>{const t=le(e);return[{id:i.tableRowItems,icon:v[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:v[i.tableRowInsertBefore],onClick:()=>N(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:v[i.tableRowInsertAfter],onClick:()=>N({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:v[i.tableRowDelete],onClick:()=>ee(e)},{id:i.tableRowProperties,label:Q,icon:v[i.tableRowProperties],onClick:({event:l})=>Be({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:v[i.tableRowCut],onClick:()=>Ae(e)},{id:i.tableRowCopy,label:"Copy row",icon:v[i.tableRowCopy],onClick:()=>te(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:v[i.tableRowPasteBefore],disabled:!t,onClick:()=>F(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:v[i.tableRowPasteAfter],disabled:!t,onClick:()=>F({...e,after:!0})}]},...q(e)]},T=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function ne(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:r,colspan:a}=T(s);if(t[l])for(;t[l][n];)n++;for(let c=l;c<l+r;c++){t[c]||(t[c]=[]);for(let h=n;h<n+a;h++)t[c][h]={real:c===l&&h===n,cell:s,rowspan:r,colspan:a}}})}),t}function C(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const I=e=>e.closestType(g);function xe(e,{x:t,y:o,rows:l,cols:s}){var a;let n=I(e[o][t].cell),r;for(let c=1;c<=l;c++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(r=t;r>=0;r--){const{cell:h}=e[o+c][r],d=I(h);if(d===n){for(let b=1;b<=s;b++){const f=h.index();d.append({type:u},{at:f+1})}break}}if(r===-1){const d=n.components().at(0).index();for(let b=1;b<=s;b++)n.append({type:u},{at:d})}}}function se(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:r}=T(s);if(r>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<r-1;a++){const c=s.index();I(s).append({type:u},{at:c+1})}xe(e,{x:o,y:t,rows:n-1,cols:r})}}}}function Ie(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const B=(e,t={})=>{var r;const o=ne(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let c=0;c<o[a].length;c++){const h=o[a][c];if((r=t.selected)!=null&&r.includes(h.cell)||l.selected.hasComponent(h.cell)){const d={x:c,y:a};s||(s=d),n=d}}return{grid:o,startPos:s,endPos:n}};function ke(e,t={}){const o=B(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:r}=e;if(!l||!s)return;const a=l.x,c=l.y,h=s.x,d=s.y,b=C(n,a,c),f=C(n,h,d);if(b&&f){se(n),n=ne(e);const w=[],V=C(n,a,c).cell;V.addAttributes({colspan:h-a+1,rowspan:d-c+1});for(let m=c;m<=d;m++)for(let z=a;z<=h;z++){const P=C(n,z,m);if(!P)continue;const{cell:S}=P;S!==V&&w.push(S)}w.forEach(m=>{t.mergeContent&&V.append(m.components().models),m.remove()}),r.setSelected(V),Ie(e)}}const ae="Cell settings",Me="Merge cells",Te="Split cell",Se=e=>e.closestType(g),H=e=>{var t;return(t=Se(e))==null?void 0:t.parent()},De=e=>{const t=e.editor.getSelectedAll(),o=H(t[0]),l=t[0];if(!o||!(l!=null&&l.is(u))||t.length>1)return!1;const{rowspan:s,colspan:n}=T(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=H(o),{grid:s}=B(l);se(s)},ce=e=>{const t=e.editor.getSelectedAll(),o=H(t[0]);if(!o||t.length<2||t.some(a=>!a.is(u)||H(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=B(o),{em:r}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let c=s.x;c<=n.x;c++){const h=C(l,c,a);if(!h||!r.selected.hasComponent(h.cell))return!1}return!0},Ee=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=H(o[0]);ke(l,{mergeContent:!0})},Ze=e=>{M(e,{id:"tableCellSettings",header:{label:ae}})},Ne=e=>[{id:i.tableCellItems,icon:v[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:ae,icon:v[i.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:i.tableCellMerge,label:Me,icon:v[i.tableCellMerge],onClick:()=>Ee(e),disabled:!ce(e)},{id:i.tableCellSplit,label:Te,icon:v[i.tableCellSplit],onClick:()=>Le(e),disabled:!De(e)}]},...ze(e),...oe(e)],Fe=e=>{const t=e[0]&&H(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=B(t,{selected:e});if(!l||!s)return;const n=[];for(let r=l.y;r<=s.y;r++)for(let a=l.x;a<=s.x;a++){const c=C(o,a,r);c&&n.push(c.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},$e="tableComponent",Oe=function(e,t={}){const o={block:{},...t},{Components:l}=e,s={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};l.addType(p,{block:o.block&&{label:"Table",media:v.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:v.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:r,value:a,emitUpdate:c}){const h=r.find("caption")[0];a?!h&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),c(),e.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:Ce(x,{rows:5}),contextMenu:({items:r,editor:a,component:c})=>[...q({editor:a,component:c,opts:o}),...r]}}}),l.addType(G,{model:{defaults:{icon:v.tableHead,...s}}}),l.addType(_,{model:{defaults:{icon:v.tableFoot,...s}}}),l.addType(x,{model:{defaults:{icon:v.tableRowProperties,...s}}}),l.addType(g,{model:{defaults:{icon:v.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:a,component:c})=>[...oe({editor:a,component:c,opts:o}),...r]}}}),l.addType(u,{model:{defaults:{icon:v.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:r,editor:a,component:c})=>[...Ne({editor:a,component:c,opts:o}),...r]}}});const n=re((r,a)=>{var b;const c=e.getSelectedAll(),h=!!((b=a==null?void 0:a.event)!=null&&b.shiftKey);if(c.length<2||!h||a.fromCell)return;const d=c.map(f=>f.is(u)?f:f.closestType(u)).filter(Boolean);d.length===c.length&&Fe(d)},0);e.on("component:select",n),fe({editor:e,plan:y.free,licenseKey:o.licenseKey,pluginName:$e,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(p),we.forEach(r=>l.removeType(r))}})},We=pe(Oe);module.exports=We;
1
+ "use strict";require("grapesjs");function re(e,t,o){let l,s,n,r,a;const c=t;function h(){const b=Date.now()-r;b<c&&b>=0?l=setTimeout(h,c-b):(l=null,a=e.apply(n,s),n=s=null)}const d=function(){return n=this,s=arguments,r=Date.now(),l||(l=setTimeout(h,c)),a};return d.clear=function(){l&&(clearTimeout(l),l=null)},d.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},d}const $="app.grapesjs.com",O="app-stage.grapesjs.com",D=[$,O,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],ie="license:check:start",he="license:check:end",de=()=>typeof window<"u",ve=({isDev:e,isStage:t})=>`${e?"":`https://${t?O:$}`}/api`,be=()=>{const e=de()&&window.location.hostname;return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))};function W(e){return typeof e=="function"}var y=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(y||{});async function ue({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:s,body:n}){const a=`${t||ve({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...l}};n&&(c.body=JSON.stringify(n));const h=s?new URLSearchParams(s).toString():"",d=h?`?${h}`:"",b=await fetch(`${a}${d}`,c);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const L={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function ge(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>ge(e);async function fe({editor:e,plan:t,pluginName:o,licenseKey:l,cleanup:s}){let n="",r=!1;const a=be(),c=d=>{console.warn("Cleanup plugin:",o,"Reason:",d),s()},h=(d={})=>{var m;const{error:b,sdkLicense:f}=d,w=(m=d.plan)==null?void 0:m.category;if(!(f||d.license)||b)c(b||"Invalid license");else if(w){const z=L[t],P=L[w];z>P&&c({pluginRequiredPlan:t,licensePlan:w})}};e.on(ie,d=>{n=d==null?void 0:d.baseApiUrl,r=!0}),e.on(he,d=>{h(d)}),setTimeout(async()=>{if(!r){if(a)return;if(l){const d=await me({licenseKey:l,pluginName:o,baseApiUrl:n});d&&h(d)}else c("The `licenseKey` option not provided")}},2e3)}async function me(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await ue({baseApiUrl:l,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}var U=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(U||{}),i=(e=>(e.table="table",e.tableSettings="tableSettings",e.tableDelete="tableDelete",e.tableHead="tableHead",e.tableFoot="tableFoot",e.tableCellItems="tableCellItems",e.tableCellProperties="tableCellProperties",e.tableCellMerge="tableCellMerge",e.tableCellSplit="tableCellSplit",e.tableRowItems="tableRowItems",e.tableRowInsertBefore="tableRowInsertBefore",e.tableRowInsertAfter="tableRowInsertAfter",e.tableRowDelete="tableRowDelete",e.tableRowProperties="tableRowProperties",e.tableRowCut="tableRowCut",e.tableRowCopy="tableRowCopy",e.tableRowPasteBefore="tableRowPasteBefore",e.tableRowPasteAfter="tableRowPasteAfter",e.tableColumn="tableColumn",e.tableColumnItems="tableColumnItems",e.tableColumnInsertBefore="tableColumnInsertBefore",e.tableColumnInsertAfter="tableColumnInsertAfter",e.tableColumnDelete="tableColumnDelete",e.tableColumnCut="tableColumnCut",e.tableColumnCopy="tableColumnCopy",e.tableColumnPasteBefore="tableColumnPasteBefore",e.tableColumnPasteAfter="tableColumnPasteAfter",e))(i||{});const v={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},p="table",G="thead",_="tfoot",x="tbody",g="row",u="cell",k="clipboardTable",we=[p,G,_,x,g,u],A=e=>e.em.get(k)||[],ye=e=>e.every(t=>t.is(u)),M=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:r,y:a,width:c,height:h}=n.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:a,w:c,h},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...t};W(s.openSettings)?s.openSettings({...e,layoutProps:d}):o.runCommand(U.layoutToggle,d)},Ce=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:g,components:Array.from(Array(o).keys()).map(n=>({type:u,components:l?{type:"text",content:W(l)?l({y:s,x:n}):l}:void 0}))}))}),K="Table settings",j=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},He=e=>{var t;(t=j(e))==null||t.remove(e.opts)},Re=e=>{const t=j(e);t&&(e.editor.select(t),M(e,{id:"tableSettings",header:{label:K}}))},q=e=>[{id:i.table,icon:v[i.table],label:"Table",items:[{id:i.tableSettings,label:K,icon:v[i.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:i.tableDelete,label:"Delete table",icon:v[i.tableDelete],onClick:()=>He(e)}]}],X=({editor:e})=>{const t=A(e);return t.length&&ye(t)},E=({component:e,editor:t,after:o})=>{if(!e.is(u))return;const l=e.closestType(p),s=e.closestType(g),n=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:u},{at:n}));const r=s==null?void 0:s.components().at(n);r&&t.select(r)},Y=({component:e,opts:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index();o==null||o.findType(g).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},J=({component:e,editor:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index(),s=(o==null?void 0:o.findType(g).map(n=>n.components().at(l)))||[];s.length&&t.em.set(k,s)},Z=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(u)||!X(e))return;const s=A(o),n=t.closestType(p),r=t.index()+(l?1:0);n==null||n.findType(g).forEach((a,c)=>{const h=s[c],d=(h==null?void 0:h.clone())||{type:u};a.append(d,{at:r})})},Ve=e=>{const{component:t}=e;t.is(u)&&(J(e),Y({...e,opts:{temporary:!0}}))},ze=e=>{const t=X(e);return[{id:i.tableColumnItems,icon:v[i.tableColumn],label:"Column",items:[{id:i.tableColumnInsertBefore,label:"Insert column before",icon:v[i.tableColumnInsertBefore],onClick:()=>E(e)},{id:i.tableColumnInsertAfter,label:"Insert column after",icon:v[i.tableColumnInsertAfter],onClick:()=>E({...e,after:!0})},{id:i.tableColumnDelete,label:"Delete column",icon:v[i.tableColumnDelete],onClick:()=>Y(e)},{id:i.tableColumnCut,label:"Cut column",icon:v[i.tableColumnCut],onClick:()=>Ve(e)},{id:i.tableColumnCopy,label:"Copy column",icon:v[i.tableColumnCopy],onClick:()=>J(e)},{id:i.tableColumnPasteBefore,label:"Paste column before",icon:v[i.tableColumnPasteBefore],disabled:!t,onClick:()=>Z(e)},{id:i.tableColumnPasteAfter,label:"Paste column after",icon:v[i.tableColumnPasteAfter],disabled:!t,onClick:()=>Z({...e,after:!0})}]}]},Q="Row settings",Pe=e=>e.every(t=>t.is(g)),R=e=>{const{component:t}=e,o=t.is(u),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},N=e=>{const{component:t,editor:o,after:l}=e,s=R(e);if(!s)return;const n=s.index()+(l?1:0),r=s.components().length,a=Array.from(Array(r).keys()).map(()=>({type:u})),c=s.parent();if(c){const h=c.append({type:g,components:a},{at:n})[0];if(t.is(u)&&h){const d=t.index(),b=h.components().at(d);b&&o.select(b)}}},ee=e=>{var t;(t=R(e))==null||t.remove(e.opts)},te=e=>{const t=R(e);t&&e.editor.em.set(k,[t])},F=e=>{var a;const{editor:t,after:o}=e,l=R(e);if(!l||!le(e))return;const n=A(t)[0],r=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:r}))},Ae=e=>{R(e)&&(te(e),ee({...e,opts:{temporary:!0}}))},le=({editor:e})=>{const t=A(e);return t.length&&Pe(t)},Be=e=>{const t=R(e);t&&(e.editor.select(t),M(e,{id:"tableRowSettings",header:{label:Q}}))},oe=e=>{const t=le(e);return[{id:i.tableRowItems,icon:v[i.tableRowProperties],label:"Row",items:[{id:i.tableRowInsertBefore,label:"Insert row before",icon:v[i.tableRowInsertBefore],onClick:()=>N(e)},{id:i.tableRowInsertAfter,label:"Insert row after",icon:v[i.tableRowInsertAfter],onClick:()=>N({...e,after:!0})},{id:i.tableRowDelete,label:"Delete row",icon:v[i.tableRowDelete],onClick:()=>ee(e)},{id:i.tableRowProperties,label:Q,icon:v[i.tableRowProperties],onClick:({event:l})=>Be({...e,event:l})},{id:i.tableRowCut,label:"Cut row",icon:v[i.tableRowCut],onClick:()=>Ae(e)},{id:i.tableRowCopy,label:"Copy row",icon:v[i.tableRowCopy],onClick:()=>te(e)},{id:i.tableRowPasteBefore,label:"Paste row before",icon:v[i.tableRowPasteBefore],disabled:!t,onClick:()=>F(e)},{id:i.tableRowPasteAfter,label:"Paste row after",icon:v[i.tableRowPasteAfter],disabled:!t,onClick:()=>F({...e,after:!0})}]},...q(e)]},T=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function ne(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:r,colspan:a}=T(s);if(t[l])for(;t[l][n];)n++;for(let c=l;c<l+r;c++){t[c]||(t[c]=[]);for(let h=n;h<n+a;h++)t[c][h]={real:c===l&&h===n,cell:s,rowspan:r,colspan:a}}})}),t}function C(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const I=e=>e.closestType(g);function xe(e,{x:t,y:o,rows:l,cols:s}){var a;let n=I(e[o][t].cell),r;for(let c=1;c<=l;c++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(r=t;r>=0;r--){const{cell:h}=e[o+c][r],d=I(h);if(d===n){for(let b=1;b<=s;b++){const f=h.index();d.append({type:u},{at:f+1})}break}}if(r===-1){const d=n.components().at(0).index();for(let b=1;b<=s;b++)n.append({type:u},{at:d})}}}function se(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:r}=T(s);if(r>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<r-1;a++){const c=s.index();I(s).append({type:u},{at:c+1})}xe(e,{x:o,y:t,rows:n-1,cols:r})}}}}function Ie(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const B=(e,t={})=>{var r;const o=ne(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let c=0;c<o[a].length;c++){const h=o[a][c];if((r=t.selected)!=null&&r.includes(h.cell)||l.selected.hasComponent(h.cell)){const d={x:c,y:a};s||(s=d),n=d}}return{grid:o,startPos:s,endPos:n}};function ke(e,t={}){const o=B(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:r}=e;if(!l||!s)return;const a=l.x,c=l.y,h=s.x,d=s.y,b=C(n,a,c),f=C(n,h,d);if(b&&f){se(n),n=ne(e);const w=[],V=C(n,a,c).cell;V.addAttributes({colspan:h-a+1,rowspan:d-c+1});for(let m=c;m<=d;m++)for(let z=a;z<=h;z++){const P=C(n,z,m);if(!P)continue;const{cell:S}=P;S!==V&&w.push(S)}w.forEach(m=>{t.mergeContent&&V.append(m.components().models),m.remove()}),r.setSelected(V),Ie(e)}}const ae="Cell settings",Me="Merge cells",Te="Split cell",Se=e=>e.closestType(g),H=e=>{var t;return(t=Se(e))==null?void 0:t.parent()},De=e=>{const t=e.editor.getSelectedAll(),o=H(t[0]),l=t[0];if(!o||!(l!=null&&l.is(u))||t.length>1)return!1;const{rowspan:s,colspan:n}=T(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=H(o),{grid:s}=B(l);se(s)},ce=e=>{const t=e.editor.getSelectedAll(),o=H(t[0]);if(!o||t.length<2||t.some(a=>!a.is(u)||H(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=B(o),{em:r}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let c=s.x;c<=n.x;c++){const h=C(l,c,a);if(!h||!r.selected.hasComponent(h.cell))return!1}return!0},Ee=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=H(o[0]);ke(l,{mergeContent:!0})},Ze=e=>{M(e,{id:"tableCellSettings",header:{label:ae}})},Ne=e=>[{id:i.tableCellItems,icon:v[i.tableCellProperties],label:"Cell",items:[{id:i.tableCellProperties,label:ae,icon:v[i.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:i.tableCellMerge,label:Me,icon:v[i.tableCellMerge],onClick:()=>Ee(e),disabled:!ce(e)},{id:i.tableCellSplit,label:Te,icon:v[i.tableCellSplit],onClick:()=>Le(e),disabled:!De(e)}]},...ze(e),...oe(e)],Fe=e=>{const t=e[0]&&H(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=B(t,{selected:e});if(!l||!s)return;const n=[];for(let r=l.y;r<=s.y;r++)for(let a=l.x;a<=s.x;a++){const c=C(o,a,r);c&&n.push(c.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},$e="tableComponent",Oe=function(e,t={}){const o={block:{},...t},{Components:l}=e,s={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};l.addType(p,{block:o.block&&{label:"Table",media:v.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:v.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:r,value:a,emitUpdate:c}){const h=r.find("caption")[0];a?!h&&r.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),c(),e.refresh({tools:!0})},getValue(r){return!!r.component.find("caption")[0]}}],components:Ce(x,{rows:5}),contextMenu:({items:r,editor:a,component:c})=>[...q({editor:a,component:c,opts:o}),...r]}}}),l.addType(G,{model:{defaults:{icon:v.tableHead,...s}}}),l.addType(_,{model:{defaults:{icon:v.tableFoot,...s}}}),l.addType(x,{model:{defaults:{icon:v.tableRowProperties,...s}}}),l.addType(g,{model:{defaults:{icon:v.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:r,editor:a,component:c})=>[...oe({editor:a,component:c,opts:o}),...r]}}}),l.addType(u,{model:{defaults:{icon:v.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:r,editor:a,component:c})=>[...Ne({editor:a,component:c,opts:o}),...r]}}});const n=re((r,a)=>{var b;const c=e.getSelectedAll(),h=!!((b=a==null?void 0:a.event)!=null&&b.shiftKey);if(c.length<2||!h||a.fromCell)return;const d=c.map(f=>f.is(u)?f:f.closestType(u)).filter(Boolean);d.length===c.length&&Fe(d)},0);e.on("component:select",n),fe({editor:e,plan:y.startup,licenseKey:o.licenseKey,pluginName:$e,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(p),we.forEach(r=>l.removeType(r))}})},We=pe(Oe);module.exports=We;
@@ -1,3 +1,4 @@
1
+ import "grapesjs";
1
2
  function re(e, t, o) {
2
3
  let l, s, n, r, a;
3
4
  const c = t;
@@ -783,14 +784,14 @@ const ae = "Cell settings", Me = "Merge cells", Te = "Split cell", Se = (e) => e
783
784
  }, 0);
784
785
  e.on("component:select", n), fe({
785
786
  editor: e,
786
- plan: y.free,
787
+ plan: y.startup,
787
788
  licenseKey: o.licenseKey,
788
789
  pluginName: $e,
789
790
  cleanup: () => {
790
791
  e.off("component:select", n), e.Blocks.remove(p), we.forEach((r) => l.removeType(r));
791
792
  }
792
793
  });
793
- }, We = pe(Oe);
794
+ }, Ue = pe(Oe);
794
795
  export {
795
- We as default
796
+ Ue as default
796
797
  };
@@ -1 +1 @@
1
- (function(z,w){typeof exports=="object"&&typeof module<"u"?module.exports=w():typeof define=="function"&&define.amd?define(w):(z=typeof globalThis<"u"?globalThis:z||self,z.StudioSdkPlugins_tableComponent=w())})(this,function(){"use strict";function z(e,t,o){let l,s,n,i,a;const c=t;function h(){const b=Date.now()-i;b<c&&b>=0?l=setTimeout(h,c-b):(l=null,a=e.apply(n,s),n=s=null)}const d=function(){return n=this,s=arguments,i=Date.now(),l||(l=setTimeout(h,c)),a};return d.clear=function(){l&&(clearTimeout(l),l=null)},d.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},d}const w="app.grapesjs.com",L="app-stage.grapesjs.com",E=[w,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],re="license:check:start",he="license:check:end",de=()=>typeof window<"u",ve=({isDev:e,isStage:t})=>`${e?"":`https://${t?L:w}`}/api`,be=()=>{const e=de()&&window.location.hostname;return!!e&&(E.includes(e)||E.some(t=>e.endsWith(t)))};function Z(e){return typeof e=="function"}var y=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(y||{});async function ue({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:s,body:n}){const a=`${t||ve({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...l}};n&&(c.body=JSON.stringify(n));const h=s?new URLSearchParams(s).toString():"",d=h?`?${h}`:"",b=await fetch(`${a}${d}`,c);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const N={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function ge(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>ge(e);async function fe({editor:e,plan:t,pluginName:o,licenseKey:l,cleanup:s}){let n="",i=!1;const a=be(),c=d=>{console.warn("Cleanup plugin:",o,"Reason:",d),s()},h=(d={})=>{var m;const{error:b,sdkLicense:f}=d,V=(m=d.plan)==null?void 0:m.category;if(!(f||d.license)||b)c(b||"Invalid license");else if(V){const A=N[t],k=N[V];A>k&&c({pluginRequiredPlan:t,licensePlan:V})}};e.on(re,d=>{n=d==null?void 0:d.baseApiUrl,i=!0}),e.on(he,d=>{h(d)}),setTimeout(async()=>{if(!i){if(a)return;if(l){const d=await me({licenseKey:l,pluginName:o,baseApiUrl:n});d&&h(d)}else c("The `licenseKey` option not provided")}},2e3)}async function me(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await ue({baseApiUrl:l,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}var F=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(F||{}),r=(e=>(e.table="table",e.tableSettings="tableSettings",e.tableDelete="tableDelete",e.tableHead="tableHead",e.tableFoot="tableFoot",e.tableCellItems="tableCellItems",e.tableCellProperties="tableCellProperties",e.tableCellMerge="tableCellMerge",e.tableCellSplit="tableCellSplit",e.tableRowItems="tableRowItems",e.tableRowInsertBefore="tableRowInsertBefore",e.tableRowInsertAfter="tableRowInsertAfter",e.tableRowDelete="tableRowDelete",e.tableRowProperties="tableRowProperties",e.tableRowCut="tableRowCut",e.tableRowCopy="tableRowCopy",e.tableRowPasteBefore="tableRowPasteBefore",e.tableRowPasteAfter="tableRowPasteAfter",e.tableColumn="tableColumn",e.tableColumnItems="tableColumnItems",e.tableColumnInsertBefore="tableColumnInsertBefore",e.tableColumnInsertAfter="tableColumnInsertAfter",e.tableColumnDelete="tableColumnDelete",e.tableColumnCut="tableColumnCut",e.tableColumnCopy="tableColumnCopy",e.tableColumnPasteBefore="tableColumnPasteBefore",e.tableColumnPasteAfter="tableColumnPasteAfter",e))(r||{});const v={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},p="table",$="thead",O="tfoot",I="tbody",g="row",u="cell",M="clipboardTable",we=[p,$,O,I,g,u],B=e=>e.em.get(M)||[],ye=e=>e.every(t=>t.is(u)),T=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:i,y:a,width:c,height:h}=n.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,y:a,w:c,h},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...t};Z(s.openSettings)?s.openSettings({...e,layoutProps:d}):o.runCommand(F.layoutToggle,d)},Ce=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:g,components:Array.from(Array(o).keys()).map(n=>({type:u,components:l?{type:"text",content:Z(l)?l({y:s,x:n}):l}:void 0}))}))}),W="Table settings",U=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},He=e=>{var t;(t=U(e))==null||t.remove(e.opts)},Re=e=>{const t=U(e);t&&(e.editor.select(t),T(e,{id:"tableSettings",header:{label:W}}))},G=e=>[{id:r.table,icon:v[r.table],label:"Table",items:[{id:r.tableSettings,label:W,icon:v[r.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:r.tableDelete,label:"Delete table",icon:v[r.tableDelete],onClick:()=>He(e)}]}],_=({editor:e})=>{const t=B(e);return t.length&&ye(t)},j=({component:e,editor:t,after:o})=>{if(!e.is(u))return;const l=e.closestType(p),s=e.closestType(g),n=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:u},{at:n}));const i=s==null?void 0:s.components().at(n);i&&t.select(i)},K=({component:e,opts:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index();o==null||o.findType(g).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},q=({component:e,editor:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index(),s=(o==null?void 0:o.findType(g).map(n=>n.components().at(l)))||[];s.length&&t.em.set(M,s)},X=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(u)||!_(e))return;const s=B(o),n=t.closestType(p),i=t.index()+(l?1:0);n==null||n.findType(g).forEach((a,c)=>{const h=s[c],d=(h==null?void 0:h.clone())||{type:u};a.append(d,{at:i})})},Ve=e=>{const{component:t}=e;t.is(u)&&(q(e),K({...e,opts:{temporary:!0}}))},ze=e=>{const t=_(e);return[{id:r.tableColumnItems,icon:v[r.tableColumn],label:"Column",items:[{id:r.tableColumnInsertBefore,label:"Insert column before",icon:v[r.tableColumnInsertBefore],onClick:()=>j(e)},{id:r.tableColumnInsertAfter,label:"Insert column after",icon:v[r.tableColumnInsertAfter],onClick:()=>j({...e,after:!0})},{id:r.tableColumnDelete,label:"Delete column",icon:v[r.tableColumnDelete],onClick:()=>K(e)},{id:r.tableColumnCut,label:"Cut column",icon:v[r.tableColumnCut],onClick:()=>Ve(e)},{id:r.tableColumnCopy,label:"Copy column",icon:v[r.tableColumnCopy],onClick:()=>q(e)},{id:r.tableColumnPasteBefore,label:"Paste column before",icon:v[r.tableColumnPasteBefore],disabled:!t,onClick:()=>X(e)},{id:r.tableColumnPasteAfter,label:"Paste column after",icon:v[r.tableColumnPasteAfter],disabled:!t,onClick:()=>X({...e,after:!0})}]}]},Y="Row settings",Pe=e=>e.every(t=>t.is(g)),C=e=>{const{component:t}=e,o=t.is(u),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},J=e=>{const{component:t,editor:o,after:l}=e,s=C(e);if(!s)return;const n=s.index()+(l?1:0),i=s.components().length,a=Array.from(Array(i).keys()).map(()=>({type:u})),c=s.parent();if(c){const h=c.append({type:g,components:a},{at:n})[0];if(t.is(u)&&h){const d=t.index(),b=h.components().at(d);b&&o.select(b)}}},Q=e=>{var t;(t=C(e))==null||t.remove(e.opts)},ee=e=>{const t=C(e);t&&e.editor.em.set(M,[t])},te=e=>{var a;const{editor:t,after:o}=e,l=C(e);if(!l||!le(e))return;const n=B(t)[0],i=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:i}))},Ae=e=>{C(e)&&(ee(e),Q({...e,opts:{temporary:!0}}))},le=({editor:e})=>{const t=B(e);return t.length&&Pe(t)},Be=e=>{const t=C(e);t&&(e.editor.select(t),T(e,{id:"tableRowSettings",header:{label:Y}}))},oe=e=>{const t=le(e);return[{id:r.tableRowItems,icon:v[r.tableRowProperties],label:"Row",items:[{id:r.tableRowInsertBefore,label:"Insert row before",icon:v[r.tableRowInsertBefore],onClick:()=>J(e)},{id:r.tableRowInsertAfter,label:"Insert row after",icon:v[r.tableRowInsertAfter],onClick:()=>J({...e,after:!0})},{id:r.tableRowDelete,label:"Delete row",icon:v[r.tableRowDelete],onClick:()=>Q(e)},{id:r.tableRowProperties,label:Y,icon:v[r.tableRowProperties],onClick:({event:l})=>Be({...e,event:l})},{id:r.tableRowCut,label:"Cut row",icon:v[r.tableRowCut],onClick:()=>Ae(e)},{id:r.tableRowCopy,label:"Copy row",icon:v[r.tableRowCopy],onClick:()=>ee(e)},{id:r.tableRowPasteBefore,label:"Paste row before",icon:v[r.tableRowPasteBefore],disabled:!t,onClick:()=>te(e)},{id:r.tableRowPasteAfter,label:"Paste row after",icon:v[r.tableRowPasteAfter],disabled:!t,onClick:()=>te({...e,after:!0})}]},...G(e)]},S=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function ne(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:i,colspan:a}=S(s);if(t[l])for(;t[l][n];)n++;for(let c=l;c<l+i;c++){t[c]||(t[c]=[]);for(let h=n;h<n+a;h++)t[c][h]={real:c===l&&h===n,cell:s,rowspan:i,colspan:a}}})}),t}function H(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const D=e=>e.closestType(g);function xe(e,{x:t,y:o,rows:l,cols:s}){var a;let n=D(e[o][t].cell),i;for(let c=1;c<=l;c++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(i=t;i>=0;i--){const{cell:h}=e[o+c][i],d=D(h);if(d===n){for(let b=1;b<=s;b++){const f=h.index();d.append({type:u},{at:f+1})}break}}if(i===-1){const d=n.components().at(0).index();for(let b=1;b<=s;b++)n.append({type:u},{at:d})}}}function se(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:i}=S(s);if(i>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<i-1;a++){const c=s.index();D(s).append({type:u},{at:c+1})}xe(e,{x:o,y:t,rows:n-1,cols:i})}}}}function ke(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const x=(e,t={})=>{var i;const o=ne(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let c=0;c<o[a].length;c++){const h=o[a][c];if((i=t.selected)!=null&&i.includes(h.cell)||l.selected.hasComponent(h.cell)){const d={x:c,y:a};s||(s=d),n=d}}return{grid:o,startPos:s,endPos:n}};function Ie(e,t={}){const o=x(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:i}=e;if(!l||!s)return;const a=l.x,c=l.y,h=s.x,d=s.y,b=H(n,a,c),f=H(n,h,d);if(b&&f){se(n),n=ne(e);const V=[],P=H(n,a,c).cell;P.addAttributes({colspan:h-a+1,rowspan:d-c+1});for(let m=c;m<=d;m++)for(let A=a;A<=h;A++){const k=H(n,A,m);if(!k)continue;const{cell:ie}=k;ie!==P&&V.push(ie)}V.forEach(m=>{t.mergeContent&&P.append(m.components().models),m.remove()}),i.setSelected(P),ke(e)}}const ae="Cell settings",Me="Merge cells",Te="Split cell",Se=e=>e.closestType(g),R=e=>{var t;return(t=Se(e))==null?void 0:t.parent()},De=e=>{const t=e.editor.getSelectedAll(),o=R(t[0]),l=t[0];if(!o||!(l!=null&&l.is(u))||t.length>1)return!1;const{rowspan:s,colspan:n}=S(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=R(o),{grid:s}=x(l);se(s)},ce=e=>{const t=e.editor.getSelectedAll(),o=R(t[0]);if(!o||t.length<2||t.some(a=>!a.is(u)||R(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=x(o),{em:i}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let c=s.x;c<=n.x;c++){const h=H(l,c,a);if(!h||!i.selected.hasComponent(h.cell))return!1}return!0},Ee=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=R(o[0]);Ie(l,{mergeContent:!0})},Ze=e=>{T(e,{id:"tableCellSettings",header:{label:ae}})},Ne=e=>[{id:r.tableCellItems,icon:v[r.tableCellProperties],label:"Cell",items:[{id:r.tableCellProperties,label:ae,icon:v[r.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:r.tableCellMerge,label:Me,icon:v[r.tableCellMerge],onClick:()=>Ee(e),disabled:!ce(e)},{id:r.tableCellSplit,label:Te,icon:v[r.tableCellSplit],onClick:()=>Le(e),disabled:!De(e)}]},...ze(e),...oe(e)],Fe=e=>{const t=e[0]&&R(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=x(t,{selected:e});if(!l||!s)return;const n=[];for(let i=l.y;i<=s.y;i++)for(let a=l.x;a<=s.x;a++){const c=H(o,a,i);c&&n.push(c.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},$e="tableComponent";return pe(function(e,t={}){const o={block:{},...t},{Components:l}=e,s={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};l.addType(p,{block:o.block&&{label:"Table",media:v.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:v.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:i,value:a,emitUpdate:c}){const h=i.find("caption")[0];a?!h&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),c(),e.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Ce(I,{rows:5}),contextMenu:({items:i,editor:a,component:c})=>[...G({editor:a,component:c,opts:o}),...i]}}}),l.addType($,{model:{defaults:{icon:v.tableHead,...s}}}),l.addType(O,{model:{defaults:{icon:v.tableFoot,...s}}}),l.addType(I,{model:{defaults:{icon:v.tableRowProperties,...s}}}),l.addType(g,{model:{defaults:{icon:v.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:a,component:c})=>[...oe({editor:a,component:c,opts:o}),...i]}}}),l.addType(u,{model:{defaults:{icon:v.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:i,editor:a,component:c})=>[...Ne({editor:a,component:c,opts:o}),...i]}}});const n=z((i,a)=>{var b;const c=e.getSelectedAll(),h=!!((b=a==null?void 0:a.event)!=null&&b.shiftKey);if(c.length<2||!h||a.fromCell)return;const d=c.map(f=>f.is(u)?f:f.closestType(u)).filter(Boolean);d.length===c.length&&Fe(d)},0);e.on("component:select",n),fe({editor:e,plan:y.free,licenseKey:o.licenseKey,pluginName:$e,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(p),we.forEach(i=>l.removeType(i))}})})});
1
+ (function(z,w){typeof exports=="object"&&typeof module<"u"?module.exports=w(require("grapesjs")):typeof define=="function"&&define.amd?define(["grapesjs"],w):(z=typeof globalThis<"u"?globalThis:z||self,z.StudioSdkPlugins_tableComponent=w())})(this,function(){"use strict";function z(e,t,o){let l,s,n,i,a;const c=t;function h(){const b=Date.now()-i;b<c&&b>=0?l=setTimeout(h,c-b):(l=null,a=e.apply(n,s),n=s=null)}const d=function(){return n=this,s=arguments,i=Date.now(),l||(l=setTimeout(h,c)),a};return d.clear=function(){l&&(clearTimeout(l),l=null)},d.flush=function(){l&&(a=e.apply(n,s),n=s=null,clearTimeout(l),l=null)},d}const w="app.grapesjs.com",L="app-stage.grapesjs.com",E=[w,L,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],re="license:check:start",he="license:check:end",de=()=>typeof window<"u",ve=({isDev:e,isStage:t})=>`${e?"":`https://${t?L:w}`}/api`,be=()=>{const e=de()&&window.location.hostname;return!!e&&(E.includes(e)||E.some(t=>e.endsWith(t)))};function Z(e){return typeof e=="function"}var y=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(y||{});async function ue({path:e,baseApiUrl:t,method:o="GET",headers:l={},params:s,body:n}){const a=`${t||ve({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...l}};n&&(c.body=JSON.stringify(n));const h=s?new URLSearchParams(s).toString():"",d=h?`?${h}`:"",b=await fetch(`${a}${d}`,c);if(!b.ok)throw new Error(`HTTP error! status: ${b.status}`);return b.json()}const N={[y.free]:0,[y.startup]:10,[y.business]:20,[y.enterprise]:30};function ge(e){const t=e;return t.init=o=>l=>e(l,o),t}const pe=e=>ge(e);async function fe({editor:e,plan:t,pluginName:o,licenseKey:l,cleanup:s}){let n="",i=!1;const a=be(),c=d=>{console.warn("Cleanup plugin:",o,"Reason:",d),s()},h=(d={})=>{var m;const{error:b,sdkLicense:f}=d,V=(m=d.plan)==null?void 0:m.category;if(!(f||d.license)||b)c(b||"Invalid license");else if(V){const A=N[t],k=N[V];A>k&&c({pluginRequiredPlan:t,licensePlan:V})}};e.on(re,d=>{n=d==null?void 0:d.baseApiUrl,i=!0}),e.on(he,d=>{h(d)}),setTimeout(async()=>{if(!i){if(a)return;if(l){const d=await me({licenseKey:l,pluginName:o,baseApiUrl:n});d&&h(d)}else c("The `licenseKey` option not provided")}},2e3)}async function me(e){const{licenseKey:t,pluginName:o,baseApiUrl:l}=e;try{return(await ue({baseApiUrl:l,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}var F=(e=>(e.toastAdd="studio:toastAdd",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.projectFiles="studio:projectFiles",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e))(F||{}),r=(e=>(e.table="table",e.tableSettings="tableSettings",e.tableDelete="tableDelete",e.tableHead="tableHead",e.tableFoot="tableFoot",e.tableCellItems="tableCellItems",e.tableCellProperties="tableCellProperties",e.tableCellMerge="tableCellMerge",e.tableCellSplit="tableCellSplit",e.tableRowItems="tableRowItems",e.tableRowInsertBefore="tableRowInsertBefore",e.tableRowInsertAfter="tableRowInsertAfter",e.tableRowDelete="tableRowDelete",e.tableRowProperties="tableRowProperties",e.tableRowCut="tableRowCut",e.tableRowCopy="tableRowCopy",e.tableRowPasteBefore="tableRowPasteBefore",e.tableRowPasteAfter="tableRowPasteAfter",e.tableColumn="tableColumn",e.tableColumnItems="tableColumnItems",e.tableColumnInsertBefore="tableColumnInsertBefore",e.tableColumnInsertAfter="tableColumnInsertAfter",e.tableColumnDelete="tableColumnDelete",e.tableColumnCut="tableColumnCut",e.tableColumnCopy="tableColumnCopy",e.tableColumnPasteBefore="tableColumnPasteBefore",e.tableColumnPasteAfter="tableColumnPasteAfter",e))(r||{});const v={table:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableSettings:'<svg viewBox="0 0 24 24"><path d="M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2m0 4v4h6V8H5m8 0v4h6V8h-6m-8 6v4h6v-4H5m8 0v4h6v-4h-6Z"/></svg>',tableDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="m14.4 8.6 1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></svg>',tableHead:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableFoot:'<svg viewBox="0 0 24 24" data-test="1" style="transform: rotate(180deg);"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm-8 11H5v3h6v-3Zm8 0h-6v3h6v-3Zm0-5h-6v3h6v-3ZM5 13h6v-3H5v3Z"/></svg>',tableColumn:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14Zm0 9h-4v5h4v-5Zm-6 0H9v5h4v-5Zm0-7H9v5h4V6Zm6 0h-4v5h4V6Z"/></svg>',tableCellItems:"",tableCellProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',tableCellMerge:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6l2-2h14zM5 16v2h3v-2H5zm14-5h-9v7h9v-7zm0-5h-4v3h4V6zM8 6H5v3h3V6zm5 0h-3v3h3V6zm-8 8h3v-3H5v3z"/></svg>',tableCellSplit:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1 1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',tableRowItems:"",tableRowInsertBefore:'<svg viewBox="0 0 24 24"><path d="M6 4a1 1 0 1 1 0 2H5v6h14V6h-1a1 1 0 0 1 0-2h2c.6 0 1 .4 1 1v13a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 0 1 0 2h-2v2a1 1 0 0 1-2 .1V8H9a1 1 0 0 1 0-2h2V4c0-.6.4-1 1-1z"/></svg>',tableRowInsertAfter:'<svg viewBox="0 0 24 24"><path d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 0 1 .1 2H13v2a1 1 0 0 1-2 .1V18H9a1 1 0 0 1-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 0 1 0-2h1v-6H5v6h1a1 1 0 0 1 0 2H4a1 1 0 0 1-1-1V6c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',tableRowDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8 1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',tableRowProperties:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',tableRowCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 0 1-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2a3 3 0 0 1 1-2.2A3.7 3.7 0 0 1 8.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 0 1 0-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 0 0-.8.4 2.5 2.5 0 0 0-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 0 0 .8-.3L9 18l.4-.4.2-.4.1-.4v-.7a1 1 0 0 0-.2-.5 1 1 0 0 0-.4-.2h-.5zm7 0H15a1 1 0 0 0-.4.3 1 1 0 0 0-.2.5 1.5 1.5 0 0 0 0 .7v.4a2.8 2.8 0 0 0 .5.7h.1a2.8 2.8 0 0 0 .8.6l.4.1h.7l.5-.2.2-.5v-.7a2.6 2.6 0 0 0-.3-.8 2.4 2.4 0 0 0-.7-.7 2.5 2.5 0 0 0-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',tableRowCopy:'<svg viewBox="0 0 24 24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',tableRowPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableRowPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnItems:"",tableColumnInsertBefore:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 2 0v1h8V6H5v1a1 1 0 1 1-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H9v2a1 1 0 0 1-2 .1V13H5a1 1 0 0 1-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',tableColumnInsertAfter:'<svg viewBox="0 0 24 24"><path d="M20 4c.6 0 1 .4 1 1v2a1 1 0 0 1-2 0V6h-8v12h8v-1a1 1 0 0 1 2 0v2c0 .5-.4 1-.9 1H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 0 1 .1 2H17v2a1 1 0 0 1-2 .1V13h-2a1 1 0 0 1-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',tableColumnDelete:'<svg viewBox="0 0 24 24"><path d="M19 4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5 1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',tableColumnCut:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M7.2 4.5a3 3 0 0 1 2.2 1A3.7 3.7 0 0 1 10.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 0 1 2 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 0 1 7 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 0 0-.7.4v.1a2.8 2.8 0 0 0-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 0 0 .8-.3 2.4 2.4 0 0 0 .7-.7 2.5 2.5 0 0 0 .3-.8 1.5 1.5 0 0 0 0-.8 1 1 0 0 0-.2-.4 1 1 0 0 0-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 0 0-.5.3 1 1 0 0 0-.2.5v.7a2.5 2.5 0 0 0 .3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 0 0 0-.8 2.6 2.6 0 0 0-.3-.8 2.5 2.5 0 0 0-1.2-1l-.4-.1H7z"/></svg>',tableColumnCopy:'<svg viewBox="0 0 24 24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',tableColumnPasteBefore:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v2H4V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>',tableColumnPasteAfter:'<svg viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 1a3 3 0 0 1 2.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 0 1-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h3.3A3 3 0 0 1 12 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/></svg>'},p="table",$="thead",O="tfoot",I="tbody",g="row",u="cell",M="clipboardTable",we=[p,$,O,I,g,u],B=e=>e.em.get(M)||[],ye=e=>e.every(t=>t.is(u)),T=(e,t)=>{const{editor:o,event:l,opts:s}=e,n=l.currentTarget||l.target,{x:i,y:a,width:c,height:h}=n.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:i,y:a,w:c,h},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...t};Z(s.openSettings)?s.openSettings({...e,layoutProps:d}):o.runCommand(F.layoutToggle,d)},Ce=(e,{rows:t=1,cells:o=5,text:l}={})=>({type:e,components:Array.from(Array(t).keys()).map(s=>({type:g,components:Array.from(Array(o).keys()).map(n=>({type:u,components:l?{type:"text",content:Z(l)?l({y:s,x:n}):l}:void 0}))}))}),W="Table settings",U=e=>{const{component:t}=e;return t.is(p)?t:t.closestType(p)},He=e=>{var t;(t=U(e))==null||t.remove(e.opts)},Re=e=>{const t=U(e);t&&(e.editor.select(t),T(e,{id:"tableSettings",header:{label:W}}))},j=e=>[{id:r.table,icon:v[r.table],label:"Table",items:[{id:r.tableSettings,label:W,icon:v[r.tableSettings],onClick:({event:o})=>Re({...e,event:o})},{id:r.tableDelete,label:"Delete table",icon:v[r.tableDelete],onClick:()=>He(e)}]}],G=({editor:e})=>{const t=B(e);return t.length&&ye(t)},_=({component:e,editor:t,after:o})=>{if(!e.is(u))return;const l=e.closestType(p),s=e.closestType(g),n=e.index()+(o?1:0);l==null||l.findType(g).forEach(a=>a.append({type:u},{at:n}));const i=s==null?void 0:s.components().at(n);i&&t.select(i)},K=({component:e,opts:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index();o==null||o.findType(g).forEach(s=>{var n;return(n=s.components().at(l))==null?void 0:n.remove(t)})},q=({component:e,editor:t})=>{if(!e.is(u))return;const o=e.closestType(p),l=e.index(),s=(o==null?void 0:o.findType(g).map(n=>n.components().at(l)))||[];s.length&&t.em.set(M,s)},X=e=>{const{component:t,editor:o,after:l}=e;if(!t.is(u)||!G(e))return;const s=B(o),n=t.closestType(p),i=t.index()+(l?1:0);n==null||n.findType(g).forEach((a,c)=>{const h=s[c],d=(h==null?void 0:h.clone())||{type:u};a.append(d,{at:i})})},Ve=e=>{const{component:t}=e;t.is(u)&&(q(e),K({...e,opts:{temporary:!0}}))},ze=e=>{const t=G(e);return[{id:r.tableColumnItems,icon:v[r.tableColumn],label:"Column",items:[{id:r.tableColumnInsertBefore,label:"Insert column before",icon:v[r.tableColumnInsertBefore],onClick:()=>_(e)},{id:r.tableColumnInsertAfter,label:"Insert column after",icon:v[r.tableColumnInsertAfter],onClick:()=>_({...e,after:!0})},{id:r.tableColumnDelete,label:"Delete column",icon:v[r.tableColumnDelete],onClick:()=>K(e)},{id:r.tableColumnCut,label:"Cut column",icon:v[r.tableColumnCut],onClick:()=>Ve(e)},{id:r.tableColumnCopy,label:"Copy column",icon:v[r.tableColumnCopy],onClick:()=>q(e)},{id:r.tableColumnPasteBefore,label:"Paste column before",icon:v[r.tableColumnPasteBefore],disabled:!t,onClick:()=>X(e)},{id:r.tableColumnPasteAfter,label:"Paste column after",icon:v[r.tableColumnPasteAfter],disabled:!t,onClick:()=>X({...e,after:!0})}]}]},Y="Row settings",Pe=e=>e.every(t=>t.is(g)),C=e=>{const{component:t}=e,o=t.is(u),l=t.is(g);if(!(!o&&!l))return l?t:t.closestType(g)},J=e=>{const{component:t,editor:o,after:l}=e,s=C(e);if(!s)return;const n=s.index()+(l?1:0),i=s.components().length,a=Array.from(Array(i).keys()).map(()=>({type:u})),c=s.parent();if(c){const h=c.append({type:g,components:a},{at:n})[0];if(t.is(u)&&h){const d=t.index(),b=h.components().at(d);b&&o.select(b)}}},Q=e=>{var t;(t=C(e))==null||t.remove(e.opts)},ee=e=>{const t=C(e);t&&e.editor.em.set(M,[t])},te=e=>{var a;const{editor:t,after:o}=e,l=C(e);if(!l||!le(e))return;const n=B(t)[0],i=l.index()+(o?1:0);n&&((a=l.parent())==null||a.append(n.clone(),{at:i}))},Ae=e=>{C(e)&&(ee(e),Q({...e,opts:{temporary:!0}}))},le=({editor:e})=>{const t=B(e);return t.length&&Pe(t)},Be=e=>{const t=C(e);t&&(e.editor.select(t),T(e,{id:"tableRowSettings",header:{label:Y}}))},oe=e=>{const t=le(e);return[{id:r.tableRowItems,icon:v[r.tableRowProperties],label:"Row",items:[{id:r.tableRowInsertBefore,label:"Insert row before",icon:v[r.tableRowInsertBefore],onClick:()=>J(e)},{id:r.tableRowInsertAfter,label:"Insert row after",icon:v[r.tableRowInsertAfter],onClick:()=>J({...e,after:!0})},{id:r.tableRowDelete,label:"Delete row",icon:v[r.tableRowDelete],onClick:()=>Q(e)},{id:r.tableRowProperties,label:Y,icon:v[r.tableRowProperties],onClick:({event:l})=>Be({...e,event:l})},{id:r.tableRowCut,label:"Cut row",icon:v[r.tableRowCut],onClick:()=>Ae(e)},{id:r.tableRowCopy,label:"Copy row",icon:v[r.tableRowCopy],onClick:()=>ee(e)},{id:r.tableRowPasteBefore,label:"Paste row before",icon:v[r.tableRowPasteBefore],disabled:!t,onClick:()=>te(e)},{id:r.tableRowPasteAfter,label:"Paste row after",icon:v[r.tableRowPasteAfter],disabled:!t,onClick:()=>te({...e,after:!0})}]},...j(e)]},S=e=>{const t=e.attributes.attributes||{},o=parseInt(`${t.rowspan||1}`,10),l=parseInt(`${t.colspan||1}`,10);return{rowspan:o,colspan:l}};function ne(e){const t=[];return e.components().forEach((o,l)=>{o.components().each((s,n)=>{const{rowspan:i,colspan:a}=S(s);if(t[l])for(;t[l][n];)n++;for(let c=l;c<l+i;c++){t[c]||(t[c]=[]);for(let h=n;h<n+a;h++)t[c][h]={real:c===l&&h===n,cell:s,rowspan:i,colspan:a}}})}),t}function H(e,t,o){var l;return(l=e[o])==null?void 0:l[t]}const D=e=>e.closestType(g);function xe(e,{x:t,y:o,rows:l,cols:s}){var a;let n=D(e[o][t].cell),i;for(let c=1;c<=l;c++)if(n=(a=n==null?void 0:n.parent())==null?void 0:a.components().at(n.index()+1),n){for(i=t;i>=0;i--){const{cell:h}=e[o+c][i],d=D(h);if(d===n){for(let b=1;b<=s;b++){const f=h.index();d.append({type:u},{at:f+1})}break}}if(i===-1){const d=n.components().at(0).index();for(let b=1;b<=s;b++)n.append({type:u},{at:d})}}}function se(e){for(let t=0;t<e.length;t++)for(let o=0;o<e[t].length;o++){const s=e[t][o].cell;if(s.em.selected.hasComponent(s)){const{rowspan:n,colspan:i}=S(s);if(i>1||n>1){s.addAttributes({colspan:1,rowspan:1});for(let a=0;a<i-1;a++){const c=s.index();D(s).append({type:u},{at:c+1})}xe(e,{x:o,y:t,rows:n-1,cols:i})}}}}function ke(e){const t=[];e.components().forEach(o=>{o.components().length||t.push(o)}),t.forEach(o=>o.remove())}const x=(e,t={})=>{var i;const o=ne(e),{em:l}=e;let s,n;for(let a=0;a<o.length;a++)for(let c=0;c<o[a].length;c++){const h=o[a][c];if((i=t.selected)!=null&&i.includes(h.cell)||l.selected.hasComponent(h.cell)){const d={x:c,y:a};s||(s=d),n=d}}return{grid:o,startPos:s,endPos:n}};function Ie(e,t={}){const o=x(e),{startPos:l,endPos:s}=o;let{grid:n}=o;const{em:i}=e;if(!l||!s)return;const a=l.x,c=l.y,h=s.x,d=s.y,b=H(n,a,c),f=H(n,h,d);if(b&&f){se(n),n=ne(e);const V=[],P=H(n,a,c).cell;P.addAttributes({colspan:h-a+1,rowspan:d-c+1});for(let m=c;m<=d;m++)for(let A=a;A<=h;A++){const k=H(n,A,m);if(!k)continue;const{cell:ie}=k;ie!==P&&V.push(ie)}V.forEach(m=>{t.mergeContent&&P.append(m.components().models),m.remove()}),i.setSelected(P),ke(e)}}const ae="Cell settings",Me="Merge cells",Te="Split cell",Se=e=>e.closestType(g),R=e=>{var t;return(t=Se(e))==null?void 0:t.parent()},De=e=>{const t=e.editor.getSelectedAll(),o=R(t[0]),l=t[0];if(!o||!(l!=null&&l.is(u))||t.length>1)return!1;const{rowspan:s,colspan:n}=S(l);return!(n<2&&s<2)},Le=e=>{const o=e.editor.getSelectedAll()[0],l=R(o),{grid:s}=x(l);se(s)},ce=e=>{const t=e.editor.getSelectedAll(),o=R(t[0]);if(!o||t.length<2||t.some(a=>!a.is(u)||R(a)!==o))return!1;const{grid:l,startPos:s,endPos:n}=x(o),{em:i}=o;if(!s||!n)return!1;for(let a=s.y;a<=n.y;a++)for(let c=s.x;c<=n.x;c++){const h=H(l,c,a);if(!h||!i.selected.hasComponent(h.cell))return!1}return!0},Ee=e=>{const{editor:t}=e;if(!ce(e))return;const o=t.getSelectedAll(),l=R(o[0]);Ie(l,{mergeContent:!0})},Ze=e=>{T(e,{id:"tableCellSettings",header:{label:ae}})},Ne=e=>[{id:r.tableCellItems,icon:v[r.tableCellProperties],label:"Cell",items:[{id:r.tableCellProperties,label:ae,icon:v[r.tableCellProperties],onClick:({event:o})=>Ze({...e,event:o})},{id:r.tableCellMerge,label:Me,icon:v[r.tableCellMerge],onClick:()=>Ee(e),disabled:!ce(e)},{id:r.tableCellSplit,label:Te,icon:v[r.tableCellSplit],onClick:()=>Le(e),disabled:!De(e)}]},...ze(e),...oe(e)],Fe=e=>{const t=e[0]&&R(e[0]);if(!t)return;const{grid:o,startPos:l,endPos:s}=x(t,{selected:e});if(!l||!s)return;const n=[];for(let i=l.y;i<=s.y;i++)for(let a=l.x;a<=s.x;a++){const c=H(o,a,i);c&&n.push(c.cell)}n.length&&t.em.setSelected(n,{fromCell:!0})},$e="tableComponent";return pe(function(e,t={}){const o={block:{},...t},{Components:l}=e,s={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};l.addType(p,{block:o.block&&{label:"Table",media:v.table,category:"Extra",content:{type:p,style:{width:"100%"}},select:!0,...o.block},model:{defaults:{emptyState:!0,highlightable:!1,icon:v.table,stylable:["width","height","margin","font-family","font-size","font-weight","line-height","text-align","background","background-color","border-width","border-style","border-color"],traits:[{type:"number",min:0,name:"cellspacing",label:"Cell spacing"},{type:"number",min:0,name:"cellpadding",label:"Cell padding"},{id:"tableCaption",type:"checkbox",label:"Caption",setValue({component:i,value:a,emitUpdate:c}){const h=i.find("caption")[0];a?!h&&i.append({type:"text",tagName:"caption",components:{type:"textnode",content:"Caption"}}):h==null||h.remove(),c(),e.refresh({tools:!0})},getValue(i){return!!i.component.find("caption")[0]}}],components:Ce(I,{rows:5}),contextMenu:({items:i,editor:a,component:c})=>[...j({editor:a,component:c,opts:o}),...i]}}}),l.addType($,{model:{defaults:{icon:v.tableHead,...s}}}),l.addType(O,{model:{defaults:{icon:v.tableFoot,...s}}}),l.addType(I,{model:{defaults:{icon:v.tableRowProperties,...s}}}),l.addType(g,{model:{defaults:{icon:v.tableRowProperties,emptyState:!0,highlightable:!1,stylable:["height","text-align","border-width","border-style","border-color"],traits:[],contextMenu:({items:i,editor:a,component:c})=>[...oe({editor:a,component:c,opts:o}),...i]}}}),l.addType(u,{model:{defaults:{icon:v.tableCellProperties,emptyState:{styleOut:"height: 1px"},stylable:["width","height","padding","background-color","text-align","vertical-align","border-width","border-style","border-color"],traits:[{id:"tableCellType",type:"select",options:[{value:"td",name:"Cell"},{value:"th",name:"Header Cell"}],label:"Cell type",name:"tagName",changeProp:!0},{id:"tableCellScope",type:"select",options:[{value:!1,name:"None"},{value:"row",name:"Row"},{value:"col",name:"Column"},{value:"rowgroup",name:"Row group"},{value:"colgroup",name:"Column group"}],label:"Scope",name:"scope"}],contextMenu:({items:i,editor:a,component:c})=>[...Ne({editor:a,component:c,opts:o}),...i]}}});const n=z((i,a)=>{var b;const c=e.getSelectedAll(),h=!!((b=a==null?void 0:a.event)!=null&&b.shiftKey);if(c.length<2||!h||a.fromCell)return;const d=c.map(f=>f.is(u)?f:f.closestType(u)).filter(Boolean);d.length===c.length&&Fe(d)},0);e.on("component:select",n),fe({editor:e,plan:y.startup,licenseKey:o.licenseKey,pluginName:$e,cleanup:()=>{e.off("component:select",n),e.Blocks.remove(p),we.forEach(i=>l.removeType(i))}})})});
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SdkPlanCategories } from '@studio/app/src/app/types';
2
- import { Editor, Plugin } from 'grapesjs';
2
+ import { Editor, Plugin, Component, TraitProperties, Trait } from 'grapesjs';
3
3
  export { SdkPlanCategories } from '@studio/app/src/app/types';
4
4
  /**
5
5
  * Interface for the options of a plugin.
@@ -13,6 +13,16 @@ export interface SDKPluginOptions {
13
13
  */
14
14
  licenseKey?: string;
15
15
  }
16
+ export interface StudioPluginTraitProperties extends TraitProperties {
17
+ tip?: string;
18
+ labelToTitle?: boolean;
19
+ subTraits?: Record<string, StudioPluginTraitProperties[]>;
20
+ visible?: (props: {
21
+ component: Component;
22
+ trait: Trait;
23
+ }) => boolean;
24
+ }
25
+ export type StudioPluginTraits = Record<string, Partial<StudioPluginTraitProperties>>;
16
26
  export interface SDKPlugin<T extends SDKPluginOptions = SDKPluginOptions> extends Plugin<T> {
17
27
  }
18
28
  export interface PluginWithInit<T extends SDKPluginOptions = SDKPluginOptions> extends Plugin<T> {
@@ -27,4 +37,29 @@ export declare function subscribeToLicenseCheck({ editor, plan, pluginName, lice
27
37
  cleanup: () => void;
28
38
  }): Promise<void>;
29
39
  export declare const elHasAttribute: (el: HTMLElement, attrName: string) => boolean;
40
+ export declare const elHasClassName: (el: HTMLElement, className: string) => boolean;
41
+ /**
42
+ * A helper function to get props, value and trait defintion from StudioPluginTraits.
43
+ */
44
+ export declare const getSetupDataFromTraits: (traitProps: StudioPluginTraits, opts?: {
45
+ category?: StudioPluginTraitProperties["category"];
46
+ }) => {
47
+ propKeys: string[];
48
+ propsNoValues: string[];
49
+ props: Record<string, any>;
50
+ traits: StudioPluginTraitProperties[];
51
+ };
52
+ /**
53
+ * A helper function to initialize the traits of a plugin.
54
+ */
55
+ export declare const initSdkPluginTraits: (cmp: Component, traits: StudioPluginTraitProperties[]) => void;
56
+ export declare const updateSubTraits: (cmp: Component, traitId: string) => void;
57
+ /**
58
+ * This function allows to move props from kebab-case to camelCase.
59
+ * It's useful when props are added via HTML attributes (eg. data-gjs-my-prop="value") but
60
+ * the component has the camelCase format (eg. myProp).
61
+ *
62
+ * This function should be usually called on model.init of the component.
63
+ */
64
+ export declare const moveKebabPropsToCamelCase: (cmp: Component, camelProps: string[]) => void;
30
65
  export declare const CLS_PREFIX = "gjs-plg-";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapesjs/studio-sdk-plugins",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },