@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +175 -162
- package/dist/accordionComponent/index.umd.js +7 -7
- package/dist/aiChat/index.cjs.js +64 -64
- package/dist/aiChat/index.es.js +5785 -5757
- package/dist/aiChat/index.js +64 -64
- package/dist/aiChat/index.umd.js +63 -63
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +204 -191
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +183 -170
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +134 -121
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +165 -152
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +5 -5
- package/dist/canvasGridMode/index.es.js +245 -232
- package/dist/canvasGridMode/index.umd.js +4 -4
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +155 -142
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +9 -9
- package/dist/dataSourceEjs/index.es.js +257 -244
- package/dist/dataSourceEjs/index.umd.js +9 -9
- package/dist/dataSourceHandlebars/index.cjs.js +8 -8
- package/dist/dataSourceHandlebars/index.es.js +216 -203
- package/dist/dataSourceHandlebars/index.umd.js +7 -7
- package/dist/dialogComponent/index.cjs.js +14 -14
- package/dist/dialogComponent/index.es.js +141 -128
- package/dist/dialogComponent/index.umd.js +14 -14
- package/dist/flexComponent/index.cjs.js +13 -13
- package/dist/flexComponent/index.es.js +484 -471
- package/dist/flexComponent/index.umd.js +13 -13
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +173 -160
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +160 -147
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +196 -183
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +25 -25
- package/dist/index.es.js +121 -108
- package/dist/index.umd.js +18 -18
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +157 -144
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +245 -232
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +106 -93
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +157 -144
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +181 -168
- package/dist/presetPrintable/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +7 -7
- package/dist/prosemirror/index.es.js +385 -372
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +200 -187
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +118 -105
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +4 -4
- package/dist/shapeDividerComponent/index.es.js +129 -116
- package/dist/shapeDividerComponent/index.umd.js +4 -4
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +203 -190
- package/dist/swiperComponent/index.umd.js +7 -7
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +257 -244
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +121 -108
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const y=require("react/jsx-runtime"),h=require("react"),W=require("react-dom/client"),D="app.grapesjs.com",_="app-stage.grapesjs.com",$="app2.grapesjs.com",B="app-stage2.grapesjs.com",R=[D,$,_,B,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],L="license:check:start",F="license:check:end",K=()=>typeof window<"u",M=({isDev:e,isStage:t,isPlatform:n})=>`${e?"":`https://${t?_:D}`}/${n?"platform-api":"api"}`,V=()=>{const e=K()&&window.location.hostname;return!!e&&(R.includes(e)||R.some(t=>e.endsWith(t)))},z=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,n)=>(n?"-":"")+t.toLowerCase()),T=e=>typeof e=="string";function q(e){return typeof e=="function"}async function G({path:e,baseApiUrl:t,method:n="GET",headers:s={},params:r,body:o}){const c=`${t||M({isDev:!1,isStage:!1})}${e}`,i={method:n,headers:{"Content-Type":"application/json",...s}};o&&(i.body=JSON.stringify(o));const u=r?new URLSearchParams(r).toString():"",d=u?`?${u}`:"",p=await fetch(`${c}${d}`,i);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var v=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(v||{});const P={[v.free]:0,[v.startup]:10,[v.business]:20,[v.enterprise]:30};function J(e){const t=e;return t.init=n=>s=>e(s,n),t}const H=e=>J(e);async function Z({editor:e,plan:t,pluginName:n,licenseKey:s,onLicenseCheckResponse:r,cleanup:o}){let a="",c=!1;const i=V(),u=p=>{console.warn("Cleanup plugin:",n,"Reason:",p),o()},d=(p={})=>{var b;const{error:m,sdkLicense:f}=p,l=(b=p.plan)==null?void 0:b.category;if(!(f||p.license)||m)u(m||"Invalid license");else if(l){const C=P[t],A=P[l];C>A&&u({pluginRequiredPlan:t,licensePlan:l})}};e.on(L,p=>{a=p==null?void 0:p.baseApiUrl,c=!0}),e.on(F,p=>{r==null||r(p),d(p)}),setTimeout(async()=>{if(!c){if(i)return;if(s){const p=await Q({licenseKey:s,pluginName:n,baseApiUrl:a});r==null||r(p),p&&d(p)}else u("The `licenseKey` option not provided")}},2e3)}async function Q(e){const{licenseKey:t,pluginName:n,baseApiUrl:s}=e;try{return(await G({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:n}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}function X(e){const t={};for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){const s=z(n);t[s]=e[n]}return t}const Y=(e,t)=>{const n=e.components||{};for(const s in n){const r=n[s];if(r.component===t)return{cmpConfig:r,type:s}}};function O(e){const t={};let n=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(typeof r=="string"||typeof r=="number"){const o=s.includes("-")?s.replace(/-([a-z])/g,a=>a[1].toUpperCase()):s;t[o]=r,n=!0}}return n?t:void 0}function ee(e){const t={};return e.split(";").forEach(n=>{if(!n.trim())return;const s=n.indexOf(":");if(s>0){const r=n.substring(0,s).trim(),o=n.substring(s+1).trim();if(r&&o){const a=r.replace(/-([a-z])/g,c=>c[1].toUpperCase());t[a]=o}}}),Object.keys(t).length>0?t:void 0}function te(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return O(e);if(typeof e=="string"){let t=ee(e);if(!t)try{const n=JSON.parse(e);typeof n=="object"&&n!==null&&!Array.isArray(n)&&(t=O(n))}catch(n){console.error("Failed to parse style string as JSON",n)}return t}if(Array.isArray(e)){const t={};return e.forEach(n=>{if(typeof n=="object"&&n!==null){const s=n.name||n.property,r=n.value;if(typeof s=="string"&&s&&r!==void 0&&r!==""){const o=s.replace(/-([a-z])/g,a=>a[1].toUpperCase());t[o]=r}}}),Object.keys(t).length>0?t:void 0}}}function ne(e){return j[e]?j[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase()):e}function oe(e){var n;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=te(r);else if(s.startsWith("data-"))t[s]=r;else{const o=ne(s);((n=e.xmlns)==null?void 0:n.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||re.has(o)||o.startsWith("svg")?t[o]=r:!se.has(o)&&!o.startsWith("on")&&!o.startsWith("aria-")&&!o.startsWith("data-")?t[s]=r:t[o]=r}return t}const se=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),re=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),j={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},S=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ce(e){return t=>{const n=t.getContent();S(n)&&t.set({content:E({...e,model:n}),reactContent:n})}}const ae=e=>t=>{const n=t.component;S(n)&&(t.component={components:E({...e,model:n})})};function E(e){const{model:t,editor:n,config:s}=e;if(S(t)){const r=t,o={},{type:a,props:c={}}=r,{children:i,className:u,style:d,...p}=c,m=l=>({type:"textnode",content:l}),f=typeof a=="symbol";if(q(a)){const l=Y(s,a);o.type=l==null?void 0:l.type}else n.Components.getType(a)?o.type=a:f||(o.tagName=a);if(u&&(o.classes=u),d&&(o.style=X(d)),Array.isArray(i)?o.components=i.map(l=>T(l)?m(l):E({...e,model:l})).filter(Boolean):T(i)&&(o.components=m(i)),Object.keys(p).length){const l=n.Parser.parserHtml.splitPropsFromAttr(p);o.attributes=l.attrs,Object.assign(o,l.props)}return o}}function ie(e){const{component:t}=e,[n,s]=h.useState(0),[r,o]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const c=()=>s(l=>l+1),i=()=>{[...t.views].forEach(w=>w.remove()),o(void 0)},{em:u}=t,d=u.Components.events,m=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(m,c),t.on(f,i),()=>{t.off(m,c),t.off(f,i),i()}},[t]),{key:n,view:r,connectDom:c=>{if(!c)return;const i=le({...e,el:c});o(i)}}}function le(e){var i;const{editor:t,component:n,el:s,frameView:r}=e,{em:o,Components:a}=t;let c=n.getView(r.model);if((c==null?void 0:c.el)===s)return c;if(!c){const{ComponentView:u}=a,d=n.attributes.type||"default",p=((i=a.getType(d))==null?void 0:i.view)||u,m={...a.config,frameView:r,em:o},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});c=new f({el:s,config:m,model:n})}return c.el=s,c.render(),c}function pe(e,t){const{Components:n}=e,s=r=>{const{id:o,model:a}=r;n.addType(o,{model:{toJSON(...c){const i=a.prototype.toJSON.apply(this,c);return i.tagName=this.tagName,i}}})};n.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([r,o])=>{var m,f;const{allowPropClassName:a,allowPropId:c,allowChildren:i}=o,u=!c&&!a,d=()=>({disabled:u}),p=()=>({disableClasses:!a,disableComponent:!c});n.addType(r,{isComponent:l=>(l==null?void 0:l.tagName)===r,model:{defaults:{type:r,traits:((m=o.props)==null?void 0:m.call(o))||[],droppable:!!i,stylable:!u,styleManager:d,selectorManager:p,...((f=o.model)==null?void 0:f.defaults)||{}}}})})}function I(e){var N;const{component:t,config:n,editor:s,frameView:r,onMount:o,tagName:a,children:c}=e,{key:i,view:u,connectDom:d}=ie(e);h.useEffect(()=>{if(!u&&!o)return;const g=setTimeout(()=>{u&&(o==null||o(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(g)},[u]);const p=t.get("type")||"default",m=t.content,f=(N=n.components)==null?void 0:N[p],l=(f==null?void 0:f.component)||a||t.tagName||"div",w=t.components(),b=w.length?w.map(g=>y.jsx(I,{component:g,config:n,editor:s,frameView:r},g.cid)):[m||void 0],C=oe(t.getAttributes()),A=f==null?void 0:f.editorRender,x=[...b,c].filter(g=>g??!1),k=x.length?x:null;if(A)return y.jsx(A,{props:C,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...C,children:k})});if(t.isInstanceOf("textnode"))return m;const U=t.isInstanceOf("text")?i:void 0;return h.createElement(l,{...C,ref:d,key:U},t.get("void")?null:k)}const ue=e=>{const{frame:t,window:n,onMount:s,editor:r}=e,o=r.Canvas.events,{root:a}=t;try{const c=W.createRoot(n.document.body);c.render(y.jsx(fe,{...e,component:a,onMount:s}));const i=()=>c.unmount();t.once(o.frameUnload,i),n.addEventListener("unload",i)}catch(c){console.warn(c)}return a.getView()};function fe(e){const{editor:t,component:n,window:s,frameView:r,config:o,onMount:a}=e,c=s.document,i=o.rootComponent||h.Fragment,u=o.rootComponent?{editorProps:{doc:c,editor:t,frameView:r}}:{},d=(o==null?void 0:o.bodyAfter)||h.Fragment;return y.jsx(i,{...u,children:y.jsx(I,{tagName:"div",component:n,config:o,editor:t,frameView:r,onMount:a,children:y.jsx(d,{...u})})})}const de="rendererReact",me=v.startup,ye=function(e,t={}){const{Blocks:n,Pages:s}=e,r=n.events,o=s.events;e.Canvas.config.customRenderer=c=>ue({...c,config:t}),e.Components.config.processor=c=>E({model:c,editor:e,config:t}),pe(e,t);const a=[[r.add,ce({editor:e,config:t})],[o.addBefore,ae({editor:e,config:t})]];a.forEach(([c,i])=>e.on(c,i)),Z({editor:e,licenseKey:t.licenseKey,plan:me,pluginName:de,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,a.forEach(([c,i])=>e.off(c,i))}})},he=H(ye);module.exports=he;
|
|
1
|
+
"use strict";const y=require("react/jsx-runtime"),h=require("react"),M=require("react-dom/client"),C="app.grapesjs.com",G="app-stage.grapesjs.com",_="app2.grapesjs.com",F="app-stage2.grapesjs.com",D=[C,_,G,F,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],W="license:check:end",$=()=>typeof window<"u",S=({isDev:e,isStage:t,isPlatform:o})=>`${e?"":`https://${t?G:C}`}/${o?"platform-api":"api"}`,K=()=>{const e=$()&&window.location.hostname;return!!e&&(D.includes(e)||D.some(t=>e.endsWith(t)))},V=e=>e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(t,o)=>(o?"-":"")+t.toLowerCase()),N=e=>typeof e=="string";function z(e){return typeof e=="function"}async function q({path:e,baseApiUrl:t,method:o="GET",headers:s={},params:r,body:n}){const a=`${t||S({isDev:!1,isStage:!1})}${e}`,c={method:o,headers:{"Content-Type":"application/json",...s}};n&&(c.body=JSON.stringify(n));const u=r?new URLSearchParams(r).toString():"",d=u?`?${u}`:"",p=await fetch(`${a}${d}`,c);if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);return p.json()}var b=(e=>(e.free="free",e.startup="startup",e.business="business",e.enterprise="enterprise",e))(b||{}),x=(e=>(e.toastAdd="studio:toastAdd",e.toastRemove="studio:toastRemove",e.dialogOpen="studio:dialogOpen",e.dialogClose="studio:dialogClose",e.dialogExportCode="studio:dialogExportCode",e.dialogImportCode="studio:dialogImportCode",e.sidebarLeftSet="studio:sidebarLeft:set",e.sidebarLeftGet="studio:sidebarLeft:get",e.sidebarLeftToggle="studio:sidebarLeft:toggle",e.sidebarRightSet="studio:sidebarRight:set",e.sidebarRightGet="studio:sidebarRight:get",e.sidebarRightToggle="studio:sidebarRight:toggle",e.sidebarTopSet="studio:sidebarTop:set",e.sidebarTopGet="studio:sidebarTop:get",e.sidebarTopToggle="studio:sidebarTop:toggle",e.sidebarBottomSet="studio:sidebarBottom:set",e.sidebarBottomGet="studio:sidebarBottom:get",e.sidebarBottomToggle="studio:sidebarBottom:toggle",e.symbolAdd="studio:symbolAdd",e.symbolDetach="studio:symbolDetach",e.symbolOverride="studio:symbolOverride",e.symbolPropagateStyles="studio:propagateStyles",e.getPagesConfig="studio:getPagesConfig",e.setPagesConfig="studio:setPagesConfig",e.getPageSettings="studio:getPageSettings",e.setPageSettings="studio:setPageSettings",e.clearPage="studio:clearPage",e.projectFiles="studio:projectFiles",e.validateCode="studio:validateCode",e.canvasReload="studio:canvasReload",e.getBlocksPanel="studio:getBlocksPanel",e.setBlocksPanel="studio:setBlocksPanel",e.getStateContextMenu="studio:getStateContextMenu",e.setStateContextMenu="studio:setStateContextMenu",e.contextMenuComponent="studio:contextMenuComponent",e.layoutAdd="studio:layoutAdd",e.layoutRemove="studio:layoutRemove",e.layoutToggle="studio:layoutToggle",e.layoutUpdate="studio:layoutUpdate",e.layoutGet="studio:layoutGet",e.layoutConfigGet="studio:layoutConfigGet",e.layoutConfigSet="studio:layoutConfigSet",e.layoutComponentAdd="studio:layoutComponentAdd",e.layoutComponentGet="studio:layoutComponentGet",e.layoutComponentRemove="studio:layoutComponentRemove",e.layoutComponentRender="studio:layoutComponentRender",e.getStateTheme="studio:getStateTheme",e.setStateTheme="studio:setStateTheme",e.settings="studio:settings",e.assetProviderGet="studio:assetProviderGet",e.assetProviderAdd="studio:assetProviderAdd",e.assetProviderRemove="studio:assetProviderRemove",e.fontGet="studio:fontGet",e.fontAdd="studio:fontAdd",e.fontRemove="studio:fontRemove",e.fontManagerOpen="studio:fontManagerOpen",e.menuFontLoad="studio:menuFontLoad",e.toggleStateDataSource="studio:toggleStateDataSource",e.getStateDataSource="studio:getStateDataSource",e.dataSourceSetGlobalData="studio:dataSourceSetGlobalData",e.dataSourceSetImporter="studio:dataSourceSetImporter",e.dataSourceSetExporter="studio:dataSourceSetExporter",e.setDragAbsolute="studio:setDragAbsolute",e))(x||{});const L={[b.free]:0,[b.startup]:10,[b.business]:20,[b.enterprise]:30};function J(e){const t=e;return t.init=o=>s=>e(s,o),t}const H=e=>J(e);async function Z({editor:e,plan:t,pluginName:o,licenseKey:s,onLicenseCheckResponse:r,cleanup:n}){let i="",a;const c=p=>{console.warn("Cleanup plugin:",o,"Reason:",p),n()},u=(p={})=>{var w;const{error:g,sdkLicense:f}=p,l=(w=p.plan)==null?void 0:w.category;if(!(f||p.license)||g)c(g||"Invalid license");else if(l){const R=L[t],A=L[l];R>A&&c({pluginRequiredPlan:t,licensePlan:l})}};e.Commands.has(x.settings)&&(a=e.runCommand(x.settings),i=(a==null?void 0:a.baseUrl)||"");const d=p=>{r==null||r(p),p&&u(p)};if(!a){e.onReady(async()=>{if(!K())if(s){const p=await X({licenseKey:s,pluginName:o,baseApiUrl:i});d(p)}else c("The `licenseKey` option not provided")});return}if(a.licensePlan||a.licenseError){const p=Q(a);d(p);return}e.on(W,p=>d(p))}const Q=e=>({sdkLicense:e.license,license:e.license,error:e.licenseError,plan:e.licensePlan});async function X(e){const{licenseKey:t,pluginName:o,baseApiUrl:s}=e;try{return(await q({baseApiUrl:s,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:o}})).result||{}}catch(r){return console.error("Error during SDK license check:",r),!1}}function Y(e){const t={};for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const s=V(o);t[s]=e[o]}return t}const ee=(e,t)=>{const o=e.components||{};for(const s in o){const r=o[s];if(r.component===t)return{cmpConfig:r,type:s}}};function j(e){const t={};let o=!1;for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const r=e[s];if(typeof r=="string"||typeof r=="number"){const n=s.includes("-")?s.replace(/-([a-z])/g,i=>i[1].toUpperCase()):s;t[n]=r,o=!0}}return o?t:void 0}function te(e){const t={};return e.split(";").forEach(o=>{if(!o.trim())return;const s=o.indexOf(":");if(s>0){const r=o.substring(0,s).trim(),n=o.substring(s+1).trim();if(r&&n){const i=r.replace(/-([a-z])/g,a=>a[1].toUpperCase());t[i]=n}}}),Object.keys(t).length>0?t:void 0}function oe(e){if(e){if(typeof e=="object"&&!Array.isArray(e))return j(e);if(typeof e=="string"){let t=te(e);if(!t)try{const o=JSON.parse(e);typeof o=="object"&&o!==null&&!Array.isArray(o)&&(t=j(o))}catch(o){console.error("Failed to parse style string as JSON",o)}return t}if(Array.isArray(e)){const t={};return e.forEach(o=>{if(typeof o=="object"&&o!==null){const s=o.name||o.property,r=o.value;if(typeof s=="string"&&s&&r!==void 0&&r!==""){const n=s.replace(/-([a-z])/g,i=>i[1].toUpperCase());t[n]=r}}}),Object.keys(t).length>0?t:void 0}}}function ne(e){return B[e]?B[e]:e.includes("-")?e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase()):e}function se(e){var o;const t={};for(const[s,r]of Object.entries(e))if(s==="style")t.style=oe(r);else if(s.startsWith("data-"))t[s]=r;else{const n=ne(s);((o=e.xmlns)==null?void 0:o.includes("svg"))||e.viewBox!==void 0||e.d!==void 0||ae.has(n)||n.startsWith("svg")?t[n]=r:!re.has(n)&&!n.startsWith("on")&&!n.startsWith("aria-")&&!n.startsWith("data-")?t[s]=r:t[n]=r}return t}const re=new Set(["className","id","style","href","src","alt","title","target","rel","type","name","value","placeholder","onClick","onChange","onSubmit","onBlur","onFocus","disabled","readOnly","checked","selected","multiple","width","height","maxLength","min","max","step","rows","cols","autoComplete","autoFocus","required","spellCheck","tabIndex","aria-label","aria-labelledby","aria-describedby","role"]),ae=new Set(["x","y","d","cx","cy","r","rx","ry","x1","x2","y1","y2","points","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","strokeDasharray","strokeOpacity","fillOpacity","fillRule","clipRule","transform","viewBox","preserveAspectRatio","pathLength","vectorEffect","dominantBaseline","alignmentBaseline","textAnchor","fontFamily","fontSize","fontStyle","fontWeight","textDecoration","baselineShift","opacity","mask","clipPath","overflow","pointerEvents"]),B={class:"className",for:"htmlFor","http-equiv":"httpEquiv","accept-charset":"acceptCharset","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","fill-rule":"fillRule","clip-rule":"clipRule","stroke-miterlimit":"strokeMiterlimit","stroke-dasharray":"strokeDasharray","stroke-opacity":"strokeOpacity","fill-opacity":"fillOpacity","font-family":"fontFamily","font-size":"fontSize","text-anchor":"textAnchor"},T=e=>(e==null?void 0:e.$$typeof)&&typeof e.props=="object";function ie(e){return t=>{const o=t.getContent();T(o)&&t.set({content:P({...e,model:o}),reactContent:o})}}const ce=e=>t=>{const o=t.component;T(o)&&(t.component={components:P({...e,model:o})})};function P(e){const{model:t,editor:o,config:s}=e;if(T(t)){const r=t,n={},{type:i,props:a={}}=r,{children:c,className:u,style:d,...p}=a,g=l=>({type:"textnode",content:l}),f=typeof i=="symbol";if(z(i)){const l=ee(s,i);n.type=l==null?void 0:l.type}else o.Components.getType(i)?n.type=i:f||(n.tagName=i);if(u&&(n.classes=u),d&&(n.style=Y(d)),Array.isArray(c)?n.components=c.map(l=>N(l)?g(l):P({...e,model:l})).filter(Boolean):N(c)&&(n.components=g(c)),Object.keys(p).length){const l=o.Parser.parserHtml.splitPropsFromAttr(p);n.attributes=l.attrs,Object.assign(n,l.props)}return n}}function le(e){const{component:t}=e,[o,s]=h.useState(0),[r,n]=h.useState();return h.useEffect(()=>{if(!t)return()=>{};const a=()=>s(l=>l+1),c=()=>{[...t.views].forEach(m=>m.remove()),n(void 0)},{em:u}=t,d=u.Components.events,g=[...["components","attributes","classes"].map(l=>`${d.update}:${l}`),"rerender"].join(" "),f=[d.removed,"rerender"].join(" ");return t.on(g,a),t.on(f,c),()=>{t.off(g,a),t.off(f,c),c()}},[t]),{key:o,view:r,connectDom:a=>{if(!a)return;const c=pe({...e,el:a});n(c)}}}function pe(e){var c;const{editor:t,component:o,el:s,frameView:r}=e,{em:n,Components:i}=t;let a=o.getView(r.model);if((a==null?void 0:a.el)===s)return a;if(!a){const{ComponentView:u}=i,d=o.attributes.type||"default",p=((c=i.getType(d))==null?void 0:c.view)||u,g={...i.config,frameView:r,em:n},f=p.extend({initComponents(){},_createElement(){return s},_removeElement(){},__clearAttributes(){},render(){var l;return this._ensureElement(),this._setData(),this.renderAttributes(),(l=this.updateSrc)==null||l.call(this),this}});a=new f({el:s,config:g,model:o})}return a.el=s,a.render(),a}function ue(e,t){const{Components:o}=e,s=r=>{const{id:n,model:i}=r;o.addType(n,{model:{toJSON(...a){const c=i.prototype.toJSON.apply(this,a);return c.tagName=this.tagName,c}}})};o.getTypes().forEach(s),e.on("component:type:add",s),Object.entries(t.components||{}).forEach(([r,n])=>{var g,f;const{allowPropClassName:i,allowPropId:a,allowChildren:c}=n,u=!a&&!i,d=()=>({disabled:u}),p=()=>({disableClasses:!i,disableComponent:!a});o.addType(r,{isComponent:l=>(l==null?void 0:l.tagName)===r,model:{defaults:{type:r,traits:((g=n.props)==null?void 0:g.call(n))||[],droppable:!!c,stylable:!u,styleManager:d,selectorManager:p,...((f=n.model)==null?void 0:f.defaults)||{}}}})})}function I(e){var O;const{component:t,config:o,editor:s,frameView:r,onMount:n,tagName:i,children:a}=e,{key:c,view:u,connectDom:d}=le(e);h.useEffect(()=>{if(!u&&!n)return;const v=setTimeout(()=>{u&&(n==null||n(u),setTimeout(()=>u.postRender()))});return()=>clearTimeout(v)},[u]);const p=t.get("type")||"default",g=t.content,f=(O=o.components)==null?void 0:O[p],l=(f==null?void 0:f.component)||i||t.tagName||"div",m=t.components(),w=m.length?m.map(v=>y.jsx(I,{component:v,config:o,editor:s,frameView:r},v.cid)):[g||void 0],R=se(t.getAttributes()),A=f==null?void 0:f.editorRender,E=[...w,a].filter(v=>v??!1),k=E.length?E:null;if(A)return y.jsx(A,{props:R,editor:s,component:t,connectDom:d,children:k});if(f!=null&&f.component)return y.jsx("gjs-wrapper",{ref:d,style:f.wrapperStyle,children:y.jsx(l,{...R,children:k})});if(t.isInstanceOf("textnode"))return g;const U=t.isInstanceOf("text")?c:void 0;return h.createElement(l,{...R,ref:d,key:U},t.get("void")?null:k)}const fe=e=>{const{frame:t,window:o,onMount:s,editor:r}=e,n=r.Canvas.events,{root:i}=t;try{const a=M.createRoot(o.document.body);a.render(y.jsx(de,{...e,component:i,onMount:s}));const c=()=>a.unmount();t.once(n.frameUnload,c),o.addEventListener("unload",c)}catch(a){console.warn(a)}return i.getView()};function de(e){const{editor:t,component:o,window:s,frameView:r,config:n,onMount:i}=e,a=s.document,c=n.rootComponent||h.Fragment,u=n.rootComponent?{editorProps:{doc:a,editor:t,frameView:r}}:{},d=(n==null?void 0:n.bodyAfter)||h.Fragment;return y.jsx(c,{...u,children:y.jsx(I,{tagName:"div",component:o,config:n,editor:t,frameView:r,onMount:i,children:y.jsx(d,{...u})})})}const ge="rendererReact",ye=b.startup,he=function(e,t={}){const{Blocks:o,Pages:s}=e,r=o.events,n=s.events;e.Canvas.config.customRenderer=a=>fe({...a,config:t}),e.Components.config.processor=a=>P({model:a,editor:e,config:t}),ue(e,t);const i=[[r.add,ie({editor:e,config:t})],[n.addBefore,ce({editor:e,config:t})]];i.forEach(([a,c])=>e.on(a,c)),Z({editor:e,licenseKey:t.licenseKey,plan:ye,pluginName:ge,cleanup:()=>{e.Canvas.config.customRenderer=void 0,e.Components.config.processor=void 0,i.forEach(([a,c])=>e.off(a,c))}})},ve=H(he);module.exports=ve;
|